@shopware-ag/dive 3.0.7 → 3.0.9

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.
Files changed (38) hide show
  1. package/build/chunks/{AssetCache-c81WyoAv.cjs → AssetCache-B8-Wr1-A.cjs} +1 -1
  2. package/build/chunks/{AssetCache-Bj2UA1RH.mjs → AssetCache-CpOZDw2l.mjs} +1 -1
  3. package/build/chunks/AssetLoader-C_5aI7P_.cjs +3 -0
  4. package/build/chunks/{AssetLoader-DhlfLA6h.mjs → AssetLoader-_PLMJWFq.mjs} +167 -151
  5. package/build/chunks/{FileTypes-q3iL9lOt.mjs → FileTypes-BzbxtVmA.mjs} +196 -166
  6. package/build/chunks/{FileTypes-DScwT8Ir.cjs → FileTypes-Cnt-P_Lo.cjs} +2 -2
  7. package/build/chunks/{PerspectiveCamera-35cBnxwG.mjs → PerspectiveCamera-B5TvUzTa.mjs} +2 -2
  8. package/build/chunks/isFileTypeSupported-CH4N-8-i.cjs +1 -0
  9. package/build/chunks/{isFileTypeSupported-0a26WUf6.mjs → isFileTypeSupported-Cj4v-F9a.mjs} +3 -3
  10. package/build/dive.cjs +1 -1
  11. package/build/dive.mjs +132 -117
  12. package/build/helpers/index.d.ts +3 -0
  13. package/build/helpers/isFileExtensionSupported/isFileExtensionSupported.d.ts +7 -0
  14. package/build/helpers/isFileSupported/isFileSupported.d.ts +6 -0
  15. package/build/helpers/isFileTypeSupported/isFileTypeSupported.d.ts +2 -0
  16. package/build/helpers/isMimeTypeSupported/isMimeTypeSupported.d.ts +7 -0
  17. package/build/helpers/isURIFileExtensionSupported/isURIFileExtensionSupported.d.ts +7 -0
  18. package/build/plugins/ar/index.cjs +1 -1
  19. package/build/plugins/ar/index.mjs +1 -1
  20. package/build/plugins/assetcache/index.cjs +1 -1
  21. package/build/plugins/assetcache/index.mjs +1 -1
  22. package/build/plugins/assetloader/index.cjs +1 -1
  23. package/build/plugins/assetloader/index.mjs +2 -2
  24. package/build/plugins/mediacreator/index.mjs +1 -1
  25. package/build/plugins/orbitcontroller/index.cjs +1 -1
  26. package/build/plugins/orbitcontroller/index.mjs +1 -1
  27. package/build/plugins/orientationdisplay/index.cjs +1 -1
  28. package/build/plugins/orientationdisplay/index.mjs +2 -2
  29. package/build/plugins/quickview/index.cjs +1 -1
  30. package/build/plugins/quickview/index.mjs +1 -1
  31. package/build/plugins/state/index.cjs +1 -1
  32. package/build/plugins/state/index.mjs +1 -1
  33. package/build/plugins/toolbox/index.cjs +1 -1
  34. package/build/plugins/toolbox/index.mjs +2 -2
  35. package/build/types/file/FileTypes.d.ts +9 -0
  36. package/package.json +1 -1
  37. package/build/chunks/AssetLoader-D6U0QvUg.cjs +0 -3
  38. package/build/chunks/isFileTypeSupported-CqKLRgSA.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var l=(i,e,t)=>e in i?d(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>l(i,typeof e!="symbol"?e+"":e,t);require("./FileTypes-DScwT8Ir.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("./network-error-CdDXil5g.cjs");class f{constructor(e){s(this,"_promise");s(this,"_resolve");s(this,"_arrayBuffer",null);s(this,"_size",0);s(this,"_createdAt");s(this,"_updatedAt");this._uri=e,this._promise=new Promise(t=>{this._resolve=t}),this._createdAt=new Date,this._updatedAt=new Date}get promise(){return this._promise}get size(){return this._size}get createdAt(){return this._createdAt}get updatedAt(){return this._updatedAt}get arrayBuffer(){return this._arrayBuffer}_getHeader(e,t){var r,a;return((a=(r=e.headers)==null?void 0:r.get)==null?void 0:a.call(r,t))??null}_concatChunks(e,t){const r=new Uint8Array(t);let a=0;for(const n of e)r.set(n,a),a+=n.byteLength;return r.buffer}async _readBodyWithReader(e){const t=e.body.getReader(),r=[];let a=0;try{for(;;){const o=await t.read();if(o.done)break;const u=o.value??new Uint8Array(0);r.push(u),a+=u.byteLength}}finally{t.releaseLock()}return this._concatChunks(r,a)}async load(){var t;const e=await fetch(this._uri);if(!e.ok)throw new _.NetworkError(this._uri);try{(t=e.body)!=null&&t.getReader?this._arrayBuffer=await this._readBodyWithReader(e):this._arrayBuffer=await e.arrayBuffer(),this._size+=this._arrayBuffer.byteLength,this._updatedAt=new Date}catch{throw new _.FileContentError(this._uri)}return this._resolve(this._arrayBuffer),this._arrayBuffer}}class y{constructor(){s(this,"_cache",new Map)}get(){return this._cache}create(e){const t=new f(e);return this._cache.set(e,t),t}write(e,t){this._cache.set(e,t)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(t=>{this._cache.delete(t)})}clear(){this._cache.clear()}}const h=Symbol.for("@shopware-ag/dive/assetcache"),c=globalThis;c[h]||(c[h]=new y);const w=c[h];exports.AssetCache=w;exports.Chunk=f;
1
+ "use strict";var d=Object.defineProperty;var l=(i,e,t)=>e in i?d(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>l(i,typeof e!="symbol"?e+"":e,t);require("./FileTypes-Cnt-P_Lo.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("./network-error-CdDXil5g.cjs");class f{constructor(e){s(this,"_promise");s(this,"_resolve");s(this,"_arrayBuffer",null);s(this,"_size",0);s(this,"_createdAt");s(this,"_updatedAt");this._uri=e,this._promise=new Promise(t=>{this._resolve=t}),this._createdAt=new Date,this._updatedAt=new Date}get promise(){return this._promise}get size(){return this._size}get createdAt(){return this._createdAt}get updatedAt(){return this._updatedAt}get arrayBuffer(){return this._arrayBuffer}_getHeader(e,t){var r,a;return((a=(r=e.headers)==null?void 0:r.get)==null?void 0:a.call(r,t))??null}_concatChunks(e,t){const r=new Uint8Array(t);let a=0;for(const n of e)r.set(n,a),a+=n.byteLength;return r.buffer}async _readBodyWithReader(e){const t=e.body.getReader(),r=[];let a=0;try{for(;;){const o=await t.read();if(o.done)break;const u=o.value??new Uint8Array(0);r.push(u),a+=u.byteLength}}finally{t.releaseLock()}return this._concatChunks(r,a)}async load(){var t;const e=await fetch(this._uri);if(!e.ok)throw new _.NetworkError(this._uri);try{(t=e.body)!=null&&t.getReader?this._arrayBuffer=await this._readBodyWithReader(e):this._arrayBuffer=await e.arrayBuffer(),this._size+=this._arrayBuffer.byteLength,this._updatedAt=new Date}catch{throw new _.FileContentError(this._uri)}return this._resolve(this._arrayBuffer),this._arrayBuffer}}class y{constructor(){s(this,"_cache",new Map)}get(){return this._cache}create(e){const t=new f(e);return this._cache.set(e,t),t}write(e,t){this._cache.set(e,t)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(t=>{this._cache.delete(t)})}clear(){this._cache.clear()}}const h=Symbol.for("@shopware-ag/dive/assetcache"),c=globalThis;c[h]||(c[h]=new y);const w=c[h];exports.AssetCache=w;exports.Chunk=f;
@@ -1,7 +1,7 @@
1
1
  var _ = Object.defineProperty;
2
2
  var f = (i, e, t) => e in i ? _(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
3
  var s = (i, e, t) => f(i, typeof e != "symbol" ? e + "" : e, t);
4
- import "./FileTypes-q3iL9lOt.mjs";
4
+ import "./FileTypes-BzbxtVmA.mjs";
5
5
  import "three/webgpu";
6
6
  import "three/examples/jsm/loaders/HDRLoader.js";
7
7
  import "three/tsl";
@@ -0,0 +1,3 @@
1
+ "use strict";var G=Object.create;var C=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var q=(c,t,n)=>t in c?C(c,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[t]=n;var H=(c,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of v(t))!j.call(c,s)&&s!==n&&C(c,s,{get:()=>t[s],enumerable:!(r=B(t,s))||r.enumerable});return c};var I=(c,t,n)=>(n=c!=null?G(W(c)):{},H(t||!c||!c.__esModule?C(n,"default",{value:c,enumerable:!0}):n,c));var p=(c,t,n)=>q(c,typeof t!="symbol"?t+"":t,n);const z=require("three/examples/jsm/loaders/GLTFLoader.js"),Y=require("three/examples/jsm/loaders/USDLoader.js"),J=require("./FileTypes-Cnt-P_Lo.cjs"),w=require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const U=require("./isFileTypeSupported-CH4N-8-i.cjs"),R=require("./parse-error-Dy_EE4rL.cjs"),$=require("three/examples/jsm/loaders/DRACOLoader.js"),T=require("./AssetCache-B8-Wr1-A.cjs");function N(){let c,t;onmessage=function(e){const o=e.data;switch(o.type){case"init":c=o.decoderConfig,t=new Promise(function(i){c.onModuleLoaded=function(_){i({draco:_})},DracoDecoderModule(c)});break;case"decode":const d=o.buffer,l=o.taskConfig;t.then(i=>{const _=i.draco,a=new _.Decoder;try{const u=n(_,a,new Int8Array(d),l),h=u.attributes.map(g=>g.array.buffer);u.index&&h.push(u.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:u},h)}catch(u){console.error(u),self.postMessage({type:"error",id:o.id,error:u.message})}finally{_.destroy(a)}});break}};function n(e,o,d,l){const i=l.attributeIDs,_=l.attributeTypes;let a,u;const h=o.GetEncodedGeometryType(d);if(h===e.TRIANGULAR_MESH)a=new e.Mesh,u=o.DecodeArrayToMesh(d,d.byteLength,a);else if(h===e.POINT_CLOUD)a=new e.PointCloud,u=o.DecodeArrayToPointCloud(d,d.byteLength,a);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||a.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const g={index:null,attributes:[]};for(const A in i){const D=self[_[A]];let y,m;if(l.useUniqueIDs)m=i[A],y=o.GetAttributeByUniqueId(a,m);else{if(m=o.GetAttributeId(a,e[i[A]]),m===-1)continue;y=o.GetAttribute(a,m)}const E=s(e,o,a,A,D,y);A==="color"&&(E.vertexColorSpace=l.vertexColorSpace),g.attributes.push(E)}return h===e.TRIANGULAR_MESH&&(g.index=r(e,o,a)),e.destroy(a),g}function r(e,o,d){const i=d.num_faces()*3,_=i*4,a=e._malloc(_);o.GetTrianglesUInt32Array(d,_,a);const u=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:u,itemSize:1}}function s(e,o,d,l,i,_){const a=d.num_points(),u=_.num_components(),h=f(e,i),g=u*i.BYTES_PER_ELEMENT,A=Math.ceil(g/4)*4,D=A/i.BYTES_PER_ELEMENT,y=a*g,m=a*A,E=e._malloc(y);o.GetAttributeDataArrayForAllPoints(d,_,h,y,E);const O=new i(e.HEAPF32.buffer,E,y/i.BYTES_PER_ELEMENT);let L;if(g===A)L=O.slice();else{L=new i(m/i.BYTES_PER_ELEMENT);let M=0;for(let b=0,x=O.length;b<x;b+=u){for(let S=0;S<u;S++)L[M+S]=O[b+S];M+=D}}return e._free(E),{name:l,count:a,itemSize:u,array:L,stride:D}}function f(e,o){switch(o){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}}const P={LOAD_DRACO_JS_DECODER:async()=>(await import("three/examples/jsm/libs/draco/draco_decoder.js?raw")).default,LOAD_DRACO_WASM_WRAPPER:async()=>(await import("three/examples/jsm/libs/draco/draco_wasm_wrapper.js?raw")).default,LOAD_DRACO_WASM_DECODER:async()=>{const c=(await import("three/examples/jsm/libs/draco/draco_decoder.wasm?url")).default;return await(await fetch(c)).arrayBuffer()}};class k extends $.DRACOLoader{constructor(){super(...arguments);p(this,"decoderPending",null);p(this,"decoderConfig",{type:"js",wasmBinary:null});p(this,"workerSourceURL","")}async _initDecoder(){if(this.decoderPending)return this.decoderPending;const n=typeof WebAssembly!="object"||this.decoderConfig.type==="js",r=[];return n?r.push(P.LOAD_DRACO_JS_DECODER()):(r.push(P.LOAD_DRACO_WASM_WRAPPER()),r.push(P.LOAD_DRACO_WASM_DECODER())),this.decoderPending=Promise.all(r).then(s=>{const f=s[0];n||(this.decoderConfig.wasmBinary=s[1]);const e=N.toString(),o=["/* draco decoder */",f,"","/* worker */",e.substring(e.indexOf("{")+1,e.lastIndexOf("}"))].join(`
2
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}}function V(){let c=null,t=null;const n=[[/'CONFIG_CONTROL_DESIGN'\s*\)/g,"'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF')"],[/'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF\.\s*\{[\s\S]*?\}\s*'/g,"'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF'"]];function r(){return c||(c=occtimportjs({locateFile:function(){return t}})),c}function s(e){for(var o=new TextDecoder("utf-8",{fatal:!1}),d=new TextEncoder,l=o.decode(e),i=0;i<n.length;i++){var _=n[i][0],a=n[i][1];l=l.replace(_,a)}return new Uint8Array(d.encode(l))}function f(e,o){var d=s(o);try{var l=e.ReadStepFile(d,null);if(l.success&&l.root)return l}catch{}try{return e.ReadStepFile(o,null)}catch{return{success:!1,root:{meshes:[],children:[]},meshes:[]}}}onmessage=async function(e){var o=e.data;switch(o.type){case"init":t=o.wasmUrl;break;case"parse":try{var d=await r(),l=new Uint8Array(o.buffer),i=o.fileType,_;if(i==="step"||i==="stp"?_=f(d,l):_=d.ReadIgesFile(l,null),!_.success||!_.root){self.postMessage({type:"error",id:o.id,error:"Failed to parse CAD file"});return}self.postMessage({type:"result",id:o.id,result:_})}catch(a){self.postMessage({type:"error",id:o.id,error:a instanceof Error?a.message:String(a)})}break}}}const F={LOAD_OCCT_JS:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-DdbbsFBH.cjs"))).default,LOAD_OCCT_WASM_URL:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-BQ1yZHCj.cjs"))).default};class Z{constructor(){p(this,"_workerPending",null);p(this,"_worker",null);p(this,"_nextId",0);p(this,"_pending",new Map)}_getWorker(){return this._workerPending?this._workerPending:(this._workerPending=(async()=>{const[t,n]=await Promise.all([F.LOAD_OCCT_JS(),F.LOAD_OCCT_WASM_URL()]),r=V.toString(),s=["/* occt-import-js */",t,"","/* step worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
3
+ `),f=URL.createObjectURL(new Blob([s])),e=new Worker(f),o=new URL(n,window.location.href).href;return e.postMessage({type:"init",wasmUrl:o}),e.onmessage=d=>{const{type:l,id:i,result:_,error:a}=d.data,u=this._pending.get(i);if(u)if(this._pending.delete(i),l==="result")try{u.resolve(this._buildScene(_))}catch(h){u.reject(h instanceof Error?h:new Error(String(h)))}else u.reject(new Error(a??"Worker error"))},e.onerror=d=>{for(const[,{reject:l}]of this._pending)l(new Error(d.message??"Worker error"));this._pending.clear()},this._worker=e,e})(),this._workerPending)}async parseAsync(t,n){const r=this._nextId++,s=await this._getWorker();return new Promise((f,e)=>{this._pending.set(r,{resolve:f,reject:e});const o=t.slice(0);s.postMessage({type:"parse",id:r,buffer:o,fileType:n},[o])})}dispose(){if(this._worker){for(const[,{reject:t}]of this._pending)t(new Error("STEPLoader disposed"));this._pending.clear(),this._worker.terminate(),this._worker=null,this._workerPending=null}}_buildScene(t){const n=new w.Group;return n.name=t.root.name??"CAD Model",this._buildNode(t.root,t.meshes,n),n.rotation.x=-Math.PI/2,n.rotation.z=Math.PI/2,n}_buildNode(t,n,r){const s=new w.Group;s.name=t.name??"Part";for(const f of t.meshes){const e=n[f];if(e!=null&&e.attributes){const o=this._createMesh(e);s.add(o)}}for(const f of t.children)this._buildNode(f,n,s);r.add(s)}_createMesh(t){var l,i;const{position:n,normal:r}=t.attributes,s=t.index??t.attributes.index,f=new w.BufferGeometry;f.setAttribute("position",new w.BufferAttribute(new Float32Array(n.array),3)),(l=r==null?void 0:r.array)!=null&&l.length?f.setAttribute("normal",new w.BufferAttribute(new Float32Array(r.array),3)):f.computeVertexNormals(),(i=s==null?void 0:s.array)!=null&&i.length&&f.setIndex(new w.BufferAttribute(new Uint32Array(s.array),1));const e=t.color,o=new w.MeshStandardMaterial({metalness:.3,roughness:.6});e&&e.length>=3?o.color.setRGB(e[0],e[1],e[2]):o.color.setHex(13421772);const d=new w.Mesh(f,o);return d.name=t.name??"Mesh",d.castShadow=!0,d.receiveShadow=!0,d}}class K{constructor(){p(this,"_gltfLoader");p(this,"_usdLoader");p(this,"_stepLoader");const t=new k;t.setDecoderConfig({type:"wasm"}),this._gltfLoader=new z.GLTFLoader,this._gltfLoader.setDRACOLoader(t),this._usdLoader=new Y.USDLoader,this._stepLoader=new Z}async load(t,n){let r;if(n)r=n;else if(r=U.getFileTypeFromUri(t),r.length===0&&(r=await this._detectFileTypeFromContent(t),r.length===0))throw new R.FileTypeError("No file extension found in URI","");if(!U.isFileTypeSupported(r))throw new R.FileTypeError(`Unsupported file type: ${r}. Supported types: ${J.SUPPORTED_FILE_TYPES.join(", ")}`,r);const s=T.AssetCache.read(t);if(s)return s.arrayBuffer?this._parse(s.arrayBuffer,r):s.promise.then(o=>this._parse(o,r));const e=await T.AssetCache.create(t).load();return this._parse(e,r)}async _detectFileTypeFromContent(t){try{const n=T.AssetCache.read(t);let r;n?n.arrayBuffer?r=n.arrayBuffer:r=await n.promise:r=await T.AssetCache.create(t).load();const s=new Uint8Array(r);return s.length>=12&&String.fromCharCode(s[0],s[1],s[2],s[3])==="glTF"?s[12]===0?"glb":"gltf":s.length>=4&&s[0]===80&&s[1]===75&&(s[2]===3||s[2]===5)&&(s[3]===4||s[3]===6)?"usdz":s.length>=20&&new TextDecoder("ascii").decode(s.subarray(0,20)).startsWith("ISO-10303-21")?"step":s.length>=80&&s[72]===83?"iges":""}catch{return""}}async _parse(t,n){try{switch(n){case"glb":case"gltf":{const r=await this._gltfLoader.parseAsync(t,"");return r.scene.animations=r.animations,r.scene}case"usdz":{const r=this._usdLoader.parse(t);return r.animations=[],r}case"step":case"stp":{const r=await this._stepLoader.parseAsync(t,n);return r.animations=[],r}case"iges":case"igs":{const r=await this._stepLoader.parseAsync(t,n);return r.animations=[],r}}}catch(r){throw r instanceof Error?new R.ParseError(`Failed to parse ${n} file: ${r.message}`,r):new R.ParseError(`Failed to parse ${n} file`)}}}exports.AssetLoader=K;exports.DRACOWorker=N;exports.DracoLoader=k;
@@ -1,139 +1,155 @@
1
- var C = Object.defineProperty;
2
- var I = (_, r, s) => r in _ ? C(_, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : _[r] = s;
3
- var h = (_, r, s) => I(_, typeof r != "symbol" ? r + "" : r, s);
4
- import { GLTFLoader as P } from "three/examples/jsm/loaders/GLTFLoader.js";
5
- import { USDLoader as U } from "three/examples/jsm/loaders/USDLoader.js";
6
- import { S as M } from "./FileTypes-q3iL9lOt.mjs";
7
- import { Group as b, BufferGeometry as k, BufferAttribute as E, MeshStandardMaterial as F, Mesh as N } from "three/webgpu";
1
+ var k = Object.defineProperty;
2
+ var F = (_, r, s) => r in _ ? k(_, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : _[r] = s;
3
+ var h = (_, r, s) => F(_, typeof r != "symbol" ? r + "" : r, s);
4
+ import { GLTFLoader as x } from "three/examples/jsm/loaders/GLTFLoader.js";
5
+ import { USDLoader as G } from "three/examples/jsm/loaders/USDLoader.js";
6
+ import { S as B } from "./FileTypes-BzbxtVmA.mjs";
7
+ import { Group as C, BufferGeometry as W, BufferAttribute as O, MeshStandardMaterial as v, Mesh as j } from "three/webgpu";
8
8
  import "three/examples/jsm/loaders/HDRLoader.js";
9
9
  import "three/tsl";
10
- import { g as x, i as G } from "./isFileTypeSupported-0a26WUf6.mjs";
11
- import { F as R, P as O } from "./parse-error-DfOPyLWM.mjs";
12
- import { DRACOLoader as W } from "three/examples/jsm/loaders/DRACOLoader.js";
13
- import { A as D } from "./AssetCache-Bj2UA1RH.mjs";
14
- function v() {
10
+ import { g as H, i as z } from "./isFileTypeSupported-Cj4v-F9a.mjs";
11
+ import { F as P, P as M } from "./parse-error-DfOPyLWM.mjs";
12
+ import { DRACOLoader as Y } from "three/examples/jsm/loaders/DRACOLoader.js";
13
+ import { A as S } from "./AssetCache-CpOZDw2l.mjs";
14
+ function J() {
15
15
  let _, r;
16
16
  onmessage = function(e) {
17
17
  const n = e.data;
18
18
  switch (n.type) {
19
19
  case "init":
20
- _ = n.decoderConfig, r = new Promise(function(a) {
21
- _.onModuleLoaded = function(u) {
22
- a({ draco: u });
20
+ _ = n.decoderConfig, r = new Promise(function(i) {
21
+ _.onModuleLoaded = function(f) {
22
+ i({ draco: f });
23
23
  }, DracoDecoderModule(_);
24
24
  });
25
25
  break;
26
26
  case "decode":
27
- const i = n.buffer, d = n.taskConfig;
28
- r.then((a) => {
29
- const u = a.draco, c = new u.Decoder();
27
+ const c = n.buffer, d = n.taskConfig;
28
+ r.then((i) => {
29
+ const f = i.draco, a = new f.Decoder();
30
30
  try {
31
- const f = s(
32
- u,
33
- c,
34
- new Int8Array(i),
31
+ const l = s(
32
+ f,
33
+ a,
34
+ new Int8Array(c),
35
35
  d
36
- ), p = f.attributes.map(
36
+ ), p = l.attributes.map(
37
37
  (m) => m.array.buffer
38
38
  );
39
- f.index && p.push(f.index.array.buffer), self.postMessage(
40
- { type: "decode", id: n.id, geometry: f },
39
+ l.index && p.push(l.index.array.buffer), self.postMessage(
40
+ { type: "decode", id: n.id, geometry: l },
41
41
  p
42
42
  );
43
- } catch (f) {
44
- console.error(f), self.postMessage({
43
+ } catch (l) {
44
+ console.error(l), self.postMessage({
45
45
  type: "error",
46
46
  id: n.id,
47
- error: f.message
47
+ error: l.message
48
48
  });
49
49
  } finally {
50
- u.destroy(c);
50
+ f.destroy(a);
51
51
  }
52
52
  });
53
53
  break;
54
54
  }
55
55
  };
56
- function s(e, n, i, d) {
57
- const a = d.attributeIDs, u = d.attributeTypes;
58
- let c, f;
59
- const p = n.GetEncodedGeometryType(i);
56
+ function s(e, n, c, d) {
57
+ const i = d.attributeIDs, f = d.attributeTypes;
58
+ let a, l;
59
+ const p = n.GetEncodedGeometryType(c);
60
60
  if (p === e.TRIANGULAR_MESH)
61
- c = new e.Mesh(), f = n.DecodeArrayToMesh(
62
- i,
63
- i.byteLength,
64
- c
61
+ a = new e.Mesh(), l = n.DecodeArrayToMesh(
62
+ c,
63
+ c.byteLength,
64
+ a
65
65
  );
66
66
  else if (p === e.POINT_CLOUD)
67
- c = new e.PointCloud(), f = n.DecodeArrayToPointCloud(
68
- i,
69
- i.byteLength,
70
- c
67
+ a = new e.PointCloud(), l = n.DecodeArrayToPointCloud(
68
+ c,
69
+ c.byteLength,
70
+ a
71
71
  );
72
72
  else
73
73
  throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
74
- if (!f.ok() || c.ptr === 0)
74
+ if (!l.ok() || a.ptr === 0)
75
75
  throw new Error(
76
- "THREE.DRACOLoader: Decoding failed: " + f.error_msg()
76
+ "THREE.DRACOLoader: Decoding failed: " + l.error_msg()
77
77
  );
78
78
  const m = { index: null, attributes: [] };
79
- for (const g in a) {
80
- const w = self[u[g]];
81
- let y, A;
79
+ for (const g in i) {
80
+ const E = self[f[g]];
81
+ let w, A;
82
82
  if (d.useUniqueIDs)
83
- A = a[g], y = n.GetAttributeByUniqueId(
84
- c,
83
+ A = i[g], w = n.GetAttributeByUniqueId(
84
+ a,
85
85
  A
86
86
  );
87
87
  else {
88
88
  if (A = n.GetAttributeId(
89
- c,
90
- e[a[g]]
89
+ a,
90
+ e[i[g]]
91
91
  ), A === -1) continue;
92
- y = n.GetAttribute(c, A);
92
+ w = n.GetAttribute(a, A);
93
93
  }
94
- const S = o(
94
+ const y = o(
95
95
  e,
96
96
  n,
97
- c,
97
+ a,
98
98
  g,
99
- w,
100
- y
99
+ E,
100
+ w
101
101
  );
102
- g === "color" && (S.vertexColorSpace = d.vertexColorSpace), m.attributes.push(S);
102
+ g === "color" && (y.vertexColorSpace = d.vertexColorSpace), m.attributes.push(y);
103
103
  }
104
- return p === e.TRIANGULAR_MESH && (m.index = t(e, n, c)), e.destroy(c), m;
104
+ return p === e.TRIANGULAR_MESH && (m.index = t(e, n, a)), e.destroy(a), m;
105
105
  }
106
- function t(e, n, i) {
107
- const a = i.num_faces() * 3, u = a * 4, c = e._malloc(u);
108
- n.GetTrianglesUInt32Array(i, u, c);
109
- const f = new Uint32Array(
106
+ function t(e, n, c) {
107
+ const i = c.num_faces() * 3, f = i * 4, a = e._malloc(f);
108
+ n.GetTrianglesUInt32Array(c, f, a);
109
+ const l = new Uint32Array(
110
110
  e.HEAPF32.buffer,
111
- c,
112
- a
111
+ a,
112
+ i
113
113
  ).slice();
114
- return e._free(c), { array: f, itemSize: 1 };
114
+ return e._free(a), { array: l, itemSize: 1 };
115
115
  }
116
- function o(e, n, i, d, a, u) {
117
- const c = u.num_components(), p = i.num_points() * c, m = p * a.BYTES_PER_ELEMENT, g = l(e, a), w = e._malloc(m);
116
+ function o(e, n, c, d, i, f) {
117
+ const a = c.num_points(), l = f.num_components(), p = u(e, i), m = l * i.BYTES_PER_ELEMENT, g = Math.ceil(m / 4) * 4, E = g / i.BYTES_PER_ELEMENT, w = a * m, A = a * g, y = e._malloc(w);
118
118
  n.GetAttributeDataArrayForAllPoints(
119
- i,
120
- u,
121
- g,
122
- m,
123
- w
119
+ c,
120
+ f,
121
+ p,
122
+ w,
123
+ y
124
124
  );
125
- const y = new a(
125
+ const R = new i(
126
126
  e.HEAPF32.buffer,
127
- w,
128
- p
129
- ).slice();
130
- return e._free(w), {
127
+ y,
128
+ w / i.BYTES_PER_ELEMENT
129
+ );
130
+ let D;
131
+ if (m === g)
132
+ D = R.slice();
133
+ else {
134
+ D = new i(
135
+ A / i.BYTES_PER_ELEMENT
136
+ );
137
+ let I = 0;
138
+ for (let T = 0, N = R.length; T < N; T += l) {
139
+ for (let L = 0; L < l; L++)
140
+ D[I + L] = R[T + L];
141
+ I += E;
142
+ }
143
+ }
144
+ return e._free(y), {
131
145
  name: d,
132
- array: y,
133
- itemSize: c
146
+ count: a,
147
+ itemSize: l,
148
+ array: D,
149
+ stride: E
134
150
  };
135
151
  }
136
- function l(e, n) {
152
+ function u(e, n) {
137
153
  switch (n) {
138
154
  case Float32Array:
139
155
  return e.DT_FLOAT32;
@@ -152,7 +168,7 @@ function v() {
152
168
  }
153
169
  }
154
170
  }
155
- const L = {
171
+ const b = {
156
172
  LOAD_DRACO_JS_DECODER: async () => (await import("three/examples/jsm/libs/draco/draco_decoder.js?raw")).default,
157
173
  LOAD_DRACO_WASM_WRAPPER: async () => (await import("three/examples/jsm/libs/draco/draco_wasm_wrapper.js?raw")).default,
158
174
  LOAD_DRACO_WASM_DECODER: async () => {
@@ -160,7 +176,7 @@ const L = {
160
176
  return await (await fetch(_)).arrayBuffer();
161
177
  }
162
178
  };
163
- class j extends W {
179
+ class $ extends Y {
164
180
  constructor() {
165
181
  super(...arguments);
166
182
  h(this, "decoderPending", null);
@@ -174,18 +190,18 @@ class j extends W {
174
190
  if (this.decoderPending) return this.decoderPending;
175
191
  const s = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];
176
192
  return s ? t.push(
177
- L.LOAD_DRACO_JS_DECODER()
193
+ b.LOAD_DRACO_JS_DECODER()
178
194
  ) : (t.push(
179
- L.LOAD_DRACO_WASM_WRAPPER()
195
+ b.LOAD_DRACO_WASM_WRAPPER()
180
196
  ), t.push(
181
- L.LOAD_DRACO_WASM_DECODER()
197
+ b.LOAD_DRACO_WASM_DECODER()
182
198
  )), this.decoderPending = Promise.all(t).then(
183
199
  (o) => {
184
- const l = o[0];
200
+ const u = o[0];
185
201
  s || (this.decoderConfig.wasmBinary = o[1]);
186
- const e = v.toString(), n = [
202
+ const e = J.toString(), n = [
187
203
  "/* draco decoder */",
188
- l,
204
+ u,
189
205
  "",
190
206
  "/* worker */",
191
207
  e.substring(e.indexOf("{") + 1, e.lastIndexOf("}"))
@@ -196,7 +212,7 @@ class j extends W {
196
212
  ), this.decoderPending;
197
213
  }
198
214
  }
199
- function B() {
215
+ function q() {
200
216
  let _ = null, r = null;
201
217
  const s = [
202
218
  [
@@ -217,16 +233,16 @@ function B() {
217
233
  })), _;
218
234
  }
219
235
  function o(e) {
220
- for (var n = new TextDecoder("utf-8", { fatal: !1 }), i = new TextEncoder(), d = n.decode(e), a = 0; a < s.length; a++) {
221
- var u = s[a][0], c = s[a][1];
222
- d = d.replace(u, c);
236
+ for (var n = new TextDecoder("utf-8", { fatal: !1 }), c = new TextEncoder(), d = n.decode(e), i = 0; i < s.length; i++) {
237
+ var f = s[i][0], a = s[i][1];
238
+ d = d.replace(f, a);
223
239
  }
224
- return new Uint8Array(i.encode(d));
240
+ return new Uint8Array(c.encode(d));
225
241
  }
226
- function l(e, n) {
227
- var i = o(n);
242
+ function u(e, n) {
243
+ var c = o(n);
228
244
  try {
229
- var d = e.ReadStepFile(i, null);
245
+ var d = e.ReadStepFile(c, null);
230
246
  if (d.success && d.root) return d;
231
247
  } catch {
232
248
  }
@@ -248,8 +264,8 @@ function B() {
248
264
  break;
249
265
  case "parse":
250
266
  try {
251
- var i = await t(), d = new Uint8Array(n.buffer), a = n.fileType, u;
252
- if (a === "step" || a === "stp" ? u = l(i, d) : u = i.ReadIgesFile(d, null), !u.success || !u.root) {
267
+ var c = await t(), d = new Uint8Array(n.buffer), i = n.fileType, f;
268
+ if (i === "step" || i === "stp" ? f = u(c, d) : f = c.ReadIgesFile(d, null), !f.success || !f.root) {
253
269
  self.postMessage({
254
270
  type: "error",
255
271
  id: n.id,
@@ -260,24 +276,24 @@ function B() {
260
276
  self.postMessage({
261
277
  type: "result",
262
278
  id: n.id,
263
- result: u
279
+ result: f
264
280
  });
265
- } catch (c) {
281
+ } catch (a) {
266
282
  self.postMessage({
267
283
  type: "error",
268
284
  id: n.id,
269
- error: c instanceof Error ? c.message : String(c)
285
+ error: a instanceof Error ? a.message : String(a)
270
286
  });
271
287
  }
272
288
  break;
273
289
  }
274
290
  };
275
291
  }
276
- const T = {
292
+ const U = {
277
293
  LOAD_OCCT_JS: async () => (await import("./occt-import-js-D-bjjBtk.mjs")).default,
278
294
  LOAD_OCCT_WASM_URL: async () => (await import("./occt-import-js-ekuHaP1Z.mjs")).default
279
295
  };
280
- class H {
296
+ class V {
281
297
  constructor() {
282
298
  h(this, "_workerPending", null);
283
299
  h(this, "_worker", null);
@@ -295,35 +311,35 @@ class H {
295
311
  r,
296
312
  s
297
313
  ] = await Promise.all([
298
- T.LOAD_OCCT_JS(),
299
- T.LOAD_OCCT_WASM_URL()
300
- ]), t = B.toString(), o = [
314
+ U.LOAD_OCCT_JS(),
315
+ U.LOAD_OCCT_WASM_URL()
316
+ ]), t = q.toString(), o = [
301
317
  "/* occt-import-js */",
302
318
  r,
303
319
  "",
304
320
  "/* step worker */",
305
321
  t.substring(t.indexOf("{") + 1, t.lastIndexOf("}"))
306
322
  ].join(`
307
- `), l = URL.createObjectURL(new Blob([o])), e = new Worker(l), n = new URL(s, window.location.href).href;
308
- return e.postMessage({ type: "init", wasmUrl: n }), e.onmessage = (i) => {
309
- const { type: d, id: a, result: u, error: c } = i.data, f = this._pending.get(a);
310
- if (f)
311
- if (this._pending.delete(a), d === "result")
323
+ `), u = URL.createObjectURL(new Blob([o])), e = new Worker(u), n = new URL(s, window.location.href).href;
324
+ return e.postMessage({ type: "init", wasmUrl: n }), e.onmessage = (c) => {
325
+ const { type: d, id: i, result: f, error: a } = c.data, l = this._pending.get(i);
326
+ if (l)
327
+ if (this._pending.delete(i), d === "result")
312
328
  try {
313
- f.resolve(this._buildScene(u));
329
+ l.resolve(this._buildScene(f));
314
330
  } catch (p) {
315
- f.reject(
331
+ l.reject(
316
332
  p instanceof Error ? p : new Error(String(p))
317
333
  );
318
334
  }
319
335
  else
320
- f.reject(new Error(c ?? "Worker error"));
321
- }, e.onerror = (i) => {
336
+ l.reject(new Error(a ?? "Worker error"));
337
+ }, e.onerror = (c) => {
322
338
  for (const [
323
339
  ,
324
340
  { reject: d }
325
341
  ] of this._pending)
326
- d(new Error(i.message ?? "Worker error"));
342
+ d(new Error(c.message ?? "Worker error"));
327
343
  this._pending.clear();
328
344
  }, this._worker = e, e;
329
345
  })(), this._workerPending);
@@ -333,8 +349,8 @@ class H {
333
349
  */
334
350
  async parseAsync(r, s) {
335
351
  const t = this._nextId++, o = await this._getWorker();
336
- return new Promise((l, e) => {
337
- this._pending.set(t, { resolve: l, reject: e });
352
+ return new Promise((u, e) => {
353
+ this._pending.set(t, { resolve: u, reject: e });
338
354
  const n = r.slice(0);
339
355
  o.postMessage({ type: "parse", id: t, buffer: n, fileType: s }, [
340
356
  n
@@ -355,70 +371,70 @@ class H {
355
371
  }
356
372
  }
357
373
  _buildScene(r) {
358
- const s = new b();
374
+ const s = new C();
359
375
  return s.name = r.root.name ?? "CAD Model", this._buildNode(r.root, r.meshes, s), s.rotation.x = -Math.PI / 2, s.rotation.z = Math.PI / 2, s;
360
376
  }
361
377
  _buildNode(r, s, t) {
362
- const o = new b();
378
+ const o = new C();
363
379
  o.name = r.name ?? "Part";
364
- for (const l of r.meshes) {
365
- const e = s[l];
380
+ for (const u of r.meshes) {
381
+ const e = s[u];
366
382
  if (e != null && e.attributes) {
367
383
  const n = this._createMesh(e);
368
384
  o.add(n);
369
385
  }
370
386
  }
371
- for (const l of r.children)
372
- this._buildNode(l, s, o);
387
+ for (const u of r.children)
388
+ this._buildNode(u, s, o);
373
389
  t.add(o);
374
390
  }
375
391
  _createMesh(r) {
376
- var d, a;
377
- const { position: s, normal: t } = r.attributes, o = r.index ?? r.attributes.index, l = new k();
378
- l.setAttribute(
392
+ var d, i;
393
+ const { position: s, normal: t } = r.attributes, o = r.index ?? r.attributes.index, u = new W();
394
+ u.setAttribute(
379
395
  "position",
380
- new E(new Float32Array(s.array), 3)
381
- ), (d = t == null ? void 0 : t.array) != null && d.length ? l.setAttribute(
396
+ new O(new Float32Array(s.array), 3)
397
+ ), (d = t == null ? void 0 : t.array) != null && d.length ? u.setAttribute(
382
398
  "normal",
383
- new E(new Float32Array(t.array), 3)
384
- ) : l.computeVertexNormals(), (a = o == null ? void 0 : o.array) != null && a.length && l.setIndex(
385
- new E(new Uint32Array(o.array), 1)
399
+ new O(new Float32Array(t.array), 3)
400
+ ) : u.computeVertexNormals(), (i = o == null ? void 0 : o.array) != null && i.length && u.setIndex(
401
+ new O(new Uint32Array(o.array), 1)
386
402
  );
387
- const e = r.color, n = new F({
403
+ const e = r.color, n = new v({
388
404
  metalness: 0.3,
389
405
  roughness: 0.6
390
406
  });
391
407
  e && e.length >= 3 ? n.color.setRGB(e[0], e[1], e[2]) : n.color.setHex(13421772);
392
- const i = new N(l, n);
393
- return i.name = r.name ?? "Mesh", i.castShadow = !0, i.receiveShadow = !0, i;
408
+ const c = new j(u, n);
409
+ return c.name = r.name ?? "Mesh", c.castShadow = !0, c.receiveShadow = !0, c;
394
410
  }
395
411
  }
396
- class te {
412
+ class ae {
397
413
  constructor() {
398
414
  h(this, "_gltfLoader");
399
415
  h(this, "_usdLoader");
400
416
  h(this, "_stepLoader");
401
- const r = new j();
402
- r.setDecoderConfig({ type: "wasm" }), this._gltfLoader = new P(), this._gltfLoader.setDRACOLoader(r), this._usdLoader = new U(), this._stepLoader = new H();
417
+ const r = new $();
418
+ r.setDecoderConfig({ type: "wasm" }), this._gltfLoader = new x(), this._gltfLoader.setDRACOLoader(r), this._usdLoader = new G(), this._stepLoader = new V();
403
419
  }
404
420
  async load(r, s) {
405
421
  let t;
406
422
  if (s)
407
423
  t = s;
408
- else if (t = x(r), t.length === 0 && (t = await this._detectFileTypeFromContent(r), t.length === 0))
409
- throw new R(
424
+ else if (t = H(r), t.length === 0 && (t = await this._detectFileTypeFromContent(r), t.length === 0))
425
+ throw new P(
410
426
  "No file extension found in URI",
411
427
  ""
412
428
  );
413
- if (!G(t))
414
- throw new R(
415
- `Unsupported file type: ${t}. Supported types: ${M.join(", ")}`,
429
+ if (!z(t))
430
+ throw new P(
431
+ `Unsupported file type: ${t}. Supported types: ${B.join(", ")}`,
416
432
  t
417
433
  );
418
- const o = D.read(r);
434
+ const o = S.read(r);
419
435
  if (o)
420
436
  return o.arrayBuffer ? this._parse(o.arrayBuffer, t) : o.promise.then((n) => this._parse(n, t));
421
- const e = await D.create(r).load();
437
+ const e = await S.create(r).load();
422
438
  return this._parse(e, t);
423
439
  }
424
440
  /**
@@ -428,9 +444,9 @@ class te {
428
444
  */
429
445
  async _detectFileTypeFromContent(r) {
430
446
  try {
431
- const s = D.read(r);
447
+ const s = S.read(r);
432
448
  let t;
433
- s ? s.arrayBuffer ? t = s.arrayBuffer : t = await s.promise : t = await D.create(r).load();
449
+ s ? s.arrayBuffer ? t = s.arrayBuffer : t = await s.promise : t = await S.create(r).load();
434
450
  const o = new Uint8Array(t);
435
451
  return o.length >= 12 && String.fromCharCode(
436
452
  o[0],
@@ -485,15 +501,15 @@ class te {
485
501
  }
486
502
  }
487
503
  } catch (t) {
488
- throw t instanceof Error ? new O(
504
+ throw t instanceof Error ? new M(
489
505
  `Failed to parse ${s} file: ${t.message}`,
490
506
  t
491
- ) : new O(`Failed to parse ${s} file`);
507
+ ) : new M(`Failed to parse ${s} file`);
492
508
  }
493
509
  }
494
510
  }
495
511
  export {
496
- te as A,
497
- v as D,
498
- j as a
512
+ ae as A,
513
+ J as D,
514
+ $ as a
499
515
  };