From 8807b18c55248b92b1efda340f6ea13b3c1e2830 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Tue, 4 Aug 2026 21:04:14 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Auto-deploy:=20melhoria=20no=20s?= =?UTF-8?q?nap=20e=20medi=C3=A7=C3=A3o=20AR=20em=2004/08/2026=2021:04:14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lab/QuestCubeLab.tsx | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/lab/QuestCubeLab.tsx b/src/lab/QuestCubeLab.tsx index 794a3b2..d5201d5 100644 --- a/src/lab/QuestCubeLab.tsx +++ b/src/lab/QuestCubeLab.tsx @@ -112,7 +112,12 @@ const CubeControlado = ({ ry = gpRight?.axes[3] ?? 0; lt = gpLeft?.buttons[1]?.value ?? 0; rt = gpRight?.buttons[1]?.value ?? 0; - resetBtn = gpRight?.buttons[4]?.pressed || gpRight?.buttons[5]?.pressed || false; + resetBtn = + gpRight?.buttons[4]?.pressed || + gpRight?.buttons[5]?.pressed || + gpLeft?.buttons[4]?.pressed || + gpLeft?.buttons[5]?.pressed || + false; } else { // Desktop nativo lx = gpDesktop!.axes[0] ?? 0; @@ -171,17 +176,35 @@ const CubeControlado = ({ { - posRef.current.x = pos.x; - posRef.current.y = Math.max(0.5, pos.y); - posRef.current.z = pos.z; + onSync={(deltaPos, deltaQuat, deltaScale) => { + // Matriz atual do cubo + const mMesh = new THREE.Matrix4().compose( + new THREE.Vector3(posRef.current.x, posRef.current.y, posRef.current.z), + new THREE.Quaternion().setFromEuler(new THREE.Euler(rotRef.current.x, rotRef.current.y, rotRef.current.z, 'YXZ')), + new THREE.Vector3(scaleRef.current, scaleRef.current, scaleRef.current) + ); - const euler = new THREE.Euler().setFromQuaternion(quat, 'YXZ'); + // Matriz delta vinda do arrasto (XRGrabbable group) + const mGroup = new THREE.Matrix4().compose(deltaPos, deltaQuat, deltaScale); + + // Multiplica o offset (group) pelo local (mesh) + const mCombined = new THREE.Matrix4().multiplyMatrices(mGroup, mMesh); + + const finalPos = new THREE.Vector3(); + const finalQuat = new THREE.Quaternion(); + const finalScale = new THREE.Vector3(); + mCombined.decompose(finalPos, finalQuat, finalScale); + + posRef.current.x = finalPos.x; + posRef.current.y = Math.max(0.5, finalPos.y); + posRef.current.z = finalPos.z; + + const euler = new THREE.Euler().setFromQuaternion(finalQuat, 'YXZ'); rotRef.current.x = euler.x; rotRef.current.y = euler.y; rotRef.current.z = euler.z; - scaleRef.current = scale.x; + scaleRef.current = finalScale.x; }} >