From 15d3a1d73f632380b2a3445ae8e9c3c14c1cfa28 Mon Sep 17 00:00:00 2001 From: Jesse Date: Sat, 4 Nov 2023 06:26:36 -0400 Subject: [PATCH] GLTFLoader: Fix use of setPath with external resources (#27106) * Fix for dispose error sampleRenderTarget is being deleted and set to null by super.dispose(); the check for undefined was incorrect causing an attempt to call dispose on a null object. * Removed disposal of sampleRenderTarget entierly * Fix for setting path not affecting GLTF Sub Assets correctly. * Fixed Comment * Update GLTFLoader.js Fix code style. --------- Co-authored-by: Michael Herzog --- examples/jsm/loaders/GLTFLoader.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index 8436a3d2d6f61a..3660eeca50cfcd 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -183,7 +183,13 @@ class GLTFLoader extends Loader { } else if ( this.path !== '' ) { - resourcePath = this.path; + // If a base path is set, resources will be relative paths from that plus the relative path of the gltf file + // Example path = 'https://my-cnd-server.com/', url = 'assets/models/model.gltf' + // resourcePath = 'https://my-cnd-server.com/assets/models/' + // referenced resource 'model.bin' will be loaded from 'https://my-cnd-server.com/assets/models/model.bin' + // referenced resource '../textures/texture.png' will be loaded from 'https://my-cnd-server.com/assets/textures/texture.png' + const relativeUrl = LoaderUtils.extractUrlBase( url ); + resourcePath = LoaderUtils.resolveURL( relativeUrl, this.path ); } else {