A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
refactor: separate scene sync from render notification in SceneViewPanel
esengine35a6128c7a03
diff --git a/editor/src/panels/SceneViewPanel.ts b/editor/src/panels/SceneViewPanel.tsindex fbe9c3c37..aa09ead18 100644--- a/editor/src/panels/SceneViewPanel.ts+++ b/editor/src/panels/SceneViewPanel.ts@@ -47,6 +47,7 @@ export class SceneViewPanel {private webglCanvas_: HTMLCanvasElement | null = null;private overlayCanvas_: HTMLCanvasElement | null = null;private unsubscribe_: (() => void) | null = null;+ private unsubscribeSceneSync_: (() => void) | null = null;private unsubscribeFocus_: (() => void) | null = null;private animationId_: number | null = null;private continuousRender_ = false;@@ -192,6 +193,7 @@ export class SceneViewPanel {this.setupEvents();this.unsubscribe_ = store.subscribe(() => this.onSceneChanged());+ this.unsubscribeSceneSync_ = store.subscribeToSceneSync(() => this.onSceneSyncNeeded());this.unsubscribeFocus_ = store.onFocusEntity((entityId) => this.focusOnEntity(entityId));this.resize();@@ -221,6 +223,10 @@ export class SceneViewPanel {this.unsubscribe_();this.unsubscribe_ = null;}+ if (this.unsubscribeSceneSync_) {+ this.unsubscribeSceneSync_();+ this.unsubscribeSceneSync_ = null;+ }if (this.unsubscribeFocus_) {this.unsubscribeFocus_();this.unsubscribeFocus_ = null;@@ -324,16 +330,17 @@ export class SceneViewPanel {await this.sceneRenderer_.syncScene(this.store_.scene);}- private lastLoadVersion_ = -1;-- private async onSceneChanged(): Promise<void> {- if (this.sceneRenderer_ && this.useWebGL_) {- const loadVersion = this.store_.sceneLoadVersion ?? 0;- if (loadVersion !== this.lastLoadVersion_) {- this.lastLoadVersion_ = loadVersion;+ private async onSceneSyncNeeded(): Promise<void> {+ try {+ if (this.sceneRenderer_ && this.useWebGL_) {await this.syncSceneToRenderer();}+ } catch (e) {+ console.warn('[SceneViewPanel] Scene sync error:', e);}+ }++ private onSceneChanged(): void {this.requestRender();}