Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Entity } from '@etherealengine/engine/src/ecs/classes/Entity'
import { getComponent, hasComponent } from '@etherealengine/engine/src/ecs/functions/ComponentFunctions'
import { entityExists } from '@etherealengine/engine/src/ecs/functions/EntityFunctions'
import { EntityTreeComponent } from '@etherealengine/engine/src/ecs/functions/EntityTree'
import { SceneObjectComponent } from '@etherealengine/engine/src/scene/components/SceneObjectComponent'
import { SceneID } from '@etherealengine/engine/src/schemas/projects/scene.schema'
import { getState } from '@etherealengine/hyperflux'
import { EditorState } from '../../services/EditorServices'
Expand All @@ -49,6 +50,7 @@ export type HeirarchyTreeCollapsedNodeType = { [key: number]: boolean }
*
* @param {entityNode} expandedNodes
*/

export function* heirarchyTreeWalker(
activeScene: SceneID,
treeNode: Entity,
Expand All @@ -64,6 +66,7 @@ export function* heirarchyTreeWalker(
const { depth, entity: entityNode, childIndex, lastChild } = stack.pop() as HeirarchyTreeNodeType

if (!entityExists(entityNode)) continue
if (!hasComponent(entityNode, SceneObjectComponent)) continue

const expandedNodes = getState(EditorState).expandedNodes

Expand Down
6 changes: 3 additions & 3 deletions packages/engine/src/networking/state/EntityNetworkState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export const EntityNetworkState = defineState({
if (!sceneState.activeScene) {
throw new Error('Trying to spawn an object with no active scene')
}
const activeSceneID = SceneState.getCurrentScene()!.root
const activeSceneEntity = UUIDComponent.entitiesByUUID[activeSceneID]

setComponent(entity, EntityTreeComponent, {
parentEntity: activeSceneEntity
parentEntity: SceneState.getRootEntity(getState(SceneState).activeScene!)
})

const spawnPosition = new Vector3()
if (action.position) spawnPosition.copy(action.position)

Expand Down