Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -210,16 +210,44 @@ function GLBModel({ sceneModel, isActive }: { sceneModel: SceneModel; isActive:
|
|||||||
rotation={[rotXRad, rotYRad, rotZRad]}
|
rotation={[rotXRad, rotYRad, rotZRad]}
|
||||||
scale={[s, s, s]}
|
scale={[s, s, s]}
|
||||||
>
|
>
|
||||||
{/* Shift geometry so its center sits at the parent's origin (pivot = center) */}
|
{/* Shift geometry so its center sits at the parent's origin (pivot = center).
|
||||||
<group position={[-modelInfo.center.x, -modelInfo.center.y, -modelInfo.center.z]}>
|
This is the local frame where measurement points are stored, so measurements
|
||||||
|
follow the model when posX/Y/Z or rotX/Y/Z change in "Posicionar" mode. */}
|
||||||
|
<ModelLocalFrame modelId={sceneModel.id} center={modelInfo.center}>
|
||||||
<primitive object={scene} />
|
<primitive object={scene} />
|
||||||
</group>
|
<ModelMeasurements modelId={sceneModel.id} />
|
||||||
|
</ModelLocalFrame>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Innermost local frame of a model. Registers itself in the global model
|
||||||
|
* registry so the store can convert world points to this group's local frame. */
|
||||||
|
function ModelLocalFrame({
|
||||||
|
modelId,
|
||||||
|
center,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
modelId: string;
|
||||||
|
center: THREE.Vector3;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
const ref = useRef<THREE.Group>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
const g = ref.current;
|
||||||
|
if (!g) return;
|
||||||
|
registerModelLocalGroup(modelId, g);
|
||||||
|
return () => unregisterModelLocalGroup(modelId, g);
|
||||||
|
}, [modelId]);
|
||||||
|
return (
|
||||||
|
<group ref={ref} position={[-center.x, -center.y, -center.z]}>
|
||||||
|
{children}
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function SceneModels() {
|
function SceneModels() {
|
||||||
const models = useModelStore((s) => s.models);
|
const models = useModelStore((s) => s.models);
|
||||||
const activeId = useModelStore((s) => s.activeModelId);
|
const activeId = useModelStore((s) => s.activeModelId);
|
||||||
|
|||||||
Reference in New Issue
Block a user