supporting parented entity after teleportation

spatial-introspection
Fabien Benetou 8 months ago
parent 55d8f2223b
commit 1835def7c4
  1. 6
      jxr-core.js

@ -207,8 +207,8 @@ AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right o
let pos = event.detail.position let pos = event.detail.position
let parentPos = document.getElementById('rig').getAttribute('position') let parentPos = document.getElementById('rig').getAttribute('position')
pos.add( parentPos ) pos.add( parentPos )
pos.sub( selectedElements.at(-1).startingPosition )
selectedElement.setAttribute("position", pos ) selectedElement.setAttribute("position", pos )
// TODO get the world position of the selectedElement on pinchstarted then offset by that
document.querySelector("#rightHand").object3D.traverse( e => { document.querySelector("#rightHand").object3D.traverse( e => {
if (e.name == "ring-finger-tip"){ if (e.name == "ring-finger-tip"){
selectedElement.object3D.rotation.copy( e.rotation ) selectedElement.object3D.rotation.copy( e.rotation )
@ -230,7 +230,9 @@ AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right o
selectedElement = getClosestTargetElement( event.detail.position ) selectedElement = getClosestTargetElement( event.detail.position )
if (selectedElement) { if (selectedElement) {
selectedElements.push({element:selectedElement, timestamp:Date.now(), primary:true}) let startingPosition = new THREE.Vector3()
selectedElement.parentEl.object3D.getWorldPosition( startingPosition )
selectedElements.push({element:selectedElement, timestamp:Date.now(), startingPosition: startingPosition, primary:true})
selectedElement.emit("picked") selectedElement.emit("picked")
} else { } else {
AFRAME.scenes[0].emit('emptypinch', {position:event.detail.position, timestamp:Date.now() }) AFRAME.scenes[0].emit('emptypinch', {position:event.detail.position, timestamp:Date.now() })

Loading…
Cancel
Save