three-stdlib 2.6.1 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/{Nodes-acab3ca5.js → Nodes-427f68b0.js} +0 -0
  2. package/{Nodes-244507d0.js → Nodes-ec4e1143.js} +0 -0
  3. package/controls/ArcballControls.cjs.js +1 -1
  4. package/controls/ArcballControls.d.ts +164 -0
  5. package/controls/ArcballControls.js +512 -197
  6. package/controls/OrbitControls.cjs.js +1 -1
  7. package/controls/OrbitControls.d.ts +1 -0
  8. package/controls/OrbitControls.js +13 -2
  9. package/geometries/TextGeometry.cjs.js +1 -0
  10. package/geometries/TextGeometry.d.ts +16 -0
  11. package/geometries/TextGeometry.js +26 -0
  12. package/index.cjs.js +1 -1
  13. package/index.d.ts +2 -0
  14. package/index.js +3 -1
  15. package/loaders/AMFLoader.js +1 -3
  16. package/loaders/ColladaLoader.cjs.js +1 -1
  17. package/loaders/ColladaLoader.js +58 -35
  18. package/loaders/EXRLoader.cjs.js +1 -1
  19. package/loaders/EXRLoader.js +197 -262
  20. package/loaders/FBXLoader.cjs.js +1 -1
  21. package/loaders/FBXLoader.js +41 -90
  22. package/loaders/FontLoader.cjs.js +1 -0
  23. package/loaders/FontLoader.d.ts +32 -0
  24. package/loaders/FontLoader.js +139 -0
  25. package/loaders/GLTFLoader.cjs.js +1 -1
  26. package/loaders/GLTFLoader.js +160 -72
  27. package/loaders/HDRCubeTextureLoader.cjs.js +1 -1
  28. package/loaders/HDRCubeTextureLoader.js +2 -10
  29. package/loaders/NodeMaterialLoader.cjs.js +1 -1
  30. package/loaders/RGBELoader.cjs.js +1 -1
  31. package/loaders/RGBELoader.js +11 -25
  32. package/loaders/RGBMLoader.cjs.js +1 -1
  33. package/loaders/RGBMLoader.js +225 -263
  34. package/loaders/SVGLoader.cjs.js +1 -1
  35. package/loaders/SVGLoader.js +46 -30
  36. package/loaders/VRMLLoader.cjs.js +1 -1
  37. package/loaders/VRMLLoader.js +2 -1
  38. package/misc/WebGL.cjs.js +1 -1
  39. package/misc/WebGL.d.ts +5 -7
  40. package/misc/WebGL.js +67 -54
  41. package/nodes/core/NodeBuilder.cjs.js +1 -1
  42. package/nodes/core/NodeBuilder.js +2 -2
  43. package/nodes/inputs/CubeTextureNode.cjs.js +1 -1
  44. package/nodes/inputs/RTTNode.cjs.js +1 -1
  45. package/nodes/inputs/ReflectorNode.cjs.js +1 -1
  46. package/nodes/inputs/ScreenNode.cjs.js +1 -1
  47. package/nodes/inputs/TextureNode.cjs.js +1 -1
  48. package/nodes/materials/BasicNodeMaterial.cjs.js +1 -1
  49. package/nodes/materials/NodeMaterial.cjs.js +1 -1
  50. package/nodes/materials/SpriteNodeMaterial.cjs.js +1 -1
  51. package/nodes/postprocessing/NodePass.cjs.js +1 -1
  52. package/nodes/postprocessing/NodePostProcessing.cjs.js +1 -1
  53. package/nodes/utils/ColorSpaceNode.cjs.js +1 -1
  54. package/nodes/utils/ColorSpaceNode.js +2 -45
  55. package/package.json +1 -1
  56. package/shaders/GammaCorrectionShader.js +1 -2
package/index.d.ts CHANGED
@@ -246,6 +246,7 @@ export * from './geometries/RoundedBoxGeometry';
246
246
  export * from './geometries/BoxLineGeometry';
247
247
  export * from './geometries/DecalGeometry';
248
248
  export * from './geometries/TeapotGeometry';
249
+ export * from './geometries/TextGeometry';
249
250
  export * from './csm/CSM';
250
251
  export * from './csm/Shader';
251
252
  export * from './csm/CSMHelper';
@@ -312,6 +313,7 @@ export * from './effects/AnaglyphEffect';
312
313
  export * from './effects/AsciiEffect';
313
314
  export * from './effects/StereoEffect';
314
315
  export * from './loaders/FBXLoader';
316
+ export * from './loaders/FontLoader';
315
317
  export * from './loaders/TGALoader';
316
318
  export * from './loaders/LUTCubeLoader';
317
319
  export * from './loaders/NRRDLoader';
package/index.js CHANGED
@@ -5,7 +5,7 @@ export { GPUComputationRenderer } from './misc/GPUComputationRenderer.js';
5
5
  export { Gyroscope } from './misc/Gyroscope.js';
6
6
  export { MorphAnimMesh } from './misc/MorphAnimMesh.js';
7
7
  export { RollerCoasterGeometry, RollerCoasterLiftersGeometry, RollerCoasterShadowGeometry, SkyGeometry, TreesGeometry } from './misc/RollerCoaster.js';
8
- export { WEBGL } from './misc/WebGL.js';
8
+ export { getErrorMessage, getWebGL2ErrorMessage, getWebGLErrorMessage, isWebGL2Available, isWebGLAvailable } from './misc/WebGL.js';
9
9
  export { MD2Character } from './misc/MD2Character.js';
10
10
  export { VolumeSlice } from './misc/VolumeSlice.js';
11
11
  export { TubePainter } from './misc/TubePainter.js';
@@ -191,6 +191,7 @@ export { RoundedBoxGeometry } from './geometries/RoundedBoxGeometry.js';
191
191
  export { BoxLineGeometry } from './geometries/BoxLineGeometry.js';
192
192
  export { DecalGeometry, DecalVertex } from './geometries/DecalGeometry.js';
193
193
  export { TeapotGeometry } from './geometries/TeapotGeometry.js';
194
+ export { TextGeometry as TextBufferGeometry, TextGeometry } from './geometries/TextGeometry.js';
194
195
  export { CSM } from './csm/CSM.js';
195
196
  export { CSMHelper } from './csm/CSMHelper.js';
196
197
  export { SMAABlendShader, SMAAEdgesShader, SMAAWeightsShader } from './shaders/SMAAShader.js';
@@ -255,6 +256,7 @@ export { AnaglyphEffect } from './effects/AnaglyphEffect.js';
255
256
  export { AsciiEffect } from './effects/AsciiEffect.js';
256
257
  export { StereoEffect } from './effects/StereoEffect.js';
257
258
  export { FBXLoader } from './loaders/FBXLoader.js';
259
+ export { Font, FontLoader } from './loaders/FontLoader.js';
258
260
  export { TGALoader } from './loaders/TGALoader.js';
259
261
  export { LUTCubeLoader } from './loaders/LUTCubeLoader.js';
260
262
  export { NRRDLoader } from './loaders/NRRDLoader.js';
@@ -5,8 +5,6 @@ import { unzipSync } from 'fflate';
5
5
  * Description: Early release of an AMF Loader following the pattern of the
6
6
  * example loaders in the three.js project.
7
7
  *
8
- * More information about the AMF format: http://amf.wikispaces.com
9
- *
10
8
  * Usage:
11
9
  * const loader = new AMFLoader();
