Fix scan/guide visibility with per-project preferences

- Store showScans/showGuides preferences per project so toggling
  persists when switching between projects
- Apply showGuides/showScans directly on guide and scan renderer groups
- Set projectId in both editor and viewer pages on mount

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Aymeric Rabot
2026-02-27 01:38:10 -05:00
co-authored by Claude Opus 4.6
parent d0e0fe7e1e
commit 31c09bacdd
5 changed files with 58 additions and 5 deletions
@@ -5,15 +5,17 @@ import { DoubleSide, type Group, type Texture, TextureLoader } from 'three'
import { float, texture } from 'three/tsl'
import { MeshBasicNodeMaterial } from 'three/webgpu'
import { useAssetUrl } from '../../../hooks/use-asset-url'
import useViewer from '../../../store/use-viewer'
export const GuideRenderer = ({ node }: { node: GuideNode }) => {
const showGuides = useViewer((s) => s.showGuides)
const ref = useRef<Group>(null!)
useRegistry(node.id, 'guide', ref)
const resolvedUrl = useAssetUrl(node.url)
return (
<group ref={ref} position={node.position} rotation={[0, node.rotation[1], 0]}>
<group ref={ref} visible={showGuides} position={node.position} rotation={[0, node.rotation[1], 0]}>
{resolvedUrl && (
<Suspense>
<GuidePlane url={resolvedUrl} scale={node.scale} opacity={node.opacity} />
@@ -3,8 +3,10 @@ import { Suspense, useMemo, useRef } from 'react'
import type { Group, Material, Mesh } from 'three'
import { useAssetUrl } from '../../../hooks/use-asset-url'
import { useGLTFKTX2 } from '../../../hooks/use-gltf-ktx2'
import useViewer from '../../../store/use-viewer'
export const ScanRenderer = ({ node }: { node: ScanNode }) => {
const showScans = useViewer((s) => s.showScans)
const ref = useRef<Group>(null!)
useRegistry(node.id, 'scan', ref)
@@ -13,6 +15,7 @@ export const ScanRenderer = ({ node }: { node: ScanNode }) => {
return (
<group
ref={ref}
visible={showScans}
position={node.position}
rotation={node.rotation}
scale={[node.scale, node.scale, node.scale]}