@mappedin/mappedin-js 5.29.3 → 5.29.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/get-venue/index.js +1 -1
- package/lib/esm/renderer/GLTFExporter-WBR76LPH.js +1 -0
- package/lib/esm/renderer/{PerformanceController-GBMI5FEK.js → PerformanceController-LO3FX7PQ.js} +1 -1
- package/lib/esm/renderer/{browser-FAMZHU6S.js → browser-JMP5BYCM.js} +1 -1
- package/lib/esm/renderer/chunk-2URYF3VL.js +1 -0
- package/lib/esm/renderer/{chunk-6I3JZBVK.js → chunk-4X2NC5DX.js} +1 -1
- package/lib/esm/renderer/chunk-7N37G36W.js +1 -0
- package/lib/esm/renderer/index.d.ts +12 -2
- package/lib/esm/renderer/index.js +1 -1
- package/lib/esm/renderer/{outdoor-context-LCBNZGDA.js → outdoor-context-X4AP3O4S.js} +1 -1
- package/lib/mappedin.js +1 -1
- package/lib/node/index.js +1 -1
- package/package.json +2 -2
- package/lib/esm/renderer/GLTFExporter-FMMECZUJ.js +0 -1
- package/lib/esm/renderer/chunk-EPUV4SBJ.js +0 -1
- package/lib/esm/renderer/chunk-I5VIUPV4.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mappedin/mappedin-js",
|
|
3
|
-
"version": "5.29.
|
|
3
|
+
"version": "5.29.4",
|
|
4
4
|
"main": "lib/esm/renderer/index.js",
|
|
5
5
|
"module": "lib/esm/renderer/index.js",
|
|
6
6
|
"browser": "lib/esm/renderer/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"jest-fetch-mock": "^3.0.3",
|
|
34
34
|
"jest-three": "^1.3.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "83780b6719317dbe159321ff66aea2872c5ba230",
|
|
37
37
|
"volta": {
|
|
38
38
|
"extends": "../package.json"
|
|
39
39
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as Re,B as Ne,C as be,D as Se,N as z,P as _e,Qa as v,V as k,Y as Ue,aa as Le,ca as O,e as de,j as ge,k as xe,l as me,m as Te,n as ye,o as we,p as Me,q as Ie,r as Ae,ra as F,x as Ee}from"./chunk-EPUV4SBJ.js";import{a as pe}from"./chunk-I5VIUPV4.js";import{a as T}from"./chunk-ZRT45YCM.js";pe();var Ce={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},ee=class{constructor(){this.pluginCallbacks=[],this.register((function(e){return new Y(e)})),this.register((function(e){return new j(e)})),this.register((function(e){return new W(e)})),this.register((function(e){return new X(e)})),this.register((function(e){return new J(e)})),this.register((function(e){return new Z(e)})),this.register((function(e){return new K(e)})),this.register((function(e){return new q(e)})),this.register((function(e){return new Q(e)})),this.register((function(e){return new $(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,r){let i=new G,n=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)n.push(this.pluginCallbacks[e](i));i.setPlugins(n),i.write(e,t,r).catch(s)}parseAsync(e,t){let s=this;return new Promise((function(r,i){s.parse(e,r,i,t)}))}};T(ee,"GLTFExporter");var P=ee,g={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},H="KHR_mesh_quantization",N={};N[Te]=g.NEAREST,N[ye]=g.NEAREST_MIPMAP_NEAREST,N[we]=g.NEAREST_MIPMAP_LINEAR,N[Me]=g.LINEAR,N[Ie]=g.LINEAR_MIPMAP_NEAREST,N[Ae]=g.LINEAR_MIPMAP_LINEAR,N[xe]=g.CLAMP_TO_EDGE,N[ge]=g.REPEAT,N[me]=g.MIRRORED_REPEAT;var Oe={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Fe=new Le,ve=12,He=1179937895,Ve=2,De=8,Ge=1313821514,Ye=5130562;function D(e,t){return e.length===t.length&&e.every((function(e,s){return e===t[s]}))}function je(e){return(new TextEncoder).encode(e).buffer}function Ke(e){return D(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function qe(e,t,s){let r={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=t;i<t+s;i++)for(let t=0;t<e.itemSize;t++){let s;e.itemSize>4?s=e.array[i*e.itemSize+t]:(0===t?s=e.getX(i):1===t?s=e.getY(i):2===t?s=e.getZ(i):3===t&&(s=e.getW(i)),!0===e.normalized&&(s=z.normalize(s,e.array))),r.min[t]=Math.min(r.min[t],s),r.max[t]=Math.max(r.max[t],s)}return r}function Be(e){return 4*Math.ceil(e/4)}function V(e,t=0){let s=Be(e.byteLength);if(s!==e.byteLength){let r=new Uint8Array(s);if(r.set(new Uint8Array(e)),0!==t)for(let i=e.byteLength;i<s;i++)r[i]=t;return r.buffer}return e}function ze(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function Pe(e,t){if(void 0!==e.toBlob)return new Promise((s=>e.toBlob(s,t)));let s;return"image/jpeg"===t?s=.92:"image/webp"===t&&(s=.8),e.convertToBlob({type:t,quality:s})}T(D,"equalArray"),T(je,"stringToArrayBuffer"),T(Ke,"isIdentityMatrix"),T(qe,"getMinMax"),T(Be,"getPaddedBufferSize"),T(V,"getPaddedArrayBuffer"),T(ze,"getCanvas"),T(Pe,"getToBlobPromise");var se=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,s={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},s),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);let r=this,i=r.buffers,n=r.json;s=r.options;let a=r.extensionsUsed,o=r.extensionsRequired,l=new Blob(i,{type:"application/octet-stream"}),u=Object.keys(a),h=Object.keys(o);if(u.length>0&&(n.extensionsUsed=u),h.length>0&&(n.extensionsRequired=h),n.buffers&&n.buffers.length>0&&(n.buffers[0].byteLength=l.size),!0===s.binary){let e=new FileReader;e.readAsArrayBuffer(l),e.onloadend=function(){let s=V(e.result),r=new DataView(new ArrayBuffer(De));r.setUint32(0,s.byteLength,!0),r.setUint32(4,Ye,!0);let i=V(je(JSON.stringify(n)),32),a=new DataView(new ArrayBuffer(De));a.setUint32(0,i.byteLength,!0),a.setUint32(4,Ge,!0);let o=new ArrayBuffer(ve),l=new DataView(o);l.setUint32(0,He,!0),l.setUint32(4,Ve,!0);let u=ve+a.byteLength+i.byteLength+r.byteLength+s.byteLength;l.setUint32(8,u,!0);let h=new Blob([o,a,i,r,s],{type:"application/octet-stream"}),c=new FileReader;c.readAsArrayBuffer(h),c.onloadend=function(){t(c.result)}}}else if(n.buffers&&n.buffers.length>0){let e=new FileReader;e.readAsDataURL(l),e.onloadend=function(){let s=e.result;n.buffers[0].uri=s,t(n)}}else t(n)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let s=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(s.includeCustomExtensions&&i.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(let e in i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new k;for(let s=0,r=e.count;s<r;s++)if(Math.abs(t.fromBufferAttribute(e,s).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let s=e.clone(),r=new k;for(let e=0,t=s.count;e<t;e++)r.fromBufferAttribute(s,e),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),s.setXYZ(e,r.x,r.y,r.z);return t.attributesNormalized.set(e,s),s}applyTextureTransform(e,t){let s=!1,r={};(0!==t.offset.x||0!==t.offset.y)&&(r.offset=t.offset.toArray(),s=!0),0!==t.rotation&&(r.rotation=t.rotation,s=!0),(1!==t.repeat.x||1!==t.repeat.y)&&(r.scale=t.repeat.toArray(),s=!0),s&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function s(e){return e.encoding===Se?T((function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}),"SRGBToLinear"):T((function(e){return e}),"LinearToLinear")}T(s,"getEncodingConversion"),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");let r=e?e.image:null,i=t?t.image:null,n=Math.max(r?r.width:0,i?i.width:0),a=Math.max(r?r.height:0,i?i.height:0),o=ze();o.width=n,o.height=a;let l=o.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,n,a);let u=l.getImageData(0,0,n,a);if(r){l.drawImage(r,0,0,n,a);let t=s(e),i=l.getImageData(0,0,n,a).data;for(let e=2;e<i.length;e+=4)u.data[e]=256*t(i[e]/256)}if(i){l.drawImage(i,0,0,n,a);let e=s(t),r=l.getImageData(0,0,n,a).data;for(let t=1;t<r.length;t+=4)u.data[t]=256*e(r[t]/256)}l.putImageData(u,0,0);let h=(e||t).clone();return h.source=new _e(o),h.encoding=be,h}processBuffer(e){let t=this.json,s=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),s.push(e),0}processBufferView(e,t,s,r,i){let n,a=this.json;switch(a.bufferViews||(a.bufferViews=[]),t){case g.BYTE:case g.UNSIGNED_BYTE:n=1;break;case g.SHORT:case g.UNSIGNED_SHORT:n=2;break;default:n=4}let o=Be(r*e.itemSize*n),l=new DataView(new ArrayBuffer(o)),u=0;for(let i=s;i<s+r;i++)for(let s=0;s<e.itemSize;s++){let r;e.itemSize>4?r=e.array[i*e.itemSize+s]:(0===s?r=e.getX(i):1===s?r=e.getY(i):2===s?r=e.getZ(i):3===s&&(r=e.getW(i)),!0===e.normalized&&(r=z.normalize(r,e.array))),t===g.FLOAT?l.setFloat32(u,r,!0):t===g.INT?l.setInt32(u,r,!0):t===g.UNSIGNED_INT?l.setUint32(u,r,!0):t===g.SHORT?l.setInt16(u,r,!0):t===g.UNSIGNED_SHORT?l.setUint16(u,r,!0):t===g.BYTE?l.setInt8(u,r):t===g.UNSIGNED_BYTE&&l.setUint8(u,r),u+=n}let h={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==i&&(h.target=i),i===g.ARRAY_BUFFER&&(h.byteStride=e.itemSize*n),this.byteOffset+=o,a.bufferViews.push(h),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,s=t.json;return s.bufferViews||(s.bufferViews=[]),new Promise((function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=V(i.result),n={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(s.bufferViews.push(n)-1)}}))}processAccessor(e,t,s,r){let i,n=this.json;if(e.array.constructor===Float32Array)i=g.FLOAT;else if(e.array.constructor===Int32Array)i=g.INT;else if(e.array.constructor===Uint32Array)i=g.UNSIGNED_INT;else if(e.array.constructor===Int16Array)i=g.SHORT;else if(e.array.constructor===Uint16Array)i=g.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)i=g.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");i=g.UNSIGNED_BYTE}if(void 0===s&&(s=0),void 0===r&&(r=e.count),0===r)return null;let a,o=qe(e,s,r);void 0!==t&&(a=e===t.index?g.ELEMENT_ARRAY_BUFFER:g.ARRAY_BUFFER);let l=this.processBufferView(e,i,s,r,a),u={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:r,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(u.normalized=!0),n.accessors||(n.accessors=[]),n.accessors.push(u)-1}processImage(e,t,s,r="image/png"){if(null!==e){let i=this,n=i.cache,a=i.json,o=i.options,l=i.pending;n.images.has(e)||n.images.set(e,{});let u=n.images.get(e),h=r+":flipY/"+s.toString();if(void 0!==u[h])return u[h];a.images||(a.images=[]);let c={mimeType:r},p=ze();p.width=Math.min(e.width,o.maxTextureSize),p.height=Math.min(e.height,o.maxTextureSize);let m=p.getContext("2d");if(!0===s&&(m.translate(0,p.height),m.scale(1,-1)),void 0!==e.data){t!==Ee&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>o.maxTextureSize||e.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let s=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<s.length;t+=4)s[t+0]=e.data[t+0],s[t+1]=e.data[t+1],s[t+2]=e.data[t+2],s[t+3]=e.data[t+3];m.putImageData(new ImageData(s,e.width,e.height),0,0)}else m.drawImage(e,0,0,p.width,p.height);!0===o.binary?l.push(Pe(p,r).then((e=>i.processBufferViewImage(e))).then((e=>{c.bufferView=e}))):void 0!==p.toDataURL?c.uri=p.toDataURL(r):l.push(Pe(p,r).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{c.uri=e})));let g=a.images.push(c)-1;return u[h]=g,g}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let s={magFilter:N[e.magFilter],minFilter:N[e.minFilter],wrapS:N[e.wrapS],wrapT:N[e.wrapT]};return t.samplers.push(s)-1}processTexture(e){let t=this.cache,s=this.json;if(t.textures.has(e))return t.textures.get(e);s.textures||(s.textures=[]);let r=e.userData.mimeType;"image/webp"===r&&(r="image/png");let i={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(i.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,i)}));let n=s.textures.push(i)-1;return t.textures.set(e,n),n}processMaterial(e){let t=this.cache,s=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;s.materials||(s.materials=[]);let r={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let i=e.color.toArray().concat([e.opacity]);if(D(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),s={index:this.processTexture(t)};this.applyTextureTransform(s,t),r.pbrMetallicRoughness.metallicRoughnessTexture=s}if(e.map){let t={index:this.processTexture(e.map)};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap)};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===de&&(r.doubleSided=!0),""!==e.name&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,r)}));let n=s.materials.push(r)-1;return t.materials.set(e,n),n}processMesh(e){let t=this.cache,s=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,s=e.material.length;t<s;t++)r.push(e.material[t].uuid);else r.push(e.material.uuid);let i=r.join(":");if(t.meshes.has(i))return t.meshes.get(i);let n,a=e.geometry;n=e.isLineSegments?g.LINES:e.isLineLoop?g.LINE_LOOP:e.isLine?g.LINE_STRIP:e.isPoints?g.POINTS:e.material.wireframe?g.LINES:g.TRIANGLES;let o={},l={},u=[],h=[],c={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=a.getAttribute("normal");void 0!==p&&!this.isNormalizedNormalAttribute(p)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),a.setAttribute("normal",this.createNormalizedNormalAttribute(p)));let m=null;for(let e in a.attributes){if("morph"===e.slice(0,5))continue;let s=a.attributes[e];if(e=c[e]||e.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(s))){l[e]=t.attributes.get(this.getUID(s));continue}m=null;let r=s.array;"JOINTS_0"===e&&!(r instanceof Uint16Array)&&!(r instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),m=new O(new Uint16Array(r),s.itemSize,s.normalized));let i=this.processAccessor(m||s,a);null!==i&&(e.startsWith("_")||this.detectMeshQuantization(e,s),l[e]=i,t.attributes.set(this.getUID(s),i))}if(void 0!==p&&a.setAttribute("normal",p),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){let s=[],r=[],i={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let n=0;n<e.morphTargetInfluences.length;++n){let o={},l=!1;for(let e in a.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}let s=a.morphAttributes[e][n],r=e.toUpperCase(),i=a.attributes[e];if(t.attributes.has(this.getUID(s,!0))){o[r]=t.attributes.get(this.getUID(s,!0));continue}let u=s.clone();if(!a.morphTargetsRelative)for(let e=0,t=s.count;e<t;e++)for(let t=0;t<s.itemSize;t++)0===t&&u.setX(e,s.getX(e)-i.getX(e)),1===t&&u.setY(e,s.getY(e)-i.getY(e)),2===t&&u.setZ(e,s.getZ(e)-i.getZ(e)),3===t&&u.setW(e,s.getW(e)-i.getW(e));o[r]=this.processAccessor(u,a),t.attributes.set(this.getUID(i,!0),o[r])}h.push(o),s.push(e.morphTargetInfluences[n]),void 0!==e.morphTargetDictionary&&r.push(i[n])}o.weights=s,r.length>0&&(o.extras={},o.extras.targetNames=r)}let f=Array.isArray(e.material);if(f&&0===a.groups.length)return null;let d=f?e.material:[e.material],T=f?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,s=T.length;e<s;e++){let s={mode:n,attributes:l};if(this.serializeUserData(a,s),h.length>0&&(s.targets=h),null!==a.index){let r=this.getUID(a.index);(void 0!==T[e].start||void 0!==T[e].count)&&(r+=":"+T[e].start+":"+T[e].count),t.attributes.has(r)?s.indices=t.attributes.get(r):(s.indices=this.processAccessor(a.index,a,T[e].start,T[e].count),t.attributes.set(r,s.indices)),null===s.indices&&delete s.indices}let r=this.processMaterial(d[T[e].materialIndex]);null!==r&&(s.material=r),u.push(s)}o.primitives=u,s.meshes||(s.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,o)}));let x=s.meshes.push(o)-1;return t.meshes.set(i,x),x}detectMeshQuantization(e,t){if(this.extensionsUsed[H])return;let s;switch(t.array.constructor){case Int8Array:s="byte";break;case Uint8Array:s="unsigned byte";break;case Int16Array:s="short";break;case Uint16Array:s="unsigned short";break;default:return}t.normalized&&(s+=" normalized");let r=e.split("_",1)[0];Ce[r]&&Ce[r].includes(s)&&(this.extensionsUsed[H]=!0,this.extensionsRequired[H]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let s=e.isOrthographicCamera,r={type:s?"orthographic":"perspective"};return s?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:z.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let s=this.json,r=this.nodeMap;s.animations||(s.animations=[]);let i=(e=P.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,n=[],a=[];for(let e=0;e<i.length;++e){let s=i[e],o=v.parseTrackName(s.name),l=v.findNode(t,o.nodeName),u=Oe[o.propertyName];if("bones"===o.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(o.objectIndex):void 0),!l||!u)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',s.name),null;let h,c=1,p=s.values.length/s.times.length;u===Oe.morphTargetInfluences&&(p/=l.morphTargetInfluences.length),!0===s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(h="CUBICSPLINE",p/=3):h=s.getInterpolation()===Re?"STEP":"LINEAR",a.push({input:this.processAccessor(new O(s.times,c)),output:this.processAccessor(new O(s.values,p)),interpolation:h}),n.push({sampler:a.length-1,target:{node:r.get(l),path:u}})}return s.animations.push({name:e.name||"clip_"+s.animations.length,samplers:a,channels:n}),s.animations.length-1}processSkin(e){let t=this.json,s=this.nodeMap,r=t.nodes[s.get(e)],i=e.skeleton;if(void 0===i)return null;let n=e.skeleton.bones[0];if(void 0===n)return null;let a=[],o=new Float32Array(16*i.bones.length),l=new Ue;for(let t=0;t<i.bones.length;++t)a.push(s.get(i.bones[t])),l.copy(i.boneInverses[t]),l.multiply(e.bindMatrix).toArray(o,16*t);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new O(o,16)),joints:a,skeleton:s.get(n)}),r.skin=t.skins.length-1}processNode(e){let t=this.json,s=this.options,r=this.nodeMap;t.nodes||(t.nodes=[]);let i={};if(s.trs){let t=e.quaternion.toArray(),s=e.position.toArray(),r=e.scale.toArray();D(t,[0,0,0,1])||(i.rotation=t),D(s,[0,0,0])||(i.translation=s),D(r,[1,1,1])||(i.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===Ke(e.matrix)&&(i.matrix=e.matrix.elements);if(""!==e.name&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){let t=this.processMesh(e);null!==t&&(i.mesh=t)}else e.isCamera&&(i.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||!1===s.onlyVisible){let e=this.processNode(i);null!==e&&t.push(e)}}t.length>0&&(i.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,i)}));let n=t.nodes.push(i)-1;return r.set(e,n),n}processScene(e){let t=this.json,s=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||!1===s.onlyVisible){let e=this.processNode(r);null!==e&&i.push(e)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(e){let t=new F;t.name="AuxScene";for(let s=0;s<e.length;s++)t.children.push(e[s]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));let s=[];for(let t=0;t<e.length;t++)e[t]instanceof F?this.processScene(e[t]):s.push(e[t]);s.length>0&&this.processObjects(s);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let s=0;s<t.animations.length;++s)this.processAnimation(t.animations[s],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,s=this.plugins.length;t<s;t++)e(this.plugins[t])}};T(se,"GLTFWriter");var G=se,te=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);let s=this.writer,r=s.json,i=s.extensionsUsed,n={};e.name&&(n.name=e.name),n.color=e.color.toArray(),n.intensity=e.intensity,e.isDirectionalLight?n.type="directional":e.isPointLight?(n.type="point",e.distance>0&&(n.range=e.distance)):e.isSpotLight&&(n.type="spot",e.distance>0&&(n.range=e.distance),n.spot={},n.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,n.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let a=r.extensions[this.name].lights;a.push(n),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}};T(te,"GLTFLightExtension");var Y=te,ne=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let s=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},s[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}};T(ne,"GLTFMaterialsUnlitExtension");var j=ne,ie=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let s=this.writer,r=s.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:s.processTexture(e.clearcoatMap)};s.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:s.processTexture(e.clearcoatRoughnessMap)};s.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:s.processTexture(e.clearcoatNormalMap)};s.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}};T(ie,"GLTFMaterialsClearcoatExtension");var K=ie,re=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let s=this.writer,r=s.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:s.processTexture(e.iridescenceMap)};s.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:s.processTexture(e.iridescenceThicknessMap)};s.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}};T(re,"GLTFMaterialsIridescenceExtension");var q=re,oe=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let s=this.writer,r=s.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:s.processTexture(e.transmissionMap)};s.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}};T(oe,"GLTFMaterialsTransmissionExtension");var W=oe,ae=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let s=this.writer,r=s.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:s.processTexture(e.thicknessMap)};s.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}};T(ae,"GLTFMaterialsVolumeExtension");var X=ae,ce=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let s=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}};T(ce,"GLTFMaterialsIorExtension");var J=ce,ue=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(Fe)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let s=this.writer,r=s.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:s.processTexture(e.specularIntensityMap)};s.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:s.processTexture(e.specularColorMap)};s.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}};T(ue,"GLTFMaterialsSpecularExtension");var Z=ue,le=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let s=this.writer,r=s.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:s.processTexture(e.sheenRoughnessMap)};s.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:s.processTexture(e.sheenColorMap)};s.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}};T(le,"GLTFMaterialsSheenExtension");var Q=le,fe=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let s=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}};T(fe,"GLTFMaterialsEmissiveStrengthExtension");var $=fe;P.Utils={insertKeyframe:function(e,t){let s,r=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),n=new e.ValueBufferType(e.values.length+r),a=e.createInterpolant(new e.ValueBufferType(r));if(0===e.times.length){i[0]=t;for(let e=0;e<r;e++)n[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;i[0]=t,i.set(e.times,1),n.set(a.evaluate(t),0),n.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),n.set(e.values,0),n.set(a.evaluate(t),e.values.length),s=i.length-1}else for(let o=0;o<e.times.length;o++){if(Math.abs(e.times[o]-t)<.001)return o;if(e.times[o]<t&&e.times[o+1]>t){i.set(e.times.slice(0,o+1),0),i[o+1]=t,i.set(e.times.slice(o+1),o+2),n.set(e.values.slice(0,(o+1)*r),0),n.set(a.evaluate(t),(o+1)*r),n.set(e.values.slice((o+1)*r),(o+2)*r),s=o+1;break}}return e.times=i,e.values=n,s},mergeMorphTargetTracks:function(e,t){let s=[],r={},i=e.tracks;for(let e=0;e<i.length;++e){let n=i[e],a=v.parseTrackName(n.name),o=v.findNode(t,a.nodeName);if("morphTargetInfluences"!==a.propertyName||void 0===a.propertyIndex){s.push(n);continue}if(n.createInterpolant!==n.InterpolantFactoryMethodDiscrete&&n.createInterpolant!==n.InterpolantFactoryMethodLinear){if(n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),n=n.clone(),n.setInterpolation(Ne)}let l,u=o.morphTargetInfluences.length,h=o.morphTargetDictionary[a.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);if(void 0===r[o.uuid]){l=n.clone();let e=new l.ValueBufferType(u*l.times.length);for(let t=0;t<l.times.length;t++)e[t*u+h]=l.values[t];l.name=(a.nodeName||"")+".morphTargetInfluences",l.values=e,r[o.uuid]=l,s.push(l);continue}let c=n.createInterpolant(new n.ValueBufferType(1));l=r[o.uuid];for(let e=0;e<l.times.length;e++)l.values[e*u+h]=c.evaluate(l.times[e]);for(let e=0;e<n.times.length;e++){let t=this.insertKeyframe(l,n.times[e]);l.values[t*u+h]=n.values[e]}}return e.tracks=s,e}};export{P as GLTFExporter};
|