From de42d9be55ddf24e0ff6da0432f140ddced9382a Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Fri, 24 Mar 2023 09:11:56 +0100 Subject: [PATCH] rotation centered on user but resetting on new pinch --- index.html | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 84e3f4e..f176156 100644 --- a/index.html +++ b/index.html @@ -2404,11 +2404,22 @@ function emptyPinchToMove(){ if (selectedElement) return if (previousPositionSecondary){ angle = previousPositionSecondary.sub(event.detail.position).clone() + let axis = new THREE.Vector3( 0, 1, 0 ); applyToClass("hidableenvironment", (e, val ) => { - let rot = e.getAttribute("rotation") - e.setAttribute("rotation", ""+rot.x+" "+(rot.y+val*90)+" "+rot.z) + //let rot = e.getAttribute("rotation") + //e.setAttribute("rotation", ""+rot.x+" "+(rot.y+val*90)+" "+rot.z) // rotating from the center of the model, not the player position - }, angle.x) +let obj = e.object3D +obj.position.sub(val.point) +obj.position.applyAxisAngle( axis, val.angle ) // no offset but reset when pinching again +//obj.position.applyAxisAngle( axis, obj.rotation.y+val.angle ) // rotates with offset +obj.position.add(val.point) +obj.rotateOnAxis(axis, val.angle) +// cf https://stackoverflow.com/questions/42812861/three-js-pivot-point/42866733#42866733 +// does reset on each new pinch though + +// might be a threejs vs AFrame rotation setup? + }, {angle:angle.x, point:event.detail.position.clone()}) } previousPositionSecondary = event.detail.position.clone() }