@shopware-ag/dive 4.0.0 → 4.0.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/{AssetCache-DdxevusY.cjs → AssetCache-CUVFS7wk.cjs} +1 -1
- package/build/chunks/{AssetCache-MXFCGzZU.mjs → AssetCache-DnAAa719.mjs} +1 -1
- package/build/chunks/{AssetLoader-kRhuVN4p.mjs → AssetLoader-Bkp3fWZz.mjs} +3 -3
- package/build/chunks/{AssetLoader-BDDJG9JL.cjs → AssetLoader-DnVvCd41.cjs} +1 -1
- package/build/chunks/{FileTypes-gD_1MonW.cjs → FileTypes-B-MjfMGd.cjs} +1 -1
- package/build/chunks/{FileTypes-DGSsi-AX.mjs → FileTypes-D3Dxr2dj.mjs} +1 -1
- package/build/chunks/{ModelComponent-Cj3ff6nL.cjs → ModelComponent-Cmu0EX0r.cjs} +1 -1
- package/build/chunks/{ModelComponent-DkfAgTL0.mjs → ModelComponent-WA0kLOEY.mjs} +1 -1
- package/build/chunks/{OrbitController-DFPcXvlO.cjs → OrbitController-CAJIiZeE.cjs} +1 -1
- package/build/chunks/{OrbitController-DLEyTvUt.mjs → OrbitController-DxCbrQVB.mjs} +1 -1
- package/build/chunks/{SpriteTextComponent-ByefJLeU.cjs → SpriteTextComponent-BpoKLOjA.cjs} +1 -1
- package/build/chunks/{SpriteTextComponent-CG5vfiFy.mjs → SpriteTextComponent-DIZFqao0.mjs} +1 -1
- package/build/chunks/{detachTransformControls-Dr3TIdVy.mjs → detachTransformControls-B4iRF1bw.mjs} +1 -1
- package/build/chunks/{detachTransformControls-2XQrpLN-.cjs → detachTransformControls-CZ2cd5hx.cjs} +1 -1
- package/build/chunks/{isFileExtensionSupported-RvlnH2dr.cjs → isFileExtensionSupported-B1q2eWs7.cjs} +1 -1
- package/build/chunks/{isFileExtensionSupported-CgcqpgqN.mjs → isFileExtensionSupported-BqOqU3-h.mjs} +1 -1
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +6 -6
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +1 -1
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +2 -2
- package/build/plugins/mediacreator/index.cjs +1 -1
- package/build/plugins/mediacreator/index.mjs +1 -1
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +2 -2
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +49 -48
- package/build/plugins/quickview/src/QuickView.d.ts +2 -3
- package/build/plugins/quickview/types/QuickViewSettings.d.ts +0 -14
- package/build/plugins/state/index.cjs +1 -1
- package/build/plugins/state/index.mjs +3 -3
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +1 -1
- package/package.json +5 -4
|
@@ -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-
|
|
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-B-MjfMGd.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-
|
|
4
|
+
import "./FileTypes-D3Dxr2dj.mjs";
|
|
5
5
|
import "three/webgpu";
|
|
6
6
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
7
7
|
import "three/tsl";
|
|
@@ -3,14 +3,14 @@ var F = (_, r, s) => r in _ ? k(_, r, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var h = (_, r, s) => F(_, typeof r != "symbol" ? r + "" : r, s);
|
|
4
4
|
import { GLTFLoader as x } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
5
5
|
import { USDLoader as G } from "three/examples/jsm/loaders/USDLoader.js";
|
|
6
|
-
import { S as B } from "./FileTypes-
|
|
6
|
+
import { S as B } from "./FileTypes-D3Dxr2dj.mjs";
|
|
7
7
|
import { Group as C, BufferGeometry as W, BufferAttribute as T, 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 H, i as z } from "./isFileExtensionSupported-
|
|
10
|
+
import { g as H, i as z } from "./isFileExtensionSupported-BqOqU3-h.mjs";
|
|
11
11
|
import { F as P, P as M } from "./parse-error-DfOPyLWM.mjs";
|
|
12
12
|
import { DRACOLoader as Y } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
13
|
-
import { A as S } from "./AssetCache-
|
|
13
|
+
import { A as S } from "./AssetCache-DnAAa719.mjs";
|
|
14
14
|
function J() {
|
|
15
15
|
let _, r;
|
|
16
16
|
onmessage = function(e) {
|
|
@@ -1,3 +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-
|
|
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-B-MjfMGd.cjs"),w=require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const U=require("./isFileExtensionSupported-B1q2eWs7.cjs"),R=require("./parse-error-Dy_EE4rL.cjs"),$=require("three/examples/jsm/loaders/DRACOLoader.js"),T=require("./AssetCache-CUVFS7wk.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
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
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.isFileExtensionSupported(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;
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
@@%-::::::::::::-%@ @%-------------=%@@
|
|
27
27
|
@@@@+:::::::#@@ @@*-------*@@@@
|
|
28
28
|
@@@@@@@ @@@@@@
|
|
29
|
-
`;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]},instanceLimit:8};const w={autoStart:!0,displayAxes:!1,...M,...u,...O};class DA{constructor(i){g(this,"_instanceId",t.MathUtils.generateUUID());g(this,"_settings");g(this,"_disposed",!1);g(this,"_views");g(this,"_mainView");g(this,"_scene");g(this,"_clock");g(this,"_orientationDisplay",null);if(this._settings={...w,...i??{}},window.DIVE.instances.length==window.DIVE.instanceLimit)throw new Error(`DIVE instance limit exceeded! Maximum allowed instances: ${window.DIVE.instanceLimit}. Current instances: ${window.DIVE.instances.length}.`);this._clock=new S,this._scene=new rA({backgroundColor:(i==null?void 0:i.backgroundColor)??w.backgroundColor,displayGrid:(i==null?void 0:i.displayGrid)??w.displayGrid,displayFloor:(i==null?void 0:i.displayFloor)??w.displayFloor}),this._clock.addTicker(this._scene);const A=new Y;A.name="DIVECamera";const e=A.addComponent(new hA);e.applySettings(this._settings),this._scene.add(A);const o=new eA(this._scene,e,this._settings);this._clock.addTicker(o),this._views=[o],this._mainView=o,this._settings.displayAxes&&Promise.resolve().then(()=>require("../plugins/orientationdisplay/index.cjs")).then(({OrientationDisplay:s})=>{this._disposed||(this._orientationDisplay=new s(this.mainView.renderer,this.scene,this.mainView.cameraComponent),this._clock.addTicker(this._orientationDisplay))}),console.log("DIVE 4.0.0 initialized successfully!"),console.log(mA),window.DIVE.instances.push(this),this._settings.autoStart&&this.startAsync()}get views(){return this._views}get mainView(){return this._mainView}get canvas(){return this.mainView.canvas}get scene(){return this._scene}get clock(){return this._clock}async startAsync(){this._disposed||(await this._clock.startAsync(),await this.mainView.initAsync())}stop(){this._clock.stop()}async disposeAsync(){return new Promise(i=>{if(this._disposed){i();return}this._disposed=!0,this._clock.dispose(),this._orientationDisplay&&(this._orientationDisplay.dispose(),this._orientationDisplay=null),this.scene.dispose(),this._views.forEach(A=>{A.dispose()}),this._views=[],window.DIVE.instances=window.DIVE.instances.filter(A=>A._instanceId!==this._instanceId),i()})}}const KA=new t.Matrix4,D=new t.Vector3,Q=new t.Quaternion,W=new t.Vector3,x=new t.Vector3;class BA{constructor(){g(this,"isBoundingBox",!0);g(this,"_box",new t.Box3);g(this,"_sphere",new t.Sphere);g(this,"_center",new t.Vector3);g(this,"_size",new t.Vector3);g(this,"_frame",new t.Matrix4);g(this,"_oriented",!1)}get box(){return this._box}get size(){return this._size}get center(){return this._center}get sphere(){return this._sphere}get radius(){return this._sphere.radius}get frame(){return this._frame}get isEmpty(){return this._box.isEmpty()}enclose(i){return this._oriented=!1,this._frame.identity(),this._measure(i)}encloseOriented(i,A){return this._oriented=!0,A.updateWorldMatrix(!0,!1),A.matrixWorld.decompose(D,Q,W),this._frame.compose(D,Q,W.setScalar(1)),this._measure(i)}clear(){return this._oriented=!1,this._frame.identity(),this._box.makeEmpty(),this._derive()}_measure(i){const A=Array.isArray(i)?i:[i],e=this._oriented?KA.copy(this._frame).invert():void 0;this._box.makeEmpty();const o=new t.Box3;return A.forEach(s=>{this._box.union(G(s,o,e))}),this._derive()}_derive(){return this._box.getSize(this._size),this._box.getCenter(D),this._center.copy(D).applyMatrix4(this._frame),this._box.isEmpty()?(this._sphere.makeEmpty(),this):(this._sphere.center.copy(this._center),this._sphere.radius=this._worldRadius(),this)}_worldRadius(){let i=0;for(let A=0;A<8;A++)x.set(A&1?this._box.max.x:this._box.min.x,A&2?this._box.max.y:this._box.min.y,A&4?this._box.max.z:this._box.min.z),i=Math.max(i,x.applyMatrix4(this._frame).distanceTo(this._center));return i}}const a=6,P=2,pA=2,vA=8,HA=new t.Vector3;class qA extends C{constructor(){super();g(this,"isMultiLineComponent",!0);g(this,"_lines");g(this,"_geometry");g(this,"_material");g(this,"_positions");g(this,"_distances");g(this,"_byKey",new Map);g(this,"_freeSlots",[]);g(this,"_capacity",vA);g(this,"_highWater",0);this.name="MultiLineComponent",this._material=new t.LineDashedMaterial({color:6710886,dashSize:.05,gapSize:.025}),this._geometry=new t.BufferGeometry,this._positions=this._createAttribute(a,3),this._distances=this._createAttribute(P,1),this._geometry.setAttribute("position",this._positions),this._geometry.setAttribute("lineDistance",this._distances),this._geometry.setDrawRange(0,0),this._lines=new t.LineSegments(this._geometry,this._material),this._lines.layers.mask=h.HELPER_LAYER_MASK,this._lines.frustumCulled=!1,this.contribute(this._lines)}get lines(){return this._lines}get lineCount(){return this._byKey.size}setLineFor(A,e,o){const s=this._byKey.get(A);if(s){s.start.set(e.x,e.y,e.z),s.end.set(o.x,o.y,o.z),this._writeLine(s);return}const n=this._freeSlots.pop()??this._byKey.size;n>=this._capacity&&this._grow();const r={slot:n,start:new t.Vector3(e.x,e.y,e.z),end:new t.Vector3(o.x,o.y,o.z),visible:!0};this._byKey.set(A,r),n+1>this._highWater&&(this._highWater=n+1,this._geometry.setDrawRange(0,this._highWater*pA)),this._writeLine(r)}removeLineFor(A){const e=this._byKey.get(A);e&&(this._byKey.delete(A),this._freeSlots.push(e.slot),this._collapseSlot(e.slot))}hasLineFor(A){return this._byKey.has(A)}setLineVisibleFor(A,e){const o=this._byKey.get(A);o&&(o.visible=e,this._writeLine(o))}setVisible(A){this._lines.visible=A}setColor(A){this._material.color.set(A)}setDashPattern(A,e){this._material.dashSize=A,this._material.gapSize=e}clearLines(){this._byKey.forEach(A=>this._collapseSlot(A.slot)),this._byKey.clear(),this._freeSlots=[],this._highWater=0,this._geometry.setDrawRange(0,0)}copy(A){return super.copy(A),this.setColor(A._material.color),this.setDashPattern(A._material.dashSize,A._material.gapSize),this.setVisible(A._lines.visible),this}dispose(){this._geometry.dispose(),this._material.dispose(),this._byKey.clear(),this._freeSlots=[]}_createAttribute(A,e){const o=new t.Float32BufferAttribute(new Float32Array(this._capacity*A),e);return o.setUsage(t.DynamicDrawUsage),o}_writeLine(A){if(!A.visible){this._collapseSlot(A.slot);return}const{slot:e,start:o,end:s}=A,n=e*a,r=this._positions.array;r[n]=o.x,r[n+1]=o.y,r[n+2]=o.z,r[n+3]=s.x,r[n+4]=s.y,r[n+5]=s.z;const B=this._distances.array,c=e*P;B[c]=0,B[c+1]=HA.subVectors(s,o).length(),this._markSlotDirty(e)}_collapseSlot(A){const e=A*a;this._positions.array.fill(0,e,e+a);const o=A*P;this._distances.array.fill(0,o,o+P),this._markSlotDirty(A)}_markSlotDirty(A){this._positions.addUpdateRange(A*a,a),this._positions.needsUpdate=!0,this._distances.addUpdateRange(A*P,P),this._distances.needsUpdate=!0}_grow(){this._capacity*=2;const A=this._createAttribute(a,3);A.array.set(this._positions.array),this._positions=A;const e=this._createAttribute(P,1);e.array.set(this._distances.array),this._distances=e,this._geometry.setAttribute("position",this._positions),this._geometry.setAttribute("lineDistance",this._distances)}}class F extends C{constructor(A,e=1){super();g(this,"isDIVELightComponent",!0);g(this,"_light");g(this,"_intensityFactor");this._light=A,this._intensityFactor=e,this._light.layers.mask=h.PRODUCT_LAYER_MASK,this.contribute(this._light)}get light(){return this._light}setColor(A){this._light.color=A}setIntensity(A){this._light.intensity=A*this._intensityFactor}setEnabled(A){this._light.visible=A}copy(A){return super.copy(A),this.setColor(A._light.color.clone()),this.setIntensity(A._light.intensity/A._intensityFactor),this.setEnabled(A._light.visible),this._light.position.copy(A._light.position),this}dispose(){var A,e;(e=(A=this._light).dispose)==null||e.call(A)}}const YA=new t.Vector3(1,1.75,1).multiplyScalar(30),N=2048,K=5;class lA extends F{constructor(){super(new t.DirectionalLight(16777215,3),3);g(this,"isDirectionalLightComponent",!0);this.name="DirectionalLightComponent";const A=this._light;A.castShadow=!0,A.shadow.mapSize.width=N,A.shadow.mapSize.height=N,A.shadow.camera.left=-K,A.shadow.camera.right=K,A.shadow.camera.top=K,A.shadow.camera.bottom=-K,A.shadow.camera.far=3500,this.setDirection(YA)}setDirection(A){if(A.x===0&&A.y===0&&A.z===0){console.warn("DirectionalLightComponent.setDirection: a zero direction leaves the light without a direction; ignoring.");return}this._light.position.set(A.x,A.y,A.z)}}const bA=new t.Vector3(0,50,0);class dA extends F{constructor(){super(new t.HemisphereLight(16777215,16777215,2),2);g(this,"isHemisphereLightComponent",!0);this.name="HemisphereLightComponent",this.setDirection(bA)}setDirection(A){if(A.x===0&&A.y===0&&A.z===0){console.warn("HemisphereLightComponent.setDirection: a zero direction leaves the light without a sky axis; ignoring.");return}this._light.position.set(A.x,A.y,A.z)}}const p=new t.Matrix4,_=new t.Vector3,yA=new t.Vector3,k=new t.Quaternion,OA=()=>{const f=new t.BoxGeometry(1,1,1),i=new t.EdgesGeometry(f);return f.dispose(),i};class MA extends C{constructor(){super();g(this,"isBoundingBoxComponent",!0);g(this,"_boundingBox",new BA);g(this,"_oriented",!1);g(this,"_stale",!0);g(this,"_boxHelper");g(this,"_sphereHelper");g(this,"_invalidate",()=>{this._stale=!0});this.name="BoundingBoxComponent",this._boxHelper=new t.LineSegments(OA(),new t.LineBasicMaterial({color:65280})),this._sphereHelper=new t.Mesh(new t.SphereGeometry(.5,32,32),new t.MeshBasicMaterial({color:65280,wireframe:!0})),[this._boxHelper,this._sphereHelper].forEach(A=>{A.layers.mask=h.HELPER_LAYER_MASK,A.visible=!1,A.matrixAutoUpdate=!1}),this.contribute(this._boxHelper,this._sphereHelper),this.setTickEnabled(!1)}get boundingBox(){return this._measure(),this._boundingBox}get box(){return this.boundingBox.box}get size(){return this.boundingBox.size}get center(){return this.boundingBox.center}get sphere(){return this.boundingBox.sphere}get radius(){return this.boundingBox.radius}get oriented(){return this._oriented}get boxHelper(){return this._measure(),this._boxHelper}get sphereHelper(){return this._measure(),this._sphereHelper}setOriented(A){return this._oriented===A?this:(this._oriented=A,this._stale=!0,this)}refresh(){return this._stale=!0,this}setBoxHelperVisible(A){this._boxHelper.visible=A,this._refreshTick()}setSphereHelperVisible(A){this._sphereHelper.visible=A,this._refreshTick()}setHelperColor(A){this._boxHelper.material.color.set(A),this._sphereHelper.material.color.set(A)}tick(){this._measure()}onAttach(A){A.addEventListener("childadded",this._invalidate),A.addEventListener("childremoved",this._invalidate),A.addEventListener("componentadded",this._invalidate),A.addEventListener("componentremoved",this._invalidate),A.addEventListener("object-transform",this._invalidate),this._stale=!0}onDetach(A){A.removeEventListener("childadded",this._invalidate),A.removeEventListener("childremoved",this._invalidate),A.removeEventListener("componentadded",this._invalidate),A.removeEventListener("componentremoved",this._invalidate),A.removeEventListener("object-transform",this._invalidate),this._stale=!0}_measure(){if(!this._stale)return;if(this._stale=!1,!this.isAttached){this._boundingBox.clear(),this._place();return}const A=this.owner;this._oriented?this._boundingBox.encloseOriented(A,A):this._boundingBox.enclose(A),this._place()}_place(){const{box:A,frame:e,center:o,radius:s}=this._boundingBox;p.identity(),this.isAttached&&p.copy(this.owner.matrixWorld).invert(),A.getCenter(_),this._boxHelper.matrix.compose(_,k,this._boundingBox.size).premultiply(e).premultiply(p),this._sphereHelper.matrix.compose(o,k,yA.setScalar(Math.max(0,s)*2)).premultiply(p)}_refreshTick(){this.setTickEnabled(this._boxHelper.visible||this._sphereHelper.visible)}copy(A){return super.copy(A),this._oriented=A.oriented,this._stale=!0,this.setHelperColor(A._boxHelper.material.color),this.setBoxHelperVisible(A._boxHelper.visible),this.setSphereHelperVisible(A._sphereHelper.visible),this}dispose(){this._boxHelper.geometry.dispose(),this._boxHelper.material.dispose(),this._sphereHelper.geometry.dispose(),this._sphereHelper.material.dispose()}}const L={glb:{key:"glb",mimeTypes:["model/gltf-binary"],extension:"glb"},gltf:{key:"gltf",mimeTypes:["model/gltf+json"],extension:"gltf"},usdz:{key:"usdz",mimeTypes:["model/vnd.usdz+zip"],extension:"usdz"},step:{key:"step",mimeTypes:["application/step","model/step","model/step+zip","model/step+xml"],extension:"step"},stp:{key:"stp",mimeTypes:["application/step","model/step","model/step+zip","model/step+xml"],extension:"stp"},iges:{key:"iges",mimeTypes:["application/iges","model/iges","model/iges+zip","model/iges+xml"],extension:"iges"},igs:{key:"igs",mimeTypes:["application/iges","model/iges","model/iges+zip","model/iges+xml"],extension:"igs"}},FA=Object.values(L).map(f=>f.extension),LA=Object.values(L).flatMap(f=>f.mimeTypes);exports.BoundingBox=BA;exports.BoundingBoxComponent=MA;exports.DIVE=DA;exports.DIVEAbortablePromise=q;exports.DIVECameraComponent=H;exports.DIVECanvasLifecycleManager=iA;exports.DIVEClock=S;exports.DIVEComponent=C;exports.DIVEDefaultSettings=w;exports.DIVEDeferredPromise=AA;exports.DIVEEnvironment=U;exports.DIVEEnvironmentDefaultSettings=R;exports.DIVELightComponent=F;exports.DIVENode=Y;exports.DIVEPerspectiveCameraDefaultSettings=u;exports.DIVERenderer=$;exports.DIVERendererDefaultSettings=O;exports.DIVERoot=oA;exports.DIVEScene=rA;exports.DIVESceneDefaultSettings=M;exports.DIVEView=eA;exports.DirectionalLightComponent=lA;exports.FILE_TYPES=L;exports.FloorComponent=d;exports.GRID_MAJOR_LINE_COLOR=sA;exports.GRID_MINOR_LINE_COLOR=tA;exports.GridComponent=nA;exports.HemisphereLightComponent=dA;exports.MeshComponent=gA;exports.MultiLineComponent=qA;exports.PerspectiveCameraComponent=hA;exports.SUPPORTED_FILE_TYPES=FA;exports.SUPPORTED_MIME_TYPES=LA;exports.computeProductBounds=G;exports.contributedBy=b;exports.disposeComponents=fA;exports.findComponent=IA;exports.findSceneRecursive=y;exports.isDIVEComponent=CA;
|
|
29
|
+
`;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]},instanceLimit:8};const w={autoStart:!0,displayAxes:!1,...M,...u,...O};class DA{constructor(i){g(this,"_instanceId",t.MathUtils.generateUUID());g(this,"_settings");g(this,"_disposed",!1);g(this,"_views");g(this,"_mainView");g(this,"_scene");g(this,"_clock");g(this,"_orientationDisplay",null);if(this._settings={...w,...i??{}},window.DIVE.instances.length==window.DIVE.instanceLimit)throw new Error(`DIVE instance limit exceeded! Maximum allowed instances: ${window.DIVE.instanceLimit}. Current instances: ${window.DIVE.instances.length}.`);this._clock=new S,this._scene=new rA({backgroundColor:(i==null?void 0:i.backgroundColor)??w.backgroundColor,displayGrid:(i==null?void 0:i.displayGrid)??w.displayGrid,displayFloor:(i==null?void 0:i.displayFloor)??w.displayFloor}),this._clock.addTicker(this._scene);const A=new Y;A.name="DIVECamera";const e=A.addComponent(new hA);e.applySettings(this._settings),this._scene.add(A);const o=new eA(this._scene,e,this._settings);this._clock.addTicker(o),this._views=[o],this._mainView=o,this._settings.displayAxes&&Promise.resolve().then(()=>require("../plugins/orientationdisplay/index.cjs")).then(({OrientationDisplay:s})=>{this._disposed||(this._orientationDisplay=new s(this.mainView.renderer,this.scene,this.mainView.cameraComponent),this._clock.addTicker(this._orientationDisplay))}),console.log("DIVE 4.0.1 initialized successfully!"),console.log(mA),window.DIVE.instances.push(this),this._settings.autoStart&&this.startAsync()}get views(){return this._views}get mainView(){return this._mainView}get canvas(){return this.mainView.canvas}get scene(){return this._scene}get clock(){return this._clock}async startAsync(){this._disposed||(await this._clock.startAsync(),await this.mainView.initAsync())}stop(){this._clock.stop()}async disposeAsync(){return new Promise(i=>{if(this._disposed){i();return}this._disposed=!0,this._clock.dispose(),this._orientationDisplay&&(this._orientationDisplay.dispose(),this._orientationDisplay=null),this.scene.dispose(),this._views.forEach(A=>{A.dispose()}),this._views=[],window.DIVE.instances=window.DIVE.instances.filter(A=>A._instanceId!==this._instanceId),i()})}}const KA=new t.Matrix4,D=new t.Vector3,Q=new t.Quaternion,W=new t.Vector3,x=new t.Vector3;class BA{constructor(){g(this,"isBoundingBox",!0);g(this,"_box",new t.Box3);g(this,"_sphere",new t.Sphere);g(this,"_center",new t.Vector3);g(this,"_size",new t.Vector3);g(this,"_frame",new t.Matrix4);g(this,"_oriented",!1)}get box(){return this._box}get size(){return this._size}get center(){return this._center}get sphere(){return this._sphere}get radius(){return this._sphere.radius}get frame(){return this._frame}get isEmpty(){return this._box.isEmpty()}enclose(i){return this._oriented=!1,this._frame.identity(),this._measure(i)}encloseOriented(i,A){return this._oriented=!0,A.updateWorldMatrix(!0,!1),A.matrixWorld.decompose(D,Q,W),this._frame.compose(D,Q,W.setScalar(1)),this._measure(i)}clear(){return this._oriented=!1,this._frame.identity(),this._box.makeEmpty(),this._derive()}_measure(i){const A=Array.isArray(i)?i:[i],e=this._oriented?KA.copy(this._frame).invert():void 0;this._box.makeEmpty();const o=new t.Box3;return A.forEach(s=>{this._box.union(G(s,o,e))}),this._derive()}_derive(){return this._box.getSize(this._size),this._box.getCenter(D),this._center.copy(D).applyMatrix4(this._frame),this._box.isEmpty()?(this._sphere.makeEmpty(),this):(this._sphere.center.copy(this._center),this._sphere.radius=this._worldRadius(),this)}_worldRadius(){let i=0;for(let A=0;A<8;A++)x.set(A&1?this._box.max.x:this._box.min.x,A&2?this._box.max.y:this._box.min.y,A&4?this._box.max.z:this._box.min.z),i=Math.max(i,x.applyMatrix4(this._frame).distanceTo(this._center));return i}}const a=6,P=2,pA=2,vA=8,HA=new t.Vector3;class qA extends C{constructor(){super();g(this,"isMultiLineComponent",!0);g(this,"_lines");g(this,"_geometry");g(this,"_material");g(this,"_positions");g(this,"_distances");g(this,"_byKey",new Map);g(this,"_freeSlots",[]);g(this,"_capacity",vA);g(this,"_highWater",0);this.name="MultiLineComponent",this._material=new t.LineDashedMaterial({color:6710886,dashSize:.05,gapSize:.025}),this._geometry=new t.BufferGeometry,this._positions=this._createAttribute(a,3),this._distances=this._createAttribute(P,1),this._geometry.setAttribute("position",this._positions),this._geometry.setAttribute("lineDistance",this._distances),this._geometry.setDrawRange(0,0),this._lines=new t.LineSegments(this._geometry,this._material),this._lines.layers.mask=h.HELPER_LAYER_MASK,this._lines.frustumCulled=!1,this.contribute(this._lines)}get lines(){return this._lines}get lineCount(){return this._byKey.size}setLineFor(A,e,o){const s=this._byKey.get(A);if(s){s.start.set(e.x,e.y,e.z),s.end.set(o.x,o.y,o.z),this._writeLine(s);return}const n=this._freeSlots.pop()??this._byKey.size;n>=this._capacity&&this._grow();const r={slot:n,start:new t.Vector3(e.x,e.y,e.z),end:new t.Vector3(o.x,o.y,o.z),visible:!0};this._byKey.set(A,r),n+1>this._highWater&&(this._highWater=n+1,this._geometry.setDrawRange(0,this._highWater*pA)),this._writeLine(r)}removeLineFor(A){const e=this._byKey.get(A);e&&(this._byKey.delete(A),this._freeSlots.push(e.slot),this._collapseSlot(e.slot))}hasLineFor(A){return this._byKey.has(A)}setLineVisibleFor(A,e){const o=this._byKey.get(A);o&&(o.visible=e,this._writeLine(o))}setVisible(A){this._lines.visible=A}setColor(A){this._material.color.set(A)}setDashPattern(A,e){this._material.dashSize=A,this._material.gapSize=e}clearLines(){this._byKey.forEach(A=>this._collapseSlot(A.slot)),this._byKey.clear(),this._freeSlots=[],this._highWater=0,this._geometry.setDrawRange(0,0)}copy(A){return super.copy(A),this.setColor(A._material.color),this.setDashPattern(A._material.dashSize,A._material.gapSize),this.setVisible(A._lines.visible),this}dispose(){this._geometry.dispose(),this._material.dispose(),this._byKey.clear(),this._freeSlots=[]}_createAttribute(A,e){const o=new t.Float32BufferAttribute(new Float32Array(this._capacity*A),e);return o.setUsage(t.DynamicDrawUsage),o}_writeLine(A){if(!A.visible){this._collapseSlot(A.slot);return}const{slot:e,start:o,end:s}=A,n=e*a,r=this._positions.array;r[n]=o.x,r[n+1]=o.y,r[n+2]=o.z,r[n+3]=s.x,r[n+4]=s.y,r[n+5]=s.z;const B=this._distances.array,c=e*P;B[c]=0,B[c+1]=HA.subVectors(s,o).length(),this._markSlotDirty(e)}_collapseSlot(A){const e=A*a;this._positions.array.fill(0,e,e+a);const o=A*P;this._distances.array.fill(0,o,o+P),this._markSlotDirty(A)}_markSlotDirty(A){this._positions.addUpdateRange(A*a,a),this._positions.needsUpdate=!0,this._distances.addUpdateRange(A*P,P),this._distances.needsUpdate=!0}_grow(){this._capacity*=2;const A=this._createAttribute(a,3);A.array.set(this._positions.array),this._positions=A;const e=this._createAttribute(P,1);e.array.set(this._distances.array),this._distances=e,this._geometry.setAttribute("position",this._positions),this._geometry.setAttribute("lineDistance",this._distances)}}class F extends C{constructor(A,e=1){super();g(this,"isDIVELightComponent",!0);g(this,"_light");g(this,"_intensityFactor");this._light=A,this._intensityFactor=e,this._light.layers.mask=h.PRODUCT_LAYER_MASK,this.contribute(this._light)}get light(){return this._light}setColor(A){this._light.color=A}setIntensity(A){this._light.intensity=A*this._intensityFactor}setEnabled(A){this._light.visible=A}copy(A){return super.copy(A),this.setColor(A._light.color.clone()),this.setIntensity(A._light.intensity/A._intensityFactor),this.setEnabled(A._light.visible),this._light.position.copy(A._light.position),this}dispose(){var A,e;(e=(A=this._light).dispose)==null||e.call(A)}}const YA=new t.Vector3(1,1.75,1).multiplyScalar(30),N=2048,K=5;class lA extends F{constructor(){super(new t.DirectionalLight(16777215,3),3);g(this,"isDirectionalLightComponent",!0);this.name="DirectionalLightComponent";const A=this._light;A.castShadow=!0,A.shadow.mapSize.width=N,A.shadow.mapSize.height=N,A.shadow.camera.left=-K,A.shadow.camera.right=K,A.shadow.camera.top=K,A.shadow.camera.bottom=-K,A.shadow.camera.far=3500,this.setDirection(YA)}setDirection(A){if(A.x===0&&A.y===0&&A.z===0){console.warn("DirectionalLightComponent.setDirection: a zero direction leaves the light without a direction; ignoring.");return}this._light.position.set(A.x,A.y,A.z)}}const bA=new t.Vector3(0,50,0);class dA extends F{constructor(){super(new t.HemisphereLight(16777215,16777215,2),2);g(this,"isHemisphereLightComponent",!0);this.name="HemisphereLightComponent",this.setDirection(bA)}setDirection(A){if(A.x===0&&A.y===0&&A.z===0){console.warn("HemisphereLightComponent.setDirection: a zero direction leaves the light without a sky axis; ignoring.");return}this._light.position.set(A.x,A.y,A.z)}}const p=new t.Matrix4,_=new t.Vector3,yA=new t.Vector3,k=new t.Quaternion,OA=()=>{const f=new t.BoxGeometry(1,1,1),i=new t.EdgesGeometry(f);return f.dispose(),i};class MA extends C{constructor(){super();g(this,"isBoundingBoxComponent",!0);g(this,"_boundingBox",new BA);g(this,"_oriented",!1);g(this,"_stale",!0);g(this,"_boxHelper");g(this,"_sphereHelper");g(this,"_invalidate",()=>{this._stale=!0});this.name="BoundingBoxComponent",this._boxHelper=new t.LineSegments(OA(),new t.LineBasicMaterial({color:65280})),this._sphereHelper=new t.Mesh(new t.SphereGeometry(.5,32,32),new t.MeshBasicMaterial({color:65280,wireframe:!0})),[this._boxHelper,this._sphereHelper].forEach(A=>{A.layers.mask=h.HELPER_LAYER_MASK,A.visible=!1,A.matrixAutoUpdate=!1}),this.contribute(this._boxHelper,this._sphereHelper),this.setTickEnabled(!1)}get boundingBox(){return this._measure(),this._boundingBox}get box(){return this.boundingBox.box}get size(){return this.boundingBox.size}get center(){return this.boundingBox.center}get sphere(){return this.boundingBox.sphere}get radius(){return this.boundingBox.radius}get oriented(){return this._oriented}get boxHelper(){return this._measure(),this._boxHelper}get sphereHelper(){return this._measure(),this._sphereHelper}setOriented(A){return this._oriented===A?this:(this._oriented=A,this._stale=!0,this)}refresh(){return this._stale=!0,this}setBoxHelperVisible(A){this._boxHelper.visible=A,this._refreshTick()}setSphereHelperVisible(A){this._sphereHelper.visible=A,this._refreshTick()}setHelperColor(A){this._boxHelper.material.color.set(A),this._sphereHelper.material.color.set(A)}tick(){this._measure()}onAttach(A){A.addEventListener("childadded",this._invalidate),A.addEventListener("childremoved",this._invalidate),A.addEventListener("componentadded",this._invalidate),A.addEventListener("componentremoved",this._invalidate),A.addEventListener("object-transform",this._invalidate),this._stale=!0}onDetach(A){A.removeEventListener("childadded",this._invalidate),A.removeEventListener("childremoved",this._invalidate),A.removeEventListener("componentadded",this._invalidate),A.removeEventListener("componentremoved",this._invalidate),A.removeEventListener("object-transform",this._invalidate),this._stale=!0}_measure(){if(!this._stale)return;if(this._stale=!1,!this.isAttached){this._boundingBox.clear(),this._place();return}const A=this.owner;this._oriented?this._boundingBox.encloseOriented(A,A):this._boundingBox.enclose(A),this._place()}_place(){const{box:A,frame:e,center:o,radius:s}=this._boundingBox;p.identity(),this.isAttached&&p.copy(this.owner.matrixWorld).invert(),A.getCenter(_),this._boxHelper.matrix.compose(_,k,this._boundingBox.size).premultiply(e).premultiply(p),this._sphereHelper.matrix.compose(o,k,yA.setScalar(Math.max(0,s)*2)).premultiply(p)}_refreshTick(){this.setTickEnabled(this._boxHelper.visible||this._sphereHelper.visible)}copy(A){return super.copy(A),this._oriented=A.oriented,this._stale=!0,this.setHelperColor(A._boxHelper.material.color),this.setBoxHelperVisible(A._boxHelper.visible),this.setSphereHelperVisible(A._sphereHelper.visible),this}dispose(){this._boxHelper.geometry.dispose(),this._boxHelper.material.dispose(),this._sphereHelper.geometry.dispose(),this._sphereHelper.material.dispose()}}const L={glb:{key:"glb",mimeTypes:["model/gltf-binary"],extension:"glb"},gltf:{key:"gltf",mimeTypes:["model/gltf+json"],extension:"gltf"},usdz:{key:"usdz",mimeTypes:["model/vnd.usdz+zip"],extension:"usdz"},step:{key:"step",mimeTypes:["application/step","model/step","model/step+zip","model/step+xml"],extension:"step"},stp:{key:"stp",mimeTypes:["application/step","model/step","model/step+zip","model/step+xml"],extension:"stp"},iges:{key:"iges",mimeTypes:["application/iges","model/iges","model/iges+zip","model/iges+xml"],extension:"iges"},igs:{key:"igs",mimeTypes:["application/iges","model/iges","model/iges+zip","model/iges+xml"],extension:"igs"}},FA=Object.values(L).map(f=>f.extension),LA=Object.values(L).flatMap(f=>f.mimeTypes);exports.BoundingBox=BA;exports.BoundingBoxComponent=MA;exports.DIVE=DA;exports.DIVEAbortablePromise=q;exports.DIVECameraComponent=H;exports.DIVECanvasLifecycleManager=iA;exports.DIVEClock=S;exports.DIVEComponent=C;exports.DIVEDefaultSettings=w;exports.DIVEDeferredPromise=AA;exports.DIVEEnvironment=U;exports.DIVEEnvironmentDefaultSettings=R;exports.DIVELightComponent=F;exports.DIVENode=Y;exports.DIVEPerspectiveCameraDefaultSettings=u;exports.DIVERenderer=$;exports.DIVERendererDefaultSettings=O;exports.DIVERoot=oA;exports.DIVEScene=rA;exports.DIVESceneDefaultSettings=M;exports.DIVEView=eA;exports.DirectionalLightComponent=lA;exports.FILE_TYPES=L;exports.FloorComponent=d;exports.GRID_MAJOR_LINE_COLOR=sA;exports.GRID_MINOR_LINE_COLOR=tA;exports.GridComponent=nA;exports.HemisphereLightComponent=dA;exports.MeshComponent=gA;exports.MultiLineComponent=qA;exports.PerspectiveCameraComponent=hA;exports.SUPPORTED_FILE_TYPES=FA;exports.SUPPORTED_MIME_TYPES=LA;exports.computeProductBounds=G;exports.contributedBy=b;exports.disposeComponents=fA;exports.findComponent=IA;exports.findSceneRecursive=y;exports.isDIVEComponent=CA;
|
|
@@ -1606,7 +1606,7 @@ class di {
|
|
|
1606
1606
|
), this._clock.addTicker(this._orientationDisplay));
|
|
1607
1607
|
}
|
|
1608
1608
|
), console.log(
|
|
1609
|
-
"DIVE 4.0.
|
|
1609
|
+
"DIVE 4.0.1 initialized successfully!"
|
|
1610
1610
|
), console.log(ci), window.DIVE.instances.push(this), this._settings.autoStart && this.startAsync();
|
|
1611
1611
|
}
|
|
1612
1612
|
get views() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var u=(r,s,t)=>s in r?m(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var a=(r,s,t)=>u(r,typeof s!="symbol"?s+"":s,t);const l=require("./contributesToBounds-C1mva__U.cjs"),d=require("./FileTypes-
|
|
1
|
+
"use strict";var m=Object.defineProperty;var u=(r,s,t)=>s in r?m(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var a=(r,s,t)=>u(r,typeof s!="symbol"?s+"":s,t);const l=require("./contributesToBounds-C1mva__U.cjs"),d=require("./FileTypes-B-MjfMGd.cjs");class _ extends d.MeshComponent{constructor(){super();a(this,"isModelComponent",!0);a(this,"animations",[]);a(this,"_url",null);a(this,"_assetLoader",null);this.name="ModelComponent"}async _getAssetLoader(){return this._assetLoader||(this._assetLoader=new(await Promise.resolve().then(()=>require("../plugins/assetloader/index.cjs"))).AssetLoader),this._assetLoader}async setFromURL(t){const o=await(await this._getAssetLoader()).load(t);return this.setFromGLTF(o),this._url=t,this.dispatchEvent({type:"object-load"}),this}setFromGLTF(t){const i=[...this.contributions];this.withdraw(...i),i.forEach(e=>e.traverse(h=>{var n;(n=h.geometry)==null||n.dispose()})),this._mesh=null;const o=this.isAttached?this.owner.layers.mask:l.PRODUCT_LAYER_MASK;return t.traverse(e=>{e.castShadow=!0,e.receiveShadow=!0,e.layers.mask=o,!this._mesh&&"isMesh"in e&&(this._mesh=e,this._materialIsOwn?e.material=this._material:Array.isArray(e.material)||(this._material=e.material))}),this.animations=t.animations,this.contribute(...t.children),this}get url(){return this._url}copy(t){return super.copy(t),this._url=t.url,this.animations=t.animations,this}}exports.ModelComponent=_;
|
|
@@ -2,7 +2,7 @@ var m = Object.defineProperty;
|
|
|
2
2
|
var l = (a, e, t) => e in a ? m(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
3
|
var r = (a, e, t) => l(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { P as u } from "./contributesToBounds-DYmHYES4.mjs";
|
|
5
|
-
import { M as _ } from "./FileTypes-
|
|
5
|
+
import { M as _ } from "./FileTypes-D3Dxr2dj.mjs";
|
|
6
6
|
class c extends _ {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var D=Object.defineProperty;var E=(r,h,t)=>h in r?D(r,h,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[h]=t;var s=(r,h,t)=>E(r,typeof h!="symbol"?h+"":h,t);const i=require("three/webgpu"),S=require("./FileTypes-gD_1MonW.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const w={enableDamping:!0,dampingFactor:.05,enabled:!0,target:new i.Vector3,minDistance:0,maxDistance:1/0,minZoom:0,maxZoom:1/0,minPolarAngle:0,maxPolarAngle:Math.PI,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0,enableZoom:!0,zoomSpeed:1,enableRotate:!0,rotateSpeed:1,enablePan:!0,panSpeed:1,screenSpacePanning:!0,keyPanSpeed:7,autoRotate:!1,autoRotateSpeed:2,keys:{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},mouseButtons:{LEFT:i.MOUSE.ROTATE,MIDDLE:i.MOUSE.DOLLY,RIGHT:i.MOUSE.PAN},touches:{ONE:i.TOUCH.ROTATE,TWO:i.TOUCH.DOLLY_PAN}},c=class c extends i.EventDispatcher{constructor(t,e,a){super();s(this,"object");s(this,"domElements");s(this,"enabled",!0);s(this,"target",new i.Vector3);s(this,"minDistance",0);s(this,"maxDistance",1/0);s(this,"minZoom",0);s(this,"maxZoom",1/0);s(this,"minPolarAngle",0);s(this,"maxPolarAngle",Math.PI);s(this,"minAzimuthAngle",-1/0);s(this,"maxAzimuthAngle",1/0);s(this,"enableDamping",!0);s(this,"dampingFactor",.05);s(this,"enableZoom",!0);s(this,"zoomSpeed",1);s(this,"enableRotate",!0);s(this,"rotateSpeed",1);s(this,"enablePan",!0);s(this,"panSpeed",1);s(this,"screenSpacePanning",!0);s(this,"keyPanSpeed",7);s(this,"autoRotate",!1);s(this,"autoRotateSpeed",2);s(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"});s(this,"mouseButtons",{LEFT:i.MOUSE.ROTATE,MIDDLE:i.MOUSE.DOLLY,RIGHT:i.MOUSE.PAN});s(this,"touches",{ONE:i.TOUCH.ROTATE,TWO:i.TOUCH.DOLLY_PAN});s(this,"target0");s(this,"position0");s(this,"zoom0");s(this,"uuid",i.MathUtils.generateUUID());s(this,"state",-1);s(this,"EPS",1e-6);s(this,"spherical",new i.Spherical);s(this,"sphericalDelta",new i.Spherical);s(this,"scale",1);s(this,"panOffset",new i.Vector3);s(this,"zoomChanged",!1);s(this,"rotateStart",new i.Vector2);s(this,"rotateEnd",new i.Vector2);s(this,"rotateDelta",new i.Vector2);s(this,"panStart",new i.Vector2);s(this,"panEnd",new i.Vector2);s(this,"panDelta",new i.Vector2);s(this,"dollyStart",new i.Vector2);s(this,"dollyEnd",new i.Vector2);s(this,"dollyDelta",new i.Vector2);s(this,"pointers",[]);s(this,"pointerPositions",{});s(this,"offset",new i.Vector3);s(this,"quat");s(this,"quatInverse");s(this,"lastPosition",new i.Vector3);s(this,"lastQuaternion",new i.Quaternion);s(this,"lastTarget",new i.Vector3);s(this,"panLeft",(()=>{const t=new i.Vector3;return(e,a)=>{t.setFromMatrixColumn(a,0),t.multiplyScalar(-e),this.panOffset.add(t)}})());s(this,"panUp",(()=>{const t=new i.Vector3;return(e,a)=>{this.screenSpacePanning===!0?t.setFromMatrixColumn(a,1):(t.setFromMatrixColumn(a,0),t.crossVectors(this.object.camera.up,t)),t.multiplyScalar(e),this.panOffset.add(t)}})());s(this,"onMouseDown",t=>{let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case i.MOUSE.DOLLY:if(this.enableZoom===!1)return;this.handleMouseDownDolly(t),this.state=1;break;case i.MOUSE.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case i.MOUSE.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});s(this,"onMouseMove",t=>{if(this.enabled!==!1)switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}});s(this,"onMouseWheel",t=>{this.enabled===!1||this.enableZoom===!1||this.state!==-1||(t.preventDefault(),this.dispatchEvent({type:"start"}),this.handleMouseWheel(t),this.dispatchEvent({type:"end"}))});s(this,"onKeyDown",t=>{this.enabled===!1||this.enablePan===!1||this.handleKeyDown(t)});s(this,"onTouchStart",t=>{switch(this.trackPointer(t),this.pointers.length){case 1:switch(this.touches.ONE){case i.TOUCH.ROTATE:if(this.enableRotate===!1)return;this.handleTouchStartRotate(t),this.state=3;break;case i.TOUCH.PAN:if(this.enablePan===!1)return;this.handleTouchStartPan(t),this.state=4;break;default:this.state=-1}break;case 2:switch(this.touches.TWO){case i.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(t),this.state=5;break;case i.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(t),this.state=6;break;default:this.state=-1}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});s(this,"onTouchMove",t=>{switch(this.trackPointer(t),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}});s(this,"onPointerDown",t=>{if(this.enabled!==!1){if(this.pointers.length===0){const e=t.currentTarget;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp)}this.isTrackingPointer(t)||(this.addPointer(t),t.pointerType==="touch"?this.onTouchStart(t):this.onMouseDown(t))}});s(this,"onPointerMove",t=>{this.enabled!==!1&&(t.pointerType==="touch"?this.onTouchMove(t):this.onMouseMove(t))});s(this,"onPointerUp",t=>{if(this.removePointer(t),this.pointers.length===0){const e=t.currentTarget;e.releasePointerCapture(t.pointerId),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.dispatchEvent({type:"end"}),this.state=-1}});s(this,"onPointerCancel",t=>{this.removePointer(t)});s(this,"onContextMenu",t=>{this.enabled!==!1&&t.preventDefault()});if(this.object=t,!t.isAttached)throw new Error("OrbitController: the camera component must be attached to a node, because that is what gets moved.");this.domElements=Array.isArray(e)?e:[e],Object.assign(this,a),this.target0=this.target.clone(),this.position0=this.object.owner.position.clone(),this.zoom0=this._camera.zoom,this.quat=new i.Quaternion().setFromUnitVectors(this.object.camera.up,new i.Vector3(0,1,0)),this.quatInverse=this.quat.clone().invert(),this.domElements.forEach(o=>this.addEventListeners(o)),this.update()}get _camera(){return this.object.camera}get domElement(){return this.domElements[0]}tick(){this.enabled&&this.update()}getPolarAngle(){return this.spherical.phi}getAzimuthalAngle(){return this.spherical.theta}getDistance(){return this.object.owner.position.distanceTo(this.target)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.owner.position),this.zoom0=this._camera.zoom}reset(){this.target.copy(this.target0),this.object.owner.position.copy(this.position0),this._camera.zoom=this.zoom0,this._camera.updateProjectionMatrix(),this.dispatchEvent({type:"change"}),this.update(),this.state=-1}update(){return this.offset.copy(this.object.owner.position).sub(this.target),this.offset.applyQuaternion(this.quat),this.spherical.setFromVector3(this.offset),this.autoRotate&&this.state===-1&&this.rotateLeft(this.getAutoRotationAngle()),this.enableDamping?(this.spherical.theta+=this.sphericalDelta.theta*this.dampingFactor,this.spherical.phi+=this.sphericalDelta.phi*this.dampingFactor):(this.spherical.theta+=this.sphericalDelta.theta,this.spherical.phi+=this.sphericalDelta.phi),this.spherical.theta=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,this.spherical.theta)),this.spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this.spherical.phi)),this.spherical.makeSafe(),this.spherical.radius*=this.scale,this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius)),this.enableDamping===!0?this.target.addScaledVector(this.panOffset,this.dampingFactor):this.target.add(this.panOffset),this.offset.setFromSpherical(this.spherical),this.offset.applyQuaternion(this.quatInverse),this.object.owner.position.copy(this.target).add(this.offset),this.object.lookAt(this.target),this.enableDamping===!0?(this.sphericalDelta.theta*=1-this.dampingFactor,this.sphericalDelta.phi*=1-this.dampingFactor,this.panOffset.multiplyScalar(1-this.dampingFactor)):(this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0)),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.owner.position)>this.EPS||8*(1-this.lastQuaternion.dot(this.object.owner.quaternion))>this.EPS||this.lastTarget.distanceToSquared(this.target)>this.EPS?(this.dispatchEvent({type:"change"}),this.lastPosition.copy(this.object.owner.position),this.lastQuaternion.copy(this.object.owner.quaternion),this.lastTarget.copy(this.target),this.zoomChanged=!1,!0):!1}dispose(){this.domElements.forEach(t=>this.removeEventListeners(t)),this.dispatchEvent({type:"dispose"})}addDomElements(...t){t.forEach(e=>{this.domElements.includes(e)||(this.domElements.push(e),this.addEventListeners(e))})}removeDomElements(...t){t.forEach(e=>{const a=this.domElements.indexOf(e);a>-1&&(this.removeEventListeners(e),this.domElements.splice(a,1))})}setDomElements(...t){this.removeDomElements(...this.domElements),this.domElements=[],this.addDomElements(...t)}computeEncompassingView(t,e=0){const a=t.center,o=t.radius,n=this._camera,l=n.fov*(Math.PI/180),m=n.aspect,d=l/2,f=Math.atan(Math.tan(d)*m),g=o/Math.sin(d),y=o/Math.sin(f),b=Math.max(g,y)*(1+e),u=this.object.owner.position.clone().sub(this.target).normalize(),P=u.length()>.001?u:new i.Vector3(0,0,1);return{position:a.clone().add(P.multiplyScalar(b)),target:a}}focusObject(t,e=0){const a=this.computeEncompassingView(new S.BoundingBox().enclose(t).sphere,e);this.object.owner.position.copy(a.position),this.target.copy(a.target),this.update()}zoomIn(t){this.dollyIn(Math.pow(.95,t??c.DEFAULT_ZOOM_FACTOR)),this.update()}zoomOut(t){this.dollyOut(Math.pow(.95,t??c.DEFAULT_ZOOM_FACTOR)),this.update()}getState(){return{target:this.target.clone(),azimuthalAngle:this.getAzimuthalAngle(),polarAngle:this.getPolarAngle(),distance:this.getDistance(),position:this.object.owner.position.clone(),quaternion:this.object.owner.quaternion.clone()}}setState(t){this.target.copy(t.target),this.object.owner.position.copy(t.position),this.object.owner.quaternion.copy(t.quaternion),this.update()}addEventListeners(t){t.style.touchAction="none",t.addEventListener("contextmenu",this.onContextMenu),t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointercancel",this.onPointerCancel),t.addEventListener("wheel",this.onMouseWheel,{passive:!1}),t.addEventListener("keydown",this.onKeyDown)}removeEventListeners(t){t.removeEventListener("contextmenu",this.onContextMenu),t.removeEventListener("pointerdown",this.onPointerDown),t.removeEventListener("pointercancel",this.onPointerCancel),t.removeEventListener("wheel",this.onMouseWheel),t.removeEventListener("keydown",this.onKeyDown),t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}pan(t,e,a){const o=new i.Vector3;if("isPerspectiveCamera"in this._camera){const n=this.object.owner.position;o.copy(n).sub(this.target);let l=o.length();l*=Math.tan(this._camera.fov/2*Math.PI/180),this.panLeft(2*t*l/a.clientHeight,this.object.owner.matrix),this.panUp(2*e*l/a.clientHeight,this.object.owner.matrix)}else"isOrthographicCamera"in this._camera?(this.panLeft(t*(this._camera.right-this._camera.left)/this._camera.zoom/a.clientWidth,this.object.owner.matrix),this.panUp(e*(this._camera.top-this._camera.bottom)/this._camera.zoom/a.clientHeight,this.object.owner.matrix)):(console.warn("WARNING: OrbitController encountered an unknown camera type - pan disabled."),this.enablePan=!1)}dollyIn(t){"isPerspectiveCamera"in this._camera||"isOrthographicCamera"in this._camera?this.scale*=t:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyOut(t){"isPerspectiveCamera"in this._camera||"isOrthographicCamera"in this._camera?this.scale/=t:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t){this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);const e=t.currentTarget;this.rotateLeft(2*Math.PI*this.rotateDelta.x/e.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/e.clientHeight),this.rotateStart.copy(this.rotateEnd),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyIn(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyOut(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t){const e=t.currentTarget;this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y,e),this.panStart.copy(this.panEnd),this.update()}handleMouseWheel(t){t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update()}handleKeyDown(t){let e=!1;const a=t.currentTarget;switch(t.code){case this.keys.UP:this.pan(0,this.keyPanSpeed,a),e=!0;break;case this.keys.BOTTOM:this.pan(0,-this.keyPanSpeed,a),e=!0;break;case this.keys.LEFT:this.pan(this.keyPanSpeed,0,a),e=!0;break;case this.keys.RIGHT:this.pan(-this.keyPanSpeed,0,a),e=!0;break}e&&(t.preventDefault(),this.update())}handleTouchStartRotate(t){if(this.pointers.length===1)this.rotateStart.set(t.pageX,t.pageY);else{const e=this.getSecondPointer(t),a=.5*(t.pageX+e.pageX),o=.5*(t.pageY+e.pageY);this.rotateStart.set(a,o)}}handleTouchStartPan(t){if(this.pointers.length===1)this.panStart.set(t.pageX,t.pageY);else{const e=this.getSecondPointer(t),a=.5*(t.pageX+e.pageX),o=.5*(t.pageY+e.pageY);this.panStart.set(a,o)}}handleTouchStartDolly(t){const e=this.getSecondPointer(t),a=t.pageX-e.pageX,o=t.pageY-e.pageY,n=Math.sqrt(a*a+o*o);this.dollyStart.set(0,n)}handleTouchStartDollyPan(t){this.enableZoom&&this.handleTouchStartDolly(t),this.enablePan&&this.handleTouchStartPan(t)}handleTouchStartDollyRotate(t){this.enableZoom&&this.handleTouchStartDolly(t),this.enableRotate&&this.handleTouchStartRotate(t)}handleTouchMoveRotate(t){if(this.pointers.length===1)this.rotateEnd.set(t.pageX,t.pageY);else{const a=this.getSecondPointer(t),o=.5*(t.pageX+a.pageX),n=.5*(t.pageY+a.pageY);this.rotateEnd.set(o,n)}const e=t.currentTarget;this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed),this.rotateLeft(2*Math.PI*this.rotateDelta.x/e.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/e.clientHeight),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(this.pointers.length===1)this.panEnd.set(t.pageX,t.pageY);else{const a=this.getSecondPointer(t),o=.5*(t.pageX+a.pageX),n=.5*(t.pageY+a.pageY);this.panEnd.set(o,n)}const e=t.currentTarget;this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y,e),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){const e=this.getSecondPointer(t),a=t.pageX-e.pageX,o=t.pageY-e.pageY,n=Math.sqrt(a*a+o*o);this.dollyEnd.set(0,n),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}addPointer(t){this.pointers.push(t)}removePointer(t){delete this.pointerPositions[t.pointerId];for(let e=0;e<this.pointers.length;e++)if(this.pointers[e].pointerId==t.pointerId){this.pointers.splice(e,1);return}}trackPointer(t){let e=this.pointerPositions[t.pointerId];e===void 0&&(e=new i.Vector2,this.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}getSecondPointer(t){return this.pointers[0].pointerId===t.pointerId?this.pointers[1]:this.pointers[0]}isTrackingPointer(t){return this.pointers.some(e=>e.pointerId===t.pointerId)}};s(c,"DEFAULT_ZOOM_FACTOR",1);let p=c;exports.OrbitController=p;exports.OrbitControllerDefaultSettings=w;
|
|
1
|
+
"use strict";var D=Object.defineProperty;var E=(r,h,t)=>h in r?D(r,h,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[h]=t;var s=(r,h,t)=>E(r,typeof h!="symbol"?h+"":h,t);const i=require("three/webgpu"),S=require("./FileTypes-B-MjfMGd.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const w={enableDamping:!0,dampingFactor:.05,enabled:!0,target:new i.Vector3,minDistance:0,maxDistance:1/0,minZoom:0,maxZoom:1/0,minPolarAngle:0,maxPolarAngle:Math.PI,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0,enableZoom:!0,zoomSpeed:1,enableRotate:!0,rotateSpeed:1,enablePan:!0,panSpeed:1,screenSpacePanning:!0,keyPanSpeed:7,autoRotate:!1,autoRotateSpeed:2,keys:{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},mouseButtons:{LEFT:i.MOUSE.ROTATE,MIDDLE:i.MOUSE.DOLLY,RIGHT:i.MOUSE.PAN},touches:{ONE:i.TOUCH.ROTATE,TWO:i.TOUCH.DOLLY_PAN}},c=class c extends i.EventDispatcher{constructor(t,e,a){super();s(this,"object");s(this,"domElements");s(this,"enabled",!0);s(this,"target",new i.Vector3);s(this,"minDistance",0);s(this,"maxDistance",1/0);s(this,"minZoom",0);s(this,"maxZoom",1/0);s(this,"minPolarAngle",0);s(this,"maxPolarAngle",Math.PI);s(this,"minAzimuthAngle",-1/0);s(this,"maxAzimuthAngle",1/0);s(this,"enableDamping",!0);s(this,"dampingFactor",.05);s(this,"enableZoom",!0);s(this,"zoomSpeed",1);s(this,"enableRotate",!0);s(this,"rotateSpeed",1);s(this,"enablePan",!0);s(this,"panSpeed",1);s(this,"screenSpacePanning",!0);s(this,"keyPanSpeed",7);s(this,"autoRotate",!1);s(this,"autoRotateSpeed",2);s(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"});s(this,"mouseButtons",{LEFT:i.MOUSE.ROTATE,MIDDLE:i.MOUSE.DOLLY,RIGHT:i.MOUSE.PAN});s(this,"touches",{ONE:i.TOUCH.ROTATE,TWO:i.TOUCH.DOLLY_PAN});s(this,"target0");s(this,"position0");s(this,"zoom0");s(this,"uuid",i.MathUtils.generateUUID());s(this,"state",-1);s(this,"EPS",1e-6);s(this,"spherical",new i.Spherical);s(this,"sphericalDelta",new i.Spherical);s(this,"scale",1);s(this,"panOffset",new i.Vector3);s(this,"zoomChanged",!1);s(this,"rotateStart",new i.Vector2);s(this,"rotateEnd",new i.Vector2);s(this,"rotateDelta",new i.Vector2);s(this,"panStart",new i.Vector2);s(this,"panEnd",new i.Vector2);s(this,"panDelta",new i.Vector2);s(this,"dollyStart",new i.Vector2);s(this,"dollyEnd",new i.Vector2);s(this,"dollyDelta",new i.Vector2);s(this,"pointers",[]);s(this,"pointerPositions",{});s(this,"offset",new i.Vector3);s(this,"quat");s(this,"quatInverse");s(this,"lastPosition",new i.Vector3);s(this,"lastQuaternion",new i.Quaternion);s(this,"lastTarget",new i.Vector3);s(this,"panLeft",(()=>{const t=new i.Vector3;return(e,a)=>{t.setFromMatrixColumn(a,0),t.multiplyScalar(-e),this.panOffset.add(t)}})());s(this,"panUp",(()=>{const t=new i.Vector3;return(e,a)=>{this.screenSpacePanning===!0?t.setFromMatrixColumn(a,1):(t.setFromMatrixColumn(a,0),t.crossVectors(this.object.camera.up,t)),t.multiplyScalar(e),this.panOffset.add(t)}})());s(this,"onMouseDown",t=>{let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case i.MOUSE.DOLLY:if(this.enableZoom===!1)return;this.handleMouseDownDolly(t),this.state=1;break;case i.MOUSE.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case i.MOUSE.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});s(this,"onMouseMove",t=>{if(this.enabled!==!1)switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}});s(this,"onMouseWheel",t=>{this.enabled===!1||this.enableZoom===!1||this.state!==-1||(t.preventDefault(),this.dispatchEvent({type:"start"}),this.handleMouseWheel(t),this.dispatchEvent({type:"end"}))});s(this,"onKeyDown",t=>{this.enabled===!1||this.enablePan===!1||this.handleKeyDown(t)});s(this,"onTouchStart",t=>{switch(this.trackPointer(t),this.pointers.length){case 1:switch(this.touches.ONE){case i.TOUCH.ROTATE:if(this.enableRotate===!1)return;this.handleTouchStartRotate(t),this.state=3;break;case i.TOUCH.PAN:if(this.enablePan===!1)return;this.handleTouchStartPan(t),this.state=4;break;default:this.state=-1}break;case 2:switch(this.touches.TWO){case i.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(t),this.state=5;break;case i.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(t),this.state=6;break;default:this.state=-1}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});s(this,"onTouchMove",t=>{switch(this.trackPointer(t),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}});s(this,"onPointerDown",t=>{if(this.enabled!==!1){if(this.pointers.length===0){const e=t.currentTarget;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp)}this.isTrackingPointer(t)||(this.addPointer(t),t.pointerType==="touch"?this.onTouchStart(t):this.onMouseDown(t))}});s(this,"onPointerMove",t=>{this.enabled!==!1&&(t.pointerType==="touch"?this.onTouchMove(t):this.onMouseMove(t))});s(this,"onPointerUp",t=>{if(this.removePointer(t),this.pointers.length===0){const e=t.currentTarget;e.releasePointerCapture(t.pointerId),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.dispatchEvent({type:"end"}),this.state=-1}});s(this,"onPointerCancel",t=>{this.removePointer(t)});s(this,"onContextMenu",t=>{this.enabled!==!1&&t.preventDefault()});if(this.object=t,!t.isAttached)throw new Error("OrbitController: the camera component must be attached to a node, because that is what gets moved.");this.domElements=Array.isArray(e)?e:[e],Object.assign(this,a),this.target0=this.target.clone(),this.position0=this.object.owner.position.clone(),this.zoom0=this._camera.zoom,this.quat=new i.Quaternion().setFromUnitVectors(this.object.camera.up,new i.Vector3(0,1,0)),this.quatInverse=this.quat.clone().invert(),this.domElements.forEach(o=>this.addEventListeners(o)),this.update()}get _camera(){return this.object.camera}get domElement(){return this.domElements[0]}tick(){this.enabled&&this.update()}getPolarAngle(){return this.spherical.phi}getAzimuthalAngle(){return this.spherical.theta}getDistance(){return this.object.owner.position.distanceTo(this.target)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.owner.position),this.zoom0=this._camera.zoom}reset(){this.target.copy(this.target0),this.object.owner.position.copy(this.position0),this._camera.zoom=this.zoom0,this._camera.updateProjectionMatrix(),this.dispatchEvent({type:"change"}),this.update(),this.state=-1}update(){return this.offset.copy(this.object.owner.position).sub(this.target),this.offset.applyQuaternion(this.quat),this.spherical.setFromVector3(this.offset),this.autoRotate&&this.state===-1&&this.rotateLeft(this.getAutoRotationAngle()),this.enableDamping?(this.spherical.theta+=this.sphericalDelta.theta*this.dampingFactor,this.spherical.phi+=this.sphericalDelta.phi*this.dampingFactor):(this.spherical.theta+=this.sphericalDelta.theta,this.spherical.phi+=this.sphericalDelta.phi),this.spherical.theta=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,this.spherical.theta)),this.spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this.spherical.phi)),this.spherical.makeSafe(),this.spherical.radius*=this.scale,this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius)),this.enableDamping===!0?this.target.addScaledVector(this.panOffset,this.dampingFactor):this.target.add(this.panOffset),this.offset.setFromSpherical(this.spherical),this.offset.applyQuaternion(this.quatInverse),this.object.owner.position.copy(this.target).add(this.offset),this.object.lookAt(this.target),this.enableDamping===!0?(this.sphericalDelta.theta*=1-this.dampingFactor,this.sphericalDelta.phi*=1-this.dampingFactor,this.panOffset.multiplyScalar(1-this.dampingFactor)):(this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0)),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.owner.position)>this.EPS||8*(1-this.lastQuaternion.dot(this.object.owner.quaternion))>this.EPS||this.lastTarget.distanceToSquared(this.target)>this.EPS?(this.dispatchEvent({type:"change"}),this.lastPosition.copy(this.object.owner.position),this.lastQuaternion.copy(this.object.owner.quaternion),this.lastTarget.copy(this.target),this.zoomChanged=!1,!0):!1}dispose(){this.domElements.forEach(t=>this.removeEventListeners(t)),this.dispatchEvent({type:"dispose"})}addDomElements(...t){t.forEach(e=>{this.domElements.includes(e)||(this.domElements.push(e),this.addEventListeners(e))})}removeDomElements(...t){t.forEach(e=>{const a=this.domElements.indexOf(e);a>-1&&(this.removeEventListeners(e),this.domElements.splice(a,1))})}setDomElements(...t){this.removeDomElements(...this.domElements),this.domElements=[],this.addDomElements(...t)}computeEncompassingView(t,e=0){const a=t.center,o=t.radius,n=this._camera,l=n.fov*(Math.PI/180),m=n.aspect,d=l/2,f=Math.atan(Math.tan(d)*m),g=o/Math.sin(d),y=o/Math.sin(f),b=Math.max(g,y)*(1+e),u=this.object.owner.position.clone().sub(this.target).normalize(),P=u.length()>.001?u:new i.Vector3(0,0,1);return{position:a.clone().add(P.multiplyScalar(b)),target:a}}focusObject(t,e=0){const a=this.computeEncompassingView(new S.BoundingBox().enclose(t).sphere,e);this.object.owner.position.copy(a.position),this.target.copy(a.target),this.update()}zoomIn(t){this.dollyIn(Math.pow(.95,t??c.DEFAULT_ZOOM_FACTOR)),this.update()}zoomOut(t){this.dollyOut(Math.pow(.95,t??c.DEFAULT_ZOOM_FACTOR)),this.update()}getState(){return{target:this.target.clone(),azimuthalAngle:this.getAzimuthalAngle(),polarAngle:this.getPolarAngle(),distance:this.getDistance(),position:this.object.owner.position.clone(),quaternion:this.object.owner.quaternion.clone()}}setState(t){this.target.copy(t.target),this.object.owner.position.copy(t.position),this.object.owner.quaternion.copy(t.quaternion),this.update()}addEventListeners(t){t.style.touchAction="none",t.addEventListener("contextmenu",this.onContextMenu),t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointercancel",this.onPointerCancel),t.addEventListener("wheel",this.onMouseWheel,{passive:!1}),t.addEventListener("keydown",this.onKeyDown)}removeEventListeners(t){t.removeEventListener("contextmenu",this.onContextMenu),t.removeEventListener("pointerdown",this.onPointerDown),t.removeEventListener("pointercancel",this.onPointerCancel),t.removeEventListener("wheel",this.onMouseWheel),t.removeEventListener("keydown",this.onKeyDown),t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}pan(t,e,a){const o=new i.Vector3;if("isPerspectiveCamera"in this._camera){const n=this.object.owner.position;o.copy(n).sub(this.target);let l=o.length();l*=Math.tan(this._camera.fov/2*Math.PI/180),this.panLeft(2*t*l/a.clientHeight,this.object.owner.matrix),this.panUp(2*e*l/a.clientHeight,this.object.owner.matrix)}else"isOrthographicCamera"in this._camera?(this.panLeft(t*(this._camera.right-this._camera.left)/this._camera.zoom/a.clientWidth,this.object.owner.matrix),this.panUp(e*(this._camera.top-this._camera.bottom)/this._camera.zoom/a.clientHeight,this.object.owner.matrix)):(console.warn("WARNING: OrbitController encountered an unknown camera type - pan disabled."),this.enablePan=!1)}dollyIn(t){"isPerspectiveCamera"in this._camera||"isOrthographicCamera"in this._camera?this.scale*=t:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyOut(t){"isPerspectiveCamera"in this._camera||"isOrthographicCamera"in this._camera?this.scale/=t:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t){this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);const e=t.currentTarget;this.rotateLeft(2*Math.PI*this.rotateDelta.x/e.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/e.clientHeight),this.rotateStart.copy(this.rotateEnd),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyIn(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyOut(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t){const e=t.currentTarget;this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y,e),this.panStart.copy(this.panEnd),this.update()}handleMouseWheel(t){t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update()}handleKeyDown(t){let e=!1;const a=t.currentTarget;switch(t.code){case this.keys.UP:this.pan(0,this.keyPanSpeed,a),e=!0;break;case this.keys.BOTTOM:this.pan(0,-this.keyPanSpeed,a),e=!0;break;case this.keys.LEFT:this.pan(this.keyPanSpeed,0,a),e=!0;break;case this.keys.RIGHT:this.pan(-this.keyPanSpeed,0,a),e=!0;break}e&&(t.preventDefault(),this.update())}handleTouchStartRotate(t){if(this.pointers.length===1)this.rotateStart.set(t.pageX,t.pageY);else{const e=this.getSecondPointer(t),a=.5*(t.pageX+e.pageX),o=.5*(t.pageY+e.pageY);this.rotateStart.set(a,o)}}handleTouchStartPan(t){if(this.pointers.length===1)this.panStart.set(t.pageX,t.pageY);else{const e=this.getSecondPointer(t),a=.5*(t.pageX+e.pageX),o=.5*(t.pageY+e.pageY);this.panStart.set(a,o)}}handleTouchStartDolly(t){const e=this.getSecondPointer(t),a=t.pageX-e.pageX,o=t.pageY-e.pageY,n=Math.sqrt(a*a+o*o);this.dollyStart.set(0,n)}handleTouchStartDollyPan(t){this.enableZoom&&this.handleTouchStartDolly(t),this.enablePan&&this.handleTouchStartPan(t)}handleTouchStartDollyRotate(t){this.enableZoom&&this.handleTouchStartDolly(t),this.enableRotate&&this.handleTouchStartRotate(t)}handleTouchMoveRotate(t){if(this.pointers.length===1)this.rotateEnd.set(t.pageX,t.pageY);else{const a=this.getSecondPointer(t),o=.5*(t.pageX+a.pageX),n=.5*(t.pageY+a.pageY);this.rotateEnd.set(o,n)}const e=t.currentTarget;this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed),this.rotateLeft(2*Math.PI*this.rotateDelta.x/e.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/e.clientHeight),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(this.pointers.length===1)this.panEnd.set(t.pageX,t.pageY);else{const a=this.getSecondPointer(t),o=.5*(t.pageX+a.pageX),n=.5*(t.pageY+a.pageY);this.panEnd.set(o,n)}const e=t.currentTarget;this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y,e),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){const e=this.getSecondPointer(t),a=t.pageX-e.pageX,o=t.pageY-e.pageY,n=Math.sqrt(a*a+o*o);this.dollyEnd.set(0,n),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}addPointer(t){this.pointers.push(t)}removePointer(t){delete this.pointerPositions[t.pointerId];for(let e=0;e<this.pointers.length;e++)if(this.pointers[e].pointerId==t.pointerId){this.pointers.splice(e,1);return}}trackPointer(t){let e=this.pointerPositions[t.pointerId];e===void 0&&(e=new i.Vector2,this.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}getSecondPointer(t){return this.pointers[0].pointerId===t.pointerId?this.pointers[1]:this.pointers[0]}isTrackingPointer(t){return this.pointers.some(e=>e.pointerId===t.pointerId)}};s(c,"DEFAULT_ZOOM_FACTOR",1);let p=c;exports.OrbitController=p;exports.OrbitControllerDefaultSettings=w;
|
|
@@ -2,7 +2,7 @@ var T = Object.defineProperty;
|
|
|
2
2
|
var A = (p, l, t) => l in p ? T(p, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[l] = t;
|
|
3
3
|
var s = (p, l, t) => A(p, typeof l != "symbol" ? l + "" : l, t);
|
|
4
4
|
import { TOUCH as c, MOUSE as r, Vector3 as n, EventDispatcher as O, MathUtils as L, Spherical as g, Vector2 as h, Quaternion as y } from "three/webgpu";
|
|
5
|
-
import { B as R } from "./FileTypes-
|
|
5
|
+
import { B as R } from "./FileTypes-D3Dxr2dj.mjs";
|
|
6
6
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
7
7
|
import "three/tsl";
|
|
8
8
|
const Z = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var _=(i,e,t)=>e in i?a(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>_(i,typeof e!="symbol"?e+"":e,t);const r=require("three/webgpu"),x=require("./FileTypes-
|
|
1
|
+
"use strict";var a=Object.defineProperty;var _=(i,e,t)=>e in i?a(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>_(i,typeof e!="symbol"?e+"":e,t);const r=require("three/webgpu"),x=require("./FileTypes-B-MjfMGd.cjs"),h=90,o=`normal ${h}px Arial`;class p extends x.DIVEComponent{constructor(){super();s(this,"isSpriteTextComponent",!0);s(this,"_text","");s(this,"_textHeight",1);s(this,"_color",new r.Color(16777215));s(this,"_canvas");s(this,"_texture");s(this,"_sprite");this.name="SpriteTextComponent",this._canvas=document.createElement("canvas"),this._texture=new r.CanvasTexture(this._canvas),this._texture.colorSpace=r.SRGBColorSpace,this._sprite=new r.Sprite(new r.SpriteMaterial({map:this._texture})),this._sprite.name="SpriteText",this.contribute(this._sprite),this._draw()}get sprite(){return this._sprite}get text(){return this._text}get textHeight(){return this._textHeight}get color(){return this._color}setText(t){return this._text=t,this._draw(),this}setTextHeight(t){return this._textHeight=t,this._draw(),this}setColor(t){return this._color.set(t),this._draw(),this}onAttach(t){this._sprite.layers.mask=t.layers.mask}copy(t){return super.copy(t),this._text=t.text,this._textHeight=t.textHeight,this._color.copy(t.color),this._draw(),this}dispose(){this._texture.dispose(),this._sprite.material.dispose()}_draw(){const t=this._canvas.getContext("2d");if(t===null)return;t.font=o;const n=Math.max(1,Math.ceil(t.measureText(this._text).width));this._canvas.width=n,this._canvas.height=h,t.font=o,t.fillStyle=`#${this._color.getHexString()}`,t.textBaseline="bottom",t.fillText(this._text,0,h),this._texture.needsUpdate=!0,this._sprite.scale.set(this._textHeight*n/h,this._textHeight,1)}}exports.SpriteTextComponent=p;
|
|
@@ -2,7 +2,7 @@ var a = Object.defineProperty;
|
|
|
2
2
|
var n = (i, e, t) => e in i ? a(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var s = (i, e, t) => n(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { Color as _, CanvasTexture as x, SRGBColorSpace as p, Sprite as c, SpriteMaterial as l } from "three/webgpu";
|
|
5
|
-
import { a as u } from "./FileTypes-
|
|
5
|
+
import { a as u } from "./FileTypes-D3Dxr2dj.mjs";
|
|
6
6
|
const r = 90, o = `normal ${r}px Arial`;
|
|
7
7
|
class w extends u {
|
|
8
8
|
constructor() {
|
package/build/chunks/{detachTransformControls-Dr3TIdVy.mjs → detachTransformControls-B4iRF1bw.mjs}
RENAMED
|
@@ -2,7 +2,7 @@ var p = Object.defineProperty;
|
|
|
2
2
|
var w = (n, s, e) => s in n ? p(n, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[s] = e;
|
|
3
3
|
var r = (n, s, e) => w(n, typeof s != "symbol" ? s + "" : s, e);
|
|
4
4
|
import { AmbientLight as C, PointLight as f, MeshBasicMaterial as G, FrontSide as S, Mesh as m, SphereGeometry as u, MeshStandardMaterial as y, BufferGeometry as h, CylinderGeometry as M, BufferAttribute as c, BoxGeometry as l, ConeGeometry as A } from "three/webgpu";
|
|
5
|
-
import { f as _, M as P, g } from "./FileTypes-
|
|
5
|
+
import { f as _, M as P, g } from "./FileTypes-D3Dxr2dj.mjs";
|
|
6
6
|
import { a as E, P as L } from "./contributesToBounds-DYmHYES4.mjs";
|
|
7
7
|
class H extends _ {
|
|
8
8
|
constructor() {
|
package/build/chunks/{detachTransformControls-2XQrpLN-.cjs → detachTransformControls-CZ2cd5hx.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var u=(i,r,e)=>r in i?d(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var s=(i,r,e)=>u(i,typeof r!="symbol"?r+"":r,e);const n=require("three/webgpu"),h=require("./FileTypes-
|
|
1
|
+
"use strict";var d=Object.defineProperty;var u=(i,r,e)=>r in i?d(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var s=(i,r,e)=>u(i,typeof r!="symbol"?r+"":r,e);const n=require("three/webgpu"),h=require("./FileTypes-B-MjfMGd.cjs"),m=require("./contributesToBounds-C1mva__U.cjs");class p extends h.DIVELightComponent{constructor(){super(new n.AmbientLight(16777215,1));s(this,"isAmbientLightComponent",!0);this.name="AmbientLightComponent"}}const _=.1,c=.8,l=512;class w extends h.DIVELightComponent{constructor(){super(new n.PointLight(16777215,1));s(this,"isPointLightComponent",!0);s(this,"_handle");s(this,"_handleMaterial");this.name="PointLightComponent";const e=this._light;e.castShadow=!0,e.shadow.mapSize.width=l,e.shadow.mapSize.height=l,this._handleMaterial=new n.MeshBasicMaterial({color:this._light.color,transparent:!0,opacity:c,side:n.FrontSide}),this._handle=new n.Mesh(new n.SphereGeometry(_,32,32),this._handleMaterial),this._handle.layers.mask=m.PROXY_LAYER_MASK,this.contribute(this._handle)}get handle(){return this._handle}setColor(e){super.setColor(e),this._handleMaterial.color=e}setIntensity(e){super.setIntensity(e),this._handleMaterial.opacity=Math.min(e*c,c)}dispose(){super.dispose(),this._handle.geometry.dispose(),this._handleMaterial.dispose()}}const C=64,G=32;class y extends h.MeshComponent{constructor(){super();s(this,"isPrimitiveComponent",!0);s(this,"_geometry",null);this.name="PrimitiveComponent",this._material=new n.MeshStandardMaterial,this._mesh=new n.Mesh(new n.BufferGeometry,this._material),this._mesh.name="PrimitiveMesh",this._mesh.layers.mask=m.PRODUCT_LAYER_MASK,this._mesh.castShadow=!0,this._mesh.receiveShadow=!0,this.contribute(this._mesh)}get geometry(){return this._geometry}setGeometry(e){const t=this._assembleGeometry(e);t&&(this._geometry=e,t.computeVertexNormals(),t.computeBoundingBox(),t.computeBoundingSphere(),this._mesh.geometry.dispose(),this._mesh.geometry=t)}copy(e){return super.copy(e),e.geometry&&this.setGeometry(e.geometry),this}_assembleGeometry(e){switch(this._material.flatShading=!1,e.name.toLowerCase()){case"cylinder":return this._createCylinderGeometry(e);case"sphere":return this._createSphereGeometry(e);case"pyramid":return this._material.flatShading=!0,this._createPyramidGeometry(e);case"cube":case"box":case"plane":return this._createBoxGeometry(e);case"cone":return this._createConeGeometry(e);case"wall":return this._createWallGeometry(e);default:return console.warn("PrimitiveComponent.setGeometry: Invalid geometry type:",e.name.toLowerCase()),null}}_createCylinderGeometry(e){const t=new n.CylinderGeometry(e.width/2,e.width/2,e.height,64);return t.translate(0,e.height/2,0),t}_createSphereGeometry(e){return new n.SphereGeometry(e.width/2,C,G)}_createPyramidGeometry(e){const t=new Float32Array([-e.width/2,0,-e.depth/2,e.width/2,0,-e.depth/2,e.width/2,0,e.depth/2,-e.width/2,0,e.depth/2,0,e.height,0]),o=new Uint16Array([0,1,2,0,2,3,0,4,1,1,4,2,2,4,3,3,4,0]),a=new n.BufferGeometry;return a.setAttribute("position",new n.BufferAttribute(t,3)),a.setIndex(new n.BufferAttribute(o,1)),a}_createBoxGeometry(e){const t=new n.BoxGeometry(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}_createConeGeometry(e){const t=new n.ConeGeometry(e.width/2,e.height,256);return t.translate(0,e.height/2,0),t}_createWallGeometry(e){const t=new n.BoxGeometry(e.width,e.height,e.depth||.05,16);return t.translate(0,e.height/2,0),t}}const f=i=>{const r=h.findSceneRecursive(i);r&&r.children.find(e=>{const t=e;if(t.isTransformControlsRoot&&t.controls)return t.controls.detach(),!0;const o=e;return o.isTransformControls&&o.detach?(o.detach(),!0):!1})};exports.AmbientLightComponent=p;exports.PointLightComponent=w;exports.PrimitiveComponent=y;exports.detachTransformControls=f;
|
package/build/chunks/{isFileExtensionSupported-RvlnH2dr.cjs → isFileExtensionSupported-B1q2eWs7.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./FileTypes-
|
|
1
|
+
"use strict";const n=require("./FileTypes-B-MjfMGd.cjs");function o(e){var t;const i=(e.split("/").pop()||"").split(/[?#]/)[0];return!i.includes(".")||i.endsWith(".")?"":((t=i.split(".").pop())==null?void 0:t.toLowerCase())||""}function s(e){return e.toLowerCase()in n.FILE_TYPES}exports.getFileTypeFromUri=o;exports.isFileExtensionSupported=s;
|
package/build/dive.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var P=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var I=(e,t,n)=>P(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/FileTypes-
|
|
1
|
+
"use strict";var M=Object.defineProperty;var P=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var I=(e,t,n)=>P(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/FileTypes-B-MjfMGd.cjs"),f=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),E=require("./chunks/contributesToBounds-C1mva__U.cjs"),m=require("./chunks/detachTransformControls-CZ2cd5hx.cjs"),L=require("./chunks/ModelComponent-Cmu0EX0r.cjs"),V=require("./chunks/SpriteTextComponent-BpoKLOjA.cjs"),_=require("./chunks/collectAnimations-C3HfZHte.cjs"),d=require("./chunks/isVisibleInHierarchy-D9JcLqR5.cjs"),D=require("./chunks/isFileExtensionSupported-B1q2eWs7.cjs"),g=require("three/webgpu"),A=require("./chunks/network-error-CdDXil5g.cjs"),O=require("./chunks/parse-error-Dy_EE4rL.cjs");class h{constructor(){I(this,"isMovable",!0)}}class y{constructor(){I(this,"isSelectable",!0)}}function T(e,t){return t.forEach(n=>{Object.getOwnPropertyNames(n.prototype).forEach(c=>{if(c==="constructor")return;const l=Object.getOwnPropertyDescriptor(n.prototype,c);Object.defineProperty(e.prototype,c,l)});const r=new n;Object.getOwnPropertyNames(r).forEach(c=>{const l=Object.getOwnPropertyDescriptor(r,c);Object.defineProperty(e.prototype,c,l)})}),e}function a(e,t=new WeakMap){if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){const i=[];t.set(e,i);for(let s=0;s<e.length;s++)i[s]=a(e[s],t);return i}if(e instanceof Map){const i=new Map;t.set(e,i);for(const[s,u]of e)i.set(a(s,t),a(u,t));return i}if(e instanceof Set){const i=new Set;t.set(e,i);for(const s of e)i.add(a(s,t));return i}const n=e;if(typeof n.clone=="function"){const i=n.clone();return t.set(e,i),i}const r=Object.create(Object.getPrototypeOf(e));t.set(e,r);const c=Object.getOwnPropertyNames(e);for(const i of c){const s=Object.getOwnPropertyDescriptor(e,i);if(s)if(s.value!==void 0){const u=a(s.value,t);Object.defineProperty(r,i,{...s,value:u})}else Object.defineProperty(r,i,s)}const l=Object.getOwnPropertySymbols(e);for(const i of l){const s=Object.getOwnPropertyDescriptor(e,i);if(s)if(s.value!==void 0){const u=a(s.value,t);Object.defineProperty(r,i,{...s,value:u})}else Object.defineProperty(r,i,s)}return r}const C=(e,t)=>{if(Object.keys(e).length===0&&Object.keys(t).length===0)return{};if(typeof e!="object"||typeof t!="object")return t;let n={};return Object.keys(t).forEach(r=>{if(!Object.keys(e).includes(r)){n={...n,[r]:t[r]};return}if(Array.isArray(t[r])){if(!Array.isArray(e[r])){n={...n,[r]:t[r]};return}const c=e[r],l=t[r];if(c.length===0&&l.length===0){n={...n};return}if(c.length!==l.length){n={...n,[r]:t[r]};return}const i=[];if(l.forEach((s,u)=>{const R=C(c[u],l[u]);Object.keys(R).length&&i.push(l[u])}),Object.keys(i).length){n={...n,[r]:i};return}return}if(typeof t[r]=="object"){if(typeof e[r]!="object"){n={...n,[r]:t[r]};return}const c=C(e[r],t[r]);if(Object.keys(c).length){n={...n,[r]:c};return}}e[r]!==t[r]&&(n={...n,[r]:t[r]})}),n};function x(e){return o.SUPPORTED_MIME_TYPES.includes(e.toLowerCase())}function F(e){return D.isFileExtensionSupported(D.getFileTypeFromUri(e))}function p(e,t){const n=(e+"e").split("e");return+(n[0]+"e"+(+n[1]+(t||0)))}function Y(e,t=0){const n=p(e,+t);return p(Math.ceil(n),-t)}function w(e,t=0){const n=p(e,+t);return p(Math.floor(n),-t)}function S(e,t=0){if(e<0)return-S(-e,t);const n=p(e,+t);return p(Math.round(n),-t)}function B(e,t,n){return Math.atan2(e.clone().cross(t).dot(n),t.clone().dot(e))}function U(e,t=0){const n=p(e,+t);return p(Math.round(n),-t).toFixed(t)}function b(e,t=0){const n=p(e,+t);return p(Math.trunc(n),-t)}function N(e){return(g.MathUtils.radToDeg(e)+360)%360}function K(e){return g.MathUtils.degToRad(e)}const v={ceilExp:Y,floorExp:w,roundExp:S,toFixedExp:U,truncateExp:b,signedAngleTo:B,radToDeg:N,degToRad:K};exports.BoundingBox=o.BoundingBox;exports.BoundingBoxComponent=o.BoundingBoxComponent;exports.DIVE=o.DIVE;exports.DIVEAbortablePromise=o.DIVEAbortablePromise;exports.DIVECameraComponent=o.DIVECameraComponent;exports.DIVECanvasLifecycleManager=o.DIVECanvasLifecycleManager;exports.DIVEClock=o.DIVEClock;exports.DIVEComponent=o.DIVEComponent;exports.DIVEDefaultSettings=o.DIVEDefaultSettings;exports.DIVEDeferredPromise=o.DIVEDeferredPromise;exports.DIVEEnvironment=o.DIVEEnvironment;exports.DIVEEnvironmentDefaultSettings=o.DIVEEnvironmentDefaultSettings;exports.DIVELightComponent=o.DIVELightComponent;exports.DIVENode=o.DIVENode;exports.DIVEPerspectiveCameraDefaultSettings=o.DIVEPerspectiveCameraDefaultSettings;exports.DIVERenderer=o.DIVERenderer;exports.DIVERendererDefaultSettings=o.DIVERendererDefaultSettings;exports.DIVERoot=o.DIVERoot;exports.DIVEScene=o.DIVEScene;exports.DIVESceneDefaultSettings=o.DIVESceneDefaultSettings;exports.DIVEView=o.DIVEView;exports.DirectionalLightComponent=o.DirectionalLightComponent;exports.FILE_TYPES=o.FILE_TYPES;exports.FloorComponent=o.FloorComponent;exports.GRID_MAJOR_LINE_COLOR=o.GRID_MAJOR_LINE_COLOR;exports.GRID_MINOR_LINE_COLOR=o.GRID_MINOR_LINE_COLOR;exports.GridComponent=o.GridComponent;exports.HemisphereLightComponent=o.HemisphereLightComponent;exports.MeshComponent=o.MeshComponent;exports.MultiLineComponent=o.MultiLineComponent;exports.PerspectiveCameraComponent=o.PerspectiveCameraComponent;exports.SUPPORTED_FILE_TYPES=o.SUPPORTED_FILE_TYPES;exports.SUPPORTED_MIME_TYPES=o.SUPPORTED_MIME_TYPES;exports.computeProductBounds=o.computeProductBounds;exports.contributedBy=o.contributedBy;exports.disposeComponents=o.disposeComponents;exports.findComponent=o.findComponent;exports.findSceneRecursive=o.findSceneRecursive;exports.isDIVEComponent=o.isDIVEComponent;exports.AxesColorBlue=f.AxesColorBlue;exports.AxesColorBlueLetter=f.AxesColorBlueLetter;exports.AxesColorGreen=f.AxesColorGreen;exports.AxesColorGreenLetter=f.AxesColorGreenLetter;exports.AxesColorRed=f.AxesColorRed;exports.AxesColorRedLetter=f.AxesColorRedLetter;exports.COORDINATE_LAYER_MASK=E.COORDINATE_LAYER_MASK;exports.DEFAULT_LAYER_MASK=E.DEFAULT_LAYER_MASK;exports.FLOOR_LAYER_MASK=E.FLOOR_LAYER_MASK;exports.HELPER_LAYER_MASK=E.HELPER_LAYER_MASK;exports.PRODUCT_LAYER_MASK=E.PRODUCT_LAYER_MASK;exports.PROXY_LAYER_MASK=E.PROXY_LAYER_MASK;exports.UI_LAYER_MASK=E.UI_LAYER_MASK;exports.contributesToBounds=E.contributesToBounds;exports.AmbientLightComponent=m.AmbientLightComponent;exports.PointLightComponent=m.PointLightComponent;exports.PrimitiveComponent=m.PrimitiveComponent;exports.detachTransformControls=m.detachTransformControls;exports.ModelComponent=L.ModelComponent;exports.SpriteTextComponent=V.SpriteTextComponent;exports.collectAnimations=_.collectAnimations;exports.findInterface=d.findInterface;exports.implementsInterface=d.implementsInterface;exports.isVisibleInHierarchy=d.isVisibleInHierarchy;exports.getFileTypeFromUri=D.getFileTypeFromUri;exports.isFileExtensionSupported=D.isFileExtensionSupported;exports.FileContentError=A.FileContentError;exports.NetworkError=A.NetworkError;exports.FileTypeError=O.FileTypeError;exports.ParseError=O.ParseError;exports.DIVEMath=v;exports.DIVEMovable=h;exports.DIVESelectable=y;exports.applyMixins=T;exports.deepClone=a;exports.getObjectDelta=C;exports.isMimeTypeSupported=x;exports.isURIFileExtensionSupported=F;
|
package/build/dive.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var g = Object.defineProperty;
|
|
2
2
|
var O = (e, t, r) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var u = (e, t, r) => O(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { h as d } from "./chunks/FileTypes-
|
|
5
|
-
import { B as G, i as j, c as v, j as H, D as b, k as J, l as W, a as q, b as z, m as X, n as Q, o as Z, f as $, d as k, p as ee, q as te, r as re, s as ne, t as oe, u as se, v as ae, w as ce, F as ie, x as fe, G as pe, y as ue, z as le, H as Ee, M as me, A as De, P as ge, S as Oe, C as de, E as Ae, e as Ie, I as ye, g as he, J as Ce } from "./chunks/FileTypes-
|
|
4
|
+
import { h as d } from "./chunks/FileTypes-D3Dxr2dj.mjs";
|
|
5
|
+
import { B as G, i as j, c as v, j as H, D as b, k as J, l as W, a as q, b as z, m as X, n as Q, o as Z, f as $, d as k, p as ee, q as te, r as re, s as ne, t as oe, u as se, v as ae, w as ce, F as ie, x as fe, G as pe, y as ue, z as le, H as Ee, M as me, A as De, P as ge, S as Oe, C as de, E as Ae, e as Ie, I as ye, g as he, J as Ce } from "./chunks/FileTypes-D3Dxr2dj.mjs";
|
|
6
6
|
import { b as Me, e as xe, a as Se, d as Re, A as Le, c as Ve } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
7
7
|
import { C as Te, D as we, F as Fe, H as Ne, P as Ye, a as Be, U as Ue, c as Ke } from "./chunks/contributesToBounds-DYmHYES4.mjs";
|
|
8
|
-
import { A as je, P as ve, a as He, d as be } from "./chunks/detachTransformControls-
|
|
9
|
-
import { M as We } from "./chunks/ModelComponent-
|
|
10
|
-
import { S as ze } from "./chunks/SpriteTextComponent-
|
|
8
|
+
import { A as je, P as ve, a as He, d as be } from "./chunks/detachTransformControls-B4iRF1bw.mjs";
|
|
9
|
+
import { M as We } from "./chunks/ModelComponent-WA0kLOEY.mjs";
|
|
10
|
+
import { S as ze } from "./chunks/SpriteTextComponent-DIZFqao0.mjs";
|
|
11
11
|
import { c as Qe } from "./chunks/collectAnimations-BgYCN1le.mjs";
|
|
12
12
|
import { f as $e, i as ke, a as et } from "./chunks/isVisibleInHierarchy-KzVGvDEw.mjs";
|
|
13
|
-
import { i as A, g as I } from "./chunks/isFileExtensionSupported-
|
|
13
|
+
import { i as A, g as I } from "./chunks/isFileExtensionSupported-BqOqU3-h.mjs";
|
|
14
14
|
import { MathUtils as E } from "three/webgpu";
|
|
15
15
|
import { F as rt, N as nt } from "./chunks/network-error-BONfHWQq.mjs";
|
|
16
16
|
import { F as st, P as at } from "./chunks/parse-error-DfOPyLWM.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-
|
|
1
|
+
"use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-DnVvCd41.cjs");require("three/examples/jsm/loaders/DRACOLoader.js");const w=require("../../chunks/AssetExporter-CoL-QXkB.cjs");var m=(o=>(o.AR_DESKTOP_PLATFORM_ERROR="ar-desktop-platform-error",o.AR_QUICK_LOOK_NOT_SAFARI_ERROR="ar-quicklook-not-safari-error",o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR="ar-quicklook-version-mismatch-error",o.AR_QUICK_LOOK_UNKNOWN_ERROR="ar-quicklook-unknown-error",o))(m||{});class a extends Error{constructor(r,t){super(r);l(this,"type");this.name=this.constructor.name,this.type=t,Object.setPrototypeOf(this,new.target.prototype)}}class R extends a{constructor(){super("AR features are not supported on desktop platforms.","ar-desktop-platform-error")}}class p extends a{constructor(){super("ARQuickLook on iOS is only available in Safari.","ar-quicklook-not-safari-error")}}class d extends a{constructor(e,r){super(`ARQuickLook requires iOS version ${r} or later. Current version: ${e}.`,"ar-quicklook-version-mismatch-error"),this.currentVersion=e,this.requiredVersion=r}}class u extends a{constructor(){super("An unknown ARQuickLook compatibility error occurred.","ar-quicklook-unknown-error")}}const k=12;class S{constructor(){l(this,"converter",new A.AssetConverter(new O.AssetLoader,new w.AssetExporter))}async launch(e,r){if(c.SystemInfo.getBrowser()!==c.EBrowser.SAFARI)return Promise.reject(new p);const t=c.SystemInfo.getIOSVersion();if(t&&t.major<k)return Promise.reject(new d(t.full,k));if(!t)return Promise.reject(new u);if(!c.SystemInfo.getSupportsARQuickLook())return Promise.reject(new u);const n=await this.convertToUSDZ(e,r);return this.launchARQuickLook(n,r)}async convertToUSDZ(e,r){const t=await this.converter.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),n=new Blob([t],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(n)}launchARQuickLook(e,r){return new Promise(t=>{(r==null?void 0:r.arScale)==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const n=document.createElement("a");n.innerHTML="<picture></picture>",n.rel="ar",n.href=e,n.download="scene.usdz",t(),n.click()})}}class _{launch(e,r){const t=self.location.toString(),n=document.createElement("a"),s=this._createParams(t,e,r),i=this._createIntent(t,e,s);n.setAttribute("href",i),n.click()}_createParams(e,r,t){const n=new URL(r,e),s=new URLSearchParams(n.search);return s.set("mode","ar_preferred"),this._applyScaleOption(s,t),this._applyPlacementOption(s,t),this._applySoundOption(s,e),this._applyLinkOption(s,e),s}_applyScaleOption(e,r){(r==null?void 0:r.arScale)==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,r){(r==null?void 0:r.arPlacement)==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,r){if(e.has("sound")){const t=new URL(e.get("sound"),r);e.set("sound",t.toString())}}_applyLinkOption(e,r){if(e.has("link")){const t=new URL(e.get("link"),r);e.set("link",t.toString())}}_createIntent(e,r,t){const n=new URL(e),s=new URL(r,e),i="#model-viewer-no-ar-fallback";return n.hash=i,`intent://arvr.google.com/scene-viewer/1.2?${t.toString()+"&file="+s.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(n.toString())};end;`}}class L{async launch(e,r){const t=c.SystemInfo.getSystem();return t===c.ESystem.IOS?new S().launch(e,r):t===c.ESystem.ANDROID?new _().launch(e,r):Promise.reject(new R)}}exports.ARDesktopPlatformError=R;exports.ARError=a;exports.ARQuickLook=S;exports.ARQuickLookNotSafariError=p;exports.ARQuickLookUnknownError=u;exports.ARQuickLookVersionMismatchError=d;exports.ARSystem=L;exports.EARErrorType=m;exports.SceneViewer=_;
|
|
@@ -3,7 +3,7 @@ var R = (o, e, r) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var l = (o, e, r) => R(o, typeof e != "symbol" ? e + "" : e, r);
|
|
4
4
|
import { SystemInfo as c, EBrowser as d, ESystem as u } from "../systeminfo/index.mjs";
|
|
5
5
|
import { AssetConverter as h } from "../assetconverter/index.mjs";
|
|
6
|
-
import { A as _ } from "../../chunks/AssetLoader-
|
|
6
|
+
import { A as _ } from "../../chunks/AssetLoader-Bkp3fWZz.mjs";
|
|
7
7
|
import "three/examples/jsm/loaders/DRACOLoader.js";
|
|
8
8
|
import { A as f } from "../../chunks/AssetExporter-CD2iuQce.mjs";
|
|
9
9
|
var S = /* @__PURE__ */ ((o) => (o.AR_DESKTOP_PLATFORM_ERROR = "ar-desktop-platform-error", o.AR_QUICK_LOOK_NOT_SAFARI_ERROR = "ar-quicklook-not-safari-error", o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR = "ar-quicklook-version-mismatch-error", o.AR_QUICK_LOOK_UNKNOWN_ERROR = "ar-quicklook-unknown-error", o))(S || {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-CUVFS7wk.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-DnVvCd41.cjs");exports.AssetLoader=e.AssetLoader;exports.DRACOWorker=e.DRACOWorker;exports.DracoLoader=e.DracoLoader;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as o } from "../../chunks/AssetLoader-
|
|
2
|
-
import { D as s, a as t } from "../../chunks/AssetLoader-
|
|
1
|
+
import { A as o } from "../../chunks/AssetLoader-Bkp3fWZz.mjs";
|
|
2
|
+
import { D as s, a as t } from "../../chunks/AssetLoader-Bkp3fWZz.mjs";
|
|
3
3
|
export {
|
|
4
4
|
o as AssetLoader,
|
|
5
5
|
s as DRACOWorker,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var w=(a,e,t)=>e in a?p(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var h=(a,e,t)=>w(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("three/webgpu"),y=require("../../chunks/FileTypes-
|
|
1
|
+
"use strict";var p=Object.defineProperty;var w=(a,e,t)=>e in a?p(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var h=(a,e,t)=>w(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("three/webgpu"),y=require("../../chunks/FileTypes-B-MjfMGd.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");class C{constructor(e,t,r){h(this,"_renderer");h(this,"_scene");h(this,"_controller");this._renderer=e,this._scene=t,this._controller=r}async generateMedia(e){const{position:t,target:r,resolution:i}=e,{width:o,height:s}=i,d=this._controller.object.owner.position.clone(),n=this._controller.target.clone(),g=this._renderer.canvas.clientWidth||o,_=this._renderer.canvas.clientHeight||s;try{return this._controller.object.onResize(o,s),this._controller.object.owner.position.copy(t),this._controller.target.copy(r),this._controller.update(),(await this.drawCanvas(void 0,i)).toDataURL()}finally{this._controller.object.owner.position.copy(d),this._controller.target.copy(n),this._controller.update(),this._controller.object.onResize(g,_)}}async drawCanvas(e,t){await this._renderer.initAsync();const r=this._renderer.webgpurenderer,i=Math.max(1,(t==null?void 0:t.width)??(e==null?void 0:e.width)??(e==null?void 0:e.clientWidth)??this._renderer.canvas.clientWidth),o=Math.max(1,(t==null?void 0:t.height)??(e==null?void 0:e.height)??(e==null?void 0:e.clientHeight)??this._renderer.canvas.clientHeight),s=new l.RenderTarget(i,o,{colorSpace:l.SRGBColorSpace}),d=r.getRenderTarget(),n=this._controller.object.camera,g=n.layers.mask;try{r.setRenderTarget(s),n.layers.mask=y.DIVECameraComponent.LIVE_VIEW_LAYER_MASK,r.render(this._scene,n);const _=await r.readRenderTargetPixelsAsync(s,0,0,i,o),c=e??document.createElement("canvas");return c.width=i,c.height=o,this._writePixelsToCanvas(c,_,i,o),c}finally{n.layers.mask=g,r.setRenderTarget(d),s.dispose()}}_writePixelsToCanvas(e,t,r,i){const o=e.getContext("2d");if(!o)throw new Error("MediaCreator.drawCanvas: 2D canvas context is not available.");const s=o.createImageData(r,i);s.data.set(new Uint8ClampedArray(Array.from(t))),o.putImageData(s,0,0)}}exports.MediaCreator=C;
|
|
@@ -2,7 +2,7 @@ var l = Object.defineProperty;
|
|
|
2
2
|
var p = (a, t, r) => t in a ? l(a, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[t] = r;
|
|
3
3
|
var h = (a, t, r) => p(a, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
import { RenderTarget as w, SRGBColorSpace as y } from "three/webgpu";
|
|
5
|
-
import { D as C } from "../../chunks/FileTypes-
|
|
5
|
+
import { D as C } from "../../chunks/FileTypes-D3Dxr2dj.mjs";
|
|
6
6
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
7
7
|
import "three/tsl";
|
|
8
8
|
class M {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/OrbitController-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/OrbitController-CAJIiZeE.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=Object.defineProperty;var c=(t,e,r)=>e in t?_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var o=(t,e,r)=>c(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("three/webgpu"),d=require("../../chunks/FileTypes-
|
|
1
|
+
"use strict";var _=Object.defineProperty;var c=(t,e,r)=>e in t?_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var o=(t,e,r)=>c(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("three/webgpu"),d=require("../../chunks/FileTypes-B-MjfMGd.cjs"),h=require("../../chunks/contributesToBounds-C1mva__U.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const a=require("../../chunks/AxisHelperColors-BrGqktN5.cjs"),x=require("../../chunks/SpriteTextComponent-BpoKLOjA.cjs"),n=(t,e,r)=>{const i=new d.DIVENode;return i.position.set(r.x,r.y,r.z),i.layers.mask=h.COORDINATE_LAYER_MASK,i.addComponent(new x.SpriteTextComponent).setText(t).setTextHeight(.2).setColor(e),i};class p extends s.Object3D{constructor(){super();o(this,"_axesHelper");this._axesHelper=new s.AxesHelper(.5),this._axesHelper.layers.mask=h.COORDINATE_LAYER_MASK,this._axesHelper.material.depthTest=!1,this._axesHelper.position.set(0,0,-1),this._axesHelper.setColors(new s.Color(a.AxesColorRed),new s.Color(a.AxesColorGreen),new s.Color(a.AxesColorBlue)),this._axesHelper.add(n("X",a.AxesColorRedLetter,{x:.7,y:0,z:0}),n("Y",a.AxesColorGreenLetter,{x:0,y:.7,z:0}),n("Z",a.AxesColorBlueLetter,{x:0,y:0,z:.7})),this.add(this._axesHelper)}setFromCameraMatrix(r){this._axesHelper.rotation.setFromRotationMatrix(new s.Matrix4().extractRotation(r).invert())}}class u{constructor(e,r,i){o(this,"uuid",s.MathUtils.generateUUID());o(this,"_axes");o(this,"_orthographicCamera");o(this,"_restoreViewport",new s.Vector4);this._renderer=e,this._scene=r,this._cameraComponent=i,this._orthographicCamera=new s.OrthographicCamera(-1,1,1,-1,.1,100),this._orthographicCamera.name="OrientationDisplayCamera",this._orthographicCamera.layers.mask=h.COORDINATE_LAYER_MASK,this._scene.add(this._orthographicCamera),this._axes=new p,this._axes.name="OrientationDisplayAxes",this._scene.add(this._axes)}tick(){var l;if(!this._renderer.webgpurenderer.initialized)return;const e=this._scene.background??null,r=this._renderer.webgpurenderer.autoClear;this._scene.background=null,this._renderer.webgpurenderer.getViewport(this._restoreViewport);const i=((l=this._renderer.webgpurenderer.domElement)==null?void 0:l.clientHeight)??this._restoreViewport.w;this._renderer.webgpurenderer.setViewport(0,Math.max(0,i-150),150,150),this._renderer.webgpurenderer.autoClear=!1,this._axes.setFromCameraMatrix(this._cameraComponent.camera.matrixWorld),this._renderer.webgpurenderer.render(this._scene,this._orthographicCamera),this._renderer.webgpurenderer.setViewport(this._restoreViewport),this._renderer.webgpurenderer.autoClear=r,this._scene.background=e}dispose(){this._scene.remove(this._axes),this._scene.remove(this._orthographicCamera)}}exports.OrientationDisplay=u;exports.OrientationDisplayAxes=p;
|
|
@@ -2,12 +2,12 @@ var p = Object.defineProperty;
|
|
|
2
2
|
var _ = (t, e, r) => e in t ? p(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var a = (t, e, r) => _(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
4
|
import { Object3D as d, AxesHelper as l, Color as o, Matrix4 as m, OrthographicCamera as c, MathUtils as x, Vector4 as C } from "three/webgpu";
|
|
5
|
-
import { d as u } from "../../chunks/FileTypes-
|
|
5
|
+
import { d as u } from "../../chunks/FileTypes-D3Dxr2dj.mjs";
|
|
6
6
|
import { C as n } from "../../chunks/contributesToBounds-DYmHYES4.mjs";
|
|
7
7
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
8
8
|
import "three/tsl";
|
|
9
9
|
import { A as w, a as g, b, c as A, d as H, e as y } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
10
|
-
import { S as V } from "../../chunks/SpriteTextComponent-
|
|
10
|
+
import { S as V } from "../../chunks/SpriteTextComponent-DIZFqao0.mjs";
|
|
11
11
|
const i = (t, e, r) => {
|
|
12
12
|
const s = new u();
|
|
13
13
|
return s.position.set(r.x, r.y, r.z), s.layers.mask = n, s.addComponent(new V()).setText(t).setTextHeight(0.2).setColor(e), s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../chunks/FileTypes-B-MjfMGd.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const C=require("../../chunks/ModelComponent-Cmu0EX0r.cjs"),S=require("../../chunks/OrbitController-CAJIiZeE.cjs"),v={...i.DIVEDefaultSettings},w=c=>{i.disposeComponents(c),c.removeFromParent()};async function E(c,l){let s=!1;const e=new i.DIVE({...l,autoStart:!1});try{e.mainView.cameraComponent.owner.position.set(0,1,2);const{clientWidth:u,clientHeight:d}=e.mainView.canvas;u>0&&d>0&&e.mainView.cameraComponent.onResize(u,d);const a=new S.OrbitController(e.mainView.cameraComponent,e.mainView.canvas);e.clock.addTicker(a);let t=null,r=null,m=0,f=Promise.resolve();const b=()=>{const o=t??e.scene.root;new i.BoundingBox().enclose(o).isEmpty||a.focusObject(o)},p=()=>{t&&(w(t),t=null),r&&(r.destroyInstance(),r=null,e.scene.root.nodes.forEach(w))},g=e.disposeAsync.bind(e);e.disposeAsync=async()=>{s=!0,m++,a.dispose(),p(),await g()};const k=async o=>{r&&p(),t||(t=new i.DIVENode,t.name="QuickViewModel",t.addComponent(new C.ModelComponent),e.scene.root.add(t));const n=t;if(await n.requireComponent(C.ModelComponent).setFromURL(o),s){i.disposeComponents(n),n.removeFromParent();return}n.dropIt()},q=async o=>{p();const n=new(await Promise.resolve().then(()=>require("../state/index.cjs"))).State(e,a);if(r=n,await n.performAction("SET_STATE",o),s){n.destroyInstance(),e.scene.root.nodes.forEach(w);return}},y=o=>{const n=++m,h=f.then(()=>{if(!(n!==m||s))return typeof o=="string"?k(o):q(o)});return f=h.then(()=>{},()=>{}),h},V=Object.assign(e,{orbitController:a,load:y});return Object.defineProperties(V,{model:{get:()=>t,enumerable:!0},state:{get:()=>r,enumerable:!0}}),await y(c),b(),((l==null?void 0:l.autoStart)??!0)&&await e.startAsync(),V}catch(u){s=!0;try{await e.disposeAsync()}catch(d){console.error("Failed to clean up a QuickView:",d)}throw u}}exports.QuickView=E;exports.QuickViewDefaultSettings=v;
|
|
@@ -1,77 +1,78 @@
|
|
|
1
|
-
import { b as
|
|
1
|
+
import { b as v, c as A, B as D, d as I, e as b } from "../../chunks/FileTypes-D3Dxr2dj.mjs";
|
|
2
2
|
import "three/webgpu";
|
|
3
3
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
4
4
|
import "three/tsl";
|
|
5
|
-
import { M as
|
|
6
|
-
import { O as
|
|
7
|
-
const
|
|
8
|
-
...
|
|
9
|
-
},
|
|
10
|
-
|
|
5
|
+
import { M as h } from "../../chunks/ModelComponent-WA0kLOEY.mjs";
|
|
6
|
+
import { O as S } from "../../chunks/OrbitController-DxCbrQVB.mjs";
|
|
7
|
+
const q = {
|
|
8
|
+
...v
|
|
9
|
+
}, p = (s) => {
|
|
10
|
+
b(s), s.removeFromParent();
|
|
11
11
|
};
|
|
12
|
-
async function
|
|
13
|
-
let
|
|
14
|
-
const e = new
|
|
12
|
+
async function B(s, c) {
|
|
13
|
+
let a = !1;
|
|
14
|
+
const e = new A({ ...c, autoStart: !1 });
|
|
15
15
|
try {
|
|
16
16
|
e.mainView.cameraComponent.owner.position.set(0, 1, 2);
|
|
17
|
-
const
|
|
17
|
+
const { clientWidth: l, clientHeight: m } = e.mainView.canvas;
|
|
18
|
+
l > 0 && m > 0 && e.mainView.cameraComponent.onResize(l, m);
|
|
19
|
+
const i = new S(
|
|
18
20
|
e.mainView.cameraComponent,
|
|
19
21
|
e.mainView.canvas
|
|
20
22
|
);
|
|
21
|
-
e.clock.addTicker(
|
|
22
|
-
let
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
new
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
},
|
|
23
|
+
e.clock.addTicker(i);
|
|
24
|
+
let t = null, r = null, d = 0, f = Promise.resolve();
|
|
25
|
+
const C = () => {
|
|
26
|
+
const o = t ?? e.scene.root;
|
|
27
|
+
new D().enclose(o).isEmpty || i.focusObject(o);
|
|
28
|
+
}, u = () => {
|
|
29
|
+
t && (p(t), t = null), r && (r.destroyInstance(), r = null, e.scene.root.nodes.forEach(p));
|
|
30
|
+
}, k = e.disposeAsync.bind(e);
|
|
29
31
|
e.disposeAsync = async () => {
|
|
30
|
-
|
|
32
|
+
a = !0, d++, i.dispose(), u(), await k();
|
|
31
33
|
};
|
|
32
|
-
const E = async (
|
|
33
|
-
|
|
34
|
-
const n =
|
|
35
|
-
if (await n.requireComponent(
|
|
36
|
-
|
|
34
|
+
const E = async (o) => {
|
|
35
|
+
r && u(), t || (t = new I(), t.name = "QuickViewModel", t.addComponent(new h()), e.scene.root.add(t));
|
|
36
|
+
const n = t;
|
|
37
|
+
if (await n.requireComponent(h).setFromURL(o), a) {
|
|
38
|
+
b(n), n.removeFromParent();
|
|
37
39
|
return;
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
const n = new (await import("../state/index.mjs")).State(e,
|
|
43
|
-
if (
|
|
44
|
-
n.destroyInstance(), e.scene.root.nodes.forEach(
|
|
41
|
+
n.dropIt();
|
|
42
|
+
}, g = async (o) => {
|
|
43
|
+
u();
|
|
44
|
+
const n = new (await import("../state/index.mjs")).State(e, i);
|
|
45
|
+
if (r = n, await n.performAction("SET_STATE", o), a) {
|
|
46
|
+
n.destroyInstance(), e.scene.root.nodes.forEach(p);
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return typeof t == "string" ? E(t, r) : h(t, r);
|
|
49
|
+
}, w = (o) => {
|
|
50
|
+
const n = ++d, V = f.then(() => {
|
|
51
|
+
if (!(n !== d || a))
|
|
52
|
+
return typeof o == "string" ? E(o) : g(o);
|
|
52
53
|
});
|
|
53
|
-
return
|
|
54
|
+
return f = V.then(
|
|
54
55
|
() => {
|
|
55
56
|
},
|
|
56
57
|
() => {
|
|
57
58
|
}
|
|
58
59
|
), V;
|
|
59
|
-
}, y = Object.assign(e, { orbitController:
|
|
60
|
+
}, y = Object.assign(e, { orbitController: i, load: w });
|
|
60
61
|
return Object.defineProperties(y, {
|
|
61
|
-
model: { get: () =>
|
|
62
|
-
state: { get: () =>
|
|
63
|
-
}), await
|
|
64
|
-
} catch (
|
|
65
|
-
|
|
62
|
+
model: { get: () => t, enumerable: !0 },
|
|
63
|
+
state: { get: () => r, enumerable: !0 }
|
|
64
|
+
}), await w(s), C(), ((c == null ? void 0 : c.autoStart) ?? !0) && await e.startAsync(), y;
|
|
65
|
+
} catch (l) {
|
|
66
|
+
a = !0;
|
|
66
67
|
try {
|
|
67
68
|
await e.disposeAsync();
|
|
68
|
-
} catch (
|
|
69
|
-
console.error("Failed to clean up a QuickView:",
|
|
69
|
+
} catch (m) {
|
|
70
|
+
console.error("Failed to clean up a QuickView:", m);
|
|
70
71
|
}
|
|
71
|
-
throw
|
|
72
|
+
throw l;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
B as QuickView,
|
|
77
|
+
q as QuickViewDefaultSettings
|
|
77
78
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DIVE, DIVENode } from '../../../index.ts';
|
|
2
2
|
import { OrbitController } from '../../orbitcontroller/index.ts';
|
|
3
3
|
import { State, StateData } from '../../state/index.ts';
|
|
4
|
-
import {
|
|
4
|
+
import { QuickViewSettings } from '../types/index.ts';
|
|
5
5
|
/**
|
|
6
6
|
* What {@link QuickView} hands back.
|
|
7
7
|
*
|
|
@@ -33,9 +33,8 @@ export type QuickView = DIVE & {
|
|
|
33
33
|
* GPU resources included.
|
|
34
34
|
*
|
|
35
35
|
* @param source - A model URI, or the scene data to apply.
|
|
36
|
-
* @param settings - What to skip; see {@link QuickViewLoadSettings}.
|
|
37
36
|
*/
|
|
38
|
-
load: (source: string | StateData
|
|
37
|
+
load: (source: string | StateData) => Promise<void>;
|
|
39
38
|
};
|
|
40
39
|
export declare const QuickViewDefaultSettings: Omit<Required<QuickViewSettings>, 'hdr'>;
|
|
41
40
|
/**
|
|
@@ -1,16 +1,2 @@
|
|
|
1
1
|
import { DIVESettings } from '../../../index.ts';
|
|
2
2
|
export type QuickViewSettings = DIVESettings;
|
|
3
|
-
/**
|
|
4
|
-
* What to do around a model swap, beyond loading it.
|
|
5
|
-
*
|
|
6
|
-
* Both default to `true`, because that is what a viewer wants: a model that
|
|
7
|
-
* stands on the ground and fills the view. Turn one off where the caller has its
|
|
8
|
-
* own answer -- a configurator that keeps the camera where the user put it, or a
|
|
9
|
-
* scene where the model is meant to float.
|
|
10
|
-
*/
|
|
11
|
-
export type QuickViewLoadSettings = {
|
|
12
|
-
/** Drop the model onto whatever is below it. @default true */
|
|
13
|
-
dropToFloor: boolean;
|
|
14
|
-
/** Frame the model once it is loaded. @default true */
|
|
15
|
-
focus: boolean;
|
|
16
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Ii=Object.defineProperty;var xi=(r,e,t)=>e in r?Ii(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _=(r,e,t)=>xi(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ft=require("three/webgpu"),A=require("../../chunks/FileTypes-gD_1MonW.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const L=require("../../chunks/detachTransformControls-2XQrpLN-.cjs"),kt=require("../../chunks/ModelComponent-Cj3ff6nL.cjs"),Vn={};function p(r,e){Vn[r]=e}function Un(r){return Vn[r]}var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var W,Xt;function Pi(){if(Xt)return W;Xt=1;function r(){this.__data__=[],this.size=0}return W=r,W}var ee,Yt;function N(){if(Yt)return ee;Yt=1;function r(e,t){return e===t||e!==e&&t!==t}return ee=r,ee}var te,Qt;function z(){if(Qt)return te;Qt=1;var r=N();function e(t,n){for(var i=t.length;i--;)if(r(t[i][0],n))return i;return-1}return te=e,te}var re,Wt;function Li(){if(Wt)return re;Wt=1;var r=z(),e=Array.prototype,t=e.splice;function n(i){var a=this.__data__,o=r(a,i);if(o<0)return!1;var s=a.length-1;return o==s?a.pop():t.call(a,o,1),--this.size,!0}return re=n,re}var ne,er;function Di(){if(er)return ne;er=1;var r=z();function e(t){var n=this.__data__,i=r(n,t);return i<0?void 0:n[i][1]}return ne=e,ne}var ie,tr;function Gi(){if(tr)return ie;tr=1;var r=z();function e(t){return r(this.__data__,t)>-1}return ie=e,ie}var ae,rr;function ki(){if(rr)return ae;rr=1;var r=z();function e(t,n){var i=this.__data__,a=r(i,t);return a<0?(++this.size,i.push([t,n])):i[a][1]=n,this}return ae=e,ae}var oe,nr;function H(){if(nr)return oe;nr=1;var r=Pi(),e=Li(),t=Di(),n=Gi(),i=ki();function a(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return a.prototype.clear=r,a.prototype.delete=e,a.prototype.get=t,a.prototype.has=n,a.prototype.set=i,oe=a,oe}var se,ir;function Vi(){if(ir)return se;ir=1;var r=H();function e(){this.__data__=new r,this.size=0}return se=e,se}var ce,ar;function Ui(){if(ar)return ce;ar=1;function r(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}return ce=r,ce}var ue,or;function Fi(){if(or)return ue;or=1;function r(e){return this.__data__.get(e)}return ue=r,ue}var fe,sr;function Bi(){if(sr)return fe;sr=1;function r(e){return this.__data__.has(e)}return fe=r,fe}var de,cr;function Fn(){if(cr)return de;cr=1;var r=typeof B=="object"&&B&&B.Object===Object&&B;return de=r,de}var le,ur;function x(){if(ur)return le;ur=1;var r=Fn(),e=typeof self=="object"&&self&&self.Object===Object&&self,t=r||e||Function("return this")();return le=t,le}var he,fr;function Bn(){if(fr)return he;fr=1;var r=x(),e=r.Symbol;return he=e,he}var pe,dr;function Ni(){if(dr)return pe;dr=1;var r=Bn(),e=Object.prototype,t=e.hasOwnProperty,n=e.toString,i=r?r.toStringTag:void 0;function a(o){var s=t.call(o,i),c=o[i];try{o[i]=void 0;var u=!0}catch{}var f=n.call(o);return u&&(s?o[i]=c:delete o[i]),f}return pe=a,pe}var ve,lr;function zi(){if(lr)return ve;lr=1;var r=Object.prototype,e=r.toString;function t(n){return e.call(n)}return ve=t,ve}var _e,hr;function K(){if(hr)return _e;hr=1;var r=Bn(),e=Ni(),t=zi(),n="[object Null]",i="[object Undefined]",a=r?r.toStringTag:void 0;function o(s){return s==null?s===void 0?i:n:a&&a in Object(s)?e(s):t(s)}return _e=o,_e}var ge,pr;function j(){if(pr)return ge;pr=1;function r(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}return ge=r,ge}var be,vr;function Bt(){if(vr)return be;vr=1;var r=K(),e=j(),t="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(s){if(!e(s))return!1;var c=r(s);return c==n||c==i||c==t||c==a}return be=o,be}var ye,_r;function Hi(){if(_r)return ye;_r=1;var r=x(),e=r["__core-js_shared__"];return ye=e,ye}var me,gr;function Ki(){if(gr)return me;gr=1;var r=Hi(),e=function(){var n=/[^.]+$/.exec(r&&r.keys&&r.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function t(n){return!!e&&e in n}return me=t,me}var Ae,br;function $i(){if(br)return Ae;br=1;var r=Function.prototype,e=r.toString;function t(n){if(n!=null){try{return e.call(n)}catch{}try{return n+""}catch{}}return""}return Ae=t,Ae}var Ce,yr;function Ji(){if(yr)return Ce;yr=1;var r=Bt(),e=Ki(),t=j(),n=$i(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,c=o.toString,u=s.hasOwnProperty,f=RegExp("^"+c.call(u).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(v){if(!t(v)||e(v))return!1;var m=r(v)?f:a;return m.test(n(v))}return Ce=d,Ce}var Ee,mr;function Zi(){if(mr)return Ee;mr=1;function r(e,t){return e==null?void 0:e[t]}return Ee=r,Ee}var qe,Ar;function Nt(){if(Ar)return qe;Ar=1;var r=Ji(),e=Zi();function t(n,i){var a=e(n,i);return r(a)?a:void 0}return qe=t,qe}var Te,Cr;function Nn(){if(Cr)return Te;Cr=1;var r=Nt(),e=x(),t=r(e,"Map");return Te=t,Te}var Se,Er;function $(){if(Er)return Se;Er=1;var r=Nt(),e=r(Object,"create");return Se=e,Se}var we,qr;function Xi(){if(qr)return we;qr=1;var r=$();function e(){this.__data__=r?r(null):{},this.size=0}return we=e,we}var Oe,Tr;function Yi(){if(Tr)return Oe;Tr=1;function r(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}return Oe=r,Oe}var je,Sr;function Qi(){if(Sr)return je;Sr=1;var r=$(),e="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function i(a){var o=this.__data__;if(r){var s=o[a];return s===e?void 0:s}return n.call(o,a)?o[a]:void 0}return je=i,je}var Re,wr;function Wi(){if(wr)return Re;wr=1;var r=$(),e=Object.prototype,t=e.hasOwnProperty;function n(i){var a=this.__data__;return r?a[i]!==void 0:t.call(a,i)}return Re=n,Re}var Ie,Or;function ea(){if(Or)return Ie;Or=1;var r=$(),e="__lodash_hash_undefined__";function t(n,i){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=r&&i===void 0?e:i,this}return Ie=t,Ie}var xe,jr;function ta(){if(jr)return xe;jr=1;var r=Xi(),e=Yi(),t=Qi(),n=Wi(),i=ea();function a(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return a.prototype.clear=r,a.prototype.delete=e,a.prototype.get=t,a.prototype.has=n,a.prototype.set=i,xe=a,xe}var Me,Rr;function ra(){if(Rr)return Me;Rr=1;var r=ta(),e=H(),t=Nn();function n(){this.size=0,this.__data__={hash:new r,map:new(t||e),string:new r}}return Me=n,Me}var Pe,Ir;function na(){if(Ir)return Pe;Ir=1;function r(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}return Pe=r,Pe}var Le,xr;function J(){if(xr)return Le;xr=1;var r=na();function e(t,n){var i=t.__data__;return r(n)?i[typeof n=="string"?"string":"hash"]:i.map}return Le=e,Le}var De,Mr;function ia(){if(Mr)return De;Mr=1;var r=J();function e(t){var n=r(this,t).delete(t);return this.size-=n?1:0,n}return De=e,De}var Ge,Pr;function aa(){if(Pr)return Ge;Pr=1;var r=J();function e(t){return r(this,t).get(t)}return Ge=e,Ge}var ke,Lr;function oa(){if(Lr)return ke;Lr=1;var r=J();function e(t){return r(this,t).has(t)}return ke=e,ke}var Ve,Dr;function sa(){if(Dr)return Ve;Dr=1;var r=J();function e(t,n){var i=r(this,t),a=i.size;return i.set(t,n),this.size+=i.size==a?0:1,this}return Ve=e,Ve}var Ue,Gr;function ca(){if(Gr)return Ue;Gr=1;var r=ra(),e=ia(),t=aa(),n=oa(),i=sa();function a(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return a.prototype.clear=r,a.prototype.delete=e,a.prototype.get=t,a.prototype.has=n,a.prototype.set=i,Ue=a,Ue}var Fe,kr;function ua(){if(kr)return Fe;kr=1;var r=H(),e=Nn(),t=ca(),n=200;function i(a,o){var s=this.__data__;if(s instanceof r){var c=s.__data__;if(!e||c.length<n-1)return c.push([a,o]),this.size=++s.size,this;s=this.__data__=new t(c)}return s.set(a,o),this.size=s.size,this}return Fe=i,Fe}var Be,Vr;function fa(){if(Vr)return Be;Vr=1;var r=H(),e=Vi(),t=Ui(),n=Fi(),i=Bi(),a=ua();function o(s){var c=this.__data__=new r(s);this.size=c.size}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=i,o.prototype.set=a,Be=o,Be}var Ne,Ur;function zn(){if(Ur)return Ne;Ur=1;var r=Nt(),e=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch{}}();return Ne=e,Ne}var ze,Fr;function zt(){if(Fr)return ze;Fr=1;var r=zn();function e(t,n,i){n=="__proto__"&&r?r(t,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[n]=i}return ze=e,ze}var He,Br;function Hn(){if(Br)return He;Br=1;var r=zt(),e=N();function t(n,i,a){(a!==void 0&&!e(n[i],a)||a===void 0&&!(i in n))&&r(n,i,a)}return He=t,He}var Ke,Nr;function da(){if(Nr)return Ke;Nr=1;function r(e){return function(t,n,i){for(var a=-1,o=Object(t),s=i(t),c=s.length;c--;){var u=s[e?c:++a];if(n(o[u],u,o)===!1)break}return t}}return Ke=r,Ke}var $e,zr;function la(){if(zr)return $e;zr=1;var r=da(),e=r();return $e=e,$e}var D={exports:{}};D.exports;var Hr;function ha(){return Hr||(Hr=1,function(r,e){var t=x(),n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,a=i&&i.exports===n,o=a?t.Buffer:void 0,s=o?o.allocUnsafe:void 0;function c(u,f){if(f)return u.slice();var d=u.length,v=s?s(d):new u.constructor(d);return u.copy(v),v}r.exports=c}(D,D.exports)),D.exports}var Je,Kr;function pa(){if(Kr)return Je;Kr=1;var r=x(),e=r.Uint8Array;return Je=e,Je}var Ze,$r;function va(){if($r)return Ze;$r=1;var r=pa();function e(t){var n=new t.constructor(t.byteLength);return new r(n).set(new r(t)),n}return Ze=e,Ze}var Xe,Jr;function _a(){if(Jr)return Xe;Jr=1;var r=va();function e(t,n){var i=n?r(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}return Xe=e,Xe}var Ye,Zr;function ga(){if(Zr)return Ye;Zr=1;function r(e,t){var n=-1,i=e.length;for(t||(t=Array(i));++n<i;)t[n]=e[n];return t}return Ye=r,Ye}var Qe,Xr;function ba(){if(Xr)return Qe;Xr=1;var r=j(),e=Object.create,t=function(){function n(){}return function(i){if(!r(i))return{};if(e)return e(i);n.prototype=i;var a=new n;return n.prototype=void 0,a}}();return Qe=t,Qe}var We,Yr;function ya(){if(Yr)return We;Yr=1;function r(e,t){return function(n){return e(t(n))}}return We=r,We}var et,Qr;function Kn(){if(Qr)return et;Qr=1;var r=ya(),e=r(Object.getPrototypeOf,Object);return et=e,et}var tt,Wr;function $n(){if(Wr)return tt;Wr=1;var r=Object.prototype;function e(t){var n=t&&t.constructor,i=typeof n=="function"&&n.prototype||r;return t===i}return tt=e,tt}var rt,en;function ma(){if(en)return rt;en=1;var r=ba(),e=Kn(),t=$n();function n(i){return typeof i.constructor=="function"&&!t(i)?r(e(i)):{}}return rt=n,rt}var nt,tn;function U(){if(tn)return nt;tn=1;function r(e){return e!=null&&typeof e=="object"}return nt=r,nt}var it,rn;function Aa(){if(rn)return it;rn=1;var r=K(),e=U(),t="[object Arguments]";function n(i){return e(i)&&r(i)==t}return it=n,it}var at,nn;function Jn(){if(nn)return at;nn=1;var r=Aa(),e=U(),t=Object.prototype,n=t.hasOwnProperty,i=t.propertyIsEnumerable,a=r(function(){return arguments}())?r:function(o){return e(o)&&n.call(o,"callee")&&!i.call(o,"callee")};return at=a,at}var ot,an;function Zn(){if(an)return ot;an=1;var r=Array.isArray;return ot=r,ot}var st,on;function Xn(){if(on)return st;on=1;var r=9007199254740991;function e(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=r}return st=e,st}var ct,sn;function Ht(){if(sn)return ct;sn=1;var r=Bt(),e=Xn();function t(n){return n!=null&&e(n.length)&&!r(n)}return ct=t,ct}var ut,cn;function Ca(){if(cn)return ut;cn=1;var r=Ht(),e=U();function t(n){return e(n)&&r(n)}return ut=t,ut}var G={exports:{}},ft,un;function Ea(){if(un)return ft;un=1;function r(){return!1}return ft=r,ft}G.exports;var fn;function Yn(){return fn||(fn=1,function(r,e){var t=x(),n=Ea(),i=e&&!e.nodeType&&e,a=i&&!0&&r&&!r.nodeType&&r,o=a&&a.exports===i,s=o?t.Buffer:void 0,c=s?s.isBuffer:void 0,u=c||n;r.exports=u}(G,G.exports)),G.exports}var dt,dn;function qa(){if(dn)return dt;dn=1;var r=K(),e=Kn(),t=U(),n="[object Object]",i=Function.prototype,a=Object.prototype,o=i.toString,s=a.hasOwnProperty,c=o.call(Object);function u(f){if(!t(f)||r(f)!=n)return!1;var d=e(f);if(d===null)return!0;var v=s.call(d,"constructor")&&d.constructor;return typeof v=="function"&&v instanceof v&&o.call(v)==c}return dt=u,dt}var lt,ln;function Ta(){if(ln)return lt;ln=1;var r=K(),e=Xn(),t=U(),n="[object Arguments]",i="[object Array]",a="[object Boolean]",o="[object Date]",s="[object Error]",c="[object Function]",u="[object Map]",f="[object Number]",d="[object Object]",v="[object RegExp]",m="[object Set]",E="[object String]",q="[object WeakMap]",T="[object ArrayBuffer]",R="[object DataView]",g="[object Float32Array]",Y="[object Float64Array]",Q="[object Int8Array]",M="[object Int16Array]",S="[object Int32Array]",C="[object Uint8Array]",b="[object Uint8ClampedArray]",F="[object Uint16Array]",y="[object Uint32Array]",l={};l[g]=l[Y]=l[Q]=l[M]=l[S]=l[C]=l[b]=l[F]=l[y]=!0,l[n]=l[i]=l[T]=l[a]=l[R]=l[o]=l[s]=l[c]=l[u]=l[f]=l[d]=l[v]=l[m]=l[E]=l[q]=!1;function P(w){return t(w)&&e(w.length)&&!!l[r(w)]}return lt=P,lt}var ht,hn;function Sa(){if(hn)return ht;hn=1;function r(e){return function(t){return e(t)}}return ht=r,ht}var k={exports:{}};k.exports;var pn;function wa(){return pn||(pn=1,function(r,e){var t=Fn(),n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,a=i&&i.exports===n,o=a&&t.process,s=function(){try{var c=i&&i.require&&i.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();r.exports=s}(k,k.exports)),k.exports}var pt,vn;function Qn(){if(vn)return pt;vn=1;var r=Ta(),e=Sa(),t=wa(),n=t&&t.isTypedArray,i=n?e(n):r;return pt=i,pt}var vt,_n;function Wn(){if(_n)return vt;_n=1;function r(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return vt=r,vt}var _t,gn;function Oa(){if(gn)return _t;gn=1;var r=zt(),e=N(),t=Object.prototype,n=t.hasOwnProperty;function i(a,o,s){var c=a[o];(!(n.call(a,o)&&e(c,s))||s===void 0&&!(o in a))&&r(a,o,s)}return _t=i,_t}var gt,bn;function ja(){if(bn)return gt;bn=1;var r=Oa(),e=zt();function t(n,i,a,o){var s=!a;a||(a={});for(var c=-1,u=i.length;++c<u;){var f=i[c],d=o?o(a[f],n[f],f,a,n):void 0;d===void 0&&(d=n[f]),s?e(a,f,d):r(a,f,d)}return a}return gt=t,gt}var bt,yn;function Ra(){if(yn)return bt;yn=1;function r(e,t){for(var n=-1,i=Array(e);++n<e;)i[n]=t(n);return i}return bt=r,bt}var yt,mn;function ei(){if(mn)return yt;mn=1;var r=9007199254740991,e=/^(?:0|[1-9]\d*)$/;function t(n,i){var a=typeof n;return i=i??r,!!i&&(a=="number"||a!="symbol"&&e.test(n))&&n>-1&&n%1==0&&n<i}return yt=t,yt}var mt,An;function Ia(){if(An)return mt;An=1;var r=Ra(),e=Jn(),t=Zn(),n=Yn(),i=ei(),a=Qn(),o=Object.prototype,s=o.hasOwnProperty;function c(u,f){var d=t(u),v=!d&&e(u),m=!d&&!v&&n(u),E=!d&&!v&&!m&&a(u),q=d||v||m||E,T=q?r(u.length,String):[],R=T.length;for(var g in u)(f||s.call(u,g))&&!(q&&(g=="length"||m&&(g=="offset"||g=="parent")||E&&(g=="buffer"||g=="byteLength"||g=="byteOffset")||i(g,R)))&&T.push(g);return T}return mt=c,mt}var At,Cn;function xa(){if(Cn)return At;Cn=1;function r(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}return At=r,At}var Ct,En;function Ma(){if(En)return Ct;En=1;var r=j(),e=$n(),t=xa(),n=Object.prototype,i=n.hasOwnProperty;function a(o){if(!r(o))return t(o);var s=e(o),c=[];for(var u in o)u=="constructor"&&(s||!i.call(o,u))||c.push(u);return c}return Ct=a,Ct}var Et,qn;function ti(){if(qn)return Et;qn=1;var r=Ia(),e=Ma(),t=Ht();function n(i){return t(i)?r(i,!0):e(i)}return Et=n,Et}var qt,Tn;function Pa(){if(Tn)return qt;Tn=1;var r=ja(),e=ti();function t(n){return r(n,e(n))}return qt=t,qt}var Tt,Sn;function La(){if(Sn)return Tt;Sn=1;var r=Hn(),e=ha(),t=_a(),n=ga(),i=ma(),a=Jn(),o=Zn(),s=Ca(),c=Yn(),u=Bt(),f=j(),d=qa(),v=Qn(),m=Wn(),E=Pa();function q(T,R,g,Y,Q,M,S){var C=m(T,g),b=m(R,g),F=S.get(b);if(F){r(T,g,F);return}var y=M?M(C,b,g+"",T,R,S):void 0,l=y===void 0;if(l){var P=o(b),w=!P&&c(b),Zt=!P&&!w&&v(b);y=b,P||w||Zt?o(C)?y=C:s(C)?y=n(C):w?(l=!1,y=e(b,!0)):Zt?(l=!1,y=t(b,!0)):y=[]:d(b)||a(b)?(y=C,a(C)?y=E(C):(!f(C)||u(C))&&(y=i(b))):l=!1}l&&(S.set(b,y),Q(y,b,Y,M,S),S.delete(b)),r(T,g,y)}return Tt=q,Tt}var St,wn;function Da(){if(wn)return St;wn=1;var r=fa(),e=Hn(),t=la(),n=La(),i=j(),a=ti(),o=Wn();function s(c,u,f,d,v){c!==u&&t(u,function(m,E){if(v||(v=new r),i(m))n(c,u,E,f,s,d,v);else{var q=d?d(o(c,E),m,E+"",c,u,v):void 0;q===void 0&&(q=m),e(c,E,q)}},a)}return St=s,St}var wt,On;function ri(){if(On)return wt;On=1;function r(e){return e}return wt=r,wt}var Ot,jn;function Ga(){if(jn)return Ot;jn=1;function r(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}return Ot=r,Ot}var jt,Rn;function ka(){if(Rn)return jt;Rn=1;var r=Ga(),e=Math.max;function t(n,i,a){return i=e(i===void 0?n.length-1:i,0),function(){for(var o=arguments,s=-1,c=e(o.length-i,0),u=Array(c);++s<c;)u[s]=o[i+s];s=-1;for(var f=Array(i+1);++s<i;)f[s]=o[s];return f[i]=a(u),r(n,this,f)}}return jt=t,jt}var Rt,In;function Va(){if(In)return Rt;In=1;function r(e){return function(){return e}}return Rt=r,Rt}var It,xn;function Ua(){if(xn)return It;xn=1;var r=Va(),e=zn(),t=ri(),n=e?function(i,a){return e(i,"toString",{configurable:!0,enumerable:!1,value:r(a),writable:!0})}:t;return It=n,It}var xt,Mn;function Fa(){if(Mn)return xt;Mn=1;var r=800,e=16,t=Date.now;function n(i){var a=0,o=0;return function(){var s=t(),c=e-(s-o);if(o=s,c>0){if(++a>=r)return arguments[0]}else a=0;return i.apply(void 0,arguments)}}return xt=n,xt}var Mt,Pn;function Ba(){if(Pn)return Mt;Pn=1;var r=Ua(),e=Fa(),t=e(r);return Mt=t,Mt}var Pt,Ln;function Na(){if(Ln)return Pt;Ln=1;var r=ri(),e=ka(),t=Ba();function n(i,a){return t(e(i,a,r),i+"")}return Pt=n,Pt}var Lt,Dn;function za(){if(Dn)return Lt;Dn=1;var r=N(),e=Ht(),t=ei(),n=j();function i(a,o,s){if(!n(s))return!1;var c=typeof o;return(c=="number"?e(s)&&t(o,s.length):c=="string"&&o in s)?r(s[o],a):!1}return Lt=i,Lt}var Dt,Gn;function Ha(){if(Gn)return Dt;Gn=1;var r=Na(),e=za();function t(n){return r(function(i,a){var o=-1,s=a.length,c=s>1?a[s-1]:void 0,u=s>2?a[2]:void 0;for(c=n.length>3&&typeof c=="function"?(s--,c):void 0,u&&e(a[0],a[1],u)&&(c=s<3?void 0:c,s=1),i=Object(i);++o<s;){var f=a[o];f&&n(i,f,o,c)}return i})}return Dt=t,Dt}var Gt,kn;function Ka(){if(kn)return Gt;kn=1;var r=Da(),e=Ha(),t=e(function(n,i,a){r(n,i,a)});return Gt=t,Gt}var $a=Ka();const Ja=Mi($a),Za=["position","rotation","scale","target"],Xa=r=>typeof r=="object"&&r!==null&&typeof r.x=="number"&&typeof r.y=="number"&&typeof r.z=="number",ni=r=>{const e={...r};return Za.forEach(t=>{const n=e[t];Xa(n)&&(e[t]={x:n.x,y:n.y,z:n.z})}),e};class Ya{constructor(){_(this,"_entities",new Map)}get size(){return this._entities.size}read(e){return e===void 0?Array.from(this._entities.values()):this._entities.get(e)}write(e,t){const n=this._entities.get(e);n&&Ja(n.schema,ni(t))}register(e,t,n){this._entities.set(e.id,{schema:e,node:t,unwatch:n})}unregister(e){var n;const t=this._entities.get(e);return t?((n=t.unwatch)==null||n.call(t),this._entities.delete(e)):!1}clear(){this._entities.forEach(e=>{var t;return(t=e.unwatch)==null?void 0:t.call(e)}),this._entities.clear()}}function ii(r){return r.entityType==="group"}function ai(r){return r.entityType==="light"}function Kt(r){return r.entityType==="model"}function Z(r){return r.entityType==="camera"}function oi(r){return r.entityType==="primitive"}const Qa=new Ft.Vector3,Vt=r=>{var t;const e=r.parent;!e||!("isDIVENode"in e)||(t=e.getComponent(A.MultiLineComponent))==null||t.setLineFor(r,Qa,r.position)};class si{constructor(e){_(this,"_engine");_(this,"_entities",new Map);this._engine=e}get root(){return this._engine.scene.root}findEntity(e){return this._entities.get(e.id)}createEntity(e){const t=this.findEntity(e);if(t)return console.warn(`EngineGateway.createEntity: Scene object with id ${e.id} already exists`),t;if(Z(e))return;const n=this._instantiate(e);return n.name=e.name,n.userData.id=e.id,this._entities.set(e.id,n),this.root.add(n),n}async applyEntity(e,t){await this._apply(e,t)}async updateEntity(e){const t=this.findEntity(e);if(!t){console.warn(`EngineGateway.updateEntity: Scene object with id ${e.id} does not exist`);return}await this._apply(t,e)}removeEntity(e){const t=this.findEntity(e);if(!t){console.warn(`EngineGateway.removeEntity: Object with id ${e.id} not found`);return}if(this._entities.delete(e.id),L.detachTransformControls(t),"isDIVENode"in t){const n=t.nodes;for(let i=n.length-1;i>=0;i--)this.root.attach(n[i])}A.disposeComponents(t),t.removeFromParent()}dispose(){this._entities.clear()}readSceneSettings(){const e=this._engine.scene;return{name:e.name,backgroundColor:"#"+e.background.getHexString(),gridEnabled:e.grid.visible,floorEnabled:e.root.floor.visible,floorColor:"#"+e.root.floor.material.color.getHexString()}}applySceneSettings(e){const t=this._engine.scene;e.name!==void 0&&(t.name=e.name),e.backgroundColor!==void 0&&t.setBackground(e.backgroundColor),e.gridEnabled!==void 0&&t.grid.setVisibility(e.gridEnabled),e.floorEnabled!==void 0&&t.root.floor.setVisibility(e.floorEnabled),e.floorColor!==void 0&&t.root.floor.setColor(e.floorColor)}startRendering(){return this._engine.startAsync()}registerTicker(e){this._engine.clock.hasTicker(e)||this._engine.clock.addTicker(e)}_instantiate(e){if(Kt(e)){const t=new A.DIVENode;return t.name="DIVEModel",t.userData.isDIVEModel=!0,t.addComponent(new kt.ModelComponent),t}if(oi(e)){const t=new A.DIVENode;return t.name="DIVEPrimitive",t.addComponent(new L.PrimitiveComponent),t}if(ii(e)){const t=new A.DIVENode;t.name="DIVEGroup";const n=t.addComponent(new A.MultiLineComponent);return t.addEventListener("childremoved",i=>n.removeLineFor(i.child)),t}if(ai(e))return this._instantiateLight(e);throw new Error(`EngineGateway.addEntity: Unknown entity type: ${e.entityType}`)}_instantiateLight(e){const t=new A.DIVENode;switch(t.name="DIVELight",e.type){case"scene":t.addComponent(new A.HemisphereLightComponent),t.addComponent(new A.DirectionalLightComponent);break;case"ambient":t.addComponent(new L.AmbientLightComponent);break;case"point":t.addComponent(new L.PointLightComponent);break;default:throw new Error(`EngineGateway.addEntity: Unknown light type: ${e.type}`)}return t}async _apply(e,t){if(t.entityType==="camera")return;const n=e;switch(t.entityType){case"light":this._applyLight(n,t);break;case"model":await this._applyModel(n,t);break;case"primitive":this._applyPrimitive(n,t);break;case"group":this._applyGroup(n,t);break;default:throw new Error(`EngineGateway.updateEntity: Unknown entity type: ${t.entityType}`)}t.name!==void 0&&(n.name=t.name),n.applyTransform(t),t.visible!==void 0&&n.setVisibility(t.visible),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId}),Vt(n)}_applyLight(e,t){e.getComponents(A.DIVELightComponent).forEach(i=>{t.intensity!==void 0&&i.setIntensity(t.intensity),t.enabled!==void 0&&i.setEnabled(t.enabled),t.color!==void 0&&i.setColor(new Ft.Color(t.color))})}async _applyModel(e,t){t.uri!==void 0&&t.uri!==e.userData.uri&&(await e.requireComponent(kt.ModelComponent).setFromURL(t.uri),e.userData.uri=t.uri),t.material!==void 0&&t.material!==null&&e.requireComponent(A.MeshComponent).setMaterial(t.material)}_applyPrimitive(e,t){t.geometry!==void 0&&t.geometry!==null&&e.requireComponent(L.PrimitiveComponent).setGeometry(t.geometry),t.material!==void 0&&t.material!==null&&e.requireComponent(A.MeshComponent).setMaterial(t.material)}_applyGroup(e,t){t.linksVisible!==void 0&&e.requireComponent(A.MultiLineComponent).setVisible(t.linksVisible)}_setParent(e){const t=this.findEntity(e);if(!t){console.warn(`EngineGateway._setParent: ${e.id} is not in the scene`);return}if(e.parentId===null){this.root.attach(t);return}const n=this.findEntity({id:e.parentId,entityType:e.entityType});if(!n){console.warn(`EngineGateway._setParent: Parent with id ${e.parentId} is not in the scene, ${e.id} stays at the root`);return}n.attach(t),Vt(t)}}class h{constructor(e,t){_(this,"_payload");_(this,"_dependencies");this._payload=e,this._dependencies=t}static define({description:e,execute:t}){return class extends h{constructor(i,a){super(i,a);_(this,"_description",e);_(this,"_payload");this._payload=i}execute(){return t(this._payload,this._dependencies)}}}}const ci=h.define({description:"Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)",execute:async(r,{getARSystem:e})=>e().then(t=>{t.launch(r.uri,r.options)})});p("LAUNCH_AR",ci);const ui=h.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(r,{gateway:e,controller:t})=>{const n=A.computeProductBounds(e.root).getBoundingSphere(new Ft.Sphere);return t.computeEncompassingView(n)}});p("COMPUTE_ENCOMPASSING_VIEW",ui);const fi=h.define({description:"Gets the current camera position and target.",execute:(r,{controller:e})=>({position:e.object.owner.position.clone(),target:e.target.clone()})});p("GET_CAMERA_TRANSFORM",fi);const di=h.define({description:"Moves the camera to a new position and target.",execute:async(r,{controller:e,registry:t,getAnimationSystem:n,gateway:i})=>{var u;const a=await n();let o={x:0,y:0,z:0},s={x:0,y:0,z:0};if("id"in r){const f=(u=t.read(r.id))==null?void 0:u.schema;if(!f)throw new Error(`CAMERA with id ${r.id} not registered.`);if(!Z(f))throw new Error(`Object with id ${r.id} is not a CAMERA. Object: ${f}`);o=f.position,s=f.target}else o=r.position,s=r.target;i.registerTicker(a),e.enabled=!0;const c=await a.fromTargets([{object:e.object.owner.position,to:o},{object:e.target,to:s}],r.duration,{easing:a.Easing.Quadratic.Out,onUpdate:()=>{e.object.lookAt(e.target)},onComplete:()=>{e.enabled=!r.locked}});return c.play(),{stop:()=>c.stop()}}});p("MOVE_CAMERA",di);const li=h.define({description:"Sets the camera layer to a certain layer.",execute:(r,{controller:e})=>{e.object.setCameraLayer(r.layer)}});p("SET_CAMERA_LAYER",li);const $t=h.define({description:"Sets the camera position and target.",execute:(r,{controller:e})=>{e.object.owner.position.copy(r.position),e.target.copy(r.target),e.update()}});p("SET_CAMERA_TRANSFORM",$t);const hi=h.define({description:"Zooms the camera in or out by a certain amount.",execute:(r,{controller:e})=>{r.direction==="IN"&&e.zoomIn(r.by),r.direction==="OUT"&&e.zoomOut(r.by)}});p("ZOOM_CAMERA",hi);const pi=h.define({description:"Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.",execute:async(r,{getMediaCreator:e,registry:t})=>{var i;const n=await e();if("id"in r){const a=(i=t.read(r.id))==null?void 0:i.schema;if(!a)throw new Error(`Object with id ${r.id} not registered.`);if(!Z(a))throw new Error(`Object with id ${r.id} is not a CAMERA. Object: ${a}`);const{resolution:o}=r,{position:s,target:c}=a;return n.generateMedia({position:s,target:c,resolution:o})}return n.generateMedia(r)}});p("GENERATE_MEDIA",pi);const Wa=(r,e,{registry:t,dispatch:n})=>{const{id:i,entityType:a}=e,o=d=>{const v=ni({id:i,entityType:a,position:d.position,rotation:d.rotation,scale:d.scale});t.write(i,v),Vt(r),n("UPDATE_OBJECT",v)},s=()=>{n("SELECT_OBJECT",{id:i,entityType:a})},c=()=>{n("DESELECT_OBJECT",{id:i,entityType:a})},u=()=>{t.write(i,{id:i,entityType:a,loaded:!0}),n("MODEL_LOADED",{id:i})};r.addEventListener("object-transform",o),r.addEventListener("object-select",s),r.addEventListener("object-deselect",c);const f=r.getComponent(kt.ModelComponent);return f==null||f.addEventListener("object-load",u),()=>{r.removeEventListener("object-transform",o),r.removeEventListener("object-select",s),r.removeEventListener("object-deselect",c),f==null||f.removeEventListener("object-load",u)}},O=h.define({description:"Adds an object to the scene.",execute:async(r,{gateway:e,registry:t,dispatch:n})=>{const i=t.read(r.id);if(i)return i.node;r.parentId===void 0&&(r.parentId=null);const a=e.createEntity(r);if(!a){t.register(r);return}t.register(r,a,Wa(a,r,{registry:t,dispatch:n}));try{await e.applyEntity(a,r)}catch(o){throw t.unregister(r.id),e.removeEntity(r),o}return a}});p("ADD_OBJECT",O);const V=h.define({description:"Updates an existing object.",execute:async(r,{gateway:e,registry:t})=>{var i;const n=(i=t.read(r.id))==null?void 0:i.schema;if(!n)throw new Error("Object not found.");t.write(r.id,r),await e.updateEntity({...r,id:n.id,entityType:n.entityType})}});p("UPDATE_OBJECT",V);const X=h.define({description:"Attach an object to another object.",execute:(r,{gateway:e,registry:t})=>{const n=t.read(r.object.id);if(!n)throw new Error("Object not found.");const i=n.schema,a=n.node;if(!a)throw new Error("Object is not in the scene.");if(r.parent===null){e.root.attach(a),new V({id:i.id,parentId:null},{gateway:e,registry:t}).execute();return}if(r.object.id===r.parent.id){console.warn("Cannot attach object to itself.");return}const o=t.read(r.parent.id);if(!o){console.warn("Parent object not found.");return}const s=o.schema,c=o.node;if(!c){console.warn("Parent object is not in the scene.");return}c.attach(a),new V({id:i.id,parentId:s.id},{gateway:e,registry:t}).execute()}});p("SET_PARENT",X);const Jt=h.define({description:"Deletes an object from the scene.",execute:(r,{gateway:e,registry:t})=>{var i;const n=(i=t.read(r.id))==null?void 0:i.schema;if(!n)return!1;n.parentId&&new X({object:{id:n.id},parent:null},{gateway:e,registry:t}).execute(),n.entityType==="group"&&t.read().forEach(({schema:a})=>{a.parentId===n.id&&new V({id:a.id,parentId:null},{gateway:e,registry:t}).execute()}),Object.assign(r,n),t.unregister(r.id),e.removeEntity(n)}});p("DELETE_OBJECT",Jt);const vi=h.define({description:"Deselects an existing object.",execute:async(r,{getToolbox:e,registry:t})=>{const n=t.read(r.id);if(!n)throw new Error("Object not found.");const i=n.node;if(!i)throw new Error("Object is not in the scene.");if(!("isSelectable"in i))throw new Error("Object is not selectable.");(await e()).selectionState.applyDeselection()}});p("DESELECT_OBJECT",vi);const _i=h.define({description:"Places an object on top of an underlying object or the floor.",execute:(r,{registry:e})=>{const t=e.read(r.id);if(!t)throw new Error(`Object with id ${r.id} not registered.`);const n=t.node;if(!n)throw new Error(`Object with id ${r.id} is not in the scene.`);n.dropIt()}});p("DROP_IT",_i);const gi=h.define({description:"Retrieves all objects in the state.",execute:(r,{registry:e})=>new Map(e.read().map(({schema:t})=>[t.id,t]))});p("GET_ALL_OBJECTS",gi);const bi=h.define({description:"Returns a list of objects of given IDs.",execute:(r,{registry:e})=>r.ids.map(t=>{var n;return(n=e.read(t))==null?void 0:n.schema}).filter(t=>t!==void 0)});p("GET_OBJECTS",bi);const yi=h.define({description:"Is triggered when a model is loaded.",execute:(r,{registry:e})=>{var n;const t=(n=e.read(r.id))==null?void 0:n.schema;if(!t)throw new Error(`Model with id ${r.id} not found`);if(!Kt(t))throw new Error(`Model with id ${r.id} is not a ModelSchema`);t.loaded=!0}});p("MODEL_LOADED",yi);const mi=h.define({description:"Selects an existing object.",execute:async(r,{getToolbox:e,registry:t})=>{const n=t.read(r.id);if(!n)throw new Error("Object not found.");const i=n.node;if(!i)throw new Error("Object is not in the scene.");if(!("isSelectable"in i))throw new Error("Object is not selectable.");(await e()).selectionState.applySelection(i)}});p("SELECT_OBJECT",mi);const Ai=h.define({description:"Starts the render process.",execute:async(r,{gateway:e})=>e.startRendering()});p("START_RENDER",Ai);const Ci=h.define({description:"Exports the current scene to a blob and returns the URL.",execute:async(r,{gateway:e,getAssetExporter:t})=>t().then(n=>n.export(e.root,r.type))});p("EXPORT_SCENE",Ci);const Ei=h.define({description:"Set the background color of the scene.",execute:(r,{gateway:e})=>{e.applySceneSettings({backgroundColor:r.color})}});p("SET_BACKGROUND",Ei);const qi=h.define({description:"Updates scene properties.",execute:(r,{gateway:e})=>{e.applySceneSettings(r),Object.assign(r,e.readSceneSettings())}});p("UPDATE_SCENE",qi);const Ti=h.define({description:"Retrieves complete state data.",execute:(r,{controller:e,gateway:t,registry:n})=>{const i=t.readSceneSettings();return{name:i.name,mediaItem:null,backgroundColor:i.backgroundColor,floorEnabled:i.floorEnabled,floorColor:i.floorColor,userCamera:{position:e.object.owner.position.clone(),target:e.target.clone()},spotmarks:[],lights:n.read().map(a=>a.schema).filter(a=>a.entityType==="light"),objects:n.read().map(a=>a.schema).filter(a=>a.entityType==="model"),cameras:n.read().map(a=>a.schema).filter(a=>a.entityType==="camera"),primitives:n.read().map(a=>a.schema).filter(a=>a.entityType==="primitive"),groups:n.read().map(a=>a.schema).filter(a=>a.entityType==="group")}}});p("GET_STATE",Ti);const Si=h.define({description:"Applies complete state data to current dive instance.",execute:async(r,{gateway:e,controller:t,registry:n,dispatch:i})=>{n.read().forEach(({schema:u})=>{new Jt({id:u.id,entityType:u.entityType},{gateway:e,registry:n}).execute()}),e.applySceneSettings(r),r.userCamera!==void 0&&new $t({position:r.userCamera.position,target:r.userCamera.target},{controller:t}).execute();const a=[],o=[],s=[],c=[];r.groups!==void 0&&r.groups.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"group"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.lights!==void 0&&r.lights.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"light"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.cameras!==void 0&&r.cameras.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"camera"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.primitives!==void 0&&r.primitives.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"primitive"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.objects!==void 0&&r.objects.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"model"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.spotmarks!==void 0&&console.warn("SET_STATE: Spotmarks are not supported yet and will be ignored."),await Promise.all(c);for(const u of o)if(u.parentId)try{await new X({object:{id:u.id},parent:{id:u.parentId}},{gateway:e,registry:n}).execute()}catch(f){s.push({entity:u,reason:f})}return s.length>0&&console.warn(`SET_STATE: ${s.length} of ${c.length} entities could not be applied.`,s),a}});p("SET_STATE",Si);const wi=h.define({description:"Sets the gizmo's mode.",execute:async(r,{getToolbox:e})=>{(await e()).getTool("transform").setGizmoMode(r.mode)}});p("SET_GIZMO_MODE",wi);const Oi=h.define({description:"Sets the gizmo's unified scale mode.",execute:async(r,{getToolbox:e})=>{(await e()).getTool("transform").setGizmoScaleLinked(r)}});p("SET_GIZMO_SCALE_LINKED",Oi);const ji=h.define({description:"Sets the gizmo's visibility.",execute:async(r,{getToolbox:e})=>{(await e()).getTool("transform").setGizmoVisible(r)}});p("SET_GIZMO_VISIBILITY",ji);const Ri=h.define({description:"Activates a specific tool from the toolbox.",execute:async(r,{getToolbox:e})=>{(await e()).enableTool(r.tool)}});p("USE_TOOL",Ri);const I=class I{constructor(e,t){_(this,"engine");_(this,"controller");_(this,"gateway");_(this,"_mediaCreator");_(this,"_arSystem");_(this,"_assetExplorer");_(this,"_animationSystem");_(this,"_toolbox");_(this,"registry",new Ya);_(this,"listeners",new Map);this.engine=e,this.controller=t,this.gateway=new si(e),I.__instances.push(this)}getMediaCreator(){return this._mediaCreator??(this._mediaCreator=Promise.resolve().then(()=>require("../mediacreator/index.cjs")).then(e=>new e.MediaCreator(this.engine.mainView.renderer,this.engine.scene,this.controller))),this._mediaCreator}getARSystem(){return this._arSystem??(this._arSystem=Promise.resolve().then(()=>require("../ar/index.cjs")).then(e=>new e.ARSystem)),this._arSystem}getAssetExporter(){return this._assetExplorer??(this._assetExplorer=Promise.resolve().then(()=>require("../assetexporter/index.cjs")).then(e=>new e.AssetExporter)),this._assetExplorer}getAnimationSystem(){return this._animationSystem??(this._animationSystem=Promise.resolve().then(()=>require("../animation/index.cjs")).then(e=>new e.AnimationSystem)),this._animationSystem}getToolbox(){return this._toolbox??(this._toolbox=Promise.resolve().then(()=>require("../toolbox/index.cjs")).then(e=>new e.Toolbox(this.engine.scene,this.controller))),this._toolbox}destroyInstance(){var t,n;const e=I.__instances.indexOf(this);return e===-1?!1:(I.__instances.splice(e,1),this.registry.clear(),this.listeners.clear(),(t=this._toolbox)==null||t.then(i=>i.dispose()),(n=this._animationSystem)==null||n.then(i=>i.dispose()),this.gateway.dispose(),!0)}performAction(e,...t){const n=Un(e);if(!n)throw new Error(`Action ${e} is not defined.`);const i=this.getDependencies(),a=t[0],o=new n(a,i);try{const s=o.execute();return s&&typeof s=="object"&&"then"in s?s.then(c=>(this.dispatch(e,a),c)).catch(c=>{throw new Error(`Failed to execute ${e}`,{cause:c})}):(this.dispatch(e,a),s)}catch(s){throw new Error(`Failed to execute ${e}`,{cause:s})}}subscribe(e,t){return this.listeners.get(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const n=this.listeners.get(e);if(!n)return;const i=n.findIndex(a=>a===t);i!==-1&&n.splice(i,1)}}dispatch(e,t){const n=this.listeners.get(e);n&&n.forEach(i=>i(t))}getDependencies(){return{registry:this.registry,dispatch:(e,t)=>this.dispatch(e,t),gateway:this.gateway,controller:this.controller,getARSystem:()=>this.getARSystem(),getAssetExporter:()=>this.getAssetExporter(),getAnimationSystem:()=>this.getAnimationSystem(),getMediaCreator:()=>this.getMediaCreator(),getToolbox:()=>this.getToolbox()}}};_(I,"__instances",[]);let Ut=I;exports.AddObjectAction=O;exports.ComputeEncompassingViewAction=ui;exports.DeleteObjectAction=Jt;exports.DeselectObjectAction=vi;exports.DropItAction=_i;exports.EngineGateway=si;exports.ExportSceneAction=Ci;exports.GenerateMediaAction=pi;exports.GetAllObjectsAction=gi;exports.GetCameraTransformAction=fi;exports.GetObjectsAction=bi;exports.GetStateAction=Ti;exports.LaunchARAction=ci;exports.ModelLoadedAction=yi;exports.MoveCameraAction=di;exports.SelectObjectAction=mi;exports.SetBackgroundAction=Ei;exports.SetCameraLayerAction=li;exports.SetCameraTransformAction=$t;exports.SetGizmoModeAction=wi;exports.SetGizmoScaleLinkedAction=Oi;exports.SetGizmoVisibleAction=ji;exports.SetParentAction=X;exports.SetStateAction=Si;exports.StartRenderAction=Ai;exports.State=Ut;exports.UpdateObjectAction=V;exports.UpdateSceneAction=qi;exports.UseToolAction=Ri;exports.ZoomCameraAction=hi;exports.getActionClass=Un;exports.isCameraSchema=Z;exports.isGroupSchema=ii;exports.isLightSchema=ai;exports.isModelSchema=Kt;exports.isPrimitiveSchema=oi;exports.registerAction=p;
|
|
1
|
+
"use strict";var Ii=Object.defineProperty;var xi=(r,e,t)=>e in r?Ii(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _=(r,e,t)=>xi(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ft=require("three/webgpu"),A=require("../../chunks/FileTypes-B-MjfMGd.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const L=require("../../chunks/detachTransformControls-CZ2cd5hx.cjs"),kt=require("../../chunks/ModelComponent-Cmu0EX0r.cjs"),Vn={};function p(r,e){Vn[r]=e}function Un(r){return Vn[r]}var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var W,Xt;function Pi(){if(Xt)return W;Xt=1;function r(){this.__data__=[],this.size=0}return W=r,W}var ee,Yt;function N(){if(Yt)return ee;Yt=1;function r(e,t){return e===t||e!==e&&t!==t}return ee=r,ee}var te,Qt;function z(){if(Qt)return te;Qt=1;var r=N();function e(t,n){for(var i=t.length;i--;)if(r(t[i][0],n))return i;return-1}return te=e,te}var re,Wt;function Li(){if(Wt)return re;Wt=1;var r=z(),e=Array.prototype,t=e.splice;function n(i){var a=this.__data__,o=r(a,i);if(o<0)return!1;var s=a.length-1;return o==s?a.pop():t.call(a,o,1),--this.size,!0}return re=n,re}var ne,er;function Di(){if(er)return ne;er=1;var r=z();function e(t){var n=this.__data__,i=r(n,t);return i<0?void 0:n[i][1]}return ne=e,ne}var ie,tr;function Gi(){if(tr)return ie;tr=1;var r=z();function e(t){return r(this.__data__,t)>-1}return ie=e,ie}var ae,rr;function ki(){if(rr)return ae;rr=1;var r=z();function e(t,n){var i=this.__data__,a=r(i,t);return a<0?(++this.size,i.push([t,n])):i[a][1]=n,this}return ae=e,ae}var oe,nr;function H(){if(nr)return oe;nr=1;var r=Pi(),e=Li(),t=Di(),n=Gi(),i=ki();function a(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return a.prototype.clear=r,a.prototype.delete=e,a.prototype.get=t,a.prototype.has=n,a.prototype.set=i,oe=a,oe}var se,ir;function Vi(){if(ir)return se;ir=1;var r=H();function e(){this.__data__=new r,this.size=0}return se=e,se}var ce,ar;function Ui(){if(ar)return ce;ar=1;function r(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}return ce=r,ce}var ue,or;function Fi(){if(or)return ue;or=1;function r(e){return this.__data__.get(e)}return ue=r,ue}var fe,sr;function Bi(){if(sr)return fe;sr=1;function r(e){return this.__data__.has(e)}return fe=r,fe}var de,cr;function Fn(){if(cr)return de;cr=1;var r=typeof B=="object"&&B&&B.Object===Object&&B;return de=r,de}var le,ur;function x(){if(ur)return le;ur=1;var r=Fn(),e=typeof self=="object"&&self&&self.Object===Object&&self,t=r||e||Function("return this")();return le=t,le}var he,fr;function Bn(){if(fr)return he;fr=1;var r=x(),e=r.Symbol;return he=e,he}var pe,dr;function Ni(){if(dr)return pe;dr=1;var r=Bn(),e=Object.prototype,t=e.hasOwnProperty,n=e.toString,i=r?r.toStringTag:void 0;function a(o){var s=t.call(o,i),c=o[i];try{o[i]=void 0;var u=!0}catch{}var f=n.call(o);return u&&(s?o[i]=c:delete o[i]),f}return pe=a,pe}var ve,lr;function zi(){if(lr)return ve;lr=1;var r=Object.prototype,e=r.toString;function t(n){return e.call(n)}return ve=t,ve}var _e,hr;function K(){if(hr)return _e;hr=1;var r=Bn(),e=Ni(),t=zi(),n="[object Null]",i="[object Undefined]",a=r?r.toStringTag:void 0;function o(s){return s==null?s===void 0?i:n:a&&a in Object(s)?e(s):t(s)}return _e=o,_e}var ge,pr;function j(){if(pr)return ge;pr=1;function r(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}return ge=r,ge}var be,vr;function Bt(){if(vr)return be;vr=1;var r=K(),e=j(),t="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(s){if(!e(s))return!1;var c=r(s);return c==n||c==i||c==t||c==a}return be=o,be}var ye,_r;function Hi(){if(_r)return ye;_r=1;var r=x(),e=r["__core-js_shared__"];return ye=e,ye}var me,gr;function Ki(){if(gr)return me;gr=1;var r=Hi(),e=function(){var n=/[^.]+$/.exec(r&&r.keys&&r.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function t(n){return!!e&&e in n}return me=t,me}var Ae,br;function $i(){if(br)return Ae;br=1;var r=Function.prototype,e=r.toString;function t(n){if(n!=null){try{return e.call(n)}catch{}try{return n+""}catch{}}return""}return Ae=t,Ae}var Ce,yr;function Ji(){if(yr)return Ce;yr=1;var r=Bt(),e=Ki(),t=j(),n=$i(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,c=o.toString,u=s.hasOwnProperty,f=RegExp("^"+c.call(u).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(v){if(!t(v)||e(v))return!1;var m=r(v)?f:a;return m.test(n(v))}return Ce=d,Ce}var Ee,mr;function Zi(){if(mr)return Ee;mr=1;function r(e,t){return e==null?void 0:e[t]}return Ee=r,Ee}var qe,Ar;function Nt(){if(Ar)return qe;Ar=1;var r=Ji(),e=Zi();function t(n,i){var a=e(n,i);return r(a)?a:void 0}return qe=t,qe}var Te,Cr;function Nn(){if(Cr)return Te;Cr=1;var r=Nt(),e=x(),t=r(e,"Map");return Te=t,Te}var Se,Er;function $(){if(Er)return Se;Er=1;var r=Nt(),e=r(Object,"create");return Se=e,Se}var we,qr;function Xi(){if(qr)return we;qr=1;var r=$();function e(){this.__data__=r?r(null):{},this.size=0}return we=e,we}var Oe,Tr;function Yi(){if(Tr)return Oe;Tr=1;function r(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}return Oe=r,Oe}var je,Sr;function Qi(){if(Sr)return je;Sr=1;var r=$(),e="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function i(a){var o=this.__data__;if(r){var s=o[a];return s===e?void 0:s}return n.call(o,a)?o[a]:void 0}return je=i,je}var Re,wr;function Wi(){if(wr)return Re;wr=1;var r=$(),e=Object.prototype,t=e.hasOwnProperty;function n(i){var a=this.__data__;return r?a[i]!==void 0:t.call(a,i)}return Re=n,Re}var Ie,Or;function ea(){if(Or)return Ie;Or=1;var r=$(),e="__lodash_hash_undefined__";function t(n,i){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=r&&i===void 0?e:i,this}return Ie=t,Ie}var xe,jr;function ta(){if(jr)return xe;jr=1;var r=Xi(),e=Yi(),t=Qi(),n=Wi(),i=ea();function a(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return a.prototype.clear=r,a.prototype.delete=e,a.prototype.get=t,a.prototype.has=n,a.prototype.set=i,xe=a,xe}var Me,Rr;function ra(){if(Rr)return Me;Rr=1;var r=ta(),e=H(),t=Nn();function n(){this.size=0,this.__data__={hash:new r,map:new(t||e),string:new r}}return Me=n,Me}var Pe,Ir;function na(){if(Ir)return Pe;Ir=1;function r(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}return Pe=r,Pe}var Le,xr;function J(){if(xr)return Le;xr=1;var r=na();function e(t,n){var i=t.__data__;return r(n)?i[typeof n=="string"?"string":"hash"]:i.map}return Le=e,Le}var De,Mr;function ia(){if(Mr)return De;Mr=1;var r=J();function e(t){var n=r(this,t).delete(t);return this.size-=n?1:0,n}return De=e,De}var Ge,Pr;function aa(){if(Pr)return Ge;Pr=1;var r=J();function e(t){return r(this,t).get(t)}return Ge=e,Ge}var ke,Lr;function oa(){if(Lr)return ke;Lr=1;var r=J();function e(t){return r(this,t).has(t)}return ke=e,ke}var Ve,Dr;function sa(){if(Dr)return Ve;Dr=1;var r=J();function e(t,n){var i=r(this,t),a=i.size;return i.set(t,n),this.size+=i.size==a?0:1,this}return Ve=e,Ve}var Ue,Gr;function ca(){if(Gr)return Ue;Gr=1;var r=ra(),e=ia(),t=aa(),n=oa(),i=sa();function a(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return a.prototype.clear=r,a.prototype.delete=e,a.prototype.get=t,a.prototype.has=n,a.prototype.set=i,Ue=a,Ue}var Fe,kr;function ua(){if(kr)return Fe;kr=1;var r=H(),e=Nn(),t=ca(),n=200;function i(a,o){var s=this.__data__;if(s instanceof r){var c=s.__data__;if(!e||c.length<n-1)return c.push([a,o]),this.size=++s.size,this;s=this.__data__=new t(c)}return s.set(a,o),this.size=s.size,this}return Fe=i,Fe}var Be,Vr;function fa(){if(Vr)return Be;Vr=1;var r=H(),e=Vi(),t=Ui(),n=Fi(),i=Bi(),a=ua();function o(s){var c=this.__data__=new r(s);this.size=c.size}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=i,o.prototype.set=a,Be=o,Be}var Ne,Ur;function zn(){if(Ur)return Ne;Ur=1;var r=Nt(),e=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch{}}();return Ne=e,Ne}var ze,Fr;function zt(){if(Fr)return ze;Fr=1;var r=zn();function e(t,n,i){n=="__proto__"&&r?r(t,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[n]=i}return ze=e,ze}var He,Br;function Hn(){if(Br)return He;Br=1;var r=zt(),e=N();function t(n,i,a){(a!==void 0&&!e(n[i],a)||a===void 0&&!(i in n))&&r(n,i,a)}return He=t,He}var Ke,Nr;function da(){if(Nr)return Ke;Nr=1;function r(e){return function(t,n,i){for(var a=-1,o=Object(t),s=i(t),c=s.length;c--;){var u=s[e?c:++a];if(n(o[u],u,o)===!1)break}return t}}return Ke=r,Ke}var $e,zr;function la(){if(zr)return $e;zr=1;var r=da(),e=r();return $e=e,$e}var D={exports:{}};D.exports;var Hr;function ha(){return Hr||(Hr=1,function(r,e){var t=x(),n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,a=i&&i.exports===n,o=a?t.Buffer:void 0,s=o?o.allocUnsafe:void 0;function c(u,f){if(f)return u.slice();var d=u.length,v=s?s(d):new u.constructor(d);return u.copy(v),v}r.exports=c}(D,D.exports)),D.exports}var Je,Kr;function pa(){if(Kr)return Je;Kr=1;var r=x(),e=r.Uint8Array;return Je=e,Je}var Ze,$r;function va(){if($r)return Ze;$r=1;var r=pa();function e(t){var n=new t.constructor(t.byteLength);return new r(n).set(new r(t)),n}return Ze=e,Ze}var Xe,Jr;function _a(){if(Jr)return Xe;Jr=1;var r=va();function e(t,n){var i=n?r(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}return Xe=e,Xe}var Ye,Zr;function ga(){if(Zr)return Ye;Zr=1;function r(e,t){var n=-1,i=e.length;for(t||(t=Array(i));++n<i;)t[n]=e[n];return t}return Ye=r,Ye}var Qe,Xr;function ba(){if(Xr)return Qe;Xr=1;var r=j(),e=Object.create,t=function(){function n(){}return function(i){if(!r(i))return{};if(e)return e(i);n.prototype=i;var a=new n;return n.prototype=void 0,a}}();return Qe=t,Qe}var We,Yr;function ya(){if(Yr)return We;Yr=1;function r(e,t){return function(n){return e(t(n))}}return We=r,We}var et,Qr;function Kn(){if(Qr)return et;Qr=1;var r=ya(),e=r(Object.getPrototypeOf,Object);return et=e,et}var tt,Wr;function $n(){if(Wr)return tt;Wr=1;var r=Object.prototype;function e(t){var n=t&&t.constructor,i=typeof n=="function"&&n.prototype||r;return t===i}return tt=e,tt}var rt,en;function ma(){if(en)return rt;en=1;var r=ba(),e=Kn(),t=$n();function n(i){return typeof i.constructor=="function"&&!t(i)?r(e(i)):{}}return rt=n,rt}var nt,tn;function U(){if(tn)return nt;tn=1;function r(e){return e!=null&&typeof e=="object"}return nt=r,nt}var it,rn;function Aa(){if(rn)return it;rn=1;var r=K(),e=U(),t="[object Arguments]";function n(i){return e(i)&&r(i)==t}return it=n,it}var at,nn;function Jn(){if(nn)return at;nn=1;var r=Aa(),e=U(),t=Object.prototype,n=t.hasOwnProperty,i=t.propertyIsEnumerable,a=r(function(){return arguments}())?r:function(o){return e(o)&&n.call(o,"callee")&&!i.call(o,"callee")};return at=a,at}var ot,an;function Zn(){if(an)return ot;an=1;var r=Array.isArray;return ot=r,ot}var st,on;function Xn(){if(on)return st;on=1;var r=9007199254740991;function e(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=r}return st=e,st}var ct,sn;function Ht(){if(sn)return ct;sn=1;var r=Bt(),e=Xn();function t(n){return n!=null&&e(n.length)&&!r(n)}return ct=t,ct}var ut,cn;function Ca(){if(cn)return ut;cn=1;var r=Ht(),e=U();function t(n){return e(n)&&r(n)}return ut=t,ut}var G={exports:{}},ft,un;function Ea(){if(un)return ft;un=1;function r(){return!1}return ft=r,ft}G.exports;var fn;function Yn(){return fn||(fn=1,function(r,e){var t=x(),n=Ea(),i=e&&!e.nodeType&&e,a=i&&!0&&r&&!r.nodeType&&r,o=a&&a.exports===i,s=o?t.Buffer:void 0,c=s?s.isBuffer:void 0,u=c||n;r.exports=u}(G,G.exports)),G.exports}var dt,dn;function qa(){if(dn)return dt;dn=1;var r=K(),e=Kn(),t=U(),n="[object Object]",i=Function.prototype,a=Object.prototype,o=i.toString,s=a.hasOwnProperty,c=o.call(Object);function u(f){if(!t(f)||r(f)!=n)return!1;var d=e(f);if(d===null)return!0;var v=s.call(d,"constructor")&&d.constructor;return typeof v=="function"&&v instanceof v&&o.call(v)==c}return dt=u,dt}var lt,ln;function Ta(){if(ln)return lt;ln=1;var r=K(),e=Xn(),t=U(),n="[object Arguments]",i="[object Array]",a="[object Boolean]",o="[object Date]",s="[object Error]",c="[object Function]",u="[object Map]",f="[object Number]",d="[object Object]",v="[object RegExp]",m="[object Set]",E="[object String]",q="[object WeakMap]",T="[object ArrayBuffer]",R="[object DataView]",g="[object Float32Array]",Y="[object Float64Array]",Q="[object Int8Array]",M="[object Int16Array]",S="[object Int32Array]",C="[object Uint8Array]",b="[object Uint8ClampedArray]",F="[object Uint16Array]",y="[object Uint32Array]",l={};l[g]=l[Y]=l[Q]=l[M]=l[S]=l[C]=l[b]=l[F]=l[y]=!0,l[n]=l[i]=l[T]=l[a]=l[R]=l[o]=l[s]=l[c]=l[u]=l[f]=l[d]=l[v]=l[m]=l[E]=l[q]=!1;function P(w){return t(w)&&e(w.length)&&!!l[r(w)]}return lt=P,lt}var ht,hn;function Sa(){if(hn)return ht;hn=1;function r(e){return function(t){return e(t)}}return ht=r,ht}var k={exports:{}};k.exports;var pn;function wa(){return pn||(pn=1,function(r,e){var t=Fn(),n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,a=i&&i.exports===n,o=a&&t.process,s=function(){try{var c=i&&i.require&&i.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();r.exports=s}(k,k.exports)),k.exports}var pt,vn;function Qn(){if(vn)return pt;vn=1;var r=Ta(),e=Sa(),t=wa(),n=t&&t.isTypedArray,i=n?e(n):r;return pt=i,pt}var vt,_n;function Wn(){if(_n)return vt;_n=1;function r(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return vt=r,vt}var _t,gn;function Oa(){if(gn)return _t;gn=1;var r=zt(),e=N(),t=Object.prototype,n=t.hasOwnProperty;function i(a,o,s){var c=a[o];(!(n.call(a,o)&&e(c,s))||s===void 0&&!(o in a))&&r(a,o,s)}return _t=i,_t}var gt,bn;function ja(){if(bn)return gt;bn=1;var r=Oa(),e=zt();function t(n,i,a,o){var s=!a;a||(a={});for(var c=-1,u=i.length;++c<u;){var f=i[c],d=o?o(a[f],n[f],f,a,n):void 0;d===void 0&&(d=n[f]),s?e(a,f,d):r(a,f,d)}return a}return gt=t,gt}var bt,yn;function Ra(){if(yn)return bt;yn=1;function r(e,t){for(var n=-1,i=Array(e);++n<e;)i[n]=t(n);return i}return bt=r,bt}var yt,mn;function ei(){if(mn)return yt;mn=1;var r=9007199254740991,e=/^(?:0|[1-9]\d*)$/;function t(n,i){var a=typeof n;return i=i??r,!!i&&(a=="number"||a!="symbol"&&e.test(n))&&n>-1&&n%1==0&&n<i}return yt=t,yt}var mt,An;function Ia(){if(An)return mt;An=1;var r=Ra(),e=Jn(),t=Zn(),n=Yn(),i=ei(),a=Qn(),o=Object.prototype,s=o.hasOwnProperty;function c(u,f){var d=t(u),v=!d&&e(u),m=!d&&!v&&n(u),E=!d&&!v&&!m&&a(u),q=d||v||m||E,T=q?r(u.length,String):[],R=T.length;for(var g in u)(f||s.call(u,g))&&!(q&&(g=="length"||m&&(g=="offset"||g=="parent")||E&&(g=="buffer"||g=="byteLength"||g=="byteOffset")||i(g,R)))&&T.push(g);return T}return mt=c,mt}var At,Cn;function xa(){if(Cn)return At;Cn=1;function r(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}return At=r,At}var Ct,En;function Ma(){if(En)return Ct;En=1;var r=j(),e=$n(),t=xa(),n=Object.prototype,i=n.hasOwnProperty;function a(o){if(!r(o))return t(o);var s=e(o),c=[];for(var u in o)u=="constructor"&&(s||!i.call(o,u))||c.push(u);return c}return Ct=a,Ct}var Et,qn;function ti(){if(qn)return Et;qn=1;var r=Ia(),e=Ma(),t=Ht();function n(i){return t(i)?r(i,!0):e(i)}return Et=n,Et}var qt,Tn;function Pa(){if(Tn)return qt;Tn=1;var r=ja(),e=ti();function t(n){return r(n,e(n))}return qt=t,qt}var Tt,Sn;function La(){if(Sn)return Tt;Sn=1;var r=Hn(),e=ha(),t=_a(),n=ga(),i=ma(),a=Jn(),o=Zn(),s=Ca(),c=Yn(),u=Bt(),f=j(),d=qa(),v=Qn(),m=Wn(),E=Pa();function q(T,R,g,Y,Q,M,S){var C=m(T,g),b=m(R,g),F=S.get(b);if(F){r(T,g,F);return}var y=M?M(C,b,g+"",T,R,S):void 0,l=y===void 0;if(l){var P=o(b),w=!P&&c(b),Zt=!P&&!w&&v(b);y=b,P||w||Zt?o(C)?y=C:s(C)?y=n(C):w?(l=!1,y=e(b,!0)):Zt?(l=!1,y=t(b,!0)):y=[]:d(b)||a(b)?(y=C,a(C)?y=E(C):(!f(C)||u(C))&&(y=i(b))):l=!1}l&&(S.set(b,y),Q(y,b,Y,M,S),S.delete(b)),r(T,g,y)}return Tt=q,Tt}var St,wn;function Da(){if(wn)return St;wn=1;var r=fa(),e=Hn(),t=la(),n=La(),i=j(),a=ti(),o=Wn();function s(c,u,f,d,v){c!==u&&t(u,function(m,E){if(v||(v=new r),i(m))n(c,u,E,f,s,d,v);else{var q=d?d(o(c,E),m,E+"",c,u,v):void 0;q===void 0&&(q=m),e(c,E,q)}},a)}return St=s,St}var wt,On;function ri(){if(On)return wt;On=1;function r(e){return e}return wt=r,wt}var Ot,jn;function Ga(){if(jn)return Ot;jn=1;function r(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}return Ot=r,Ot}var jt,Rn;function ka(){if(Rn)return jt;Rn=1;var r=Ga(),e=Math.max;function t(n,i,a){return i=e(i===void 0?n.length-1:i,0),function(){for(var o=arguments,s=-1,c=e(o.length-i,0),u=Array(c);++s<c;)u[s]=o[i+s];s=-1;for(var f=Array(i+1);++s<i;)f[s]=o[s];return f[i]=a(u),r(n,this,f)}}return jt=t,jt}var Rt,In;function Va(){if(In)return Rt;In=1;function r(e){return function(){return e}}return Rt=r,Rt}var It,xn;function Ua(){if(xn)return It;xn=1;var r=Va(),e=zn(),t=ri(),n=e?function(i,a){return e(i,"toString",{configurable:!0,enumerable:!1,value:r(a),writable:!0})}:t;return It=n,It}var xt,Mn;function Fa(){if(Mn)return xt;Mn=1;var r=800,e=16,t=Date.now;function n(i){var a=0,o=0;return function(){var s=t(),c=e-(s-o);if(o=s,c>0){if(++a>=r)return arguments[0]}else a=0;return i.apply(void 0,arguments)}}return xt=n,xt}var Mt,Pn;function Ba(){if(Pn)return Mt;Pn=1;var r=Ua(),e=Fa(),t=e(r);return Mt=t,Mt}var Pt,Ln;function Na(){if(Ln)return Pt;Ln=1;var r=ri(),e=ka(),t=Ba();function n(i,a){return t(e(i,a,r),i+"")}return Pt=n,Pt}var Lt,Dn;function za(){if(Dn)return Lt;Dn=1;var r=N(),e=Ht(),t=ei(),n=j();function i(a,o,s){if(!n(s))return!1;var c=typeof o;return(c=="number"?e(s)&&t(o,s.length):c=="string"&&o in s)?r(s[o],a):!1}return Lt=i,Lt}var Dt,Gn;function Ha(){if(Gn)return Dt;Gn=1;var r=Na(),e=za();function t(n){return r(function(i,a){var o=-1,s=a.length,c=s>1?a[s-1]:void 0,u=s>2?a[2]:void 0;for(c=n.length>3&&typeof c=="function"?(s--,c):void 0,u&&e(a[0],a[1],u)&&(c=s<3?void 0:c,s=1),i=Object(i);++o<s;){var f=a[o];f&&n(i,f,o,c)}return i})}return Dt=t,Dt}var Gt,kn;function Ka(){if(kn)return Gt;kn=1;var r=Da(),e=Ha(),t=e(function(n,i,a){r(n,i,a)});return Gt=t,Gt}var $a=Ka();const Ja=Mi($a),Za=["position","rotation","scale","target"],Xa=r=>typeof r=="object"&&r!==null&&typeof r.x=="number"&&typeof r.y=="number"&&typeof r.z=="number",ni=r=>{const e={...r};return Za.forEach(t=>{const n=e[t];Xa(n)&&(e[t]={x:n.x,y:n.y,z:n.z})}),e};class Ya{constructor(){_(this,"_entities",new Map)}get size(){return this._entities.size}read(e){return e===void 0?Array.from(this._entities.values()):this._entities.get(e)}write(e,t){const n=this._entities.get(e);n&&Ja(n.schema,ni(t))}register(e,t,n){this._entities.set(e.id,{schema:e,node:t,unwatch:n})}unregister(e){var n;const t=this._entities.get(e);return t?((n=t.unwatch)==null||n.call(t),this._entities.delete(e)):!1}clear(){this._entities.forEach(e=>{var t;return(t=e.unwatch)==null?void 0:t.call(e)}),this._entities.clear()}}function ii(r){return r.entityType==="group"}function ai(r){return r.entityType==="light"}function Kt(r){return r.entityType==="model"}function Z(r){return r.entityType==="camera"}function oi(r){return r.entityType==="primitive"}const Qa=new Ft.Vector3,Vt=r=>{var t;const e=r.parent;!e||!("isDIVENode"in e)||(t=e.getComponent(A.MultiLineComponent))==null||t.setLineFor(r,Qa,r.position)};class si{constructor(e){_(this,"_engine");_(this,"_entities",new Map);this._engine=e}get root(){return this._engine.scene.root}findEntity(e){return this._entities.get(e.id)}createEntity(e){const t=this.findEntity(e);if(t)return console.warn(`EngineGateway.createEntity: Scene object with id ${e.id} already exists`),t;if(Z(e))return;const n=this._instantiate(e);return n.name=e.name,n.userData.id=e.id,this._entities.set(e.id,n),this.root.add(n),n}async applyEntity(e,t){await this._apply(e,t)}async updateEntity(e){const t=this.findEntity(e);if(!t){console.warn(`EngineGateway.updateEntity: Scene object with id ${e.id} does not exist`);return}await this._apply(t,e)}removeEntity(e){const t=this.findEntity(e);if(!t){console.warn(`EngineGateway.removeEntity: Object with id ${e.id} not found`);return}if(this._entities.delete(e.id),L.detachTransformControls(t),"isDIVENode"in t){const n=t.nodes;for(let i=n.length-1;i>=0;i--)this.root.attach(n[i])}A.disposeComponents(t),t.removeFromParent()}dispose(){this._entities.clear()}readSceneSettings(){const e=this._engine.scene;return{name:e.name,backgroundColor:"#"+e.background.getHexString(),gridEnabled:e.grid.visible,floorEnabled:e.root.floor.visible,floorColor:"#"+e.root.floor.material.color.getHexString()}}applySceneSettings(e){const t=this._engine.scene;e.name!==void 0&&(t.name=e.name),e.backgroundColor!==void 0&&t.setBackground(e.backgroundColor),e.gridEnabled!==void 0&&t.grid.setVisibility(e.gridEnabled),e.floorEnabled!==void 0&&t.root.floor.setVisibility(e.floorEnabled),e.floorColor!==void 0&&t.root.floor.setColor(e.floorColor)}startRendering(){return this._engine.startAsync()}registerTicker(e){this._engine.clock.hasTicker(e)||this._engine.clock.addTicker(e)}_instantiate(e){if(Kt(e)){const t=new A.DIVENode;return t.name="DIVEModel",t.userData.isDIVEModel=!0,t.addComponent(new kt.ModelComponent),t}if(oi(e)){const t=new A.DIVENode;return t.name="DIVEPrimitive",t.addComponent(new L.PrimitiveComponent),t}if(ii(e)){const t=new A.DIVENode;t.name="DIVEGroup";const n=t.addComponent(new A.MultiLineComponent);return t.addEventListener("childremoved",i=>n.removeLineFor(i.child)),t}if(ai(e))return this._instantiateLight(e);throw new Error(`EngineGateway.addEntity: Unknown entity type: ${e.entityType}`)}_instantiateLight(e){const t=new A.DIVENode;switch(t.name="DIVELight",e.type){case"scene":t.addComponent(new A.HemisphereLightComponent),t.addComponent(new A.DirectionalLightComponent);break;case"ambient":t.addComponent(new L.AmbientLightComponent);break;case"point":t.addComponent(new L.PointLightComponent);break;default:throw new Error(`EngineGateway.addEntity: Unknown light type: ${e.type}`)}return t}async _apply(e,t){if(t.entityType==="camera")return;const n=e;switch(t.entityType){case"light":this._applyLight(n,t);break;case"model":await this._applyModel(n,t);break;case"primitive":this._applyPrimitive(n,t);break;case"group":this._applyGroup(n,t);break;default:throw new Error(`EngineGateway.updateEntity: Unknown entity type: ${t.entityType}`)}t.name!==void 0&&(n.name=t.name),n.applyTransform(t),t.visible!==void 0&&n.setVisibility(t.visible),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId}),Vt(n)}_applyLight(e,t){e.getComponents(A.DIVELightComponent).forEach(i=>{t.intensity!==void 0&&i.setIntensity(t.intensity),t.enabled!==void 0&&i.setEnabled(t.enabled),t.color!==void 0&&i.setColor(new Ft.Color(t.color))})}async _applyModel(e,t){t.uri!==void 0&&t.uri!==e.userData.uri&&(await e.requireComponent(kt.ModelComponent).setFromURL(t.uri),e.userData.uri=t.uri),t.material!==void 0&&t.material!==null&&e.requireComponent(A.MeshComponent).setMaterial(t.material)}_applyPrimitive(e,t){t.geometry!==void 0&&t.geometry!==null&&e.requireComponent(L.PrimitiveComponent).setGeometry(t.geometry),t.material!==void 0&&t.material!==null&&e.requireComponent(A.MeshComponent).setMaterial(t.material)}_applyGroup(e,t){t.linksVisible!==void 0&&e.requireComponent(A.MultiLineComponent).setVisible(t.linksVisible)}_setParent(e){const t=this.findEntity(e);if(!t){console.warn(`EngineGateway._setParent: ${e.id} is not in the scene`);return}if(e.parentId===null){this.root.attach(t);return}const n=this.findEntity({id:e.parentId,entityType:e.entityType});if(!n){console.warn(`EngineGateway._setParent: Parent with id ${e.parentId} is not in the scene, ${e.id} stays at the root`);return}n.attach(t),Vt(t)}}class h{constructor(e,t){_(this,"_payload");_(this,"_dependencies");this._payload=e,this._dependencies=t}static define({description:e,execute:t}){return class extends h{constructor(i,a){super(i,a);_(this,"_description",e);_(this,"_payload");this._payload=i}execute(){return t(this._payload,this._dependencies)}}}}const ci=h.define({description:"Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)",execute:async(r,{getARSystem:e})=>e().then(t=>{t.launch(r.uri,r.options)})});p("LAUNCH_AR",ci);const ui=h.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(r,{gateway:e,controller:t})=>{const n=A.computeProductBounds(e.root).getBoundingSphere(new Ft.Sphere);return t.computeEncompassingView(n)}});p("COMPUTE_ENCOMPASSING_VIEW",ui);const fi=h.define({description:"Gets the current camera position and target.",execute:(r,{controller:e})=>({position:e.object.owner.position.clone(),target:e.target.clone()})});p("GET_CAMERA_TRANSFORM",fi);const di=h.define({description:"Moves the camera to a new position and target.",execute:async(r,{controller:e,registry:t,getAnimationSystem:n,gateway:i})=>{var u;const a=await n();let o={x:0,y:0,z:0},s={x:0,y:0,z:0};if("id"in r){const f=(u=t.read(r.id))==null?void 0:u.schema;if(!f)throw new Error(`CAMERA with id ${r.id} not registered.`);if(!Z(f))throw new Error(`Object with id ${r.id} is not a CAMERA. Object: ${f}`);o=f.position,s=f.target}else o=r.position,s=r.target;i.registerTicker(a),e.enabled=!0;const c=await a.fromTargets([{object:e.object.owner.position,to:o},{object:e.target,to:s}],r.duration,{easing:a.Easing.Quadratic.Out,onUpdate:()=>{e.object.lookAt(e.target)},onComplete:()=>{e.enabled=!r.locked}});return c.play(),{stop:()=>c.stop()}}});p("MOVE_CAMERA",di);const li=h.define({description:"Sets the camera layer to a certain layer.",execute:(r,{controller:e})=>{e.object.setCameraLayer(r.layer)}});p("SET_CAMERA_LAYER",li);const $t=h.define({description:"Sets the camera position and target.",execute:(r,{controller:e})=>{e.object.owner.position.copy(r.position),e.target.copy(r.target),e.update()}});p("SET_CAMERA_TRANSFORM",$t);const hi=h.define({description:"Zooms the camera in or out by a certain amount.",execute:(r,{controller:e})=>{r.direction==="IN"&&e.zoomIn(r.by),r.direction==="OUT"&&e.zoomOut(r.by)}});p("ZOOM_CAMERA",hi);const pi=h.define({description:"Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.",execute:async(r,{getMediaCreator:e,registry:t})=>{var i;const n=await e();if("id"in r){const a=(i=t.read(r.id))==null?void 0:i.schema;if(!a)throw new Error(`Object with id ${r.id} not registered.`);if(!Z(a))throw new Error(`Object with id ${r.id} is not a CAMERA. Object: ${a}`);const{resolution:o}=r,{position:s,target:c}=a;return n.generateMedia({position:s,target:c,resolution:o})}return n.generateMedia(r)}});p("GENERATE_MEDIA",pi);const Wa=(r,e,{registry:t,dispatch:n})=>{const{id:i,entityType:a}=e,o=d=>{const v=ni({id:i,entityType:a,position:d.position,rotation:d.rotation,scale:d.scale});t.write(i,v),Vt(r),n("UPDATE_OBJECT",v)},s=()=>{n("SELECT_OBJECT",{id:i,entityType:a})},c=()=>{n("DESELECT_OBJECT",{id:i,entityType:a})},u=()=>{t.write(i,{id:i,entityType:a,loaded:!0}),n("MODEL_LOADED",{id:i})};r.addEventListener("object-transform",o),r.addEventListener("object-select",s),r.addEventListener("object-deselect",c);const f=r.getComponent(kt.ModelComponent);return f==null||f.addEventListener("object-load",u),()=>{r.removeEventListener("object-transform",o),r.removeEventListener("object-select",s),r.removeEventListener("object-deselect",c),f==null||f.removeEventListener("object-load",u)}},O=h.define({description:"Adds an object to the scene.",execute:async(r,{gateway:e,registry:t,dispatch:n})=>{const i=t.read(r.id);if(i)return i.node;r.parentId===void 0&&(r.parentId=null);const a=e.createEntity(r);if(!a){t.register(r);return}t.register(r,a,Wa(a,r,{registry:t,dispatch:n}));try{await e.applyEntity(a,r)}catch(o){throw t.unregister(r.id),e.removeEntity(r),o}return a}});p("ADD_OBJECT",O);const V=h.define({description:"Updates an existing object.",execute:async(r,{gateway:e,registry:t})=>{var i;const n=(i=t.read(r.id))==null?void 0:i.schema;if(!n)throw new Error("Object not found.");t.write(r.id,r),await e.updateEntity({...r,id:n.id,entityType:n.entityType})}});p("UPDATE_OBJECT",V);const X=h.define({description:"Attach an object to another object.",execute:(r,{gateway:e,registry:t})=>{const n=t.read(r.object.id);if(!n)throw new Error("Object not found.");const i=n.schema,a=n.node;if(!a)throw new Error("Object is not in the scene.");if(r.parent===null){e.root.attach(a),new V({id:i.id,parentId:null},{gateway:e,registry:t}).execute();return}if(r.object.id===r.parent.id){console.warn("Cannot attach object to itself.");return}const o=t.read(r.parent.id);if(!o){console.warn("Parent object not found.");return}const s=o.schema,c=o.node;if(!c){console.warn("Parent object is not in the scene.");return}c.attach(a),new V({id:i.id,parentId:s.id},{gateway:e,registry:t}).execute()}});p("SET_PARENT",X);const Jt=h.define({description:"Deletes an object from the scene.",execute:(r,{gateway:e,registry:t})=>{var i;const n=(i=t.read(r.id))==null?void 0:i.schema;if(!n)return!1;n.parentId&&new X({object:{id:n.id},parent:null},{gateway:e,registry:t}).execute(),n.entityType==="group"&&t.read().forEach(({schema:a})=>{a.parentId===n.id&&new V({id:a.id,parentId:null},{gateway:e,registry:t}).execute()}),Object.assign(r,n),t.unregister(r.id),e.removeEntity(n)}});p("DELETE_OBJECT",Jt);const vi=h.define({description:"Deselects an existing object.",execute:async(r,{getToolbox:e,registry:t})=>{const n=t.read(r.id);if(!n)throw new Error("Object not found.");const i=n.node;if(!i)throw new Error("Object is not in the scene.");if(!("isSelectable"in i))throw new Error("Object is not selectable.");(await e()).selectionState.applyDeselection()}});p("DESELECT_OBJECT",vi);const _i=h.define({description:"Places an object on top of an underlying object or the floor.",execute:(r,{registry:e})=>{const t=e.read(r.id);if(!t)throw new Error(`Object with id ${r.id} not registered.`);const n=t.node;if(!n)throw new Error(`Object with id ${r.id} is not in the scene.`);n.dropIt()}});p("DROP_IT",_i);const gi=h.define({description:"Retrieves all objects in the state.",execute:(r,{registry:e})=>new Map(e.read().map(({schema:t})=>[t.id,t]))});p("GET_ALL_OBJECTS",gi);const bi=h.define({description:"Returns a list of objects of given IDs.",execute:(r,{registry:e})=>r.ids.map(t=>{var n;return(n=e.read(t))==null?void 0:n.schema}).filter(t=>t!==void 0)});p("GET_OBJECTS",bi);const yi=h.define({description:"Is triggered when a model is loaded.",execute:(r,{registry:e})=>{var n;const t=(n=e.read(r.id))==null?void 0:n.schema;if(!t)throw new Error(`Model with id ${r.id} not found`);if(!Kt(t))throw new Error(`Model with id ${r.id} is not a ModelSchema`);t.loaded=!0}});p("MODEL_LOADED",yi);const mi=h.define({description:"Selects an existing object.",execute:async(r,{getToolbox:e,registry:t})=>{const n=t.read(r.id);if(!n)throw new Error("Object not found.");const i=n.node;if(!i)throw new Error("Object is not in the scene.");if(!("isSelectable"in i))throw new Error("Object is not selectable.");(await e()).selectionState.applySelection(i)}});p("SELECT_OBJECT",mi);const Ai=h.define({description:"Starts the render process.",execute:async(r,{gateway:e})=>e.startRendering()});p("START_RENDER",Ai);const Ci=h.define({description:"Exports the current scene to a blob and returns the URL.",execute:async(r,{gateway:e,getAssetExporter:t})=>t().then(n=>n.export(e.root,r.type))});p("EXPORT_SCENE",Ci);const Ei=h.define({description:"Set the background color of the scene.",execute:(r,{gateway:e})=>{e.applySceneSettings({backgroundColor:r.color})}});p("SET_BACKGROUND",Ei);const qi=h.define({description:"Updates scene properties.",execute:(r,{gateway:e})=>{e.applySceneSettings(r),Object.assign(r,e.readSceneSettings())}});p("UPDATE_SCENE",qi);const Ti=h.define({description:"Retrieves complete state data.",execute:(r,{controller:e,gateway:t,registry:n})=>{const i=t.readSceneSettings();return{name:i.name,mediaItem:null,backgroundColor:i.backgroundColor,floorEnabled:i.floorEnabled,floorColor:i.floorColor,userCamera:{position:e.object.owner.position.clone(),target:e.target.clone()},spotmarks:[],lights:n.read().map(a=>a.schema).filter(a=>a.entityType==="light"),objects:n.read().map(a=>a.schema).filter(a=>a.entityType==="model"),cameras:n.read().map(a=>a.schema).filter(a=>a.entityType==="camera"),primitives:n.read().map(a=>a.schema).filter(a=>a.entityType==="primitive"),groups:n.read().map(a=>a.schema).filter(a=>a.entityType==="group")}}});p("GET_STATE",Ti);const Si=h.define({description:"Applies complete state data to current dive instance.",execute:async(r,{gateway:e,controller:t,registry:n,dispatch:i})=>{n.read().forEach(({schema:u})=>{new Jt({id:u.id,entityType:u.entityType},{gateway:e,registry:n}).execute()}),e.applySceneSettings(r),r.userCamera!==void 0&&new $t({position:r.userCamera.position,target:r.userCamera.target},{controller:t}).execute();const a=[],o=[],s=[],c=[];r.groups!==void 0&&r.groups.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"group"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.lights!==void 0&&r.lights.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"light"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.cameras!==void 0&&r.cameras.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"camera"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.primitives!==void 0&&r.primitives.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"primitive"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.objects!==void 0&&r.objects.forEach(u=>{const f={...u,locked:u.locked??!1,visible:u.visible??!0,entityType:"model"};c.push(new O({...f,parentId:null},{gateway:e,registry:n,dispatch:i}).execute().then(d=>{o.push(f),d!==void 0&&a.push(d)}).catch(d=>{s.push({entity:f,reason:d})}))}),r.spotmarks!==void 0&&console.warn("SET_STATE: Spotmarks are not supported yet and will be ignored."),await Promise.all(c);for(const u of o)if(u.parentId)try{await new X({object:{id:u.id},parent:{id:u.parentId}},{gateway:e,registry:n}).execute()}catch(f){s.push({entity:u,reason:f})}return s.length>0&&console.warn(`SET_STATE: ${s.length} of ${c.length} entities could not be applied.`,s),a}});p("SET_STATE",Si);const wi=h.define({description:"Sets the gizmo's mode.",execute:async(r,{getToolbox:e})=>{(await e()).getTool("transform").setGizmoMode(r.mode)}});p("SET_GIZMO_MODE",wi);const Oi=h.define({description:"Sets the gizmo's unified scale mode.",execute:async(r,{getToolbox:e})=>{(await e()).getTool("transform").setGizmoScaleLinked(r)}});p("SET_GIZMO_SCALE_LINKED",Oi);const ji=h.define({description:"Sets the gizmo's visibility.",execute:async(r,{getToolbox:e})=>{(await e()).getTool("transform").setGizmoVisible(r)}});p("SET_GIZMO_VISIBILITY",ji);const Ri=h.define({description:"Activates a specific tool from the toolbox.",execute:async(r,{getToolbox:e})=>{(await e()).enableTool(r.tool)}});p("USE_TOOL",Ri);const I=class I{constructor(e,t){_(this,"engine");_(this,"controller");_(this,"gateway");_(this,"_mediaCreator");_(this,"_arSystem");_(this,"_assetExplorer");_(this,"_animationSystem");_(this,"_toolbox");_(this,"registry",new Ya);_(this,"listeners",new Map);this.engine=e,this.controller=t,this.gateway=new si(e),I.__instances.push(this)}getMediaCreator(){return this._mediaCreator??(this._mediaCreator=Promise.resolve().then(()=>require("../mediacreator/index.cjs")).then(e=>new e.MediaCreator(this.engine.mainView.renderer,this.engine.scene,this.controller))),this._mediaCreator}getARSystem(){return this._arSystem??(this._arSystem=Promise.resolve().then(()=>require("../ar/index.cjs")).then(e=>new e.ARSystem)),this._arSystem}getAssetExporter(){return this._assetExplorer??(this._assetExplorer=Promise.resolve().then(()=>require("../assetexporter/index.cjs")).then(e=>new e.AssetExporter)),this._assetExplorer}getAnimationSystem(){return this._animationSystem??(this._animationSystem=Promise.resolve().then(()=>require("../animation/index.cjs")).then(e=>new e.AnimationSystem)),this._animationSystem}getToolbox(){return this._toolbox??(this._toolbox=Promise.resolve().then(()=>require("../toolbox/index.cjs")).then(e=>new e.Toolbox(this.engine.scene,this.controller))),this._toolbox}destroyInstance(){var t,n;const e=I.__instances.indexOf(this);return e===-1?!1:(I.__instances.splice(e,1),this.registry.clear(),this.listeners.clear(),(t=this._toolbox)==null||t.then(i=>i.dispose()),(n=this._animationSystem)==null||n.then(i=>i.dispose()),this.gateway.dispose(),!0)}performAction(e,...t){const n=Un(e);if(!n)throw new Error(`Action ${e} is not defined.`);const i=this.getDependencies(),a=t[0],o=new n(a,i);try{const s=o.execute();return s&&typeof s=="object"&&"then"in s?s.then(c=>(this.dispatch(e,a),c)).catch(c=>{throw new Error(`Failed to execute ${e}`,{cause:c})}):(this.dispatch(e,a),s)}catch(s){throw new Error(`Failed to execute ${e}`,{cause:s})}}subscribe(e,t){return this.listeners.get(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const n=this.listeners.get(e);if(!n)return;const i=n.findIndex(a=>a===t);i!==-1&&n.splice(i,1)}}dispatch(e,t){const n=this.listeners.get(e);n&&n.forEach(i=>i(t))}getDependencies(){return{registry:this.registry,dispatch:(e,t)=>this.dispatch(e,t),gateway:this.gateway,controller:this.controller,getARSystem:()=>this.getARSystem(),getAssetExporter:()=>this.getAssetExporter(),getAnimationSystem:()=>this.getAnimationSystem(),getMediaCreator:()=>this.getMediaCreator(),getToolbox:()=>this.getToolbox()}}};_(I,"__instances",[]);let Ut=I;exports.AddObjectAction=O;exports.ComputeEncompassingViewAction=ui;exports.DeleteObjectAction=Jt;exports.DeselectObjectAction=vi;exports.DropItAction=_i;exports.EngineGateway=si;exports.ExportSceneAction=Ci;exports.GenerateMediaAction=pi;exports.GetAllObjectsAction=gi;exports.GetCameraTransformAction=fi;exports.GetObjectsAction=bi;exports.GetStateAction=Ti;exports.LaunchARAction=ci;exports.ModelLoadedAction=yi;exports.MoveCameraAction=di;exports.SelectObjectAction=mi;exports.SetBackgroundAction=Ei;exports.SetCameraLayerAction=li;exports.SetCameraTransformAction=$t;exports.SetGizmoModeAction=wi;exports.SetGizmoScaleLinkedAction=Oi;exports.SetGizmoVisibleAction=ji;exports.SetParentAction=X;exports.SetStateAction=Si;exports.StartRenderAction=Ai;exports.State=Ut;exports.UpdateObjectAction=V;exports.UpdateSceneAction=qi;exports.UseToolAction=Ri;exports.ZoomCameraAction=hi;exports.getActionClass=Un;exports.isCameraSchema=Z;exports.isGroupSchema=ii;exports.isLightSchema=ai;exports.isModelSchema=Kt;exports.isPrimitiveSchema=oi;exports.registerAction=p;
|
|
@@ -2,11 +2,11 @@ var ii = Object.defineProperty;
|
|
|
2
2
|
var ai = (r, e, t) => e in r ? ii(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var _ = (r, e, t) => ai(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { Vector3 as si, Color as oi, Sphere as ui } from "three/webgpu";
|
|
5
|
-
import { A as Lt, e as ci, d as V, H as fi, w as di, f as hi, M as zt, C as li } from "../../chunks/FileTypes-
|
|
5
|
+
import { A as Lt, e as ci, d as V, H as fi, w as di, f as hi, M as zt, C as li } from "../../chunks/FileTypes-D3Dxr2dj.mjs";
|
|
6
6
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
7
7
|
import "three/tsl";
|
|
8
|
-
import { d as pi, a as Kt, P as vi, A as _i } from "../../chunks/detachTransformControls-
|
|
9
|
-
import { M as Dt } from "../../chunks/ModelComponent-
|
|
8
|
+
import { d as pi, a as Kt, P as vi, A as _i } from "../../chunks/detachTransformControls-B4iRF1bw.mjs";
|
|
9
|
+
import { M as Dt } from "../../chunks/ModelComponent-WA0kLOEY.mjs";
|
|
10
10
|
const Gn = {};
|
|
11
11
|
function v(r, e) {
|
|
12
12
|
Gn[r] = e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var S=(a,t,e)=>t in a?y(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var r=(a,t,e)=>S(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("three/webgpu");require("../../chunks/FileTypes-gD_1MonW.cjs");const _=require("../../chunks/contributesToBounds-C1mva__U.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const h=require("../../chunks/isVisibleInHierarchy-D9JcLqR5.cjs"),T=require("three/examples/jsm/controls/TransformControls.js"),d=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class v{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){this._select(t,!0)}applySelection(t){this._select(t,!1)}deselect(){this._deselect(!0)}applyDeselection(){this._deselect(!1)}_select(t,e){var i,o;if(this._selected===t)return;const s=this._selected;this._selected=null,(i=s==null?void 0:s.onDeselect)==null||i.call(s),this._selected=t,e&&((o=t.onSelect)==null||o.call(t)),this.notifyListeners()}_deselect(t){var s;const e=this._selected;e&&(this._selected=null,t&&((s=e.onDeselect)==null||s.call(e)),this.notifyListeners())}onChange(t){this._listeners.add(t)}offChange(t){this._listeners.delete(t)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const t of this._listeners)t(this._selected)}}class b{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var t,e;this._hovered&&((e=(t=this._hovered).onPointerLeave)==null||e.call(t),this._hovered=null)}onPointerMove(t){var i,o,n,c,p,f,m;if(t.pointerPrimaryDown||t.pointerMiddleDown||t.pointerSecondaryDown)return;const e=t.intersects[0],s=h.findInterface(e==null?void 0:e.object,"isHoverable");if(e&&s){if(!this._hovered){(i=s.onPointerEnter)==null||i.call(s,e),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(n=(o=this._hovered).onPointerLeave)==null||n.call(o),(c=s.onPointerEnter)==null||c.call(s,e),this._hovered=s;return}(p=s.onPointerOver)==null||p.call(s,e);return}this._hovered&&((m=(f=this._hovered).onPointerLeave)==null||m.call(f),this._hovered=null)}}const P=a=>a.name==="select";class g{constructor(t){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=t}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(t){const e=t.entityIntersects[0],s=h.findInterface(e==null?void 0:e.object,"isSelectable");if(!e||!s){this._selectionState.deselect();return}const i=this._selectionState.selected;i&&i.uuid===s.uuid||this._selectionState.select(s)}select(t){this._selectionState.select(t)}deselect(){this._selectionState.deselect()}}const w=a=>a.name==="transform";class u extends l.EventDispatcher{constructor(e,s,i){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_gizmoHelper");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=e,this._controller=s,this._selectionState=i,this._gizmo=this.initGizmo(),this._gizmoHelper=this._gizmo.getHelper(),this._scene.add(this._gizmoHelper),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const e=this._selectionState.selected;e&&this.attachGizmo(e)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(e){if(this._gizmo.dragging)return!0;if(e.pointerPrimaryDown||e.pointerMiddleDown||e.pointerSecondaryDown)return;if(e.intersects.some(i=>this.isGizmoChild(i.object)))return!0}setGizmoMode(e){this._gizmo.mode=e}setGizmoVisible(e){this._gizmoVisible=e;const s=this._scene.children.includes(this._gizmoHelper);e&&!s?(this._scene.add(this._gizmoHelper),this._gizmo.getRaycaster().layers.enableAll()):!e&&s&&(this._scene.remove(this._gizmoHelper),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(e){this._scaleLinked=e}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmoHelper),this._gizmo.dispose()}onSelectionChange(e){e&&h.implementsInterface(e,"isMovable")?this.attachGizmo(e):this._gizmo.detach()}attachGizmo(e){h.implementsInterface(e,"isMovable")&&(this._gizmo.attach(e),this.setGizmoVisible(e.visible&&this._gizmoVisible))}isGizmoChild(e){let s=e;for(;s;){if(s===this._gizmoHelper)return!0;s=s.parent}return!1}initGizmo(){const e=new T.TransformControls(this._controller.object.camera,this._controller.domElement);e.mode="translate";const s=e.getHelper();return s.name="TransformControlsRoot",s.traverse(i=>{if(!("isMesh"in i))return;const o=i.material;i.name==="X"&&o.color.set(d.AxesColorRed),i.name==="Y"&&o.color.set(d.AxesColorGreen),i.name==="Z"&&o.color.set(d.AxesColorBlue),i.name==="XY"&&o.color.set(d.AxesColorBlue),i.name==="YZ"&&o.color.set(d.AxesColorRed),i.name==="XZ"&&o.color.set(d.AxesColorGreen)}),e.addEventListener("mouseDown",()=>{var i,o;this._controller.enabled=!1,h.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveStart)==null||o.call(i))}),e.addEventListener("objectChange",()=>{var i,o;if(h.implementsInterface(e.object,"isMovable")){if((o=(i=e.object).onMove)==null||o.call(i),this._scaleLinked&&e.object){const n=e.object.scale,c=(n.x+n.y+n.z)/3;e.object.scale.set(c,c,c)}switch(this.dispatchEvent({type:"object-change",object:e.object}),e.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:e.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:e.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:e.object});break}}}),e.addEventListener("mouseUp",()=>{var i,o;this._controller.enabled=!0,h.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveEnd)==null||o.call(i))}),e}}const E=.001;class D{constructor(t){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new l.Vector3);r(this,"_dragCurrent",new l.Vector3);r(this,"_dragEnd",new l.Vector3);r(this,"_dragDelta",new l.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new l.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(t){var e;t.pointerPrimaryDown&&(this._draggable=h.findInterface((e=t.intersects[0])==null?void 0:e.object,"isDraggable")||null)}onPointerMove(t){if(t.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(t.pointer,this._controller.object.camera),this._dragging||t.lastPointerDown.distanceTo(t.pointer)>E&&this.startDrag(t),this._dragging))return this.updateDrag(t),!0}onPointerUp(t){this._dragging&&(this._raycaster.setFromCamera(t.pointer,this._controller.object.camera),this.endDrag()),this._draggable=null}setDragRaycastTargets(t){this._dragRaycastTargets=t}startDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragStart.copy(e.point),this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.set(0,0,0),(i=(s=this._draggable)==null?void 0:s.onDragStart)==null||i.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(i=(s=this._draggable)==null?void 0:s.onDrag)==null||i.call(s,this.createDragEvent()))}endDrag(){var e,s;const t=this.createDragEvent();(s=(e=this._draggable)==null?void 0:e.onDragEnd)==null||s.call(e,t),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(t){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:t.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const C=.001;class z{constructor(t,e){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=t,this._controller=e,this._canvas=e.domElement,this._selectionState=new v,this._raycaster=new l.Raycaster,this._pointer=new l.Vector2,this._lastPointerDown=new l.Vector2,this._tools=new Map([["hover",new b],["select",new g(this._selectionState)],["transform",new u(t,e,this._selectionState)],["drag",new D(e)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(t){var s;const e=this._tools.get(t);e&&(this._activeTools.has(t)||(this._activeTools.set(t,e),this.updateSortedTools(),(s=e.onActivate)==null||s.call(e)))}disableTool(t){var s;const e=this._activeTools.get(t);e&&((s=e.onDeactivate)==null||s.call(e),this._activeTools.delete(t),this.updateSortedTools())}isToolEnabled(t){return this._activeTools.has(t)}getTool(t){return this._tools.get(t)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var t;for(const e of this._activeTools.values())(t=e.onDeactivate)==null||t.call(e);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(t){var s;this.updatePointer(t);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerMove)==null?void 0:s.call(i,e))break}onPointerDown(t){var s;this.updatePointerState(t,!0),this.updatePointer(t),this._lastPointerDown.copy(this._pointer);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerDown)==null?void 0:s.call(i,e))break}onPointerUp(t){var i,o;this.updatePointer(t);const e=this.createPointerContext(t),s=!this.pointerWasDragged();for(const n of this._sortedActiveTools)if((i=n.onPointerUp)==null?void 0:i.call(n,e))break;if(s){for(const n of this._sortedActiveTools)if((o=n.onClick)==null?void 0:o.call(n,e))break}this.updatePointerState(t,!1)}onWheel(t){var s;const e=this.createWheelContext(t);for(const i of this._sortedActiveTools)if((s=i.onWheel)==null?void 0:s.call(i,e))break}createPointerContext(t){return Object.assign(this.createLazyIntersects(),{event:t,pointer:this._pointer.clone(),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()})}createWheelContext(t){return Object.assign(this.createLazyIntersects(),{event:t,pointer:this._pointer.clone()})}createLazyIntersects(){const t=()=>s??(s=this.raycast()),e=c=>this.filterIntersectsByLayer(t(),c);let s,i,o,n;return{get intersects(){return t()},get modelIntersects(){return i??(i=e(_.PRODUCT_LAYER_MASK))},get entityIntersects(){return o??(o=e(_.PRODUCT_LAYER_MASK|_.PROXY_LAYER_MASK))},get uiIntersects(){return n??(n=e(_.UI_LAYER_MASK))}}}updatePointer(t){this._pointer.x=t.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(t.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object.camera)}updatePointerState(t,e){switch(t.button){case 0:this._pointerPrimaryDown=e;break;case 1:this._pointerMiddleDown=e;break;case 2:this._pointerSecondaryDown=e;break}}raycast(){return this._raycaster.layers.mask=_.DEFAULT_LAYER_MASK|_.PRODUCT_LAYER_MASK|_.UI_LAYER_MASK|_.PROXY_LAYER_MASK,this._raycaster.intersectObjects(this._scene.children,!0).filter(t=>h.isVisibleInHierarchy(t.object))}filterIntersectsByLayer(t,e){return t.filter(s=>(s.object.layers.mask&e)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((t,e)=>t.priority-e.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>C}}exports.DIVESelectTool=g;exports.DIVETransformTool=u;exports.DragTool=D;exports.HoverTool=b;exports.SelectTool=g;exports.SelectionState=v;exports.Toolbox=z;exports.TransformTool=u;exports.isSelectTool=P;exports.isTransformTool=w;
|
|
1
|
+
"use strict";var y=Object.defineProperty;var S=(a,t,e)=>t in a?y(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var r=(a,t,e)=>S(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("three/webgpu");require("../../chunks/FileTypes-B-MjfMGd.cjs");const _=require("../../chunks/contributesToBounds-C1mva__U.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const h=require("../../chunks/isVisibleInHierarchy-D9JcLqR5.cjs"),T=require("three/examples/jsm/controls/TransformControls.js"),d=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class v{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){this._select(t,!0)}applySelection(t){this._select(t,!1)}deselect(){this._deselect(!0)}applyDeselection(){this._deselect(!1)}_select(t,e){var i,o;if(this._selected===t)return;const s=this._selected;this._selected=null,(i=s==null?void 0:s.onDeselect)==null||i.call(s),this._selected=t,e&&((o=t.onSelect)==null||o.call(t)),this.notifyListeners()}_deselect(t){var s;const e=this._selected;e&&(this._selected=null,t&&((s=e.onDeselect)==null||s.call(e)),this.notifyListeners())}onChange(t){this._listeners.add(t)}offChange(t){this._listeners.delete(t)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const t of this._listeners)t(this._selected)}}class b{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var t,e;this._hovered&&((e=(t=this._hovered).onPointerLeave)==null||e.call(t),this._hovered=null)}onPointerMove(t){var i,o,n,c,p,f,m;if(t.pointerPrimaryDown||t.pointerMiddleDown||t.pointerSecondaryDown)return;const e=t.intersects[0],s=h.findInterface(e==null?void 0:e.object,"isHoverable");if(e&&s){if(!this._hovered){(i=s.onPointerEnter)==null||i.call(s,e),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(n=(o=this._hovered).onPointerLeave)==null||n.call(o),(c=s.onPointerEnter)==null||c.call(s,e),this._hovered=s;return}(p=s.onPointerOver)==null||p.call(s,e);return}this._hovered&&((m=(f=this._hovered).onPointerLeave)==null||m.call(f),this._hovered=null)}}const P=a=>a.name==="select";class g{constructor(t){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=t}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(t){const e=t.entityIntersects[0],s=h.findInterface(e==null?void 0:e.object,"isSelectable");if(!e||!s){this._selectionState.deselect();return}const i=this._selectionState.selected;i&&i.uuid===s.uuid||this._selectionState.select(s)}select(t){this._selectionState.select(t)}deselect(){this._selectionState.deselect()}}const w=a=>a.name==="transform";class u extends l.EventDispatcher{constructor(e,s,i){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_gizmoHelper");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=e,this._controller=s,this._selectionState=i,this._gizmo=this.initGizmo(),this._gizmoHelper=this._gizmo.getHelper(),this._scene.add(this._gizmoHelper),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const e=this._selectionState.selected;e&&this.attachGizmo(e)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(e){if(this._gizmo.dragging)return!0;if(e.pointerPrimaryDown||e.pointerMiddleDown||e.pointerSecondaryDown)return;if(e.intersects.some(i=>this.isGizmoChild(i.object)))return!0}setGizmoMode(e){this._gizmo.mode=e}setGizmoVisible(e){this._gizmoVisible=e;const s=this._scene.children.includes(this._gizmoHelper);e&&!s?(this._scene.add(this._gizmoHelper),this._gizmo.getRaycaster().layers.enableAll()):!e&&s&&(this._scene.remove(this._gizmoHelper),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(e){this._scaleLinked=e}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmoHelper),this._gizmo.dispose()}onSelectionChange(e){e&&h.implementsInterface(e,"isMovable")?this.attachGizmo(e):this._gizmo.detach()}attachGizmo(e){h.implementsInterface(e,"isMovable")&&(this._gizmo.attach(e),this.setGizmoVisible(e.visible&&this._gizmoVisible))}isGizmoChild(e){let s=e;for(;s;){if(s===this._gizmoHelper)return!0;s=s.parent}return!1}initGizmo(){const e=new T.TransformControls(this._controller.object.camera,this._controller.domElement);e.mode="translate";const s=e.getHelper();return s.name="TransformControlsRoot",s.traverse(i=>{if(!("isMesh"in i))return;const o=i.material;i.name==="X"&&o.color.set(d.AxesColorRed),i.name==="Y"&&o.color.set(d.AxesColorGreen),i.name==="Z"&&o.color.set(d.AxesColorBlue),i.name==="XY"&&o.color.set(d.AxesColorBlue),i.name==="YZ"&&o.color.set(d.AxesColorRed),i.name==="XZ"&&o.color.set(d.AxesColorGreen)}),e.addEventListener("mouseDown",()=>{var i,o;this._controller.enabled=!1,h.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveStart)==null||o.call(i))}),e.addEventListener("objectChange",()=>{var i,o;if(h.implementsInterface(e.object,"isMovable")){if((o=(i=e.object).onMove)==null||o.call(i),this._scaleLinked&&e.object){const n=e.object.scale,c=(n.x+n.y+n.z)/3;e.object.scale.set(c,c,c)}switch(this.dispatchEvent({type:"object-change",object:e.object}),e.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:e.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:e.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:e.object});break}}}),e.addEventListener("mouseUp",()=>{var i,o;this._controller.enabled=!0,h.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveEnd)==null||o.call(i))}),e}}const E=.001;class D{constructor(t){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new l.Vector3);r(this,"_dragCurrent",new l.Vector3);r(this,"_dragEnd",new l.Vector3);r(this,"_dragDelta",new l.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new l.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(t){var e;t.pointerPrimaryDown&&(this._draggable=h.findInterface((e=t.intersects[0])==null?void 0:e.object,"isDraggable")||null)}onPointerMove(t){if(t.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(t.pointer,this._controller.object.camera),this._dragging||t.lastPointerDown.distanceTo(t.pointer)>E&&this.startDrag(t),this._dragging))return this.updateDrag(t),!0}onPointerUp(t){this._dragging&&(this._raycaster.setFromCamera(t.pointer,this._controller.object.camera),this.endDrag()),this._draggable=null}setDragRaycastTargets(t){this._dragRaycastTargets=t}startDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragStart.copy(e.point),this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.set(0,0,0),(i=(s=this._draggable)==null?void 0:s.onDragStart)==null||i.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(i=(s=this._draggable)==null?void 0:s.onDrag)==null||i.call(s,this.createDragEvent()))}endDrag(){var e,s;const t=this.createDragEvent();(s=(e=this._draggable)==null?void 0:e.onDragEnd)==null||s.call(e,t),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(t){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:t.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const C=.001;class z{constructor(t,e){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=t,this._controller=e,this._canvas=e.domElement,this._selectionState=new v,this._raycaster=new l.Raycaster,this._pointer=new l.Vector2,this._lastPointerDown=new l.Vector2,this._tools=new Map([["hover",new b],["select",new g(this._selectionState)],["transform",new u(t,e,this._selectionState)],["drag",new D(e)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(t){var s;const e=this._tools.get(t);e&&(this._activeTools.has(t)||(this._activeTools.set(t,e),this.updateSortedTools(),(s=e.onActivate)==null||s.call(e)))}disableTool(t){var s;const e=this._activeTools.get(t);e&&((s=e.onDeactivate)==null||s.call(e),this._activeTools.delete(t),this.updateSortedTools())}isToolEnabled(t){return this._activeTools.has(t)}getTool(t){return this._tools.get(t)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var t;for(const e of this._activeTools.values())(t=e.onDeactivate)==null||t.call(e);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(t){var s;this.updatePointer(t);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerMove)==null?void 0:s.call(i,e))break}onPointerDown(t){var s;this.updatePointerState(t,!0),this.updatePointer(t),this._lastPointerDown.copy(this._pointer);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerDown)==null?void 0:s.call(i,e))break}onPointerUp(t){var i,o;this.updatePointer(t);const e=this.createPointerContext(t),s=!this.pointerWasDragged();for(const n of this._sortedActiveTools)if((i=n.onPointerUp)==null?void 0:i.call(n,e))break;if(s){for(const n of this._sortedActiveTools)if((o=n.onClick)==null?void 0:o.call(n,e))break}this.updatePointerState(t,!1)}onWheel(t){var s;const e=this.createWheelContext(t);for(const i of this._sortedActiveTools)if((s=i.onWheel)==null?void 0:s.call(i,e))break}createPointerContext(t){return Object.assign(this.createLazyIntersects(),{event:t,pointer:this._pointer.clone(),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()})}createWheelContext(t){return Object.assign(this.createLazyIntersects(),{event:t,pointer:this._pointer.clone()})}createLazyIntersects(){const t=()=>s??(s=this.raycast()),e=c=>this.filterIntersectsByLayer(t(),c);let s,i,o,n;return{get intersects(){return t()},get modelIntersects(){return i??(i=e(_.PRODUCT_LAYER_MASK))},get entityIntersects(){return o??(o=e(_.PRODUCT_LAYER_MASK|_.PROXY_LAYER_MASK))},get uiIntersects(){return n??(n=e(_.UI_LAYER_MASK))}}}updatePointer(t){this._pointer.x=t.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(t.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object.camera)}updatePointerState(t,e){switch(t.button){case 0:this._pointerPrimaryDown=e;break;case 1:this._pointerMiddleDown=e;break;case 2:this._pointerSecondaryDown=e;break}}raycast(){return this._raycaster.layers.mask=_.DEFAULT_LAYER_MASK|_.PRODUCT_LAYER_MASK|_.UI_LAYER_MASK|_.PROXY_LAYER_MASK,this._raycaster.intersectObjects(this._scene.children,!0).filter(t=>h.isVisibleInHierarchy(t.object))}filterIntersectsByLayer(t,e){return t.filter(s=>(s.object.layers.mask&e)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((t,e)=>t.priority-e.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>C}}exports.DIVESelectTool=g;exports.DIVETransformTool=u;exports.DragTool=D;exports.HoverTool=b;exports.SelectTool=g;exports.SelectionState=v;exports.Toolbox=z;exports.TransformTool=u;exports.isSelectTool=P;exports.isTransformTool=w;
|
|
@@ -2,7 +2,7 @@ var P = Object.defineProperty;
|
|
|
2
2
|
var w = (a, t, e) => t in a ? P(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
3
|
var r = (a, t, e) => w(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { EventDispatcher as T, Vector3 as h, Raycaster as S, Vector2 as m } from "three/webgpu";
|
|
5
|
-
import "../../chunks/FileTypes-
|
|
5
|
+
import "../../chunks/FileTypes-D3Dxr2dj.mjs";
|
|
6
6
|
import { D as E, P as _, U as f, a as v } from "../../chunks/contributesToBounds-DYmHYES4.mjs";
|
|
7
7
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
8
8
|
import "three/tsl";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware-ag/dive",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Shopware Spatial Framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/dive.cjs",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"> 1%, not dead, not ie 11, not op_mini all"
|
|
108
108
|
],
|
|
109
109
|
"dependencies": {
|
|
110
|
-
"three": "^0.
|
|
110
|
+
"three": "^0.186.0",
|
|
111
111
|
"@tweenjs/tween.js": "^25.0.0",
|
|
112
112
|
"lodash": "^4.18.1",
|
|
113
113
|
"occt-import-js": "^0.0.23"
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"@types/lodash": "^4.17.12",
|
|
120
120
|
"@types/node": "^20.12.7",
|
|
121
121
|
"@types/three": "^0.185.1",
|
|
122
|
-
"@vitest/coverage-v8": "
|
|
122
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
123
123
|
"acorn": "^8.14.1",
|
|
124
124
|
"acorn-walk": "^8.3.4",
|
|
125
125
|
"chokidar": "^3.6.0",
|
|
@@ -141,9 +141,10 @@
|
|
|
141
141
|
"vite-plugin-dts": "^4.5.3",
|
|
142
142
|
"vite-plugin-wasm": "^3.4.1",
|
|
143
143
|
"vite-tsconfig-paths": "^5.1.4",
|
|
144
|
-
"vitest": "^
|
|
144
|
+
"vitest": "^4.1.11"
|
|
145
145
|
},
|
|
146
146
|
"resolutions": {
|
|
147
|
+
"vite": "^6.2.1",
|
|
147
148
|
"lodash": "4.18.1",
|
|
148
149
|
"vite-plugin-dts/@microsoft/api-extractor/minimatch": "3.1.5",
|
|
149
150
|
"minimatch/brace-expansion": "1.1.16",
|