12
10
  * loader.load('/path/to/project.amf', function(objecttree) {
@@ -57,7 +55,7 @@ class AMFLoader extends Loader {
57
55
  console.log('THREE.AMFLoader: Loading Zip');
58
56
 
59
57
  try {
60
- zip = unzipSync(new Uint8Array(data)); // eslint-disable-line no-undef
58
+ zip = unzipSync(new Uint8Array(data));
61
59
  } catch (e) {
62
60
  if (e instanceof ReferenceError) {
63
61
  console.log('THREE.AMFLoader: fflate missing and file is compressed.');
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("./TGALoader.cjs.js");class n extends e.Loader{constructor(e){super(e)}load(t,n,s,o){const i=this,r=""===i.path?e.LoaderUtils.extractUrlBase(t):i.path,a=new e.FileLoader(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,(function(e){try{n(i.parse(e,r))}catch(e){o?o(e):console.error(e),i.manager.itemError(t)}}),s,o)}parse(n,s){function o(e,t){const n=[],s=e.childNodes;for(let e=0,o=s.length;e<o;e++){const o=s[e];o.nodeName===t&&n.push(o)}return n}function i(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,s=t.length;e<s;e++)n[e]=t[e];return n}function r(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,s=t.length;e<s;e++)n[e]=parseFloat(t[e]);return n}function a(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,s=t.length;e<s;e++)n[e]=parseInt(t[e]);return n}function c(e){return e.substring(1)}function l(e){return 0===Object.keys(e).length}function d(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}function u(e){return void 0!==e?e.textContent:"Y_UP"}function f(e,t,n,s){const i=o(e,t)[0];if(void 0!==i){const e=o(i,n);for(let t=0;t<e.length;t++)s(e[t])}}function h(e,t){for(const n in e){e[n].build=t(e[n])}}function m(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function p(e){const t={inputs:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=c(s.getAttribute("source")),n=s.getAttribute("semantic");t.inputs[n]=e}}return t}function g(e){const t={};let n=e.getAttribute("target").split("/");const s=n.shift();let o=n.shift();const i=-1!==o.indexOf("("),r=-1!==o.indexOf(".");if(r)n=o.split("."),o=n.shift(),t.member=n.shift();else if(i){const e=o.split("(");o=e.shift();for(let t=0;t<e.length;t++)e[t]=parseInt(e[t].replace(/\)/,""));t.indices=e}return t.id=s,t.sid=o,t.arraySyntax=i,t.memberSyntax=r,t.sampler=c(e.getAttribute("source")),t}function b(e){const t=[],n=e.channels,s=e.samplers,o=e.sources;for(const e in n)if(n.hasOwnProperty(e)){const i=n[e],r=s[i.sampler],a=r.inputs.INPUT,c=r.inputs.OUTPUT;A(N(i,o[a],o[c]),t)}return t}function y(e){return m(Ze.animations[e],b)}function N(e,t,n){const s=Ze.nodes[e.id],o=Ue(s.id),i=s.transforms[e.sid],r=s.matrix.clone().transpose();let a,c,l,d,u,f;const h={};switch(i){case"matrix":for(l=0,d=t.array.length;l<d;l++)if(a=t.array[l],c=l*n.stride,void 0===h[a]&&(h[a]={}),!0===e.arraySyntax){const t=n.array[c],s=e.indices[0]+4*e.indices[1];h[a][s]=t}else for(u=0,f=n.stride;u<f;u++)h[a][u]=n.array[c+u];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',i)}const m=function(e,t){const n=[];for(const t in e)n.push({time:parseFloat(t),value:e[t]});n.sort(s);for(let e=0;e<16;e++)v(n,e,t.elements[e]);return n;function s(e,t){return e.time-t.time}}(h,r);return{name:o.uuid,keyframes:m}}const w=new e.Vector3,x=new e.Vector3,k=new e.Quaternion;function A(t,n){const s=t.keyframes,o=t.name,i=[],r=[],a=[],c=[];for(let e=0,t=s.length;e<t;e++){const t=s[e],n=t.time,o=t.value;Ce.fromArray(o).transpose(),Ce.decompose(w,k,x),i.push(n),r.push(w.x,w.y,w.z),a.push(k.x,k.y,k.z,k.w),c.push(x.x,x.y,x.z)}return r.length>0&&n.push(new e.VectorKeyframeTrack(o+".position",i,r)),a.length>0&&n.push(new e.QuaternionKeyframeTrack(o+".quaternion",i,a)),c.length>0&&n.push(new e.VectorKeyframeTrack(o+".scale",i,c)),n}function v(e,t,n){let s,o,i,r=!0;for(o=0,i=e.length;o<i;o++)s=e[o],void 0===s.value[t]?s.value[t]=null:r=!1;if(!0===r)for(o=0,i=e.length;o<i;o++)s=e[o],s.value[t]=n;else!function(e,t){let n,s;for(let o=0,i=e.length;o<i;o++){const i=e[o];if(null===i.value[t]){if(n=T(e,o,t),s=C(e,o,t),null===n){i.value[t]=s.value[t];continue}if(null===s){i.value[t]=n.value[t];continue}_(i,n,s,t)}}}(e,t)}function T(e,t,n){for(;t>=0;){const s=e[t];if(null!==s.value[n])return s;t--}return null}function C(e,t,n){for(;t<e.length;){const s=e[t];if(null!==s.value[n])return s;t++}return null}function _(e,t,n,s){n.time-t.time!=0?e.value[s]=(e.time-t.time)*(n.value[s]-t.value[s])/(n.time-t.time)+t.value[s]:e.value[s]=t.value[s]}function E(t){const n=[],s=t.name,o=t.end-t.start||-1,i=t.animations;for(let e=0,t=i.length;e<t;e++){const t=y(i[e]);for(let e=0,s=t.length;e<s;e++)n.push(t[e])}return new e.AnimationClip(s,o,n)}function M(e){return m(Ze.clips[e],E)}function L(e){const t={sources:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=r(s.textContent);break;case"source":const e=s.getAttribute("id");t.sources[e]=re(s);break;case"joints":t.joints=R(s);break;case"vertex_weights":t.vertexWeights=O(s)}}return t}function R(e){const t={inputs:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=s.getAttribute("semantic"),n=c(s.getAttribute("source"));t.inputs[e]=n}}return t}function O(e){const t={inputs:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=s.getAttribute("semantic"),n=c(s.getAttribute("source")),o=parseInt(s.getAttribute("offset"));t.inputs[e]={id:n,offset:o};break;case"vcount":t.vcount=a(s.textContent);break;case"v":t.v=a(s.textContent)}}return t}function j(t){const n={id:t.id},s=Ze.geometries[n.id];return void 0!==t.skin&&(n.skin=function(t){const n=4,s={joints:[],indices:{array:[],stride:n},weights:{array:[],stride:n}},o=t.sources,i=t.vertexWeights,r=i.vcount,a=i.v,c=i.inputs.JOINT.offset,l=i.inputs.WEIGHT.offset,d=t.sources[t.joints.inputs.JOINT],u=t.sources[t.joints.inputs.INV_BIND_MATRIX],f=o[i.inputs.WEIGHT.id].array;let h,m,p,g=0;for(h=0,p=r.length;h<p;h++){const e=r[h],t=[];for(m=0;m<e;m++){const e=a[g+c],n=f[a[g+l]];t.push({index:e,weight:n}),g+=2}for(t.sort(b),m=0;m<n;m++){const e=t[m];void 0!==e?(s.indices.array.push(e.index),s.weights.array.push(e.weight)):(s.indices.array.push(0),s.weights.array.push(0))}}t.bindShapeMatrix?s.bindMatrix=(new e.Matrix4).fromArray(t.bindShapeMatrix).transpose():s.bindMatrix=(new e.Matrix4).identity();for(h=0,p=d.array.length;h<p;h++){const t=d.array[h],n=(new e.Matrix4).fromArray(u.array,h*u.stride).transpose();s.joints.push({name:t,boneInverse:n})}return s;function b(e,t){return t.weight-e.weight}}(t.skin),s.sources.skinIndices=n.skin.indices,s.sources.skinWeights=n.skin.weights),n}function q(e){return void 0!==e.build?e.build:e.init_from}function I(e){const t=Ze.images[e];return void 0!==t?m(t,q):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function S(e){const t={surfaces:{},samplers:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"newparam":U(s,t);break;case"technique":t.technique=B(s);break;case"extra":t.extra=G(s)}}return t}function U(e,t){const n=e.getAttribute("sid");for(let s=0,o=e.childNodes.length;s<o;s++){const o=e.childNodes[s];if(1===o.nodeType)switch(o.nodeName){case"surface":t.surfaces[n]=F(o);break;case"sampler2D":t.samplers[n]=H(o)}}}function F(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"init_from":t.init_from=s.textContent}}return t}function H(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"source":t.source=s.textContent}}return t}function B(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=s.nodeName,t.parameters=P(s)}}return t}function P(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[s.nodeName]=V(s);break;case"transparent":t[s.nodeName]={opaque:s.getAttribute("opaque"),data:V(s)}}}return t}function V(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"color":t[s.nodeName]=r(s.textContent);break;case"float":t[s.nodeName]=parseFloat(s.textContent);break;case"texture":t[s.nodeName]={id:s.getAttribute("texture"),extra:D(s)}}}return t}function D(e){const t={technique:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"extra":W(s,t)}}return t}function W(e,t){for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique":z(s,t)}}}function z(e,t){for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[s.nodeName]=parseFloat(s.textContent);break;case"wrapU":case"wrapV":"TRUE"===s.textContent.toUpperCase()?t.technique[s.nodeName]=1:"FALSE"===s.textContent.toUpperCase()?t.technique[s.nodeName]=0:t.technique[s.nodeName]=parseInt(s.textContent)}}}function G(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique":t.technique=J(s)}}return t}function J(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"double_sided":t[s.nodeName]=parseInt(s.textContent)}}return t}function X(e){return e}function K(t){const n=(s=t.url,m(Ze.effects[s],X));var s;const o=n.profile.technique,i=n.profile.extra;let r;switch(o.type){case"phong":case"blinn":r=new e.MeshPhongMaterial;break;case"lambert":r=new e.MeshLambertMaterial;break;default:r=new e.MeshBasicMaterial}function a(t){const s=n.profile.samplers[t.id];let o=null;if(void 0!==s){o=I(n.profile.surfaces[s.source].init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),o=I(t.id);if(null!==o){const n=function(e){let t,n=e.slice(2+(e.lastIndexOf(".")-1>>>0));switch(n=n.toLowerCase(),n){case"tga":t=Ge;break;default:t=ze}return t}(o);if(void 0!==n){const s=n.load(o),i=t.extra;if(void 0!==i&&void 0!==i.technique&&!1===l(i.technique)){const t=i.technique;s.wrapS=t.wrapU?e.RepeatWrapping:e.ClampToEdgeWrapping,s.wrapT=t.wrapV?e.RepeatWrapping:e.ClampToEdgeWrapping,s.offset.set(t.offsetU||0,t.offsetV||0),s.repeat.set(t.repeatU||1,t.repeatV||1)}else s.wrapS=e.RepeatWrapping,s.wrapT=e.RepeatWrapping;return s}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",o),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}r.name=t.name||"";const c=o.parameters;for(const e in c){const t=c[e];switch(e){case"diffuse":t.color&&r.color.fromArray(t.color),t.texture&&(r.map=a(t.texture));break;case"specular":t.color&&r.specular&&r.specular.fromArray(t.color),t.texture&&(r.specularMap=a(t.texture));break;case"bump":t.texture&&(r.normalMap=a(t.texture));break;case"ambient":t.texture&&(r.lightMap=a(t.texture));break;case"shininess":t.float&&r.shininess&&(r.shininess=t.float);break;case"emission":t.color&&r.emissive&&r.emissive.fromArray(t.color),t.texture&&(r.emissiveMap=a(t.texture))}}let d=c.transparent,u=c.transparency;if(void 0===u&&d&&(u={float:1}),void 0===d&&u&&(d={opaque:"A_ONE",data:{color:[1,1,1,1]}}),d&&u)if(d.data.texture)r.transparent=!0;else{const e=d.data.color;switch(d.opaque){case"A_ONE":r.opacity=e[3]*u.float;break;case"RGB_ZERO":r.opacity=1-e[0]*u.float;break;case"A_ZERO":r.opacity=1-e[3]*u.float;break;case"RGB_ONE":r.opacity=e[0]*u.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',d.opaque)}r.opacity<1&&(r.transparent=!0)}return void 0!==i&&void 0!==i.technique&&1===i.technique.double_sided&&(r.side=e.DoubleSide),r}function Z(e){return m(Ze.materials[e],K)}function Q(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];switch(n.nodeName){case"technique_common":return Y(n)}}return{}}function Y(e){const t={};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];switch(s.nodeName){case"perspective":case"orthographic":t.technique=s.nodeName,t.parameters=$(s)}}return t}function $(e){const t={};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];switch(s.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[s.nodeName]=parseFloat(s.textContent)}}return t}function ee(t){let n;switch(t.optics.technique){case"perspective":n=new e.PerspectiveCamera(t.optics.parameters.yfov,t.optics.parameters.aspect_ratio,t.optics.parameters.znear,t.optics.parameters.zfar);break;case"orthographic":let s=t.optics.parameters.ymag,o=t.optics.parameters.xmag;const i=t.optics.parameters.aspect_ratio;o=void 0===o?s*i:o,s=void 0===s?o/i:s,o*=.5,s*=.5,n=new e.OrthographicCamera(-o,o,s,-s,t.optics.parameters.znear,t.optics.parameters.zfar);break;default:n=new e.PerspectiveCamera}return n.name=t.name||"",n}function te(e){const t=Ze.cameras[e];return void 0!==t?m(t,ee):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function ne(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=s.nodeName,t.parameters=se(s)}}return t}function se(t){const n={};for(let s=0,o=t.childNodes.length;s<o;s++){const o=t.childNodes[s];if(1===o.nodeType)switch(o.nodeName){case"color":const t=r(o.textContent);n.color=(new e.Color).fromArray(t);break;case"falloff_angle":n.falloffAngle=parseFloat(o.textContent);break;case"quadratic_attenuation":const s=parseFloat(o.textContent);n.distance=s?Math.sqrt(1/s):0}}return n}function oe(t){let n;switch(t.technique){case"directional":n=new e.DirectionalLight;break;case"point":n=new e.PointLight;break;case"spot":n=new e.SpotLight;break;case"ambient":n=new e.AmbientLight}return t.parameters.color&&n.color.copy(t.parameters.color),t.parameters.distance&&(n.distance=t.parameters.distance),n}function ie(e){const t=Ze.lights[e];return void 0!==t?m(t,oe):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function re(e){const t={array:[],stride:3};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"float_array":t.array=r(s.textContent);break;case"Name_array":t.array=i(s.textContent);break;case"technique_common":const e=o(s,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function ae(e){const t={};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];1===s.nodeType&&(t[s.getAttribute("semantic")]=c(s.getAttribute("source")))}return t}function ce(e){const t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=c(s.getAttribute("source")),n=s.getAttribute("semantic"),o=parseInt(s.getAttribute("offset")),i=parseInt(s.getAttribute("set")),r=i>0?n+i:n;t.inputs[r]={id:e,offset:o},t.stride=Math.max(t.stride,o+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=a(s.textContent);break;case"p":t.p=a(s.textContent)}}return t}function le(e){let t=0;for(let n=0,s=e.length;n<s;n++){!0===e[n].hasUV&&t++}t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function de(e){const t={},n=e.sources,s=e.vertices,o=e.primitives;if(0===o.length)return{};const i=function(e){const t={};for(let n=0;n<e.length;n++){const s=e[n];void 0===t[s.type]&&(t[s.type]=[]),t[s.type].push(s)}return t}(o);for(const e in i){const o=i[e];le(o),t[e]=ue(o,n,s)}return t}function ue(t,n,s){const o={},i={array:[],stride:0},r={array:[],stride:0},a={array:[],stride:0},c={array:[],stride:0},l={array:[],stride:0},d=[],u=4,f=[],h=4,m=new e.BufferGeometry,p=[];let g=0;for(let e=0;e<t.length;e++){const o=t[e],u=o.inputs;let h=0;switch(o.type){case"lines":case"linestrips":h=2*o.count;break;case"triangles":h=3*o.count;break;case"polylist":for(let e=0;e<o.count;e++){const t=o.vcount[e];switch(t){case 3:h+=3;break;case 4:h+=6;break;default:h+=3*(t-2)}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",o.type)}m.addGroup(g,h,e),g+=h,o.material&&p.push(o.material);for(const e in u){const h=u[e];switch(e){case"VERTEX":for(const e in s){const u=s[e];switch(e){case"POSITION":const s=i.array.length;if(fe(o,n[u],h.offset,i.array),i.stride=n[u].stride,n.skinWeights&&n.skinIndices&&(fe(o,n.skinIndices,h.offset,d),fe(o,n.skinWeights,h.offset,f)),!1===o.hasUV&&!0===t.uvsNeedsFix){const e=(i.array.length-s)/i.stride;for(let t=0;t<e;t++)a.array.push(0,0)}break;case"NORMAL":fe(o,n[u],h.offset,r.array),r.stride=n[u].stride;break;case"COLOR":fe(o,n[u],h.offset,l.array),l.stride=n[u].stride;break;case"TEXCOORD":fe(o,n[u],h.offset,a.array),a.stride=n[u].stride;break;case"TEXCOORD1":fe(o,n[u],h.offset,c.array),a.stride=n[u].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',e)}}break;case"NORMAL":fe(o,n[h.id],h.offset,r.array),r.stride=n[h.id].stride;break;case"COLOR":fe(o,n[h.id],h.offset,l.array),l.stride=n[h.id].stride;break;case"TEXCOORD":fe(o,n[h.id],h.offset,a.array),a.stride=n[h.id].stride;break;case"TEXCOORD1":fe(o,n[h.id],h.offset,c.array),c.stride=n[h.id].stride}}}return i.array.length>0&&m.setAttribute("position",new e.Float32BufferAttribute(i.array,i.stride)),r.array.length>0&&m.setAttribute("normal",new e.Float32BufferAttribute(r.array,r.stride)),l.array.length>0&&m.setAttribute("color",new e.Float32BufferAttribute(l.array,l.stride)),a.array.length>0&&m.setAttribute("uv",new e.Float32BufferAttribute(a.array,a.stride)),c.array.length>0&&m.setAttribute("uv2",new e.Float32BufferAttribute(c.array,c.stride)),d.length>0&&m.setAttribute("skinIndex",new e.Float32BufferAttribute(d,u)),f.length>0&&m.setAttribute("skinWeight",new e.Float32BufferAttribute(f,h)),o.data=m,o.type=t[0].type,o.materialKeys=p,o}function fe(e,t,n,s){const o=e.p,i=e.stride,r=e.vcount;function a(e){let t=o[e+n]*l;const i=t+l;for(;t<i;t++)s.push(c[t])}const c=t.array,l=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,n=r.length;t<n;t++){const n=r[t];if(4===n){const t=e+1*i,n=e+2*i,s=e+3*i;a(e+0*i),a(t),a(s),a(t),a(n),a(s)}else if(3===n){const t=e+1*i,n=e+2*i;a(e+0*i),a(t),a(n)}else if(n>4)for(let t=1,s=n-2;t<=s;t++){const n=e+i*t,s=e+i*(t+1);a(e+0*i),a(n),a(s)}e+=i*n}}else for(let e=0,t=o.length;e<t;e+=i)a(e)}function he(e){return m(Ze.geometries[e],de)}function me(e){return void 0!==e.build?e.build:e}function pe(e,t){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"joint":t.joints[s.getAttribute("sid")]=ge(s);break;case"link":t.links.push(ye(s))}}}function ge(e){let t;for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"prismatic":case"revolute":t=be(s)}}return t}function be(t){const n={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",axis:new e.Vector3,limits:{min:0,max:0},type:t.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let e=0;e<t.childNodes.length;e++){const s=t.childNodes[e];if(1===s.nodeType)switch(s.nodeName){case"axis":const e=r(s.textContent);n.axis.fromArray(e);break;case"limits":const t=s.getElementsByTagName("max")[0],o=s.getElementsByTagName("min")[0];n.limits.max=parseFloat(t.textContent),n.limits.min=parseFloat(o.textContent)}}return n.limits.min>=n.limits.max&&(n.static=!0),n.middlePosition=(n.limits.min+n.limits.max)/2,n}function ye(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"attachment_full":t.attachments.push(Ne(s));break;case"matrix":case"translate":case"rotate":t.transforms.push(we(s))}}return t}function Ne(e){const t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"link":t.links.push(ye(s));break;case"matrix":case"translate":case"rotate":t.transforms.push(we(s))}}return t}function we(t){const n={type:t.nodeName},s=r(t.textContent);switch(n.type){case"matrix":n.obj=new e.Matrix4,n.obj.fromArray(s).transpose();break;case"translate":n.obj=new e.Vector3,n.obj.fromArray(s);break;case"rotate":n.obj=new e.Vector3,n.obj.fromArray(s),n.angle=e.MathUtils.degToRad(s[3])}return n}function xe(e,t){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique_common":ke(s,t)}}}function ke(e,t){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"inertia":t.inertia=r(s.textContent);break;case"mass":t.mass=r(s.textContent)[0]}}}function Ae(e){const t={target:e.getAttribute("target").split("/").pop()};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"axis":const e=s.getElementsByTagName("param")[0];t.axis=e.textContent;const n=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=n.substr(0,n.length-1)}}return t}function ve(e){return void 0!==e.build?e.build:e}function Te(t){const n=[],s=Pe.querySelector('[id="'+t.id+'"]');for(let t=0;t<s.childNodes.length;t++){const o=s.childNodes[t];if(1!==o.nodeType)continue;let i,a;switch(o.nodeName){case"matrix":i=r(o.textContent);const t=(new e.Matrix4).fromArray(i).transpose();n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:t});break;case"translate":case"scale":i=r(o.textContent),a=(new e.Vector3).fromArray(i),n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:a});break;case"rotate":i=r(o.textContent),a=(new e.Vector3).fromArray(i);const s=e.MathUtils.degToRad(i[3]);n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:a,angle:s})}}return n}const Ce=new e.Matrix4,_e=new e.Vector3;function Ee(t){const n={name:t.getAttribute("name")||"",type:t.getAttribute("type"),id:t.getAttribute("id"),sid:t.getAttribute("sid"),matrix:new e.Matrix4,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let s=0;s<t.childNodes.length;s++){const o=t.childNodes[s];if(1!==o.nodeType)continue;let i;switch(o.nodeName){case"node":n.nodes.push(o.getAttribute("id")),Ee(o);break;case"instance_camera":n.instanceCameras.push(c(o.getAttribute("url")));break;case"instance_controller":n.instanceControllers.push(Me(o));break;case"instance_light":n.instanceLights.push(c(o.getAttribute("url")));break;case"instance_geometry":n.instanceGeometries.push(Me(o));break;case"instance_node":n.instanceNodes.push(c(o.getAttribute("url")));break;case"matrix":i=r(o.textContent),n.matrix.multiply(Ce.fromArray(i).transpose()),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"translate":i=r(o.textContent),_e.fromArray(i),n.matrix.multiply(Ce.makeTranslation(_e.x,_e.y,_e.z)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"rotate":i=r(o.textContent);const t=e.MathUtils.degToRad(i[3]);n.matrix.multiply(Ce.makeRotationAxis(_e.fromArray(i),t)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"scale":i=r(o.textContent),n.matrix.scale(_e.fromArray(i)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"extra":break;default:console.log(o)}}return Se(n.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",n.id):Ze.nodes[n.id]=n,n}function Me(e){const t={id:c(e.getAttribute("url")),materials:{},skeletons:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];switch(s.nodeName){case"bind_material":const e=s.getElementsByTagName("instance_material");for(let n=0;n<e.length;n++){const s=e[n],o=s.getAttribute("symbol"),i=s.getAttribute("target");t.materials[o]=c(i)}break;case"skeleton":t.skeletons.push(c(s.textContent))}}return t}function Le(t,n){const s=[],o=[];let i,r,a;for(i=0;i<t.length;i++){const e=t[i];let o;if(Se(e))o=Ue(e),Re(o,n,s);else if(c=e,void 0!==Ze.visualScenes[c]){const t=Ze.visualScenes[e].children;for(let e=0;e<t.length;e++){const o=t[e];if("JOINT"===o.type){Re(Ue(o.id),n,s)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",e)}var c;for(i=0;i<n.length;i++)for(r=0;r<s.length;r++)if(a=s[r],a.bone.name===n[i].name){o[i]=a,a.processed=!0;break}for(i=0;i<s.length;i++)a=s[i],!1===a.processed&&(o.push(a),a.processed=!0);const l=[],d=[];for(i=0;i<o.length;i++)a=o[i],l.push(a.bone),d.push(a.boneInverse);return new e.Skeleton(l,d)}function Re(t,n,s){t.traverse((function(t){if(!0===t.isBone){let o;for(let e=0;e<n.length;e++){const s=n[e];if(s.name===t.name){o=s.boneInverse;break}}void 0===o&&(o=new e.Matrix4),s.push({bone:t,boneInverse:o,processed:!1})}}))}function Oe(t){const n=[],s=t.matrix,o=t.nodes,i=t.type,r=t.instanceCameras,a=t.instanceControllers,c=t.instanceLights,l=t.instanceGeometries,d=t.instanceNodes;for(let e=0,t=o.length;e<t;e++)n.push(Ue(o[e]));for(let e=0,t=r.length;e<t;e++){const t=te(r[e]);null!==t&&n.push(t.clone())}for(let e=0,t=a.length;e<t;e++){const t=a[e],s=(u=t.id,m(Ze.controllers[u],j)),o=Ie(he(s.id),t.materials),i=Le(t.skeletons,s.skin.joints);for(let e=0,t=o.length;e<t;e++){const t=o[e];t.isSkinnedMesh&&(t.bind(i,s.skin.bindMatrix),t.normalizeSkinWeights()),n.push(t)}}var u;for(let e=0,t=c.length;e<t;e++){const t=ie(c[e]);null!==t&&n.push(t.clone())}for(let e=0,t=l.length;e<t;e++){const t=l[e],s=Ie(he(t.id),t.materials);for(let e=0,t=s.length;e<t;e++)n.push(s[e])}for(let e=0,t=d.length;e<t;e++)n.push(Ue(d[e]).clone());let f;if(0===o.length&&1===n.length)f=n[0];else{f="JOINT"===i?new e.Bone:new e.Group;for(let e=0;e<n.length;e++)f.add(n[e])}return f.name="JOINT"===i?t.sid:t.name,f.matrix.copy(s),f.matrix.decompose(f.position,f.quaternion,f.scale),f}const je=new e.MeshBasicMaterial({color:16711935});function qe(e,t){const n=[];for(let s=0,o=e.length;s<o;s++){const o=t[e[s]];void 0===o?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",e[s]),n.push(je)):n.push(Z(o))}return n}function Ie(t,n){const s=[];for(const o in t){const i=t[o],r=qe(i.materialKeys,n);0===r.length&&("lines"===o||"linestrips"===o?r.push(new e.LineBasicMaterial):r.push(new e.MeshPhongMaterial));const a=void 0!==i.data.attributes.skinIndex;if(a)for(let e=0,t=r.length;e<t;e++)r[e].skinning=!0;const c=1===r.length?r[0]:r;let l;switch(o){case"lines":l=new e.LineSegments(i.data,c);break;case"linestrips":l=new e.Line(i.data,c);break;case"triangles":case"polylist":l=a?new e.SkinnedMesh(i.data,c):new e.Mesh(i.data,c)}s.push(l)}return s}function Se(e){return void 0!==Ze.nodes[e]}function Ue(e){return m(Ze.nodes[e],Oe)}function Fe(t){const n=new e.Group;n.name=t.name;const s=t.children;for(let e=0;e<s.length;e++){const t=s[e];n.add(Ue(t.id))}return n}function He(e){return m(Ze.visualScenes[e],Fe)}if(0===n.length)return{scene:new e.Scene};const Be=(new DOMParser).parseFromString(n,"application/xml"),Pe=o(Be,"COLLADA")[0],Ve=Be.getElementsByTagName("parsererror")[0];if(void 0!==Ve){const e=o(Ve,"div")[0];let t;return t=e?e.textContent:function(e){let t="";const n=[e];for(;n.length;){const e=n.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",n.push.apply(n,e.childNodes))}return t.trim()}(Ve),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",t),null}const De=Pe.getAttribute("version");console.log("THREE.ColladaLoader: File version",De);const We=function(e){return{unit:d(o(e,"unit")[0]),upAxis:u(o(e,"up_axis")[0])}}(o(Pe,"asset")[0]),ze=new e.TextureLoader(this.manager);let Ge;ze.setPath(this.resourcePath||s).setCrossOrigin(this.crossOrigin),t.TGALoader&&(Ge=new t.TGALoader(this.manager),Ge.setPath(this.resourcePath||s));const Je=[];let Xe={},Ke=0;const Ze={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};f(Pe,"library_animations","animation",(function t(n){const s={sources:{},samplers:{},channels:{}};let o=!1;for(let e=0,i=n.childNodes.length;e<i;e++){const i=n.childNodes[e];if(1!==i.nodeType)continue;let r;switch(i.nodeName){case"source":r=i.getAttribute("id"),s.sources[r]=re(i);break;case"sampler":r=i.getAttribute("id"),s.samplers[r]=p(i);break;case"channel":r=i.getAttribute("target"),s.channels[r]=g(i);break;case"animation":t(i),o=!0;break;default:console.log(i)}}!1===o&&(Ze.animations[n.getAttribute("id")||e.MathUtils.generateUUID()]=s)})),f(Pe,"library_animation_clips","animation_clip",(function(e){const t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"instance_animation":t.animations.push(c(s.getAttribute("url")))}}Ze.clips[e.getAttribute("id")]=t})),f(Pe,"library_controllers","controller",(function(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"skin":t.id=c(s.getAttribute("source")),t.skin=L(s);break;case"morph":t.id=c(s.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}Ze.controllers[e.getAttribute("id")]=t})),f(Pe,"library_images","image",(function(e){const t={init_from:o(e,"init_from")[0].textContent};Ze.images[e.getAttribute("id")]=t})),f(Pe,"library_effects","effect",(function(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"profile_COMMON":t.profile=S(s)}}Ze.effects[e.getAttribute("id")]=t})),f(Pe,"library_materials","material",(function(e){const t={name:e.getAttribute("name")};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"instance_effect":t.url=c(s.getAttribute("url"))}}Ze.materials[e.getAttribute("id")]=t})),f(Pe,"library_cameras","camera",(function(e){const t={name:e.getAttribute("name")};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"optics":t.optics=Q(s)}}Ze.cameras[e.getAttribute("id")]=t})),f(Pe,"library_lights","light",(function(e){let t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique_common":t=ne(s)}}Ze.lights[e.getAttribute("id")]=t})),f(Pe,"library_geometries","geometry",(function(e){const t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},n=o(e,"mesh")[0];if(void 0!==n){for(let e=0;e<n.childNodes.length;e++){const s=n.childNodes[e];if(1!==s.nodeType)continue;const o=s.getAttribute("id");switch(s.nodeName){case"source":t.sources[o]=re(s);break;case"vertices":t.vertices=ae(s);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",s.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(ce(s));break;default:console.log(s)}}Ze.geometries[e.getAttribute("id")]=t}})),f(Pe,"library_nodes","node",Ee),f(Pe,"library_visual_scenes","visual_scene",(function(e){const t={name:e.getAttribute("name"),children:[]};!function(e){const t=e.getElementsByTagName("node");for(let e=0;e<t.length;e++){const n=t[e];!1===n.hasAttribute("id")&&n.setAttribute("id","three_default_"+Ke++)}}(e);const n=o(e,"node");for(let e=0;e<n.length;e++)t.children.push(Ee(n[e]));Ze.visualScenes[e.getAttribute("id")]=t})),f(Pe,"library_kinematics_models","kinematics_model",(function(e){const t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique_common":pe(s,t)}}Ze.kinematicsModels[e.getAttribute("id")]=t})),f(Pe,"library_physics_models","physics_model",(function(e){const t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"rigid_body":t.rigidBodies[s.getAttribute("name")]={},xe(s,t.rigidBodies[s.getAttribute("name")])}}Ze.physicsModels[e.getAttribute("id")]=t})),f(Pe,"scene","instance_kinematics_scene",(function(e){const t={bindJointAxis:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"bind_joint_axis":t.bindJointAxis.push(Ae(s))}}Ze.kinematicsScenes[c(e.getAttribute("url"))]=t})),h(Ze.animations,b),h(Ze.clips,E),h(Ze.controllers,j),h(Ze.images,q),h(Ze.effects,X),h(Ze.materials,K),h(Ze.cameras,ee),h(Ze.lights,oe),h(Ze.geometries,de),h(Ze.visualScenes,Fe),function(){const t=Ze.clips;if(!0===l(t)){if(!1===l(Ze.animations)){const t=[];for(const e in Ze.animations){const n=y(e);for(let e=0,s=n.length;e<s;e++)t.push(n[e])}Je.push(new e.AnimationClip("default",-1,t))}}else for(const e in t)Je.push(M(e))}(),function(){const t=Object.keys(Ze.kinematicsModels)[0],n=Object.keys(Ze.kinematicsScenes)[0],s=Object.keys(Ze.visualScenes)[0];if(void 0===t||void 0===n)return;const o=(i=t,m(Ze.kinematicsModels[i],me));var i;const r=function(e){return m(Ze.kinematicsScenes[e],ve)}(n),a=He(s),c=r.bindJointAxis,l={};for(let e=0,t=c.length;e<t;e++){const t=c[e],n=Pe.querySelector('[sid="'+t.target+'"]');if(n){const e=n.parentElement;d(t.jointIndex,e)}}function d(e,t){const n=t.getAttribute("name"),s=o.joints[e];a.traverse((function(o){o.name===n&&(l[e]={object:o,transforms:Te(t),joint:s,position:s.zeroPosition})}))}const u=new e.Matrix4;Xe={joints:o&&o.joints,getJointValue:function(e){const t=l[e];if(t)return t.position;console.warn("THREE.ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(t,n){const s=l[t];if(s){const o=s.joint;if(n>o.limits.max||n<o.limits.min)console.warn("THREE.ColladaLoader: Joint "+t+" value "+n+" outside of limits (min: "+o.limits.min+", max: "+o.limits.max+").");else if(o.static)console.warn("THREE.ColladaLoader: Joint "+t+" is static.");else{const i=s.object,r=o.axis,a=s.transforms;Ce.identity();for(let s=0;s<a.length;s++){const i=a[s];if(i.sid&&-1!==i.sid.indexOf(t))switch(o.type){case"revolute":Ce.multiply(u.makeRotationAxis(r,e.MathUtils.degToRad(n)));break;case"prismatic":Ce.multiply(u.makeTranslation(r.x*n,r.y*n,r.z*n));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+o.type)}else switch(i.type){case"matrix":Ce.multiply(i.obj);break;case"translate":Ce.multiply(u.makeTranslation(i.obj.x,i.obj.y,i.obj.z));break;case"scale":Ce.scale(i.obj);break;case"rotate":Ce.multiply(u.makeRotationAxis(i.obj,i.angle))}}i.matrix.copy(Ce),i.matrix.decompose(i.position,i.quaternion,i.scale),l[t].position=n}}else console.log("THREE.ColladaLoader: "+t+" does not exist.")}}}();const Qe=function(e){return He(c(o(e,"instance_visual_scene")[0].getAttribute("url")))}(o(Pe,"scene")[0]);return Qe.animations=Je,"Z_UP"===We.upAxis&&Qe.quaternion.setFromEuler(new e.Euler(-Math.PI/2,0,0)),Qe.scale.multiplyScalar(We.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Je},kinematics:Xe,library:Ze,scene:Qe}}}exports.ColladaLoader=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("./TGALoader.cjs.js");class n extends e.Loader{constructor(e){super(e)}load(t,n,s,o){const i=this,r=""===i.path?e.LoaderUtils.extractUrlBase(t):i.path,a=new e.FileLoader(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,(function(e){try{n(i.parse(e,r))}catch(e){o?o(e):console.error(e),i.manager.itemError(t)}}),s,o)}parse(n,s){function o(e,t){const n=[],s=e.childNodes;for(let e=0,o=s.length;e<o;e++){const o=s[e];o.nodeName===t&&n.push(o)}return n}function i(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,s=t.length;e<s;e++)n[e]=t[e];return n}function r(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,s=t.length;e<s;e++)n[e]=parseFloat(t[e]);return n}function a(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,s=t.length;e<s;e++)n[e]=parseInt(t[e]);return n}function c(e){return e.substring(1)}function l(e){return 0===Object.keys(e).length}function d(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}function u(e){return void 0!==e?e.textContent:"Y_UP"}function f(e,t,n,s){const i=o(e,t)[0];if(void 0!==i){const e=o(i,n);for(let t=0;t<e.length;t++)s(e[t])}}function h(e,t){for(const n in e){e[n].build=t(e[n])}}function m(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function p(e){const t={inputs:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=c(s.getAttribute("source")),n=s.getAttribute("semantic");t.inputs[n]=e}}return t}function g(e){const t={};let n=e.getAttribute("target").split("/");const s=n.shift();let o=n.shift();const i=-1!==o.indexOf("("),r=-1!==o.indexOf(".");if(r)n=o.split("."),o=n.shift(),t.member=n.shift();else if(i){const e=o.split("(");o=e.shift();for(let t=0;t<e.length;t++)e[t]=parseInt(e[t].replace(/\)/,""));t.indices=e}return t.id=s,t.sid=o,t.arraySyntax=i,t.memberSyntax=r,t.sampler=c(e.getAttribute("source")),t}function b(e){const t=[],n=e.channels,s=e.samplers,o=e.sources;for(const e in n)if(n.hasOwnProperty(e)){const i=n[e],r=s[i.sampler],a=r.inputs.INPUT,c=r.inputs.OUTPUT;A(N(i,o[a],o[c]),t)}return t}function y(e){return m(Qe.animations[e],b)}function N(e,t,n){const s=Qe.nodes[e.id],o=Fe(s.id),i=s.transforms[e.sid],r=s.matrix.clone().transpose();let a,c,l,d,u,f;const h={};switch(i){case"matrix":for(l=0,d=t.array.length;l<d;l++)if(a=t.array[l],c=l*n.stride,void 0===h[a]&&(h[a]={}),!0===e.arraySyntax){const t=n.array[c],s=e.indices[0]+4*e.indices[1];h[a][s]=t}else for(u=0,f=n.stride;u<f;u++)h[a][u]=n.array[c+u];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',i)}const m=function(e,t){const n=[];for(const t in e)n.push({time:parseFloat(t),value:e[t]});n.sort(s);for(let e=0;e<16;e++)v(n,e,t.elements[e]);return n;function s(e,t){return e.time-t.time}}(h,r);return{name:o.uuid,keyframes:m}}const w=new e.Vector3,x=new e.Vector3,k=new e.Quaternion;function A(t,n){const s=t.keyframes,o=t.name,i=[],r=[],a=[],c=[];for(let e=0,t=s.length;e<t;e++){const t=s[e],n=t.time,o=t.value;_e.fromArray(o).transpose(),_e.decompose(w,k,x),i.push(n),r.push(w.x,w.y,w.z),a.push(k.x,k.y,k.z,k.w),c.push(x.x,x.y,x.z)}return r.length>0&&n.push(new e.VectorKeyframeTrack(o+".position",i,r)),a.length>0&&n.push(new e.QuaternionKeyframeTrack(o+".quaternion",i,a)),c.length>0&&n.push(new e.VectorKeyframeTrack(o+".scale",i,c)),n}function v(e,t,n){let s,o,i,r=!0;for(o=0,i=e.length;o<i;o++)s=e[o],void 0===s.value[t]?s.value[t]=null:r=!1;if(!0===r)for(o=0,i=e.length;o<i;o++)s=e[o],s.value[t]=n;else!function(e,t){let n,s;for(let o=0,i=e.length;o<i;o++){const i=e[o];if(null===i.value[t]){if(n=T(e,o,t),s=C(e,o,t),null===n){i.value[t]=s.value[t];continue}if(null===s){i.value[t]=n.value[t];continue}_(i,n,s,t)}}}(e,t)}function T(e,t,n){for(;t>=0;){const s=e[t];if(null!==s.value[n])return s;t--}return null}function C(e,t,n){for(;t<e.length;){const s=e[t];if(null!==s.value[n])return s;t++}return null}function _(e,t,n,s){n.time-t.time!=0?e.value[s]=(e.time-t.time)*(n.value[s]-t.value[s])/(n.time-t.time)+t.value[s]:e.value[s]=t.value[s]}function E(t){const n=[],s=t.name,o=t.end-t.start||-1,i=t.animations;for(let e=0,t=i.length;e<t;e++){const t=y(i[e]);for(let e=0,s=t.length;e<s;e++)n.push(t[e])}return new e.AnimationClip(s,o,n)}function M(e){return m(Qe.clips[e],E)}function L(e){const t={sources:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=r(s.textContent);break;case"source":const e=s.getAttribute("id");t.sources[e]=ae(s);break;case"joints":t.joints=R(s);break;case"vertex_weights":t.vertexWeights=O(s)}}return t}function R(e){const t={inputs:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=s.getAttribute("semantic"),n=c(s.getAttribute("source"));t.inputs[e]=n}}return t}function O(e){const t={inputs:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=s.getAttribute("semantic"),n=c(s.getAttribute("source")),o=parseInt(s.getAttribute("offset"));t.inputs[e]={id:n,offset:o};break;case"vcount":t.vcount=a(s.textContent);break;case"v":t.v=a(s.textContent)}}return t}function j(t){const n={id:t.id},s=Qe.geometries[n.id];return void 0!==t.skin&&(n.skin=function(t){const n=4,s={joints:[],indices:{array:[],stride:n},weights:{array:[],stride:n}},o=t.sources,i=t.vertexWeights,r=i.vcount,a=i.v,c=i.inputs.JOINT.offset,l=i.inputs.WEIGHT.offset,d=t.sources[t.joints.inputs.JOINT],u=t.sources[t.joints.inputs.INV_BIND_MATRIX],f=o[i.inputs.WEIGHT.id].array;let h,m,p,g=0;for(h=0,p=r.length;h<p;h++){const e=r[h],t=[];for(m=0;m<e;m++){const e=a[g+c],n=f[a[g+l]];t.push({index:e,weight:n}),g+=2}for(t.sort(b),m=0;m<n;m++){const e=t[m];void 0!==e?(s.indices.array.push(e.index),s.weights.array.push(e.weight)):(s.indices.array.push(0),s.weights.array.push(0))}}t.bindShapeMatrix?s.bindMatrix=(new e.Matrix4).fromArray(t.bindShapeMatrix).transpose():s.bindMatrix=(new e.Matrix4).identity();for(h=0,p=d.array.length;h<p;h++){const t=d.array[h],n=(new e.Matrix4).fromArray(u.array,h*u.stride).transpose();s.joints.push({name:t,boneInverse:n})}return s;function b(e,t){return t.weight-e.weight}}(t.skin),s.sources.skinIndices=n.skin.indices,s.sources.skinWeights=n.skin.weights),n}function q(e){return void 0!==e.build?e.build:e.init_from}function I(e){const t=Qe.images[e];return void 0!==t?m(t,q):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function S(e){const t={surfaces:{},samplers:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"newparam":U(s,t);break;case"technique":t.technique=B(s);break;case"extra":t.extra=G(s)}}return t}function U(e,t){const n=e.getAttribute("sid");for(let s=0,o=e.childNodes.length;s<o;s++){const o=e.childNodes[s];if(1===o.nodeType)switch(o.nodeName){case"surface":t.surfaces[n]=F(o);break;case"sampler2D":t.samplers[n]=H(o)}}}function F(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"init_from":t.init_from=s.textContent}}return t}function H(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"source":t.source=s.textContent}}return t}function B(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=s.nodeName,t.parameters=V(s);break;case"extra":t.extra=G(s)}}return t}function V(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[s.nodeName]=P(s);break;case"transparent":t[s.nodeName]={opaque:s.hasAttribute("opaque")?s.getAttribute("opaque"):"A_ONE",data:P(s)}}}return t}function P(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"color":t[s.nodeName]=r(s.textContent);break;case"float":t[s.nodeName]=parseFloat(s.textContent);break;case"texture":t[s.nodeName]={id:s.getAttribute("texture"),extra:D(s)}}}return t}function D(e){const t={technique:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"extra":W(s,t)}}return t}function W(e,t){for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique":z(s,t)}}}function z(e,t){for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[s.nodeName]=parseFloat(s.textContent);break;case"wrapU":case"wrapV":"TRUE"===s.textContent.toUpperCase()?t.technique[s.nodeName]=1:"FALSE"===s.textContent.toUpperCase()?t.technique[s.nodeName]=0:t.technique[s.nodeName]=parseInt(s.textContent);break;case"bump":t[s.nodeName]=X(s)}}}function G(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique":t.technique=J(s)}}return t}function J(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"double_sided":t[s.nodeName]=parseInt(s.textContent);break;case"bump":t[s.nodeName]=X(s)}}return t}function X(e){for(var t={},n=0,s=e.childNodes.length;n<s;n++){var o=e.childNodes[n];if(1===o.nodeType)switch(o.nodeName){case"texture":t[o.nodeName]={id:o.getAttribute("texture"),texcoord:o.getAttribute("texcoord"),extra:D(o)}}}return t}function K(e){return e}function Z(t){const n=(s=t.url,m(Qe.effects[s],K));var s;const o=n.profile.technique;let i;switch(o.type){case"phong":case"blinn":i=new e.MeshPhongMaterial;break;case"lambert":i=new e.MeshLambertMaterial;break;default:i=new e.MeshBasicMaterial}function r(t){const s=n.profile.samplers[t.id];let o=null;if(void 0!==s){o=I(n.profile.surfaces[s.source].init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),o=I(t.id);if(null!==o){const n=function(e){let t,n=e.slice(2+(e.lastIndexOf(".")-1>>>0));switch(n=n.toLowerCase(),n){case"tga":t=Je;break;default:t=Ge}return t}(o);if(void 0!==n){const s=n.load(o),i=t.extra;if(void 0!==i&&void 0!==i.technique&&!1===l(i.technique)){const t=i.technique;s.wrapS=t.wrapU?e.RepeatWrapping:e.ClampToEdgeWrapping,s.wrapT=t.wrapV?e.RepeatWrapping:e.ClampToEdgeWrapping,s.offset.set(t.offsetU||0,t.offsetV||0),s.repeat.set(t.repeatU||1,t.repeatV||1)}else s.wrapS=e.RepeatWrapping,s.wrapT=e.RepeatWrapping;return s}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",o),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}i.name=t.name||"";const a=o.parameters;for(const e in a){const t=a[e];switch(e){case"diffuse":t.color&&i.color.fromArray(t.color),t.texture&&(i.map=r(t.texture));break;case"specular":t.color&&i.specular&&i.specular.fromArray(t.color),t.texture&&(i.specularMap=r(t.texture));break;case"bump":t.texture&&(i.normalMap=r(t.texture));break;case"ambient":t.texture&&(i.lightMap=r(t.texture));break;case"shininess":t.float&&i.shininess&&(i.shininess=t.float);break;case"emission":t.color&&i.emissive&&i.emissive.fromArray(t.color),t.texture&&(i.emissiveMap=r(t.texture))}}let c=a.transparent,d=a.transparency;if(void 0===d&&c&&(d={float:1}),void 0===c&&d&&(c={opaque:"A_ONE",data:{color:[1,1,1,1]}}),c&&d)if(c.data.texture)i.transparent=!0;else{const e=c.data.color;switch(c.opaque){case"A_ONE":i.opacity=e[3]*d.float;break;case"RGB_ZERO":i.opacity=1-e[0]*d.float;break;case"A_ZERO":i.opacity=1-e[3]*d.float;break;case"RGB_ONE":i.opacity=e[0]*d.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',c.opaque)}i.opacity<1&&(i.transparent=!0)}if(void 0!==o.extra&&void 0!==o.extra.technique){const t=o.extra.technique;for(const n in t){const s=t[n];switch(n){case"double_sided":i.side=1===s?e.DoubleSide:e.FrontSide;break;case"bump":i.normalMap=r(s.texture),i.normalScale=new e.Vector2(1,1)}}}return i}function Q(e){return m(Qe.materials[e],Z)}function Y(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];switch(n.nodeName){case"technique_common":return $(n)}}return{}}function $(e){const t={};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];switch(s.nodeName){case"perspective":case"orthographic":t.technique=s.nodeName,t.parameters=ee(s)}}return t}function ee(e){const t={};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];switch(s.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[s.nodeName]=parseFloat(s.textContent)}}return t}function te(t){let n;switch(t.optics.technique){case"perspective":n=new e.PerspectiveCamera(t.optics.parameters.yfov,t.optics.parameters.aspect_ratio,t.optics.parameters.znear,t.optics.parameters.zfar);break;case"orthographic":let s=t.optics.parameters.ymag,o=t.optics.parameters.xmag;const i=t.optics.parameters.aspect_ratio;o=void 0===o?s*i:o,s=void 0===s?o/i:s,o*=.5,s*=.5,n=new e.OrthographicCamera(-o,o,s,-s,t.optics.parameters.znear,t.optics.parameters.zfar);break;default:n=new e.PerspectiveCamera}return n.name=t.name||"",n}function ne(e){const t=Qe.cameras[e];return void 0!==t?m(t,te):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function se(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=s.nodeName,t.parameters=oe(s)}}return t}function oe(t){const n={};for(let s=0,o=t.childNodes.length;s<o;s++){const o=t.childNodes[s];if(1===o.nodeType)switch(o.nodeName){case"color":const t=r(o.textContent);n.color=(new e.Color).fromArray(t);break;case"falloff_angle":n.falloffAngle=parseFloat(o.textContent);break;case"quadratic_attenuation":const s=parseFloat(o.textContent);n.distance=s?Math.sqrt(1/s):0}}return n}function ie(t){let n;switch(t.technique){case"directional":n=new e.DirectionalLight;break;case"point":n=new e.PointLight;break;case"spot":n=new e.SpotLight;break;case"ambient":n=new e.AmbientLight}return t.parameters.color&&n.color.copy(t.parameters.color),t.parameters.distance&&(n.distance=t.parameters.distance),n}function re(e){const t=Qe.lights[e];return void 0!==t?m(t,ie):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function ae(e){const t={array:[],stride:3};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"float_array":t.array=r(s.textContent);break;case"Name_array":t.array=i(s.textContent);break;case"technique_common":const e=o(s,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function ce(e){const t={};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];1===s.nodeType&&(t[s.getAttribute("semantic")]=c(s.getAttribute("source")))}return t}function le(e){const t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=c(s.getAttribute("source")),n=s.getAttribute("semantic"),o=parseInt(s.getAttribute("offset")),i=parseInt(s.getAttribute("set")),r=i>0?n+i:n;t.inputs[r]={id:e,offset:o},t.stride=Math.max(t.stride,o+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=a(s.textContent);break;case"p":t.p=a(s.textContent)}}return t}function de(e){let t=0;for(let n=0,s=e.length;n<s;n++){!0===e[n].hasUV&&t++}t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function ue(e){const t={},n=e.sources,s=e.vertices,o=e.primitives;if(0===o.length)return{};const i=function(e){const t={};for(let n=0;n<e.length;n++){const s=e[n];void 0===t[s.type]&&(t[s.type]=[]),t[s.type].push(s)}return t}(o);for(const e in i){const o=i[e];de(o),t[e]=fe(o,n,s)}return t}function fe(t,n,s){const o={},i={array:[],stride:0},r={array:[],stride:0},a={array:[],stride:0},c={array:[],stride:0},l={array:[],stride:0},d=[],u=4,f=[],h=4,m=new e.BufferGeometry,p=[];let g=0;for(let e=0;e<t.length;e++){const o=t[e],u=o.inputs;let h=0;switch(o.type){case"lines":case"linestrips":h=2*o.count;break;case"triangles":h=3*o.count;break;case"polylist":for(let e=0;e<o.count;e++){const t=o.vcount[e];switch(t){case 3:h+=3;break;case 4:h+=6;break;default:h+=3*(t-2)}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",o.type)}m.addGroup(g,h,e),g+=h,o.material&&p.push(o.material);for(const e in u){const h=u[e];switch(e){case"VERTEX":for(const e in s){const u=s[e];switch(e){case"POSITION":const s=i.array.length;if(he(o,n[u],h.offset,i.array),i.stride=n[u].stride,n.skinWeights&&n.skinIndices&&(he(o,n.skinIndices,h.offset,d),he(o,n.skinWeights,h.offset,f)),!1===o.hasUV&&!0===t.uvsNeedsFix){const e=(i.array.length-s)/i.stride;for(let t=0;t<e;t++)a.array.push(0,0)}break;case"NORMAL":he(o,n[u],h.offset,r.array),r.stride=n[u].stride;break;case"COLOR":he(o,n[u],h.offset,l.array),l.stride=n[u].stride;break;case"TEXCOORD":he(o,n[u],h.offset,a.array),a.stride=n[u].stride;break;case"TEXCOORD1":he(o,n[u],h.offset,c.array),a.stride=n[u].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',e)}}break;case"NORMAL":he(o,n[h.id],h.offset,r.array),r.stride=n[h.id].stride;break;case"COLOR":he(o,n[h.id],h.offset,l.array),l.stride=n[h.id].stride;break;case"TEXCOORD":he(o,n[h.id],h.offset,a.array),a.stride=n[h.id].stride;break;case"TEXCOORD1":he(o,n[h.id],h.offset,c.array),c.stride=n[h.id].stride}}}return i.array.length>0&&m.setAttribute("position",new e.Float32BufferAttribute(i.array,i.stride)),r.array.length>0&&m.setAttribute("normal",new e.Float32BufferAttribute(r.array,r.stride)),l.array.length>0&&m.setAttribute("color",new e.Float32BufferAttribute(l.array,l.stride)),a.array.length>0&&m.setAttribute("uv",new e.Float32BufferAttribute(a.array,a.stride)),c.array.length>0&&m.setAttribute("uv2",new e.Float32BufferAttribute(c.array,c.stride)),d.length>0&&m.setAttribute("skinIndex",new e.Float32BufferAttribute(d,u)),f.length>0&&m.setAttribute("skinWeight",new e.Float32BufferAttribute(f,h)),o.data=m,o.type=t[0].type,o.materialKeys=p,o}function he(e,t,n,s){const o=e.p,i=e.stride,r=e.vcount;function a(e){let t=o[e+n]*l;const i=t+l;for(;t<i;t++)s.push(c[t])}const c=t.array,l=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,n=r.length;t<n;t++){const n=r[t];if(4===n){const t=e+1*i,n=e+2*i,s=e+3*i;a(e+0*i),a(t),a(s),a(t),a(n),a(s)}else if(3===n){const t=e+1*i,n=e+2*i;a(e+0*i),a(t),a(n)}else if(n>4)for(let t=1,s=n-2;t<=s;t++){const n=e+i*t,s=e+i*(t+1);a(e+0*i),a(n),a(s)}e+=i*n}}else for(let e=0,t=o.length;e<t;e+=i)a(e)}function me(e){return m(Qe.geometries[e],ue)}function pe(e){return void 0!==e.build?e.build:e}function ge(e,t){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"joint":t.joints[s.getAttribute("sid")]=be(s);break;case"link":t.links.push(Ne(s))}}}function be(e){let t;for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"prismatic":case"revolute":t=ye(s)}}return t}function ye(t){const n={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",axis:new e.Vector3,limits:{min:0,max:0},type:t.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let e=0;e<t.childNodes.length;e++){const s=t.childNodes[e];if(1===s.nodeType)switch(s.nodeName){case"axis":const e=r(s.textContent);n.axis.fromArray(e);break;case"limits":const t=s.getElementsByTagName("max")[0],o=s.getElementsByTagName("min")[0];n.limits.max=parseFloat(t.textContent),n.limits.min=parseFloat(o.textContent)}}return n.limits.min>=n.limits.max&&(n.static=!0),n.middlePosition=(n.limits.min+n.limits.max)/2,n}function Ne(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"attachment_full":t.attachments.push(we(s));break;case"matrix":case"translate":case"rotate":t.transforms.push(xe(s))}}return t}function we(e){const t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"link":t.links.push(Ne(s));break;case"matrix":case"translate":case"rotate":t.transforms.push(xe(s))}}return t}function xe(t){const n={type:t.nodeName},s=r(t.textContent);switch(n.type){case"matrix":n.obj=new e.Matrix4,n.obj.fromArray(s).transpose();break;case"translate":n.obj=new e.Vector3,n.obj.fromArray(s);break;case"rotate":n.obj=new e.Vector3,n.obj.fromArray(s),n.angle=e.MathUtils.degToRad(s[3])}return n}function ke(e,t){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique_common":Ae(s,t)}}}function Ae(e,t){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"inertia":t.inertia=r(s.textContent);break;case"mass":t.mass=r(s.textContent)[0]}}}function ve(e){const t={target:e.getAttribute("target").split("/").pop()};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"axis":const e=s.getElementsByTagName("param")[0];t.axis=e.textContent;const n=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=n.substr(0,n.length-1)}}return t}function Te(e){return void 0!==e.build?e.build:e}function Ce(t){const n=[],s=Pe.querySelector('[id="'+t.id+'"]');for(let t=0;t<s.childNodes.length;t++){const o=s.childNodes[t];if(1!==o.nodeType)continue;let i,a;switch(o.nodeName){case"matrix":i=r(o.textContent);const t=(new e.Matrix4).fromArray(i).transpose();n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:t});break;case"translate":case"scale":i=r(o.textContent),a=(new e.Vector3).fromArray(i),n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:a});break;case"rotate":i=r(o.textContent),a=(new e.Vector3).fromArray(i);const s=e.MathUtils.degToRad(i[3]);n.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:a,angle:s})}}return n}const _e=new e.Matrix4,Ee=new e.Vector3;function Me(t){const n={name:t.getAttribute("name")||"",type:t.getAttribute("type"),id:t.getAttribute("id"),sid:t.getAttribute("sid"),matrix:new e.Matrix4,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let s=0;s<t.childNodes.length;s++){const o=t.childNodes[s];if(1!==o.nodeType)continue;let i;switch(o.nodeName){case"node":n.nodes.push(o.getAttribute("id")),Me(o);break;case"instance_camera":n.instanceCameras.push(c(o.getAttribute("url")));break;case"instance_controller":n.instanceControllers.push(Le(o));break;case"instance_light":n.instanceLights.push(c(o.getAttribute("url")));break;case"instance_geometry":n.instanceGeometries.push(Le(o));break;case"instance_node":n.instanceNodes.push(c(o.getAttribute("url")));break;case"matrix":i=r(o.textContent),n.matrix.multiply(_e.fromArray(i).transpose()),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"translate":i=r(o.textContent),Ee.fromArray(i),n.matrix.multiply(_e.makeTranslation(Ee.x,Ee.y,Ee.z)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"rotate":i=r(o.textContent);const t=e.MathUtils.degToRad(i[3]);n.matrix.multiply(_e.makeRotationAxis(Ee.fromArray(i),t)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"scale":i=r(o.textContent),n.matrix.scale(Ee.fromArray(i)),n.transforms[o.getAttribute("sid")]=o.nodeName;break;case"extra":break;default:console.log(o)}}return Ue(n.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",n.id):Qe.nodes[n.id]=n,n}function Le(e){const t={id:c(e.getAttribute("url")),materials:{},skeletons:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];switch(s.nodeName){case"bind_material":const e=s.getElementsByTagName("instance_material");for(let n=0;n<e.length;n++){const s=e[n],o=s.getAttribute("symbol"),i=s.getAttribute("target");t.materials[o]=c(i)}break;case"skeleton":t.skeletons.push(c(s.textContent))}}return t}function Re(t,n){const s=[],o=[];let i,r,a;for(i=0;i<t.length;i++){const e=t[i];let o;if(Ue(e))o=Fe(e),Oe(o,n,s);else if(c=e,void 0!==Qe.visualScenes[c]){const t=Qe.visualScenes[e].children;for(let e=0;e<t.length;e++){const o=t[e];if("JOINT"===o.type){Oe(Fe(o.id),n,s)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",e)}var c;for(i=0;i<n.length;i++)for(r=0;r<s.length;r++)if(a=s[r],a.bone.name===n[i].name){o[i]=a,a.processed=!0;break}for(i=0;i<s.length;i++)a=s[i],!1===a.processed&&(o.push(a),a.processed=!0);const l=[],d=[];for(i=0;i<o.length;i++)a=o[i],l.push(a.bone),d.push(a.boneInverse);return new e.Skeleton(l,d)}function Oe(t,n,s){t.traverse((function(t){if(!0===t.isBone){let o;for(let e=0;e<n.length;e++){const s=n[e];if(s.name===t.name){o=s.boneInverse;break}}void 0===o&&(o=new e.Matrix4),s.push({bone:t,boneInverse:o,processed:!1})}}))}function je(t){const n=[],s=t.matrix,o=t.nodes,i=t.type,r=t.instanceCameras,a=t.instanceControllers,c=t.instanceLights,l=t.instanceGeometries,d=t.instanceNodes;for(let e=0,t=o.length;e<t;e++)n.push(Fe(o[e]));for(let e=0,t=r.length;e<t;e++){const t=ne(r[e]);null!==t&&n.push(t.clone())}for(let e=0,t=a.length;e<t;e++){const t=a[e],s=(u=t.id,m(Qe.controllers[u],j)),o=Se(me(s.id),t.materials),i=Re(t.skeletons,s.skin.joints);for(let e=0,t=o.length;e<t;e++){const t=o[e];t.isSkinnedMesh&&(t.bind(i,s.skin.bindMatrix),t.normalizeSkinWeights()),n.push(t)}}var u;for(let e=0,t=c.length;e<t;e++){const t=re(c[e]);null!==t&&n.push(t.clone())}for(let e=0,t=l.length;e<t;e++){const t=l[e],s=Se(me(t.id),t.materials);for(let e=0,t=s.length;e<t;e++)n.push(s[e])}for(let e=0,t=d.length;e<t;e++)n.push(Fe(d[e]).clone());let f;if(0===o.length&&1===n.length)f=n[0];else{f="JOINT"===i?new e.Bone:new e.Group;for(let e=0;e<n.length;e++)f.add(n[e])}return f.name="JOINT"===i?t.sid:t.name,f.matrix.copy(s),f.matrix.decompose(f.position,f.quaternion,f.scale),f}const qe=new e.MeshBasicMaterial({color:16711935});function Ie(e,t){const n=[];for(let s=0,o=e.length;s<o;s++){const o=t[e[s]];void 0===o?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",e[s]),n.push(qe)):n.push(Q(o))}return n}function Se(t,n){const s=[];for(const o in t){const i=t[o],r=Ie(i.materialKeys,n);0===r.length&&("lines"===o||"linestrips"===o?r.push(new e.LineBasicMaterial):r.push(new e.MeshPhongMaterial));const a=void 0!==i.data.attributes.skinIndex,c=1===r.length?r[0]:r;let l;switch(o){case"lines":l=new e.LineSegments(i.data,c);break;case"linestrips":l=new e.Line(i.data,c);break;case"triangles":case"polylist":l=a?new e.SkinnedMesh(i.data,c):new e.Mesh(i.data,c)}s.push(l)}return s}function Ue(e){return void 0!==Qe.nodes[e]}function Fe(e){return m(Qe.nodes[e],je)}function He(t){const n=new e.Group;n.name=t.name;const s=t.children;for(let e=0;e<s.length;e++){const t=s[e];n.add(Fe(t.id))}return n}function Be(e){return m(Qe.visualScenes[e],He)}if(0===n.length)return{scene:new e.Scene};const Ve=(new DOMParser).parseFromString(n,"application/xml"),Pe=o(Ve,"COLLADA")[0],De=Ve.getElementsByTagName("parsererror")[0];if(void 0!==De){const e=o(De,"div")[0];let t;return t=e?e.textContent:function(e){let t="";const n=[e];for(;n.length;){const e=n.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",n.push.apply(n,e.childNodes))}return t.trim()}(De),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",t),null}const We=Pe.getAttribute("version");console.log("THREE.ColladaLoader: File version",We);const ze=function(e){return{unit:d(o(e,"unit")[0]),upAxis:u(o(e,"up_axis")[0])}}(o(Pe,"asset")[0]),Ge=new e.TextureLoader(this.manager);let Je;Ge.setPath(this.resourcePath||s).setCrossOrigin(this.crossOrigin),t.TGALoader&&(Je=new t.TGALoader(this.manager),Je.setPath(this.resourcePath||s));const Xe=[];let Ke={},Ze=0;const Qe={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};f(Pe,"library_animations","animation",(function t(n){const s={sources:{},samplers:{},channels:{}};let o=!1;for(let e=0,i=n.childNodes.length;e<i;e++){const i=n.childNodes[e];if(1!==i.nodeType)continue;let r;switch(i.nodeName){case"source":r=i.getAttribute("id"),s.sources[r]=ae(i);break;case"sampler":r=i.getAttribute("id"),s.samplers[r]=p(i);break;case"channel":r=i.getAttribute("target"),s.channels[r]=g(i);break;case"animation":t(i),o=!0;break;default:console.log(i)}}!1===o&&(Qe.animations[n.getAttribute("id")||e.MathUtils.generateUUID()]=s)})),f(Pe,"library_animation_clips","animation_clip",(function(e){const t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"instance_animation":t.animations.push(c(s.getAttribute("url")))}}Qe.clips[e.getAttribute("id")]=t})),f(Pe,"library_controllers","controller",(function(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"skin":t.id=c(s.getAttribute("source")),t.skin=L(s);break;case"morph":t.id=c(s.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}Qe.controllers[e.getAttribute("id")]=t})),f(Pe,"library_images","image",(function(e){const t={init_from:o(e,"init_from")[0].textContent};Qe.images[e.getAttribute("id")]=t})),f(Pe,"library_effects","effect",(function(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"profile_COMMON":t.profile=S(s)}}Qe.effects[e.getAttribute("id")]=t})),f(Pe,"library_materials","material",(function(e){const t={name:e.getAttribute("name")};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"instance_effect":t.url=c(s.getAttribute("url"))}}Qe.materials[e.getAttribute("id")]=t})),f(Pe,"library_cameras","camera",(function(e){const t={name:e.getAttribute("name")};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"optics":t.optics=Y(s)}}Qe.cameras[e.getAttribute("id")]=t})),f(Pe,"library_lights","light",(function(e){let t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique_common":t=se(s)}}Qe.lights[e.getAttribute("id")]=t})),f(Pe,"library_geometries","geometry",(function(e){const t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},n=o(e,"mesh")[0];if(void 0!==n){for(let e=0;e<n.childNodes.length;e++){const s=n.childNodes[e];if(1!==s.nodeType)continue;const o=s.getAttribute("id");switch(s.nodeName){case"source":t.sources[o]=ae(s);break;case"vertices":t.vertices=ce(s);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",s.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(le(s));break;default:console.log(s)}}Qe.geometries[e.getAttribute("id")]=t}})),f(Pe,"library_nodes","node",Me),f(Pe,"library_visual_scenes","visual_scene",(function(e){const t={name:e.getAttribute("name"),children:[]};!function(e){const t=e.getElementsByTagName("node");for(let e=0;e<t.length;e++){const n=t[e];!1===n.hasAttribute("id")&&n.setAttribute("id","three_default_"+Ze++)}}(e);const n=o(e,"node");for(let e=0;e<n.length;e++)t.children.push(Me(n[e]));Qe.visualScenes[e.getAttribute("id")]=t})),f(Pe,"library_kinematics_models","kinematics_model",(function(e){const t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"technique_common":ge(s,t)}}Qe.kinematicsModels[e.getAttribute("id")]=t})),f(Pe,"library_physics_models","physics_model",(function(e){const t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"rigid_body":t.rigidBodies[s.getAttribute("name")]={},ke(s,t.rigidBodies[s.getAttribute("name")])}}Qe.physicsModels[e.getAttribute("id")]=t})),f(Pe,"scene","instance_kinematics_scene",(function(e){const t={bindJointAxis:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"bind_joint_axis":t.bindJointAxis.push(ve(s))}}Qe.kinematicsScenes[c(e.getAttribute("url"))]=t})),h(Qe.animations,b),h(Qe.clips,E),h(Qe.controllers,j),h(Qe.images,q),h(Qe.effects,K),h(Qe.materials,Z),h(Qe.cameras,te),h(Qe.lights,ie),h(Qe.geometries,ue),h(Qe.visualScenes,He),function(){const t=Qe.clips;if(!0===l(t)){if(!1===l(Qe.animations)){const t=[];for(const e in Qe.animations){const n=y(e);for(let e=0,s=n.length;e<s;e++)t.push(n[e])}Xe.push(new e.AnimationClip("default",-1,t))}}else for(const e in t)Xe.push(M(e))}(),function(){const t=Object.keys(Qe.kinematicsModels)[0],n=Object.keys(Qe.kinematicsScenes)[0],s=Object.keys(Qe.visualScenes)[0];if(void 0===t||void 0===n)return;const o=(i=t,m(Qe.kinematicsModels[i],pe));var i;const r=function(e){return m(Qe.kinematicsScenes[e],Te)}(n),a=Be(s),c=r.bindJointAxis,l={};for(let e=0,t=c.length;e<t;e++){const t=c[e],n=Pe.querySelector('[sid="'+t.target+'"]');if(n){const e=n.parentElement;d(t.jointIndex,e)}}function d(e,t){const n=t.getAttribute("name"),s=o.joints[e];a.traverse((function(o){o.name===n&&(l[e]={object:o,transforms:Ce(t),joint:s,position:s.zeroPosition})}))}const u=new e.Matrix4;Ke={joints:o&&o.joints,getJointValue:function(e){const t=l[e];if(t)return t.position;console.warn("THREE.ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(t,n){const s=l[t];if(s){const o=s.joint;if(n>o.limits.max||n<o.limits.min)console.warn("THREE.ColladaLoader: Joint "+t+" value "+n+" outside of limits (min: "+o.limits.min+", max: "+o.limits.max+").");else if(o.static)console.warn("THREE.ColladaLoader: Joint "+t+" is static.");else{const i=s.object,r=o.axis,a=s.transforms;_e.identity();for(let s=0;s<a.length;s++){const i=a[s];if(i.sid&&-1!==i.sid.indexOf(t))switch(o.type){case"revolute":_e.multiply(u.makeRotationAxis(r,e.MathUtils.degToRad(n)));break;case"prismatic":_e.multiply(u.makeTranslation(r.x*n,r.y*n,r.z*n));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+o.type)}else switch(i.type){case"matrix":_e.multiply(i.obj);break;case"translate":_e.multiply(u.makeTranslation(i.obj.x,i.obj.y,i.obj.z));break;case"scale":_e.scale(i.obj);break;case"rotate":_e.multiply(u.makeRotationAxis(i.obj,i.angle))}}i.matrix.copy(_e),i.matrix.decompose(i.position,i.quaternion,i.scale),l[t].position=n}}else console.log("THREE.ColladaLoader: "+t+" does not exist.")}}}();const Ye=function(e){return Be(c(o(e,"instance_visual_scene")[0].getAttribute("url")))}(o(Pe,"scene")[0]);return Ye.animations=Xe,"Z_UP"===ze.upAxis&&Ye.quaternion.setFromEuler(new e.Euler(-Math.PI/2,0,0)),Ye.scale.multiplyScalar(ze.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Xe},kinematics:Ke,library:Qe,scene:Ye}}}exports.ColladaLoader=n;
@@ -1,4 +1,4 @@
1
- import { Loader, LoaderUtils, FileLoader, Vector3, Quaternion, Matrix4, MeshBasicMaterial, Scene, TextureLoader, Euler, MathUtils, AnimationClip, VectorKeyframeTrack, QuaternionKeyframeTrack, MeshLambertMaterial, MeshPhongMaterial, DoubleSide, PerspectiveCamera, OrthographicCamera, Color, AmbientLight, SpotLight, PointLight, DirectionalLight, BufferGeometry, Float32BufferAttribute, Skeleton, Bone, Group, LineBasicMaterial, SkinnedMesh, Mesh, Line, LineSegments, RepeatWrapping, ClampToEdgeWrapping } from 'three';
1
+ import { Loader, LoaderUtils, FileLoader, Vector3, Quaternion, Matrix4, MeshBasicMaterial, Scene, TextureLoader, Euler, MathUtils, AnimationClip, VectorKeyframeTrack, QuaternionKeyframeTrack, MeshLambertMaterial, MeshPhongMaterial, Vector2, DoubleSide, FrontSide, PerspectiveCamera, OrthographicCamera, Color, AmbientLight, SpotLight, PointLight, DirectionalLight, BufferGeometry, Float32BufferAttribute, Skeleton, Bone, Group, LineBasicMaterial, SkinnedMesh, Mesh, Line, LineSegments, RepeatWrapping, ClampToEdgeWrapping } from 'three';
2
2
  import { TGALoader } from './TGALoader.js';
3
3
 
4
4
  class ColladaLoader extends Loader {
@@ -370,11 +370,7 @@ class ColladaLoader extends Loader {
370
370
  }
371
371
 
372
372
  if (positionData.length > 0) tracks.push(new VectorKeyframeTrack(name + '.position', times, positionData));
373
-
374
- if (quaternionData.length > 0) {
375
- tracks.push(new QuaternionKeyframeTrack(name + '.quaternion', times, quaternionData));
376
- }
377
-
373
+ if (quaternionData.length > 0) tracks.push(new QuaternionKeyframeTrack(name + '.quaternion', times, quaternionData));
378
374
  if (scaleData.length > 0) tracks.push(new VectorKeyframeTrack(name + '.scale', times, scaleData));
379
375
  return tracks;
380
376
  }
@@ -857,6 +853,10 @@ class ColladaLoader extends Loader {
857
853
  data.type = child.nodeName;
858
854
  data.parameters = parseEffectParameters(child);
859
855
  break;
856
+
857
+ case 'extra':
858
+ data.extra = parseEffectExtra(child);
859
+ break;
860
860
  }
861
861
  }
862
862
 
@@ -883,7 +883,7 @@ class ColladaLoader extends Loader {
883
883
 
884
884
  case 'transparent':
885
885
  data[child.nodeName] = {
886
- opaque: child.getAttribute('opaque'),
886
+ opaque: child.hasAttribute('opaque') ? child.getAttribute('opaque') : 'A_ONE',
887
887
  data: parseEffectParameter(child)
888
888
  };
889
889
  break;
@@ -978,6 +978,10 @@ class ColladaLoader extends Loader {
978
978
  }
979
979
 
980
980
  break;
981
+
982
+ case 'bump':
983
+ data[child.nodeName] = parseEffectExtraTechniqueBump(child);
984
+ break;
981
985
  }
982
986
  }
983
987
  }
@@ -1010,6 +1014,31 @@ class ColladaLoader extends Loader {
1010
1014
  case 'double_sided':
1011
1015
  data[child.nodeName] = parseInt(child.textContent);
1012
1016
  break;
1017
+
1018
+ case 'bump':
1019
+ data[child.nodeName] = parseEffectExtraTechniqueBump(child);
1020
+ break;
1021
+ }
1022
+ }
1023
+
1024
+ return data;
1025
+ }
1026
+
1027
+ function parseEffectExtraTechniqueBump(xml) {
1028
+ var data = {};
1029
+
1030
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1031
+ var child = xml.childNodes[i];
1032
+ if (child.nodeType !== 1) continue;
1033
+
1034
+ switch (child.nodeName) {
1035
+ case 'texture':
1036
+ data[child.nodeName] = {
1037
+ id: child.getAttribute('texture'),
1038
+ texcoord: child.getAttribute('texcoord'),
1039
+ extra: parseEffectParameterTexture(child)
1040
+ };
1041
+ break;
1013
1042
  }
1014
1043
  }
