diff --git a/index.html b/index.html index e2c6df7..3578a26 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - + @@ -221,17 +221,29 @@ AFRAME.registerComponent('onemptypinch', { // changed from ondrop to be coherent function onHoveredChangeColor(){ console.log( "onHoveredChangeOpacity" ) - let target = document.getElementById('testboxpinch') - // could iterate over targets, see https://aframe.io/docs/1.5.0/components/cursor.html#configuring-the-cursor-through-the-raycaster-component - console.log ( "cursor-hovered?", target.states.includes( "cursor-hovered" ) ) - if ( target.states.includes( "cursor-hovered" ) ){ - console.log ( "yes, cursor-hovered" ) - target.setAttribute("material", "color", "green") - //target.setAttribute("color", "red") - document.getElementById('rig').setAttribute('position', "4 0 -3") - // bug on hand pinch, even while checking on world position, might have to see older commit - } + // iterate over targets + // see instead of teleportable https://aframe.io/docs/1.5.0/components/cursor.html#configuring-the-cursor-through-the-raycaster-component + Array.from( document.querySelectorAll(".teleportable") ).map( target => { + if ( target.states.includes( "cursor-hovered" ) ){ + target.setAttribute("material", "color", "magenta") // visited + document.getElementById('rig').setAttribute('position', target.getAttribute("position") ) + } + }) +} + +AFRAME.registerComponent('highlight-on-gaze', { + init: function(){ + this.el.setAttribute("opacity", .5) + }, + events: { + mouseenter: function (e) { + this.el.setAttribute("opacity", .8) + }, + mouseleave: function (e) { + this.el.setAttribute("opacity", .5) + } } +}); let page = "Wiki.VirtualRealityInterface"; // should do then only once graph loaded instead, should emit event @@ -258,8 +270,8 @@ setTimeout( _ => { @@ -323,8 +335,14 @@ setTimeout( _ => { - - + + + + + + + + diff --git a/jxr-core.js b/jxr-core.js index d23274a..7554347 100644 --- a/jxr-core.js +++ b/jxr-core.js @@ -208,6 +208,7 @@ AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right o let parentPos = document.getElementById('rig').getAttribute('position') pos.add( parentPos ) selectedElement.setAttribute("position", pos ) + // TODO get the world position of the selectedElement on pinchstarted then offset by that document.querySelector("#rightHand").object3D.traverse( e => { if (e.name == "ring-finger-tip"){ selectedElement.object3D.rotation.copy( e.rotation ) @@ -608,11 +609,32 @@ function doublePinchToScale(){ } // from https://aframe.io/aframe/examples/showcase/hand-tracking/pressable.js +// modified to support teleportation via #rig AFRAME.registerComponent('pressable', { schema:{pressDistance:{default:0.06}}, init:function(){this.worldPosition=new THREE.Vector3();this.handEls=document.querySelectorAll('[hand-tracking-controls]');this.pressed=false;}, - tick:function(){var handEls=this.handEls;var handEl;var distance;for(var i=0;i