supporting parented entity after teleportation

teleport
Fabien Benetou 3 weeks 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 parentPos = document.getElementById('rig').getAttribute('position')
pos.add( parentPos )
pos.sub( selectedElements.at(-1).startingPosition )
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 )
@ -230,7 +230,9 @@ AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right o
selectedElement = getClosestTargetElement( event.detail.position )
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")
} else {
AFRAME.scenes[0].emit('emptypinch', {position:event.detail.position, timestamp:Date.now() })

Loading…
Cancel
Save