Skip to content

Commit

Permalink
fix(scene): fix dynamic scene entity binding reload on query
Browse files Browse the repository at this point in the history
  • Loading branch information
haweston authored and mumanity committed Jun 12, 2024
1 parent ee0e11b commit d8a1b89
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
63 changes: 63 additions & 0 deletions packages/scene-composer/src/utils/entityModelUtils/sceneUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { isEmpty } from 'lodash';

import {
DEFAULT_PARENT_RELATIONSHIP_NAME,
DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME,
SCENE_ROOT_ENTITY_COMPONENT_NAME,
SCENE_ROOT_ENTITY_ID,
SCENE_ROOT_ENTITY_NAME,
Expand Down Expand Up @@ -188,60 +189,122 @@ export const fetchSceneNodes = async (sceneRootEntityId: string): Promise<IScene
match (entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
// Get entityBindings for this layer of the scene tree
`select entity, rb, binding
from EntityGraph
match (binding)<-[rb]-(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,

`select c, r1, entity
from EntityGraph
match (c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
`select c, rb1, binding
from EntityGraph
match (binding)<-[rb1]-(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb1.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,

`select c2, r2, c
from EntityGraph
match (c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
`select c2, rb2, binding
from EntityGraph
match (binding)<-[rb2]-(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb2.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,

`select c3, r3, c2
from EntityGraph
match (c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
`select c3, rb3, binding
from EntityGraph
match (binding)<-[rb3]-(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb3.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,

`select c4, r4, c3
from EntityGraph
match (c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
`select c4, rb4, binding
from EntityGraph
match (binding)<-[rb4]-(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb4.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,

`select c5, r5, c4
from EntityGraph
match (c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
`select c5, rb5, binding
from EntityGraph
match (binding)<-[rb5]-(c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb5.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,

`select c6, r6, c5
from EntityGraph
match (c6)-[r6]->(c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
`select c6, rb6, binding
from EntityGraph
match (binding)<-[rb6]-(c6)-[r6]->(c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb6.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,

`select c7, r7, c6
from EntityGraph
match (c7)-[r7]->(c6)-[r6]->(c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
`select c7, rb7, binding
from EntityGraph
match (binding)<-[rb7]-(c7)-[r7]->(c6)-[r6]->(c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb7.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,

`select c8, r8, c7
from EntityGraph
match (c8)-[r8]->(c7)-[r7]->(c6)-[r6]->(c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
`select c8, rb8, binding
from EntityGraph
match (binding)<-[rb8]-(c8)-[r8]->(c7)-[r7]->(c6)-[r6]->(c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb8.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,

`select c9, r9, c8
from EntityGraph
match (c9)-[r9]->(c8)-[r8]->(c7)-[r7]->(c6)-[r6]->(c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'`,
//this one may fail as it's depth 11 effectively
`select c9, rb9, binding
from EntityGraph
match (binding)<-[rb9]-(c9)-[r9]->(c8)-[r8]->(c7)-[r7]->(c6)-[r6]->(c5)-[r5]->(c4)-[r4]->(c3)-[r3]->(c2)-[r2]->(c)-[r1]->(entity)-[r]->(e)
where r.relationshipName = '${DEFAULT_PARENT_RELATIONSHIP_NAME}'
and e.entityId = '${sceneRootEntityId}'
and rb9.relationshipName = '${DEFAULT_ENTITY_BINDING_RELATIONSHIP_NAME}'`,
]);

return nodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const updateEntity = async (
compsToBeUpdated?: ISceneComponentInternal[],
updateType?: ComponentUpdateType,
oldNode?: ISceneNodeInternal,
//oldParentRef?: string | undefined,
sceneRootEntityId?: string | undefined,
): Promise<void> => {
const sceneMetadataModule = getGlobalSettings().twinMakerSceneMetadataModule;
Expand Down

0 comments on commit d8a1b89

Please sign in to comment.