diff --git a/src/EnvironmentProvider.tsx b/src/EnvironmentProvider.tsx index d4fca7a..67e9ab2 100644 --- a/src/EnvironmentProvider.tsx +++ b/src/EnvironmentProvider.tsx @@ -10,6 +10,7 @@ export default function EnvironmentProvider({ const [selectedEnvironment, setSelectedEnvironment] = useState( null ); + const [showEnvironment, setShowEnvironment] = useState(false); const { basePath } = useSettings(); const context = useMemo(() => { @@ -19,9 +20,11 @@ export default function EnvironmentProvider({ return { selectedEnvironment, setSelectedEnvironment, + showEnvironment, + setShowEnvironment, environmentImageUrl, }; - }, [basePath, selectedEnvironment, setSelectedEnvironment]); + }, [basePath, selectedEnvironment, showEnvironment]); return ( diff --git a/src/EnvironmentSelector.tsx b/src/EnvironmentSelector.tsx index adcb688..b35417b 100644 --- a/src/EnvironmentSelector.tsx +++ b/src/EnvironmentSelector.tsx @@ -1,7 +1,12 @@ import useEnvironment from "./useEnvironment"; export default function EnvironmentSelector() { - const { selectedEnvironment, setSelectedEnvironment } = useEnvironment(); + const { + selectedEnvironment, + setSelectedEnvironment, + showEnvironment, + setShowEnvironment, + } = useEnvironment(); return ( <> diff --git a/src/ModelViewer.tsx b/src/ModelViewer.tsx index b279a89..36a2291 100644 --- a/src/ModelViewer.tsx +++ b/src/ModelViewer.tsx @@ -30,6 +30,7 @@ function useTimeScale(modelViewer: ModelViewerElement | null) { interface ModelViewerProps { modelUrl: string; environmentImageUrl: string | null; + showEnvironment?: boolean; colorImageUrl?: string; metallicImageUrl?: string; animationName: string | null; @@ -43,6 +44,7 @@ interface ModelViewerProps { function ModelViewerKeyedByModel({ modelUrl, environmentImageUrl, + showEnvironment = false, animationName, animationPaused = false, cameraOrbit, @@ -119,15 +121,25 @@ function ModelViewerKeyedByModel({ ref={setModelViewer} alt="Tribes 2 Model" src={modelUrl} - shadow-intensity={0} camera-controls camera-orbit={cameraOrbit} + max-camera-orbit={ + environmentImageUrl && showEnvironment ? "auto 90deg auto" : undefined + } camera-target={cameraTarget} min-field-of-view="10deg" + max-field-of-view="45deg" animation-name={animationName ?? undefined} autoplay={animationName ? "true" : "false"} touch-action="pan-y" environment-image={environmentImageUrl ?? undefined} + skybox-image={ + environmentImageUrl && showEnvironment + ? environmentImageUrl + : undefined + } + skybox-height="1.5m" + shadow-intensity={environmentImageUrl && showEnvironment ? 1 : 0} style={{ width: "100%", height: "100%" }} /> {isLoaded ? ( diff --git a/src/WarriorViewer.tsx b/src/WarriorViewer.tsx index 1f80b88..5b155b1 100644 --- a/src/WarriorViewer.tsx +++ b/src/WarriorViewer.tsx @@ -18,12 +18,13 @@ export default function WarriorViewer() { selectedAnimation, animationPaused, } = useWarrior(); - const { environmentImageUrl } = useEnvironment(); + const { environmentImageUrl, showEnvironment } = useEnvironment(); return ( void; + showEnvironment: boolean; + setShowEnvironment: (showEnvironment: boolean) => void; environmentImageUrl: string | null; }