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

Commit

Permalink
fix properties panel crash in certain cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dinomut1 committed May 25, 2024
1 parent dbb8067 commit 75d677f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Popover } from '@mui/material'
import React from 'react'
import { useTranslation } from 'react-i18next'

import { EntityUUID, UUIDComponent } from '@etherealengine/ecs'
import { EntityUUID, UUIDComponent, entityExists } from '@etherealengine/ecs'
import { Component, ComponentJSONIDMap, useOptionalComponent } from '@etherealengine/ecs/src/ComponentFunctions'
import { MaterialSelectionState } from '@etherealengine/engine/src/scene/materials/MaterialLibraryState'
import { NO_PROXY, getMutableState, getState, useHookstate } from '@etherealengine/hyperflux'
Expand Down Expand Up @@ -122,6 +122,8 @@ export const PropertiesPanelContainer = () => {
const multiEdit = selectedEntities.length > 1
const uuid = lockedNode.value ? lockedNode.value : selectedEntities[selectedEntities.length - 1]

const entity = UUIDComponent.useEntityByUUID(uuid)

const { t } = useTranslation()
const materialUUID = useHookstate(getMutableState(MaterialSelectionState).selectedMaterial).value

Expand All @@ -134,7 +136,7 @@ export const PropertiesPanelContainer = () => {
>
{materialUUID ? (
<MaterialEditor materialUUID={materialUUID} />
) : uuid ? (
) : uuid && entity && entityExists(entity) ? (
<EntityEditor entityUUID={uuid} key={uuid} multiEdit={multiEdit} />
) : (
<div
Expand Down
4 changes: 4 additions & 0 deletions packages/engine/src/scene/components/ModelComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { GroupComponent, addObjectToGroup } from '@etherealengine/spatial/src/re
import { MeshComponent } from '@etherealengine/spatial/src/renderer/components/MeshComponent'
import {
EntityTreeComponent,
iterateEntityNode,
removeEntityNodeRecursively
} from '@etherealengine/spatial/src/transform/components/EntityTree'
import { VRM } from '@pixiv/three-vrm'
Expand Down Expand Up @@ -233,6 +234,9 @@ function ModelReactor() {
if (!parentEntity) return
const parentUUID = getComponent(parentEntity, UUIDComponent)
const parentSource = getComponent(parentEntity, SourceComponent)
iterateEntityNode(entity, (entity) => {
setComponent(entity, SourceComponent, parentSource)
})
GLTFSnapshotState.injectSnapshot(modelUUID, sourceID, parentUUID, parentSource)
}, [modelComponent.dereference, gltfDocumentState[modelSceneID]])

Expand Down

0 comments on commit 75d677f

Please sign in to comment.