🚀 Auto-deploy: melhoria no snap e medição AR em 04/08/2026 21:04:14
This commit is contained in:
@@ -112,7 +112,12 @@ const CubeControlado = ({
|
|||||||
ry = gpRight?.axes[3] ?? 0;
|
ry = gpRight?.axes[3] ?? 0;
|
||||||
lt = gpLeft?.buttons[1]?.value ?? 0;
|
lt = gpLeft?.buttons[1]?.value ?? 0;
|
||||||
rt = gpRight?.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 {
|
} else {
|
||||||
// Desktop nativo
|
// Desktop nativo
|
||||||
lx = gpDesktop!.axes[0] ?? 0;
|
lx = gpDesktop!.axes[0] ?? 0;
|
||||||
@@ -171,17 +176,35 @@ const CubeControlado = ({
|
|||||||
<XRGrabbable
|
<XRGrabbable
|
||||||
allowScale={true}
|
allowScale={true}
|
||||||
lockedActive={lockedRef.current}
|
lockedActive={lockedRef.current}
|
||||||
onSync={(pos, quat, scale) => {
|
onSync={(deltaPos, deltaQuat, deltaScale) => {
|
||||||
posRef.current.x = pos.x;
|
// Matriz atual do cubo
|
||||||
posRef.current.y = Math.max(0.5, pos.y);
|
const mMesh = new THREE.Matrix4().compose(
|
||||||
posRef.current.z = pos.z;
|
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.x = euler.x;
|
||||||
rotRef.current.y = euler.y;
|
rotRef.current.y = euler.y;
|
||||||
rotRef.current.z = euler.z;
|
rotRef.current.z = euler.z;
|
||||||
|
|
||||||
scaleRef.current = scale.x;
|
scaleRef.current = finalScale.x;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<mesh
|
<mesh
|
||||||
|
|||||||
Reference in New Issue
Block a user