🚀 Auto-deploy: melhoria no snap e medição AR em 03/06/2026 10:31:54

This commit is contained in:
2026-06-03 10:31:54 +00:00
parent 7f5b4427d7
commit 426bf13241
5 changed files with 21 additions and 1 deletions
@@ -87,6 +87,8 @@ export function ControllerLocomotion({ rigRef }: Props) {
const ctrlPose = frame.getPose(activeSource.targetRaySpace, referenceSpace);
if (ctrlPose) {
const m = new THREE.Matrix4().fromArray(ctrlPose.transform.matrix);
// Aplica a matriz de mundo do rig para alinhar a origem física com a locomoção do rig
m.premultiply(rig.matrixWorld);
origin.setFromMatrixPosition(m);
const q = new THREE.Quaternion().setFromRotationMatrix(m);
dir.set(0, 0, -1).applyQuaternion(q).normalize();
@@ -131,6 +131,10 @@ export function XRControllerMeasure() {
if (!pose) return;
const m = new THREE.Matrix4().fromArray(pose.transform.matrix);
const xrRig = useModelStore.getState().xrRig;
if (xrRig) {
m.premultiply(xrRig.matrixWorld);
}
tmpOrigin.current.setFromMatrixPosition(m);
tmpQuat.current.setFromRotationMatrix(m);
tmpDir.current.set(0, 0, -1).applyQuaternion(tmpQuat.current).normalize();
+5
View File
@@ -3,6 +3,7 @@ import { useFrame, useThree } from '@react-three/fiber';
import * as THREE from 'three';
// DEVKIT: remove this import + the fake-input block in useFrame to strip devkit
import { fakeInput, isFakeActive } from '@/devkit/fakeInputStore';
import { useModelStore } from '@/stores/useModelStore';
export interface GrabState {
/** Analog grip pressure (0..1) */
@@ -108,6 +109,10 @@ export function useControllerGrab() {
const pose = frame.getPose(source.gripSpace, referenceSpace);
if (pose) {
slot.gripWorld.fromArray(pose.transform.matrix);
const xrRig = useModelStore.getState().xrRig;
if (xrRig) {
slot.gripWorld.premultiply(xrRig.matrixWorld);
}
slot.hasPose = true;
}
}
+4 -1
View File
@@ -1157,7 +1157,10 @@ const XRSession = () => {
<directionalLight position={[3, 5, 3]} intensity={1.2} />
<directionalLight position={[-3, 3, -3]} intensity={0.4} />
<group ref={rigRef}>
<group ref={(el) => {
(rigRef as React.MutableRefObject<THREE.Group | null>).current = el;
useModelStore.getState().setXRRig(el);
}}>
<XROrigin />
</group>
+6
View File
@@ -372,6 +372,9 @@ interface ModelStore {
ifcMaterialColors: boolean;
setIfcMaterialColors: (enabled: boolean) => void;
xrRig: THREE.Group | null;
setXRRig: (rig: THREE.Group | null) => void;
}
/** Sync top-level legacy `model` / `fineTuning` from active SceneModel. */
@@ -384,6 +387,9 @@ function syncActive(state: Pick<ModelStore, 'models' | 'activeModelId'>): { mode
}
export const useModelStore = create<ModelStore>((set, get) => ({
xrRig: null,
setXRRig: (rig) => set({ xrRig: rig }),
// ── Multi-model ─────────────
models: [],
activeModelId: null,