@shopware-ag/dive 2.3.8 → 3.0.0-beta.1
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/build/chunks/Animator-DHnpWRt_.mjs +16 -0
- package/build/chunks/Animator-YDE8aFEd.cjs +1 -0
- package/build/chunks/AssetCache-Bk3ov4KH.cjs +1 -0
- package/build/chunks/{AssetCache-CJPVU7kz.mjs → AssetCache-DNcSNSJk.mjs} +6 -5
- package/build/chunks/AssetExporter-Cdxb04b3.cjs +1 -0
- package/build/chunks/AssetExporter-DLL_vJae.mjs +67 -0
- package/build/chunks/AssetLoader-D6ScugS-.cjs +3 -0
- package/build/chunks/AssetLoader-Dvq0Wk28.mjs +499 -0
- package/build/chunks/{ClipAnimator-keFLDMNZ.mjs → ClipAnimator-D8Gho4Ec.mjs} +2 -2
- package/build/chunks/ClipAnimator-SdDq2wk1.cjs +1 -0
- package/build/chunks/FileTypes-CGEeONh9.cjs +29 -0
- package/build/chunks/FileTypes-DU8bBa_V.mjs +1976 -0
- package/build/chunks/GridNode-0R5ZnzR6.mjs +30 -0
- package/build/chunks/GridNode-iqnu86_v.cjs +1 -0
- package/build/chunks/{PerspectiveCamera-BFzE2TQU.mjs → PerspectiveCamera-B5TvUzTa.mjs} +1 -1
- package/build/chunks/PerspectiveCamera-DwQUmkDv.cjs +1 -0
- package/build/chunks/{TargetAnimator-DuqPk2eq.cjs → TargetAnimator-D37bWNKD.cjs} +1 -1
- package/build/chunks/{TargetAnimator-DUqkkdVb.mjs → TargetAnimator-DL_9b921.mjs} +1 -1
- package/build/chunks/{isFileTypeSupported-CqzOKCiV.mjs → isFileTypeSupported-DY4QOFj7.mjs} +1 -1
- package/build/chunks/{isFileTypeSupported-D97zmt1P.cjs → isFileTypeSupported-DrMUwnQx.cjs} +1 -1
- package/build/components/boundingbox/BoundingBox.d.ts +1 -1
- package/build/components/floor/Floor.d.ts +1 -1
- package/build/components/gizmo/Gizmo.d.ts +1 -1
- package/build/components/gizmo/handles/AxisHandle.d.ts +1 -1
- package/build/components/gizmo/handles/RadialHandle.d.ts +1 -1
- package/build/components/gizmo/handles/ScaleHandle.d.ts +1 -1
- package/build/components/gizmo/plane/GizmoPlane.d.ts +1 -1
- package/build/components/gizmo/rotate/RotateGizmo.d.ts +1 -1
- package/build/components/gizmo/scale/ScaleGizmo.d.ts +1 -1
- package/build/components/gizmo/translate/TranslateGizmo.d.ts +1 -1
- package/build/components/grid/Grid.d.ts +2 -1
- package/build/components/group/Group.d.ts +1 -1
- package/build/components/light/AmbientLight.d.ts +1 -1
- package/build/components/light/PointLight.d.ts +1 -1
- package/build/components/light/SceneLight.d.ts +1 -1
- package/build/components/model/Model.d.ts +1 -1
- package/build/components/node/Node.d.ts +1 -1
- package/build/components/primitive/Primitive.d.ts +1 -1
- package/build/components/root/Root.d.ts +1 -1
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +58 -60
- package/build/engine/Dive.d.ts +4 -31
- package/build/engine/camera/PerspectiveCamera.d.ts +1 -1
- package/build/engine/environment/Environment.d.ts +12 -27
- package/build/engine/renderer/Renderer.d.ts +7 -8
- package/build/engine/scene/Scene.d.ts +1 -1
- package/build/engine/scene/xrroot/XRRoot.d.ts +2 -3
- package/build/engine/scene/xrroot/xrlightroot/XRLightRoot.d.ts +3 -3
- package/build/helpers/findInterface/findInterface.d.ts +1 -1
- package/build/helpers/findSceneRecursive/findSceneRecursive.d.ts +1 -1
- package/build/helpers/implementsInterface/implementsInterface.d.ts +1 -1
- package/build/helpers/math/signedAngleTo/signedAngleTo.d.ts +1 -1
- package/build/interfaces/Hoverable.d.ts +1 -1
- package/build/plugins/animation/index.cjs +1 -1
- package/build/plugins/animation/index.mjs +12 -20
- package/build/plugins/animation/src/animator/Animator.d.ts +1 -1
- package/build/plugins/animation/src/animator/ClipAnimator.d.ts +1 -1
- package/build/plugins/animation/src/system/AnimationSystem.d.ts +1 -6
- package/build/plugins/animation/src/types/AnimatorTypes.d.ts +1 -1
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +5 -4
- package/build/plugins/ar/src/webxr/controller/WebXRController.d.ts +1 -1
- package/build/plugins/ar/src/webxr/crosshair/WebXRCrosshair.d.ts +1 -1
- package/build/plugins/ar/src/webxr/origin/WebXROrigin.d.ts +1 -1
- package/build/plugins/ar/src/webxr/raycaster/WebXRRaycaster.d.ts +1 -1
- package/build/plugins/ar/src/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +1 -1
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetexporter/index.cjs +1 -1
- package/build/plugins/assetexporter/index.mjs +1 -1
- package/build/plugins/assetexporter/src/AssetExporter.d.ts +1 -1
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +2 -2
- package/build/plugins/assetloader/src/loader/AssetLoader.d.ts +2 -2
- package/build/plugins/assetloader/src/step/STEPLoader.d.ts +1 -1
- package/build/plugins/mediacreator/index.cjs +1 -1
- package/build/plugins/mediacreator/index.mjs +52 -24
- package/build/plugins/mediacreator/src/MediaCreator.d.ts +4 -3
- package/build/plugins/mediacreator/types/MediaGenerationByPosition.d.ts +1 -1
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orbitcontroller/src/OrbitController.d.ts +1 -1
- package/build/plugins/orbitcontroller/types/OrbitControllerState.types.d.ts +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +17 -16
- package/build/plugins/orientationdisplay/src/axes/Axes.d.ts +1 -1
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +9 -8
- package/build/plugins/shader/index.cjs +1 -1
- package/build/plugins/shader/index.mjs +2 -3
- package/build/plugins/shader/src/index.d.ts +1 -3
- package/build/plugins/shader/src/shaders/GridNode.d.ts +16 -0
- package/build/plugins/state/index.cjs +9 -9
- package/build/plugins/state/index.mjs +939 -936
- package/build/plugins/state/src/actions/camera/computeencompassingview.d.ts +1 -1
- package/build/plugins/state/src/actions/camera/getcameratransform.d.ts +1 -1
- package/build/plugins/state/src/actions/camera/movecamera.d.ts +1 -1
- package/build/plugins/state/src/actions/camera/setcameratransform.d.ts +1 -1
- package/build/plugins/state/types/StateSceneData.d.ts +1 -1
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.d.ts +0 -1
- package/build/plugins/toolbox/index.mjs +224 -853
- package/build/plugins/toolbox/src/PointerContext.d.ts +1 -1
- package/build/plugins/toolbox/src/SelectionState.d.ts +1 -1
- package/build/plugins/toolbox/src/Toolbox.d.ts +0 -10
- package/build/plugins/toolbox/src/drag/DragTool.d.ts +1 -1
- package/build/plugins/toolbox/src/drag/DraggableEvent.d.ts +1 -1
- package/build/plugins/toolbox/src/hover/HoverTool.d.ts +1 -1
- package/build/plugins/toolbox/src/select/SelectTool.d.ts +1 -1
- package/build/plugins/toolbox/src/transform/TransformTool.d.ts +2 -1
- package/build/types/schema/GroupSchema.d.ts +1 -1
- package/build/types/schema/LightSchema.d.ts +1 -1
- package/build/types/schema/MaterialSchema.d.ts +1 -1
- package/build/types/schema/ModelSchema.d.ts +1 -1
- package/build/types/schema/PovSchema.d.ts +1 -1
- package/build/types/schema/PrimitiveSchema.d.ts +1 -1
- package/package.json +5 -4
- package/build/chunks/Animator-BGFdF70Z.mjs +0 -47
- package/build/chunks/Animator-Cu7NIkVg.cjs +0 -1
- package/build/chunks/AssetCache-B74AQgyY.cjs +0 -1
- package/build/chunks/AssetExporter-PFiNYi50.mjs +0 -1628
- package/build/chunks/AssetExporter-yVhYmVXW.cjs +0 -164
- package/build/chunks/AssetLoader-BCI944C9.mjs +0 -2590
- package/build/chunks/AssetLoader-BIU78Bv9.cjs +0 -5
- package/build/chunks/ClipAnimator-tjhLo851.cjs +0 -1
- package/build/chunks/DIVEShaderMaterial-Bt0d8oJB.mjs +0 -3468
- package/build/chunks/DIVEShaderMaterial-DE8YRWj9.cjs +0 -1554
- package/build/chunks/FileTypes-B0qjl7u2.cjs +0 -33
- package/build/chunks/FileTypes-DJxyD4wK.mjs +0 -2155
- package/build/chunks/PerspectiveCamera-iAsZqrnY.cjs +0 -1
- package/build/chunks/draco_decoder-Bh9flJPu.cjs +0 -1
- package/build/chunks/draco_decoder-CEzwqP9o.mjs +0 -38
- package/build/chunks/draco_decoder-DtHHc5d0.mjs +0 -4
- package/build/chunks/draco_decoder-DvYjcLz_.cjs +0 -35
- package/build/chunks/draco_wasm_wrapper-FoEVV9af.cjs +0 -118
- package/build/chunks/draco_wasm_wrapper-yQy2VLhb.mjs +0 -121
- package/build/chunks/fflate.module-DHdJvhNh.cjs +0 -6
- package/build/chunks/fflate.module-xyO_T3Zm.mjs +0 -602
- package/build/plugins/shader/src/material/DIVEShaderMaterial.d.ts +0 -5
- package/build/plugins/shader/src/shaders/DIVEShaderLib.d.ts +0 -2
- package/build/plugins/shader/src/shaders/grid/index.d.ts +0 -40
- package/build/plugins/toolbox/src/BaseTool.d.ts +0 -59
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var s = Object.defineProperty;
|
|
2
|
+
var u = (e, t, i) => t in e ? s(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var r = (e, t, i) => u(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { EventDispatcher as a, MathUtils as n } from "three/webgpu";
|
|
5
|
+
class h extends a {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
r(this, "_uuid", n.generateUUID());
|
|
9
|
+
}
|
|
10
|
+
get uuid() {
|
|
11
|
+
return this._uuid;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
h as A
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var n=(e,t,i)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var u=(e,t,i)=>n(e,typeof t!="symbol"?t+"":t,i);const r=require("three/webgpu");class a extends r.EventDispatcher{constructor(){super(...arguments);u(this,"_uuid",r.MathUtils.generateUUID())}get uuid(){return this._uuid}}exports.Animator=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var n=(s,e,r)=>e in s?u(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var t=(s,e,r)=>n(s,typeof e!="symbol"?e+"":e,r);require("./FileTypes-CGEeONh9.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const h=require("./network-error-CdDXil5g.cjs");class c{constructor(e){t(this,"_promise");t(this,"_resolve");t(this,"_arrayBuffer",null);t(this,"_size",0);t(this,"_createdAt");t(this,"_updatedAt");this._uri=e,this._promise=new Promise(r=>{this._resolve=r}),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}async load(){const e=await fetch(this._uri);if(!e.ok)throw new h.NetworkError(this._uri);try{this._arrayBuffer=await e.arrayBuffer(),this._size+=this._arrayBuffer.byteLength,this._updatedAt=new Date}catch{throw new h.FileContentError(this._uri)}return this._resolve(this._arrayBuffer),this._arrayBuffer}}class o{constructor(){t(this,"_cache",new Map)}get(){return this._cache}create(e){const r=new c(e);return this._cache.set(e,r),r}write(e,r){this._cache.set(e,r)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(r=>{this._cache.delete(r)})}clear(){this._cache.clear()}}const a=Symbol.for("@shopware-ag/dive/assetcache"),i=globalThis;i[a]||(i[a]=new o);const _=i[a];exports.AssetCache=_;exports.Chunk=c;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
var h = Object.defineProperty;
|
|
2
2
|
var c = (s, e, t) => e in s ? h(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var r = (s, e, t) => c(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import "./FileTypes-
|
|
5
|
-
import "three";
|
|
6
|
-
import "
|
|
4
|
+
import "./FileTypes-DU8bBa_V.mjs";
|
|
5
|
+
import "three/webgpu";
|
|
6
|
+
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
7
|
+
import "three/tsl";
|
|
7
8
|
import { N as o, F as _ } from "./network-error-BONfHWQq.mjs";
|
|
8
9
|
class n {
|
|
9
10
|
constructor(e) {
|
|
@@ -73,8 +74,8 @@ class u {
|
|
|
73
74
|
}
|
|
74
75
|
const a = Symbol.for("@shopware-ag/dive/assetcache"), i = globalThis;
|
|
75
76
|
i[a] || (i[a] = new u());
|
|
76
|
-
const
|
|
77
|
+
const m = i[a];
|
|
77
78
|
export {
|
|
78
|
-
A,
|
|
79
|
+
m as A,
|
|
79
80
|
n as C
|
|
80
81
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var c=(o,r,t)=>r in o?i(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t;var n=(o,r,t)=>c(o,typeof r!="symbol"?r+"":r,t);const p=require("three/webgpu"),u=require("three/examples/jsm/exporters/GLTFExporter.js"),f=require("three/examples/jsm/exporters/USDZExporter.js"),s=require("./parse-error-Dy_EE4rL.cjs");class x{constructor(){n(this,"_gltfExporter");n(this,"_usdzExporter");this._gltfExporter=new u.GLTFExporter,this._usdzExporter=new f.USDZExporter}async export(r,t,e){switch(this._computeNormals(r),t){case"glb":return this._exportGlb(r,e);case"gltf":return this._exportGltf(r,e);case"usdz":return this._exportUsdz(r,e);default:throw new s.FileTypeError(`Unsupported file type: ${t}`,t)}}async _exportGlb(r,t){try{const e=await this._gltfExporter.parseAsync(r,{animations:r.animations.length>0?r.animations:void 0,...t,binary:!0});if(e instanceof ArrayBuffer)return e;throw new s.ParseError("Failed to export GLB: expected ArrayBuffer")}catch(e){throw e instanceof s.ParseError?e:new s.ParseError("Failed to export GLB",e)}}async _exportGltf(r,t){try{const e=await this._gltfExporter.parseAsync(r,{animations:r.animations||[],...t,binary:!1}),a=JSON.stringify(e);return new TextEncoder().encode(a).buffer}catch(e){throw e instanceof s.ParseError?e:new s.ParseError("Failed to export GLTF",e)}}async _exportUsdz(r,t){try{return(await this._usdzExporter.parseAsync(r,t)).buffer}catch(e){throw e instanceof s.ParseError?e:new s.ParseError("Failed to export USDZ",e)}}_computeNormals(r){r.traverse(t=>{t instanceof p.Mesh&&t.geometry&&(t.geometry.getAttribute("normal")||t.geometry.computeVertexNormals())})}}exports.AssetExporter=x;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var i = Object.defineProperty;
|
|
2
|
+
var f = (s, r, e) => r in s ? i(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
|
|
3
|
+
var n = (s, r, e) => f(s, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { Mesh as p } from "three/webgpu";
|
|
5
|
+
import { GLTFExporter as c } from "three/examples/jsm/exporters/GLTFExporter.js";
|
|
6
|
+
import { USDZExporter as x } from "three/examples/jsm/exporters/USDZExporter.js";
|
|
7
|
+
import { F as u, P as o } from "./parse-error-DfOPyLWM.mjs";
|
|
8
|
+
class E {
|
|
9
|
+
constructor() {
|
|
10
|
+
n(this, "_gltfExporter");
|
|
11
|
+
n(this, "_usdzExporter");
|
|
12
|
+
this._gltfExporter = new c(), this._usdzExporter = new x();
|
|
13
|
+
}
|
|
14
|
+
async export(r, e, t) {
|
|
15
|
+
switch (this._computeNormals(r), e) {
|
|
16
|
+
case "glb":
|
|
17
|
+
return this._exportGlb(r, t);
|
|
18
|
+
case "gltf":
|
|
19
|
+
return this._exportGltf(r, t);
|
|
20
|
+
case "usdz":
|
|
21
|
+
return this._exportUsdz(r, t);
|
|
22
|
+
default:
|
|
23
|
+
throw new u(`Unsupported file type: ${e}`, e);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async _exportGlb(r, e) {
|
|
27
|
+
try {
|
|
28
|
+
const t = await this._gltfExporter.parseAsync(r, {
|
|
29
|
+
animations: r.animations.length > 0 ? r.animations : void 0,
|
|
30
|
+
...e,
|
|
31
|
+
binary: !0
|
|
32
|
+
});
|
|
33
|
+
if (t instanceof ArrayBuffer)
|
|
34
|
+
return t;
|
|
35
|
+
throw new o("Failed to export GLB: expected ArrayBuffer");
|
|
36
|
+
} catch (t) {
|
|
37
|
+
throw t instanceof o ? t : new o("Failed to export GLB", t);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async _exportGltf(r, e) {
|
|
41
|
+
try {
|
|
42
|
+
const t = await this._gltfExporter.parseAsync(r, {
|
|
43
|
+
animations: r.animations || [],
|
|
44
|
+
...e,
|
|
45
|
+
binary: !1
|
|
46
|
+
}), a = JSON.stringify(t);
|
|
47
|
+
return new TextEncoder().encode(a).buffer;
|
|
48
|
+
} catch (t) {
|
|
49
|
+
throw t instanceof o ? t : new o("Failed to export GLTF", t);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async _exportUsdz(r, e) {
|
|
53
|
+
try {
|
|
54
|
+
return (await this._usdzExporter.parseAsync(r, e)).buffer;
|
|
55
|
+
} catch (t) {
|
|
56
|
+
throw t instanceof o ? t : new o("Failed to export USDZ", t);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
_computeNormals(r) {
|
|
60
|
+
r.traverse((e) => {
|
|
61
|
+
e instanceof p && e.geometry && (e.geometry.getAttribute("normal") || e.geometry.computeVertexNormals());
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
E as A
|
|
67
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var U=Object.create;var b=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var x=(i,t,n)=>t in i?b(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var G=(i,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of F(t))!N.call(i,s)&&s!==n&&b(i,s,{get:()=>t[s],enumerable:!(r=M(t,s))||r.enumerable});return i};var S=(i,t,n)=>(n=i!=null?U(k(i)):{},G(t||!i||!i.__esModule?b(n,"default",{value:i,enumerable:!0}):n,i));var h=(i,t,n)=>x(i,typeof t!="symbol"?t+"":t,n);const v=require("three/examples/jsm/loaders/GLTFLoader.js"),W=require("three/examples/jsm/loaders/USDLoader.js"),j=require("./FileTypes-CGEeONh9.cjs"),A=require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const C=require("./isFileTypeSupported-DrMUwnQx.cjs"),L=require("./parse-error-Dy_EE4rL.cjs"),B=require("three/examples/jsm/loaders/DRACOLoader.js"),E=require("./AssetCache-Bk3ov4KH.cjs");function I(){let i,t;onmessage=function(e){const o=e.data;switch(o.type){case"init":i=o.decoderConfig,t=new Promise(function(a){i.onModuleLoaded=function(f){a({draco:f})},DracoDecoderModule(i)});break;case"decode":const c=o.buffer,u=o.taskConfig;t.then(a=>{const f=a.draco,d=new f.Decoder;try{const _=n(f,d,new Int8Array(c),u),p=_.attributes.map(g=>g.array.buffer);_.index&&p.push(_.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:_},p)}catch(_){console.error(_),self.postMessage({type:"error",id:o.id,error:_.message})}finally{f.destroy(d)}});break}};function n(e,o,c,u){const a=u.attributeIDs,f=u.attributeTypes;let d,_;const p=o.GetEncodedGeometryType(c);if(p===e.TRIANGULAR_MESH)d=new e.Mesh,_=o.DecodeArrayToMesh(c,c.byteLength,d);else if(p===e.POINT_CLOUD)d=new e.PointCloud,_=o.DecodeArrayToPointCloud(c,c.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!_.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+_.error_msg());const g={index:null,attributes:[]};for(const w in a){const y=self[f[w]];let m,D;if(u.useUniqueIDs)D=a[w],m=o.GetAttributeByUniqueId(d,D);else{if(D=o.GetAttributeId(d,e[a[w]]),D===-1)continue;m=o.GetAttribute(d,D)}const R=s(e,o,d,w,y,m);w==="color"&&(R.vertexColorSpace=u.vertexColorSpace),g.attributes.push(R)}return p===e.TRIANGULAR_MESH&&(g.index=r(e,o,d)),e.destroy(d),g}function r(e,o,c){const a=c.num_faces()*3,f=a*4,d=e._malloc(f);o.GetTrianglesUInt32Array(c,f,d);const _=new Uint32Array(e.HEAPF32.buffer,d,a).slice();return e._free(d),{array:_,itemSize:1}}function s(e,o,c,u,a,f){const d=f.num_components(),p=c.num_points()*d,g=p*a.BYTES_PER_ELEMENT,w=l(e,a),y=e._malloc(g);o.GetAttributeDataArrayForAllPoints(c,f,w,g,y);const m=new a(e.HEAPF32.buffer,y,p).slice();return e._free(y),{name:u,array:m,itemSize:d}}function l(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 T={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 i=(await import("three/examples/jsm/libs/draco/draco_decoder.wasm?url")).default;return await(await fetch(i)).arrayBuffer()}};class P extends B.DRACOLoader{constructor(){super(...arguments);h(this,"decoderPending",null);h(this,"decoderConfig",{type:"js",wasmBinary:null});h(this,"workerSourceURL","")}async _initDecoder(){if(this.decoderPending)return this.decoderPending;const n=typeof WebAssembly!="object"||this.decoderConfig.type==="js",r=[];return n?r.push(T.LOAD_DRACO_JS_DECODER()):(r.push(T.LOAD_DRACO_WASM_WRAPPER()),r.push(T.LOAD_DRACO_WASM_DECODER())),this.decoderPending=Promise.all(r).then(s=>{const l=s[0];n||(this.decoderConfig.wasmBinary=s[1]);const e=I.toString(),o=["/* draco decoder */",l,"","/* worker */",e.substring(e.indexOf("{")+1,e.lastIndexOf("}"))].join(`
|
|
2
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}}function q(){let i=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 i||(i=occtimportjs({locateFile:function(){return t}})),i}function s(e){for(var o=new TextDecoder("utf-8",{fatal:!1}),c=new TextEncoder,u=o.decode(e),a=0;a<n.length;a++){var f=n[a][0],d=n[a][1];u=u.replace(f,d)}return new Uint8Array(c.encode(u))}function l(e,o){var c=s(o);try{var u=e.ReadStepFile(c,null);if(u.success&&u.root)return u}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 c=await r(),u=new Uint8Array(o.buffer),a=o.fileType,f;if(a==="step"||a==="stp"?f=l(c,u):f=c.ReadIgesFile(u,null),!f.success||!f.root){self.postMessage({type:"error",id:o.id,error:"Failed to parse CAD file"});return}self.postMessage({type:"result",id:o.id,result:f})}catch(d){self.postMessage({type:"error",id:o.id,error:d instanceof Error?d.message:String(d)})}break}}}const O={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 H{constructor(){h(this,"_workerPending",null);h(this,"_worker",null);h(this,"_nextId",0);h(this,"_pending",new Map)}_getWorker(){return this._workerPending?this._workerPending:(this._workerPending=(async()=>{const[t,n]=await Promise.all([O.LOAD_OCCT_JS(),O.LOAD_OCCT_WASM_URL()]),r=q.toString(),s=["/* occt-import-js */",t,"","/* step worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
|
|
3
|
+
`),l=URL.createObjectURL(new Blob([s])),e=new Worker(l),o=new URL(n,window.location.href).href;return e.postMessage({type:"init",wasmUrl:o}),e.onmessage=c=>{const{type:u,id:a,result:f,error:d}=c.data,_=this._pending.get(a);if(_)if(this._pending.delete(a),u==="result")try{_.resolve(this._buildScene(f))}catch(p){_.reject(p instanceof Error?p:new Error(String(p)))}else _.reject(new Error(d??"Worker error"))},e.onerror=c=>{for(const[,{reject:u}]of this._pending)u(new Error(c.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((l,e)=>{this._pending.set(r,{resolve:l,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 A.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 A.Group;s.name=t.name??"Part";for(const l of t.meshes){const e=n[l];if(e!=null&&e.attributes){const o=this._createMesh(e);s.add(o)}}for(const l of t.children)this._buildNode(l,n,s);r.add(s)}_createMesh(t){var u,a;const{position:n,normal:r}=t.attributes,s=t.index??t.attributes.index,l=new A.BufferGeometry;l.setAttribute("position",new A.BufferAttribute(new Float32Array(n.array),3)),(u=r==null?void 0:r.array)!=null&&u.length?l.setAttribute("normal",new A.BufferAttribute(new Float32Array(r.array),3)):l.computeVertexNormals(),(a=s==null?void 0:s.array)!=null&&a.length&&l.setIndex(new A.BufferAttribute(new Uint32Array(s.array),1));const e=t.color,o=new A.MeshStandardMaterial({metalness:.3,roughness:.6});e&&e.length>=3?o.color.setRGB(e[0],e[1],e[2]):o.color.setHex(13421772);const c=new A.Mesh(l,o);return c.name=t.name??"Mesh",c.castShadow=!0,c.receiveShadow=!0,c}}class z{constructor(){h(this,"_gltfLoader");h(this,"_usdLoader");h(this,"_stepLoader");const t=new P;t.setDecoderConfig({type:"wasm"}),this._gltfLoader=new v.GLTFLoader,this._gltfLoader.setDRACOLoader(t),this._usdLoader=new W.USDLoader,this._stepLoader=new H}async load(t,n){let r;if(n)r=n;else if(r=C.getFileTypeFromUri(t),r.length===0&&(r=await this._detectFileTypeFromContent(t),r.length===0))throw new L.FileTypeError("No file extension found in URI","");if(!C.isFileTypeSupported(r))throw new L.FileTypeError(`Unsupported file type: ${r}. Supported types: ${j.SUPPORTED_FILE_TYPES.join(", ")}`,r);const s=E.AssetCache.read(t);if(s)return s.arrayBuffer?this._parse(s.arrayBuffer,r):s.promise.then(o=>this._parse(o,r));const e=await E.AssetCache.create(t).load();return this._parse(e,r)}async _detectFileTypeFromContent(t){try{const n=E.AssetCache.read(t);let r;n?n.arrayBuffer?r=n.arrayBuffer:r=await n.promise:r=await E.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 L.ParseError(`Failed to parse ${n} file: ${r.message}`,r):new L.ParseError(`Failed to parse ${n} file`)}}}exports.AssetLoader=z;exports.DRACOWorker=I;exports.DracoLoader=P;
|
|
@@ -0,0 +1,499 @@
|
|
|
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-DU8bBa_V.mjs";
|
|
7
|
+
import { Group as b, BufferGeometry as k, BufferAttribute as E, MeshStandardMaterial as F, Mesh as N } from "three/webgpu";
|
|
8
|
+
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
9
|
+
import "three/tsl";
|
|
10
|
+
import { g as x, i as G } from "./isFileTypeSupported-DY4QOFj7.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-DNcSNSJk.mjs";
|
|
14
|
+
function v() {
|
|
15
|
+
let _, r;
|
|
16
|
+
onmessage = function(e) {
|
|
17
|
+
const n = e.data;
|
|
18
|
+
switch (n.type) {
|
|
19
|
+
case "init":
|
|
20
|
+
_ = n.decoderConfig, r = new Promise(function(a) {
|
|
21
|
+
_.onModuleLoaded = function(u) {
|
|
22
|
+
a({ draco: u });
|
|
23
|
+
}, DracoDecoderModule(_);
|
|
24
|
+
});
|
|
25
|
+
break;
|
|
26
|
+
case "decode":
|
|
27
|
+
const i = n.buffer, d = n.taskConfig;
|
|
28
|
+
r.then((a) => {
|
|
29
|
+
const u = a.draco, c = new u.Decoder();
|
|
30
|
+
try {
|
|
31
|
+
const f = s(
|
|
32
|
+
u,
|
|
33
|
+
c,
|
|
34
|
+
new Int8Array(i),
|
|
35
|
+
d
|
|
36
|
+
), p = f.attributes.map(
|
|
37
|
+
(m) => m.array.buffer
|
|
38
|
+
);
|
|
39
|
+
f.index && p.push(f.index.array.buffer), self.postMessage(
|
|
40
|
+
{ type: "decode", id: n.id, geometry: f },
|
|
41
|
+
p
|
|
42
|
+
);
|
|
43
|
+
} catch (f) {
|
|
44
|
+
console.error(f), self.postMessage({
|
|
45
|
+
type: "error",
|
|
46
|
+
id: n.id,
|
|
47
|
+
error: f.message
|
|
48
|
+
});
|
|
49
|
+
} finally {
|
|
50
|
+
u.destroy(c);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
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);
|
|
60
|
+
if (p === e.TRIANGULAR_MESH)
|
|
61
|
+
c = new e.Mesh(), f = n.DecodeArrayToMesh(
|
|
62
|
+
i,
|
|
63
|
+
i.byteLength,
|
|
64
|
+
c
|
|
65
|
+
);
|
|
66
|
+
else if (p === e.POINT_CLOUD)
|
|
67
|
+
c = new e.PointCloud(), f = n.DecodeArrayToPointCloud(
|
|
68
|
+
i,
|
|
69
|
+
i.byteLength,
|
|
70
|
+
c
|
|
71
|
+
);
|
|
72
|
+
else
|
|
73
|
+
throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
|
|
74
|
+
if (!f.ok() || c.ptr === 0)
|
|
75
|
+
throw new Error(
|
|
76
|
+
"THREE.DRACOLoader: Decoding failed: " + f.error_msg()
|
|
77
|
+
);
|
|
78
|
+
const m = { index: null, attributes: [] };
|
|
79
|
+
for (const g in a) {
|
|
80
|
+
const w = self[u[g]];
|
|
81
|
+
let y, A;
|
|
82
|
+
if (d.useUniqueIDs)
|
|
83
|
+
A = a[g], y = n.GetAttributeByUniqueId(
|
|
84
|
+
c,
|
|
85
|
+
A
|
|
86
|
+
);
|
|
87
|
+
else {
|
|
88
|
+
if (A = n.GetAttributeId(
|
|
89
|
+
c,
|
|
90
|
+
e[a[g]]
|
|
91
|
+
), A === -1) continue;
|
|
92
|
+
y = n.GetAttribute(c, A);
|
|
93
|
+
}
|
|
94
|
+
const S = o(
|
|
95
|
+
e,
|
|
96
|
+
n,
|
|
97
|
+
c,
|
|
98
|
+
g,
|
|
99
|
+
w,
|
|
100
|
+
y
|
|
101
|
+
);
|
|
102
|
+
g === "color" && (S.vertexColorSpace = d.vertexColorSpace), m.attributes.push(S);
|
|
103
|
+
}
|
|
104
|
+
return p === e.TRIANGULAR_MESH && (m.index = t(e, n, c)), e.destroy(c), m;
|
|
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(
|
|
110
|
+
e.HEAPF32.buffer,
|
|
111
|
+
c,
|
|
112
|
+
a
|
|
113
|
+
).slice();
|
|
114
|
+
return e._free(c), { array: f, itemSize: 1 };
|
|
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);
|
|
118
|
+
n.GetAttributeDataArrayForAllPoints(
|
|
119
|
+
i,
|
|
120
|
+
u,
|
|
121
|
+
g,
|
|
122
|
+
m,
|
|
123
|
+
w
|
|
124
|
+
);
|
|
125
|
+
const y = new a(
|
|
126
|
+
e.HEAPF32.buffer,
|
|
127
|
+
w,
|
|
128
|
+
p
|
|
129
|
+
).slice();
|
|
130
|
+
return e._free(w), {
|
|
131
|
+
name: d,
|
|
132
|
+
array: y,
|
|
133
|
+
itemSize: c
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function l(e, n) {
|
|
137
|
+
switch (n) {
|
|
138
|
+
case Float32Array:
|
|
139
|
+
return e.DT_FLOAT32;
|
|
140
|
+
case Int8Array:
|
|
141
|
+
return e.DT_INT8;
|
|
142
|
+
case Int16Array:
|
|
143
|
+
return e.DT_INT16;
|
|
144
|
+
case Int32Array:
|
|
145
|
+
return e.DT_INT32;
|
|
146
|
+
case Uint8Array:
|
|
147
|
+
return e.DT_UINT8;
|
|
148
|
+
case Uint16Array:
|
|
149
|
+
return e.DT_UINT16;
|
|
150
|
+
case Uint32Array:
|
|
151
|
+
return e.DT_UINT32;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const L = {
|
|
156
|
+
LOAD_DRACO_JS_DECODER: async () => (await import("three/examples/jsm/libs/draco/draco_decoder.js?raw")).default,
|
|
157
|
+
LOAD_DRACO_WASM_WRAPPER: async () => (await import("three/examples/jsm/libs/draco/draco_wasm_wrapper.js?raw")).default,
|
|
158
|
+
LOAD_DRACO_WASM_DECODER: async () => {
|
|
159
|
+
const _ = (await import("three/examples/jsm/libs/draco/draco_decoder.wasm?url")).default;
|
|
160
|
+
return await (await fetch(_)).arrayBuffer();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
class j extends W {
|
|
164
|
+
constructor() {
|
|
165
|
+
super(...arguments);
|
|
166
|
+
h(this, "decoderPending", null);
|
|
167
|
+
h(this, "decoderConfig", {
|
|
168
|
+
type: "js",
|
|
169
|
+
wasmBinary: null
|
|
170
|
+
});
|
|
171
|
+
h(this, "workerSourceURL", "");
|
|
172
|
+
}
|
|
173
|
+
async _initDecoder() {
|
|
174
|
+
if (this.decoderPending) return this.decoderPending;
|
|
175
|
+
const s = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];
|
|
176
|
+
return s ? t.push(
|
|
177
|
+
L.LOAD_DRACO_JS_DECODER()
|
|
178
|
+
) : (t.push(
|
|
179
|
+
L.LOAD_DRACO_WASM_WRAPPER()
|
|
180
|
+
), t.push(
|
|
181
|
+
L.LOAD_DRACO_WASM_DECODER()
|
|
182
|
+
)), this.decoderPending = Promise.all(t).then(
|
|
183
|
+
(o) => {
|
|
184
|
+
const l = o[0];
|
|
185
|
+
s || (this.decoderConfig.wasmBinary = o[1]);
|
|
186
|
+
const e = v.toString(), n = [
|
|
187
|
+
"/* draco decoder */",
|
|
188
|
+
l,
|
|
189
|
+
"",
|
|
190
|
+
"/* worker */",
|
|
191
|
+
e.substring(e.indexOf("{") + 1, e.lastIndexOf("}"))
|
|
192
|
+
].join(`
|
|
193
|
+
`);
|
|
194
|
+
this.workerSourceURL = URL.createObjectURL(new Blob([n]));
|
|
195
|
+
}
|
|
196
|
+
), this.decoderPending;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function B() {
|
|
200
|
+
let _ = null, r = null;
|
|
201
|
+
const s = [
|
|
202
|
+
[
|
|
203
|
+
/'CONFIG_CONTROL_DESIGN'\s*\)/g,
|
|
204
|
+
"'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF')"
|
|
205
|
+
],
|
|
206
|
+
[
|
|
207
|
+
/'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF\.\s*\{[\s\S]*?\}\s*'/g,
|
|
208
|
+
"'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF'"
|
|
209
|
+
]
|
|
210
|
+
];
|
|
211
|
+
function t() {
|
|
212
|
+
return _ || (_ = occtimportjs({
|
|
213
|
+
// eslint-disable-line no-undef
|
|
214
|
+
locateFile: function() {
|
|
215
|
+
return r;
|
|
216
|
+
}
|
|
217
|
+
})), _;
|
|
218
|
+
}
|
|
219
|
+
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);
|
|
223
|
+
}
|
|
224
|
+
return new Uint8Array(i.encode(d));
|
|
225
|
+
}
|
|
226
|
+
function l(e, n) {
|
|
227
|
+
var i = o(n);
|
|
228
|
+
try {
|
|
229
|
+
var d = e.ReadStepFile(i, null);
|
|
230
|
+
if (d.success && d.root) return d;
|
|
231
|
+
} catch {
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
return e.ReadStepFile(n, null);
|
|
235
|
+
} catch {
|
|
236
|
+
return {
|
|
237
|
+
success: !1,
|
|
238
|
+
root: { meshes: [], children: [] },
|
|
239
|
+
meshes: []
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
onmessage = async function(e) {
|
|
244
|
+
var n = e.data;
|
|
245
|
+
switch (n.type) {
|
|
246
|
+
case "init":
|
|
247
|
+
r = n.wasmUrl;
|
|
248
|
+
break;
|
|
249
|
+
case "parse":
|
|
250
|
+
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) {
|
|
253
|
+
self.postMessage({
|
|
254
|
+
type: "error",
|
|
255
|
+
id: n.id,
|
|
256
|
+
error: "Failed to parse CAD file"
|
|
257
|
+
});
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
self.postMessage({
|
|
261
|
+
type: "result",
|
|
262
|
+
id: n.id,
|
|
263
|
+
result: u
|
|
264
|
+
});
|
|
265
|
+
} catch (c) {
|
|
266
|
+
self.postMessage({
|
|
267
|
+
type: "error",
|
|
268
|
+
id: n.id,
|
|
269
|
+
error: c instanceof Error ? c.message : String(c)
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
const T = {
|
|
277
|
+
LOAD_OCCT_JS: async () => (await import("./occt-import-js-D-bjjBtk.mjs")).default,
|
|
278
|
+
LOAD_OCCT_WASM_URL: async () => (await import("./occt-import-js-ekuHaP1Z.mjs")).default
|
|
279
|
+
};
|
|
280
|
+
class H {
|
|
281
|
+
constructor() {
|
|
282
|
+
h(this, "_workerPending", null);
|
|
283
|
+
h(this, "_worker", null);
|
|
284
|
+
h(this, "_nextId", 0);
|
|
285
|
+
h(this, "_pending", /* @__PURE__ */ new Map());
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Create (or return existing) blob-URL worker.
|
|
289
|
+
* Loads occt-import-js JS as raw text, concatenates with STEPWorker
|
|
290
|
+
* function body, and creates a classic (non-module) worker.
|
|
291
|
+
*/
|
|
292
|
+
_getWorker() {
|
|
293
|
+
return this._workerPending ? this._workerPending : (this._workerPending = (async () => {
|
|
294
|
+
const [
|
|
295
|
+
r,
|
|
296
|
+
s
|
|
297
|
+
] = await Promise.all([
|
|
298
|
+
T.LOAD_OCCT_JS(),
|
|
299
|
+
T.LOAD_OCCT_WASM_URL()
|
|
300
|
+
]), t = B.toString(), o = [
|
|
301
|
+
"/* occt-import-js */",
|
|
302
|
+
r,
|
|
303
|
+
"",
|
|
304
|
+
"/* step worker */",
|
|
305
|
+
t.substring(t.indexOf("{") + 1, t.lastIndexOf("}"))
|
|
306
|
+
].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")
|
|
312
|
+
try {
|
|
313
|
+
f.resolve(this._buildScene(u));
|
|
314
|
+
} catch (p) {
|
|
315
|
+
f.reject(
|
|
316
|
+
p instanceof Error ? p : new Error(String(p))
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
else
|
|
320
|
+
f.reject(new Error(c ?? "Worker error"));
|
|
321
|
+
}, e.onerror = (i) => {
|
|
322
|
+
for (const [
|
|
323
|
+
,
|
|
324
|
+
{ reject: d }
|
|
325
|
+
] of this._pending)
|
|
326
|
+
d(new Error(i.message ?? "Worker error"));
|
|
327
|
+
this._pending.clear();
|
|
328
|
+
}, this._worker = e, e;
|
|
329
|
+
})(), this._workerPending);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Parse STEP or IGES file content and return a Three.js Object3D
|
|
333
|
+
*/
|
|
334
|
+
async parseAsync(r, s) {
|
|
335
|
+
const t = this._nextId++, o = await this._getWorker();
|
|
336
|
+
return new Promise((l, e) => {
|
|
337
|
+
this._pending.set(t, { resolve: l, reject: e });
|
|
338
|
+
const n = r.slice(0);
|
|
339
|
+
o.postMessage({ type: "parse", id: t, buffer: n, fileType: s }, [
|
|
340
|
+
n
|
|
341
|
+
]);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Dispose the worker. Call when the loader is no longer needed.
|
|
346
|
+
*/
|
|
347
|
+
dispose() {
|
|
348
|
+
if (this._worker) {
|
|
349
|
+
for (const [
|
|
350
|
+
,
|
|
351
|
+
{ reject: r }
|
|
352
|
+
] of this._pending)
|
|
353
|
+
r(new Error("STEPLoader disposed"));
|
|
354
|
+
this._pending.clear(), this._worker.terminate(), this._worker = null, this._workerPending = null;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
_buildScene(r) {
|
|
358
|
+
const s = new b();
|
|
359
|
+
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
|
+
}
|
|
361
|
+
_buildNode(r, s, t) {
|
|
362
|
+
const o = new b();
|
|
363
|
+
o.name = r.name ?? "Part";
|
|
364
|
+
for (const l of r.meshes) {
|
|
365
|
+
const e = s[l];
|
|
366
|
+
if (e != null && e.attributes) {
|
|
367
|
+
const n = this._createMesh(e);
|
|
368
|
+
o.add(n);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
for (const l of r.children)
|
|
372
|
+
this._buildNode(l, s, o);
|
|
373
|
+
t.add(o);
|
|
374
|
+
}
|
|
375
|
+
_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(
|
|
379
|
+
"position",
|
|
380
|
+
new E(new Float32Array(s.array), 3)
|
|
381
|
+
), (d = t == null ? void 0 : t.array) != null && d.length ? l.setAttribute(
|
|
382
|
+
"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)
|
|
386
|
+
);
|
|
387
|
+
const e = r.color, n = new F({
|
|
388
|
+
metalness: 0.3,
|
|
389
|
+
roughness: 0.6
|
|
390
|
+
});
|
|
391
|
+
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;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
class te {
|
|
397
|
+
constructor() {
|
|
398
|
+
h(this, "_gltfLoader");
|
|
399
|
+
h(this, "_usdLoader");
|
|
400
|
+
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();
|
|
403
|
+
}
|
|
404
|
+
async load(r, s) {
|
|
405
|
+
let t;
|
|
406
|
+
if (s)
|
|
407
|
+
t = s;
|
|
408
|
+
else if (t = x(r), t.length === 0 && (t = await this._detectFileTypeFromContent(r), t.length === 0))
|
|
409
|
+
throw new R(
|
|
410
|
+
"No file extension found in URI",
|
|
411
|
+
""
|
|
412
|
+
);
|
|
413
|
+
if (!G(t))
|
|
414
|
+
throw new R(
|
|
415
|
+
`Unsupported file type: ${t}. Supported types: ${M.join(", ")}`,
|
|
416
|
+
t
|
|
417
|
+
);
|
|
418
|
+
const o = D.read(r);
|
|
419
|
+
if (o)
|
|
420
|
+
return o.arrayBuffer ? this._parse(o.arrayBuffer, t) : o.promise.then((n) => this._parse(n, t));
|
|
421
|
+
const e = await D.create(r).load();
|
|
422
|
+
return this._parse(e, t);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Detects file type from content (magic bytes)
|
|
426
|
+
* @param uri - The URI to load and detect
|
|
427
|
+
* @returns The detected file extension or empty string if detection fails
|
|
428
|
+
*/
|
|
429
|
+
async _detectFileTypeFromContent(r) {
|
|
430
|
+
try {
|
|
431
|
+
const s = D.read(r);
|
|
432
|
+
let t;
|
|
433
|
+
s ? s.arrayBuffer ? t = s.arrayBuffer : t = await s.promise : t = await D.create(r).load();
|
|
434
|
+
const o = new Uint8Array(t);
|
|
435
|
+
return o.length >= 12 && String.fromCharCode(
|
|
436
|
+
o[0],
|
|
437
|
+
o[1],
|
|
438
|
+
o[2],
|
|
439
|
+
o[3]
|
|
440
|
+
) === "glTF" ? o[12] === 0 ? "glb" : "gltf" : o.length >= 4 && o[0] === 80 && // 'P'
|
|
441
|
+
o[1] === 75 && // 'K'
|
|
442
|
+
(o[2] === 3 || o[2] === 5) && (o[3] === 4 || o[3] === 6) ? "usdz" : o.length >= 20 && new TextDecoder("ascii").decode(
|
|
443
|
+
o.subarray(0, 20)
|
|
444
|
+
).startsWith("ISO-10303-21") ? "step" : o.length >= 80 && o[72] === 83 ? "iges" : "";
|
|
445
|
+
} catch {
|
|
446
|
+
return "";
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* parse function for the chunk
|
|
451
|
+
* @param arrayBuffer - the array buffer to parse, will be provided within the chunk
|
|
452
|
+
* @param type - the file type of the array buffer
|
|
453
|
+
* @returns the parsed object, will be stored within the chunk
|
|
454
|
+
*/
|
|
455
|
+
async _parse(r, s) {
|
|
456
|
+
try {
|
|
457
|
+
switch (s) {
|
|
458
|
+
case "glb":
|
|
459
|
+
case "gltf": {
|
|
460
|
+
const t = await this._gltfLoader.parseAsync(
|
|
461
|
+
r,
|
|
462
|
+
""
|
|
463
|
+
);
|
|
464
|
+
return t.scene.animations = t.animations, t.scene;
|
|
465
|
+
}
|
|
466
|
+
case "usdz": {
|
|
467
|
+
const t = this._usdLoader.parse(r);
|
|
468
|
+
return t.animations = [], t;
|
|
469
|
+
}
|
|
470
|
+
case "step":
|
|
471
|
+
case "stp": {
|
|
472
|
+
const t = await this._stepLoader.parseAsync(
|
|
473
|
+
r,
|
|
474
|
+
s
|
|
475
|
+
);
|
|
476
|
+
return t.animations = [], t;
|
|
477
|
+
}
|
|
478
|
+
case "iges":
|
|
479
|
+
case "igs": {
|
|
480
|
+
const t = await this._stepLoader.parseAsync(
|
|
481
|
+
r,
|
|
482
|
+
s
|
|
483
|
+
);
|
|
484
|
+
return t.animations = [], t;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
} catch (t) {
|
|
488
|
+
throw t instanceof Error ? new O(
|
|
489
|
+
`Failed to parse ${s} file: ${t.message}`,
|
|
490
|
+
t
|
|
491
|
+
) : new O(`Failed to parse ${s} file`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
export {
|
|
496
|
+
te as A,
|
|
497
|
+
v as D,
|
|
498
|
+
j as a
|
|
499
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var h = Object.defineProperty;
|
|
2
2
|
var a = (s, i, t) => i in s ? h(s, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[i] = t;
|
|
3
3
|
var n = (s, i, t) => a(s, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
-
import { AnimationMixer as p, LoopOnce as c, LoopPingPong as u, LoopRepeat as _ } from "three";
|
|
5
|
-
import { A as l } from "./Animator-
|
|
4
|
+
import { AnimationMixer as p, LoopOnce as c, LoopPingPong as u, LoopRepeat as _ } from "three/webgpu";
|
|
5
|
+
import { A as l } from "./Animator-DHnpWRt_.mjs";
|
|
6
6
|
class g extends l {
|
|
7
7
|
constructor(t, r) {
|
|
8
8
|
super();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var h=(s,i,t)=>i in s?a(s,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[i]=t;var n=(s,i,t)=>h(s,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("three/webgpu"),u=require("./Animator-YDE8aFEd.cjs");class p extends u.Animator{constructor(t,o){super();n(this,"_mixer");n(this,"_actions",new Map);n(this,"_currentAction",null);n(this,"_state","idle");n(this,"_loop","once");this._mixer=new r.AnimationMixer(t);for(const e of o){const c=this._mixer.clipAction(e);c.clampWhenFinished=!0,c.loop=r.LoopOnce,this._actions.set(e.name,c)}this._mixer.addEventListener("finished",()=>{this._state="idle",this.dispatchEvent({type:"complete",target:this})})}get state(){return this._state}get duration(){var t;return((t=this._currentAction)==null?void 0:t.getClip().duration)??0}get loop(){return this._loop}set loop(t){this._loop=t,this._currentAction&&(this._currentAction.loop=this._resolveLoopConstant(t))}_resolveLoopConstant(t){switch(t){case"repeat":return r.LoopRepeat;case"pingpong":return r.LoopPingPong;default:return r.LoopOnce}}get time(){var t;return((t=this._currentAction)==null?void 0:t.time)??0}set time(t){this._currentAction&&(this._currentAction.time=t)}get clipNames(){return[...this._actions.keys()]}get currentClipName(){return this._currentAction?this._currentAction.getClip().name:null}play(t){const o=t??this._actions.keys().next().value??void 0;if(o===void 0)return this;const e=this._actions.get(o);return e?(this._currentAction&&this._currentAction!==e?(this._currentAction.fadeOut(.3),e.reset().fadeIn(.3)):this._state==="idle"&&e.reset(),e.loop=this._resolveLoopConstant(this._loop),e.play(),this._state="playing",this._currentAction=e,this._currentAction.paused=!1,this.dispatchEvent({type:"play",target:this}),this):this}pause(){return this._state="paused",this._currentAction&&(this._currentAction.paused=!0),this.dispatchEvent({type:"pause",target:this}),this}resume(){return this._state="playing",this._currentAction&&(this._currentAction.paused=!1),this.dispatchEvent({type:"resume",target:this}),this}stop(){return this._state="idle",this._mixer.stopAllAction(),this._currentAction=null,this.dispatchEvent({type:"stop",target:this}),this}update(t){this._mixer.update(t)}dispose(){this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._mixer.getRoot()),this._actions.clear(),this._currentAction=null,this._state="idle"}}exports.ClipAnimator=p;
|