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

Commit

Permalink
Merge branch 'dev' into ir-3787
Browse files Browse the repository at this point in the history
  • Loading branch information
dtlehrer authored Aug 14, 2024
2 parents 4c0e294 + bce156b commit 07f8a0f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 21 deletions.
12 changes: 10 additions & 2 deletions packages/client-core/src/admin/components/scene/SceneItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -118,7 +125,8 @@ export const SceneItem = ({ scene, updateEditorState, handleOpenScene, refetchPr
<ul
className={twMerge(
'fixed z-10 block w-max translate-x-5 rounded-lg bg-theme-primary px-4 py-3 pr-10',
showContentMenu.value ? 'visible' : 'hidden'
showContentMenu.value ? 'visible' : 'hidden',
moveMenuUp ? '-translate-y-10' : ''
)}
style={{
top: menuPosition.top.value,
Expand Down
6 changes: 0 additions & 6 deletions packages/editor/src/components/prefabs/PrefabEditors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ export const PrefabShelfState = defineState({
category: 'Collider',
detail: 'Simple cylinder collider'
},
{
name: 'Mesh Collider',
url: `${config.client.fileServer}/projects/default-project/assets/prefabs/mesh-collider.prefab.gltf`,
category: 'Collider',
detail: 'Simple mesh collider, drag and drop your mesh'
},
{
name: 'Text',
url: `${config.client.fileServer}/projects/default-project/assets/prefabs/text.prefab.gltf`,
Expand Down
4 changes: 1 addition & 3 deletions packages/editor/src/functions/EditorControlFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
import { Entity } from '@etherealengine/ecs/src/Entity'
import { GLTFDocumentState, GLTFSnapshotAction } from '@etherealengine/engine/src/gltf/GLTFDocumentState'
import { GLTFSnapshotState, GLTFSourceState } from '@etherealengine/engine/src/gltf/GLTFState'
import { PrimitiveGeometryComponent } from '@etherealengine/engine/src/scene/components/PrimitiveGeometryComponent'
import { SkyboxComponent } from '@etherealengine/engine/src/scene/components/SkyboxComponent'
import { SourceComponent } from '@etherealengine/engine/src/scene/components/SourceComponent'
import { TransformSpace } from '@etherealengine/engine/src/scene/constants/transformConstants'
Expand Down Expand Up @@ -224,8 +223,7 @@ const overwriteLookdevObject = (
SkyboxComponent,
HemisphereLightComponent,
DirectionalLightComponent,
PostProcessingComponent,
PrimitiveGeometryComponent //this component is for test will remove later
PostProcessingComponent
]
let overwrited = false
for (const comp of lookDevComponent) {
Expand Down
1 change: 0 additions & 1 deletion packages/engine/src/scene/components/ModelComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ function ModelReactor() {
/**if we've loaded or converted to vrm, create animation component whose mixer's root is the normalized rig */
if (boneMatchedAsset instanceof VRM)
setComponent(entity, AnimationComponent, {
animations: gltf.animations,
mixer: new AnimationMixer(boneMatchedAsset.humanoid.normalizedHumanBonesRoot)
})

Expand Down
11 changes: 9 additions & 2 deletions packages/engine/src/scene/systems/SceneObjectSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
Texture
} from 'three'

import { useEntityContext, UUIDComponent } from '@etherealengine/ecs'
import { entityExists, useEntityContext, UUIDComponent } from '@etherealengine/ecs'
import {
getComponent,
getOptionalComponent,
Expand All @@ -52,7 +52,7 @@ import { Entity, EntityUUID } from '@etherealengine/ecs/src/Entity'
import { defineQuery, QueryReactor } from '@etherealengine/ecs/src/QueryFunctions'
import { defineSystem } from '@etherealengine/ecs/src/SystemFunctions'
import { AnimationSystemGroup } from '@etherealengine/ecs/src/SystemGroups'
import { getMutableState, getState, useHookstate } from '@etherealengine/hyperflux'
import { getMutableState, getState, useHookstate, useImmediateEffect } from '@etherealengine/hyperflux'
import { CallbackComponent } from '@etherealengine/spatial/src/common/CallbackComponent'
import { ColliderComponent } from '@etherealengine/spatial/src/physics/components/ColliderComponent'
import { RigidBodyComponent } from '@etherealengine/spatial/src/physics/components/RigidBodyComponent'
Expand Down Expand Up @@ -167,6 +167,13 @@ function SceneObjectReactor(props: { entity: Entity; obj: Object3D }) {
const renderState = getMutableState(RendererState)
const forceBasicMaterials = useHookstate(renderState.forceBasicMaterials)

useImmediateEffect(() => {
setComponent(entity, DistanceFromCameraComponent)
return () => {
if (entityExists(entity)) removeComponent(entity, DistanceFromCameraComponent)
}
}, [])

useEffect(() => {
const source = hasComponent(entity, ModelComponent)
? getModelSceneID(entity)
Expand Down
15 changes: 13 additions & 2 deletions packages/spatial/src/renderer/components/MeshComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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({
Expand All @@ -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])
Expand Down
14 changes: 9 additions & 5 deletions packages/spatial/src/renderer/csm/CSM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -456,7 +460,7 @@ export class CSM {
material.defines!.CSM_FADE = ''
material.needsUpdate = true
}
}, this)
}
}

getExtendedBreaks(target: Vector2[]): void {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default function ScenesPanel() {
key={scene.id}
scene={scene}
updateEditorState
moveMenuUp={true}
handleOpenScene={() => onClickScene(scene)}
refetchProjectsData={scenesQuery.refetch}
/>
Expand Down

0 comments on commit 07f8a0f

Please sign in to comment.