diff --git a/packages/client-core/src/admin/components/scene/SceneItem.tsx b/packages/client-core/src/admin/components/scene/SceneItem.tsx
index 131568e135..d100b0970a 100644
--- a/packages/client-core/src/admin/components/scene/SceneItem.tsx
+++ b/packages/client-core/src/admin/components/scene/SceneItem.tsx
@@ -43,11 +43,18 @@ import { twMerge } from 'tailwind-merge'
type SceneItemProps = {
scene: StaticResourceType
updateEditorState?: boolean
+ moveMenuUp?: boolean
handleOpenScene: () => void
refetchProjectsData: () => void
}
-export const SceneItem = ({ scene, updateEditorState, handleOpenScene, refetchProjectsData }: SceneItemProps) => {
+export const SceneItem = ({
+ scene,
+ updateEditorState,
+ moveMenuUp,
+ handleOpenScene,
+ refetchProjectsData
+}: SceneItemProps) => {
const { t } = useTranslation()
const editorState = useMutableState(EditorState)
@@ -118,7 +125,8 @@ export const SceneItem = ({ scene, updateEditorState, handleOpenScene, refetchPr
{
+ setComponent(entity, DistanceFromCameraComponent)
+ return () => {
+ if (entityExists(entity)) removeComponent(entity, DistanceFromCameraComponent)
+ }
+ }, [])
+
useEffect(() => {
const source = hasComponent(entity, ModelComponent)
? getModelSceneID(entity)
diff --git a/packages/spatial/src/renderer/components/MeshComponent.ts b/packages/spatial/src/renderer/components/MeshComponent.ts
index 9f1a308fac..af917d2cd4 100644
--- a/packages/spatial/src/renderer/components/MeshComponent.ts
+++ b/packages/spatial/src/renderer/components/MeshComponent.ts
@@ -24,7 +24,7 @@ Ethereal Engine. All Rights Reserved.
*/
import { useEffect } from 'react'
-import { BufferGeometry, Material, Mesh } from 'three'
+import { Box3, BufferGeometry, Material, Mesh } from 'three'
import { Entity, useEntityContext } from '@etherealengine/ecs'
import {
@@ -34,9 +34,10 @@ import {
setComponent,
useComponent
} from '@etherealengine/ecs/src/ComponentFunctions'
-import { State, useImmediateEffect } from '@etherealengine/hyperflux'
+import { NO_PROXY, State, useImmediateEffect } from '@etherealengine/hyperflux'
import { useResource } from '../../resources/resourceHooks'
+import { BoundingBoxComponent } from '../../transform/components/BoundingBoxComponents'
import { addObjectToGroup, removeObjectFromGroup } from './GroupComponent'
export const MeshComponent = defineComponent({
@@ -61,6 +62,16 @@ export const MeshComponent = defineComponent({
!Array.isArray(meshComponent.material.value) ? (meshComponent.material.value as Material).uuid : undefined
)
+ useEffect(() => {
+ const box = geometryResource.boundingBox.get(NO_PROXY) as Box3 | null
+ if (!box) return
+
+ setComponent(entity, BoundingBoxComponent, { box: box })
+ return () => {
+ removeComponent(entity, BoundingBoxComponent)
+ }
+ }, [geometryResource.boundingBox])
+
useEffect(() => {
if (meshComponent.value !== meshResource.value) meshResource.set(meshComponent.value)
}, [meshComponent])
diff --git a/packages/spatial/src/renderer/csm/CSM.ts b/packages/spatial/src/renderer/csm/CSM.ts
index 32e7a338db..40f1a97617 100644
--- a/packages/spatial/src/renderer/csm/CSM.ts
+++ b/packages/spatial/src/renderer/csm/CSM.ts
@@ -43,6 +43,7 @@ import { Engine } from '@etherealengine/ecs/src/Engine'
import { Entity } from '@etherealengine/ecs/src/Entity'
import { createEntity, removeEntity } from '@etherealengine/ecs/src/EntityFunctions'
+import { getState } from '@etherealengine/hyperflux'
import { CameraComponent } from '../../camera/components/CameraComponent'
import { NameComponent } from '../../common/NameComponent'
import { Vector3_Zero } from '../../common/constants/MathConstants'
@@ -51,6 +52,7 @@ import { addObjectToGroup } from '../../renderer/components/GroupComponent'
import { VisibleComponent } from '../../renderer/components/VisibleComponent'
import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
+import { RendererState } from '../RendererState'
import Frustum from './Frustum'
import Shader from './Shader'
@@ -319,7 +321,8 @@ export class CSM {
if (this.sourceLight) this.lightDirection.subVectors(this.sourceLight.target.position, this.sourceLight.position)
if (this.needsUpdate) {
this.injectInclude()
- this.updateFrustums()
+ // Only update uniforms if WebGLRendererSystem isn't already updating them every frame
+ this.updateFrustums(!getState(RendererState).updateCSMFrustums)
for (const light of this.lights) {
light.shadow.map?.dispose()
light.shadow.map = null as any
@@ -439,7 +442,8 @@ export class CSM {
updateUniforms(): void {
const camera = getComponent(Engine.instance.cameraEntity, CameraComponent)
const far = Math.min(camera.far, this.maxFar)
- this.shaders.forEach(function (shader: ShaderType, material: Material) {
+
+ for (const [material, shader] of this.shaders.entries()) {
const camera = getComponent(Engine.instance.cameraEntity, CameraComponent)
if (shader !== null) {
@@ -456,7 +460,7 @@ export class CSM {
material.defines!.CSM_FADE = ''
material.needsUpdate = true
}
- }, this)
+ }
}
getExtendedBreaks(target: Vector2[]): void {
@@ -474,11 +478,11 @@ export class CSM {
}
}
- updateFrustums(): void {
+ updateFrustums(updateUniforms = true): void {
this.getBreaks()
this.initCascades()
this.updateShadowBounds()
- this.updateUniforms()
+ if (updateUniforms) this.updateUniforms()
}
remove(): void {
diff --git a/packages/ui/src/components/editor/panels/Scenes/container/index.tsx b/packages/ui/src/components/editor/panels/Scenes/container/index.tsx
index e11d76ee1b..a85a8f81e7 100644
--- a/packages/ui/src/components/editor/panels/Scenes/container/index.tsx
+++ b/packages/ui/src/components/editor/panels/Scenes/container/index.tsx
@@ -96,6 +96,7 @@ export default function ScenesPanel() {
key={scene.id}
scene={scene}
updateEditorState
+ moveMenuUp={true}
handleOpenScene={() => onClickScene(scene)}
refetchProjectsData={scenesQuery.refetch}
/>