|
|
@ -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() }) |
|
|
|