1015
1044
 
@@ -1065,7 +1094,6 @@ class ColladaLoader extends Loader {
1065
1094
  function buildMaterial(data) {
1066
1095
  const effect = getEffect(data.url);
1067
1096
  const technique = effect.profile.technique;
1068
- const extra = effect.profile.extra;
1069
1097
  let material;
1070
1098
 
1071
1099
  switch (technique.type) {
@@ -1216,8 +1244,23 @@ class ColladaLoader extends Loader {
1216
1244
  } //
1217
1245
 
1218
1246
 
1219
- if (extra !== undefined && extra.technique !== undefined && extra.technique.double_sided === 1) {
1220
- material.side = DoubleSide;
1247
+ if (technique.extra !== undefined && technique.extra.technique !== undefined) {
1248
+ const techniques = technique.extra.technique;
1249
+
1250
+ for (const k in techniques) {
1251
+ const v = techniques[k];
1252
+
1253
+ switch (k) {
1254
+ case 'double_sided':
1255
+ material.side = v === 1 ? DoubleSide : FrontSide;
1256
+ break;
1257
+
1258
+ case 'bump':
1259
+ material.normalMap = getTexture(v.texture);
1260
+ material.normalScale = new Vector2(1, 1);
1261
+ break;
1262
+ }
1263
+ }
1221
1264
  }
1222
1265
 
1223
1266
  return material;
@@ -1792,26 +1835,13 @@ class ColladaLoader extends Loader {
1792
1835
  } // build geometry
1793
1836
 
1794
1837
 
1795
- if (position.array.length > 0) {
1796
- geometry.setAttribute('position', new Float32BufferAttribute(position.array, position.stride));
1797
- }
1798
-
1799
- if (normal.array.length > 0) {
1800
- geometry.setAttribute('normal', new Float32BufferAttribute(normal.array, normal.stride));
1801
- }
1802
-
1838
+ if (position.array.length > 0) geometry.setAttribute('position', new Float32BufferAttribute(position.array, position.stride));
1839
+ if (normal.array.length > 0) geometry.setAttribute('normal', new Float32BufferAttribute(normal.array, normal.stride));
1803
1840
  if (color.array.length > 0) geometry.setAttribute('color', new Float32BufferAttribute(color.array, color.stride));
1804
1841
  if (uv.array.length > 0) geometry.setAttribute('uv', new Float32BufferAttribute(uv.array, uv.stride));
1805
1842
  if (uv2.array.length > 0) geometry.setAttribute('uv2', new Float32BufferAttribute(uv2.array, uv2.stride));
1806
-
1807
- if (skinIndex.array.length > 0) {
1808
- geometry.setAttribute('skinIndex', new Float32BufferAttribute(skinIndex.array, skinIndex.stride));
1809
- }
1810
-
1811
- if (skinWeight.array.length > 0) {
1812
- geometry.setAttribute('skinWeight', new Float32BufferAttribute(skinWeight.array, skinWeight.stride));
1813
- }
1814
-
1843
+ if (skinIndex.array.length > 0) geometry.setAttribute('skinIndex', new Float32BufferAttribute(skinIndex.array, skinIndex.stride));
1844
+ if (skinWeight.array.length > 0) geometry.setAttribute('skinWeight', new Float32BufferAttribute(skinWeight.array, skinWeight.stride));
1815
1845
  build.data = geometry;
1816
1846
  build.type = primitives[0].type;
1817
1847
  build.materialKeys = materialKeys;
@@ -2708,14 +2738,7 @@ class ColladaLoader extends Loader {
2708
2738
  } // regard skinning
2709
2739
 
2710
2740
 
2711
- const skinning = geometry.data.attributes.skinIndex !== undefined;
2712
-
2713
- if (skinning) {
2714
- for (let i = 0, l = materials.length; i < l; i++) {
2715
- materials[i].skinning = true;
2716
- }
2717
- } // choose between a single or multi materials (material array)
2718
-
2741
+ const skinning = geometry.data.attributes.skinIndex !== undefined; // choose between a single or multi materials (material array)
2719
2742
 
2720
2743
  const material = materials.length === 1 ? materials[0] : materials; // now create a specific 3D object
2721
2744
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("fflate");class n extends e.DataTextureLoader{constructor(r){super(r),this.type=e.FloatType}parse(n){const a=65536,t=14,i=65537,o=16384,l=Math.pow(2.7182818,2.2);var s=new DataView(new ArrayBuffer(8));function f(e){if(0===e)return[e,0];s.setFloat64(0,e);var r=s.getUint32(0)>>>20&2047;0===r&&(s.setFloat64(0,e*Math.pow(2,64)),r=(s.getUint32(0)>>>20&2047)-64);var n=r-1022;return[function(e,r){for(var n=Math.min(3,Math.ceil(Math.abs(r)/1023)),a=e,t=0;t<n;t++)a*=Math.pow(2,Math.floor((r+t)/n));return a}(e,-n),n]}const u={l:0,c:0,lc:0};function c(e,r,n,a,t){for(;n<e;)r=r<<8|V(a,t),n+=8;n-=e,u.l=r>>n&(1<<e)-1,u.c=r,u.lc=n}const v=new Array(59);function h(e,r,n,a,t,o,l){for(var s=n,f=0,h=0;t<=o;t++){if(s.value-n.value>a)return!1;c(6,f,h,e,s);var w=u.l;if(f=u.c,h=u.lc,l[t]=w,63==w){if(s.value-n.value>a)throw"Something wrong with hufUnpackEncTable";c(8,f,h,e,s);var p=u.l+6;if(f=u.c,h=u.lc,t+p>o+1)throw"Something wrong with hufUnpackEncTable";for(;p--;)l[t++]=0;t--}else if(w>=59){if(t+(p=w-59+2)>o+1)throw"Something wrong with hufUnpackEncTable";for(;p--;)l[t++]=0;t--}}!function(e){for(var r=0;r<=58;++r)v[r]=0;for(r=0;r<i;++r)v[e[r]]+=1;var n=0;for(r=58;r>0;--r){var a=n+v[r]>>1;v[r]=n,n=a}for(r=0;r<i;++r){var t=e[r];t>0&&(e[r]=t|v[t]++<<6)}}(l)}function w(e){return 63&e}function p(e){return e>>6}const y={c:0,lc:0};function d(e,r,n,a){e=e<<8|V(n,a),r+=8,y.c=e,y.lc=r}const g={c:0,lc:0};function S(e,r,n,a,t,i,o,l,s,f){if(e==r){a<8&&(d(n,a,t,o),n=y.c,a=y.lc);var u=n>>(a-=8);u=new Uint8Array([u])[0];if(s.value+u>f)return!1;for(var c=l[s.value-1];u-- >0;)l[s.value++]=c}else{if(!(s.value<f))return!1;l[s.value++]=e}g.c=n,g.lc=a}function b(e){return 65535&e}function A(e){var r=b(e);return r>32767?r-65536:r}const U={a:0,b:0};function m(e,r){var n=A(e),a=A(r),t=n+(1&a)+(a>>1),i=t,o=t-a;U.a=i,U.b=o}function M(e,r){var n=b(e),a=b(r),t=n-(a>>1)&65535,i=a+t-32768&65535;U.a=i,U.b=t}function O(e,r,n,a,t,i,o){for(var l,s=o<16384,f=n>t?t:n,u=1;u<=f;)u<<=1;for(l=u>>=1,u>>=1;u>=1;){for(var c,v,h,w,p=0,y=p+i*(t-l),d=i*u,g=i*l,S=a*u,b=a*l;p<=y;p+=g){for(var A=p,O=p+a*(n-l);A<=O;A+=b){var E=A+S,C=(I=A+d)+S;s?(m(e[A+r],e[I+r]),c=U.a,h=U.b,m(e[E+r],e[C+r]),v=U.a,w=U.b,m(c,v),e[A+r]=U.a,e[E+r]=U.b,m(h,w),e[I+r]=U.a,e[C+r]=U.b):(M(e[A+r],e[I+r]),c=U.a,h=U.b,M(e[E+r],e[C+r]),v=U.a,w=U.b,M(c,v),e[A+r]=U.a,e[E+r]=U.b,M(h,w),e[I+r]=U.a,e[C+r]=U.b)}if(n&u){var I=A+d;s?m(e[A+r],e[I+r]):M(e[A+r],e[I+r]),c=U.a,e[I+r]=U.b,e[A+r]=c}}if(t&u)for(A=p,O=p+a*(n-l);A<=O;A+=b){E=A+S;s?m(e[A+r],e[E+r]):M(e[A+r],e[E+r]),c=U.a,e[E+r]=U.b,e[A+r]=c}l=u,u>>=1}return p}function E(e,r,n,a,l,s){var f=n.value,u=X(r,n),c=X(r,n);n.value+=4;var v=X(r,n);if(n.value+=4,u<0||u>=i||c<0||c>=i)throw"Something wrong with HUF_ENCSIZE";var b=new Array(i),A=new Array(o);if(function(e){for(var r=0;r<o;r++)e[r]={},e[r].len=0,e[r].lit=0,e[r].p=null}(A),h(e,0,n,a-(n.value-f),u,c,b),v>8*(a-(n.value-f)))throw"Something wrong with hufUncompress";!function(e,r,n,a){for(;r<=n;r++){var i=p(e[r]),o=w(e[r]);if(i>>o)throw"Invalid table entry";if(o>t){if((u=a[i>>o-t]).len)throw"Invalid table entry";if(u.lit++,u.p){var l=u.p;u.p=new Array(u.lit);for(var s=0;s<u.lit-1;++s)u.p[s]=l[s]}else u.p=new Array(1);u.p[u.lit-1]=r}else if(o){var f=0;for(s=1<<t-o;s>0;s--){var u;if((u=a[(i<<t-o)+f]).len||u.p)throw"Invalid table entry";u.len=o,u.lit=r,f++}}}}(b,u,c,A),function(e,r,n,a,i,o,l,s,f,u){for(var c=0,v=0,h=s,b=Math.trunc(i.value+(o+7)/8);i.value<b;)for(d(c,v,n,i),c=y.c,v=y.lc;v>=t;)if((M=r[c>>v-t&16383]).len)v-=M.len,S(M.lit,l,c,v,n,0,i,f,u,h),c=g.c,v=g.lc;else{if(!M.p)throw"hufDecode issues";var A;for(A=0;A<M.lit;A++){for(var U=w(e[M.p[A]]);v<U&&i.value<b;)d(c,v,n,i),c=y.c,v=y.lc;if(v>=U&&p(e[M.p[A]])==(c>>v-U&(1<<U)-1)){v-=U,S(M.p[A],l,c,v,n,0,i,f,u,h),c=g.c,v=g.lc;break}}if(A==M.lit)throw"hufDecode issues"}var m=8-o&7;for(c>>=m,v-=m;v>0;){var M;if(!(M=r[c<<t-v&16383]).len)throw"hufDecode issues";v-=M.len,S(M.lit,l,c,v,n,0,i,f,u,h),c=g.c,v=g.lc}}(b,A,e,0,n,v,c,s,l,{value:0})}function C(e){for(var r=1;r<e.length;r++){var n=e[r-1]+e[r]-128;e[r]=n}}function I(e,r){for(var n=0,a=Math.floor((e.length+1)/2),t=0,i=e.length-1;!(t>i||(r[t++]=e[n++],t>i));)r[t++]=e[a++]}function R(e){for(var r=e.byteLength,n=new Array,a=0,t=new DataView(e);r>0;){var i=t.getInt8(a++);if(i<0){r-=(l=-i)+1;for(var o=0;o<l;o++)n.push(t.getUint8(a++))}else{var l=i;r-=2;var s=t.getUint8(a++);for(o=0;o<l+1;o++)n.push(s)}}return n}function x(e,r,n){for(var a,t=1;t<64;)65280==(a=r[e.value])?t=64:a>>8==255?t+=255&a:(n[t]=a,t++),e.value++}function z(e,r){r[0]=Y(e[0]),r[1]=Y(e[1]),r[2]=Y(e[5]),r[3]=Y(e[6]),r[4]=Y(e[14]),r[5]=Y(e[15]),r[6]=Y(e[27]),r[7]=Y(e[28]),r[8]=Y(e[2]),r[9]=Y(e[4]),r[10]=Y(e[7]),r[11]=Y(e[13]),r[12]=Y(e[16]),r[13]=Y(e[26]),r[14]=Y(e[29]),r[15]=Y(e[42]),r[16]=Y(e[3]),r[17]=Y(e[8]),r[18]=Y(e[12]),r[19]=Y(e[17]),r[20]=Y(e[25]),r[21]=Y(e[30]),r[22]=Y(e[41]),r[23]=Y(e[43]),r[24]=Y(e[9]),r[25]=Y(e[11]),r[26]=Y(e[18]),r[27]=Y(e[24]),r[28]=Y(e[31]),r[29]=Y(e[40]),r[30]=Y(e[44]),r[31]=Y(e[53]),r[32]=Y(e[10]),r[33]=Y(e[19]),r[34]=Y(e[23]),r[35]=Y(e[32]),r[36]=Y(e[39]),r[37]=Y(e[45]),r[38]=Y(e[52]),r[39]=Y(e[54]),r[40]=Y(e[20]),r[41]=Y(e[22]),r[42]=Y(e[33]),r[43]=Y(e[38]),r[44]=Y(e[46]),r[45]=Y(e[51]),r[46]=Y(e[55]),r[47]=Y(e[60]),r[48]=Y(e[21]),r[49]=Y(e[34]),r[50]=Y(e[37]),r[51]=Y(e[47]),r[52]=Y(e[50]),r[53]=Y(e[56]),r[54]=Y(e[59]),r[55]=Y(e[61]),r[56]=Y(e[35]),r[57]=Y(e[36]),r[58]=Y(e[48]),r[59]=Y(e[49]),r[60]=Y(e[57]),r[61]=Y(e[58]),r[62]=Y(e[62]),r[63]=Y(e[63])}function P(e){const r=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),a=.5*Math.cos(3.14159/8),t=.5*Math.cos(3*3.14159/16),i=.5*Math.cos(.981746875),o=.5*Math.cos(3*3.14159/8),l=.5*Math.cos(1.374445625);for(var s=new Array(4),f=new Array(4),u=new Array(4),c=new Array(4),v=0;v<8;++v){var h=8*v;s[0]=a*e[h+2],s[1]=o*e[h+2],s[2]=a*e[h+6],s[3]=o*e[h+6],f[0]=n*e[h+1]+t*e[h+3]+i*e[h+5]+l*e[h+7],f[1]=t*e[h+1]-l*e[h+3]-n*e[h+5]-i*e[h+7],f[2]=i*e[h+1]-n*e[h+3]+l*e[h+5]+t*e[h+7],f[3]=l*e[h+1]-i*e[h+3]+t*e[h+5]-n*e[h+7],u[0]=r*(e[h+0]+e[h+4]),u[3]=r*(e[h+0]-e[h+4]),u[1]=s[0]+s[3],u[2]=s[1]-s[2],c[0]=u[0]+u[1],c[1]=u[3]+u[2],c[2]=u[3]-u[2],c[3]=u[0]-u[1],e[h+0]=c[0]+f[0],e[h+1]=c[1]+f[1],e[h+2]=c[2]+f[2],e[h+3]=c[3]+f[3],e[h+4]=c[3]-f[3],e[h+5]=c[2]-f[2],e[h+6]=c[1]-f[1],e[h+7]=c[0]-f[0]}for(var w=0;w<8;++w)s[0]=a*e[16+w],s[1]=o*e[16+w],s[2]=a*e[48+w],s[3]=o*e[48+w],f[0]=n*e[8+w]+t*e[24+w]+i*e[40+w]+l*e[56+w],f[1]=t*e[8+w]-l*e[24+w]-n*e[40+w]-i*e[56+w],f[2]=i*e[8+w]-n*e[24+w]+l*e[40+w]+t*e[56+w],f[3]=l*e[8+w]-i*e[24+w]+t*e[40+w]-n*e[56+w],u[0]=r*(e[w]+e[32+w]),u[3]=r*(e[w]-e[32+w]),u[1]=s[0]+s[3],u[2]=s[1]-s[2],c[0]=u[0]+u[1],c[1]=u[3]+u[2],c[2]=u[3]-u[2],c[3]=u[0]-u[1],e[0+w]=c[0]+f[0],e[8+w]=c[1]+f[1],e[16+w]=c[2]+f[2],e[24+w]=c[3]+f[3],e[32+w]=c[3]-f[3],e[40+w]=c[2]-f[2],e[48+w]=c[1]-f[1],e[56+w]=c[0]-f[0]}function N(e){for(var r=0;r<64;++r){var n=e[0][r],a=e[1][r],t=e[2][r];e[0][r]=n+1.5747*t,e[1][r]=n-.1873*a-.4682*t,e[2][r]=n+1.8556*a}}function F(r,n,a){for(var t=0;t<64;++t)n[a+t]=e.DataUtils.toHalfFloat(T(r[t]))}function T(e){return e<=1?Math.sign(e)*Math.pow(Math.abs(e),2.2):Math.sign(e)*Math.pow(l,Math.abs(e)-1)}function k(e){var n=e.array.slice(e.offset.value,e.offset.value+e.size),a=r.unzlibSync(n),t=new Uint8Array(a.length);return C(a),I(a,t),new DataView(t.buffer)}function D(e){var n=e.viewer,a={value:e.offset.value},t=new Uint8Array(e.width*e.lines*(J.channels.length*e.type*2)),i={version:Z(n,a),unknownUncompressedSize:Z(n,a),unknownCompressedSize:Z(n,a),acCompressedSize:Z(n,a),dcCompressedSize:Z(n,a),rleCompressedSize:Z(n,a),rleUncompressedSize:Z(n,a),rleRawSize:Z(n,a),totalAcUncompressedCount:Z(n,a),totalDcUncompressedCount:Z(n,a),acCompression:Z(n,a)};if(i.version<2)throw"EXRLoader.parse: "+J.compression+" version "+i.version+" is unsupported";for(var o=new Array,l=G(n,a)-2;l>0;){var s=_(n.buffer,a),f=W(n,a),u=f>>2&3,c=new Int8Array([(f>>4)-1])[0],v=W(n,a);o.push({name:s,index:c,type:v,compression:u}),l-=s.length+3}for(var h=J.channels,w=new Array(e.channels),p=0;p<e.channels;++p){var y=w[p]={},d=h[p];y.name=d.name,y.compression=0,y.decoded=!1,y.type=d.pixelType,y.pLinear=d.pLinear,y.width=e.width,y.height=e.lines}for(var g={idx:new Array(3)},S=0;S<e.channels;++S)for(y=w[S],p=0;p<o.length;++p){var b=o[p];y.name==b.name&&(y.compression=b.compression,b.index>=0&&(g.idx[b.index]=S),y.offset=S)}if(i.acCompressedSize>0)switch(i.acCompression){case 0:var A=new Uint16Array(i.totalAcUncompressedCount);E(e.array,n,a,i.acCompressedSize,A,i.totalAcUncompressedCount);break;case 1:var U=e.array.slice(a.value,a.value+i.totalAcUncompressedCount),m=r.unzlibSync(U);A=new Uint16Array(m.buffer);a.value+=i.totalAcUncompressedCount}if(i.dcCompressedSize>0){var M={array:e.array,offset:a,size:i.dcCompressedSize},O=new Uint16Array(k(M).buffer);a.value+=i.dcCompressedSize}if(i.rleRawSize>0){U=e.array.slice(a.value,a.value+i.rleCompressedSize);var C=R((m=r.unzlibSync(U)).buffer);a.value+=i.rleCompressedSize}var I=0,T=new Array(w.length);for(p=0;p<T.length;++p)T[p]=new Array;for(var D=0;D<e.lines;++D)for(var L=0;L<w.length;++L)T[L].push(I),I+=w[L].width*e.type*2;!function(e,r,n,a,t,i){var o=new DataView(i.buffer),l=n[e.idx[0]].width,s=n[e.idx[0]].height,f=Math.floor(l/8),u=Math.ceil(l/8),c=Math.ceil(s/8),v=l-8*(u-1),h=s-8*(c-1),w={value:0},p=new Array(3),y=new Array(3),d=new Array(3),g=new Array(3),S=new Array(3);for(let n=0;n<3;++n)S[n]=r[e.idx[n]],p[n]=n<1?0:p[n-1]+u*c,y[n]=new Float32Array(64),d[n]=new Uint16Array(64),g[n]=new Uint16Array(64*u);for(let r=0;r<c;++r){var b=8;r==c-1&&(b=h);var A=8;for(let e=0;e<u;++e){e==u-1&&(A=v);for(let e=0;e<3;++e)d[e].fill(0),d[e][0]=t[p[e]++],x(w,a,d[e]),z(d[e],y[e]),P(y[e]);N(y);for(let r=0;r<3;++r)F(y[r],g[r],64*e)}let i=0;for(let a=0;a<3;++a){const t=n[e.idx[a]].type;for(let e=8*r;e<8*r+b;++e){i=S[a][e];for(let r=0;r<f;++r){const n=64*r+8*(7&e);o.setUint16(i+0*t,g[a][n+0],!0),o.setUint16(i+2*t,g[a][n+1],!0),o.setUint16(i+4*t,g[a][n+2],!0),o.setUint16(i+6*t,g[a][n+3],!0),o.setUint16(i+8*t,g[a][n+4],!0),o.setUint16(i+10*t,g[a][n+5],!0),o.setUint16(i+12*t,g[a][n+6],!0),o.setUint16(i+14*t,g[a][n+7],!0),i+=16*t}}if(f!=u)for(let e=8*r;e<8*r+b;++e){const r=S[a][e]+8*f*2*t,n=64*f+8*(7&e);for(let e=0;e<A;++e)o.setUint16(r+2*e*t,g[a][n+e],!0)}}}for(var U=new Uint16Array(l),m=(o=new DataView(i.buffer),0);m<3;++m){n[e.idx[m]].decoded=!0;var M=n[e.idx[m]].type;if(2==n[m].type)for(var O=0;O<s;++O){const e=S[m][O];for(var E=0;E<l;++E)U[E]=o.getUint16(e+2*E*M,!0);for(E=0;E<l;++E)o.setFloat32(e+2*E*M,Y(U[E]),!0)}}}(g,T,w,A,O,t);for(p=0;p<w.length;++p){if(!(y=w[p]).decoded)switch(y.compression){case 2:var B=0,X=0;for(D=0;D<e.lines;++D){for(var V=T[p][B],H=0;H<y.width;++H){for(var q=0;q<2*y.type;++q)t[V++]=C[X+q*y.width*y.height];X++}B++}break;case 1:default:throw"EXRLoader.parse: unsupported channel compression"}}return new DataView(t.buffer)}function _(e,r){for(var n=new Uint8Array(e),a=0;0!=n[r.value+a];)a+=1;var t=(new TextDecoder).decode(n.slice(r.value,r.value+a));return r.value=r.value+a+1,t}function L(e,r){var n=e.getUint32(0,!0);return r.value=r.value+8,n}function B(e,r){var n=e.getInt32(r.value,!0);return r.value=r.value+4,n}function X(e,r){var n=e.getUint32(r.value,!0);return r.value=r.value+4,n}function V(e,r){var n=e[r.value];return r.value=r.value+1,n}function W(e,r){var n=e.getUint8(r.value);return r.value=r.value+1,n}function Z(e,r){var n=Number(e.getBigInt64(r.value,!0));return r.value+=8,n}function H(e,r){var n=e.getFloat32(r.value,!0);return r.value+=4,n}function Y(e){var r=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(r?31===r?n?NaN:1/0:Math.pow(2,r-15)*(1+n/1024):n/1024*6103515625e-14)}function G(e,r){var n=e.getUint16(r.value,!0);return r.value+=2,n}function q(e,r,n,a,t){return"string"===a||"stringvector"===a||"iccProfile"===a?function(e,r,n){var a=(new TextDecoder).decode(new Uint8Array(e).slice(r.value,r.value+n));return r.value=r.value+n,a}(r,n,t):"chlist"===a?function(e,r,n,a){for(var t=n.value,i=[];n.value<t+a-1;){var o=_(r,n),l=B(e,n),s=W(e,n);n.value+=3;var f=B(e,n),u=B(e,n);i.push({name:o,pixelType:l,pLinear:s,xSampling:f,ySampling:u})}return n.value+=1,i}(e,r,n,t):"chromaticities"===a?function(e,r){return{redX:H(e,r),redY:H(e,r),greenX:H(e,r),greenY:H(e,r),blueX:H(e,r),blueY:H(e,r),whiteX:H(e,r),whiteY:H(e,r)}}(e,n):"compression"===a?function(e,r){return["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"][W(e,r)]}(e,n):"box2i"===a?function(e,r){return{xMin:X(e,r),yMin:X(e,r),xMax:X(e,r),yMax:X(e,r)}}(e,n):"lineOrder"===a?function(e,r){return["INCREASING_Y"][W(e,r)]}(e,n):"float"===a?H(e,n):"v2f"===a?function(e,r){return[H(e,r),H(e,r)]}(e,n):"v3f"===a?function(e,r){return[H(e,r),H(e,r),H(e,r)]}(e,n):"int"===a?B(e,n):"rational"===a?function(e,r){return[B(e,r),X(e,r)]}(e,n):"timecode"===a?function(e,r){return[X(e,r),X(e,r)]}(e,n):"preview"===a?(n.value+=t,"skipped"):void(n.value+=t)}var j=new DataView(n),$=new Uint8Array(n),J={};j.getUint32(0,!0),j.getUint8(4,!0),j.getUint8(5,!0);for(var K={value:8},Q=!0;Q;){var ee=_(n,K);if(0==ee)Q=!1;else{var re=_(n,K),ne=q(j,n,K,re,X(j,K));void 0===ne?console.warn(`EXRLoader.parse: skipped unknown header attribute type '${re}'.`):J[ee]=ne}}var ae,te,ie,oe,le=J.dataWindow.yMax+1;switch(J.compression){case"NO_COMPRESSION":te=1,ae=function(e){return new DataView(e.array.buffer,e.offset.value,e.size)};break;case"RLE_COMPRESSION":te=1,ae=function(e){var r=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(R(r)),a=new Uint8Array(n.length);return C(n),I(n,a),new DataView(a.buffer)};break;case"ZIPS_COMPRESSION":te=1,ae=k;break;case"ZIP_COMPRESSION":te=16,ae=k;break;case"PIZ_COMPRESSION":te=32,ae=function(e){for(var r=e.viewer,n={value:e.offset.value},t=e.width*te*(J.channels.length*e.type),i=new Uint16Array(t),o=new Uint8Array(8192),l=0,s=new Array(e.channels),f=0;f<e.channels;f++)s[f]={},s[f].start=l,s[f].end=s[f].start,s[f].nx=e.width,s[f].ny=e.lines,s[f].size=e.type,l+=s[f].nx*s[f].ny*s[f].size;var u=G(r,n),c=G(r,n);if(c>=8192)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(u<=c)for(f=0;f<c-u+1;f++)o[f+u]=W(r,n);var v=new Uint16Array(a),h=function(e,r){for(var n=0,t=0;t<a;++t)(0==t||e[t>>3]&1<<(7&t))&&(r[n++]=t);for(var i=n-1;n<a;)r[n++]=0;return i}(o,v),w=X(r,n);for(E(e.array,r,n,w,i,l),f=0;f<e.channels;++f)for(var p=s[f],y=0;y<s[f].size;++y)O(i,p.start+y,p.nx,p.size,p.ny,p.nx*p.size,h);!function(e,r,n){for(var a=0;a<n;++a)r[a]=e[r[a]]}(v,i,l);for(var d=0,g=new Uint8Array(i.buffer.byteLength),S=0;S<e.lines;S++)for(var b=0;b<e.channels;b++){var A=(p=s[b]).nx*p.size,U=new Uint8Array(i.buffer,2*p.end,2*A);g.set(U,d),d+=2*A,p.end+=A}return new DataView(g.buffer)};break;case"PXR24_COMPRESSION":te=16,ae=function(e){var n=e.array.slice(e.offset.value,e.offset.value+e.size),a=r.unzlibSync(n);const t=e.lines*e.channels*e.width,i=1==e.type?new Uint16Array(t):new Uint32Array(t);let o=0,l=0;const s=new Array(4);for(let r=0;r<e.lines;r++)for(let r=0;r<e.channels;r++){let r=0;switch(e.type){case 1:s[0]=o,s[1]=s[0]+e.width,o=s[1]+e.width;for(let n=0;n<e.width;++n)r+=a[s[0]++]<<8|a[s[1]++],i[l]=r,l++;break;case 2:s[0]=o,s[1]=s[0]+e.width,s[2]=s[1]+e.width,o=s[2]+e.width;for(let n=0;n<e.width;++n)r+=a[s[0]++]<<24|a[s[1]++]<<16|a[s[2]++]<<8,i[l]=r,l++}}return new DataView(i.buffer)};break;case"DWAA_COMPRESSION":te=32,ae=D;break;case"DWAB_COMPRESSION":te=256,ae=D;break;default:throw"EXRLoader.parse: "+J.compression+" is unsupported"}var se=J.channels[0].pixelType;if(1===se)switch(this.type){case e.UnsignedByteType:case e.FloatType:oe=function(e,r){return Y(G(e,r))},ie=2;break;case e.HalfFloatType:oe=G,ie=2}else{if(2!==se)throw"EXRLoader.parse: unsupported pixelType "+se+" for "+J.compression+".";switch(this.type){case e.UnsignedByteType:case e.FloatType:oe=H,ie=4;break;case e.HalfFloatType:oe=function(r,n){return e.DataUtils.toHalfFloat(H(r,n))},ie=4}}for(var fe=le/te,ue=0;ue<fe;ue++)L(j,K);var ce=J.dataWindow.xMax-J.dataWindow.xMin+1,ve=J.dataWindow.yMax-J.dataWindow.yMin+1,he=ce*ve*4;switch(this.type){case e.UnsignedByteType:case e.FloatType:var we=new Float32Array(he);J.channels.length<4&&we.fill(1,0,he);break;case e.HalfFloatType:we=new Uint16Array(he);J.channels.length<4&&we.fill(15360,0,he);break;default:console.error("THREE.EXRLoader: unsupported type: ",this.type)}for(var pe,ye,de={R:0,G:1,B:2,A:3},ge={size:0,width:ce,lines:te,offset:K,array:$,viewer:j,type:se,channels:J.channels.length},Se={value:0},be=0;be<ve/te;be++){pe=X(j,K),he=X(j,K),ge.lines=pe+te>ve?ve-pe:te,ge.offset=K,ge.size=he,ye=ae(ge),K.value+=he;for(var Ae=0;Ae<te;Ae++){var Ue=Ae+be*te;if(Ue>=ve)break;for(var me=0;me<J.channels.length;me++)for(var Me=de[J.channels[me].name],Oe=0;Oe<ce;Oe++){var Ee=Ae*(J.channels.length*ce)+me*ce+Oe;Se.value=Ee*ie;var Ce=oe(ye,Se);we[4*ce*(ve-1-Ue)+4*Oe+Me]=Ce}}}if(this.type===e.UnsignedByteType){let e,r;const n=we.length,a=new Uint8Array(n);for(let n=0;n<ve;++n)for(let t=0;t<ce;++t){r=n*ce*4+4*t;const i=we[r],o=we[r+1],l=we[r+2];if(e=i>o?i:o,e=l>e?l:e,e<1e-32)a[r]=a[r+1]=a[r+2]=a[r+3]=0;else{const n=f(e);e=256*n[0]/e,a[r]=i*e,a[r+1]=o*e,a[r+2]=l*e,a[r+3]=n[1]+128}}we=a}const Ie=this.type===e.UnsignedByteType?e.RGBEFormat:e.RGBAFormat;return{header:J,width:ce,height:ve,data:we,format:Ie,type:this.type}}setDataType(e){return this.type=e,this}load(r,n,a,t){return super.load(r,(function(r,a){switch(r.type){case e.UnsignedByteType:r.encoding=e.RGBEEncoding,r.minFilter=e.NearestFilter,r.magFilter=e.NearestFilter,r.generateMipmaps=!1,r.flipY=!1;break;case e.FloatType:case e.HalfFloatType:r.encoding=e.LinearEncoding,r.minFilter=e.LinearFilter,r.magFilter=e.LinearFilter,r.generateMipmaps=!1,r.flipY=!1}n&&n(r,a)}),a,t)}}exports.EXRLoader=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("fflate");class n extends e.DataTextureLoader{constructor(r){super(r),this.type=e.HalfFloatType}parse(n){const t=65536,a=14,i=65537,o=16384,l=Math.pow(2.7182818,2.2);const s={l:0,c:0,lc:0};function u(e,r,n,t,a){for(;n<e;)r=r<<8|V(t,a),n+=8;n-=e,s.l=r>>n&(1<<e)-1,s.c=r,s.lc=n}const c=new Array(59);function f(e,r,n,t,a,o,l){for(var f=n,v=0,h=0;a<=o;a++){if(f.value-n.value>t)return!1;u(6,v,h,e,f);var p=s.l;if(v=s.c,h=s.lc,l[a]=p,63==p){if(f.value-n.value>t)throw"Something wrong with hufUnpackEncTable";u(8,v,h,e,f);var w=s.l+6;if(v=s.c,h=s.lc,a+w>o+1)throw"Something wrong with hufUnpackEncTable";for(;w--;)l[a++]=0;a--}else if(p>=59){if(a+(w=p-59+2)>o+1)throw"Something wrong with hufUnpackEncTable";for(;w--;)l[a++]=0;a--}}!function(e){for(var r=0;r<=58;++r)c[r]=0;for(r=0;r<i;++r)c[e[r]]+=1;var n=0;for(r=58;r>0;--r){var t=n+c[r]>>1;c[r]=n,n=t}for(r=0;r<i;++r){var a=e[r];a>0&&(e[r]=a|c[a]++<<6)}}(l)}function v(e){return 63&e}function h(e){return e>>6}const p={c:0,lc:0};function w(e,r,n,t){e=e<<8|V(n,t),r+=8,p.c=e,p.lc=r}const d={c:0,lc:0};function y(e,r,n,t,a,i,o,l,s,u){if(e==r){t<8&&(w(n,t,a,o),n=p.c,t=p.lc);var c=n>>(t-=8);c=new Uint8Array([c])[0];if(s.value+c>u)return!1;for(var f=l[s.value-1];c-- >0;)l[s.value++]=f}else{if(!(s.value<u))return!1;l[s.value++]=e}d.c=n,d.lc=t}function S(e){return 65535&e}function g(e){var r=S(e);return r>32767?r-65536:r}const b={a:0,b:0};function m(e,r){var n=g(e),t=g(r),a=n+(1&t)+(t>>1),i=a,o=a-t;b.a=i,b.b=o}function A(e,r){var n=S(e),t=S(r),a=n-(t>>1)&65535,i=t+a-32768&65535;b.a=i,b.b=a}function U(e,r,n,t,a,i,o){for(var l,s=o<16384,u=n>a?a:n,c=1;c<=u;)c<<=1;for(l=c>>=1,c>>=1;c>=1;){for(var f,v,h,p,w=0,d=w+i*(a-l),y=i*c,S=i*l,g=t*c,U=t*l;w<=d;w+=S){for(var M=w,z=w+t*(n-l);M<=z;M+=U){var C=M+g,E=(O=M+y)+g;s?(m(e[M+r],e[O+r]),f=b.a,h=b.b,m(e[C+r],e[E+r]),v=b.a,p=b.b,m(f,v),e[M+r]=b.a,e[C+r]=b.b,m(h,p),e[O+r]=b.a,e[E+r]=b.b):(A(e[M+r],e[O+r]),f=b.a,h=b.b,A(e[C+r],e[E+r]),v=b.a,p=b.b,A(f,v),e[M+r]=b.a,e[C+r]=b.b,A(h,p),e[O+r]=b.a,e[E+r]=b.b)}if(n&c){var O=M+y;s?m(e[M+r],e[O+r]):A(e[M+r],e[O+r]),f=b.a,e[O+r]=b.b,e[M+r]=f}}if(a&c)for(M=w,z=w+t*(n-l);M<=z;M+=U){C=M+g;s?m(e[M+r],e[C+r]):A(e[M+r],e[C+r]),f=b.a,e[C+r]=b.b,e[M+r]=f}l=c,c>>=1}return w}function M(e,r,n,t,l,s){var u=n.value,c=H(r,n),S=H(r,n);n.value+=4;var g=H(r,n);if(n.value+=4,c<0||c>=i||S<0||S>=i)throw"Something wrong with HUF_ENCSIZE";var b=new Array(i),m=new Array(o);if(function(e){for(var r=0;r<o;r++)e[r]={},e[r].len=0,e[r].lit=0,e[r].p=null}(m),f(e,0,n,t-(n.value-u),c,S,b),g>8*(t-(n.value-u)))throw"Something wrong with hufUncompress";!function(e,r,n,t){for(;r<=n;r++){var i=h(e[r]),o=v(e[r]);if(i>>o)throw"Invalid table entry";if(o>a){if((c=t[i>>o-a]).len)throw"Invalid table entry";if(c.lit++,c.p){var l=c.p;c.p=new Array(c.lit);for(var s=0;s<c.lit-1;++s)c.p[s]=l[s]}else c.p=new Array(1);c.p[c.lit-1]=r}else if(o){var u=0;for(s=1<<a-o;s>0;s--){var c;if((c=t[(i<<a-o)+u]).len||c.p)throw"Invalid table entry";c.len=o,c.lit=r,u++}}}}(b,c,S,m),function(e,r,n,t,i,o,l,s,u,c){for(var f=0,S=0,g=s,b=Math.trunc(i.value+(o+7)/8);i.value<b;)for(w(f,S,n,i),f=p.c,S=p.lc;S>=a;)if((M=r[f>>S-a&16383]).len)S-=M.len,y(M.lit,l,f,S,n,0,i,u,c,g),f=d.c,S=d.lc;else{if(!M.p)throw"hufDecode issues";var m;for(m=0;m<M.lit;m++){for(var A=v(e[M.p[m]]);S<A&&i.value<b;)w(f,S,n,i),f=p.c,S=p.lc;if(S>=A&&h(e[M.p[m]])==(f>>S-A&(1<<A)-1)){S-=A,y(M.p[m],l,f,S,n,0,i,u,c,g),f=d.c,S=d.lc;break}}if(m==M.lit)throw"hufDecode issues"}var U=8-o&7;for(f>>=U,S-=U;S>0;){var M;if(!(M=r[f<<a-S&16383]).len)throw"hufDecode issues";S-=M.len,y(M.lit,l,f,S,n,0,i,u,c,g),f=d.c,S=d.lc}}(b,m,e,0,n,g,S,s,l,{value:0})}function z(e){for(var r=1;r<e.length;r++){var n=e[r-1]+e[r]-128;e[r]=n}}function C(e,r){for(var n=0,t=Math.floor((e.length+1)/2),a=0,i=e.length-1;!(a>i||(r[a++]=e[n++],a>i));)r[a++]=e[t++]}function E(e){for(var r=e.byteLength,n=new Array,t=0,a=new DataView(e);r>0;){var i=a.getInt8(t++);if(i<0){r-=(l=-i)+1;for(var o=0;o<l;o++)n.push(a.getUint8(t++))}else{var l=i;r-=2;var s=a.getUint8(t++);for(o=0;o<l+1;o++)n.push(s)}}return n}function O(e,r,n){for(var t,a=1;a<64;)65280==(t=r[e.value])?a=64:t>>8==255?a+=255&t:(n[a]=t,a++),e.value++}function R(e,r){r[0]=q(e[0]),r[1]=q(e[1]),r[2]=q(e[5]),r[3]=q(e[6]),r[4]=q(e[14]),r[5]=q(e[15]),r[6]=q(e[27]),r[7]=q(e[28]),r[8]=q(e[2]),r[9]=q(e[4]),r[10]=q(e[7]),r[11]=q(e[13]),r[12]=q(e[16]),r[13]=q(e[26]),r[14]=q(e[29]),r[15]=q(e[42]),r[16]=q(e[3]),r[17]=q(e[8]),r[18]=q(e[12]),r[19]=q(e[17]),r[20]=q(e[25]),r[21]=q(e[30]),r[22]=q(e[41]),r[23]=q(e[43]),r[24]=q(e[9]),r[25]=q(e[11]),r[26]=q(e[18]),r[27]=q(e[24]),r[28]=q(e[31]),r[29]=q(e[40]),r[30]=q(e[44]),r[31]=q(e[53]),r[32]=q(e[10]),r[33]=q(e[19]),r[34]=q(e[23]),r[35]=q(e[32]),r[36]=q(e[39]),r[37]=q(e[45]),r[38]=q(e[52]),r[39]=q(e[54]),r[40]=q(e[20]),r[41]=q(e[22]),r[42]=q(e[33]),r[43]=q(e[38]),r[44]=q(e[46]),r[45]=q(e[51]),r[46]=q(e[55]),r[47]=q(e[60]),r[48]=q(e[21]),r[49]=q(e[34]),r[50]=q(e[37]),r[51]=q(e[47]),r[52]=q(e[50]),r[53]=q(e[56]),r[54]=q(e[59]),r[55]=q(e[61]),r[56]=q(e[35]),r[57]=q(e[36]),r[58]=q(e[48]),r[59]=q(e[49]),r[60]=q(e[57]),r[61]=q(e[58]),r[62]=q(e[62]),r[63]=q(e[63])}function I(e){const r=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),t=.5*Math.cos(3.14159/8),a=.5*Math.cos(3*3.14159/16),i=.5*Math.cos(.981746875),o=.5*Math.cos(3*3.14159/8),l=.5*Math.cos(1.374445625);for(var s=new Array(4),u=new Array(4),c=new Array(4),f=new Array(4),v=0;v<8;++v){var h=8*v;s[0]=t*e[h+2],s[1]=o*e[h+2],s[2]=t*e[h+6],s[3]=o*e[h+6],u[0]=n*e[h+1]+a*e[h+3]+i*e[h+5]+l*e[h+7],u[1]=a*e[h+1]-l*e[h+3]-n*e[h+5]-i*e[h+7],u[2]=i*e[h+1]-n*e[h+3]+l*e[h+5]+a*e[h+7],u[3]=l*e[h+1]-i*e[h+3]+a*e[h+5]-n*e[h+7],c[0]=r*(e[h+0]+e[h+4]),c[3]=r*(e[h+0]-e[h+4]),c[1]=s[0]+s[3],c[2]=s[1]-s[2],f[0]=c[0]+c[1],f[1]=c[3]+c[2],f[2]=c[3]-c[2],f[3]=c[0]-c[1],e[h+0]=f[0]+u[0],e[h+1]=f[1]+u[1],e[h+2]=f[2]+u[2],e[h+3]=f[3]+u[3],e[h+4]=f[3]-u[3],e[h+5]=f[2]-u[2],e[h+6]=f[1]-u[1],e[h+7]=f[0]-u[0]}for(var p=0;p<8;++p)s[0]=t*e[16+p],s[1]=o*e[16+p],s[2]=t*e[48+p],s[3]=o*e[48+p],u[0]=n*e[8+p]+a*e[24+p]+i*e[40+p]+l*e[56+p],u[1]=a*e[8+p]-l*e[24+p]-n*e[40+p]-i*e[56+p],u[2]=i*e[8+p]-n*e[24+p]+l*e[40+p]+a*e[56+p],u[3]=l*e[8+p]-i*e[24+p]+a*e[40+p]-n*e[56+p],c[0]=r*(e[p]+e[32+p]),c[3]=r*(e[p]-e[32+p]),c[1]=s[0]+s[3],c[2]=s[1]-s[2],f[0]=c[0]+c[1],f[1]=c[3]+c[2],f[2]=c[3]-c[2],f[3]=c[0]-c[1],e[0+p]=f[0]+u[0],e[8+p]=f[1]+u[1],e[16+p]=f[2]+u[2],e[24+p]=f[3]+u[3],e[32+p]=f[3]-u[3],e[40+p]=f[2]-u[2],e[48+p]=f[1]-u[1],e[56+p]=f[0]-u[0]}function x(e){for(var r=0;r<64;++r){var n=e[0][r],t=e[1][r],a=e[2][r];e[0][r]=n+1.5747*a,e[1][r]=n-.1873*t-.4682*a,e[2][r]=n+1.8556*t}}function k(r,n,t){for(var a=0;a<64;++a)n[t+a]=e.DataUtils.toHalfFloat(P(r[a]))}function P(e){return e<=1?Math.sign(e)*Math.pow(Math.abs(e),2.2):Math.sign(e)*Math.pow(l,Math.abs(e)-1)}function N(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function D(e){var r=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(E(r)),t=new Uint8Array(n.length);return z(n),C(n,t),new DataView(t.buffer)}function L(e){var n=e.array.slice(e.offset.value,e.offset.value+e.size),t=r.unzlibSync(n),a=new Uint8Array(t.length);return z(t),C(t,a),new DataView(a.buffer)}function _(e){for(var r=e.viewer,n={value:e.offset.value},a=new Uint16Array(e.width*e.scanlineBlockSize*(e.channels*e.type)),i=new Uint8Array(8192),o=0,l=new Array(e.channels),s=0;s<e.channels;s++)l[s]={},l[s].start=o,l[s].end=l[s].start,l[s].nx=e.width,l[s].ny=e.lines,l[s].size=e.type,o+=l[s].nx*l[s].ny*l[s].size;var u=j(r,n),c=j(r,n);if(c>=8192)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(u<=c)for(s=0;s<c-u+1;s++)i[s+u]=W(r,n);var f=new Uint16Array(t),v=function(e,r){for(var n=0,a=0;a<t;++a)(0==a||e[a>>3]&1<<(7&a))&&(r[n++]=a);for(var i=n-1;n<t;)r[n++]=0;return i}(i,f),h=H(r,n);M(e.array,r,n,h,a,o);for(s=0;s<e.channels;++s)for(var p=l[s],w=0;w<l[s].size;++w)U(a,p.start+w,p.nx,p.size,p.ny,p.nx*p.size,v);!function(e,r,n){for(var t=0;t<n;++t)r[t]=e[r[t]]}(f,a,o);for(var d=0,y=new Uint8Array(a.buffer.byteLength),S=0;S<e.lines;S++)for(var g=0;g<e.channels;g++){var b=(p=l[g]).nx*p.size,m=new Uint8Array(a.buffer,2*p.end,2*b);y.set(m,d),d+=2*b,p.end+=b}return new DataView(y.buffer)}function T(e){var n=e.array.slice(e.offset.value,e.offset.value+e.size),t=r.unzlibSync(n);const a=e.lines*e.channels*e.width,i=1==e.type?new Uint16Array(a):new Uint32Array(a);let o=0,l=0;const s=new Array(4);for(let r=0;r<e.lines;r++)for(let r=0;r<e.channels;r++){let r=0;switch(e.type){case 1:s[0]=o,s[1]=s[0]+e.width,o=s[1]+e.width;for(let n=0;n<e.width;++n){r+=t[s[0]++]<<8|t[s[1]++],i[l]=r,l++}break;case 2:s[0]=o,s[1]=s[0]+e.width,s[2]=s[1]+e.width,o=s[2]+e.width;for(let n=0;n<e.width;++n){r+=t[s[0]++]<<24|t[s[1]++]<<16|t[s[2]++]<<8,i[l]=r,l++}}}return new DataView(i.buffer)}function F(e){var n=e.viewer,t={value:e.offset.value},a=new Uint8Array(e.width*e.lines*(e.channels*e.type*2)),i={version:Z(n,t),unknownUncompressedSize:Z(n,t),unknownCompressedSize:Z(n,t),acCompressedSize:Z(n,t),dcCompressedSize:Z(n,t),rleCompressedSize:Z(n,t),rleUncompressedSize:Z(n,t),rleRawSize:Z(n,t),totalAcUncompressedCount:Z(n,t),totalDcUncompressedCount:Z(n,t),acCompression:Z(n,t)};if(i.version<2)throw"EXRLoader.parse: "+re.compression+" version "+i.version+" is unsupported";for(var o=new Array,l=j(n,t)-2;l>0;){var s=X(n.buffer,t),u=W(n,t),c=u>>2&3,f=new Int8Array([(u>>4)-1])[0],v=W(n,t);o.push({name:s,index:f,type:v,compression:c}),l-=s.length+3}for(var h=re.channels,p=new Array(e.channels),w=0;w<e.channels;++w){var d=p[w]={},y=h[w];d.name=y.name,d.compression=0,d.decoded=!1,d.type=y.pixelType,d.pLinear=y.pLinear,d.width=e.width,d.height=e.lines}for(var S={idx:new Array(3)},g=0;g<e.channels;++g)for(d=p[g],w=0;w<o.length;++w){var b=o[w];d.name==b.name&&(d.compression=b.compression,b.index>=0&&(S.idx[b.index]=g),d.offset=g)}if(i.acCompressedSize>0)switch(i.acCompression){case 0:var m=new Uint16Array(i.totalAcUncompressedCount);M(e.array,n,t,i.acCompressedSize,m,i.totalAcUncompressedCount);break;case 1:var A=e.array.slice(t.value,t.value+i.totalAcUncompressedCount),U=r.unzlibSync(A);m=new Uint16Array(U.buffer);t.value+=i.totalAcUncompressedCount}if(i.dcCompressedSize>0){var z={array:e.array,offset:t,size:i.dcCompressedSize},C=new Uint16Array(L(z).buffer);t.value+=i.dcCompressedSize}if(i.rleRawSize>0){A=e.array.slice(t.value,t.value+i.rleCompressedSize);var P=E((U=r.unzlibSync(A)).buffer);t.value+=i.rleCompressedSize}var N=0,D=new Array(p.length);for(w=0;w<D.length;++w)D[w]=new Array;for(var _=0;_<e.lines;++_)for(var T=0;T<p.length;++T)D[T].push(N),N+=p[T].width*e.type*2;!function(e,r,n,t,a,i){var o=new DataView(i.buffer),l=n[e.idx[0]].width,s=n[e.idx[0]].height,u=Math.floor(l/8),c=Math.ceil(l/8),f=Math.ceil(s/8),v=l-8*(c-1),h=s-8*(f-1),p={value:0},w=new Array(3),d=new Array(3),y=new Array(3),S=new Array(3),g=new Array(3);for(let n=0;n<3;++n)g[n]=r[e.idx[n]],w[n]=n<1?0:w[n-1]+c*f,d[n]=new Float32Array(64),y[n]=new Uint16Array(64),S[n]=new Uint16Array(64*c);for(let r=0;r<f;++r){var b=8;r==f-1&&(b=h);var m=8;for(let e=0;e<c;++e){e==c-1&&(m=v);for(let e=0;e<3;++e)y[e].fill(0),y[e][0]=a[w[e]++],O(p,t,y[e]),R(y[e],d[e]),I(d[e]);x(d);for(let r=0;r<3;++r)k(d[r],S[r],64*e)}let i=0;for(let t=0;t<3;++t){const a=n[e.idx[t]].type;for(let e=8*r;e<8*r+b;++e){i=g[t][e];for(let r=0;r<u;++r){const n=64*r+8*(7&e);o.setUint16(i+0*a,S[t][n+0],!0),o.setUint16(i+2*a,S[t][n+1],!0),o.setUint16(i+4*a,S[t][n+2],!0),o.setUint16(i+6*a,S[t][n+3],!0),o.setUint16(i+8*a,S[t][n+4],!0),o.setUint16(i+10*a,S[t][n+5],!0),o.setUint16(i+12*a,S[t][n+6],!0),o.setUint16(i+14*a,S[t][n+7],!0),i+=16*a}}if(u!=c)for(let e=8*r;e<8*r+b;++e){const r=g[t][e]+8*u*2*a,n=64*u+8*(7&e);for(let e=0;e<m;++e)o.setUint16(r+2*e*a,S[t][n+e],!0)}}}for(var A=new Uint16Array(l),U=(o=new DataView(i.buffer),0);U<3;++U){n[e.idx[U]].decoded=!0;var M=n[e.idx[U]].type;if(2==n[U].type)for(var z=0;z<s;++z){const e=g[U][z];for(var C=0;C<l;++C)A[C]=o.getUint16(e+2*C*M,!0);for(C=0;C<l;++C)o.setFloat32(e+2*C*M,q(A[C]),!0)}}}(S,D,p,m,C,a);for(w=0;w<p.length;++w){if(!(d=p[w]).decoded)switch(d.compression){case 2:var F=0,B=0;for(_=0;_<e.lines;++_){for(var H=D[w][F],V=0;V<d.width;++V){for(var Y=0;Y<2*d.type;++Y)a[H++]=P[B+Y*d.width*d.height];B++}F++}break;case 1:default:throw"EXRLoader.parse: unsupported channel compression"}}return new DataView(a.buffer)}function X(e,r){for(var n=new Uint8Array(e),t=0;0!=n[r.value+t];)t+=1;var a=(new TextDecoder).decode(n.slice(r.value,r.value+t));return r.value=r.value+t+1,a}function B(e,r){var n=e.getInt32(r.value,!0);return r.value=r.value+4,n}function H(e,r){var n=e.getUint32(r.value,!0);return r.value=r.value+4,n}function V(e,r){var n=e[r.value];return r.value=r.value+1,n}function W(e,r){var n=e.getUint8(r.value);return r.value=r.value+1,n}function Z(e,r){var n=Number(e.getBigInt64(r.value,!0));return r.value+=8,n}function Y(e,r){var n=e.getFloat32(r.value,!0);return r.value+=4,n}function G(r,n){return e.DataUtils.toHalfFloat(Y(r,n))}function q(e){var r=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(r?31===r?n?NaN:1/0:Math.pow(2,r-15)*(1+n/1024):n/1024*6103515625e-14)}function j(e,r){var n=e.getUint16(r.value,!0);return r.value+=2,n}function $(e,r){return q(j(e,r))}function J(e,r,n,t,a){return"string"===t||"stringvector"===t||"iccProfile"===t?function(e,r,n){var t=(new TextDecoder).decode(new Uint8Array(e).slice(r.value,r.value+n));return r.value=r.value+n,t}(r,n,a):"chlist"===t?function(e,r,n,t){for(var a=n.value,i=[];n.value<a+t-1;){var o=X(r,n),l=B(e,n),s=W(e,n);n.value+=3;var u=B(e,n),c=B(e,n);i.push({name:o,pixelType:l,pLinear:s,xSampling:u,ySampling:c})}return n.value+=1,i}(e,r,n,a):"chromaticities"===t?function(e,r){return{redX:Y(e,r),redY:Y(e,r),greenX:Y(e,r),greenY:Y(e,r),blueX:Y(e,r),blueY:Y(e,r),whiteX:Y(e,r),whiteY:Y(e,r)}}(e,n):"compression"===t?function(e,r){return["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"][W(e,r)]}(e,n):"box2i"===t?function(e,r){return{xMin:H(e,r),yMin:H(e,r),xMax:H(e,r),yMax:H(e,r)}}(e,n):"lineOrder"===t?function(e,r){return["INCREASING_Y"][W(e,r)]}(e,n):"float"===t?Y(e,n):"v2f"===t?function(e,r){return[Y(e,r),Y(e,r)]}(e,n):"v3f"===t?function(e,r){return[Y(e,r),Y(e,r),Y(e,r)]}(e,n):"int"===t?B(e,n):"rational"===t?function(e,r){return[B(e,r),H(e,r)]}(e,n):"timecode"===t?function(e,r){return[H(e,r),H(e,r)]}(e,n):"preview"===t?(n.value+=a,"skipped"):void(n.value+=a)}const K=new DataView(n),Q=new Uint8Array(n),ee={value:0},re=function(e,r,n){const t={};if(20000630!=e.getUint32(0,!0))throw"THREE.EXRLoader: provided file doesn't appear to be in OpenEXR format.";t.version=e.getUint8(4,!0);const a=e.getUint8(5,!0);t.spec={singleTile:!!(1&a),longName:!!(2&a),deepFormat:!!(4&a),multiPart:!!(8&a)},n.value=8;for(var i=!0;i;){var o=X(r,n);if(0==o)i=!1;else{var l=X(r,n),s=J(e,r,n,l,H(e,n));void 0===s?console.warn(`EXRLoader.parse: skipped unknown header attribute type '${l}'.`):t[o]=s}}if(0!=a)throw console.error("EXRHeader:",t),"THREE.EXRLoader: provided file is currently unsupported.";return t}(K,n,ee),ne=function(r,n,t,a,i){const o={size:0,viewer:n,array:t,offset:a,width:r.dataWindow.xMax-r.dataWindow.xMin+1,height:r.dataWindow.yMax-r.dataWindow.yMin+1,channels:r.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:r.channels[0].pixelType,uncompress:null,getter:null,format:null,encoding:null};switch(r.compression){case"NO_COMPRESSION":o.lines=1,o.uncompress=N;break;case"RLE_COMPRESSION":o.lines=1,o.uncompress=D;break;case"ZIPS_COMPRESSION":o.lines=1,o.uncompress=L;break;case"ZIP_COMPRESSION":o.lines=16,o.uncompress=L;break;case"PIZ_COMPRESSION":o.lines=32,o.uncompress=_;break;case"PXR24_COMPRESSION":o.lines=16,o.uncompress=T;break;case"DWAA_COMPRESSION":o.lines=32,o.uncompress=F;break;case"DWAB_COMPRESSION":o.lines=256,o.uncompress=F;break;default:throw"EXRLoader.parse: "+r.compression+" is unsupported"}if(o.scanlineBlockSize=o.lines,1==o.type)switch(i){case e.FloatType:o.getter=$,o.inputSize=2;break;case e.HalfFloatType:o.getter=j,o.inputSize=2}else{if(2!=o.type)throw"EXRLoader.parse: unsupported pixelType "+o.type+" for "+r.compression+".";switch(i){case e.FloatType:o.getter=Y,o.inputSize=4;break;case e.HalfFloatType:o.getter=G,o.inputSize=4}}o.blockCount=(r.dataWindow.yMax+1)/o.scanlineBlockSize;for(var l=0;l<o.blockCount;l++)Z(n,a);o.outputChannels=3==o.channels?4:o.channels;const s=o.width*o.height*o.outputChannels;switch(i){case e.FloatType:o.byteArray=new Float32Array(s),o.channels<o.outputChannels&&o.byteArray.fill(1,0,s);break;case e.HalfFloatType:o.byteArray=new Uint16Array(s),o.channels<o.outputChannels&&o.byteArray.fill(15360,0,s);break;default:console.error("THREE.EXRLoader: unsupported type: ",i)}return o.bytesPerLine=o.width*o.inputSize*o.channels,4==o.outputChannels?(o.format=e.RGBAFormat,o.encoding=e.LinearEncoding):(o.format=e.RedFormat,o.encoding=e.LinearEncoding),o}(re,K,Q,ee,this.type),te={value:0},ae={R:0,G:1,B:2,A:3,Y:0};for(let e=0;e<ne.height/ne.scanlineBlockSize;e++){const r=H(K,ee);ne.size=H(K,ee),ne.lines=r+ne.scanlineBlockSize>ne.height?ne.height-r:ne.scanlineBlockSize;const n=ne.size<ne.lines*ne.bytesPerLine?ne.uncompress(ne):N(ne);ee.value+=ne.size;for(let r=0;r<ne.scanlineBlockSize;r++){const t=r+e*ne.scanlineBlockSize;if(t>=ne.height)break;for(let e=0;e<ne.channels;e++){const a=ae[re.channels[e].name];for(let i=0;i<ne.width;i++){te.value=(r*(ne.channels*ne.width)+e*ne.width+i)*ne.inputSize;const o=(ne.height-1-t)*(ne.width*ne.outputChannels)+i*ne.outputChannels+a;ne.byteArray[o]=ne.getter(n,te)}}}}return{header:re,width:ne.width,height:ne.height,data:ne.byteArray,format:ne.format,encoding:ne.encoding,type:this.type}}setDataType(e){return this.type=e,this}load(r,n,t,a){return super.load(r,(function(r,t){r.encoding=t.encoding,r.minFilter=e.LinearFilter,r.magFilter=e.LinearFilter,r.generateMipmaps=!1,r.flipY=!1,n&&n(r,t)}),t,a)}}exports.EXRLoader=n;