three-stdlib 2.21.12 → 2.22.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/index.cjs.js +1 -1
  2. package/interactive/HTMLMesh.cjs.js +1 -1
  3. package/interactive/HTMLMesh.js +3 -2
  4. package/lights/LightProbeGenerator.cjs.js +1 -1
  5. package/lights/LightProbeGenerator.js +19 -20
  6. package/loaders/3MFLoader.cjs.js +1 -1
  7. package/loaders/3MFLoader.js +3 -2
  8. package/loaders/EXRLoader.cjs.js +1 -1
  9. package/loaders/EXRLoader.js +4 -4
  10. package/loaders/FBXLoader.cjs.js +1 -1
  11. package/loaders/FBXLoader.js +5 -5
  12. package/loaders/GLTFLoader.cjs.js +1 -1
  13. package/loaders/GLTFLoader.js +7 -6
  14. package/loaders/HDRCubeTextureLoader.cjs.js +1 -1
  15. package/loaders/HDRCubeTextureLoader.js +3 -8
  16. package/loaders/KTX2Loader.cjs.js +1 -1
  17. package/loaders/KTX2Loader.js +65 -21
  18. package/loaders/NodeMaterialLoader.cjs.js +1 -1
  19. package/loaders/RGBELoader.cjs.js +1 -1
  20. package/loaders/RGBELoader.js +3 -2
  21. package/misc/MD2Character.cjs.js +1 -1
  22. package/misc/MD2Character.js +2 -2
  23. package/misc/MD2CharacterComplex.cjs.js +1 -1
  24. package/misc/MD2CharacterComplex.js +2 -2
  25. package/nodes/Nodes.cjs.js +1 -1
  26. package/nodes/core/NodeBuilder.cjs.js +1 -1
  27. package/nodes/core/NodeBuilder.js +4 -4
  28. package/nodes/display/ColorSpaceNode.cjs.js +1 -1
  29. package/nodes/display/ColorSpaceNode.js +2 -3
  30. package/nodes/loaders/NodeLoader.cjs.js +1 -1
  31. package/nodes/loaders/NodeObjectLoader.cjs.js +1 -1
  32. package/objects/Reflector.cjs.js +1 -1
  33. package/objects/Reflector.js +1 -1
  34. package/objects/ReflectorForSSRPass.cjs.js +1 -1
  35. package/objects/ReflectorForSSRPass.js +1 -1
  36. package/objects/Refractor.cjs.js +1 -1
  37. package/objects/Refractor.js +1 -1
  38. package/objects/Water2.cjs.js +1 -1
  39. package/objects/Water2.js +2 -2
  40. package/package.json +1 -1
  41. package/postprocessing/SSRPass.cjs.js +1 -1
  42. package/postprocessing/SSRPass.js +4 -1
  43. package/renderers/webgpu/WebGPUTextures.cjs.js +1 -1
  44. package/renderers/webgpu/WebGPUTextures.js +6 -6
  45. /package/{Nodes-9aa16d74.js → Nodes-8d3adda1.js} +0 -0
  46. /package/{Nodes-4f766d71.js → Nodes-b3c0e6fc.js} +0 -0
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("../BufferGeometryUtils-903f7ecb.js");require("../types/helpers.cjs.js");class s extends e.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new c(e)})),this.register((function(e){return new f(e)})),this.register((function(e){return new A(e)})),this.register((function(e){return new g(e)})),this.register((function(e){return new u(e)})),this.register((function(e){return new h(e)})),this.register((function(e){return new d(e)})),this.register((function(e){return new m(e)})),this.register((function(e){return new a(e)})),this.register((function(e){return new p(e)})),this.register((function(e){return new l(e)})),this.register((function(e){return new i(e)})),this.register((function(e){return new T(e)})),this.register((function(e){return new x(e)}))}load(t,s,n,r){const i=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:e.LoaderUtils.extractUrlBase(t),this.manager.itemStart(t);const a=function(e){r?r(e):console.error(e),i.manager.itemError(t),i.manager.itemEnd(t)},c=new e.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(t,(function(e){try{i.parse(e,o,(function(e){s(e),i.manager.itemEnd(t)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(t,s,n,i){let a;const c={},l={};if("string"==typeof t)a=JSON.parse(t);else if(t instanceof ArrayBuffer){if(e.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4)))===R){try{c[r.KHR_BINARY_GLTF]=new v(t)}catch(e){return void(i&&i(e))}a=JSON.parse(c[r.KHR_BINARY_GLTF].content)}else a=JSON.parse(e.LoaderUtils.decodeText(new Uint8Array(t)))}else a=t;if(void 0===a.asset||a.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const u=new W(a,{path:s||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](u);l[t.name]=t,c[t.name]=!0}if(a.extensionsUsed)for(let e=0;e<a.extensionsUsed.length;++e){const t=a.extensionsUsed[e],s=a.extensionsRequired||[];switch(t){case r.KHR_MATERIALS_UNLIT:c[t]=new o;break;case r.KHR_DRACO_MESH_COMPRESSION:c[t]=new w(a,this.dracoLoader);break;case r.KHR_TEXTURE_TRANSFORM:c[t]=new L;break;case r.KHR_MESH_QUANTIZATION:c[t]=new M;break;default:s.indexOf(t)>=0&&void 0===l[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}u.setExtensions(c),u.setPlugins(l),u.parse(n,i)}parseAsync(e,t){const s=this;return new Promise((function(n,r){s.parse(e,t,n,r)}))}}function n(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const r={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class i{constructor(e){this.parser=e,this.name=r.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(t){const s=this.parser,n="light:"+t;let r=s.cache.get(n);if(r)return r;const i=s.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let a;const c=new e.Color(16777215);void 0!==o.color&&c.fromArray(o.color);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new e.DirectionalLight(c),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new e.PointLight(c),a.distance=l;break;case"spot":a=new e.SpotLight(c),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,j(a,o),void 0!==o.intensity&&(a.intensity=o.intensity),a.name=s.createUniqueName(o.name||"light_"+t),r=Promise.resolve(a),s.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,n=s.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return s._getNodeRef(t.cache,r,e)}))}}class o{constructor(){this.name=r.KHR_MATERIALS_UNLIT}getMaterialType(){return e.MeshBasicMaterial}extendParams(t,s,n){const r=[];t.color=new e.Color(1,1,1),t.opacity=1;const i=s.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;t.color.fromArray(e),t.opacity=e[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(t,"map",i.baseColorTexture,e.sRGBEncoding))}return Promise.all(r)}}class a{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class c{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];if(void 0!==o.clearcoatFactor&&(s.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&i.push(n.assignTexture(s,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(s.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&i.push(n.assignTexture(s,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(i.push(n.assignTexture(s,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const t=o.clearcoatNormalTexture.scale;s.clearcoatNormalScale=new e.Vector2(t,t)}return Promise.all(i)}}class l{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&r.push(s.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&r.push(s.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class u{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_SHEEN}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];s.sheenColor=new e.Color(0,0,0),s.sheenRoughness=0,s.sheen=1;const o=r.extensions[this.name];return void 0!==o.sheenColorFactor&&s.sheenColor.fromArray(o.sheenColorFactor),void 0!==o.sheenRoughnessFactor&&(s.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&i.push(n.assignTexture(s,"sheenColorMap",o.sheenColorTexture,e.sRGBEncoding)),void 0!==o.sheenRoughnessTexture&&i.push(n.assignTexture(s,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class h{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&r.push(s.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class d{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_VOLUME}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];s.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&i.push(n.assignTexture(s,"thicknessMap",o.thicknessTexture)),s.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return s.attenuationColor=new e.Color(a[0],a[1],a[2]),Promise.all(i)}}class m{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_IOR}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class p{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_SPECULAR}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];s.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&i.push(n.assignTexture(s,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return s.specularColor=new e.Color(a[0],a[1],a[2]),void 0!==o.specularColorTexture&&i.push(n.assignTexture(s,"specularColorMap",o.specularColorTexture,e.sRGBEncoding)),Promise.all(i)}}class f{constructor(e){this.parser=e,this.name=r.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,i)}}class A{constructor(e){this.parser=e,this.name=r.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=n.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return s.loadTextureImage(e,i.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class g{constructor(e){this.parser=e,this.name=r.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=n.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return s.loadTextureImage(e,i.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class T{constructor(e){this.name=r.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then((function(t){const s=e.byteOffset||0,n=e.byteLength||0,i=e.count,o=e.byteStride,a=new Uint8Array(t,s,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(i,o,a,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(i*o);return r.decodeGltfBuffer(new Uint8Array(t),i,o,a,e.mode,e.filter),t}))}))}return null}}class x{constructor(e){this.name=r.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(t){const s=this.parser.json,n=s.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=s.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==b.TRIANGLES&&e.mode!==b.TRIANGLE_STRIP&&e.mode!==b.TRIANGLE_FAN&&void 0!==e.mode)return null;const i=n.extensions[this.name].attributes,o=[],a={};for(const e in i)o.push(this.parser.getDependency("accessor",i[e]).then((t=>(a[e]=t,a[e]))));return o.length<1?null:(o.push(this.parser.createNodeMesh(t)),Promise.all(o).then((t=>{const s=t.pop(),n=s.isGroup?s.children:[s],r=t[0].count,i=[];for(const t of n){const s=new e.Matrix4,n=new e.Vector3,o=new e.Quaternion,c=new e.Vector3(1,1,1),l=new e.InstancedMesh(t.geometry,t.material,r);for(let e=0;e<r;e++)a.TRANSLATION&&n.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&o.fromBufferAttribute(a.ROTATION,e),a.SCALE&&c.fromBufferAttribute(a.SCALE,e),l.setMatrixAt(e,s.compose(n,o,c));for(const e in a)"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,a[e]);e.Object3D.prototype.copy.call(l,t),this.parser.assignFinalMaterial(l),i.push(l)}return s.isGroup?(s.clear(),s.add(...i),s):i[0]})))}}const R="glTF",E=1313821514,_=5130562;class v{constructor(t){this.name=r.KHR_BINARY_GLTF,this.content=null,this.body=null;const s=new DataView(t,0,12);if(this.header={magic:e.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:s.getUint32(4,!0),length:s.getUint32(8,!0)},this.header.magic!==R)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,i=new DataView(t,12);let o=0;for(;o<n;){const s=i.getUint32(o,!0);o+=4;const n=i.getUint32(o,!0);if(o+=4,n===E){const n=new Uint8Array(t,12+o,s);this.content=e.LoaderUtils.decodeText(n)}else if(n===_){const e=12+o;this.body=t.slice(e,e+s)}o+=s}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class w{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=r.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},a={},c={};for(const e in i){const t=H[e]||e.toLowerCase();o[t]=i[e]}for(const t in e.attributes){const n=H[t]||t.toLowerCase();if(void 0!==i[t]){const r=s.accessors[e.attributes[t]],i=N[r.componentType];c[n]=i.name,a[n]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){n.decodeDracoFile(e,(function(e){for(const t in e.attributes){const s=e.attributes[t],n=a[t];void 0!==n&&(s.normalized=n)}t(e)}),o,c)}))}))}}class L{constructor(){this.name=r.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class M{constructor(){this.name=r.KHR_MESH_QUANTIZATION}}class y extends e.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=s[r+e];return t}interpolate_(e,t,s,n){const r=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,c=3*o,l=n-t,u=(s-t)/l,h=u*u,d=h*u,m=e*c,p=m-c,f=-2*d+3*h,A=d-h,g=1-f,T=A-h+u;for(let e=0;e!==o;e++){const t=i[p+e+o],s=i[p+e+a]*l,n=i[m+e+o],c=i[m+e]*l;r[e]=g*t+T*s+f*n+A*c}return r}}const S=new e.Quaternion;class I extends y{interpolate_(e,t,s,n){const r=super.interpolate_(e,t,s,n);return S.fromArray(r).normalize().toArray(r),r}}const b={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},N={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},O={9728:e.NearestFilter,9729:e.LinearFilter,9984:e.NearestMipmapNearestFilter,9985:e.LinearMipmapNearestFilter,9986:e.NearestMipmapLinearFilter,9987:e.LinearMipmapLinearFilter},C={33071:e.ClampToEdgeWrapping,33648:e.MirroredRepeatWrapping,10497:e.RepeatWrapping},P={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},H={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...e.REVISION.replace(/\D+/g,"")>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},F={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},k={CUBICSPLINE:void 0,LINEAR:e.InterpolateLinear,STEP:e.InterpolateDiscrete},D="OPAQUE",B="MASK",U="BLEND";function G(e,t,s){for(const n in s.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=s.extensions[n])}function j(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function K(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,n=t.weights.length;s<n;s++)e.morphTargetInfluences[s]=t.weights[s];if(t.extras&&Array.isArray(t.extras.targetNames)){const s=t.extras.targetNames;if(e.morphTargetInfluences.length===s.length){e.morphTargetDictionary={};for(let t=0,n=s.length;t<n;t++)e.morphTargetDictionary[s[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function V(e){const t=e.extensions&&e.extensions[r.KHR_DRACO_MESH_COMPRESSION];let s;return s=t?"draco:"+t.bufferView+":"+t.indices+":"+X(t.attributes):e.indices+":"+X(e.attributes)+":"+e.mode,s}function X(e){let t="";const s=Object.keys(e).sort();for(let n=0,r=s.length;n<r;n++)t+=s[n]+":"+e[s[n]]+";";return t}function q(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const z=new e.Matrix4;class W{constructor(t={},s={}){this.json=t,this.extensions={},this.plugins={},this.options=s,this.cache=new n,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,i=!1,o=-1;"undefined"!=typeof navigator&&(r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,o=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||r||i&&o<98?this.textureLoader=new e.TextureLoader(this.options.manager):this.textureLoader=new e.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new e.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])})).then((function(t){const i={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:s,userData:{}};G(r,i,n),j(i,n),Promise.all(s._invokeAll((function(e){return e.afterRoot&&e.afterRoot(i)}))).then((function(){e(i)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s].joints;for(let t=0,s=n.length;t<s;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(s[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),r=(e,t)=>{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,n]of e.children.entries())r(n,t.children[s])};return r(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&s.push(r)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":n=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne((function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)})),!n)throw new Error("Unknown type: "+e)}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map((function(t,n){return s.getDependency(e,n)}))),this.cache.add(e,t)}return t}loadBuffer(t){const s=this.json.buffers[t],n=this.fileLoader;if(s.type&&"arraybuffer"!==s.type)throw new Error("THREE.GLTFLoader: "+s.type+" buffer type is not supported.");if(void 0===s.uri&&0===t)return Promise.resolve(this.extensions[r.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(t,r){n.load(e.LoaderUtils.resolveURL(s.uri,i.path),t,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+s.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const s=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+s)}))}loadAccessor(t){const s=this,n=this.json,r=this.json.accessors[t];if(void 0===r.bufferView&&void 0===r.sparse){const t=P[r.type],s=N[r.componentType],n=!0===r.normalized,i=new s(r.count*t);return Promise.resolve(new e.BufferAttribute(i,t,n))}const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(t){const i=t[0],o=P[r.type],a=N[r.componentType],c=a.BYTES_PER_ELEMENT,l=c*o,u=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let m,p;if(h&&h!==l){const t=Math.floor(u/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+t+":"+r.count;let l=s.cache.get(n);l||(m=new a(i,t*h,r.count*h/c),l=new e.InterleavedBuffer(m,h/c),s.cache.add(n,l)),p=new e.InterleavedBufferAttribute(l,o,u%h/c,d)}else m=null===i?new a(r.count*o):new a(i,u,r.count*o),p=new e.BufferAttribute(m,o,d);if(void 0!==r.sparse){const s=P.SCALAR,n=N[r.sparse.indices.componentType],c=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,u=new n(t[1],c,r.sparse.count*s),h=new a(t[2],l,r.sparse.count*o);null!==i&&(p=new e.BufferAttribute(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=u.length;e<t;e++){const t=u[e];if(p.setX(t,h[e*o]),o>=2&&p.setY(t,h[e*o+1]),o>=3&&p.setZ(t,h[e*o+2]),o>=4&&p.setW(t,h[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,s=this.options,n=t.textures[e].source,r=t.images[n];let i=this.textureLoader;if(r.uri){const e=s.manager.getHandler(r.uri);null!==e&&(i=e)}return this.loadTextureImage(e,n,i)}loadTextureImage(t,s,n){const r=this,i=this.json,o=i.textures[t],a=i.images[s],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(s,n).then((function(s){s.flipY=!1,s.name=o.name||a.name||"",""===s.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(s.name=a.uri);const n=(i.samplers||{})[o.sampler]||{};return s.magFilter=O[n.magFilter]||e.LinearFilter,s.minFilter=O[n.minFilter]||e.LinearMipmapLinearFilter,s.wrapS=C[n.wrapS]||e.RepeatWrapping,s.wrapT=C[n.wrapT]||e.RepeatWrapping,r.associations.set(s,{textures:t}),s})).catch((function(){return null}));return this.textureCache[c]=l,l}loadImageSource(t,s){const n=this,r=this.json,i=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((e=>e.clone()));const o=r.images[t],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(void 0!==o.bufferView)c=n.getDependency("bufferView",o.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:o.mimeType});return c=a.createObjectURL(t),c}));else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(c).then((function(t){return new Promise((function(n,r){let o=n;!0===s.isImageBitmapLoader&&(o=function(t){const s=new e.Texture(t);s.needsUpdate=!0,n(s)}),s.load(e.LoaderUtils.resolveURL(t,i.path),o,void 0,r)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(c),e.userData.mimeType=o.mimeType||((t=o.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),e}));return this.sourceCache[t]=u,u}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then((function(o){if(!o)return null;if(void 0!==s.texCoord&&s.texCoord>0&&((o=o.clone()).channel=s.texCoord),i.extensions[r.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[r.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(o);o=i.extensions[r.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==n&&(o.encoding=n),e[t]=o,o}))}assignFinalMaterial(t){const s=t.geometry;let n=t.material;const r=void 0===s.attributes.tangent,i=void 0!==s.attributes.color,o=void 0===s.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let s=this.cache.get(t);s||(s=new e.PointsMaterial,e.Material.prototype.copy.call(s,n),s.color.copy(n.color),s.map=n.map,s.sizeAttenuation=!1,this.cache.add(t,s)),n=s}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let s=this.cache.get(t);s||(s=new e.LineBasicMaterial,e.Material.prototype.copy.call(s,n),s.color.copy(n.color),s.map=n.map,this.cache.add(t,s)),n=s}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}t.material=n}getMaterialType(){return e.MeshStandardMaterial}loadMaterial(t){const s=this,n=this.json,i=this.extensions,o=n.materials[t];let a;const c={},l=[];if((o.extensions||{})[r.KHR_MATERIALS_UNLIT]){const e=i[r.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),l.push(e.extendParams(c,o,s))}else{const n=o.pbrMetallicRoughness||{};if(c.color=new e.Color(1,1,1),c.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;c.color.fromArray(e),c.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(s.assignTexture(c,"map",n.baseColorTexture,e.sRGBEncoding)),c.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,c.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(s.assignTexture(c,"metalnessMap",n.metallicRoughnessTexture)),l.push(s.assignTexture(c,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),l.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,c)}))))}!0===o.doubleSided&&(c.side=e.DoubleSide);const u=o.alphaMode||D;if(u===U?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,u===B&&(c.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&a!==e.MeshBasicMaterial&&(l.push(s.assignTexture(c,"normalMap",o.normalTexture)),c.normalScale=new e.Vector2(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;c.normalScale.set(e,e)}return void 0!==o.occlusionTexture&&a!==e.MeshBasicMaterial&&(l.push(s.assignTexture(c,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(c.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&a!==e.MeshBasicMaterial&&(c.emissive=(new e.Color).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&a!==e.MeshBasicMaterial&&l.push(s.assignTexture(c,"emissiveMap",o.emissiveTexture,e.sRGBEncoding)),Promise.all(l).then((function(){const e=new a(c);return o.name&&(e.name=o.name),j(e,o),s.associations.set(e,{materials:t}),o.extensions&&G(i,e,o),e}))}createUniqueName(t){const s=e.PropertyBinding.sanitizeNodeName(t||"");let n=s;for(let e=1;this.nodeNamesUsed[n];++e)n=s+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(t){const s=this,n=this.extensions,i=this.primitiveCache;function o(e){return n[r.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,s).then((function(t){return Q(t,e,s)}))}const a=[];for(let n=0,c=t.length;n<c;n++){const c=t[n],l=V(c),u=i[l];if(u)a.push(u.promise);else{let t;t=c.extensions&&c.extensions[r.KHR_DRACO_MESH_COMPRESSION]?o(c):Q(new e.BufferGeometry,c,s),i[l]={primitive:c,promise:t},a.push(t)}}return Promise.all(a)}loadMesh(s){const n=this,r=this.json,i=this.extensions,o=r.meshes[s],a=o.primitives,c=[];for(let t=0,s=a.length;t<s;t++){const s=void 0===a[t].material?(void 0===(l=this.cache).DefaultMaterial&&(l.DefaultMaterial=new e.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:e.FrontSide})),l.DefaultMaterial):this.getDependency("material",a[t].material);c.push(s)}var l;return c.push(n.loadGeometries(a)),Promise.all(c).then((function(r){const c=r.slice(0,r.length-1),l=r[r.length-1],u=[];for(let r=0,h=l.length;r<h;r++){const h=l[r],d=a[r];let m;const p=c[r];if(d.mode===b.TRIANGLES||d.mode===b.TRIANGLE_STRIP||d.mode===b.TRIANGLE_FAN||void 0===d.mode)m=!0===o.isSkinnedMesh?new e.SkinnedMesh(h,p):new e.Mesh(h,p),!0===m.isSkinnedMesh&&m.normalizeSkinWeights(),d.mode===b.TRIANGLE_STRIP?m.geometry=t.toTrianglesDrawMode(m.geometry,e.TriangleStripDrawMode):d.mode===b.TRIANGLE_FAN&&(m.geometry=t.toTrianglesDrawMode(m.geometry,e.TriangleFanDrawMode));else if(d.mode===b.LINES)m=new e.LineSegments(h,p);else if(d.mode===b.LINE_STRIP)m=new e.Line(h,p);else if(d.mode===b.LINE_LOOP)m=new e.LineLoop(h,p);else{if(d.mode!==b.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);m=new e.Points(h,p)}Object.keys(m.geometry.morphAttributes).length>0&&K(m,o),m.name=n.createUniqueName(o.name||"mesh_"+s),j(m,o),d.extensions&&G(i,m,d),n.assignFinalMaterial(m),u.push(m)}for(let e=0,t=u.length;e<t;e++)n.associations.set(u[e],{meshes:s,primitives:e});if(1===u.length)return u[0];const h=new e.Group;n.associations.set(h,{meshes:s});for(let e=0,t=u.length;e<t;e++)h.add(u[e]);return h}))}loadCamera(t){let s;const n=this.json.cameras[t],r=n[n.type];if(r)return"perspective"===n.type?s=new e.PerspectiveCamera(e.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(s=new e.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(s.name=this.createUniqueName(n.name)),j(s,n),Promise.resolve(s);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const s=this.json.skins[t],n=[];for(let e=0,t=s.joints.length;e<t;e++)n.push(this._loadNodeShallow(s.joints[e]));return void 0!==s.inverseBindMatrices?n.push(this.getDependency("accessor",s.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(t){const n=t.pop(),r=t,i=[],o=[];for(let t=0,a=r.length;t<a;t++){const a=r[t];if(a){i.push(a);const s=new e.Matrix4;null!==n&&s.fromArray(n.array,16*t),o.push(s)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',s.joints[t])}return new e.Skeleton(i,o)}))}loadAnimation(t){const s=this.json.animations[t],n=s.name?s.name:"animation_"+t,r=[],i=[],o=[],a=[],c=[];for(let e=0,t=s.channels.length;e<t;e++){const t=s.channels[e],n=s.samplers[t.sampler],l=t.target,u=l.node,h=void 0!==s.parameters?s.parameters[n.input]:n.input,d=void 0!==s.parameters?s.parameters[n.output]:n.output;void 0!==l.node&&(r.push(this.getDependency("node",u)),i.push(this.getDependency("accessor",h)),o.push(this.getDependency("accessor",d)),a.push(n),c.push(l))}return Promise.all([Promise.all(r),Promise.all(i),Promise.all(o),Promise.all(a),Promise.all(c)]).then((function(t){const s=t[0],r=t[1],i=t[2],o=t[3],a=t[4],c=[];for(let t=0,n=s.length;t<n;t++){const n=s[t],l=r[t],u=i[t],h=o[t],d=a[t];if(void 0===n)continue;let m;switch(n.updateMatrix(),F[d.path]){case F.weights:m=e.NumberKeyframeTrack;break;case F.rotation:m=e.QuaternionKeyframeTrack;break;case F.position:case F.scale:default:m=e.VectorKeyframeTrack}const p=n.name?n.name:n.uuid,f=void 0!==h.interpolation?k[h.interpolation]:e.InterpolateLinear,A=[];F[d.path]===F.weights?n.traverse((function(e){e.morphTargetInfluences&&A.push(e.name?e.name:e.uuid)})):A.push(p);let g=u.array;if(u.normalized){const e=q(g.constructor),t=new Float32Array(g.length);for(let s=0,n=g.length;s<n;s++)t[s]=g[s]*e;g=t}for(let t=0,s=A.length;t<s;t++){const s=new m(A[t]+"."+F[d.path],l.array,g,f);"CUBICSPLINE"===h.interpolation&&(s.createInterpolant=function(t){return new(this instanceof e.QuaternionKeyframeTrack?I:y)(this.times,this.values,this.getValueSize()/3,t)},s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),c.push(s)}}return new e.AnimationClip(n,void 0,c)}))}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return void 0===n.mesh?null:s.getDependency("mesh",n.mesh).then((function(e){const t=s._getNodeRef(s.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,s=n.weights.length;t<s;t++)e.morphTargetInfluences[t]=n.weights[t]})),t}))}loadNode(e){const t=this,s=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],i=s.children||[];for(let e=0,s=i.length;e<s;e++)r.push(t.getDependency("node",i[e]));const o=void 0===s.skin?Promise.resolve(null):t.getDependency("skin",s.skin);return Promise.all([n,Promise.all(r),o]).then((function(e){const t=e[0],s=e[1],n=e[2];null!==n&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(n,z)}));for(let e=0,n=s.length;e<n;e++)t.add(s[e]);return t}))}_loadNodeShallow(t){const s=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const i=s.nodes[t],o=i.name?r.createUniqueName(i.name):"",a=[],c=r._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return c&&a.push(c),void 0!==i.camera&&a.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(e){a.push(e)})),this.nodeCache[t]=Promise.all(a).then((function(s){let a;if(a=!0===i.isBone?new e.Bone:s.length>1?new e.Group:1===s.length?s[0]:new e.Object3D,a!==s[0])for(let e=0,t=s.length;e<t;e++)a.add(s[e]);if(i.name&&(a.userData.name=i.name,a.name=o),j(a,i),i.extensions&&G(n,a,i),void 0!==i.matrix){const t=new e.Matrix4;t.fromArray(i.matrix),a.applyMatrix4(t)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=t,a})),this.nodeCache[t]}loadScene(t){const s=this.extensions,n=this.json.scenes[t],r=this,i=new e.Group;n.name&&(i.name=r.createUniqueName(n.name)),j(i,n),n.extensions&&G(s,i,n);const o=n.nodes||[],a=[];for(let e=0,t=o.length;e<t;e++)a.push(r.getDependency("node",o[e]));return Promise.all(a).then((function(t){for(let e=0,s=t.length;e<s;e++)i.add(t[e]);return r.associations=(t=>{const s=new Map;for(const[t,n]of r.associations)(t instanceof e.Material||t instanceof e.Texture)&&s.set(t,n);return t.traverse((e=>{const t=r.associations.get(e);null!=t&&s.set(e,t)})),s})(i),i}))}}function Q(t,s,n){const r=s.attributes,i=[];function o(e,s){return n.getDependency("accessor",e).then((function(e){t.setAttribute(s,e)}))}for(const e in r){const s=H[e]||e.toLowerCase();s in t.attributes||i.push(o(r[e],s))}if(void 0!==s.indices&&!t.index){const e=n.getDependency("accessor",s.indices).then((function(e){t.setIndex(e)}));i.push(e)}return j(t,s),function(t,s,n){const r=s.attributes,i=new e.Box3;if(void 0===r.POSITION)return;{const t=n.json.accessors[r.POSITION],s=t.min,o=t.max;if(void 0===s||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new e.Vector3(s[0],s[1],s[2]),new e.Vector3(o[0],o[1],o[2])),t.normalized){const e=q(N[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const o=s.targets;if(void 0!==o){const t=new e.Vector3,s=new e.Vector3;for(let e=0,r=o.length;e<r;e++){const r=o[e];if(void 0!==r.POSITION){const e=n.json.accessors[r.POSITION],i=e.min,o=e.max;if(void 0!==i&&void 0!==o){if(s.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),s.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),s.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),e.normalized){const t=q(N[e.componentType]);s.multiplyScalar(t)}t.max(s)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(t)}t.boundingBox=i;const a=new e.Sphere;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,t.boundingSphere=a}(t,s,n),Promise.all(i).then((function(){return void 0!==s.targets?function(e,t,s){let n=!1,r=!1,i=!1;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(void 0!==s.POSITION&&(n=!0),void 0!==s.NORMAL&&(r=!0),void 0!==s.COLOR_0&&(i=!0),n&&r&&i)break}if(!n&&!r&&!i)return Promise.resolve(e);const o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){const u=t[l];if(n){const t=void 0!==u.POSITION?s.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==u.NORMAL?s.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(i){const t=void 0!==u.COLOR_0?s.getDependency("accessor",u.COLOR_0):e.attributes.color;c.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then((function(t){const s=t[0],o=t[1],a=t[2];return n&&(e.morphAttributes.position=s),r&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(t,s.targets,n):t}))}exports.GLTFLoader=s;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("../BufferGeometryUtils-903f7ecb.js");require("../types/helpers.cjs.js");class s extends e.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new c(e)})),this.register((function(e){return new f(e)})),this.register((function(e){return new A(e)})),this.register((function(e){return new g(e)})),this.register((function(e){return new u(e)})),this.register((function(e){return new h(e)})),this.register((function(e){return new d(e)})),this.register((function(e){return new m(e)})),this.register((function(e){return new a(e)})),this.register((function(e){return new p(e)})),this.register((function(e){return new l(e)})),this.register((function(e){return new i(e)})),this.register((function(e){return new T(e)})),this.register((function(e){return new x(e)}))}load(t,s,n,r){const i=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:e.LoaderUtils.extractUrlBase(t),this.manager.itemStart(t);const a=function(e){r?r(e):console.error(e),i.manager.itemError(t),i.manager.itemEnd(t)},c=new e.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(t,(function(e){try{i.parse(e,o,(function(e){s(e),i.manager.itemEnd(t)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(t,s,n,i){let a;const c={},l={};if("string"==typeof t)a=JSON.parse(t);else if(t instanceof ArrayBuffer){if(e.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4)))===R){try{c[r.KHR_BINARY_GLTF]=new v(t)}catch(e){return void(i&&i(e))}a=JSON.parse(c[r.KHR_BINARY_GLTF].content)}else a=JSON.parse(e.LoaderUtils.decodeText(new Uint8Array(t)))}else a=t;if(void 0===a.asset||a.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const u=new W(a,{path:s||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](u);l[t.name]=t,c[t.name]=!0}if(a.extensionsUsed)for(let e=0;e<a.extensionsUsed.length;++e){const t=a.extensionsUsed[e],s=a.extensionsRequired||[];switch(t){case r.KHR_MATERIALS_UNLIT:c[t]=new o;break;case r.KHR_DRACO_MESH_COMPRESSION:c[t]=new w(a,this.dracoLoader);break;case r.KHR_TEXTURE_TRANSFORM:c[t]=new L;break;case r.KHR_MESH_QUANTIZATION:c[t]=new M;break;default:s.indexOf(t)>=0&&void 0===l[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}u.setExtensions(c),u.setPlugins(l),u.parse(n,i)}parseAsync(e,t){const s=this;return new Promise((function(n,r){s.parse(e,t,n,r)}))}}function n(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const r={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class i{constructor(e){this.parser=e,this.name=r.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(t){const s=this.parser,n="light:"+t;let r=s.cache.get(n);if(r)return r;const i=s.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let a;const c=new e.Color(16777215);void 0!==o.color&&c.fromArray(o.color);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new e.DirectionalLight(c),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new e.PointLight(c),a.distance=l;break;case"spot":a=new e.SpotLight(c),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,j(a,o),void 0!==o.intensity&&(a.intensity=o.intensity),a.name=s.createUniqueName(o.name||"light_"+t),r=Promise.resolve(a),s.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,n=s.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return s._getNodeRef(t.cache,r,e)}))}}class o{constructor(){this.name=r.KHR_MATERIALS_UNLIT}getMaterialType(){return e.MeshBasicMaterial}extendParams(t,s,n){const r=[];t.color=new e.Color(1,1,1),t.opacity=1;const i=s.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;t.color.fromArray(e),t.opacity=e[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(t,"map",i.baseColorTexture,3001))}return Promise.all(r)}}class a{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class c{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];if(void 0!==o.clearcoatFactor&&(s.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&i.push(n.assignTexture(s,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(s.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&i.push(n.assignTexture(s,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(i.push(n.assignTexture(s,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const t=o.clearcoatNormalTexture.scale;s.clearcoatNormalScale=new e.Vector2(t,t)}return Promise.all(i)}}class l{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&r.push(s.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&r.push(s.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class u{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_SHEEN}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];s.sheenColor=new e.Color(0,0,0),s.sheenRoughness=0,s.sheen=1;const o=r.extensions[this.name];return void 0!==o.sheenColorFactor&&s.sheenColor.fromArray(o.sheenColorFactor),void 0!==o.sheenRoughnessFactor&&(s.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&i.push(n.assignTexture(s,"sheenColorMap",o.sheenColorTexture,3001)),void 0!==o.sheenRoughnessTexture&&i.push(n.assignTexture(s,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class h{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&r.push(s.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class d{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_VOLUME}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];s.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&i.push(n.assignTexture(s,"thicknessMap",o.thicknessTexture)),s.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return s.attenuationColor=new e.Color(a[0],a[1],a[2]),Promise.all(i)}}class m{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_IOR}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class p{constructor(e){this.parser=e,this.name=r.KHR_MATERIALS_SPECULAR}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];s.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&i.push(n.assignTexture(s,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return s.specularColor=new e.Color(a[0],a[1],a[2]),void 0!==o.specularColorTexture&&i.push(n.assignTexture(s,"specularColorMap",o.specularColorTexture,3001)),Promise.all(i)}}class f{constructor(e){this.parser=e,this.name=r.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,i)}}class A{constructor(e){this.parser=e,this.name=r.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=n.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return s.loadTextureImage(e,i.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class g{constructor(e){this.parser=e,this.name=r.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=n.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return s.loadTextureImage(e,i.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class T{constructor(e){this.name=r.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then((function(t){const s=e.byteOffset||0,n=e.byteLength||0,i=e.count,o=e.byteStride,a=new Uint8Array(t,s,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(i,o,a,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(i*o);return r.decodeGltfBuffer(new Uint8Array(t),i,o,a,e.mode,e.filter),t}))}))}return null}}class x{constructor(e){this.name=r.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(t){const s=this.parser.json,n=s.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=s.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==b.TRIANGLES&&e.mode!==b.TRIANGLE_STRIP&&e.mode!==b.TRIANGLE_FAN&&void 0!==e.mode)return null;const i=n.extensions[this.name].attributes,o=[],a={};for(const e in i)o.push(this.parser.getDependency("accessor",i[e]).then((t=>(a[e]=t,a[e]))));return o.length<1?null:(o.push(this.parser.createNodeMesh(t)),Promise.all(o).then((t=>{const s=t.pop(),n=s.isGroup?s.children:[s],r=t[0].count,i=[];for(const t of n){const s=new e.Matrix4,n=new e.Vector3,o=new e.Quaternion,c=new e.Vector3(1,1,1),l=new e.InstancedMesh(t.geometry,t.material,r);for(let e=0;e<r;e++)a.TRANSLATION&&n.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&o.fromBufferAttribute(a.ROTATION,e),a.SCALE&&c.fromBufferAttribute(a.SCALE,e),l.setMatrixAt(e,s.compose(n,o,c));for(const e in a)"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,a[e]);e.Object3D.prototype.copy.call(l,t),this.parser.assignFinalMaterial(l),i.push(l)}return s.isGroup?(s.clear(),s.add(...i),s):i[0]})))}}const R="glTF",E=1313821514,_=5130562;class v{constructor(t){this.name=r.KHR_BINARY_GLTF,this.content=null,this.body=null;const s=new DataView(t,0,12);if(this.header={magic:e.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:s.getUint32(4,!0),length:s.getUint32(8,!0)},this.header.magic!==R)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,i=new DataView(t,12);let o=0;for(;o<n;){const s=i.getUint32(o,!0);o+=4;const n=i.getUint32(o,!0);if(o+=4,n===E){const n=new Uint8Array(t,12+o,s);this.content=e.LoaderUtils.decodeText(n)}else if(n===_){const e=12+o;this.body=t.slice(e,e+s)}o+=s}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class w{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=r.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},a={},c={};for(const e in i){const t=H[e]||e.toLowerCase();o[t]=i[e]}for(const t in e.attributes){const n=H[t]||t.toLowerCase();if(void 0!==i[t]){const r=s.accessors[e.attributes[t]],i=N[r.componentType];c[n]=i.name,a[n]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){n.decodeDracoFile(e,(function(e){for(const t in e.attributes){const s=e.attributes[t],n=a[t];void 0!==n&&(s.normalized=n)}t(e)}),o,c)}))}))}}class L{constructor(){this.name=r.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class M{constructor(){this.name=r.KHR_MESH_QUANTIZATION}}class y extends e.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=s[r+e];return t}interpolate_(e,t,s,n){const r=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,c=3*o,l=n-t,u=(s-t)/l,h=u*u,d=h*u,m=e*c,p=m-c,f=-2*d+3*h,A=d-h,g=1-f,T=A-h+u;for(let e=0;e!==o;e++){const t=i[p+e+o],s=i[p+e+a]*l,n=i[m+e+o],c=i[m+e]*l;r[e]=g*t+T*s+f*n+A*c}return r}}const S=new e.Quaternion;class I extends y{interpolate_(e,t,s,n){const r=super.interpolate_(e,t,s,n);return S.fromArray(r).normalize().toArray(r),r}}const b={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},N={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},O={9728:e.NearestFilter,9729:e.LinearFilter,9984:e.NearestMipmapNearestFilter,9985:e.LinearMipmapNearestFilter,9986:e.NearestMipmapLinearFilter,9987:e.LinearMipmapLinearFilter},C={33071:e.ClampToEdgeWrapping,33648:e.MirroredRepeatWrapping,10497:e.RepeatWrapping},P={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},H={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...e.REVISION.replace(/\D+/g,"")>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},F={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},k={CUBICSPLINE:void 0,LINEAR:e.InterpolateLinear,STEP:e.InterpolateDiscrete},D="OPAQUE",U="MASK",B="BLEND";function G(e,t,s){for(const n in s.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=s.extensions[n])}function j(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function K(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,n=t.weights.length;s<n;s++)e.morphTargetInfluences[s]=t.weights[s];if(t.extras&&Array.isArray(t.extras.targetNames)){const s=t.extras.targetNames;if(e.morphTargetInfluences.length===s.length){e.morphTargetDictionary={};for(let t=0,n=s.length;t<n;t++)e.morphTargetDictionary[s[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function V(e){const t=e.extensions&&e.extensions[r.KHR_DRACO_MESH_COMPRESSION];let s;return s=t?"draco:"+t.bufferView+":"+t.indices+":"+X(t.attributes):e.indices+":"+X(e.attributes)+":"+e.mode,s}function X(e){let t="";const s=Object.keys(e).sort();for(let n=0,r=s.length;n<r;n++)t+=s[n]+":"+e[s[n]]+";";return t}function q(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const z=new e.Matrix4;class W{constructor(t={},s={}){this.json=t,this.extensions={},this.plugins={},this.options=s,this.cache=new n,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,i=!1,o=-1;"undefined"!=typeof navigator&&(r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,o=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||r||i&&o<98?this.textureLoader=new e.TextureLoader(this.options.manager):this.textureLoader=new e.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new e.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])})).then((function(t){const i={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:s,userData:{}};G(r,i,n),j(i,n),Promise.all(s._invokeAll((function(e){return e.afterRoot&&e.afterRoot(i)}))).then((function(){e(i)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s].joints;for(let t=0,s=n.length;t<s;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(s[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),r=(e,t)=>{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,n]of e.children.entries())r(n,t.children[s])};return r(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&s.push(r)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":n=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne((function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)})),!n)throw new Error("Unknown type: "+e)}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map((function(t,n){return s.getDependency(e,n)}))),this.cache.add(e,t)}return t}loadBuffer(t){const s=this.json.buffers[t],n=this.fileLoader;if(s.type&&"arraybuffer"!==s.type)throw new Error("THREE.GLTFLoader: "+s.type+" buffer type is not supported.");if(void 0===s.uri&&0===t)return Promise.resolve(this.extensions[r.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(t,r){n.load(e.LoaderUtils.resolveURL(s.uri,i.path),t,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+s.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const s=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+s)}))}loadAccessor(t){const s=this,n=this.json,r=this.json.accessors[t];if(void 0===r.bufferView&&void 0===r.sparse){const t=P[r.type],s=N[r.componentType],n=!0===r.normalized,i=new s(r.count*t);return Promise.resolve(new e.BufferAttribute(i,t,n))}const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(t){const i=t[0],o=P[r.type],a=N[r.componentType],c=a.BYTES_PER_ELEMENT,l=c*o,u=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let m,p;if(h&&h!==l){const t=Math.floor(u/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+t+":"+r.count;let l=s.cache.get(n);l||(m=new a(i,t*h,r.count*h/c),l=new e.InterleavedBuffer(m,h/c),s.cache.add(n,l)),p=new e.InterleavedBufferAttribute(l,o,u%h/c,d)}else m=null===i?new a(r.count*o):new a(i,u,r.count*o),p=new e.BufferAttribute(m,o,d);if(void 0!==r.sparse){const s=P.SCALAR,n=N[r.sparse.indices.componentType],c=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,u=new n(t[1],c,r.sparse.count*s),h=new a(t[2],l,r.sparse.count*o);null!==i&&(p=new e.BufferAttribute(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=u.length;e<t;e++){const t=u[e];if(p.setX(t,h[e*o]),o>=2&&p.setY(t,h[e*o+1]),o>=3&&p.setZ(t,h[e*o+2]),o>=4&&p.setW(t,h[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,s=this.options,n=t.textures[e].source,r=t.images[n];let i=this.textureLoader;if(r.uri){const e=s.manager.getHandler(r.uri);null!==e&&(i=e)}return this.loadTextureImage(e,n,i)}loadTextureImage(t,s,n){const r=this,i=this.json,o=i.textures[t],a=i.images[s],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(s,n).then((function(s){s.flipY=!1,s.name=o.name||a.name||"",""===s.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(s.name=a.uri);const n=(i.samplers||{})[o.sampler]||{};return s.magFilter=O[n.magFilter]||e.LinearFilter,s.minFilter=O[n.minFilter]||e.LinearMipmapLinearFilter,s.wrapS=C[n.wrapS]||e.RepeatWrapping,s.wrapT=C[n.wrapT]||e.RepeatWrapping,r.associations.set(s,{textures:t}),s})).catch((function(){return null}));return this.textureCache[c]=l,l}loadImageSource(t,s){const n=this,r=this.json,i=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((e=>e.clone()));const o=r.images[t],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(void 0!==o.bufferView)c=n.getDependency("bufferView",o.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:o.mimeType});return c=a.createObjectURL(t),c}));else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(c).then((function(t){return new Promise((function(n,r){let o=n;!0===s.isImageBitmapLoader&&(o=function(t){const s=new e.Texture(t);s.needsUpdate=!0,n(s)}),s.load(e.LoaderUtils.resolveURL(t,i.path),o,void 0,r)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(c),e.userData.mimeType=o.mimeType||((t=o.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),e}));return this.sourceCache[t]=u,u}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then((function(o){if(!o)return null;if(void 0!==s.texCoord&&s.texCoord>0&&((o=o.clone()).channel=s.texCoord),i.extensions[r.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[r.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(o);o=i.extensions[r.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==n&&("colorSpace"in o?o.colorSpace=3001===n?"srgb":"srgb-linear":o.encoding=n),e[t]=o,o}))}assignFinalMaterial(t){const s=t.geometry;let n=t.material;const r=void 0===s.attributes.tangent,i=void 0!==s.attributes.color,o=void 0===s.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let s=this.cache.get(t);s||(s=new e.PointsMaterial,e.Material.prototype.copy.call(s,n),s.color.copy(n.color),s.map=n.map,s.sizeAttenuation=!1,this.cache.add(t,s)),n=s}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let s=this.cache.get(t);s||(s=new e.LineBasicMaterial,e.Material.prototype.copy.call(s,n),s.color.copy(n.color),s.map=n.map,this.cache.add(t,s)),n=s}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}t.material=n}getMaterialType(){return e.MeshStandardMaterial}loadMaterial(t){const s=this,n=this.json,i=this.extensions,o=n.materials[t];let a;const c={},l=[];if((o.extensions||{})[r.KHR_MATERIALS_UNLIT]){const e=i[r.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),l.push(e.extendParams(c,o,s))}else{const n=o.pbrMetallicRoughness||{};if(c.color=new e.Color(1,1,1),c.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;c.color.fromArray(e),c.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(s.assignTexture(c,"map",n.baseColorTexture,3001)),c.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,c.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(s.assignTexture(c,"metalnessMap",n.metallicRoughnessTexture)),l.push(s.assignTexture(c,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),l.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,c)}))))}!0===o.doubleSided&&(c.side=e.DoubleSide);const u=o.alphaMode||D;if(u===B?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,u===U&&(c.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&a!==e.MeshBasicMaterial&&(l.push(s.assignTexture(c,"normalMap",o.normalTexture)),c.normalScale=new e.Vector2(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;c.normalScale.set(e,e)}return void 0!==o.occlusionTexture&&a!==e.MeshBasicMaterial&&(l.push(s.assignTexture(c,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(c.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&a!==e.MeshBasicMaterial&&(c.emissive=(new e.Color).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&a!==e.MeshBasicMaterial&&l.push(s.assignTexture(c,"emissiveMap",o.emissiveTexture,sRGBEncoding)),Promise.all(l).then((function(){const e=new a(c);return o.name&&(e.name=o.name),j(e,o),s.associations.set(e,{materials:t}),o.extensions&&G(i,e,o),e}))}createUniqueName(t){const s=e.PropertyBinding.sanitizeNodeName(t||"");let n=s;for(let e=1;this.nodeNamesUsed[n];++e)n=s+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(t){const s=this,n=this.extensions,i=this.primitiveCache;function o(e){return n[r.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,s).then((function(t){return Q(t,e,s)}))}const a=[];for(let n=0,c=t.length;n<c;n++){const c=t[n],l=V(c),u=i[l];if(u)a.push(u.promise);else{let t;t=c.extensions&&c.extensions[r.KHR_DRACO_MESH_COMPRESSION]?o(c):Q(new e.BufferGeometry,c,s),i[l]={primitive:c,promise:t},a.push(t)}}return Promise.all(a)}loadMesh(s){const n=this,r=this.json,i=this.extensions,o=r.meshes[s],a=o.primitives,c=[];for(let t=0,s=a.length;t<s;t++){const s=void 0===a[t].material?(void 0===(l=this.cache).DefaultMaterial&&(l.DefaultMaterial=new e.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:e.FrontSide})),l.DefaultMaterial):this.getDependency("material",a[t].material);c.push(s)}var l;return c.push(n.loadGeometries(a)),Promise.all(c).then((function(r){const c=r.slice(0,r.length-1),l=r[r.length-1],u=[];for(let r=0,h=l.length;r<h;r++){const h=l[r],d=a[r];let m;const p=c[r];if(d.mode===b.TRIANGLES||d.mode===b.TRIANGLE_STRIP||d.mode===b.TRIANGLE_FAN||void 0===d.mode)m=!0===o.isSkinnedMesh?new e.SkinnedMesh(h,p):new e.Mesh(h,p),!0===m.isSkinnedMesh&&m.normalizeSkinWeights(),d.mode===b.TRIANGLE_STRIP?m.geometry=t.toTrianglesDrawMode(m.geometry,e.TriangleStripDrawMode):d.mode===b.TRIANGLE_FAN&&(m.geometry=t.toTrianglesDrawMode(m.geometry,e.TriangleFanDrawMode));else if(d.mode===b.LINES)m=new e.LineSegments(h,p);else if(d.mode===b.LINE_STRIP)m=new e.Line(h,p);else if(d.mode===b.LINE_LOOP)m=new e.LineLoop(h,p);else{if(d.mode!==b.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);m=new e.Points(h,p)}Object.keys(m.geometry.morphAttributes).length>0&&K(m,o),m.name=n.createUniqueName(o.name||"mesh_"+s),j(m,o),d.extensions&&G(i,m,d),n.assignFinalMaterial(m),u.push(m)}for(let e=0,t=u.length;e<t;e++)n.associations.set(u[e],{meshes:s,primitives:e});if(1===u.length)return u[0];const h=new e.Group;n.associations.set(h,{meshes:s});for(let e=0,t=u.length;e<t;e++)h.add(u[e]);return h}))}loadCamera(t){let s;const n=this.json.cameras[t],r=n[n.type];if(r)return"perspective"===n.type?s=new e.PerspectiveCamera(e.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(s=new e.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(s.name=this.createUniqueName(n.name)),j(s,n),Promise.resolve(s);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const s=this.json.skins[t],n=[];for(let e=0,t=s.joints.length;e<t;e++)n.push(this._loadNodeShallow(s.joints[e]));return void 0!==s.inverseBindMatrices?n.push(this.getDependency("accessor",s.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(t){const n=t.pop(),r=t,i=[],o=[];for(let t=0,a=r.length;t<a;t++){const a=r[t];if(a){i.push(a);const s=new e.Matrix4;null!==n&&s.fromArray(n.array,16*t),o.push(s)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',s.joints[t])}return new e.Skeleton(i,o)}))}loadAnimation(t){const s=this.json.animations[t],n=s.name?s.name:"animation_"+t,r=[],i=[],o=[],a=[],c=[];for(let e=0,t=s.channels.length;e<t;e++){const t=s.channels[e],n=s.samplers[t.sampler],l=t.target,u=l.node,h=void 0!==s.parameters?s.parameters[n.input]:n.input,d=void 0!==s.parameters?s.parameters[n.output]:n.output;void 0!==l.node&&(r.push(this.getDependency("node",u)),i.push(this.getDependency("accessor",h)),o.push(this.getDependency("accessor",d)),a.push(n),c.push(l))}return Promise.all([Promise.all(r),Promise.all(i),Promise.all(o),Promise.all(a),Promise.all(c)]).then((function(t){const s=t[0],r=t[1],i=t[2],o=t[3],a=t[4],c=[];for(let t=0,n=s.length;t<n;t++){const n=s[t],l=r[t],u=i[t],h=o[t],d=a[t];if(void 0===n)continue;let m;switch(n.updateMatrix(),F[d.path]){case F.weights:m=e.NumberKeyframeTrack;break;case F.rotation:m=e.QuaternionKeyframeTrack;break;case F.position:case F.scale:default:m=e.VectorKeyframeTrack}const p=n.name?n.name:n.uuid,f=void 0!==h.interpolation?k[h.interpolation]:e.InterpolateLinear,A=[];F[d.path]===F.weights?n.traverse((function(e){e.morphTargetInfluences&&A.push(e.name?e.name:e.uuid)})):A.push(p);let g=u.array;if(u.normalized){const e=q(g.constructor),t=new Float32Array(g.length);for(let s=0,n=g.length;s<n;s++)t[s]=g[s]*e;g=t}for(let t=0,s=A.length;t<s;t++){const s=new m(A[t]+"."+F[d.path],l.array,g,f);"CUBICSPLINE"===h.interpolation&&(s.createInterpolant=function(t){return new(this instanceof e.QuaternionKeyframeTrack?I:y)(this.times,this.values,this.getValueSize()/3,t)},s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),c.push(s)}}return new e.AnimationClip(n,void 0,c)}))}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return void 0===n.mesh?null:s.getDependency("mesh",n.mesh).then((function(e){const t=s._getNodeRef(s.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,s=n.weights.length;t<s;t++)e.morphTargetInfluences[t]=n.weights[t]})),t}))}loadNode(e){const t=this,s=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],i=s.children||[];for(let e=0,s=i.length;e<s;e++)r.push(t.getDependency("node",i[e]));const o=void 0===s.skin?Promise.resolve(null):t.getDependency("skin",s.skin);return Promise.all([n,Promise.all(r),o]).then((function(e){const t=e[0],s=e[1],n=e[2];null!==n&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(n,z)}));for(let e=0,n=s.length;e<n;e++)t.add(s[e]);return t}))}_loadNodeShallow(t){const s=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const i=s.nodes[t],o=i.name?r.createUniqueName(i.name):"",a=[],c=r._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return c&&a.push(c),void 0!==i.camera&&a.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(e){a.push(e)})),this.nodeCache[t]=Promise.all(a).then((function(s){let a;if(a=!0===i.isBone?new e.Bone:s.length>1?new e.Group:1===s.length?s[0]:new e.Object3D,a!==s[0])for(let e=0,t=s.length;e<t;e++)a.add(s[e]);if(i.name&&(a.userData.name=i.name,a.name=o),j(a,i),i.extensions&&G(n,a,i),void 0!==i.matrix){const t=new e.Matrix4;t.fromArray(i.matrix),a.applyMatrix4(t)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=t,a})),this.nodeCache[t]}loadScene(t){const s=this.extensions,n=this.json.scenes[t],r=this,i=new e.Group;n.name&&(i.name=r.createUniqueName(n.name)),j(i,n),n.extensions&&G(s,i,n);const o=n.nodes||[],a=[];for(let e=0,t=o.length;e<t;e++)a.push(r.getDependency("node",o[e]));return Promise.all(a).then((function(t){for(let e=0,s=t.length;e<s;e++)i.add(t[e]);return r.associations=(t=>{const s=new Map;for(const[t,n]of r.associations)(t instanceof e.Material||t instanceof e.Texture)&&s.set(t,n);return t.traverse((e=>{const t=r.associations.get(e);null!=t&&s.set(e,t)})),s})(i),i}))}}function Q(t,s,n){const r=s.attributes,i=[];function o(e,s){return n.getDependency("accessor",e).then((function(e){t.setAttribute(s,e)}))}for(const e in r){const s=H[e]||e.toLowerCase();s in t.attributes||i.push(o(r[e],s))}if(void 0!==s.indices&&!t.index){const e=n.getDependency("accessor",s.indices).then((function(e){t.setIndex(e)}));i.push(e)}return j(t,s),function(t,s,n){const r=s.attributes,i=new e.Box3;if(void 0===r.POSITION)return;{const t=n.json.accessors[r.POSITION],s=t.min,o=t.max;if(void 0===s||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new e.Vector3(s[0],s[1],s[2]),new e.Vector3(o[0],o[1],o[2])),t.normalized){const e=q(N[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const o=s.targets;if(void 0!==o){const t=new e.Vector3,s=new e.Vector3;for(let e=0,r=o.length;e<r;e++){const r=o[e];if(void 0!==r.POSITION){const e=n.json.accessors[r.POSITION],i=e.min,o=e.max;if(void 0!==i&&void 0!==o){if(s.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),s.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),s.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),e.normalized){const t=q(N[e.componentType]);s.multiplyScalar(t)}t.max(s)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(t)}t.boundingBox=i;const a=new e.Sphere;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,t.boundingSphere=a}(t,s,n),Promise.all(i).then((function(){return void 0!==s.targets?function(e,t,s){let n=!1,r=!1,i=!1;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(void 0!==s.POSITION&&(n=!0),void 0!==s.NORMAL&&(r=!0),void 0!==s.COLOR_0&&(i=!0),n&&r&&i)break}if(!n&&!r&&!i)return Promise.resolve(e);const o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){const u=t[l];if(n){const t=void 0!==u.POSITION?s.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==u.NORMAL?s.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(i){const t=void 0!==u.COLOR_0?s.getDependency("accessor",u.COLOR_0):e.attributes.color;c.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then((function(t){const s=t[0],o=t[1],a=t[2];return n&&(e.morphAttributes.position=s),r&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(t,s.targets,n):t}))}exports.GLTFLoader=s;
@@ -1,4 +1,4 @@
1
- import { Loader, LoaderUtils, FileLoader, Color, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, sRGBEncoding, MeshPhysicalMaterial, Vector2, Matrix4, Vector3, Quaternion, InstancedMesh, Object3D, REVISION, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, Mesh, TriangleStripDrawMode, TriangleFanDrawMode, LineSegments, Line, LineLoop, Points, Group, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, InterpolateLinear, AnimationClip, Bone, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, Box3, Sphere, Interpolant } from 'three';
1
+ import { Loader, LoaderUtils, FileLoader, Color, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, MeshPhysicalMaterial, Vector2, Matrix4, Vector3, Quaternion, InstancedMesh, Object3D, REVISION, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, Mesh, TriangleStripDrawMode, TriangleFanDrawMode, LineSegments, Line, LineLoop, Points, Group, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, InterpolateLinear, AnimationClip, Bone, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, Box3, Sphere, Interpolant } from 'three';
2
2
  import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
3
3
 
4
4
  class GLTFLoader extends Loader {
@@ -409,7 +409,7 @@ class GLTFMaterialsUnlitExtension {
409
409
  }
410
410
 
411
411
  if (metallicRoughness.baseColorTexture !== undefined) {
412
- pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture, sRGBEncoding));
412
+ pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture, 3001)); // sRGBEncoding
413
413
  }
414
414
  }
415
415
 
@@ -614,7 +614,7 @@ class GLTFMaterialsSheenExtension {
614
614
  }
615
615
 
616
616
  if (extension.sheenColorTexture !== undefined) {
617
- pending.push(parser.assignTexture(materialParams, 'sheenColorMap', extension.sheenColorTexture, sRGBEncoding));
617
+ pending.push(parser.assignTexture(materialParams, 'sheenColorMap', extension.sheenColorTexture, 3001)); // sRGBEncoding
618
618
  }
619
619
 
620
620
  if (extension.sheenRoughnessTexture !== undefined) {
@@ -786,7 +786,8 @@ class GLTFMaterialsSpecularExtension {
786
786
  materialParams.specularColor = new Color(colorArray[0], colorArray[1], colorArray[2]);
787
787
 
788
788
  if (extension.specularColorTexture !== undefined) {
789
- pending.push(parser.assignTexture(materialParams, 'specularColorMap', extension.specularColorTexture, sRGBEncoding));
789
+ pending.push(parser.assignTexture(materialParams, 'specularColorMap', extension.specularColorTexture, 3001) // sRGBEncoding
790
+ );
790
791
  }
791
792
 
792
793
  return Promise.all(pending);
@@ -2253,7 +2254,7 @@ class GLTFParser {
2253
2254
  }
2254
2255
 
2255
2256
  if (encoding !== undefined) {
2256
- texture.encoding = encoding;
2257
+ if ('colorSpace' in texture) texture.colorSpace = encoding === 3001 ? 'srgb' : 'srgb-linear';else texture.encoding = encoding;
2257
2258
  }
2258
2259
 
2259
2260
  materialParams[mapName] = texture;
@@ -2374,7 +2375,7 @@ class GLTFParser {
2374
2375
  }
2375
2376
 
2376
2377
  if (metallicRoughness.baseColorTexture !== undefined) {
2377
- pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture, sRGBEncoding));
2378
+ pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture, 3001)); // sRGBEncoding
2378
2379
  }
2379
2380
 
2380
2381
  materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("./RGBELoader.cjs.js");class a extends e.Loader{constructor(a){super(a),this.hdrLoader=new t.RGBELoader,this.type=e.HalfFloatType}load(t,a,r,i){Array.isArray(t)||(console.warn("THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead."),this.setDataType(t),t=a,a=r,r=i,i=arguments[4]);const s=new e.CubeTexture;switch(s.type=this.type,s.type){case e.FloatType:case e.HalfFloatType:s.encoding=e.LinearEncoding,s.minFilter=e.LinearFilter,s.magFilter=e.LinearFilter,s.generateMipmaps=!1}const n=this;let o=0;function d(a,r,i,d){new e.FileLoader(n.manager).setPath(n.path).setResponseType("arraybuffer").setWithCredentials(n.withCredentials).load(t[a],(function(t){o++;const i=n.hdrLoader.parse(t);if(i){if(void 0!==i.data){const t=new e.DataTexture(i.data,i.width,i.height);t.type=s.type,t.encoding=s.encoding,t.format=s.format,t.minFilter=s.minFilter,t.magFilter=s.magFilter,t.generateMipmaps=s.generateMipmaps,s.images[a]=t}6===o&&(s.needsUpdate=!0,r&&r(s))}}),i,d)}for(let e=0;e<t.length;e++)d(e,a,r,i);return s}setDataType(e){return this.type=e,this.hdrLoader.setDataType(e),this}}exports.HDRCubeTextureLoader=a;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("./RGBELoader.cjs.js");class a extends e.Loader{constructor(a){super(a),this.hdrLoader=new t.RGBELoader,this.type=e.HalfFloatType}load(t,a,r,s){Array.isArray(t)||(console.warn("THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead."),this.setDataType(t),t=a,a=r,r=s,s=arguments[4]);const i=new e.CubeTexture;switch(i.type=this.type,i.type){case e.FloatType:case e.HalfFloatType:"colorSpace"in i?i.colorSpace="srgb-linear":i.encoding=3e3,i.minFilter=e.LinearFilter,i.magFilter=e.LinearFilter,i.generateMipmaps=!1}const n=this;let o=0;function p(a,r,s,p){new e.FileLoader(n.manager).setPath(n.path).setResponseType("arraybuffer").setWithCredentials(n.withCredentials).load(t[a],(function(t){o++;const s=n.hdrLoader.parse(t);if(s){if(void 0!==s.data){const t=new e.DataTexture(s.data,s.width,s.height);t.type=i.type,t.encoding=i.encoding,t.format=i.format,t.minFilter=i.minFilter,t.magFilter=i.magFilter,t.generateMipmaps=i.generateMipmaps,i.images[a]=t}6===o&&(i.needsUpdate=!0,r&&r(i))}}),s,p)}for(let e=0;e<t.length;e++)p(e,a,r,s);return i}setDataType(e){return this.type=e,this.hdrLoader.setDataType(e),this}}exports.HDRCubeTextureLoader=a;
@@ -1,4 +1,4 @@
1
- import { Loader, HalfFloatType, CubeTexture, LinearEncoding, LinearFilter, FloatType, FileLoader, DataTexture } from 'three';
1
+ import { Loader, HalfFloatType, CubeTexture, LinearFilter, FloatType, FileLoader, DataTexture } from 'three';
2
2
  import { RGBELoader } from './RGBELoader.js';
3
3
 
4
4
  class HDRCubeTextureLoader extends Loader {
@@ -23,14 +23,9 @@ class HDRCubeTextureLoader extends Loader {
23
23
 
24
24
  switch (texture.type) {
25
25
  case FloatType:
26
- texture.encoding = LinearEncoding;
27
- texture.minFilter = LinearFilter;
28
- texture.magFilter = LinearFilter;
29
- texture.generateMipmaps = false;
30
- break;
31
-
32
26
  case HalfFloatType:
33
- texture.encoding = LinearEncoding;
27
+ if ('colorSpace' in texture) texture.colorSpace = 'srgb-linear';else texture.encoding = 3000; // LinearEncoding
28
+
34
29
  texture.minFilter = LinearFilter;
35
30
  texture.magFilter = LinearFilter;
36
31
  texture.generateMipmaps = false;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("../utils/WorkerPool.cjs.js"),t=require("ktx-parse"),o=require("zstddec");const s=new WeakMap;let a,n=0;class i extends e.Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new r.WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1),this}init(){if(!this.transcoderPending){const r=new e.FileLoader(this.manager);r.setPath(this.transcoderPath),r.setWithCredentials(this.withCredentials);const t=r.loadAsync("basis_transcoder.js"),o=new e.FileLoader(this.manager);o.setPath(this.transcoderPath),o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials);const s=o.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then((([e,r])=>{const t=i.BasisWorker.toString(),o=["/* constants */","let _EngineFormat = "+JSON.stringify(i.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(i.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(i.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([o])),this.transcoderBinary=r,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),r=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:r},[r]),e}))})),n>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),n++}return this.transcoderPending}load(r,t,o,a){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const n=new e.FileLoader(this.manager);n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials),n.load(r,(e=>{if(s.has(e)){return s.get(e).promise.then(t).catch(a)}this._createTexture(e).then((e=>t?t(e):null)).catch(a)}),o,a)}_createTextureFrom(r){const{mipmaps:o,width:s,height:a,format:n,type:i,error:_,dfdTransferFn:T,dfdFlags:d}=r;if("error"===i)return Promise.reject(_);const R=new e.CompressedTexture(o,s,a,n,e.UnsignedByteType);return R.minFilter=1===o.length?e.LinearFilter:e.LinearMipmapLinearFilter,R.magFilter=e.LinearFilter,R.generateMipmaps=!1,R.needsUpdate=!0,R.encoding=T===t.KHR_DF_TRANSFER_SRGB?e.sRGBEncoding:e.LinearEncoding,R.premultiplyAlpha=!!(d&t.KHR_DF_FLAG_ALPHA_PREMULTIPLIED),R}_createTexture(r,n={}){const i=t.read(new Uint8Array(r));if(i.vkFormat!==t.VK_FORMAT_UNDEFINED)return async function(r){const{vkFormat:s,pixelWidth:n,pixelHeight:i,pixelDepth:R}=r;if(void 0===_[s])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const c=r.levels[0];let F,p;if(r.supercompressionScheme===t.KHR_SUPERCOMPRESSION_NONE)F=c.levelData;else{if(r.supercompressionScheme!==t.KHR_SUPERCOMPRESSION_ZSTD)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");a||(a=new Promise((async e=>{const r=new o.ZSTDDecoder;await r.init(),e(r)}))),F=(await a).decode(c.levelData,c.uncompressedByteLength)}p=T[s]===e.FloatType?new Float32Array(F.buffer,F.byteOffset,F.byteLength/Float32Array.BYTES_PER_ELEMENT):T[s]===e.HalfFloatType?new Uint16Array(F.buffer,F.byteOffset,F.byteLength/Uint16Array.BYTES_PER_ELEMENT):F;const m=0===R?new e.DataTexture(p,n,i):new e.Data3DTexture(p,n,i,R);return m.type=T[s],m.format=_[s],m.encoding=d[s]||e.LinearEncoding,m.needsUpdate=!0,Promise.resolve(m)}(i);const R=n,c=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:r,taskConfig:R},[r]))).then((e=>this._createTextureFrom(e.data)));return s.set(r,{promise:c}),c}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),n--,this}}i.BasisFormat={ETC1S:0,UASTC_4x4:1},i.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},i.EngineFormat={RGBAFormat:e.RGBAFormat,RGBA_ASTC_4x4_Format:e.RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:e.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:e.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:e.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:e.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:e.RGB_ETC1_Format,RGB_ETC2_Format:e.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:e.RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:e.RGB_S3TC_DXT1_Format},i.BasisWorker=function(){let e,r,t;const o=_EngineFormat,s=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",(function(n){const d=n.data;switch(d.type){case"init":e=d.config,R=d.transcoderBinary,r=new Promise((e=>{t={wasmBinary:R,onRuntimeInitialized:e},BASIS(t)})).then((()=>{t.initializeBasis(),void 0===t.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":r.then((()=>{try{const{width:r,height:n,hasAlpha:R,mipmaps:c,format:F,dfdTransferFn:p,dfdFlags:m}=function(r){const n=new t.KTX2File(new Uint8Array(r));function d(){n.close(),n.delete()}if(!n.isValid())throw d(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const R=n.isUASTC()?a.UASTC_4x4:a.ETC1S,c=n.getWidth(),F=n.getHeight(),p=n.getLevels(),m=n.getHasAlpha(),l=n.getDFDTransferFunc(),A=n.getDFDFlags(),{transcoderFormat:B,engineFormat:h}=function(r,t,n,d){let R,c;const F=r===a.ETC1S?i:_;for(let o=0;o<F.length;o++){const s=F[o];if(e[s.if]&&(s.basisFormat.includes(r)&&!(d&&s.transcoderFormat.length<2)&&(!s.needsPowerOfTwo||T(t)&&T(n))))return R=s.transcoderFormat[d?1:0],c=s.engineFormat[d?1:0],{transcoderFormat:R,engineFormat:c}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),R=s.RGBA32,c=o.RGBAFormat,{transcoderFormat:R,engineFormat:c}}(R,c,F,m);if(!c||!F||!p)throw d(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!n.startTranscoding())throw d(),new Error("THREE.KTX2Loader: .startTranscoding failed");const S=[];for(let e=0;e<p;e++){const r=n.getImageLevelInfo(e,0,0),t=r.origWidth,o=r.origHeight,s=new Uint8Array(n.getImageTranscodedSizeInBytes(e,0,0,B));if(!n.transcodeImage(s,e,0,0,B,0,-1,-1))throw d(),new Error("THREE.KTX2Loader: .transcodeImage failed.");S.push({data:s,width:t,height:o})}return d(),{width:c,height:F,hasAlpha:m,mipmaps:S,format:h,dfdTransferFn:l,dfdFlags:A}}(d.buffer),l=[];for(let e=0;e<c.length;++e)l.push(c[e].data.buffer);self.postMessage({type:"transcode",id:d.id,width:r,height:n,hasAlpha:R,mipmaps:c,format:F,dfdTransferFn:p,dfdFlags:m},l)}catch(e){console.error(e),self.postMessage({type:"error",id:d.id,error:e.message})}}))}var R}));const n=[{if:"astcSupported",basisFormat:[a.UASTC_4x4],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[o.RGBA_ASTC_4x4_Format,o.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[o.RGBA_BPTC_Format,o.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.BC1,s.BC3],engineFormat:[o.RGB_S3TC_DXT1_Format,o.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[o.RGB_ETC2_Format,o.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.ETC1],engineFormat:[o.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[o.RGB_PVRTC_4BPPV1_Format,o.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],i=n.sort((function(e,r){return e.priorityETC1S-r.priorityETC1S})),_=n.sort((function(e,r){return e.priorityUASTC-r.priorityUASTC}));function T(e){return e<=2||0==(e&e-1)&&0!==e}};const _={[t.VK_FORMAT_R32G32B32A32_SFLOAT]:e.RGBAFormat,[t.VK_FORMAT_R16G16B16A16_SFLOAT]:e.RGBAFormat,[t.VK_FORMAT_R8G8B8A8_UNORM]:e.RGBAFormat,[t.VK_FORMAT_R8G8B8A8_SRGB]:e.RGBAFormat,[t.VK_FORMAT_R32G32_SFLOAT]:e.RGFormat,[t.VK_FORMAT_R16G16_SFLOAT]:e.RGFormat,[t.VK_FORMAT_R8G8_UNORM]:e.RGFormat,[t.VK_FORMAT_R8G8_SRGB]:e.RGFormat,[t.VK_FORMAT_R32_SFLOAT]:e.RedFormat,[t.VK_FORMAT_R16_SFLOAT]:e.RedFormat,[t.VK_FORMAT_R8_SRGB]:e.RedFormat,[t.VK_FORMAT_R8_UNORM]:e.RedFormat},T={[t.VK_FORMAT_R32G32B32A32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16G16B16A16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8G8B8A8_UNORM]:e.UnsignedByteType,[t.VK_FORMAT_R8G8B8A8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R32G32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16G16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8G8_UNORM]:e.UnsignedByteType,[t.VK_FORMAT_R8G8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R8_UNORM]:e.UnsignedByteType},d={[t.VK_FORMAT_R8G8B8A8_SRGB]:e.sRGBEncoding,[t.VK_FORMAT_R8G8_SRGB]:e.sRGBEncoding,[t.VK_FORMAT_R8_SRGB]:e.sRGBEncoding};exports.KTX2Loader=i;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("../utils/WorkerPool.cjs.js"),t=require("ktx-parse"),o=require("zstddec");class s extends e.CompressedTexture{constructor(r,t,o,s,a,n){super(r,t,o,a,n),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=e.ClampToEdgeWrapping}}const a=new WeakMap;let n,i=0;class _ extends e.Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new r.WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1),this}init(){if(!this.transcoderPending){const r=new e.FileLoader(this.manager);r.setPath(this.transcoderPath),r.setWithCredentials(this.withCredentials);const t=r.loadAsync("basis_transcoder.js"),o=new e.FileLoader(this.manager);o.setPath(this.transcoderPath),o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials);const s=o.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then((([e,r])=>{const t=_.BasisWorker.toString(),o=["/* constants */","let _EngineFormat = "+JSON.stringify(_.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(_.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(_.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([o])),this.transcoderBinary=r,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),r=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:r},[r]),e}))})),i>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),i++}return this.transcoderPending}load(r,t,o,s){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const n=new e.FileLoader(this.manager);n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials),n.load(r,(e=>{if(a.has(e)){return a.get(e).promise.then(t).catch(s)}this._createTexture(e).then((e=>t?t(e):null)).catch(s)}),o,s)}_createTextureFrom(r,o){const{mipmaps:a,width:n,height:i,format:_,type:T,error:d,dfdTransferFn:c,dfdFlags:R}=r;if("error"===T)return Promise.reject(d);const F=o.layerCount>1?new s(a,n,i,o.layerCount,_,e.UnsignedByteType):new e.CompressedTexture(a,n,i,_,e.UnsignedByteType);return F.minFilter=1===a.length?e.LinearFilter:e.LinearMipmapLinearFilter,F.magFilter=e.LinearFilter,F.generateMipmaps=!1,F.needsUpdate=!0,"colorSpace"in F?F.colorSpace=c===t.KHR_DF_TRANSFER_SRGB?"srgb":"srgb-linear":F.encoding=c===t.KHR_DF_TRANSFER_SRGB?3001:3e3,F.premultiplyAlpha=!!(R&t.KHR_DF_FLAG_ALPHA_PREMULTIPLIED),F}async _createTexture(r,s={}){const i=t.read(new Uint8Array(r));if(i.vkFormat!==t.VK_FORMAT_UNDEFINED)return async function(r){const{vkFormat:s,pixelWidth:a,pixelHeight:i,pixelDepth:_}=r;if(void 0===T[s])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const R=r.levels[0];let F,p;if(r.supercompressionScheme===t.KHR_SUPERCOMPRESSION_NONE)F=R.levelData;else{if(r.supercompressionScheme!==t.KHR_SUPERCOMPRESSION_ZSTD)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");n||(n=new Promise((async e=>{const r=new o.ZSTDDecoder;await r.init(),e(r)}))),F=(await n).decode(R.levelData,R.uncompressedByteLength)}p=d[s]===e.FloatType?new Float32Array(F.buffer,F.byteOffset,F.byteLength/Float32Array.BYTES_PER_ELEMENT):d[s]===e.HalfFloatType?new Uint16Array(F.buffer,F.byteOffset,F.byteLength/Uint16Array.BYTES_PER_ELEMENT):F;const m=0===_?new e.DataTexture(p,a,i):new e.Data3DTexture(p,a,i,_);return m.type=d[s],m.format=T[s],m.encoding=c[s]||3e3,m.needsUpdate=!0,Promise.resolve(m)}(i);const _=s,R=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:r,taskConfig:_},[r]))).then((e=>this._createTextureFrom(e.data,i)));return a.set(r,{promise:R}),R}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),i--,this}}_.BasisFormat={ETC1S:0,UASTC_4x4:1},_.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},_.EngineFormat={RGBAFormat:e.RGBAFormat,RGBA_ASTC_4x4_Format:e.RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:e.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:e.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:e.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:e.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:e.RGB_ETC1_Format,RGB_ETC2_Format:e.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:e.RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:e.RGB_S3TC_DXT1_Format},_.BasisWorker=function(){let e,r,t;const o=_EngineFormat,s=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",(function(n){const c=n.data;switch(c.type){case"init":e=c.config,R=c.transcoderBinary,r=new Promise((e=>{t={wasmBinary:R,onRuntimeInitialized:e},BASIS(t)})).then((()=>{t.initializeBasis(),void 0===t.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":r.then((()=>{try{const{width:r,height:n,hasAlpha:R,mipmaps:F,format:p,dfdTransferFn:m,dfdFlags:l}=function(r){const n=new t.KTX2File(new Uint8Array(r));function c(){n.close(),n.delete()}if(!n.isValid())throw c(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const R=n.isUASTC()?a.UASTC_4x4:a.ETC1S,F=n.getWidth(),p=n.getHeight(),m=n.getLayers()||1,l=n.getLevels(),h=n.getHasAlpha(),A=n.getDFDTransferFunc(),B=n.getDFDFlags(),{transcoderFormat:u,engineFormat:S}=function(r,t,n,d){let c,R;const F=r===a.ETC1S?i:_;for(let o=0;o<F.length;o++){const s=F[o];if(e[s.if]&&(s.basisFormat.includes(r)&&!(d&&s.transcoderFormat.length<2)&&(!s.needsPowerOfTwo||T(t)&&T(n))))return c=s.transcoderFormat[d?1:0],R=s.engineFormat[d?1:0],{transcoderFormat:c,engineFormat:R}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),c=s.RGBA32,R=o.RGBAFormat,{transcoderFormat:c,engineFormat:R}}(R,F,p,h);if(!F||!p||!l)throw c(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!n.startTranscoding())throw c(),new Error("THREE.KTX2Loader: .startTranscoding failed");const C=[];for(let e=0;e<l;e++){const r=[];let t,o;for(let s=0;s<m;s++){const a=n.getImageLevelInfo(e,s,0);t=a.origWidth<4?a.origWidth:a.width,o=a.origHeight<4?a.origHeight:a.height;const i=new Uint8Array(n.getImageTranscodedSizeInBytes(e,s,0,u));if(!n.transcodeImage(i,e,s,0,u,0,-1,-1))throw c(),new Error("THREE.KTX2Loader: .transcodeImage failed.");r.push(i)}C.push({data:d(r),width:t,height:o})}return c(),{width:F,height:p,hasAlpha:h,mipmaps:C,format:S,dfdTransferFn:A,dfdFlags:B}}(c.buffer),h=[];for(let e=0;e<F.length;++e)h.push(F[e].data.buffer);self.postMessage({type:"transcode",id:c.id,width:r,height:n,hasAlpha:R,mipmaps:F,format:p,dfdTransferFn:m,dfdFlags:l},h)}catch(e){console.error(e),self.postMessage({type:"error",id:c.id,error:e.message})}}))}var R}));const n=[{if:"astcSupported",basisFormat:[a.UASTC_4x4],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[o.RGBA_ASTC_4x4_Format,o.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[o.RGBA_BPTC_Format,o.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.BC1,s.BC3],engineFormat:[o.RGB_S3TC_DXT1_Format,o.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[o.RGB_ETC2_Format,o.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.ETC1],engineFormat:[o.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[o.RGB_PVRTC_4BPPV1_Format,o.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],i=n.sort((function(e,r){return e.priorityETC1S-r.priorityETC1S})),_=n.sort((function(e,r){return e.priorityUASTC-r.priorityUASTC}));function T(e){return e<=2||0==(e&e-1)&&0!==e}function d(e){let r=0;for(let t=0;t<e.length;t++){r+=e[t].byteLength}const t=new Uint8Array(r);let o=0;for(let r=0;r<e.length;r++){const s=e[r];t.set(s,o),o+=s.byteLength}return t}};const T={[t.VK_FORMAT_R32G32B32A32_SFLOAT]:e.RGBAFormat,[t.VK_FORMAT_R16G16B16A16_SFLOAT]:e.RGBAFormat,[t.VK_FORMAT_R8G8B8A8_UNORM]:e.RGBAFormat,[t.VK_FORMAT_R8G8B8A8_SRGB]:e.RGBAFormat,[t.VK_FORMAT_R32G32_SFLOAT]:e.RGFormat,[t.VK_FORMAT_R16G16_SFLOAT]:e.RGFormat,[t.VK_FORMAT_R8G8_UNORM]:e.RGFormat,[t.VK_FORMAT_R8G8_SRGB]:e.RGFormat,[t.VK_FORMAT_R32_SFLOAT]:e.RedFormat,[t.VK_FORMAT_R16_SFLOAT]:e.RedFormat,[t.VK_FORMAT_R8_SRGB]:e.RedFormat,[t.VK_FORMAT_R8_UNORM]:e.RedFormat},d={[t.VK_FORMAT_R32G32B32A32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16G16B16A16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8G8B8A8_UNORM]:e.UnsignedByteType,[t.VK_FORMAT_R8G8B8A8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R32G32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16G16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8G8_UNORM]:e.UnsignedByteType,[t.VK_FORMAT_R8G8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R8_UNORM]:e.UnsignedByteType},c={[t.VK_FORMAT_R8G8B8A8_SRGB]:3001,[t.VK_FORMAT_R8G8_SRGB]:3001,[t.VK_FORMAT_R8_SRGB]:3001};exports.KTX2Loader=_;
@@ -1,4 +1,4 @@
1
- import { Loader, FileLoader, CompressedTexture, UnsignedByteType, LinearFilter, LinearMipmapLinearFilter, sRGBEncoding, LinearEncoding, RGBAFormat, RGBA_ASTC_4x4_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, FloatType, HalfFloatType, DataTexture, Data3DTexture, RGFormat, RedFormat } from 'three';
1
+ import { Loader, FileLoader, UnsignedByteType, CompressedTexture, LinearFilter, LinearMipmapLinearFilter, RGBAFormat, RGBA_ASTC_4x4_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, FloatType, HalfFloatType, DataTexture, Data3DTexture, ClampToEdgeWrapping, RGFormat, RedFormat } from 'three';
2
2
  import { WorkerPool } from '../utils/WorkerPool.js';
3
3
  import { KHR_DF_TRANSFER_SRGB, KHR_DF_FLAG_ALPHA_PREMULTIPLIED, read, VK_FORMAT_UNDEFINED, KHR_SUPERCOMPRESSION_NONE, KHR_SUPERCOMPRESSION_ZSTD, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8_SRGB, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R8_SRGB, VK_FORMAT_R8_UNORM } from 'ktx-parse';
4
4
  import { ZSTDDecoder } from 'zstddec';
@@ -16,6 +16,16 @@ import { ZSTDDecoder } from 'zstddec';
16
16
  * - DFD: https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#basicdescriptor
17
17
  */
18
18
 
19
+ class CompressedArrayTexture extends CompressedTexture {
20
+ constructor(mipmaps, width, height, depth, format, type) {
21
+ super(mipmaps, width, height, format, type);
22
+ this.isCompressedArrayTexture = true;
23
+ this.image.depth = depth;
24
+ this.wrapR = ClampToEdgeWrapping;
25
+ }
26
+
27
+ }
28
+
19
29
  const _taskCache = new WeakMap();
20
30
 
21
31
  let _activeLoaders = 0;
@@ -127,7 +137,7 @@ class KTX2Loader extends Loader {
127
137
  }, onProgress, onError);
128
138
  }
129
139
 
130
- _createTextureFrom(transcodeResult) {
140
+ _createTextureFrom(transcodeResult, container) {
131
141
  const {
132
142
  mipmaps,
133
143
  width,
@@ -139,23 +149,23 @@ class KTX2Loader extends Loader {
139
149
  dfdFlags
140
150
  } = transcodeResult;
141
151
  if (type === 'error') return Promise.reject(error);
142
- const texture = new CompressedTexture(mipmaps, width, height, format, UnsignedByteType);
152
+ const texture = container.layerCount > 1 ? new CompressedArrayTexture(mipmaps, width, height, container.layerCount, format, UnsignedByteType) : new CompressedTexture(mipmaps, width, height, format, UnsignedByteType);
143
153
  texture.minFilter = mipmaps.length === 1 ? LinearFilter : LinearMipmapLinearFilter;
144
154
  texture.magFilter = LinearFilter;
145
155
  texture.generateMipmaps = false;
146
156
  texture.needsUpdate = true;
147
- texture.encoding = dfdTransferFn === KHR_DF_TRANSFER_SRGB ? sRGBEncoding : LinearEncoding;
157
+ if ('colorSpace' in texture) texture.colorSpace = dfdTransferFn === KHR_DF_TRANSFER_SRGB ? 'srgb' : 'srgb-linear';else texture.encoding = dfdTransferFn === KHR_DF_TRANSFER_SRGB ? 3001 : 3000;
148
158
  texture.premultiplyAlpha = !!(dfdFlags & KHR_DF_FLAG_ALPHA_PREMULTIPLIED);
149
159
  return texture;
150
160
  }
151
161
  /**
152
162
  * @param {ArrayBuffer} buffer
153
163
  * @param {object?} config
154
- * @return {Promise<CompressedTexture|DataTexture|Data3DTexture>}
164
+ * @return {Promise<CompressedTexture|CompressedArrayTexture|DataTexture|Data3DTexture>}
155
165
  */
156
166
 
157
167
 
158
- _createTexture(buffer, config = {}) {
168
+ async _createTexture(buffer, config = {}) {
159
169
  const container = read(new Uint8Array(buffer));
160
170
 
161
171
  if (container.vkFormat !== VK_FORMAT_UNDEFINED) {
@@ -170,7 +180,7 @@ class KTX2Loader extends Loader {
170
180
  buffer,
171
181
  taskConfig: taskConfig
172
182
  }, [buffer]);
173
- }).then(e => this._createTextureFrom(e.data)); // Cache the task result.
183
+ }).then(e => this._createTextureFrom(e.data, container)); // Cache the task result.
174
184
 
175
185
  _taskCache.set(buffer, {
176
186
  promise: texturePending
@@ -320,6 +330,7 @@ KTX2Loader.BasisWorker = function () {
320
330
  const basisFormat = ktx2File.isUASTC() ? BasisFormat.UASTC_4x4 : BasisFormat.ETC1S;
321
331
  const width = ktx2File.getWidth();
322
332
  const height = ktx2File.getHeight();
333
+ const layers = ktx2File.getLayers() || 1;
323
334
  const levels = ktx2File.getLevels();
324
335
  const hasAlpha = ktx2File.getHasAlpha();
325
336
  const dfdTransferFn = ktx2File.getDFDTransferFunc();
@@ -342,19 +353,26 @@ KTX2Loader.BasisWorker = function () {
342
353
  const mipmaps = [];
343
354
 
344
355
  for (let mip = 0; mip < levels; mip++) {
345
- const levelInfo = ktx2File.getImageLevelInfo(mip, 0, 0);
346
- const mipWidth = levelInfo.origWidth;
347
- const mipHeight = levelInfo.origHeight;
348
- const dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, 0, 0, transcoderFormat));
349
- const status = ktx2File.transcodeImage(dst, mip, 0, 0, transcoderFormat, 0, -1, -1);
350
-
351
- if (!status) {
352
- cleanup();
353
- throw new Error('THREE.KTX2Loader: .transcodeImage failed.');
356
+ const layerMips = [];
357
+ let mipWidth, mipHeight;
358
+
359
+ for (let layer = 0; layer < layers; layer++) {
360
+ const levelInfo = ktx2File.getImageLevelInfo(mip, layer, 0);
361
+ mipWidth = levelInfo.origWidth < 4 ? levelInfo.origWidth : levelInfo.width;
362
+ mipHeight = levelInfo.origHeight < 4 ? levelInfo.origHeight : levelInfo.height;
363
+ const dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, transcoderFormat));
364
+ const status = ktx2File.transcodeImage(dst, mip, layer, 0, transcoderFormat, 0, -1, -1);
365
+
366
+ if (!status) {
367
+ cleanup();
368
+ throw new Error('THREE.KTX2Loader: .transcodeImage failed.');
369
+ }
370
+
371
+ layerMips.push(dst);
354
372
  }
355
373
 
356
374
  mipmaps.push({
357
- data: dst,
375
+ data: concat(layerMips),
358
376
  width: mipWidth,
359
377
  height: mipHeight
360
378
  });
@@ -468,6 +486,28 @@ KTX2Loader.BasisWorker = function () {
468
486
  if (value <= 2) return true;
469
487
  return (value & value - 1) === 0 && value !== 0;
470
488
  }
489
+ /** Concatenates N byte arrays. */
490
+
491
+
492
+ function concat(arrays) {
493
+ let totalByteLength = 0;
494
+
495
+ for (let i = 0; i < arrays.length; i++) {
496
+ const array = arrays[i];
497
+ totalByteLength += array.byteLength;
498
+ }
499
+
500
+ const result = new Uint8Array(totalByteLength);
501
+ let byteOffset = 0;
502
+
503
+ for (let i = 0; i < arrays.length; i++) {
504
+ const array = arrays[i];
505
+ result.set(array, byteOffset);
506
+ byteOffset += array.byteLength;
507
+ }
508
+
509
+ return result;
510
+ }
471
511
  }; //
472
512
  // DataTexture and Data3DTexture parsing.
473
513
 
@@ -501,9 +541,12 @@ const TYPE_MAP = {
501
541
  [VK_FORMAT_R8_UNORM]: UnsignedByteType
502
542
  };
503
543
  const ENCODING_MAP = {
504
- [VK_FORMAT_R8G8B8A8_SRGB]: sRGBEncoding,
505
- [VK_FORMAT_R8G8_SRGB]: sRGBEncoding,
506
- [VK_FORMAT_R8_SRGB]: sRGBEncoding
544
+ [VK_FORMAT_R8G8B8A8_SRGB]: 3001,
545
+ // sRGBEncoding
546
+ [VK_FORMAT_R8G8_SRGB]: 3001,
547
+ // sRGBEncoding
548
+ [VK_FORMAT_R8_SRGB]: 3001 // sRGBEncoding
549
+
507
550
  };
508
551
 
509
552
  async function createDataTexture(container) {
@@ -551,7 +594,8 @@ async function createDataTexture(container) {
551
594
  const texture = pixelDepth === 0 ? new DataTexture(view, pixelWidth, pixelHeight) : new Data3DTexture(view, pixelWidth, pixelHeight, pixelDepth);
552
595
  texture.type = TYPE_MAP[vkFormat];
553
596
  texture.format = FORMAT_MAP[vkFormat];
554
- texture.encoding = ENCODING_MAP[vkFormat] || LinearEncoding;
597
+ texture.encoding = ENCODING_MAP[vkFormat] || 3000; // LinearEncoding
598
+
555
599
  texture.needsUpdate = true; //
556
600
 
557
601
  return Promise.resolve(texture);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),s=require("../Nodes-9aa16d74.js");require("../nodes/core/ArrayUniformNode.cjs.js"),require("../nodes/core/UniformNode.cjs.js"),require("../nodes/core/InputNode.cjs.js"),require("../nodes/core/Node.cjs.js"),require("../nodes/core/constants.cjs.js"),require("../nodes/core/NodeUtils.cjs.js"),require("../nodes/core/AttributeNode.cjs.js"),require("../nodes/core/VaryNode.cjs.js"),require("../nodes/core/BypassNode.cjs.js"),require("../nodes/core/CodeNode.cjs.js"),require("../nodes/core/ConstNode.cjs.js"),require("../nodes/core/ContextNode.cjs.js"),require("../nodes/core/ExpressionNode.cjs.js"),require("../nodes/core/TempNode.cjs.js"),require("../nodes/core/FunctionCallNode.cjs.js"),require("../nodes/core/FunctionNode.cjs.js"),require("../nodes/core/NodeAttribute.cjs.js"),require("../nodes/core/NodeBuilder.cjs.js"),require("../nodes/core/NodeUniform.cjs.js"),require("../nodes/core/NodeVary.cjs.js"),require("../nodes/core/NodeVar.cjs.js"),require("../nodes/core/NodeCode.cjs.js"),require("../nodes/core/NodeKeywords.cjs.js"),require("../nodes/core/NodeFrame.cjs.js"),require("../nodes/core/NodeFunctionInput.cjs.js"),require("../nodes/core/PropertyNode.cjs.js"),require("../nodes/core/VarNode.cjs.js"),require("../nodes/accessors/BufferNode.cjs.js"),require("../nodes/accessors/CameraNode.cjs.js"),require("@babel/runtime/helpers/defineProperty"),require("../nodes/accessors/Object3DNode.cjs.js"),require("../nodes/accessors/CubeTextureNode.cjs.js"),require("../nodes/accessors/TextureNode.cjs.js"),require("../nodes/accessors/UVNode.cjs.js"),require("../nodes/accessors/ReflectNode.cjs.js"),require("../nodes/ShaderNode.cjs.js"),require("../nodes/accessors/PositionNode.cjs.js"),require("../nodes/accessors/ModelNode.cjs.js"),require("../nodes/math/MathNode.cjs.js"),require("../nodes/utils/JoinNode.cjs.js"),require("../nodes/utils/SplitNode.cjs.js"),require("../nodes/math/OperatorNode.cjs.js"),require("../nodes/accessors/NormalNode.cjs.js"),require("../nodes/math/CondNode.cjs.js"),require("../nodes/utils/ArrayElementNode.cjs.js"),require("../nodes/utils/ConvertNode.cjs.js"),require("../nodes/accessors/MaterialNode.cjs.js"),require("../nodes/accessors/MaterialReferenceNode.cjs.js"),require("../nodes/accessors/ReferenceNode.cjs.js"),require("../nodes/accessors/ModelViewProjectionNode.cjs.js"),require("../nodes/accessors/PointUVNode.cjs.js"),require("../nodes/accessors/SkinningNode.cjs.js"),require("../nodes/display/ColorSpaceNode.cjs.js"),require("../nodes/display/NormalMapNode.cjs.js"),require("../nodes/lights/LightContextNode.cjs.js"),require("../nodes/functions/BSDFs.cjs.js"),require("../nodes/lights/LightNode.cjs.js"),require("../nodes/lights/LightsNode.cjs.js"),require("../nodes/utils/SpriteSheetUVNode.cjs.js"),require("../nodes/utils/MatcapUVNode.cjs.js"),require("../nodes/utils/OscNode.cjs.js"),require("../nodes/utils/TimerNode.cjs.js"),require("../nodes/loaders/NodeMaterialLoader.cjs.js"),require("../nodes/procedural/CheckerNode.cjs.js"),require("../nodes/fog/FogNode.cjs.js"),require("../nodes/fog/FogRangeNode.cjs.js"),require("../nodes/materials/LineBasicNodeMaterial.cjs.js"),require("../nodes/materials/NodeMaterial.cjs.js"),require("../nodes/materials/MeshBasicNodeMaterial.cjs.js"),require("../nodes/materials/MeshStandardNodeMaterial.cjs.js"),require("../nodes/materials/PointsNodeMaterial.cjs.js");class r extends e.Loader{constructor(e,s={}){super(e),this.nodes={},this.materials={},this.passes={},this.names={},this.library=s}load(s,r,o,i){const t=this,d=new e.FileLoader(t.manager);return d.setPath(t.path),d.load(s,(function(e){r(t.parse(JSON.parse(e)))}),o,i),this}getObjectByName(e){return this.names[e]}getObjectById(e){return this.library[e]||this.nodes[e]||this.materials[e]||this.passes[e]||this.names[e]}getNode(e){const s=this.getObjectById(e);return s||console.warn('Node "'+e+'" not found.'),s}resolve(e){switch(typeof e){case"boolean":case"number":return e;case"string":return/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i.test(e)||this.library[e]?this.getNode(e):e;default:if(Array.isArray(e))for(let s=0;s<e.length;s++)e[s]=this.resolve(e[s]);else for(const s in e)"uuid"!==s&&(e[s]=this.resolve(e[s]))}return e}declare(e){let r,o,i;for(r in e.nodes)o=e.nodes[r],i=new s.Nodes[o.nodeType+"Node"],o.name&&(i.name=o.name,this.names[i.name]=i),this.nodes[r]=i;for(r in e.materials)o=e.materials[r],i=new s.Nodes[o.type],o.name&&(i.name=o.name,this.names[i.name]=i),this.materials[r]=i;for(r in e.passes)o=e.passes[r],i=new s.Nodes[o.type],o.name&&(i.name=o.name,this.names[i.name]=i),this.passes[r]=i;return e.material&&(this.material=this.materials[e.material]),e.pass&&(this.pass=this.passes[e.pass]),e}parse(e){let s;for(s in(e=this.resolve(this.declare(e))).nodes)this.nodes[s].copy(e.nodes[s]);for(s in e.materials)this.materials[s].copy(e.materials[s]);for(s in e.passes)this.passes[s].copy(e.passes[s]);return this.material||this.pass||this}}exports.NodeMaterialLoader=r,exports.NodeMaterialLoaderUtils=class{static replaceUUIDObject(e,s,r,o){if(o=void 0===o||o,"object"==typeof s&&(s=s.uuid),"object"==typeof e){const i=Object.keys(e);for(let t=0;t<i.length;t++){const d=i[t];o&&(e[d]=this.replaceUUIDObject(e[d],s,r)),d===s&&(e[s]=e[d],delete e[d])}}return e===s?r:e}static replaceUUID(e,s,r){return this.replaceUUIDObject(e,s,r,!1),this.replaceUUIDObject(e.nodes,s,r),this.replaceUUIDObject(e.materials,s,r),this.replaceUUIDObject(e.passes,s,r),this.replaceUUIDObject(e.library,s,r,!1),e}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),s=require("../Nodes-8d3adda1.js");require("../nodes/core/ArrayUniformNode.cjs.js"),require("../nodes/core/UniformNode.cjs.js"),require("../nodes/core/InputNode.cjs.js"),require("../nodes/core/Node.cjs.js"),require("../nodes/core/constants.cjs.js"),require("../nodes/core/NodeUtils.cjs.js"),require("../nodes/core/AttributeNode.cjs.js"),require("../nodes/core/VaryNode.cjs.js"),require("../nodes/core/BypassNode.cjs.js"),require("../nodes/core/CodeNode.cjs.js"),require("../nodes/core/ConstNode.cjs.js"),require("../nodes/core/ContextNode.cjs.js"),require("../nodes/core/ExpressionNode.cjs.js"),require("../nodes/core/TempNode.cjs.js"),require("../nodes/core/FunctionCallNode.cjs.js"),require("../nodes/core/FunctionNode.cjs.js"),require("../nodes/core/NodeAttribute.cjs.js"),require("../nodes/core/NodeBuilder.cjs.js"),require("../nodes/core/NodeUniform.cjs.js"),require("../nodes/core/NodeVary.cjs.js"),require("../nodes/core/NodeVar.cjs.js"),require("../nodes/core/NodeCode.cjs.js"),require("../nodes/core/NodeKeywords.cjs.js"),require("../nodes/core/NodeFrame.cjs.js"),require("../nodes/core/NodeFunctionInput.cjs.js"),require("../nodes/core/PropertyNode.cjs.js"),require("../nodes/core/VarNode.cjs.js"),require("../nodes/accessors/BufferNode.cjs.js"),require("../nodes/accessors/CameraNode.cjs.js"),require("@babel/runtime/helpers/defineProperty"),require("../nodes/accessors/Object3DNode.cjs.js"),require("../nodes/accessors/CubeTextureNode.cjs.js"),require("../nodes/accessors/TextureNode.cjs.js"),require("../nodes/accessors/UVNode.cjs.js"),require("../nodes/accessors/ReflectNode.cjs.js"),require("../nodes/ShaderNode.cjs.js"),require("../nodes/accessors/PositionNode.cjs.js"),require("../nodes/accessors/ModelNode.cjs.js"),require("../nodes/math/MathNode.cjs.js"),require("../nodes/utils/JoinNode.cjs.js"),require("../nodes/utils/SplitNode.cjs.js"),require("../nodes/math/OperatorNode.cjs.js"),require("../nodes/accessors/NormalNode.cjs.js"),require("../nodes/math/CondNode.cjs.js"),require("../nodes/utils/ArrayElementNode.cjs.js"),require("../nodes/utils/ConvertNode.cjs.js"),require("../nodes/accessors/MaterialNode.cjs.js"),require("../nodes/accessors/MaterialReferenceNode.cjs.js"),require("../nodes/accessors/ReferenceNode.cjs.js"),require("../nodes/accessors/ModelViewProjectionNode.cjs.js"),require("../nodes/accessors/PointUVNode.cjs.js"),require("../nodes/accessors/SkinningNode.cjs.js"),require("../nodes/display/ColorSpaceNode.cjs.js"),require("../nodes/display/NormalMapNode.cjs.js"),require("../nodes/lights/LightContextNode.cjs.js"),require("../nodes/functions/BSDFs.cjs.js"),require("../nodes/lights/LightNode.cjs.js"),require("../nodes/lights/LightsNode.cjs.js"),require("../nodes/utils/SpriteSheetUVNode.cjs.js"),require("../nodes/utils/MatcapUVNode.cjs.js"),require("../nodes/utils/OscNode.cjs.js"),require("../nodes/utils/TimerNode.cjs.js"),require("../nodes/loaders/NodeMaterialLoader.cjs.js"),require("../nodes/procedural/CheckerNode.cjs.js"),require("../nodes/fog/FogNode.cjs.js"),require("../nodes/fog/FogRangeNode.cjs.js"),require("../nodes/materials/LineBasicNodeMaterial.cjs.js"),require("../nodes/materials/NodeMaterial.cjs.js"),require("../nodes/materials/MeshBasicNodeMaterial.cjs.js"),require("../nodes/materials/MeshStandardNodeMaterial.cjs.js"),require("../nodes/materials/PointsNodeMaterial.cjs.js");class r extends e.Loader{constructor(e,s={}){super(e),this.nodes={},this.materials={},this.passes={},this.names={},this.library=s}load(s,r,o,i){const t=this,d=new e.FileLoader(t.manager);return d.setPath(t.path),d.load(s,(function(e){r(t.parse(JSON.parse(e)))}),o,i),this}getObjectByName(e){return this.names[e]}getObjectById(e){return this.library[e]||this.nodes[e]||this.materials[e]||this.passes[e]||this.names[e]}getNode(e){const s=this.getObjectById(e);return s||console.warn('Node "'+e+'" not found.'),s}resolve(e){switch(typeof e){case"boolean":case"number":return e;case"string":return/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i.test(e)||this.library[e]?this.getNode(e):e;default:if(Array.isArray(e))for(let s=0;s<e.length;s++)e[s]=this.resolve(e[s]);else for(const s in e)"uuid"!==s&&(e[s]=this.resolve(e[s]))}return e}declare(e){let r,o,i;for(r in e.nodes)o=e.nodes[r],i=new s.Nodes[o.nodeType+"Node"],o.name&&(i.name=o.name,this.names[i.name]=i),this.nodes[r]=i;for(r in e.materials)o=e.materials[r],i=new s.Nodes[o.type],o.name&&(i.name=o.name,this.names[i.name]=i),this.materials[r]=i;for(r in e.passes)o=e.passes[r],i=new s.Nodes[o.type],o.name&&(i.name=o.name,this.names[i.name]=i),this.passes[r]=i;return e.material&&(this.material=this.materials[e.material]),e.pass&&(this.pass=this.passes[e.pass]),e}parse(e){let s;for(s in(e=this.resolve(this.declare(e))).nodes)this.nodes[s].copy(e.nodes[s]);for(s in e.materials)this.materials[s].copy(e.materials[s]);for(s in e.passes)this.passes[s].copy(e.passes[s]);return this.material||this.pass||this}}exports.NodeMaterialLoader=r,exports.NodeMaterialLoaderUtils=class{static replaceUUIDObject(e,s,r,o){if(o=void 0===o||o,"object"==typeof s&&(s=s.uuid),"object"==typeof e){const i=Object.keys(e);for(let t=0;t<i.length;t++){const d=i[t];o&&(e[d]=this.replaceUUIDObject(e[d],s,r)),d===s&&(e[s]=e[d],delete e[d])}}return e===s?r:e}static replaceUUID(e,s,r){return this.replaceUUIDObject(e,s,r,!1),this.replaceUUIDObject(e.nodes,s,r),this.replaceUUIDObject(e.materials,s,r),this.replaceUUIDObject(e.passes,s,r),this.replaceUUIDObject(e.library,s,r,!1),e}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class t extends e.DataTextureLoader{constructor(t){super(t),this.type=e.HalfFloatType}parse(t){const r=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},a=function(e,t,r){t=t||1024;let a=e.pos,n=-1,o=0,s="",i=String.fromCharCode.apply(null,new Uint16Array(e.subarray(a,a+128)));for(;0>(n=i.indexOf("\n"))&&o<t&&a<e.byteLength;)s+=i,o+=i.length,a+=128,i+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(a,a+128)));return-1<n&&(!1!==r&&(e.pos+=o+n+1),s+i.slice(0,n))},n=function(e,t,r,a){const n=e[t+3],o=Math.pow(2,n-128)/255;r[a+0]=e[t+0]*o,r[a+1]=e[t+1]*o,r[a+2]=e[t+2]*o,r[a+3]=1},o=function(t,r,a,n){const o=t[r+3],s=Math.pow(2,o-128)/255;a[n+0]=e.DataUtils.toHalfFloat(Math.min(t[r+0]*s,65504)),a[n+1]=e.DataUtils.toHalfFloat(Math.min(t[r+1]*s,65504)),a[n+2]=e.DataUtils.toHalfFloat(Math.min(t[r+2]*s,65504)),a[n+3]=e.DataUtils.toHalfFloat(1)},s=new Uint8Array(t);s.pos=0;const i=function(e){const t=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,n=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,i={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=e.byteLength||!(l=a(e)))return r(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return r(3,"bad initial token");for(i.valid|=1,i.programtype=c[1],i.string+=l+"\n";l=a(e),!1!==l;)if(i.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(t))&&(i.gamma=parseFloat(c[1])),(c=l.match(n))&&(i.exposure=parseFloat(c[1])),(c=l.match(o))&&(i.valid|=2,i.format=c[1]),(c=l.match(s))&&(i.valid|=4,i.height=parseInt(c[1],10),i.width=parseInt(c[2],10)),2&i.valid&&4&i.valid)break}else i.comments+=l+"\n";return 2&i.valid?4&i.valid?i:r(3,"missing image size specifier"):r(3,"missing format specifier")}(s);if(-1!==i){const t=i.width,a=i.height,l=function(e,t,a){const n=t;if(n<8||n>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(n!==(e[2]<<8|e[3]))return r(3,"wrong scanline width");const o=new Uint8Array(4*t*a);if(!o.length)return r(4,"unable to allocate buffer space");let s=0,i=0;const l=4*n,c=new Uint8Array(4),f=new Uint8Array(l);let p=a;for(;p>0&&i<e.byteLength;){if(i+4>e.byteLength)return r(1);if(c[0]=e[i++],c[1]=e[i++],c[2]=e[i++],c[3]=e[i++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=n)return r(3,"bad rgbe scanline format");let t,a=0;for(;a<l&&i<e.byteLength;){t=e[i++];const n=t>128;if(n&&(t-=128),0===t||a+t>l)return r(3,"bad scanline data");if(n){const r=e[i++];for(let e=0;e<t;e++)f[a++]=r}else f.set(e.subarray(i,i+t),a),a+=t,i+=t}const d=n;for(let e=0;e<d;e++){let t=0;o[s]=f[e+t],t+=n,o[s+1]=f[e+t],t+=n,o[s+2]=f[e+t],t+=n,o[s+3]=f[e+t],s+=4}p--}return o}(s.subarray(s.pos),t,a);if(-1!==l){let r,s,c;switch(this.type){case e.FloatType:c=l.length/4;const t=new Float32Array(4*c);for(let e=0;e<c;e++)n(l,4*e,t,4*e);r=t,s=e.FloatType;break;case e.HalfFloatType:c=l.length/4;const a=new Uint16Array(4*c);for(let e=0;e<c;e++)o(l,4*e,a,4*e);r=a,s=e.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:t,height:a,data:r,header:i.string,gamma:i.gamma,exposure:i.exposure,type:s}}}return null}setDataType(e){return this.type=e,this}load(t,r,a,n){return super.load(t,(function(t,a){switch(t.type){case e.FloatType:case e.HalfFloatType:t.encoding=e.LinearEncoding,t.minFilter=e.LinearFilter,t.magFilter=e.LinearFilter,t.generateMipmaps=!1,t.flipY=!0}r&&r(t,a)}),a,n)}}exports.RGBELoader=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class t extends e.DataTextureLoader{constructor(t){super(t),this.type=e.HalfFloatType}parse(t){const r=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},a=function(e,t,r){t=t||1024;let a=e.pos,n=-1,o=0,s="",i=String.fromCharCode.apply(null,new Uint16Array(e.subarray(a,a+128)));for(;0>(n=i.indexOf("\n"))&&o<t&&a<e.byteLength;)s+=i,o+=i.length,a+=128,i+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(a,a+128)));return-1<n&&(!1!==r&&(e.pos+=o+n+1),s+i.slice(0,n))},n=function(e,t,r,a){const n=e[t+3],o=Math.pow(2,n-128)/255;r[a+0]=e[t+0]*o,r[a+1]=e[t+1]*o,r[a+2]=e[t+2]*o,r[a+3]=1},o=function(t,r,a,n){const o=t[r+3],s=Math.pow(2,o-128)/255;a[n+0]=e.DataUtils.toHalfFloat(Math.min(t[r+0]*s,65504)),a[n+1]=e.DataUtils.toHalfFloat(Math.min(t[r+1]*s,65504)),a[n+2]=e.DataUtils.toHalfFloat(Math.min(t[r+2]*s,65504)),a[n+3]=e.DataUtils.toHalfFloat(1)},s=new Uint8Array(t);s.pos=0;const i=function(e){const t=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,n=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,i={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=e.byteLength||!(l=a(e)))return r(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return r(3,"bad initial token");for(i.valid|=1,i.programtype=c[1],i.string+=l+"\n";l=a(e),!1!==l;)if(i.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(t))&&(i.gamma=parseFloat(c[1])),(c=l.match(n))&&(i.exposure=parseFloat(c[1])),(c=l.match(o))&&(i.valid|=2,i.format=c[1]),(c=l.match(s))&&(i.valid|=4,i.height=parseInt(c[1],10),i.width=parseInt(c[2],10)),2&i.valid&&4&i.valid)break}else i.comments+=l+"\n";return 2&i.valid?4&i.valid?i:r(3,"missing image size specifier"):r(3,"missing format specifier")}(s);if(-1!==i){const t=i.width,a=i.height,l=function(e,t,a){const n=t;if(n<8||n>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(n!==(e[2]<<8|e[3]))return r(3,"wrong scanline width");const o=new Uint8Array(4*t*a);if(!o.length)return r(4,"unable to allocate buffer space");let s=0,i=0;const l=4*n,c=new Uint8Array(4),p=new Uint8Array(l);let f=a;for(;f>0&&i<e.byteLength;){if(i+4>e.byteLength)return r(1);if(c[0]=e[i++],c[1]=e[i++],c[2]=e[i++],c[3]=e[i++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=n)return r(3,"bad rgbe scanline format");let t,a=0;for(;a<l&&i<e.byteLength;){t=e[i++];const n=t>128;if(n&&(t-=128),0===t||a+t>l)return r(3,"bad scanline data");if(n){const r=e[i++];for(let e=0;e<t;e++)p[a++]=r}else p.set(e.subarray(i,i+t),a),a+=t,i+=t}const u=n;for(let e=0;e<u;e++){let t=0;o[s]=p[e+t],t+=n,o[s+1]=p[e+t],t+=n,o[s+2]=p[e+t],t+=n,o[s+3]=p[e+t],s+=4}f--}return o}(s.subarray(s.pos),t,a);if(-1!==l){let r,s,c;switch(this.type){case e.FloatType:c=l.length/4;const t=new Float32Array(4*c);for(let e=0;e<c;e++)n(l,4*e,t,4*e);r=t,s=e.FloatType;break;case e.HalfFloatType:c=l.length/4;const a=new Uint16Array(4*c);for(let e=0;e<c;e++)o(l,4*e,a,4*e);r=a,s=e.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:t,height:a,data:r,header:i.string,gamma:i.gamma,exposure:i.exposure,type:s}}}return null}setDataType(e){return this.type=e,this}load(t,r,a,n){return super.load(t,(function(t,a){switch(t.type){case e.FloatType:case e.HalfFloatType:"colorSpace"in t?t.colorSpace="srgb-linear":t.encoding=3e3,t.minFilter=e.LinearFilter,t.magFilter=e.LinearFilter,t.generateMipmaps=!1,t.flipY=!0}r&&r(t,a)}),a,n)}}exports.RGBELoader=t;
@@ -1,4 +1,4 @@
1
- import { DataTextureLoader, HalfFloatType, FloatType, DataUtils, LinearEncoding, LinearFilter } from 'three';
1
+ import { DataTextureLoader, HalfFloatType, FloatType, DataUtils, LinearFilter } from 'three';
2
2
 
3
3
  // http://en.wikipedia.org/wiki/RGBE_image_format
4
4
 
@@ -362,7 +362,8 @@ class RGBELoader extends DataTextureLoader {
362
362
  switch (texture.type) {
363
363
  case FloatType:
364
364
  case HalfFloatType:
365
- texture.encoding = LinearEncoding;
365
+ if ('colorSpace' in texture) texture.colorSpace = 'srgb-linear';else texture.encoding = 3000; // LinearEncoding
366
+
366
367
  texture.minFilter = LinearFilter;
367
368
  texture.magFilter = LinearFilter;
368
369
  texture.generateMipmaps = false;