From 726f0d03d57da0146520e71b7304052e7cd9f2e6 Mon Sep 17 00:00:00 2001 From: Kluskey Date: Tue, 22 Oct 2024 01:47:11 -0700 Subject: [PATCH] log --- .../space-engine-non-game-context.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mirror-2/components/engine/non-game-context/space-engine-non-game-context.tsx b/mirror-2/components/engine/non-game-context/space-engine-non-game-context.tsx index b348e971..b3df3f8e 100644 --- a/mirror-2/components/engine/non-game-context/space-engine-non-game-context.tsx +++ b/mirror-2/components/engine/non-game-context/space-engine-non-game-context.tsx @@ -90,10 +90,22 @@ export const SpaceEngineNonGameProvider = ({ children }) => { const observer = new Observer(observerData) // handle changes/updates to entity - // DO NOT use RTK/Redux here; it manages itself separately. Took a lot of hours trying to figure out a solution: it's much easier just to decouple it so that Redux observes the inputs instead of reacting to this Observer system + // DO NOT update RTK/Redux here; it manages itself separately. Took a lot of hours trying to figure out a solution: it's much easier just to decouple it so that Redux "observes" the playcanvas app & makes changes instead of updates getting "pushed" from the Observer. This is doubly good with separation of concerns because the PlayCanvas app shoulnd't know Redux exists. observer.on('*:set', async (path, value) => { // const entityId = extractEntityIdFromJsonPathForObserverStructure(path) // TODO: try out key compare here to reduce calls to update engine, if needed. benchmark + // console.log('path', path) + // console.log('value', value) + // console.log('json', ) + const jsonData: DatabaseEntity = observer.json() as DatabaseEntity + const entityId = jsonData.id + + const engineEntity = app.root.findByGuid(entityId) + + if (engineEntity) { + console.log('find: engine entity', engineEntity) + } + // const currentData = observer.get(id) // const updatedData = observer.get(); // updateEngineApp(updatedData);