Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Check for shadow component
Browse files Browse the repository at this point in the history
  • Loading branch information
CITIZENDOT committed Nov 16, 2023
1 parent f4a8b2c commit 6f7bb54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions packages/engine/src/scene/components/UVOL1Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { EngineState } from '../../ecs/classes/EngineState'
import {
defineComponent,
getMutableComponent,
getOptionalMutableComponent,
hasComponent,
removeComponent,
setComponent,
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 4 additions & 3 deletions packages/engine/src/scene/components/UVOL2Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { EngineState } from '../../ecs/classes/EngineState'
import {
defineComponent,
getMutableComponent,
getOptionalMutableComponent,
removeComponent,
setComponent,
useComponent
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/engine/src/scene/components/VolumetricComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f7bb54

Please sign in to comment.