Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
+32
-1
@@ -359,10 +359,11 @@ function XRSnapHandler() {
|
|||||||
// ─── XR Grid ───────────────────────────────────────────
|
// ─── XR Grid ───────────────────────────────────────────
|
||||||
function XRGrid() {
|
function XRGrid() {
|
||||||
const showGrid = useModelStore((s) => s.showGrid);
|
const showGrid = useModelStore((s) => s.showGrid);
|
||||||
|
const gridY = useModelStore((s) => s.gridY);
|
||||||
if (!showGrid) return null;
|
if (!showGrid) return null;
|
||||||
return (
|
return (
|
||||||
<Grid
|
<Grid
|
||||||
position={[0, -0.09, 0]}
|
position={[0, gridY, 0]}
|
||||||
infiniteGrid
|
infiniteGrid
|
||||||
cellSize={0.01}
|
cellSize={0.01}
|
||||||
sectionSize={0.1}
|
sectionSize={0.1}
|
||||||
@@ -376,6 +377,36 @@ function XRGrid() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Auto-follow grid to model bottom when enabled. */
|
||||||
|
function XRGridAutoFollower() {
|
||||||
|
const models = useModelStore((s) => s.models);
|
||||||
|
const { scene } = useThree();
|
||||||
|
useEffect(() => {
|
||||||
|
if (!useModelStore.getState().gridAutoFollow) return;
|
||||||
|
const id = setTimeout(() => {
|
||||||
|
if (!useModelStore.getState().gridAutoFollow) return;
|
||||||
|
const box = new THREE.Box3();
|
||||||
|
let has = false;
|
||||||
|
scene.traverse((obj) => {
|
||||||
|
if (obj instanceof THREE.Mesh && obj.geometry) {
|
||||||
|
if (obj.geometry instanceof THREE.SphereGeometry) return;
|
||||||
|
if (obj.geometry instanceof THREE.RingGeometry) return;
|
||||||
|
if (obj.userData.__edgeLine) return;
|
||||||
|
obj.updateWorldMatrix(true, false);
|
||||||
|
const b = new THREE.Box3().setFromObject(obj);
|
||||||
|
if (isFinite(b.min.y)) {
|
||||||
|
if (!has) { box.copy(b); has = true; }
|
||||||
|
else box.union(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (has) useModelStore.setState({ gridY: box.min.y - 0.005 });
|
||||||
|
}, 150);
|
||||||
|
return () => clearTimeout(id);
|
||||||
|
}, [models, scene]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// ImageTrackingAnchor removed — replaced by XRHitTestPlacement
|
// ImageTrackingAnchor removed — replaced by XRHitTestPlacement
|
||||||
|
|
||||||
// ─── XRSession Page ────────────────────────────────────
|
// ─── XRSession Page ────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user