diff --git a/packages/engine/src/scene/components/UVOL1Component.ts b/packages/engine/src/scene/components/UVOL1Component.ts index f257e6472c..d1bf6fed00 100644 --- a/packages/engine/src/scene/components/UVOL1Component.ts +++ b/packages/engine/src/scene/components/UVOL1Component.ts @@ -44,6 +44,7 @@ import { EngineState } from '../../ecs/classes/EngineState' import { defineComponent, getMutableComponent, + getOptionalMutableComponent, hasComponent, removeComponent, setComponent, @@ -160,9 +161,11 @@ function UVOL1Reactor() { if (volumetric.useLoadingEffect.value) { setComponent(entity, UVOLDissolveComponent) } - const shadow = getMutableComponent(entity, ShadowComponent) - shadow.cast.set(true) - shadow.receive.set(true) + const shadow = getOptionalMutableComponent(entity, ShadowComponent) + if (shadow) { + shadow.cast.set(true) + shadow.receive.set(true) + } video.src = component.manifestPath.value.replace('.manifest', '.mp4') video.load() diff --git a/packages/engine/src/scene/components/UVOL2Component.ts b/packages/engine/src/scene/components/UVOL2Component.ts index 123fba4168..6bd74768ba 100644 --- a/packages/engine/src/scene/components/UVOL2Component.ts +++ b/packages/engine/src/scene/components/UVOL2Component.ts @@ -48,6 +48,7 @@ import { EngineState } from '../../ecs/classes/EngineState' import { defineComponent, getMutableComponent, + getOptionalMutableComponent, removeComponent, setComponent, useComponent @@ -401,12 +402,12 @@ transformed.z += mix(keyframeA.z, keyframeB.z, mixRatio); manifest.current = calculatePriority(component.data.get({ noproxy: true })) component.data.set(manifest.current) - const shadow = getMutableComponent(entity, ShadowComponent) - if (manifest.current.type === UVOL_TYPE.UNIFORM_SOLVE_WITH_COMPRESSED_TEXTURE) { + const shadow = getOptionalMutableComponent(entity, ShadowComponent) + if (manifest.current.type === UVOL_TYPE.UNIFORM_SOLVE_WITH_COMPRESSED_TEXTURE && shadow) { // TODO: Cast shadows properly with uniform solve shadow.cast.set(false) shadow.receive.set(false) - } else { + } else if (shadow) { shadow.cast.set(true) shadow.receive.set(true) } diff --git a/packages/engine/src/scene/components/VolumetricComponent.ts b/packages/engine/src/scene/components/VolumetricComponent.ts index 5c0cfd483c..bf3b8e2936 100755 --- a/packages/engine/src/scene/components/VolumetricComponent.ts +++ b/packages/engine/src/scene/components/VolumetricComponent.ts @@ -40,6 +40,7 @@ import { useEntityContext } from '../../ecs/functions/EntityFunctions' import { EngineRenderer } from '../../renderer/WebGLRendererSystem' import { PlayMode } from '../constants/PlayMode' import { AudioNodeGroups, MediaElementComponent, createAudioNodeGroup, getNextTrack } from './MediaComponent' +import { ShadowComponent } from './ShadowComponent' import { UVOL1Component } from './UVOL1Component' import { UVOL2Component } from './UVOL2Component' @@ -166,6 +167,7 @@ export function VolumetricReactor() { setComponent(entity, MediaElementComponent, { element: document.createElement('video') as HTMLMediaElement }) + setComponent(entity, ShadowComponent) const videoElement = getMutableComponent(entity, MediaElementComponent) const element = videoElement.element.value as HTMLVideoElement element.playsInline = true