From b4289a2bb7de141fdcb086fa6c9f5b212fc5cd9c Mon Sep 17 00:00:00 2001 From: mistic100 Date: Tue, 30 Jul 2024 13:18:43 +0200 Subject: [PATCH] Fix #1394 Closes #1395 performance issues during transitions - Remove call to Renderer#clearDepth --- .../core/src/adapters/EquirectangularAdapter.ts | 15 ++++++++++++--- packages/core/src/services/Renderer.ts | 4 ---- packages/cubemap-adapter/src/CubemapAdapter.ts | 15 ++++++++++++--- .../src/CubemapTilesAdapter.ts | 11 ++++++++--- .../src/EquirectangularTilesAdapter.ts | 13 +++++++++---- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/packages/core/src/adapters/EquirectangularAdapter.ts b/packages/core/src/adapters/EquirectangularAdapter.ts index d7904edcf..684dc682c 100644 --- a/packages/core/src/adapters/EquirectangularAdapter.ts +++ b/packages/core/src/adapters/EquirectangularAdapter.ts @@ -367,11 +367,20 @@ export class EquirectangularAdapter extends AbstractAdapter this.__refresh()); } - private __setTexture(mesh: CubemapMesh, { texture, panoData }: CubemapTexture) { + private __setTexture(mesh: CubemapMesh, { texture, panoData }: CubemapTexture, transition: boolean) { for (let i = 0; i < 6; i++) { let material; if (texture) { @@ -227,6 +227,11 @@ export class CubemapTilesAdapter extends AbstractAdapter< material = new MeshBasicMaterial({ opacity: 0, transparent: true }); } + if (transition) { + material.depthTest = false; + material.depthWrite = false; + } + for (let j = 0; j < NB_GROUPS_BY_FACE; j++) { mesh.material.push(material); } diff --git a/packages/equirectangular-tiles-adapter/src/EquirectangularTilesAdapter.ts b/packages/equirectangular-tiles-adapter/src/EquirectangularTilesAdapter.ts index 0e7d27306..a35d09bcc 100644 --- a/packages/equirectangular-tiles-adapter/src/EquirectangularTilesAdapter.ts +++ b/packages/equirectangular-tiles-adapter/src/EquirectangularTilesAdapter.ts @@ -270,17 +270,17 @@ export class EquirectangularTilesAdapter extends AbstractAdapter< /** * Applies the base texture and starts the loading of tiles */ - setTexture(mesh: EquirectangularMesh, textureData: EquirectangularTexture, transition: boolean) { + setTexture(mesh: EquirectangularMesh, textureData: EquirectangularTexture, transition?: boolean) { const { texture } = textureData; if (transition) { this.state.inTransition = true; - this.__setTexture(mesh, texture); + this.__setTexture(mesh, texture, true); return; } this.__cleanup(); - this.__setTexture(mesh, texture); + this.__setTexture(mesh, texture, false); this.state.materials = mesh.material; this.state.geom = mesh.geometry; @@ -295,7 +295,7 @@ export class EquirectangularTilesAdapter extends AbstractAdapter< setTimeout(() => this.__refresh()); } - private __setTexture(mesh: EquirectangularMesh, texture: Texture) { + private __setTexture(mesh: EquirectangularMesh, texture: Texture, transition: boolean) { let material; if (texture) { material = new MeshBasicMaterial({ map: texture }); @@ -303,6 +303,11 @@ export class EquirectangularTilesAdapter extends AbstractAdapter< material = new MeshBasicMaterial({ color: this.config.backgroundColor }); } + if (transition) { + material.depthTest = false; + material.depthWrite = false; + } + for (let i = 0; i < this.NB_GROUPS; i++) { mesh.material.push(material); }