diff --git a/example/aframe/sandbox/index.html b/example/aframe/sandbox/index.html
index a80491d..7b4f656 100644
--- a/example/aframe/sandbox/index.html
+++ b/example/aframe/sandbox/index.html
@@ -18,7 +18,7 @@
light="defaultLightsEnabled: false">
-
+
diff --git a/src/3rd/js/aframe/patch.hand-tracking-controls.js b/src/3rd/js/aframe/patch.hand-tracking-controls.js
new file mode 100644
index 0000000..3bf9237
--- /dev/null
+++ b/src/3rd/js/aframe/patch.hand-tracking-controls.js
@@ -0,0 +1,11 @@
+AFRAME.components['hand-tracking-controls'].Component.prototype.onModelLoaded = function(onModelLoaded){
+ return function(e){
+ onModelLoaded.apply(this);
+ // re-attach children
+ ([...this.el.children]).map( (c) => {
+ if( c.object3D ){
+ this.el.object3D.getObjectByName("wrist").add(c.object3D)
+ }
+ })
+ }
+}(AFRAME.components['hand-tracking-controls'].Component.prototype.onModelLoaded)
diff --git a/src/3rd/js/aframe/pressable.js b/src/3rd/js/aframe/pressable.js
index c5096dc..257599a 100644
--- a/src/3rd/js/aframe/pressable.js
+++ b/src/3rd/js/aframe/pressable.js
@@ -64,7 +64,7 @@ AFRAME.registerComponent('pressable', {
this.el.emit('click');
this.pressed = setTimeout( () => {
this.el.emit('pressedended');
- this.pressed = null
+ this.pressed = false
},300)
}
}
diff --git a/src/3rd/js/aframe/xrf-button.js b/src/3rd/js/aframe/xrf-button.js
index 43ea9d6..4f71841 100644
--- a/src/3rd/js/aframe/xrf-button.js
+++ b/src/3rd/js/aframe/xrf-button.js
@@ -57,8 +57,10 @@ window.AFRAME.registerComponent('xrf-button', {
this.el.addEventListener('mouseenter', (e) => this.onMouseEnter(e) );
this.el.addEventListener('mouseleave', (e) => this.onMouseLeave(e) );
+ let cb = new Function(this.data.action)
+
if( this.data.action ){
- this.el.addEventListener('click', new Function(this.data.action) )
+ this.el.addEventListener('click', AFRAME.utils.throttle(cb, 500 ) )
}
},
bindMethods: function() {
diff --git a/src/3rd/js/plugin/frontend/frontend.js b/src/3rd/js/plugin/frontend/frontend.js
index 9dcd75b..199cc84 100644
--- a/src/3rd/js/plugin/frontend/frontend.js
+++ b/src/3rd/js/plugin/frontend/frontend.js
@@ -284,29 +284,8 @@ window.frontend = (opts) => new Proxy({
},
updateHashPosition(randomize){
- // *TODO* this should be part of the XRF Threejs framework
- if( typeof THREE == 'undefined' ) THREE = xrf.THREE
- let radToDeg = THREE.MathUtils.radToDeg
- let toDeg = (x) => x / (Math.PI / 180)
- let camera = document.querySelector('[camera]').object3D.parent // *TODO* fix for threejs
- camera.position.x += Math.random()/10
- camera.position.z += Math.random()/10
-
- // *TODO* add camera direction
- let direction = new xrf.THREE.Vector3()
- camera.getWorldDirection(direction)
- const pitch = Math.asin(direction.y);
- const yaw = Math.atan2(direction.x, direction.z);
- const pitchInDegrees = pitch * 180 / Math.PI;
- const yawInDegrees = yaw * 180 / Math.PI;
-
- let lastPos = `pos=${camera.position.x.toFixed(2)},${camera.position.y.toFixed(2)},${camera.position.z.toFixed(2)}`
- let newHash = document.location.hash.replace(/[&]?(pos|rot)=[0-9\.-]+,[0-9\.-]+,[0-9\.-]+/,'')
- if( lastPos != "pos=" ){
- newHash += `&${lastPos}`
- document.location.hash = newHash.replace(/&&/,'&')
- .replace(/#&/,'')
- }
+ const pos = xrf.frag.pos.get()
+ xrf.navigator.URI.hash.pos = `${pos.x},${pos.y},${pos.z}`
this.copyToClipboard( window.location.href );
},
@@ -326,8 +305,9 @@ window.frontend = (opts) => new Proxy({
document.location.hash += `&meet=${network.meetingLink}`
}
if( !document.location.hash.match(/pos=/) && (network.posName || network.pos) ){
- document.location.hash += `&pos=${ network.posName || network.pos }`
- }
+ xrf.navigator.URI.hash.pos = network.posName || network.pos
+ }else frontend.updateHashPosition()
+
let url = window.location.href
if( opts.linkonly ) return url
this.copyToClipboard( url )
diff --git a/src/3rd/js/three/navigator.js b/src/3rd/js/three/navigator.js
index 8fd3e93..2abca7c 100644
--- a/src/3rd/js/three/navigator.js
+++ b/src/3rd/js/three/navigator.js
@@ -12,7 +12,6 @@ xrf.navigator.to = (url,flags,loader,data) => {
let hashbus = xrf.hashbus
xrf.navigator.URI = URI
let {directory,file,fragment,fileExt} = URI;
- console.dir({URI, nav: xrf.navigator.URI})
const evalFragment = () => {
if( URI.fragment ){
diff --git a/src/3rd/js/three/xrf/pos.js b/src/3rd/js/three/xrf/pos.js
index 7b208b7..9b5cc5a 100644
--- a/src/3rd/js/three/xrf/pos.js
+++ b/src/3rd/js/three/xrf/pos.js
@@ -24,6 +24,32 @@ xrf.frag.pos = function(v, opts){
camera.updateMatrixWorld()
}
+xrf.frag.pos.get = function(precision,randomize){
+ if( !precision ) precision = 2;
+ if( typeof THREE == 'undefined' ) THREE = xrf.THREE
+ let radToDeg = THREE.MathUtils.radToDeg
+ let toDeg = (x) => x / (Math.PI / 180)
+ let camera = xrf.camera
+ if( randomize ){
+ camera.position.x += Math.random()/10
+ camera.position.z += Math.random()/10
+ }
+
+ // *TODO* add camera direction
+ let direction = new xrf.THREE.Vector3()
+ camera.getWorldDirection(direction)
+ const pitch = Math.asin(direction.y);
+ const yaw = Math.atan2(direction.x, direction.z);
+ const pitchInDegrees = pitch * 180 / Math.PI;
+ const yawInDegrees = yaw * 180 / Math.PI;
+
+ return {
+ x: String(camera.position.x.toFixed(2)),
+ y: String(camera.position.y.toFixed(2)),
+ z: String(camera.position.z.toFixed(2)),
+ }
+}
+
xrf.addEventListener('reset', (opts) => {
// set the player to position 0,0,0
xrf.camera.position.set(0,0,0)
diff --git a/src/3rd/js/three/xrf/src.js b/src/3rd/js/three/xrf/src.js
index f26780e..0e3d02f 100644
--- a/src/3rd/js/three/xrf/src.js
+++ b/src/3rd/js/three/xrf/src.js
@@ -94,7 +94,7 @@ xrf.frag.src.externalSRC = (url,frag,opts) => {
fetch(url, { method: 'HEAD' })
.then( (res) => {
let mimetype = res.headers.get('Content-type')
- if(xrf.debug != undefined ) console.log("HEAD "+url+" => "+mimetype)
+ if(xrf.debug > 0 ) console.log("HEAD "+url+" => "+mimetype)
if( url.replace(/#.*/,'').match(/\.(gltf|glb)$/) ) mimetype = 'gltf'
if( url.replace(/#.*/,'').match(/\.(frag|fs|glsl)$/) ) mimetype = 'x-shader/x-fragment'
if( url.replace(/#.*/,'').match(/\.(vert|vs)$/) ) mimetype = 'x-shader/x-fragment'
diff --git a/src/spec/url.json b/src/spec/url.json
index d744a13..1bd93ad 100644
--- a/src/spec/url.json
+++ b/src/spec/url.json
@@ -16,5 +16,6 @@
{"fn":"url","data":"/bar/flop#mycustom=foo", "expect":{ "fn":"testURLBrowse", "input":"path","out":"/bar/flop"},"label":"test URLBrowser (overwrite path 2)"},
{"fn":"url","data":"/bar/flop#mycustom=foo", "expect":{ "fn":"testURLBrowse", "input":"host","out":"foo.com"},"label":"test URLBrowser (maintain host)"},
{"fn":"url","data":"c/d?foo=1#mycustom=foo", "expect":{ "fn":"testURLBrowse", "input":"path","out":"/bar/flop/c/d"},"label":"test URLBrowser (append path+query)"},
- {"fn":"url","data":"a/b#foo=bar", "expect":{ "fn":"testURL", "input":"hash.foo","out":"bar"},"label":"test URL hash #mycustom == foo"}
+ {"fn":"url","data":"a/b#foo=bar", "expect":{ "fn":"testURL", "input":"hash.foo","out":"bar"},"label":"test URL hash #mycustom == foo"},
+ {"fn":"url","data":"a/b?index.glb#foo=bar://foo/flop.gltf", "expect":{ "fn":"testURL", "input":"directory","out":"a/b"},"label":"test URLhash with protocol"}
]
diff --git a/src/xrfragment/URI.hx b/src/xrfragment/URI.hx
index cfbc706..c570dc0 100644
--- a/src/xrfragment/URI.hx
+++ b/src/xrfragment/URI.hx
@@ -410,7 +410,6 @@ class URI {
if (newURI.host != null && newURI.host.length > 0 )
{
- trace("host: "+newURI.host);
resultURI.host = newURI.host;
resultURI.port = null;
resultURI.fragment = null;