UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

41 lines 1.56 kB
import { CubeUVReflectionMapping } from "three"; import { getParam } from "../engine_utils.js"; const debug = getParam("debugexr") || getParam("debugpmrem"); export class NEEDLE_pmrem { get name() { return "NEEDLE_pmrem"; } parser; constructor(parser) { this.parser = parser; } loadTexture(textureIndex) { const name = this.name; const parser = this.parser; const json = parser.json; const textureDef = json.textures[textureIndex]; if (!textureDef.extensions || !textureDef.extensions[name]) { return null; } const extension = textureDef.extensions[name]; // Use the KTX2Loader already configured on the GLTFLoader (with GPU support detection) const loader = parser.options.ktx2Loader; if (!loader) { console.warn("NEEDLE_pmrem: No KTX2Loader available on GLTFLoader — cannot load PMREM texture"); return null; } if (debug) console.log("NEEDLE_pmrem.loadTexture", textureIndex, extension); const promise = parser.loadTextureImage(textureIndex, extension.source, loader); return promise.then(tex => { NEEDLE_pmrem.postprocess(tex); tex.name = "PMREM_" + tex.name; if (debug) console.log("NEEDLE_pmrem: loaded PMREM texture", tex); return tex; }); } static postprocess(tex) { tex.mapping = CubeUVReflectionMapping; return tex; } } //# sourceMappingURL=NEEDLE_pmrem.js.map