From c0ad302a3f1f2a7a0f1171e54f41d5425b66b693 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 9 Jan 2025 21:08:11 +0900 Subject: [PATCH] Shift transform handling --- src/three/TilesRenderer.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/three/TilesRenderer.js b/src/three/TilesRenderer.js index 4c3a1bc2..7962c468 100644 --- a/src/three/TilesRenderer.js +++ b/src/three/TilesRenderer.js @@ -646,7 +646,22 @@ export class TilesRenderer extends TilesRendererBase { const loader = new GLTFExtensionLoader( manager ); loader.workingPath = workingPath; loader.fetchOptions = fetchOptions; - promise = loader.parse( buffer ); + promise = loader.parse( buffer ).then( result => { + + // apply the local up-axis correction rotation + // GLTFLoader seems to never set a transformation on the root scene object so + // any transformations applied to it can be assumed to be applied after load + // (such as applying RTC_CENTER) meaning they should happen _after_ the z-up + // rotation fix which is why "multiply" happens here. + const { scene } = result; + scene.updateMatrix(); + scene.matrix + .multiply( upRotationMatrix ) + .decompose( scene.position, scene.quaternion, scene.scale ); + + return result; + + } ); break; } @@ -701,18 +716,6 @@ export class TilesRenderer extends TilesRendererBase { // ensure the matrix is up to date in case the scene has a transform applied scene.updateMatrix(); - - // apply the local up-axis correction rotation - // GLTFLoader seems to never set a transformation on the root scene object so - // any transformations applied to it can be assumed to be applied after load - // (such as applying RTC_CENTER) meaning they should happen _after_ the z-up - // rotation fix which is why "multiply" happens here. - if ( fileType === 'glb' || fileType === 'gltf' ) { - - scene.matrix.multiply( upRotationMatrix ); - - } - scene.matrix.premultiply( cachedTransform ); scene.matrix.decompose( scene.position, scene.quaternion, scene.scale ); scene.traverse( c => {