wip: trigger default view

This commit is contained in:
Leon van Kammen 2023-06-10 14:43:07 +02:00
parent 1443b71f62
commit b01d0e57d9
12 changed files with 52 additions and 32 deletions

View File

@ -452,7 +452,7 @@ var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
var store = { };
if(url.indexOf("#") == -1) {
if(url == null || url.indexOf("#") == -1) {
return store;
}
var fragment = url.split("#");
@ -966,7 +966,8 @@ xrf.navigator.to = (url,event) => {
model.file = file
xrf.add( model.scene )
xrf.model = model
xrf.eval( url, model ) // and eval URI XR fragments
xrf.eval( '#', model ) // execute the default projection '#' (if exist)
xrf.eval( url, model ) // and eval URI XR fragments
xrf.navigator.pushState( `${dir}${file}`, hash )
resolve(model)
})
@ -1202,7 +1203,7 @@ const doPredefinedView = (opts) => {
const predefinedView = (frag,scene,mesh) => {
let id = frag.string
if( mesh.userData[id] ){
if( mesh.userData[`#${id}`] ){
let frag = xrf.URI.parse( mesh.userData[id], xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.EMBEDDED )
for ( let k in frag ){
let opts = {frag, model, camera: xrf.camera, scene: xrf.scene, renderer: xrf.renderer, THREE: xrf.THREE }

2
dist/xrfragment.js vendored
View File

@ -452,7 +452,7 @@ var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
var store = { };
if(url.indexOf("#") == -1) {
if(url == null || url.indexOf("#") == -1) {
return store;
}
var fragment = url.split("#");

30
dist/xrfragment.lua vendored
View File

@ -2051,20 +2051,26 @@ _hx_exports["xrfragment"]["URI"] = __xrfragment_URI
__xrfragment_URI.__name__ = true
__xrfragment_URI.parse = function(url,filter)
local store = _hx_e();
local startIndex = nil;
if (startIndex == nil) then
startIndex = 1;
local tmp;
if (url ~= nil) then
local startIndex = nil;
if (startIndex == nil) then
startIndex = 1;
else
startIndex = startIndex + 1;
end;
local r = __lua_lib_luautf8_Utf8.find(url, "#", startIndex, true);
tmp = (function()
local _hx_1
if ((r ~= nil) and (r > 0)) then
_hx_1 = r - 1; else
_hx_1 = -1; end
return _hx_1
end )() == -1;
else
startIndex = startIndex + 1;
tmp = true;
end;
local r = __lua_lib_luautf8_Utf8.find(url, "#", startIndex, true);
if ((function()
local _hx_1
if ((r ~= nil) and (r > 0)) then
_hx_1 = r - 1; else
_hx_1 = -1; end
return _hx_1
end )() == -1) then
if (tmp) then
do return store end;
end;
local idx = 1;

View File

@ -452,7 +452,7 @@ var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
var store = { };
if(url.indexOf("#") == -1) {
if(url == null || url.indexOf("#") == -1) {
return store;
}
var fragment = url.split("#");

9
dist/xrfragment.py vendored
View File

@ -1536,8 +1536,13 @@ class xrfragment_URI:
@staticmethod
def parse(url,_hx_filter):
store = _hx_AnonObject({})
startIndex = None
if (((url.find("#") if ((startIndex is None)) else HxString.indexOfImpl(url,"#",startIndex))) == -1):
tmp = None
if (url is not None):
startIndex = None
tmp = (((url.find("#") if ((startIndex is None)) else HxString.indexOfImpl(url,"#",startIndex))) == -1)
else:
tmp = True
if tmp:
return store
fragment = url.split("#")
_this = (fragment[1] if 1 < len(fragment) else None)

View File

@ -452,7 +452,7 @@ var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
var store = { };
if(url.indexOf("#") == -1) {
if(url == null || url.indexOf("#") == -1) {
return store;
}
var fragment = url.split("#");
@ -966,7 +966,8 @@ xrf.navigator.to = (url,event) => {
model.file = file
xrf.add( model.scene )
xrf.model = model
xrf.eval( url, model ) // and eval URI XR fragments
xrf.eval( '#', model ) // execute the default projection '#' (if exist)
xrf.eval( url, model ) // and eval URI XR fragments
xrf.navigator.pushState( `${dir}${file}`, hash )
resolve(model)
})
@ -1202,7 +1203,7 @@ const doPredefinedView = (opts) => {
const predefinedView = (frag,scene,mesh) => {
let id = frag.string
if( mesh.userData[id] ){
if( mesh.userData[`#${id}`] ){
let frag = xrf.URI.parse( mesh.userData[id], xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.EMBEDDED )
for ( let k in frag ){
let opts = {frag, model, camera: xrf.camera, scene: xrf.scene, renderer: xrf.renderer, THREE: xrf.THREE }

View File

@ -452,7 +452,7 @@ var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
var store = { };
if(url.indexOf("#") == -1) {
if(url == null || url.indexOf("#") == -1) {
return store;
}
var fragment = url.split("#");
@ -966,7 +966,8 @@ xrf.navigator.to = (url,event) => {
model.file = file
xrf.add( model.scene )
xrf.model = model
xrf.eval( url, model ) // and eval URI XR fragments
xrf.eval( '#', model ) // execute the default projection '#' (if exist)
xrf.eval( url, model ) // and eval URI XR fragments
xrf.navigator.pushState( `${dir}${file}`, hash )
resolve(model)
})
@ -1202,7 +1203,7 @@ const doPredefinedView = (opts) => {
const predefinedView = (frag,scene,mesh) => {
let id = frag.string
if( mesh.userData[id] ){
if( mesh.userData[`#${id}`] ){
let frag = xrf.URI.parse( mesh.userData[id], xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.EMBEDDED )
for ( let k in frag ){
let opts = {frag, model, camera: xrf.camera, scene: xrf.scene, renderer: xrf.renderer, THREE: xrf.THREE }

View File

@ -23,7 +23,8 @@ xrf.navigator.to = (url,event) => {
model.file = file
xrf.add( model.scene )
xrf.model = model
xrf.eval( url, model ) // and eval URI XR fragments
xrf.eval( '#', model ) // execute the default projection '#' (if exist)
xrf.eval( url, model ) // and eval URI XR fragments
xrf.navigator.pushState( `${dir}${file}`, hash )
resolve(model)
})

View File

@ -25,7 +25,7 @@ const doPredefinedView = (opts) => {
const predefinedView = (frag,scene,mesh) => {
let id = frag.string
if( mesh.userData[id] ){
if( mesh.userData[`#${id}`] ){
let frag = xrf.URI.parse( mesh.userData[id], xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.EMBEDDED )
for ( let k in frag ){
let opts = {frag, model, camera: xrf.camera, scene: xrf.scene, renderer: xrf.renderer, THREE: xrf.THREE }

View File

@ -46,7 +46,7 @@ class URI {
@:keep
public static function parse(url:String,filter:Int):haxe.DynamicAccess<Dynamic> {
var store:haxe.DynamicAccess<Dynamic> = {}; // 1. store key/values into a associative array or dynamic object
if( url.indexOf("#") == -1 ) return store;
if( url == null || url.indexOf("#") == -1 ) return store;
var fragment:Array<String> = url.split("#"); // 1. fragment URI starts with `#`
var splitArray:Array<String> = fragment[1].split('&'); // 1. fragments are split by `&`
for (i in 0...splitArray.length) { // 1. loop thru each fragment

View File

@ -562,7 +562,7 @@ var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
var store = { };
if(url.indexOf("#") == -1) {
if(url == null || url.indexOf("#") == -1) {
return store;
}
var fragment = url.split("#");

View File

@ -1599,8 +1599,8 @@ class xrfragment_Query:
fails = 0
qualify = 0
def _hx_local_2(expr):
nonlocal fails
nonlocal conds
nonlocal fails
conds = (conds + 1)
fails = (fails + (0 if expr else 1))
return expr
@ -1650,8 +1650,13 @@ class xrfragment_URI:
@staticmethod
def parse(url,_hx_filter):
store = _hx_AnonObject({})
startIndex = None
if (((url.find("#") if ((startIndex is None)) else HxString.indexOfImpl(url,"#",startIndex))) == -1):
tmp = None
if (url is not None):
startIndex = None
tmp = (((url.find("#") if ((startIndex is None)) else HxString.indexOfImpl(url,"#",startIndex))) == -1)
else:
tmp = True
if tmp:
return store
fragment = url.split("#")
_this = (fragment[1] if 1 < len(fragment) else None)