From ddb25caba4ce941650d3fe77651bc378fa26cd71 Mon Sep 17 00:00:00 2001 From: Dario Sanchez <110812521+dswhy@users.noreply.github.com> Date: Wed, 29 Apr 2026 14:31:03 +0200 Subject: [PATCH 1/2] Fix: IESSpotLight hot swap texture and dedup fixes. Update example. (#33502) --- src/nodes/lighting/IESSpotLightNode.js | 42 ++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/nodes/lighting/IESSpotLightNode.js b/src/nodes/lighting/IESSpotLightNode.js index 044959bbba1622..4a096debd3a7bf 100644 --- a/src/nodes/lighting/IESSpotLightNode.js +++ b/src/nodes/lighting/IESSpotLightNode.js @@ -15,6 +15,25 @@ class IESSpotLightNode extends SpotLightNode { } + /** + * Constructs a new IES spot light node. + * + * @param {?SpotLight} [light=null] - The spot light source. + */ + constructor( light = null ) { + + super( light ); + + /** + * The texture node representing the IES texture. + * + * @type {?TextureNode} + * @default null + */ + this._iesTextureNode = null; + + } + /** * Overwrites the default implementation to compute an IES conform spot attenuation. * @@ -32,11 +51,13 @@ class IESSpotLightNode extends SpotLightNode { const angle = angleCosine.acos().mul( 1.0 / Math.PI ); - spotAttenuation = texture( iesMap, vec2( angle, 0 ), 0 ).r; + this._iesTextureNode = texture( iesMap, vec2( angle, 0 ), 0 ); + + spotAttenuation = this._iesTextureNode.r; } else { - spotAttenuation = super.getSpotAttenuation( angleCosine ); + spotAttenuation = super.getSpotAttenuation( builder, angleCosine ); } @@ -44,6 +65,23 @@ class IESSpotLightNode extends SpotLightNode { } + /** + * Overwritten to update the IES spot light texture. + * + * @param {NodeFrame} frame - A reference to the current node frame. + */ + update( frame ) { + + super.update( frame ); + + if ( this._iesTextureNode !== null && this.light.iesMap ) { + + this._iesTextureNode.value = this.light.iesMap; + + } + + } + } export default IESSpotLightNode; From 062a743fa753c839c6d5cd3e77a83829770645ea Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 30 Apr 2026 00:14:29 +0800 Subject: [PATCH 2/2] MikkTSpace: Add `dispose()`, cache promise. (#33501) Co-authored-by: Michael Herzog --- examples/jsm/libs/mikktspace.module.js | 43 ++++++++++++++++++++------ 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/examples/jsm/libs/mikktspace.module.js b/examples/jsm/libs/mikktspace.module.js index 0a1baaa3a4339d..28da574cb35cea 100644 --- a/examples/jsm/libs/mikktspace.module.js +++ b/examples/jsm/libs/mikktspace.module.js @@ -117,12 +117,37 @@ export let wasm; export let isReady = false; -export const ready = fetch(wasmDataURI) - .then((res) => res.arrayBuffer()) - .then((buffer) => WebAssembly.instantiate(buffer, { - './mikktspace_module_bg.js': {__wbindgen_string_new, __wbindgen_rethrow} - })) - .then((result) => { - wasm = result.instance.exports; - isReady = true; - }); +let readyPromise = null; + +function initialize() { + + return fetch( wasmDataURI ) + .then( ( res ) => res.arrayBuffer() ) + .then( ( buffer ) => WebAssembly.instantiate( buffer, { + './mikktspace_module_bg.js': { __wbindgen_string_new, __wbindgen_rethrow } + } ) ) + .then( ( result ) => { + + wasm = result.instance.exports; + isReady = true; + + } ); + +} + +export const ready = { + then: function ( onFulfilled, onRejected ) { + + if ( readyPromise === null ) readyPromise = initialize(); + return readyPromise.then( onFulfilled, onRejected ); + + } +}; + +export function dispose() { + + wasm = null; + isReady = false; + readyPromise = null; + +}