refactor(paint-slots): share scene IBL as viewer SceneEnvironment
Replace the editor-only EditorEnvironment wrapper with a SceneEnvironment component exported from @pascal-app/viewer, mounted as an opt-in <Viewer> child (still not baked into the Viewer component). One source of truth the editor and the community public viewer both inject; embed/thumbnail surfaces simply don't mount it. Sunset preset at environmentIntensity 0.6. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
37c56788f3
commit
4818807360
@@ -1,20 +0,0 @@
|
|||||||
'use client'
|
|
||||||
|
|
||||||
import { Environment } from '@react-three/drei'
|
|
||||||
import { Suspense } from 'react'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scene IBL for the editor — drei's prefiltered environment map. Injected as a
|
|
||||||
* <Viewer> *child* (not baked into the Viewer component) so read-only / embed
|
|
||||||
* viewers don't pull the HDRI. This is what gives PBR metals their reflections
|
|
||||||
* and lifts the lighting on vertical surfaces (walls), which flat directional +
|
|
||||||
* hemisphere lights can't do alone. Intensity is dialled below the preset
|
|
||||||
* default so it complements the scene lights rather than washing them out.
|
|
||||||
*/
|
|
||||||
export function EditorEnvironment() {
|
|
||||||
return (
|
|
||||||
<Suspense fallback={null}>
|
|
||||||
<Environment preset="sunset" environmentIntensity={0.6} />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,13 @@ import {
|
|||||||
spatialGridManager,
|
spatialGridManager,
|
||||||
useScene,
|
useScene,
|
||||||
} from '@pascal-app/core'
|
} from '@pascal-app/core'
|
||||||
import { type HoverStyles, InteractiveSystem, useViewer, Viewer } from '@pascal-app/viewer'
|
import {
|
||||||
|
type HoverStyles,
|
||||||
|
InteractiveSystem,
|
||||||
|
SceneEnvironment,
|
||||||
|
useViewer,
|
||||||
|
Viewer,
|
||||||
|
} from '@pascal-app/viewer'
|
||||||
import { memo, type ReactNode, useCallback, useEffect, useRef, useState } from 'react'
|
import { memo, type ReactNode, useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { ViewerOverlay } from '../../components/viewer-overlay'
|
import { ViewerOverlay } from '../../components/viewer-overlay'
|
||||||
import { ViewerZoneSystem } from '../../components/viewer-zone-system'
|
import { ViewerZoneSystem } from '../../components/viewer-zone-system'
|
||||||
@@ -21,7 +27,6 @@ import {
|
|||||||
} from '../../lib/scene'
|
} from '../../lib/scene'
|
||||||
import { initSFXBus } from '../../lib/sfx-bus'
|
import { initSFXBus } from '../../lib/sfx-bus'
|
||||||
import useEditor from '../../store/use-editor'
|
import useEditor from '../../store/use-editor'
|
||||||
import { EditorEnvironment } from '../editor-environment'
|
|
||||||
import { CeilingSelectionAffordanceSystem } from '../systems/ceiling/ceiling-selection-affordance-system'
|
import { CeilingSelectionAffordanceSystem } from '../systems/ceiling/ceiling-selection-affordance-system'
|
||||||
import { CeilingSystem } from '../systems/ceiling/ceiling-system'
|
import { CeilingSystem } from '../systems/ceiling/ceiling-system'
|
||||||
import { RoofEditSystem } from '../systems/roof/roof-edit-system'
|
import { RoofEditSystem } from '../systems/roof/roof-edit-system'
|
||||||
@@ -603,7 +608,7 @@ const ViewerSceneContent = memo(function ViewerSceneContent({
|
|||||||
const noEditing = isVersionPreviewMode || isFirstPersonMode || isStudioMode
|
const noEditing = isVersionPreviewMode || isFirstPersonMode || isStudioMode
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<EditorEnvironment />
|
<SceneEnvironment />
|
||||||
{!(isFirstPersonMode || isStudioMode) && <SelectionManager />}
|
{!(isFirstPersonMode || isStudioMode) && <SelectionManager />}
|
||||||
{!noEditing && <BoxSelectTool />}
|
{!noEditing && <BoxSelectTool />}
|
||||||
{!noEditing && <NodeArrowHandles />}
|
{!noEditing && <NodeArrowHandles />}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { Environment } from '@react-three/drei'
|
||||||
|
import { Suspense } from 'react'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scene IBL — drei's prefiltered environment map, exported as an opt-in
|
||||||
|
* <Viewer> *child* rather than baked into the Viewer component, so embed /
|
||||||
|
* thumbnail surfaces that don't want the HDRI fetch simply don't mount it.
|
||||||
|
* This is what gives PBR metals their reflections and lifts the lighting on
|
||||||
|
* vertical surfaces (walls), which flat directional + hemisphere lights can't
|
||||||
|
* do alone. Intensity is dialled below the preset default so it complements
|
||||||
|
* the scene lights rather than washing them out. Only visible in `rendered`
|
||||||
|
* shading.
|
||||||
|
*/
|
||||||
|
export function SceneEnvironment() {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={null}>
|
||||||
|
<Environment preset="sunset" environmentIntensity={0.6} />
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ export {
|
|||||||
DEFAULT_HOVER_STYLES,
|
DEFAULT_HOVER_STYLES,
|
||||||
SSGI_PARAMS,
|
SSGI_PARAMS,
|
||||||
} from './components/viewer/post-processing'
|
} from './components/viewer/post-processing'
|
||||||
|
export { SceneEnvironment } from './components/viewer/scene-environment'
|
||||||
export { WalkthroughControls } from './components/viewer/walkthrough-controls'
|
export { WalkthroughControls } from './components/viewer/walkthrough-controls'
|
||||||
export { useAssetUrl } from './hooks/use-asset-url'
|
export { useAssetUrl } from './hooks/use-asset-url'
|
||||||
export { useGLTFKTX2 } from './hooks/use-gltf-ktx2'
|
export { useGLTFKTX2 } from './hooks/use-gltf-ktx2'
|
||||||
|
|||||||
Reference in New Issue
Block a user