Skip to content

Commit

Permalink
Add deferral of initialization for TextureReadUtility
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Jan 15, 2025
1 parent 41a3048 commit 517b1d4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/plugins/three/gltf/metadata/utilities/TextureReadUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js';
const _box = /* @__PURE__ */ new Box2();

// Utility for reading sets of individual pixel values from textures
export const TextureReadUtility = new ( class {
class _TextureReadUtility {

constructor() {

Expand Down Expand Up @@ -88,4 +88,32 @@ export const TextureReadUtility = new ( class {

}

}

// Create a wrapper class to defer instantiation of the WebGLRenderer until it's needed
// See NASA-AMMOS/3DTilesRendererJS#905
export const TextureReadUtility = /* @__PURE__ */ new ( class {

constructor() {

let reader = null;
Object
.getOwnPropertyNames( _TextureReadUtility.prototype )
.forEach( key => {

if ( key !== 'constructor' ) {

this[ key ] = ( ...args ) => {

reader = reader || new _TextureReadUtility();
return reader[ key ]( ...args );

};

}

} );

}

} )();

0 comments on commit 517b1d4

Please sign in to comment.