pages: work in progress [might break]
This commit is contained in:
parent
99f8bd951c
commit
bf57687a24
11 changed files with 192 additions and 164762 deletions
34
dist/xrfragment.aframe.all.js
vendored
34
dist/xrfragment.aframe.all.js
vendored
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* v0.5.1 generated at Fri Jul 12 05:21:08 PM UTC 2024
|
||||
* v0.5.1 generated at Mon Jul 15 02:49:04 PM UTC 2024
|
||||
* https://xrfragment.org
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
|
@ -1188,7 +1188,7 @@ xrfragment_URI.template = function(uri,vars) {
|
|||
};
|
||||
xrfragment_URI.parse = function(stringUrl,flags) {
|
||||
var r = new EReg("^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\\d*))?)(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))(?:\\?([^#]*))?(?:#(.*))?)","");
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/") {
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/" && stringUrl.charAt(0) != "#") {
|
||||
stringUrl = "/" + stringUrl;
|
||||
}
|
||||
r.match(stringUrl);
|
||||
|
|
@ -1372,7 +1372,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
if(url.directory != null) {
|
||||
directory = url.directory;
|
||||
}
|
||||
if(newURI.directory != null) {
|
||||
if(newURI.directory != null && newURI.source.charAt(0) != "#" && newURI.directory.length > 0) {
|
||||
if(newUrl.charAt(0) != "/" && newUrl.indexOf("://") == -1) {
|
||||
var stripRelative_r = new RegExp("\\./.*","".split("u").join(""));
|
||||
directory = directory.replace(stripRelative_r,"");
|
||||
|
|
@ -1382,7 +1382,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
}
|
||||
}
|
||||
resultURI.directory = directory;
|
||||
if(newURI.file != null) {
|
||||
if(newURI.file != null && newURI.file.length > 0) {
|
||||
resultURI.file = newURI.file;
|
||||
} else {
|
||||
resultURI.file = url.file;
|
||||
|
|
@ -1939,6 +1939,7 @@ xrf.loadModel = function(model,url,noadd){
|
|||
let {directory,file,fragment,fileExt} = URI;
|
||||
model.file = URI.file
|
||||
xrf.model = model
|
||||
xrf.scene = model.scene
|
||||
|
||||
if( !model.isXRF ) xrf.parseModel(model,url.replace(directory,"")) // this marks the model as an XRF model
|
||||
|
||||
|
|
@ -2044,6 +2045,9 @@ xrf.navigator.to = (url,flags,loader,data) => {
|
|||
URI.duplicatePos = URI.source == xrf.navigator.URI.source && URI.hasPos
|
||||
URI.hashChange = String(xrf.navigator.URI.fragment||"") != String(URI.fragment||"")
|
||||
let hashbus = xrf.hashbus
|
||||
|
||||
//console.dir({URI1:xrf.navigator.URI,URI2:URI})
|
||||
|
||||
xrf.navigator.URI = URI
|
||||
let {directory,file,fragment,fileExt} = URI;
|
||||
|
||||
|
|
@ -2500,18 +2504,20 @@ xrf.frag.src = function(v, opts){
|
|||
|
||||
if( mesh.isSRC ) return // only embed src once
|
||||
|
||||
// correct for relative urls
|
||||
if( v.string.charAt(0) != '#' && xrf.URI.isRelative( xrf.URI.parse( v.string ) ) ){
|
||||
v.string = xrf.navigator.URI.URN + v.string
|
||||
}
|
||||
|
||||
let url = xrf.frag.src.expandURI( mesh, v.string )
|
||||
let srcFrag = opts.srcFrag = xrfragment.URI.parse(url).XRF
|
||||
|
||||
opts.isLocal = v.string[0] == '#'
|
||||
opts.isPortal = xrf.frag.src.renderAsPortal(mesh)
|
||||
opts.isSRC = mesh.isSRC = true
|
||||
|
||||
// correct for relative urls
|
||||
let url = v.string
|
||||
if( v.string.charAt(0) != '#' && xrf.URI.isRelative( xrf.URI.parse( v.string ) ) ){
|
||||
url = xrf.navigator.URI.URN + v.string
|
||||
}
|
||||
url = xrf.frag.src.expandURI( mesh, url )
|
||||
|
||||
let srcFrag = opts.srcFrag = xrfragment.URI.parse(url).XRF
|
||||
|
||||
|
||||
if(xrf.debug) console.log(`src.js: instancing ${opts.isLocal?'local':'remote'} object ${url}`)
|
||||
|
||||
if( opts.isLocal ){
|
||||
|
|
@ -3224,7 +3230,7 @@ xrf.addEventListener('dynamicKey', (opts) => {
|
|||
|
||||
xrf.addEventListener('navigateLoaded', (opts) => {
|
||||
// select active camera if any
|
||||
let {id,match,v} = opts
|
||||
let {id,match,v,THREE} = opts
|
||||
let envmap = {}
|
||||
let current = ''
|
||||
|
||||
|
|
@ -3241,7 +3247,7 @@ xrf.addEventListener('navigateLoaded', (opts) => {
|
|||
// Update the closest ancestor's material map
|
||||
if (node.isMesh && node.material && node.material.map) {
|
||||
closestAncestorMaterialMap = node.material.map.clone();
|
||||
closestAncestorMaterialMap.mapping = THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.mapping = xrf.THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.needsUpdate = true
|
||||
}
|
||||
|
||||
|
|
|
|||
34
dist/xrfragment.aframe.js
vendored
34
dist/xrfragment.aframe.js
vendored
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* v0.5.1 generated at Fri Jul 12 05:21:08 PM UTC 2024
|
||||
* v0.5.1 generated at Mon Jul 15 02:49:04 PM UTC 2024
|
||||
* https://xrfragment.org
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
|
@ -1186,7 +1186,7 @@ xrfragment_URI.template = function(uri,vars) {
|
|||
};
|
||||
xrfragment_URI.parse = function(stringUrl,flags) {
|
||||
var r = new EReg("^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\\d*))?)(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))(?:\\?([^#]*))?(?:#(.*))?)","");
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/") {
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/" && stringUrl.charAt(0) != "#") {
|
||||
stringUrl = "/" + stringUrl;
|
||||
}
|
||||
r.match(stringUrl);
|
||||
|
|
@ -1370,7 +1370,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
if(url.directory != null) {
|
||||
directory = url.directory;
|
||||
}
|
||||
if(newURI.directory != null) {
|
||||
if(newURI.directory != null && newURI.source.charAt(0) != "#" && newURI.directory.length > 0) {
|
||||
if(newUrl.charAt(0) != "/" && newUrl.indexOf("://") == -1) {
|
||||
var stripRelative_r = new RegExp("\\./.*","".split("u").join(""));
|
||||
directory = directory.replace(stripRelative_r,"");
|
||||
|
|
@ -1380,7 +1380,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
}
|
||||
}
|
||||
resultURI.directory = directory;
|
||||
if(newURI.file != null) {
|
||||
if(newURI.file != null && newURI.file.length > 0) {
|
||||
resultURI.file = newURI.file;
|
||||
} else {
|
||||
resultURI.file = url.file;
|
||||
|
|
@ -1937,6 +1937,7 @@ xrf.loadModel = function(model,url,noadd){
|
|||
let {directory,file,fragment,fileExt} = URI;
|
||||
model.file = URI.file
|
||||
xrf.model = model
|
||||
xrf.scene = model.scene
|
||||
|
||||
if( !model.isXRF ) xrf.parseModel(model,url.replace(directory,"")) // this marks the model as an XRF model
|
||||
|
||||
|
|
@ -2042,6 +2043,9 @@ xrf.navigator.to = (url,flags,loader,data) => {
|
|||
URI.duplicatePos = URI.source == xrf.navigator.URI.source && URI.hasPos
|
||||
URI.hashChange = String(xrf.navigator.URI.fragment||"") != String(URI.fragment||"")
|
||||
let hashbus = xrf.hashbus
|
||||
|
||||
//console.dir({URI1:xrf.navigator.URI,URI2:URI})
|
||||
|
||||
xrf.navigator.URI = URI
|
||||
let {directory,file,fragment,fileExt} = URI;
|
||||
|
||||
|
|
@ -2498,18 +2502,20 @@ xrf.frag.src = function(v, opts){
|
|||
|
||||
if( mesh.isSRC ) return // only embed src once
|
||||
|
||||
// correct for relative urls
|
||||
if( v.string.charAt(0) != '#' && xrf.URI.isRelative( xrf.URI.parse( v.string ) ) ){
|
||||
v.string = xrf.navigator.URI.URN + v.string
|
||||
}
|
||||
|
||||
let url = xrf.frag.src.expandURI( mesh, v.string )
|
||||
let srcFrag = opts.srcFrag = xrfragment.URI.parse(url).XRF
|
||||
|
||||
opts.isLocal = v.string[0] == '#'
|
||||
opts.isPortal = xrf.frag.src.renderAsPortal(mesh)
|
||||
opts.isSRC = mesh.isSRC = true
|
||||
|
||||
// correct for relative urls
|
||||
let url = v.string
|
||||
if( v.string.charAt(0) != '#' && xrf.URI.isRelative( xrf.URI.parse( v.string ) ) ){
|
||||
url = xrf.navigator.URI.URN + v.string
|
||||
}
|
||||
url = xrf.frag.src.expandURI( mesh, url )
|
||||
|
||||
let srcFrag = opts.srcFrag = xrfragment.URI.parse(url).XRF
|
||||
|
||||
|
||||
if(xrf.debug) console.log(`src.js: instancing ${opts.isLocal?'local':'remote'} object ${url}`)
|
||||
|
||||
if( opts.isLocal ){
|
||||
|
|
@ -3222,7 +3228,7 @@ xrf.addEventListener('dynamicKey', (opts) => {
|
|||
|
||||
xrf.addEventListener('navigateLoaded', (opts) => {
|
||||
// select active camera if any
|
||||
let {id,match,v} = opts
|
||||
let {id,match,v,THREE} = opts
|
||||
let envmap = {}
|
||||
let current = ''
|
||||
|
||||
|
|
@ -3239,7 +3245,7 @@ xrf.addEventListener('navigateLoaded', (opts) => {
|
|||
// Update the closest ancestor's material map
|
||||
if (node.isMesh && node.material && node.material.map) {
|
||||
closestAncestorMaterialMap = node.material.map.clone();
|
||||
closestAncestorMaterialMap.mapping = THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.mapping = xrf.THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.needsUpdate = true
|
||||
}
|
||||
|
||||
|
|
|
|||
6
dist/xrfragment.js
vendored
6
dist/xrfragment.js
vendored
|
|
@ -1181,7 +1181,7 @@ xrfragment_URI.template = function(uri,vars) {
|
|||
};
|
||||
xrfragment_URI.parse = function(stringUrl,flags) {
|
||||
var r = new EReg("^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\\d*))?)(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))(?:\\?([^#]*))?(?:#(.*))?)","");
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/") {
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/" && stringUrl.charAt(0) != "#") {
|
||||
stringUrl = "/" + stringUrl;
|
||||
}
|
||||
r.match(stringUrl);
|
||||
|
|
@ -1365,7 +1365,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
if(url.directory != null) {
|
||||
directory = url.directory;
|
||||
}
|
||||
if(newURI.directory != null) {
|
||||
if(newURI.directory != null && newURI.source.charAt(0) != "#" && newURI.directory.length > 0) {
|
||||
if(newUrl.charAt(0) != "/" && newUrl.indexOf("://") == -1) {
|
||||
var stripRelative_r = new RegExp("\\./.*","".split("u").join(""));
|
||||
directory = directory.replace(stripRelative_r,"");
|
||||
|
|
@ -1375,7 +1375,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
}
|
||||
}
|
||||
resultURI.directory = directory;
|
||||
if(newURI.file != null) {
|
||||
if(newURI.file != null && newURI.file.length > 0) {
|
||||
resultURI.file = newURI.file;
|
||||
} else {
|
||||
resultURI.file = url.file;
|
||||
|
|
|
|||
6
dist/xrfragment.lua
vendored
6
dist/xrfragment.lua
vendored
|
|
@ -2590,7 +2590,7 @@ __xrfragment_URI.template = function(uri,vars)
|
|||
end
|
||||
__xrfragment_URI.parse = function(stringUrl,flags)
|
||||
local r = EReg.new("^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\\d*))?)(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))(?:\\?([^#]*))?(?:#(.*))?)", "");
|
||||
if ((String.prototype.indexOf(stringUrl, "://") == -1) and (__lua_lib_luautf8_Utf8.sub(stringUrl, 1, 1) ~= "/")) then
|
||||
if (((String.prototype.indexOf(stringUrl, "://") == -1) and (__lua_lib_luautf8_Utf8.sub(stringUrl, 1, 1) ~= "/")) and (__lua_lib_luautf8_Utf8.sub(stringUrl, 1, 1) ~= "#")) then
|
||||
stringUrl = Std.string("/") .. Std.string(stringUrl);
|
||||
end;
|
||||
r:match(stringUrl);
|
||||
|
|
@ -2785,7 +2785,7 @@ __xrfragment_URI.toAbsolute = function(url,newUrl)
|
|||
if (url.directory ~= nil) then
|
||||
directory = url.directory;
|
||||
end;
|
||||
if (newURI.directory ~= nil) then
|
||||
if (((newURI.directory ~= nil) and (__lua_lib_luautf8_Utf8.sub(newURI.source, 1, 1) ~= "#")) and (__lua_lib_luautf8_Utf8.len(newURI.directory) > 0)) then
|
||||
if ((__lua_lib_luautf8_Utf8.sub(newUrl, 1, 1) ~= "/") and (String.prototype.indexOf(newUrl, "://") == -1)) then
|
||||
local stripRelative = EReg.new("\\./.*", "");
|
||||
directory = stripRelative:replace(directory, "");
|
||||
|
|
@ -2795,7 +2795,7 @@ __xrfragment_URI.toAbsolute = function(url,newUrl)
|
|||
end;
|
||||
end;
|
||||
resultURI.directory = directory;
|
||||
if (newURI.file ~= nil) then
|
||||
if ((newURI.file ~= nil) and (__lua_lib_luautf8_Utf8.len(newURI.file) > 0)) then
|
||||
resultURI.file = newURI.file;
|
||||
else
|
||||
resultURI.file = url.file;
|
||||
|
|
|
|||
164599
dist/xrfragment.module.js
vendored
164599
dist/xrfragment.module.js
vendored
File diff suppressed because it is too large
Load diff
10
dist/xrfragment.py
vendored
10
dist/xrfragment.py
vendored
|
|
@ -2318,7 +2318,7 @@ class xrfragment_URI:
|
|||
def parse(stringUrl,flags):
|
||||
r = EReg("^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\\d*))?)(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))(?:\\?([^#]*))?(?:#(.*))?)","")
|
||||
startIndex = None
|
||||
if ((((stringUrl.find("://") if ((startIndex is None)) else HxString.indexOfImpl(stringUrl,"://",startIndex))) == -1) and (((("" if ((0 >= len(stringUrl))) else stringUrl[0])) != "/"))):
|
||||
if (((((stringUrl.find("://") if ((startIndex is None)) else HxString.indexOfImpl(stringUrl,"://",startIndex))) == -1) and (((("" if ((0 >= len(stringUrl))) else stringUrl[0])) != "/"))) and (((("" if ((0 >= len(stringUrl))) else stringUrl[0])) != "#"))):
|
||||
stringUrl = ("/" + ("null" if stringUrl is None else stringUrl))
|
||||
r.matchObj = python_lib_Re.search(r.pattern,stringUrl)
|
||||
url = xrfragment_URI()
|
||||
|
|
@ -2495,7 +2495,13 @@ class xrfragment_URI:
|
|||
directory = ""
|
||||
if (url.directory is not None):
|
||||
directory = url.directory
|
||||
tmp = None
|
||||
if (newURI.directory is not None):
|
||||
_this = newURI.source
|
||||
tmp = ((("" if ((0 >= len(_this))) else _this[0])) != "#")
|
||||
else:
|
||||
tmp = False
|
||||
if (tmp and ((len(newURI.directory) > 0))):
|
||||
tmp = None
|
||||
if ((("" if ((0 >= len(newUrl))) else newUrl[0])) != "/"):
|
||||
startIndex = None
|
||||
|
|
@ -2509,7 +2515,7 @@ class xrfragment_URI:
|
|||
else:
|
||||
directory = newURI.directory
|
||||
resultURI.directory = directory
|
||||
if (newURI.file is not None):
|
||||
if ((newURI.file is not None) and ((len(newURI.file) > 0))):
|
||||
resultURI.file = newURI.file
|
||||
else:
|
||||
resultURI.file = url.file
|
||||
|
|
|
|||
34
dist/xrfragment.three.js
vendored
34
dist/xrfragment.three.js
vendored
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* v0.5.1 generated at Fri Jul 12 05:21:08 PM UTC 2024
|
||||
* v0.5.1 generated at Mon Jul 15 02:49:04 PM UTC 2024
|
||||
* https://xrfragment.org
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
|
@ -1186,7 +1186,7 @@ xrfragment_URI.template = function(uri,vars) {
|
|||
};
|
||||
xrfragment_URI.parse = function(stringUrl,flags) {
|
||||
var r = new EReg("^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\\d*))?)(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))(?:\\?([^#]*))?(?:#(.*))?)","");
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/") {
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/" && stringUrl.charAt(0) != "#") {
|
||||
stringUrl = "/" + stringUrl;
|
||||
}
|
||||
r.match(stringUrl);
|
||||
|
|
@ -1370,7 +1370,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
if(url.directory != null) {
|
||||
directory = url.directory;
|
||||
}
|
||||
if(newURI.directory != null) {
|
||||
if(newURI.directory != null && newURI.source.charAt(0) != "#" && newURI.directory.length > 0) {
|
||||
if(newUrl.charAt(0) != "/" && newUrl.indexOf("://") == -1) {
|
||||
var stripRelative_r = new RegExp("\\./.*","".split("u").join(""));
|
||||
directory = directory.replace(stripRelative_r,"");
|
||||
|
|
@ -1380,7 +1380,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
}
|
||||
}
|
||||
resultURI.directory = directory;
|
||||
if(newURI.file != null) {
|
||||
if(newURI.file != null && newURI.file.length > 0) {
|
||||
resultURI.file = newURI.file;
|
||||
} else {
|
||||
resultURI.file = url.file;
|
||||
|
|
@ -1937,6 +1937,7 @@ xrf.loadModel = function(model,url,noadd){
|
|||
let {directory,file,fragment,fileExt} = URI;
|
||||
model.file = URI.file
|
||||
xrf.model = model
|
||||
xrf.scene = model.scene
|
||||
|
||||
if( !model.isXRF ) xrf.parseModel(model,url.replace(directory,"")) // this marks the model as an XRF model
|
||||
|
||||
|
|
@ -2042,6 +2043,9 @@ xrf.navigator.to = (url,flags,loader,data) => {
|
|||
URI.duplicatePos = URI.source == xrf.navigator.URI.source && URI.hasPos
|
||||
URI.hashChange = String(xrf.navigator.URI.fragment||"") != String(URI.fragment||"")
|
||||
let hashbus = xrf.hashbus
|
||||
|
||||
//console.dir({URI1:xrf.navigator.URI,URI2:URI})
|
||||
|
||||
xrf.navigator.URI = URI
|
||||
let {directory,file,fragment,fileExt} = URI;
|
||||
|
||||
|
|
@ -2498,18 +2502,20 @@ xrf.frag.src = function(v, opts){
|
|||
|
||||
if( mesh.isSRC ) return // only embed src once
|
||||
|
||||
// correct for relative urls
|
||||
if( v.string.charAt(0) != '#' && xrf.URI.isRelative( xrf.URI.parse( v.string ) ) ){
|
||||
v.string = xrf.navigator.URI.URN + v.string
|
||||
}
|
||||
|
||||
let url = xrf.frag.src.expandURI( mesh, v.string )
|
||||
let srcFrag = opts.srcFrag = xrfragment.URI.parse(url).XRF
|
||||
|
||||
opts.isLocal = v.string[0] == '#'
|
||||
opts.isPortal = xrf.frag.src.renderAsPortal(mesh)
|
||||
opts.isSRC = mesh.isSRC = true
|
||||
|
||||
// correct for relative urls
|
||||
let url = v.string
|
||||
if( v.string.charAt(0) != '#' && xrf.URI.isRelative( xrf.URI.parse( v.string ) ) ){
|
||||
url = xrf.navigator.URI.URN + v.string
|
||||
}
|
||||
url = xrf.frag.src.expandURI( mesh, url )
|
||||
|
||||
let srcFrag = opts.srcFrag = xrfragment.URI.parse(url).XRF
|
||||
|
||||
|
||||
if(xrf.debug) console.log(`src.js: instancing ${opts.isLocal?'local':'remote'} object ${url}`)
|
||||
|
||||
if( opts.isLocal ){
|
||||
|
|
@ -3222,7 +3228,7 @@ xrf.addEventListener('dynamicKey', (opts) => {
|
|||
|
||||
xrf.addEventListener('navigateLoaded', (opts) => {
|
||||
// select active camera if any
|
||||
let {id,match,v} = opts
|
||||
let {id,match,v,THREE} = opts
|
||||
let envmap = {}
|
||||
let current = ''
|
||||
|
||||
|
|
@ -3239,7 +3245,7 @@ xrf.addEventListener('navigateLoaded', (opts) => {
|
|||
// Update the closest ancestor's material map
|
||||
if (node.isMesh && node.material && node.material.map) {
|
||||
closestAncestorMaterialMap = node.material.map.clone();
|
||||
closestAncestorMaterialMap.mapping = THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.mapping = xrf.THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.needsUpdate = true
|
||||
}
|
||||
|
||||
|
|
|
|||
34
dist/xrfragment.three.module.js
vendored
34
dist/xrfragment.three.module.js
vendored
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* v0.5.1 generated at Fri Jul 12 05:21:08 PM UTC 2024
|
||||
* v0.5.1 generated at Mon Jul 15 02:49:04 PM UTC 2024
|
||||
* https://xrfragment.org
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
|
@ -1186,7 +1186,7 @@ xrfragment_URI.template = function(uri,vars) {
|
|||
};
|
||||
xrfragment_URI.parse = function(stringUrl,flags) {
|
||||
var r = new EReg("^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\\d*))?)(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))(?:\\?([^#]*))?(?:#(.*))?)","");
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/") {
|
||||
if(stringUrl.indexOf("://") == -1 && stringUrl.charAt(0) != "/" && stringUrl.charAt(0) != "#") {
|
||||
stringUrl = "/" + stringUrl;
|
||||
}
|
||||
r.match(stringUrl);
|
||||
|
|
@ -1370,7 +1370,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
if(url.directory != null) {
|
||||
directory = url.directory;
|
||||
}
|
||||
if(newURI.directory != null) {
|
||||
if(newURI.directory != null && newURI.source.charAt(0) != "#" && newURI.directory.length > 0) {
|
||||
if(newUrl.charAt(0) != "/" && newUrl.indexOf("://") == -1) {
|
||||
var stripRelative_r = new RegExp("\\./.*","".split("u").join(""));
|
||||
directory = directory.replace(stripRelative_r,"");
|
||||
|
|
@ -1380,7 +1380,7 @@ xrfragment_URI.toAbsolute = function(url,newUrl) {
|
|||
}
|
||||
}
|
||||
resultURI.directory = directory;
|
||||
if(newURI.file != null) {
|
||||
if(newURI.file != null && newURI.file.length > 0) {
|
||||
resultURI.file = newURI.file;
|
||||
} else {
|
||||
resultURI.file = url.file;
|
||||
|
|
@ -1937,6 +1937,7 @@ xrf.loadModel = function(model,url,noadd){
|
|||
let {directory,file,fragment,fileExt} = URI;
|
||||
model.file = URI.file
|
||||
xrf.model = model
|
||||
xrf.scene = model.scene
|
||||
|
||||
if( !model.isXRF ) xrf.parseModel(model,url.replace(directory,"")) // this marks the model as an XRF model
|
||||
|
||||
|
|
@ -2042,6 +2043,9 @@ xrf.navigator.to = (url,flags,loader,data) => {
|
|||
URI.duplicatePos = URI.source == xrf.navigator.URI.source && URI.hasPos
|
||||
URI.hashChange = String(xrf.navigator.URI.fragment||"") != String(URI.fragment||"")
|
||||
let hashbus = xrf.hashbus
|
||||
|
||||
//console.dir({URI1:xrf.navigator.URI,URI2:URI})
|
||||
|
||||
xrf.navigator.URI = URI
|
||||
let {directory,file,fragment,fileExt} = URI;
|
||||
|
||||
|
|
@ -2498,18 +2502,20 @@ xrf.frag.src = function(v, opts){
|
|||
|
||||
if( mesh.isSRC ) return // only embed src once
|
||||
|
||||
// correct for relative urls
|
||||
if( v.string.charAt(0) != '#' && xrf.URI.isRelative( xrf.URI.parse( v.string ) ) ){
|
||||
v.string = xrf.navigator.URI.URN + v.string
|
||||
}
|
||||
|
||||
let url = xrf.frag.src.expandURI( mesh, v.string )
|
||||
let srcFrag = opts.srcFrag = xrfragment.URI.parse(url).XRF
|
||||
|
||||
opts.isLocal = v.string[0] == '#'
|
||||
opts.isPortal = xrf.frag.src.renderAsPortal(mesh)
|
||||
opts.isSRC = mesh.isSRC = true
|
||||
|
||||
// correct for relative urls
|
||||
let url = v.string
|
||||
if( v.string.charAt(0) != '#' && xrf.URI.isRelative( xrf.URI.parse( v.string ) ) ){
|
||||
url = xrf.navigator.URI.URN + v.string
|
||||
}
|
||||
url = xrf.frag.src.expandURI( mesh, url )
|
||||
|
||||
let srcFrag = opts.srcFrag = xrfragment.URI.parse(url).XRF
|
||||
|
||||
|
||||
if(xrf.debug) console.log(`src.js: instancing ${opts.isLocal?'local':'remote'} object ${url}`)
|
||||
|
||||
if( opts.isLocal ){
|
||||
|
|
@ -3222,7 +3228,7 @@ xrf.addEventListener('dynamicKey', (opts) => {
|
|||
|
||||
xrf.addEventListener('navigateLoaded', (opts) => {
|
||||
// select active camera if any
|
||||
let {id,match,v} = opts
|
||||
let {id,match,v,THREE} = opts
|
||||
let envmap = {}
|
||||
let current = ''
|
||||
|
||||
|
|
@ -3239,7 +3245,7 @@ xrf.addEventListener('navigateLoaded', (opts) => {
|
|||
// Update the closest ancestor's material map
|
||||
if (node.isMesh && node.material && node.material.map) {
|
||||
closestAncestorMaterialMap = node.material.map.clone();
|
||||
closestAncestorMaterialMap.mapping = THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.mapping = xrf.THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.needsUpdate = true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
<model-viewer
|
||||
src="./../assets/index.glb"
|
||||
environment-image="https://cdn.glitch.global/8e507517-31ff-4aa5-80c1-10ea6de9483d/white_furnace.hdr"
|
||||
ar alt="XR Fragments demo scene"camera-controls touch-action="none" disable-tap
|
||||
field-of-view="80deg" min-field-of-view="25deg" max-field-of-view="100deg"
|
||||
interpolation-decay="200" camera-target="0m 0m 0m" min-camera-orbit="0.1% 0.1% 0.1%"
|
||||
|
|
@ -21,141 +20,76 @@
|
|||
>
|
||||
</model-viewer>
|
||||
|
||||
<script src="./../../dist/xrfragment.js"></script>
|
||||
<script src="./../../dist/xrfragment.aframe.all.js"></script>
|
||||
<script>
|
||||
const mv = window.mv = document.querySelector("model-viewer");
|
||||
const $url = document.querySelector('#url')
|
||||
const orbitDefault = '50deg 90deg 1.0m'
|
||||
const panOffset = 1.6
|
||||
const enableXRF = (mv) => {
|
||||
console.dir(mv)
|
||||
|
||||
function getSymbol(name) {
|
||||
let opts = {
|
||||
arButton: mv[getSymbol(mv,'arButtonContainer')],
|
||||
editButton: null,
|
||||
}
|
||||
|
||||
overrideARButton(opts)
|
||||
createEditButton(opts)
|
||||
|
||||
console.dir(opts)
|
||||
}
|
||||
|
||||
const overrideARButton = (opts) => {
|
||||
const arButton = opts.arButton.cloneNode(true)
|
||||
opts.arButton.parentNode.appendChild( arButton )
|
||||
opts.arButton.remove()
|
||||
opts.arButton = arButton
|
||||
opts.arButton.addEventListener('click', () => alert("hoi"))
|
||||
}
|
||||
|
||||
const createEditButton = (opts) => {
|
||||
opts.editButton = opts.arButton.querySelector('a').cloneNode(true)
|
||||
opts.editButton.innerHTML = `
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M21.2635 2.29289C20.873 1.90237 20.2398 1.90237 19.8493 2.29289L18.9769 3.16525C17.8618 2.63254 16.4857 2.82801 15.5621 3.75165L4.95549 14.3582L10.6123 20.0151L21.2189 9.4085C22.1426 8.48486 22.338 7.1088 21.8053 5.99367L22.6777 5.12132C23.0682 4.7308 23.0682 4.09763 22.6777 3.70711L21.2635 2.29289ZM16.9955 10.8035L10.6123 17.1867L7.78392 14.3582L14.1671 7.9751L16.9955 10.8035ZM18.8138 8.98525L19.8047 7.99429C20.1953 7.60376 20.1953 6.9706 19.8047 6.58007L18.3905 5.16586C18 4.77534 17.3668 4.77534 16.9763 5.16586L15.9853 6.15683L18.8138 8.98525Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M2 22.9502L4.12171 15.1717L9.77817 20.8289L2 22.9502Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
`
|
||||
opts.editButton.id = "edit-button"
|
||||
opts.editButton.style.bottom = '16px'
|
||||
opts.editButton.style.left = '16px'
|
||||
opts.editButton.style.color = 'black'
|
||||
opts.editButton.style.position = 'absolute'
|
||||
opts.editButton.addEventListener('click', () => alert("hoi") )
|
||||
opts.arButton.querySelector('a').parentNode.appendChild(opts.editButton)
|
||||
}
|
||||
|
||||
function getSymbol(mv,name) {
|
||||
let obj = mv;
|
||||
do {
|
||||
const sym = Object.getOwnPropertySymbols(obj).find(
|
||||
(x) => x.description === name
|
||||
);
|
||||
if (sym) {
|
||||
return sym;
|
||||
}
|
||||
const sym = Object.getOwnPropertySymbols(obj).find( (x) => x.description === name);
|
||||
if (sym) { return sym; }
|
||||
} while ((obj = Object.getPrototypeOf(obj)));
|
||||
}
|
||||
|
||||
const createHotspot = (pos, n) => {
|
||||
//.name, `${n.userData['aria-description'] || n.name}` )
|
||||
const btn = document.createElement('button')
|
||||
btn.innerText = n.name
|
||||
btn.className = 'view-button'
|
||||
btn.node = n
|
||||
if( n.userData['aria-description']){
|
||||
btn.alt = n.userData['aria-description']
|
||||
btn.setAttribute("aria-description", n.userData['aria-description'])
|
||||
}
|
||||
btn.setAttribute('slot','hotspot-'+n.name)
|
||||
btn.setAttribute('data-normal',"0 0 1")
|
||||
btn.setAttribute('data-position',`${pos.x}m ${pos.y}m ${pos.z}m`)
|
||||
btn.setAttribute('data-target',`${pos.x}m ${pos.y}m ${pos.z}m`)
|
||||
btn.setAttribute('data-orbit', orbitDefault )
|
||||
btn.style.cursor = 'pointer'
|
||||
mv.appendChild(btn)
|
||||
}
|
||||
|
||||
const setupHotspots = (scene) => {
|
||||
scene.traverse( (n) => {
|
||||
if( n.userData.href ){
|
||||
let pos = n.position.clone()
|
||||
n.getWorldPosition(pos)
|
||||
createHotspot(pos, n)
|
||||
}
|
||||
const mvs = [...document.querySelectorAll('model-viewer')]
|
||||
mvs.map( (mv) => {
|
||||
mv.addEventListener('load', () => enableXRF(mv) )
|
||||
// prevent loading in model-viewer mode
|
||||
mv.setAttribute('xrf', mv.src )
|
||||
mv.removeAttribute('src')
|
||||
})
|
||||
setupClicks()
|
||||
}
|
||||
|
||||
const setupClicks = () => {
|
||||
// implement click action
|
||||
const annotationClicked = (annotation) => {
|
||||
let dataset = annotation.dataset;
|
||||
let node = annotation.node
|
||||
mv.cameraTarget = dataset.target;
|
||||
mv.cameraOrbit = dataset.orbit;
|
||||
mv.fieldOfView = '45deg';
|
||||
console.dir(node)
|
||||
if( node && node.userData.href ){
|
||||
//node.userData.XRF.href.exec({type:'click'})
|
||||
console.log("clicked!")
|
||||
}
|
||||
}
|
||||
mv.querySelectorAll('button').forEach((hotspot) => {
|
||||
hotspot.addEventListener('click', () => annotationClicked(hotspot));
|
||||
});
|
||||
}
|
||||
|
||||
const setupDefaultProjection = (scene) => {
|
||||
let defaultStr = scene.userData['#']
|
||||
if( !defaultStr ) return console.warn('no default # fragment found in 3D model')
|
||||
console.log("defaultStr "+defaultStr)
|
||||
let frag = xrf.URI.parse( defaultStr )
|
||||
if( frag.XRF.pos ){
|
||||
let obj = scene.getObjectByName( frag.XRF.pos.string )
|
||||
if( !obj ) return console.error('obj '+frag.XRF.pos.string+" not found")
|
||||
console.log("updating cam")
|
||||
const pos = obj.position.clone()
|
||||
obj.getWorldPosition(pos)
|
||||
pos.y += panOffset
|
||||
mv.cameraTarget = `${pos.x}m ${pos.y}m ${pos.z}m`
|
||||
console.log(`${pos.x} ${pos.y} ${pos.z}`)
|
||||
mv.cameraOrbit = orbitDefault;
|
||||
mv.fieldOfView = '45deg';
|
||||
}
|
||||
}
|
||||
|
||||
const setupCSS = (scene) => {
|
||||
if( document.querySelector('#viewbutton-css') ) return
|
||||
let style = document.createElement('style')
|
||||
style.type = 'text/css'
|
||||
style.id = 'viewbutton-css'
|
||||
style.innerHTML = `
|
||||
.view-button{
|
||||
opacity:0.001;
|
||||
cursor:pointer;
|
||||
}
|
||||
.view-button:hover{
|
||||
opacity:1;
|
||||
cursor:pointer;
|
||||
}
|
||||
`
|
||||
document.body.appendChild(style)
|
||||
}
|
||||
|
||||
const onLoad = () => function(){
|
||||
const scene = mv[getSymbol('scene')].getObjectByName('Target').children[0]
|
||||
const renderer = mv[getSymbol("renderer")].threeRenderer
|
||||
const controls = mv[getSymbol("controls")]
|
||||
const camera = mv[getSymbol("scene")].getCamera()
|
||||
const url = mv.src
|
||||
|
||||
opts = window.opts = {
|
||||
scene,
|
||||
renderer,
|
||||
camera,
|
||||
controls
|
||||
}
|
||||
|
||||
window.opts = opts
|
||||
window.xrf = window.xrfragment // shorten
|
||||
|
||||
setupCSS()
|
||||
setupHotspots(scene)
|
||||
setupDefaultProjection(scene)
|
||||
|
||||
// now we re-insert the model via the XR Fragments lib (so it will parse the XRF metadata)
|
||||
}
|
||||
|
||||
mv.addEventListener("load", onLoad() )
|
||||
//mv.addEventListener('before-render', function(){
|
||||
// const scene = mv[getSymbol('scene')]
|
||||
// scene.visible = false
|
||||
// console.log("before-render")
|
||||
//})
|
||||
</script>
|
||||
<!-- Loads <model-viewer> for browsers: -->
|
||||
<script
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ xrf.loadModel = function(model,url,noadd){
|
|||
let {directory,file,fragment,fileExt} = URI;
|
||||
model.file = URI.file
|
||||
xrf.model = model
|
||||
xrf.scene = model.scene
|
||||
|
||||
if( !model.isXRF ) xrf.parseModel(model,url.replace(directory,"")) // this marks the model as an XRF model
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
xrf.addEventListener('navigateLoaded', (opts) => {
|
||||
// select active camera if any
|
||||
let {id,match,v} = opts
|
||||
let {id,match,v,THREE} = opts
|
||||
let envmap = {}
|
||||
let current = ''
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ xrf.addEventListener('navigateLoaded', (opts) => {
|
|||
// Update the closest ancestor's material map
|
||||
if (node.isMesh && node.material && node.material.map) {
|
||||
closestAncestorMaterialMap = node.material.map.clone();
|
||||
closestAncestorMaterialMap.mapping = THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.mapping = xrf.THREE.EquirectangularReflectionMapping;
|
||||
closestAncestorMaterialMap.needsUpdate = true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue