@shopware-ag/dive 3.0.4-beta.1 → 3.0.4-beta.3
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-BzdQ6WmJ.cjs +1 -0
- package/build/chunks/AssetCache-QGfP1Cd3.mjs +194 -0
- package/build/chunks/{AssetLoader-C7XL4V0l.mjs → AssetLoader-CyuWDXoP.mjs} +3 -3
- package/build/chunks/{AssetLoader-B4s8jloI.cjs → AssetLoader-Df_Q2uWS.cjs} +1 -1
- package/build/chunks/{FileTypes-g6ZqzZse.mjs → FileTypes-DGNq8jnU.mjs} +1 -1
- package/build/chunks/{FileTypes-Dol5v9ki.cjs → FileTypes-EnUNPee7.cjs} +1 -1
- package/build/chunks/{isFileTypeSupported-P3xRVDuO.cjs → isFileTypeSupported-BFAW5Rfl.cjs} +1 -1
- package/build/chunks/{isFileTypeSupported-Y7SrG74A.mjs → isFileTypeSupported-CyuZhxpo.mjs} +1 -1
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +2 -2
- 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/assetcache/src/chunk/Chunk.d.ts +5 -0
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +2 -2
- 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 +1 -1
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +1 -1
- package/build/plugins/state/index.cjs +1 -1
- package/build/plugins/state/index.mjs +1 -1
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +1 -1
- package/package.json +1 -1
- package/build/chunks/AssetCache-C5gMTga4.cjs +0 -1
- package/build/chunks/AssetCache-DON6nyPa.mjs +0 -81
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var p=(i,e,r)=>e in i?g(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var o=(i,e,r)=>p(i,typeof e!="symbol"?e+"":e,r);require("./FileTypes-EnUNPee7.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const l=require("./network-error-CdDXil5g.cjs");class _{constructor(e){o(this,"_promise");o(this,"_resolve");o(this,"_arrayBuffer",null);o(this,"_size",0);o(this,"_createdAt");o(this,"_updatedAt");this._uri=e,this._promise=new Promise(r=>{this._resolve=r}),this._createdAt=new Date,this._updatedAt=new Date}get promise(){return this._promise}get size(){return this._size}get createdAt(){return this._createdAt}get updatedAt(){return this._updatedAt}get arrayBuffer(){return this._arrayBuffer}_getHeader(e,r){var t,a;return((a=(t=e.headers)==null?void 0:t.get)==null?void 0:a.call(t,r))??null}_concatChunks(e,r){const t=new Uint8Array(r);let a=0;for(const s of e)t.set(s,a),a+=s.byteLength;return t.buffer}async _readBodyWithReader(e,r){const t=e.body.getReader(),a=[];let s=0,n=0;this._logLoad("reader-start",{uri:this._uri,elapsedMs:Math.round(performance.now()-r)});try{for(;;){const c=await t.read();if(c.done){this._logLoad("reader-done",{uri:this._uri,chunkCount:n,totalByteLength:s,elapsedMs:Math.round(performance.now()-r)});break}const h=c.value??new Uint8Array(0);a.push(h),s+=h.byteLength,n+=1,this._logLoad("reader-chunk",{uri:this._uri,chunkCount:n,chunkByteLength:h.byteLength,totalByteLength:s,elapsedMs:Math.round(performance.now()-r)})}}finally{t.releaseLock()}const f=this._concatChunks(a,s);return this._logLoad("reader-complete",{uri:this._uri,chunkCount:n,totalByteLength:s,elapsedMs:Math.round(performance.now()-r)}),f}_logLoad(e,r={}){console.info("[Chunk.load]",e,r)}_logLoadError(e,r,t={}){console.error("[Chunk.load]",e,{...t,error:r instanceof Error?r.message:String(r)})}async load(){var t;const e=performance.now();let r;this._logLoad("fetch-start",{uri:this._uri});try{r=await fetch(this._uri)}catch(a){throw this._logLoadError("fetch-failed",a,{uri:this._uri,elapsedMs:Math.round(performance.now()-e)}),a}if(this._logLoad("fetch-resolved",{uri:this._uri,ok:r.ok,status:r.status,contentLength:this._getHeader(r,"content-length"),contentType:this._getHeader(r,"content-type"),elapsedMs:Math.round(performance.now()-e)}),!r.ok)throw this._logLoad("fetch-not-ok",{uri:this._uri,status:r.status,elapsedMs:Math.round(performance.now()-e)}),new l.NetworkError(this._uri);try{this._logLoad("array-buffer-start",{uri:this._uri,elapsedMs:Math.round(performance.now()-e)}),(t=r.body)!=null&&t.getReader?this._arrayBuffer=await this._readBodyWithReader(r,e):(this._logLoad("array-buffer-fallback-start",{uri:this._uri,elapsedMs:Math.round(performance.now()-e)}),this._arrayBuffer=await r.arrayBuffer(),this._logLoad("array-buffer-fallback-resolved",{uri:this._uri,byteLength:this._arrayBuffer.byteLength,elapsedMs:Math.round(performance.now()-e)})),this._logLoad("array-buffer-resolved",{uri:this._uri,byteLength:this._arrayBuffer.byteLength,elapsedMs:Math.round(performance.now()-e)}),this._size+=this._arrayBuffer.byteLength,this._updatedAt=new Date,this._logLoad("metadata-updated",{uri:this._uri,size:this._size,updatedAt:this._updatedAt.toISOString(),elapsedMs:Math.round(performance.now()-e)})}catch(a){throw this._logLoadError("array-buffer-failed",a,{uri:this._uri,elapsedMs:Math.round(performance.now()-e)}),new l.FileContentError(this._uri)}return this._logLoad("resolve-start",{uri:this._uri,byteLength:this._arrayBuffer.byteLength,elapsedMs:Math.round(performance.now()-e)}),this._resolve(this._arrayBuffer),this._logLoad("resolve-complete",{uri:this._uri,byteLength:this._arrayBuffer.byteLength,elapsedMs:Math.round(performance.now()-e)}),this._arrayBuffer}}class y{constructor(){o(this,"_cache",new Map)}get(){return this._cache}create(e){const r=new _(e);return this._cache.set(e,r),r}write(e,r){this._cache.set(e,r)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(r=>{this._cache.delete(r)})}clear(){this._cache.clear()}}const u=Symbol.for("@shopware-ag/dive/assetcache"),d=globalThis;d[u]||(d[u]=new y);const w=d[u];exports.AssetCache=w;exports.Chunk=_;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var f = (i, e, r) => e in i ? _(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
|
|
3
|
+
var o = (i, e, r) => f(i, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import "./FileTypes-DGNq8jnU.mjs";
|
|
5
|
+
import "three/webgpu";
|
|
6
|
+
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
7
|
+
import "three/tsl";
|
|
8
|
+
import { N as p, F as g } from "./network-error-BONfHWQq.mjs";
|
|
9
|
+
class y {
|
|
10
|
+
constructor(e) {
|
|
11
|
+
o(this, "_promise");
|
|
12
|
+
o(this, "_resolve");
|
|
13
|
+
o(this, "_arrayBuffer", null);
|
|
14
|
+
// metadata
|
|
15
|
+
o(this, "_size", 0);
|
|
16
|
+
o(this, "_createdAt");
|
|
17
|
+
o(this, "_updatedAt");
|
|
18
|
+
this._uri = e, this._promise = new Promise((r) => {
|
|
19
|
+
this._resolve = r;
|
|
20
|
+
}), this._createdAt = /* @__PURE__ */ new Date(), this._updatedAt = /* @__PURE__ */ new Date();
|
|
21
|
+
}
|
|
22
|
+
get promise() {
|
|
23
|
+
return this._promise;
|
|
24
|
+
}
|
|
25
|
+
get size() {
|
|
26
|
+
return this._size;
|
|
27
|
+
}
|
|
28
|
+
get createdAt() {
|
|
29
|
+
return this._createdAt;
|
|
30
|
+
}
|
|
31
|
+
get updatedAt() {
|
|
32
|
+
return this._updatedAt;
|
|
33
|
+
}
|
|
34
|
+
get arrayBuffer() {
|
|
35
|
+
return this._arrayBuffer;
|
|
36
|
+
}
|
|
37
|
+
_getHeader(e, r) {
|
|
38
|
+
var t, a;
|
|
39
|
+
return ((a = (t = e.headers) == null ? void 0 : t.get) == null ? void 0 : a.call(t, r)) ?? null;
|
|
40
|
+
}
|
|
41
|
+
_concatChunks(e, r) {
|
|
42
|
+
const t = new Uint8Array(r);
|
|
43
|
+
let a = 0;
|
|
44
|
+
for (const s of e)
|
|
45
|
+
t.set(s, a), a += s.byteLength;
|
|
46
|
+
return t.buffer;
|
|
47
|
+
}
|
|
48
|
+
async _readBodyWithReader(e, r) {
|
|
49
|
+
const t = e.body.getReader(), a = [];
|
|
50
|
+
let s = 0, n = 0;
|
|
51
|
+
this._logLoad("reader-start", {
|
|
52
|
+
uri: this._uri,
|
|
53
|
+
elapsedMs: Math.round(performance.now() - r)
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
for (; ; ) {
|
|
57
|
+
const c = await t.read();
|
|
58
|
+
if (c.done) {
|
|
59
|
+
this._logLoad("reader-done", {
|
|
60
|
+
uri: this._uri,
|
|
61
|
+
chunkCount: n,
|
|
62
|
+
totalByteLength: s,
|
|
63
|
+
elapsedMs: Math.round(performance.now() - r)
|
|
64
|
+
});
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
const h = c.value ?? new Uint8Array(0);
|
|
68
|
+
a.push(h), s += h.byteLength, n += 1, this._logLoad("reader-chunk", {
|
|
69
|
+
uri: this._uri,
|
|
70
|
+
chunkCount: n,
|
|
71
|
+
chunkByteLength: h.byteLength,
|
|
72
|
+
totalByteLength: s,
|
|
73
|
+
elapsedMs: Math.round(performance.now() - r)
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
} finally {
|
|
77
|
+
t.releaseLock();
|
|
78
|
+
}
|
|
79
|
+
const l = this._concatChunks(a, s);
|
|
80
|
+
return this._logLoad("reader-complete", {
|
|
81
|
+
uri: this._uri,
|
|
82
|
+
chunkCount: n,
|
|
83
|
+
totalByteLength: s,
|
|
84
|
+
elapsedMs: Math.round(performance.now() - r)
|
|
85
|
+
}), l;
|
|
86
|
+
}
|
|
87
|
+
_logLoad(e, r = {}) {
|
|
88
|
+
console.info("[Chunk.load]", e, r);
|
|
89
|
+
}
|
|
90
|
+
_logLoadError(e, r, t = {}) {
|
|
91
|
+
console.error("[Chunk.load]", e, {
|
|
92
|
+
...t,
|
|
93
|
+
error: r instanceof Error ? r.message : String(r)
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async load() {
|
|
97
|
+
var t;
|
|
98
|
+
const e = performance.now();
|
|
99
|
+
let r;
|
|
100
|
+
this._logLoad("fetch-start", {
|
|
101
|
+
uri: this._uri
|
|
102
|
+
});
|
|
103
|
+
try {
|
|
104
|
+
r = await fetch(this._uri);
|
|
105
|
+
} catch (a) {
|
|
106
|
+
throw this._logLoadError("fetch-failed", a, {
|
|
107
|
+
uri: this._uri,
|
|
108
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
109
|
+
}), a;
|
|
110
|
+
}
|
|
111
|
+
if (this._logLoad("fetch-resolved", {
|
|
112
|
+
uri: this._uri,
|
|
113
|
+
ok: r.ok,
|
|
114
|
+
status: r.status,
|
|
115
|
+
contentLength: this._getHeader(r, "content-length"),
|
|
116
|
+
contentType: this._getHeader(r, "content-type"),
|
|
117
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
118
|
+
}), !r.ok)
|
|
119
|
+
throw this._logLoad("fetch-not-ok", {
|
|
120
|
+
uri: this._uri,
|
|
121
|
+
status: r.status,
|
|
122
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
123
|
+
}), new p(this._uri);
|
|
124
|
+
try {
|
|
125
|
+
this._logLoad("array-buffer-start", {
|
|
126
|
+
uri: this._uri,
|
|
127
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
128
|
+
}), (t = r.body) != null && t.getReader ? this._arrayBuffer = await this._readBodyWithReader(r, e) : (this._logLoad("array-buffer-fallback-start", {
|
|
129
|
+
uri: this._uri,
|
|
130
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
131
|
+
}), this._arrayBuffer = await r.arrayBuffer(), this._logLoad("array-buffer-fallback-resolved", {
|
|
132
|
+
uri: this._uri,
|
|
133
|
+
byteLength: this._arrayBuffer.byteLength,
|
|
134
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
135
|
+
})), this._logLoad("array-buffer-resolved", {
|
|
136
|
+
uri: this._uri,
|
|
137
|
+
byteLength: this._arrayBuffer.byteLength,
|
|
138
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
139
|
+
}), this._size += this._arrayBuffer.byteLength, this._updatedAt = /* @__PURE__ */ new Date(), this._logLoad("metadata-updated", {
|
|
140
|
+
uri: this._uri,
|
|
141
|
+
size: this._size,
|
|
142
|
+
updatedAt: this._updatedAt.toISOString(),
|
|
143
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
144
|
+
});
|
|
145
|
+
} catch (a) {
|
|
146
|
+
throw this._logLoadError("array-buffer-failed", a, {
|
|
147
|
+
uri: this._uri,
|
|
148
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
149
|
+
}), new g(this._uri);
|
|
150
|
+
}
|
|
151
|
+
return this._logLoad("resolve-start", {
|
|
152
|
+
uri: this._uri,
|
|
153
|
+
byteLength: this._arrayBuffer.byteLength,
|
|
154
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
155
|
+
}), this._resolve(this._arrayBuffer), this._logLoad("resolve-complete", {
|
|
156
|
+
uri: this._uri,
|
|
157
|
+
byteLength: this._arrayBuffer.byteLength,
|
|
158
|
+
elapsedMs: Math.round(performance.now() - e)
|
|
159
|
+
}), this._arrayBuffer;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
class w {
|
|
163
|
+
constructor() {
|
|
164
|
+
o(this, "_cache", /* @__PURE__ */ new Map());
|
|
165
|
+
}
|
|
166
|
+
get() {
|
|
167
|
+
return this._cache;
|
|
168
|
+
}
|
|
169
|
+
create(e) {
|
|
170
|
+
const r = new y(e);
|
|
171
|
+
return this._cache.set(e, r), r;
|
|
172
|
+
}
|
|
173
|
+
write(e, r) {
|
|
174
|
+
this._cache.set(e, r);
|
|
175
|
+
}
|
|
176
|
+
read(e) {
|
|
177
|
+
return this._cache.get(e) ?? null;
|
|
178
|
+
}
|
|
179
|
+
delete(...e) {
|
|
180
|
+
e.forEach((r) => {
|
|
181
|
+
this._cache.delete(r);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
clear() {
|
|
185
|
+
this._cache.clear();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const u = Symbol.for("@shopware-ag/dive/assetcache"), d = globalThis;
|
|
189
|
+
d[u] || (d[u] = new w());
|
|
190
|
+
const A = d[u];
|
|
191
|
+
export {
|
|
192
|
+
A,
|
|
193
|
+
y as C
|
|
194
|
+
};
|
|
@@ -3,14 +3,14 @@ var I = (u, t, o) => t in u ? T(u, t, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var _ = (u, t, o) => I(u, typeof t != "symbol" ? t + "" : t, o);
|
|
4
4
|
import { GLTFLoader as P } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
5
5
|
import { USDLoader as U } from "three/examples/jsm/loaders/USDLoader.js";
|
|
6
|
-
import { S as k } from "./FileTypes-
|
|
6
|
+
import { S as k } from "./FileTypes-DGNq8jnU.mjs";
|
|
7
7
|
import { Group as S, BufferGeometry as F, BufferAttribute as D, MeshStandardMaterial as N, Mesh as G } from "three/webgpu";
|
|
8
8
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
9
9
|
import "three/tsl";
|
|
10
|
-
import { g as v, i as W } from "./isFileTypeSupported-
|
|
10
|
+
import { g as v, i as W } from "./isFileTypeSupported-CyuZhxpo.mjs";
|
|
11
11
|
import { F as C, P as R } from "./parse-error-DfOPyLWM.mjs";
|
|
12
12
|
import { DRACOLoader as B } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
13
|
-
import { A as L } from "./AssetCache-
|
|
13
|
+
import { A as L } from "./AssetCache-QGfP1Cd3.mjs";
|
|
14
14
|
function H() {
|
|
15
15
|
let u, t;
|
|
16
16
|
onmessage = function(s) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var U=Object.create;var b=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var v=(a,r,s)=>r in a?b(a,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[r]=s;var W=(a,r,s,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of F(r))!G.call(a,e)&&e!==s&&b(a,e,{get:()=>r[e],enumerable:!(t=k(r,e))||t.enumerable});return a};var C=(a,r,s)=>(s=a!=null?U(N(a)):{},W(r||!a||!a.__esModule?b(s,"default",{value:a,enumerable:!0}):s,a));var _=(a,r,s)=>v(a,typeof r!="symbol"?r+"":r,s);const B=require("three/examples/jsm/loaders/GLTFLoader.js"),q=require("three/examples/jsm/loaders/USDLoader.js"),j=require("./FileTypes-
|
|
1
|
+
"use strict";var U=Object.create;var b=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var v=(a,r,s)=>r in a?b(a,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[r]=s;var W=(a,r,s,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of F(r))!G.call(a,e)&&e!==s&&b(a,e,{get:()=>r[e],enumerable:!(t=k(r,e))||t.enumerable});return a};var C=(a,r,s)=>(s=a!=null?U(N(a)):{},W(r||!a||!a.__esModule?b(s,"default",{value:a,enumerable:!0}):s,a));var _=(a,r,s)=>v(a,typeof r!="symbol"?r+"":r,s);const B=require("three/examples/jsm/loaders/GLTFLoader.js"),q=require("three/examples/jsm/loaders/USDLoader.js"),j=require("./FileTypes-EnUNPee7.cjs"),m=require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const R=require("./isFileTypeSupported-BFAW5Rfl.cjs"),M=require("./parse-error-Dy_EE4rL.cjs"),H=require("three/examples/jsm/loaders/DRACOLoader.js"),D=require("./AssetCache-BzdQ6WmJ.cjs");function I(){let a,r;onmessage=function(o){const n=o.data;switch(n.type){case"init":a=n.decoderConfig,r=new Promise(function(d){a.onModuleLoaded=function(h){d({draco:h})},DracoDecoderModule(a)});break;case"decode":const i=n.buffer,u=n.taskConfig;r.then(d=>{const h=d.draco,l=new h.Decoder;try{const f=s(h,l,new Int8Array(i),u),p=f.attributes.map(g=>g.array.buffer);f.index&&p.push(f.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:f},p)}catch(f){console.error(f),self.postMessage({type:"error",id:n.id,error:f.message})}finally{h.destroy(l)}});break}};function s(o,n,i,u){const d=u.attributeIDs,h=u.attributeTypes;let l,f;const p=n.GetEncodedGeometryType(i);if(p===o.TRIANGULAR_MESH)l=new o.Mesh,f=n.DecodeArrayToMesh(i,i.byteLength,l);else if(p===o.POINT_CLOUD)l=new o.PointCloud,f=n.DecodeArrayToPointCloud(i,i.byteLength,l);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||l.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const g={index:null,attributes:[]};for(const w in d){const A=self[h[w]];let L,y;if(u.useUniqueIDs)y=d[w],L=n.GetAttributeByUniqueId(l,y);else{if(y=n.GetAttributeId(l,o[d[w]]),y===-1)continue;L=n.GetAttribute(l,y)}const T=e(o,n,l,w,A,L);w==="color"&&(T.vertexColorSpace=u.vertexColorSpace),g.attributes.push(T)}return p===o.TRIANGULAR_MESH&&(g.index=t(o,n,l)),o.destroy(l),g}function t(o,n,i){const d=i.num_faces()*3,h=d*4,l=o._malloc(h);n.GetTrianglesUInt32Array(i,h,l);const f=new Uint32Array(o.HEAPF32.buffer,l,d).slice();return o._free(l),{array:f,itemSize:1}}function e(o,n,i,u,d,h){const l=h.num_components(),p=i.num_points()*l,g=p*d.BYTES_PER_ELEMENT,w=c(o,d),A=o._malloc(g);n.GetAttributeDataArrayForAllPoints(i,h,w,g,A);const L=new d(o.HEAPF32.buffer,A,p).slice();return o._free(A),{name:u,array:L,itemSize:l}}function c(o,n){switch(n){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}const S={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 a=(await import("three/examples/jsm/libs/draco/draco_decoder.wasm?url")).default;return await(await fetch(a)).arrayBuffer()}};class P extends H.DRACOLoader{constructor(){super(...arguments);_(this,"decoderPending",null);_(this,"decoderConfig",{type:"js",wasmBinary:null});_(this,"workerSourceURL","")}async _initDecoder(){if(this.decoderPending)return this.decoderPending;const s=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return s?t.push(S.LOAD_DRACO_JS_DECODER()):(t.push(S.LOAD_DRACO_WASM_WRAPPER()),t.push(S.LOAD_DRACO_WASM_DECODER())),this.decoderPending=Promise.all(t).then(e=>{const c=e[0];s||(this.decoderConfig.wasmBinary=e[1]);const o=I.toString(),n=["/* draco decoder */",c,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
|
|
2
2
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}}function z(){let a=null,r=null;const s=[[/'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 t(){return a||(a=occtimportjs({locateFile:function(){return r}})),a}function e(o){for(var n=new TextDecoder("utf-8",{fatal:!1}),i=new TextEncoder,u=n.decode(o),d=0;d<s.length;d++){var h=s[d][0],l=s[d][1];u=u.replace(h,l)}return new Uint8Array(i.encode(u))}function c(o,n){var i=e(n);try{var u=o.ReadStepFile(i,null);if(u.success&&u.root)return u}catch{}try{return o.ReadStepFile(n,null)}catch{return{success:!1,root:{meshes:[],children:[]},meshes:[]}}}onmessage=async function(o){var n=o.data;switch(n.type){case"init":r=n.wasmUrl;break;case"parse":try{var i=await t(),u=new Uint8Array(n.buffer),d=n.fileType,h;if(d==="step"||d==="stp"?h=c(i,u):h=i.ReadIgesFile(u,null),!h.success||!h.root){self.postMessage({type:"error",id:n.id,error:"Failed to parse CAD file"});return}self.postMessage({type:"result",id:n.id,result:h})}catch(l){self.postMessage({type:"error",id:n.id,error:l instanceof Error?l.message:String(l)})}break}}}const O={LOAD_OCCT_JS:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-DdbbsFBH.cjs"))).default,LOAD_OCCT_WASM_URL:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-BQ1yZHCj.cjs"))).default};class J{constructor(){_(this,"_workerPending",null);_(this,"_worker",null);_(this,"_nextId",0);_(this,"_pending",new Map)}_getWorker(){return this._workerPending?this._workerPending:(this._workerPending=(async()=>{const[r,s]=await Promise.all([O.LOAD_OCCT_JS(),O.LOAD_OCCT_WASM_URL()]),t=z.toString(),e=["/* occt-import-js */",r,"","/* step worker */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))].join(`
|
|
3
3
|
`),c=URL.createObjectURL(new Blob([e])),o=new Worker(c),n=new URL(s,window.location.href).href;return o.postMessage({type:"init",wasmUrl:n}),o.onmessage=i=>{const{type:u,id:d,result:h,error:l}=i.data,f=this._pending.get(d);if(f)if(this._pending.delete(d),u==="result")try{f.resolve(this._buildScene(h))}catch(p){f.reject(p instanceof Error?p:new Error(String(p)))}else f.reject(new Error(l??"Worker error"))},o.onerror=i=>{for(const[,{reject:u}]of this._pending)u(new Error(i.message??"Worker error"));this._pending.clear()},this._worker=o,o})(),this._workerPending)}async parseAsync(r,s){const t=this._nextId++,e=await this._getWorker();return new Promise((c,o)=>{this._pending.set(t,{resolve:c,reject:o});const n=r.slice(0);e.postMessage({type:"parse",id:t,buffer:n,fileType:s},[n])})}dispose(){if(this._worker){for(const[,{reject:r}]of this._pending)r(new Error("STEPLoader disposed"));this._pending.clear(),this._worker.terminate(),this._worker=null,this._workerPending=null}}_buildScene(r){const s=new m.Group;return s.name=r.root.name??"CAD Model",this._buildNode(r.root,r.meshes,s),s.rotation.x=-Math.PI/2,s.rotation.z=Math.PI/2,s}_buildNode(r,s,t){const e=new m.Group;e.name=r.name??"Part";for(const c of r.meshes){const o=s[c];if(o!=null&&o.attributes){const n=this._createMesh(o);e.add(n)}}for(const c of r.children)this._buildNode(c,s,e);t.add(e)}_createMesh(r){var u,d;const{position:s,normal:t}=r.attributes,e=r.index??r.attributes.index,c=new m.BufferGeometry;c.setAttribute("position",new m.BufferAttribute(new Float32Array(s.array),3)),(u=t==null?void 0:t.array)!=null&&u.length?c.setAttribute("normal",new m.BufferAttribute(new Float32Array(t.array),3)):c.computeVertexNormals(),(d=e==null?void 0:e.array)!=null&&d.length&&c.setIndex(new m.BufferAttribute(new Uint32Array(e.array),1));const o=r.color,n=new m.MeshStandardMaterial({metalness:.3,roughness:.6});o&&o.length>=3?n.color.setRGB(o[0],o[1],o[2]):n.color.setHex(13421772);const i=new m.Mesh(c,n);return i.name=r.name??"Mesh",i.castShadow=!0,i.receiveShadow=!0,i}}const E=a=>Array.isArray(a==null?void 0:a.children)?a.children.length:0;class ${constructor(){_(this,"_gltfLoader");_(this,"_usdLoader");_(this,"_stepLoader");const r=new P;r.setDecoderConfig({type:"wasm"}),this._gltfLoader=new B.GLTFLoader,this._gltfLoader.setDRACOLoader(r),this._usdLoader=new q.USDLoader,this._stepLoader=new J}_logLoad(r,s={}){console.info("[AssetLoader.load]",r,s)}_logLoadError(r,s,t={}){console.error("[AssetLoader.load]",r,{...t,error:s instanceof Error?s.message:String(s)})}async load(r,s){const t=performance.now();let e;if(this._logLoad("start",{uri:r,fileType:s??null}),s)e=s,this._logLoad("using-explicit-file-type",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)});else if(e=R.getFileTypeFromUri(r),this._logLoad("derived-file-type-from-uri",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)}),e.length===0&&(this._logLoad("detect-file-type-from-content-start",{uri:r,elapsedMs:Math.round(performance.now()-t)}),e=await this._detectFileTypeFromContent(r),this._logLoad("detect-file-type-from-content-complete",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)}),e.length===0))throw new M.FileTypeError("No file extension found in URI","");if(!R.isFileTypeSupported(e))throw new M.FileTypeError(`Unsupported file type: ${e}. Supported types: ${j.SUPPORTED_FILE_TYPES.join(", ")}`,e);const c=D.AssetCache.read(r);if(this._logLoad(c?"cache-hit":"cache-miss",{uri:r,extension:e,hasArrayBuffer:!!(c!=null&&c.arrayBuffer),elapsedMs:Math.round(performance.now()-t)}),c)return c.arrayBuffer?(this._logLoad("parse-start",{uri:r,extension:e,source:"cache-array-buffer",byteLength:c.arrayBuffer.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._parse(c.arrayBuffer,e,{uri:r,source:"cache-array-buffer",startedAt:t})):(this._logLoad("await-existing-cache-promise-start",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)}),c.promise.then(i=>(this._logLoad("await-existing-cache-promise-resolved",{uri:r,extension:e,byteLength:i.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._logLoad("parse-start",{uri:r,extension:e,source:"cache-promise",byteLength:i.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._parse(i,e,{uri:r,source:"cache-promise",startedAt:t}))));const o=D.AssetCache.create(r);this._logLoad("chunk-created",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)}),this._logLoad("chunk-load-start",{uri:r,extension:e,elapsedMs:Math.round(performance.now()-t)});const n=await o.load();return this._logLoad("chunk-load-resolved",{uri:r,extension:e,byteLength:n.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._logLoad("parse-start",{uri:r,extension:e,source:"fresh-chunk",byteLength:n.byteLength,elapsedMs:Math.round(performance.now()-t)}),this._parse(n,e,{uri:r,source:"fresh-chunk",startedAt:t})}async _detectFileTypeFromContent(r){try{const s=D.AssetCache.read(r);let t;s?s.arrayBuffer?t=s.arrayBuffer:t=await s.promise:t=await D.AssetCache.create(r).load();const e=new Uint8Array(t);return e.length>=12&&String.fromCharCode(e[0],e[1],e[2],e[3])==="glTF"?e[12]===0?"glb":"gltf":e.length>=4&&e[0]===80&&e[1]===75&&(e[2]===3||e[2]===5)&&(e[3]===4||e[3]===6)?"usdz":e.length>=20&&new TextDecoder("ascii").decode(e.subarray(0,20)).startsWith("ISO-10303-21")?"step":e.length>=80&&e[72]===83?"iges":""}catch{return""}}async _parse(r,s,t){try{switch(this._logLoad("parse-dispatch",{uri:t.uri,type:s,source:t.source,byteLength:r.byteLength,elapsedMs:Math.round(performance.now()-t.startedAt)}),s){case"glb":case"gltf":{this._logLoad("gltf-parse-start",{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)});const e=await this._gltfLoader.parseAsync(r,"");return e.scene.animations=e.animations,this._logLoad("gltf-parse-complete",{uri:t.uri,type:s,source:t.source,childCount:E(e.scene),animationCount:Array.isArray(e.animations)?e.animations.length:0,elapsedMs:Math.round(performance.now()-t.startedAt)}),e.scene}case"usdz":{this._logLoad("usdz-parse-start",{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)});const e=this._usdLoader.parse(r);return e.animations=[],this._logLoad("usdz-parse-complete",{uri:t.uri,type:s,source:t.source,childCount:E(e),elapsedMs:Math.round(performance.now()-t.startedAt)}),e}case"step":case"stp":{this._logLoad("step-parse-start",{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)});const e=await this._stepLoader.parseAsync(r,s);return e.animations=[],this._logLoad("step-parse-complete",{uri:t.uri,type:s,source:t.source,childCount:E(e),elapsedMs:Math.round(performance.now()-t.startedAt)}),e}case"iges":case"igs":{this._logLoad("iges-parse-start",{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)});const e=await this._stepLoader.parseAsync(r,s);return e.animations=[],this._logLoad("iges-parse-complete",{uri:t.uri,type:s,source:t.source,childCount:E(e),elapsedMs:Math.round(performance.now()-t.startedAt)}),e}}}catch(e){throw this._logLoadError("parse-failed",e,{uri:t.uri,type:s,source:t.source,elapsedMs:Math.round(performance.now()-t.startedAt)}),e instanceof Error?new M.ParseError(`Failed to parse ${s} file: ${e.message}`,e):new M.ParseError(`Failed to parse ${s} file`)}}}exports.AssetLoader=$;exports.DRACOWorker=I;exports.DracoLoader=P;
|
|
@@ -1979,7 +1979,7 @@ class ni {
|
|
|
1979
1979
|
), this._clock.addTicker(this._orientationDisplay));
|
|
1980
1980
|
}
|
|
1981
1981
|
), this._settings.autoStart && this.start(), console.log(
|
|
1982
|
-
"DIVE 3.0.4-beta.
|
|
1982
|
+
"DIVE 3.0.4-beta.3 initialized successfully!"
|
|
1983
1983
|
), console.log(UA), window.DIVE.instances.push(this);
|
|
1984
1984
|
}
|
|
1985
1985
|
get views() {
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
@@%-::::::::::::-%@ @%-------------=%@@
|
|
27
27
|
@@@@+:::::::#@@ @@*-------*@@@@
|
|
28
28
|
@@@@@@@ @@@@@@
|
|
29
|
-
`;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]}};const P={autoStart:!0,displayAxes:!1,...d,...a.DIVEPerspectiveCameraDefaultSettings,...p,...J};class tA{constructor(t){e(this,"_instanceId",g.MathUtils.generateUUID());e(this,"_settings");e(this,"_disposed",!1);e(this,"_views");e(this,"_mainView");e(this,"_scene");e(this,"_clock");e(this,"_orientationDisplay",null);this._settings={...P,...t??{}},this._clock=new Y,this._scene=new x({backgroundColor:(t==null?void 0:t.backgroundColor)??P.backgroundColor,displayGrid:(t==null?void 0:t.displayGrid)??P.displayGrid,displayFloor:(t==null?void 0:t.displayFloor)??P.displayFloor});const A=new F(this._scene,new a.DIVEPerspectiveCamera,this._settings);this._clock.addTicker(A),this._views=[A],this._mainView=A,this._settings.displayAxes&&Promise.resolve().then(()=>require("../plugins/orientationdisplay/index.cjs")).then(({OrientationDisplay:i})=>{this._disposed||(this._orientationDisplay=new i(this.mainView.renderer,this.scene,this.mainView.camera),this._clock.addTicker(this._orientationDisplay))}),this._settings.autoStart&&this.start(),console.log("DIVE 3.0.4-beta.
|
|
29
|
+
`;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]}};const P={autoStart:!0,displayAxes:!1,...d,...a.DIVEPerspectiveCameraDefaultSettings,...p,...J};class tA{constructor(t){e(this,"_instanceId",g.MathUtils.generateUUID());e(this,"_settings");e(this,"_disposed",!1);e(this,"_views");e(this,"_mainView");e(this,"_scene");e(this,"_clock");e(this,"_orientationDisplay",null);this._settings={...P,...t??{}},this._clock=new Y,this._scene=new x({backgroundColor:(t==null?void 0:t.backgroundColor)??P.backgroundColor,displayGrid:(t==null?void 0:t.displayGrid)??P.displayGrid,displayFloor:(t==null?void 0:t.displayFloor)??P.displayFloor});const A=new F(this._scene,new a.DIVEPerspectiveCamera,this._settings);this._clock.addTicker(A),this._views=[A],this._mainView=A,this._settings.displayAxes&&Promise.resolve().then(()=>require("../plugins/orientationdisplay/index.cjs")).then(({OrientationDisplay:i})=>{this._disposed||(this._orientationDisplay=new i(this.mainView.renderer,this.scene,this.mainView.camera),this._clock.addTicker(this._orientationDisplay))}),this._settings.autoStart&&this.start(),console.log("DIVE 3.0.4-beta.3 initialized successfully!"),console.log(eA),window.DIVE.instances.push(this)}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}start(){this._disposed||this.startAsync().catch(t=>{console.error("DIVE.start: Failed to initialize the WebGPU renderer.",t)})}async startAsync(){if(!this._disposed){if(this.mainView.renderer.initialized)this._clock.start();else{const t=this.mainView.init();queueMicrotask(()=>{this._disposed||this._clock.start()});try{await t}catch(A){this.dispose(),console.error("DIVE.startAsync: Failed to initialize. Error:",A)}}this._disposed}}stop(){this._clock.stop()}async dispose(){return this._disposed=!0,new Promise(t=>{this._clock.dispose(),this._views.forEach(A=>{A.dispose()}),this._views=[],this._orientationDisplay&&(this._orientationDisplay.dispose(),this._orientationDisplay=null),this.scene.dispose(),window.DIVE.instances=window.DIVE.instances.filter(A=>A._instanceId!==this._instanceId),t()})}}const T={glb:{key:"glb",extension:"glb"},gltf:{key:"gltf",extension:"gltf"},usdz:{key:"usdz",extension:"usdz"},step:{key:"step",extension:"step"},stp:{key:"stp",extension:"stp"},iges:{key:"iges",extension:"iges"},igs:{key:"igs",extension:"igs"}},gA=Object.values(T).map(f=>f.extension);exports.BoundingBox=u;exports.DIVE=tA;exports.DIVEAmbientLight=X;exports.DIVECanvasLifecycleManager=L;exports.DIVEClock=Y;exports.DIVEDefaultSettings=P;exports.DIVEEnvironment=O;exports.DIVEEnvironmentDefaultSettings=b;exports.DIVEFloor=W;exports.DIVEGrid=l;exports.DIVEGroup=Q;exports.DIVEModel=v;exports.DIVENode=w;exports.DIVEPointLight=j;exports.DIVEPrimitive=Z;exports.DIVERenderer=M;exports.DIVERendererDefaultSettings=p;exports.DIVERoot=N;exports.DIVEScene=x;exports.DIVESceneDefaultSettings=d;exports.DIVESceneLight=E;exports.DIVEView=F;exports.FILE_TYPES=T;exports.GRID_MAJOR_LINE_COLOR=S;exports.GRID_MINOR_LINE_COLOR=k;exports.OrbitController=m;exports.OrbitControllerDefaultSettings=J;exports.SUPPORTED_FILE_TYPES=gA;exports.findSceneRecursive=K;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./FileTypes-
|
|
1
|
+
"use strict";const n=require("./FileTypes-EnUNPee7.cjs");function o(e){var t;const i=e.split("/").pop()||"";return!i.includes(".")||i.endsWith(".")?"":((t=i.split(".").pop())==null?void 0:t.toLowerCase().split("?")[0])||""}function r(e){return e.toLowerCase()in n.FILE_TYPES}exports.getFileTypeFromUri=o;exports.isFileTypeSupported=r;
|
package/build/dive.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty;var O=(r,i,e)=>i in r?b(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>O(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./chunks/FileTypes-Dol5v9ki.cjs"),u=require("./chunks/PerspectiveCamera-DwQUmkDv.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three/webgpu"),V=require("./chunks/findInterface-C6mrvf_t.cjs"),y=require("./chunks/isFileTypeSupported-P3xRVDuO.cjs"),w=require("./chunks/network-error-CdDXil5g.cjs"),A=require("./chunks/parse-error-Dy_EE4rL.cjs"),x=require("./chunks/PovSchema-Co9FznEz.cjs");class m extends s.Object3D{constructor(e,t,o,h,a){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVERadialHandle",this.axis=e,this._color.set(a),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1;const l=new s.TorusGeometry(t,.01,13,48,o);this._lineMaterial=new s.MeshBasicMaterial({color:a,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,this.add(d);const g=new s.TorusGeometry(t,.1,3,48,o),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this.add(this._colliderMesh),this.lookAt(h)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}function p(r,i){const e=(r+"e").split("e");return+(e[0]+"e"+(+e[1]+(i||0)))}function R(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function v(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function P(r,i=0){if(r<0)return-P(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function H(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function G(r,i=0){const e=p(r,+i);return p(Math.round(e),-i).toFixed(i)}function z(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function L(r){return(s.MathUtils.radToDeg(r)+360)%360}function C(r){return s.MathUtils.degToRad(r)}const S={ceilExp:R,floorExp:v,roundExp:P,toFixedExp:G,truncateExp:z,signedAngleTo:H,radToDeg:L,degToRad:C};class Y extends s.Object3D{constructor(e){super();n(this,"children");n(this,"_controller");n(this,"_startRot");this.name="DIVERotateGizmo",this.children=[],this._startRot=null,this._controller=e,this.add(new m("x",1,Math.PI/2,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new m("y",1,-Math.PI/2,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new m("z",1,Math.PI/2,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startRot||this.parent&&this.parent.parent&&(this.parent.parent.onHover("rotate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startRot=t.rotation.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startRot||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragCurrent.clone().sub(this.parent.parent.position).normalize(),h=t.dragStart.clone().sub(this.parent.parent.position).normalize(),a=S.signedAngleTo(h,o,e.forwardVector),l=new s.Euler(this._startRot.x+e.forwardVector.x*a,this._startRot.y+e.forwardVector.y*a,this._startRot.z+e.forwardVector.z*a);this.parent.parent.onChange(void 0,l)}onHandleDragEnd(e){this._startRot=null,this.handleHighlight(e.axis,!1,!1)}}class D extends s.Object3D{constructor(e,t,o,h){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVEAxisHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._highlight=!1,this._hovered=!1;const a=new s.CylinderGeometry(.01,.01,t,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const l=new s.Mesh(a,this._lineMaterial);l.layers.mask=u.UI_LAYER_MASK,l.renderOrder=1/0,l.rotateX(Math.PI/2),l.translateY(t/2),this.add(l);const d=new s.CylinderGeometry(.1,.1,t,3),g=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(d,g),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}class T extends s.Object3D{constructor(e){super();n(this,"_controller");n(this,"children");n(this,"_startPos");this.name="DIVETranslateGizmo",this.children=[],this._startPos=null,this._controller=e,this.add(new D("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new D("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new D("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startPos||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startPos=t.position.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startPos||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(this._startPos.clone().add(o))}onHandleDragEnd(e){this._startPos=null,this.handleHighlight(e.axis,!1,!1)}}class M extends s.Object3D{constructor(e,t,o,h,a=.05){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");n(this,"_box");n(this,"_boxSize");this.name="DIVEScaleHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1,this._boxSize=a;const l=new s.CylinderGeometry(.01,.01,t-a/2,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,d.rotateX(Math.PI/2),d.translateY(t/2-a/4),this.add(d),this._box=new s.Mesh(new s.BoxGeometry(a,a,a),this._lineMaterial),this._box.layers.mask=u.UI_LAYER_MASK,this._box.renderOrder=1/0,this._box.rotateX(Math.PI/2),this._box.translateY(t-a/2),this._box.rotateZ(o.x*Math.PI/2),this._box.rotateX(o.z*Math.PI/2),this.add(this._box);const g=new s.CylinderGeometry(.1,.1,t+a/2,3),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}update(e){this._box.scale.copy(new s.Vector3(1,1,1).sub(this.forwardVector).add(e.clone().multiply(this.forwardVector)))}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHoverAxis(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHoverAxis(this,!1)}onDragStart(){this.parent&&this.parent.onAxisDragStart(this)}onDrag(e){this.parent&&this.parent.onAxisDrag(this,e)}onDragEnd(){this.parent&&this.parent.onAxisDragEnd(this)}}class j extends s.Object3D{constructor(e){super();n(this,"isHoverable",!0);n(this,"children");n(this,"_controller");n(this,"_startScale");this.name="DIVEScaleGizmo",this.children=[],this._startScale=null,this._controller=e,this.add(new M("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new M("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new M("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}update(e){this.children.forEach(t=>{t.update(e)})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHoverAxis(e,t){this._startScale||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onAxisDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startScale=t.scale.clone(),this.handleHighlight(e.axis,!0,!0))}onAxisDrag(e,t){if(!this._startScale||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(void 0,void 0,this._startScale.clone().add(o))}onAxisDragEnd(e){this._startScale=null,this.handleHighlight(e.axis,!1,!1)}}class N extends s.Object3D{constructor(){super();n(this,"_meshX");n(this,"_meshY");n(this,"_meshZ");this.name="DIVEGizmoPlane";const e=new s.MeshBasicMaterial({transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1,side:2}),t=new s.PlaneGeometry(100,100,2,2),o=e.clone();o.color.set(16711680),this._meshX=new s.Mesh(t,o),this._meshX.layers.mask=u.UI_LAYER_MASK,this._meshX.rotateY(Math.PI/2);const h=new s.PlaneGeometry(100,100,2,2),a=e.clone();a.color.set(65280),this._meshY=new s.Mesh(h,a),this._meshY.layers.mask=u.UI_LAYER_MASK,this._meshY.rotateX(-Math.PI/2);const l=new s.PlaneGeometry(100,100,2,2),d=e.clone();d.color.set(255),this._meshZ=new s.Mesh(l,d),this._meshZ.layers.mask=u.UI_LAYER_MASK}get XPlane(){return this._meshX}get YPlane(){return this._meshY}get ZPlane(){return this._meshZ}assemble(e,t){if(this.clear(),e==="translate"||e==="scale")switch(t){case"x":this.add(this._meshY),this.add(this._meshZ);break;case"y":this.add(this._meshX),this.add(this._meshZ);break;case"z":this.add(this._meshX),this.add(this._meshY);break}else if(e==="rotate")switch(t){case"x":this.add(this._meshX);break;case"y":this.add(this._meshY);break;case"z":this.add(this._meshZ);break}}}class F extends s.Object3D{constructor(e){super();n(this,"_mode");n(this,"_gizmoNode");n(this,"_translateGizmo");n(this,"_rotateGizmo");n(this,"_scaleGizmo");n(this,"_gizmoPlane");n(this,"_object");this.name="DIVEGizmo",e.addEventListener("change",()=>{const t=e.getDistance()/2.5;this.scale.set(t,t,t)}),this._mode="translate",this._gizmoNode=new s.Object3D,this.add(this._gizmoNode),this._translateGizmo=new T(e),this._rotateGizmo=new Y(e),this._scaleGizmo=new j(e),this._gizmoPlane=new N,this._gizmoPlane.visible=!1,this._object=null}get mode(){return this._mode}set mode(e){this._mode=e,this.assemble()}set debug(e){this._translateGizmo.debug=e,this._rotateGizmo.debug=e,this._scaleGizmo.debug=e}get gizmoNode(){return this._gizmoNode}get gizmoPlane(){return this._gizmoPlane}get object(){return this._object}attach(e){return this._object=e,this.assemble(),this}detach(){return this._object=null,this.assemble(),this}onHover(e,t,o){o&&this._gizmoPlane.assemble(e,t)}onChange(e,t,o){this.object!==null&&(e&&(this.position.copy(e),this.object.position.copy(e)),t&&this.object.rotation.copy(t),o&&(this.object.scale.copy(o),this._scaleGizmo.update(o)))}assemble(){this._gizmoNode.clear(),this._gizmoPlane.clear(),this._translateGizmo.reset(),this._rotateGizmo.reset(),this._scaleGizmo.reset(),this.object!==null&&(this._mode==="translate"&&this._gizmoNode.add(this._translateGizmo),this._mode==="rotate"&&this._gizmoNode.add(this._rotateGizmo),this._mode==="scale"&&this._gizmoNode.add(this._scaleGizmo),this.add(this._gizmoPlane))}}class U{constructor(){n(this,"isMovable",!0)}}class K{constructor(){n(this,"isSelectable",!0)}}function X(r,i){return i.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(o=>{if(o==="constructor")return;const h=Object.getOwnPropertyDescriptor(e.prototype,o);Object.defineProperty(r.prototype,o,h)});const t=new e;Object.getOwnPropertyNames(t).forEach(o=>{const h=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r.prototype,o,h)})}),r}function f(r,i=new WeakMap){if(r===null||typeof r!="object")return r;if(i.has(r))return i.get(r);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const a=[];i.set(r,a);for(let l=0;l<r.length;l++)a[l]=f(r[l],i);return a}if(r instanceof Map){const a=new Map;i.set(r,a);for(const[l,d]of r)a.set(f(l,i),f(d,i));return a}if(r instanceof Set){const a=new Set;i.set(r,a);for(const l of r)a.add(f(l,i));return a}const e=r;if(typeof e.clone=="function"){const a=e.clone();return i.set(r,a),a}const t=Object.create(Object.getPrototypeOf(r));i.set(r,t);const o=Object.getOwnPropertyNames(r);for(const a of o){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}const h=Object.getOwnPropertySymbols(r);for(const a of h){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}return t}const I=(r,i)=>{if(Object.keys(r).length===0&&Object.keys(i).length===0)return{};if(typeof r!="object"||typeof i!="object")return i;let e={};return Object.keys(i).forEach(t=>{if(!Object.keys(r).includes(t)){e={...e,[t]:i[t]};return}if(Array.isArray(i[t])){if(!Array.isArray(r[t])){e={...e,[t]:i[t]};return}const o=r[t],h=i[t];if(o.length===0&&h.length===0){e={...e};return}if(o.length!==h.length){e={...e,[t]:i[t]};return}const a=[];if(h.forEach((l,d)=>{const g=I(o[d],h[d]);Object.keys(g).length&&a.push(h[d])}),Object.keys(a).length){e={...e,[t]:a};return}return}if(typeof i[t]=="object"){if(typeof r[t]!="object"){e={...e,[t]:i[t]};return}const o=I(r[t],i[t]);if(Object.keys(o).length){e={...e,[t]:o};return}}r[t]!==i[t]&&(e={...e,[t]:i[t]})}),e};function q(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function Z(r){return r.entityType==="primitive"}exports.BoundingBox=c.BoundingBox;exports.DIVE=c.DIVE;exports.DIVEAmbientLight=c.DIVEAmbientLight;exports.DIVECanvasLifecycleManager=c.DIVECanvasLifecycleManager;exports.DIVEClock=c.DIVEClock;exports.DIVEDefaultSettings=c.DIVEDefaultSettings;exports.DIVEEnvironment=c.DIVEEnvironment;exports.DIVEEnvironmentDefaultSettings=c.DIVEEnvironmentDefaultSettings;exports.DIVEFloor=c.DIVEFloor;exports.DIVEGrid=c.DIVEGrid;exports.DIVEGroup=c.DIVEGroup;exports.DIVEModel=c.DIVEModel;exports.DIVENode=c.DIVENode;exports.DIVEPointLight=c.DIVEPointLight;exports.DIVEPrimitive=c.DIVEPrimitive;exports.DIVERenderer=c.DIVERenderer;exports.DIVERendererDefaultSettings=c.DIVERendererDefaultSettings;exports.DIVERoot=c.DIVERoot;exports.DIVEScene=c.DIVEScene;exports.DIVESceneDefaultSettings=c.DIVESceneDefaultSettings;exports.DIVESceneLight=c.DIVESceneLight;exports.DIVEView=c.DIVEView;exports.FILE_TYPES=c.FILE_TYPES;exports.GRID_MAJOR_LINE_COLOR=c.GRID_MAJOR_LINE_COLOR;exports.GRID_MINOR_LINE_COLOR=c.GRID_MINOR_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=c.SUPPORTED_FILE_TYPES;exports.findSceneRecursive=c.findSceneRecursive;exports.COORDINATE_LAYER_MASK=u.COORDINATE_LAYER_MASK;exports.DEFAULT_LAYER_MASK=u.DEFAULT_LAYER_MASK;exports.DIVEPerspectiveCamera=u.DIVEPerspectiveCamera;exports.DIVEPerspectiveCameraDefaultSettings=u.DIVEPerspectiveCameraDefaultSettings;exports.HELPER_LAYER_MASK=u.HELPER_LAYER_MASK;exports.PRODUCT_LAYER_MASK=u.PRODUCT_LAYER_MASK;exports.UI_LAYER_MASK=u.UI_LAYER_MASK;exports.AxesColorBlue=_.AxesColorBlue;exports.AxesColorBlueLetter=_.AxesColorBlueLetter;exports.AxesColorGreen=_.AxesColorGreen;exports.AxesColorGreenLetter=_.AxesColorGreenLetter;exports.AxesColorRed=_.AxesColorRed;exports.AxesColorRedLetter=_.AxesColorRedLetter;exports.findInterface=V.findInterface;exports.implementsInterface=V.implementsInterface;exports.getFileTypeFromUri=y.getFileTypeFromUri;exports.isFileTypeSupported=y.isFileTypeSupported;exports.FileContentError=w.FileContentError;exports.NetworkError=w.NetworkError;exports.FileTypeError=A.FileTypeError;exports.ParseError=A.ParseError;exports.isModelSchema=x.isModelSchema;exports.isPovSchema=x.isPovSchema;exports.DIVEGizmo=F;exports.DIVEMath=S;exports.DIVEMovable=U;exports.DIVESelectable=K;exports.applyMixins=X;exports.deepClone=f;exports.getObjectDelta=I;exports.isGroupSchema=q;exports.isLightSchema=B;exports.isPrimitiveSchema=Z;
|
|
1
|
+
"use strict";var b=Object.defineProperty;var O=(r,i,e)=>i in r?b(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>O(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./chunks/FileTypes-EnUNPee7.cjs"),u=require("./chunks/PerspectiveCamera-DwQUmkDv.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three/webgpu"),V=require("./chunks/findInterface-C6mrvf_t.cjs"),y=require("./chunks/isFileTypeSupported-BFAW5Rfl.cjs"),w=require("./chunks/network-error-CdDXil5g.cjs"),A=require("./chunks/parse-error-Dy_EE4rL.cjs"),x=require("./chunks/PovSchema-Co9FznEz.cjs");class m extends s.Object3D{constructor(e,t,o,h,a){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVERadialHandle",this.axis=e,this._color.set(a),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1;const l=new s.TorusGeometry(t,.01,13,48,o);this._lineMaterial=new s.MeshBasicMaterial({color:a,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,this.add(d);const g=new s.TorusGeometry(t,.1,3,48,o),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this.add(this._colliderMesh),this.lookAt(h)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}function p(r,i){const e=(r+"e").split("e");return+(e[0]+"e"+(+e[1]+(i||0)))}function R(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function v(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function P(r,i=0){if(r<0)return-P(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function H(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function G(r,i=0){const e=p(r,+i);return p(Math.round(e),-i).toFixed(i)}function z(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function L(r){return(s.MathUtils.radToDeg(r)+360)%360}function C(r){return s.MathUtils.degToRad(r)}const S={ceilExp:R,floorExp:v,roundExp:P,toFixedExp:G,truncateExp:z,signedAngleTo:H,radToDeg:L,degToRad:C};class Y extends s.Object3D{constructor(e){super();n(this,"children");n(this,"_controller");n(this,"_startRot");this.name="DIVERotateGizmo",this.children=[],this._startRot=null,this._controller=e,this.add(new m("x",1,Math.PI/2,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new m("y",1,-Math.PI/2,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new m("z",1,Math.PI/2,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startRot||this.parent&&this.parent.parent&&(this.parent.parent.onHover("rotate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startRot=t.rotation.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startRot||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragCurrent.clone().sub(this.parent.parent.position).normalize(),h=t.dragStart.clone().sub(this.parent.parent.position).normalize(),a=S.signedAngleTo(h,o,e.forwardVector),l=new s.Euler(this._startRot.x+e.forwardVector.x*a,this._startRot.y+e.forwardVector.y*a,this._startRot.z+e.forwardVector.z*a);this.parent.parent.onChange(void 0,l)}onHandleDragEnd(e){this._startRot=null,this.handleHighlight(e.axis,!1,!1)}}class D extends s.Object3D{constructor(e,t,o,h){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVEAxisHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._highlight=!1,this._hovered=!1;const a=new s.CylinderGeometry(.01,.01,t,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const l=new s.Mesh(a,this._lineMaterial);l.layers.mask=u.UI_LAYER_MASK,l.renderOrder=1/0,l.rotateX(Math.PI/2),l.translateY(t/2),this.add(l);const d=new s.CylinderGeometry(.1,.1,t,3),g=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(d,g),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}class T extends s.Object3D{constructor(e){super();n(this,"_controller");n(this,"children");n(this,"_startPos");this.name="DIVETranslateGizmo",this.children=[],this._startPos=null,this._controller=e,this.add(new D("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new D("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new D("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startPos||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startPos=t.position.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startPos||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(this._startPos.clone().add(o))}onHandleDragEnd(e){this._startPos=null,this.handleHighlight(e.axis,!1,!1)}}class M extends s.Object3D{constructor(e,t,o,h,a=.05){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");n(this,"_box");n(this,"_boxSize");this.name="DIVEScaleHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1,this._boxSize=a;const l=new s.CylinderGeometry(.01,.01,t-a/2,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,d.rotateX(Math.PI/2),d.translateY(t/2-a/4),this.add(d),this._box=new s.Mesh(new s.BoxGeometry(a,a,a),this._lineMaterial),this._box.layers.mask=u.UI_LAYER_MASK,this._box.renderOrder=1/0,this._box.rotateX(Math.PI/2),this._box.translateY(t-a/2),this._box.rotateZ(o.x*Math.PI/2),this._box.rotateX(o.z*Math.PI/2),this.add(this._box);const g=new s.CylinderGeometry(.1,.1,t+a/2,3),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}update(e){this._box.scale.copy(new s.Vector3(1,1,1).sub(this.forwardVector).add(e.clone().multiply(this.forwardVector)))}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHoverAxis(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHoverAxis(this,!1)}onDragStart(){this.parent&&this.parent.onAxisDragStart(this)}onDrag(e){this.parent&&this.parent.onAxisDrag(this,e)}onDragEnd(){this.parent&&this.parent.onAxisDragEnd(this)}}class j extends s.Object3D{constructor(e){super();n(this,"isHoverable",!0);n(this,"children");n(this,"_controller");n(this,"_startScale");this.name="DIVEScaleGizmo",this.children=[],this._startScale=null,this._controller=e,this.add(new M("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new M("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new M("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}update(e){this.children.forEach(t=>{t.update(e)})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHoverAxis(e,t){this._startScale||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onAxisDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startScale=t.scale.clone(),this.handleHighlight(e.axis,!0,!0))}onAxisDrag(e,t){if(!this._startScale||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(void 0,void 0,this._startScale.clone().add(o))}onAxisDragEnd(e){this._startScale=null,this.handleHighlight(e.axis,!1,!1)}}class N extends s.Object3D{constructor(){super();n(this,"_meshX");n(this,"_meshY");n(this,"_meshZ");this.name="DIVEGizmoPlane";const e=new s.MeshBasicMaterial({transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1,side:2}),t=new s.PlaneGeometry(100,100,2,2),o=e.clone();o.color.set(16711680),this._meshX=new s.Mesh(t,o),this._meshX.layers.mask=u.UI_LAYER_MASK,this._meshX.rotateY(Math.PI/2);const h=new s.PlaneGeometry(100,100,2,2),a=e.clone();a.color.set(65280),this._meshY=new s.Mesh(h,a),this._meshY.layers.mask=u.UI_LAYER_MASK,this._meshY.rotateX(-Math.PI/2);const l=new s.PlaneGeometry(100,100,2,2),d=e.clone();d.color.set(255),this._meshZ=new s.Mesh(l,d),this._meshZ.layers.mask=u.UI_LAYER_MASK}get XPlane(){return this._meshX}get YPlane(){return this._meshY}get ZPlane(){return this._meshZ}assemble(e,t){if(this.clear(),e==="translate"||e==="scale")switch(t){case"x":this.add(this._meshY),this.add(this._meshZ);break;case"y":this.add(this._meshX),this.add(this._meshZ);break;case"z":this.add(this._meshX),this.add(this._meshY);break}else if(e==="rotate")switch(t){case"x":this.add(this._meshX);break;case"y":this.add(this._meshY);break;case"z":this.add(this._meshZ);break}}}class F extends s.Object3D{constructor(e){super();n(this,"_mode");n(this,"_gizmoNode");n(this,"_translateGizmo");n(this,"_rotateGizmo");n(this,"_scaleGizmo");n(this,"_gizmoPlane");n(this,"_object");this.name="DIVEGizmo",e.addEventListener("change",()=>{const t=e.getDistance()/2.5;this.scale.set(t,t,t)}),this._mode="translate",this._gizmoNode=new s.Object3D,this.add(this._gizmoNode),this._translateGizmo=new T(e),this._rotateGizmo=new Y(e),this._scaleGizmo=new j(e),this._gizmoPlane=new N,this._gizmoPlane.visible=!1,this._object=null}get mode(){return this._mode}set mode(e){this._mode=e,this.assemble()}set debug(e){this._translateGizmo.debug=e,this._rotateGizmo.debug=e,this._scaleGizmo.debug=e}get gizmoNode(){return this._gizmoNode}get gizmoPlane(){return this._gizmoPlane}get object(){return this._object}attach(e){return this._object=e,this.assemble(),this}detach(){return this._object=null,this.assemble(),this}onHover(e,t,o){o&&this._gizmoPlane.assemble(e,t)}onChange(e,t,o){this.object!==null&&(e&&(this.position.copy(e),this.object.position.copy(e)),t&&this.object.rotation.copy(t),o&&(this.object.scale.copy(o),this._scaleGizmo.update(o)))}assemble(){this._gizmoNode.clear(),this._gizmoPlane.clear(),this._translateGizmo.reset(),this._rotateGizmo.reset(),this._scaleGizmo.reset(),this.object!==null&&(this._mode==="translate"&&this._gizmoNode.add(this._translateGizmo),this._mode==="rotate"&&this._gizmoNode.add(this._rotateGizmo),this._mode==="scale"&&this._gizmoNode.add(this._scaleGizmo),this.add(this._gizmoPlane))}}class U{constructor(){n(this,"isMovable",!0)}}class K{constructor(){n(this,"isSelectable",!0)}}function X(r,i){return i.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(o=>{if(o==="constructor")return;const h=Object.getOwnPropertyDescriptor(e.prototype,o);Object.defineProperty(r.prototype,o,h)});const t=new e;Object.getOwnPropertyNames(t).forEach(o=>{const h=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r.prototype,o,h)})}),r}function f(r,i=new WeakMap){if(r===null||typeof r!="object")return r;if(i.has(r))return i.get(r);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const a=[];i.set(r,a);for(let l=0;l<r.length;l++)a[l]=f(r[l],i);return a}if(r instanceof Map){const a=new Map;i.set(r,a);for(const[l,d]of r)a.set(f(l,i),f(d,i));return a}if(r instanceof Set){const a=new Set;i.set(r,a);for(const l of r)a.add(f(l,i));return a}const e=r;if(typeof e.clone=="function"){const a=e.clone();return i.set(r,a),a}const t=Object.create(Object.getPrototypeOf(r));i.set(r,t);const o=Object.getOwnPropertyNames(r);for(const a of o){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}const h=Object.getOwnPropertySymbols(r);for(const a of h){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}return t}const I=(r,i)=>{if(Object.keys(r).length===0&&Object.keys(i).length===0)return{};if(typeof r!="object"||typeof i!="object")return i;let e={};return Object.keys(i).forEach(t=>{if(!Object.keys(r).includes(t)){e={...e,[t]:i[t]};return}if(Array.isArray(i[t])){if(!Array.isArray(r[t])){e={...e,[t]:i[t]};return}const o=r[t],h=i[t];if(o.length===0&&h.length===0){e={...e};return}if(o.length!==h.length){e={...e,[t]:i[t]};return}const a=[];if(h.forEach((l,d)=>{const g=I(o[d],h[d]);Object.keys(g).length&&a.push(h[d])}),Object.keys(a).length){e={...e,[t]:a};return}return}if(typeof i[t]=="object"){if(typeof r[t]!="object"){e={...e,[t]:i[t]};return}const o=I(r[t],i[t]);if(Object.keys(o).length){e={...e,[t]:o};return}}r[t]!==i[t]&&(e={...e,[t]:i[t]})}),e};function q(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function Z(r){return r.entityType==="primitive"}exports.BoundingBox=c.BoundingBox;exports.DIVE=c.DIVE;exports.DIVEAmbientLight=c.DIVEAmbientLight;exports.DIVECanvasLifecycleManager=c.DIVECanvasLifecycleManager;exports.DIVEClock=c.DIVEClock;exports.DIVEDefaultSettings=c.DIVEDefaultSettings;exports.DIVEEnvironment=c.DIVEEnvironment;exports.DIVEEnvironmentDefaultSettings=c.DIVEEnvironmentDefaultSettings;exports.DIVEFloor=c.DIVEFloor;exports.DIVEGrid=c.DIVEGrid;exports.DIVEGroup=c.DIVEGroup;exports.DIVEModel=c.DIVEModel;exports.DIVENode=c.DIVENode;exports.DIVEPointLight=c.DIVEPointLight;exports.DIVEPrimitive=c.DIVEPrimitive;exports.DIVERenderer=c.DIVERenderer;exports.DIVERendererDefaultSettings=c.DIVERendererDefaultSettings;exports.DIVERoot=c.DIVERoot;exports.DIVEScene=c.DIVEScene;exports.DIVESceneDefaultSettings=c.DIVESceneDefaultSettings;exports.DIVESceneLight=c.DIVESceneLight;exports.DIVEView=c.DIVEView;exports.FILE_TYPES=c.FILE_TYPES;exports.GRID_MAJOR_LINE_COLOR=c.GRID_MAJOR_LINE_COLOR;exports.GRID_MINOR_LINE_COLOR=c.GRID_MINOR_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=c.SUPPORTED_FILE_TYPES;exports.findSceneRecursive=c.findSceneRecursive;exports.COORDINATE_LAYER_MASK=u.COORDINATE_LAYER_MASK;exports.DEFAULT_LAYER_MASK=u.DEFAULT_LAYER_MASK;exports.DIVEPerspectiveCamera=u.DIVEPerspectiveCamera;exports.DIVEPerspectiveCameraDefaultSettings=u.DIVEPerspectiveCameraDefaultSettings;exports.HELPER_LAYER_MASK=u.HELPER_LAYER_MASK;exports.PRODUCT_LAYER_MASK=u.PRODUCT_LAYER_MASK;exports.UI_LAYER_MASK=u.UI_LAYER_MASK;exports.AxesColorBlue=_.AxesColorBlue;exports.AxesColorBlueLetter=_.AxesColorBlueLetter;exports.AxesColorGreen=_.AxesColorGreen;exports.AxesColorGreenLetter=_.AxesColorGreenLetter;exports.AxesColorRed=_.AxesColorRed;exports.AxesColorRedLetter=_.AxesColorRedLetter;exports.findInterface=V.findInterface;exports.implementsInterface=V.implementsInterface;exports.getFileTypeFromUri=y.getFileTypeFromUri;exports.isFileTypeSupported=y.isFileTypeSupported;exports.FileContentError=w.FileContentError;exports.NetworkError=w.NetworkError;exports.FileTypeError=A.FileTypeError;exports.ParseError=A.ParseError;exports.isModelSchema=x.isModelSchema;exports.isPovSchema=x.isPovSchema;exports.DIVEGizmo=F;exports.DIVEMath=S;exports.DIVEMovable=U;exports.DIVESelectable=K;exports.applyMixins=X;exports.deepClone=f;exports.getObjectDelta=I;exports.isGroupSchema=q;exports.isLightSchema=B;exports.isPrimitiveSchema=Z;
|
package/build/dive.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var S = Object.defineProperty;
|
|
2
2
|
var A = (r, s, t) => s in r ? S(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
|
|
3
3
|
var i = (r, s, t) => A(r, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
-
import { B as ot, b as ht, d as lt, e as ct, f as dt, D as pt, g as ut, h as ft, i as _t, j as gt, k as mt, c as Dt, l as Et, m as wt, n as yt, o as Mt, p as xt, q as It, r as Pt, s as Vt, t as bt, u as Ht, F as vt, G as zt, v as Ot, S as St, w as At } from "./chunks/FileTypes-
|
|
4
|
+
import { B as ot, b as ht, d as lt, e as ct, f as dt, D as pt, g as ut, h as ft, i as _t, j as gt, k as mt, c as Dt, l as Et, m as wt, n as yt, o as Mt, p as xt, q as It, r as Pt, s as Vt, t as bt, u as Ht, F as vt, G as zt, v as Ot, S as St, w as At } from "./chunks/FileTypes-DGNq8jnU.mjs";
|
|
5
5
|
import { U as d } from "./chunks/PerspectiveCamera-B5TvUzTa.mjs";
|
|
6
6
|
import { C as Rt, b as Tt, D as Yt, a as jt, H as Lt, P as Ct } from "./chunks/PerspectiveCamera-B5TvUzTa.mjs";
|
|
7
7
|
import { A as I, a as P, b as V } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
8
8
|
import { e as Xt, d as Ft, c as Zt } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
9
9
|
import { Object3D as f, Color as b, Vector3 as c, TorusGeometry as H, MeshBasicMaterial as g, Mesh as p, MathUtils as z, Euler as G, CylinderGeometry as D, BoxGeometry as R, PlaneGeometry as w } from "three/webgpu";
|
|
10
10
|
import { f as Qt, i as Wt } from "./chunks/findInterface-DbJ5qzbc.mjs";
|
|
11
|
-
import { g as Ut, i as Bt } from "./chunks/isFileTypeSupported-
|
|
11
|
+
import { g as Ut, i as Bt } from "./chunks/isFileTypeSupported-CyuZhxpo.mjs";
|
|
12
12
|
import { F as Jt, N as $t } from "./chunks/network-error-BONfHWQq.mjs";
|
|
13
13
|
import { F as ee, P as re } from "./chunks/parse-error-DfOPyLWM.mjs";
|
|
14
14
|
import { i as ie, a as ne } from "./chunks/PovSchema-DWWvr_ED.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-Df_Q2uWS.cjs");require("three/examples/jsm/loaders/DRACOLoader.js");const w=require("../../chunks/AssetExporter-Cdxb04b3.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-CyuWDXoP.mjs";
|
|
7
7
|
import "three/examples/jsm/loaders/DRACOLoader.js";
|
|
8
8
|
import { A as f } from "../../chunks/AssetExporter-DLL_vJae.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-BzdQ6WmJ.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
|
|
@@ -11,6 +11,11 @@ export declare class Chunk {
|
|
|
11
11
|
get createdAt(): Date;
|
|
12
12
|
get updatedAt(): Date;
|
|
13
13
|
get arrayBuffer(): ArrayBuffer | null;
|
|
14
|
+
private _getHeader;
|
|
15
|
+
private _concatChunks;
|
|
16
|
+
private _readBodyWithReader;
|
|
17
|
+
private _logLoad;
|
|
18
|
+
private _logLoadError;
|
|
14
19
|
constructor(_uri: string);
|
|
15
20
|
load(): Promise<ArrayBuffer>;
|
|
16
21
|
}
|
|
@@ -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-Df_Q2uWS.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-CyuWDXoP.mjs";
|
|
2
|
+
import { D as s, a as t } from "../../chunks/AssetLoader-CyuWDXoP.mjs";
|
|
3
3
|
export {
|
|
4
4
|
o as AssetLoader,
|
|
5
5
|
s as DRACOWorker,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-EnUNPee7.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var c=(s,r,e)=>r in s?p(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e;var o=(s,r,e)=>c(s,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("three/webgpu");require("../../chunks/FileTypes-
|
|
1
|
+
"use strict";var p=Object.defineProperty;var c=(s,r,e)=>r in s?p(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e;var o=(s,r,e)=>c(s,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("three/webgpu");require("../../chunks/FileTypes-EnUNPee7.cjs");const h=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const n=require("../../chunks/AxisHelperColors-BrGqktN5.cjs"),_=require("three-spritetext");class l extends t.Object3D{constructor(){super();o(this,"_axesHelper");this._axesHelper=new t.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 t.Color(n.AxesColorRed),new t.Color(n.AxesColorGreen),new t.Color(n.AxesColorBlue));const e=new _("X",.2,n.AxesColorRedLetter),a=new _("Y",.2,n.AxesColorGreenLetter),i=new _("Z",.2,n.AxesColorBlueLetter);e.layers.mask=h.COORDINATE_LAYER_MASK,a.layers.mask=h.COORDINATE_LAYER_MASK,i.layers.mask=h.COORDINATE_LAYER_MASK,e.position.set(.7,0,0),a.position.set(0,.7,0),i.position.set(0,0,.7),this._axesHelper.add(e),this._axesHelper.add(a),this._axesHelper.add(i),this.add(this._axesHelper)}setFromCameraMatrix(e){this._axesHelper.rotation.setFromRotationMatrix(new t.Matrix4().extractRotation(e).invert())}}class d{constructor(r,e,a){o(this,"uuid",t.MathUtils.generateUUID());o(this,"_axes");o(this,"_orthographicCamera");o(this,"_restoreViewport",new t.Vector4);this._renderer=r,this._scene=e,this._camera=a,this._orthographicCamera=new t.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 l,this._axes.name="OrientationDisplayAxes",this._scene.add(this._axes)}tick(){var i;const r=this._scene.background??null,e=this._renderer.webgpurenderer.autoClear;this._scene.background=null,this._renderer.webgpurenderer.getViewport(this._restoreViewport);const a=((i=this._renderer.webgpurenderer.domElement)==null?void 0:i.clientHeight)??this._restoreViewport.w;this._renderer.webgpurenderer.setViewport(0,Math.max(0,a-150),150,150),this._renderer.webgpurenderer.autoClear=!1,this._axes.setFromCameraMatrix(this._camera.matrix),this._renderer.webgpurenderer.render(this._scene,this._orthographicCamera),this._renderer.webgpurenderer.setViewport(this._restoreViewport),this._renderer.webgpurenderer.autoClear=e,this._scene.background=r}dispose(){this._scene.remove(this._axes),this._scene.remove(this._orthographicCamera)}}exports.OrientationDisplay=d;exports.OrientationDisplayAxes=l;
|
|
@@ -2,7 +2,7 @@ var p = Object.defineProperty;
|
|
|
2
2
|
var _ = (t, r, e) => r in t ? p(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
|
|
3
3
|
var i = (t, r, e) => _(t, typeof r != "symbol" ? r + "" : r, e);
|
|
4
4
|
import { Object3D as l, AxesHelper as c, Color as n, Matrix4 as d, OrthographicCamera as m, MathUtils as x, Vector4 as w } from "three/webgpu";
|
|
5
|
-
import "../../chunks/FileTypes-
|
|
5
|
+
import "../../chunks/FileTypes-DGNq8jnU.mjs";
|
|
6
6
|
import { C as o } from "../../chunks/PerspectiveCamera-B5TvUzTa.mjs";
|
|
7
7
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
8
8
|
import "three/tsl";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../chunks/FileTypes-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../chunks/FileTypes-EnUNPee7.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const a={...o.DIVEDefaultSettings},l=async(n,c)=>{const e=new o.DIVE(c);e.mainView.camera.position.set(0,1,2);const i=await new o.DIVEModel().setFromURL(n);e.scene.root.add(i),i.placeOnFloor();const t=new o.OrbitController(e.mainView.camera,e.mainView.canvas);t.focusObject(i),e.clock.addTicker(t);const s=Object.assign(e,{orbitController:t,model:i}),r=e.dispose.bind(e);return s.dispose=async()=>{t.dispose(),await r()},s};exports.QuickView=l;exports.QuickViewDefaultSettings=a;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as c, b as r, c as l, O as m } from "../../chunks/FileTypes-
|
|
1
|
+
import { D as c, b as r, c as l, O as m } from "../../chunks/FileTypes-DGNq8jnU.mjs";
|
|
2
2
|
import "three/webgpu";
|
|
3
3
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
4
4
|
import "three/tsl";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var $d=Object.defineProperty;var Hd=(d,g,o)=>g in d?$d(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var rn=(d,g,o)=>Hd(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qd=require("three/webgpu"),zd=require("../../chunks/FileTypes-
|
|
1
|
+
"use strict";var $d=Object.defineProperty;var Hd=(d,g,o)=>g in d?$d(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var rn=(d,g,o)=>Hd(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qd=require("three/webgpu"),zd=require("../../chunks/FileTypes-EnUNPee7.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const Mi=require("../../chunks/PovSchema-Co9FznEz.cjs"),Ao={};function G(d,g){Ao[d]=g}function xo(d){return Ao[d]}class F{constructor(g,o){rn(this,"_payload");rn(this,"_dependencies");this._payload=g,this._dependencies=o}static define({description:g,execute:o}){return class extends F{constructor(m,N){super(m,N);rn(this,"_description",g);rn(this,"_payload");this._payload=m}execute(){return o(this._payload,this._dependencies)}}}}const mo=F.define({description:"Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)",execute:async(d,{getARSystem:g})=>g().then(o=>{o.launch(d.uri,d.options)})});G("LAUNCH_AR",mo);const Eo=F.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(d,{engine:g,controller:o})=>{const S=new zd.BoundingBox(g.scene.root,!1,65280);return o.computeEncompassingView(S)}});G("COMPUTE_ENCOMPASSING_VIEW",Eo);const So=F.define({description:"Gets the current camera position and target.",execute:(d,{controller:g})=>({position:g.object.position.clone(),target:g.target.clone()})});G("GET_CAMERA_TRANSFORM",So);const bo=F.define({description:"Moves the camera to a new position and target.",execute:async(d,{controller:g,registered:o,getAnimationSystem:S,engine:m})=>{const N=await S();let q={x:0,y:0,z:0},un={x:0,y:0,z:0};if("id"in d){const Gn=o.get(d.id);if(!Gn)throw new Error(`POV with id ${d.id} not registered. Registered: ${o}`);if(!Mi.isPovSchema(Gn))throw new Error(`Object with id ${d.id} is not a POV. Object: ${Gn}`);q=Gn.position,un=Gn.target}else q=d.position,un=d.target;m.clock.hasTicker(N)||m.clock.addTicker(N),g.enabled=!0;const jn=await N.fromTargets([{object:g.object.position,to:q},{object:g.target,to:un}],d.duration,{easing:N.Easing.Quadratic.Out,onUpdate:()=>{g.object.lookAt(g.target)},onComplete:()=>{g.enabled=!d.locked}});return jn.play(),{stop:()=>jn.stop()}}});G("MOVE_CAMERA",bo);const Oo=F.define({description:"Sets the camera layer to a certain layer.",execute:(d,{controller:g})=>{"setCameraLayer"in g.object&&g.object.setCameraLayer(d.layer)}});G("SET_CAMERA_LAYER",Oo);const To=F.define({description:"Sets the camera position and target.",execute:(d,{controller:g})=>{g.object.position.copy(d.position),g.target.copy(d.target),g.update()}});G("SET_CAMERA_TRANSFORM",To);const Co=F.define({description:"Zooms the camera in or out by a certain amount.",execute:(d,{controller:g})=>{d.direction==="IN"&&g.zoomIn(d.by),d.direction==="OUT"&&g.zoomOut(d.by)}});G("ZOOM_CAMERA",Co);const Ro=F.define({description:"Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.",execute:async(d,{registered:g,getMediaCreator:o})=>{const S=await o();if("id"in d){const m=g.get(d.id);if(!m)throw new Error(`Object with id ${d.id} not registered. Registered: ${g}`);if(!Mi.isPovSchema(m))throw new Error(`Object with id ${d.id} is not a POV. Object: ${m}`);const{resolution:N}=d,{position:q,target:un}=m;return S.generateMedia({position:q,target:un,resolution:N})}return S.generateMedia(d)}});G("GENERATE_MEDIA",Ro);const Io=F.define({description:"Adds an object to the scene.",execute:(d,{engine:g,registered:o})=>{o.get(d.id)||(d.parentId===void 0&&(d.parentId=null),o.set(d.id,d),g.scene.root.addSceneObject(d))}});G("ADD_OBJECT",Io);var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lt={exports:{}};/**
|
|
2
2
|
* @license
|
|
3
3
|
* Lodash <https://lodash.com/>
|
|
4
4
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
@@ -2,7 +2,7 @@ var _p = Object.defineProperty;
|
|
|
2
2
|
var pp = (p, g, o) => g in p ? _p(p, g, { enumerable: !0, configurable: !0, writable: !0, value: o }) : p[g] = o;
|
|
3
3
|
var rn = (p, g, o) => pp(p, typeof g != "symbol" ? g + "" : g, o);
|
|
4
4
|
import { MathUtils as dp } from "three/webgpu";
|
|
5
|
-
import { B as vp } from "../../chunks/FileTypes-
|
|
5
|
+
import { B as vp } from "../../chunks/FileTypes-DGNq8jnU.mjs";
|
|
6
6
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
7
7
|
import "three/tsl";
|
|
8
8
|
import { a as vo, i as wp } from "../../chunks/PovSchema-DWWvr_ED.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var S=(n,t,e)=>t in n?y(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>S(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("three/webgpu");require("../../chunks/FileTypes-Dol5v9ki.cjs");const h=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("../../chunks/findInterface-C6mrvf_t.cjs"),T=require("three/examples/jsm/controls/TransformControls.js"),d=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class m{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){var e,s,i;this._selected!==t&&(this._selected&&((s=(e=this._selected).onDeselect)==null||s.call(e)),this._selected=t,(i=t.onSelect)==null||i.call(t),this.notifyListeners())}deselect(){var t,e;this._selected&&((e=(t=this._selected).onDeselect)==null||e.call(t),this._selected=null,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,a,l,p,f,v;const e=t.modelIntersects[0],s=_.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){(a=(o=this._hovered).onPointerLeave)==null||a.call(o),(l=s.onPointerEnter)==null||l.call(s,e),this._hovered=s;return}(p=s.onPointerOver)==null||p.call(s,e);return}this._hovered&&((v=(f=this._hovered).onPointerLeave)==null||v.call(f),this._hovered=null)}}const P=n=>n.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.modelIntersects[0],s=_.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=n=>n.name==="transform";class u extends c.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||e.uiIntersects.length>0&&e.uiIntersects.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&&_.implementsInterface(e,"isMovable")?this.attachGizmo(e):this._gizmo.detach()}attachGizmo(e){_.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,this._controller.domElement);return e.mode="translate",e.getHelper().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,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveStart)==null||o.call(i))}),e.addEventListener("objectChange",()=>{var i,o;if(_.implementsInterface(e.object,"isMovable")){if((o=(i=e.object).onMove)==null||o.call(i),this._scaleLinked&&e.object){const a=e.object.scale,l=(a.x+a.y+a.z)/3;e.object.scale.set(l,l,l)}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,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveEnd)==null||o.call(i))}),e}}const C=.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 c.Vector3);r(this,"_dragCurrent",new c.Vector3);r(this,"_dragEnd",new c.Vector3);r(this,"_dragDelta",new c.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new c.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=_.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),this._dragging||t.lastPointerDown.distanceTo(t.pointer)>C&&this.startDrag(t),this._dragging))return this.updateDrag(t),!0}onPointerUp(t){this._dragging&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),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 E=.001;class M{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,"_productLayerMask");r(this,"_uiLayerMask");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 m,this._raycaster=new c.Raycaster,this._pointer=new c.Vector2,this._lastPointerDown=new c.Vector2,this._productLayerMask=new c.Layers,this._productLayerMask.set(Math.log2(h.PRODUCT_LAYER_MASK)),this._uiLayerMask=new c.Layers,this._uiLayerMask.set(Math.log2(h.UI_LAYER_MASK)),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 a of this._sortedActiveTools)if((i=a.onPointerUp)==null?void 0:i.call(a,e))break;if(s){for(const a of this._sortedActiveTools)if((o=a.onClick)==null?void 0:o.call(a,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){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.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)}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(){this._raycaster.layers.mask=h.PRODUCT_LAYER_MASK|h.UI_LAYER_MASK;const t=this._scene.children.filter(e=>e.visible&&"isMesh"in e&&e.isMesh);return this._raycaster.intersectObjects(t,!0)}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)>E}}exports.DIVESelectTool=g;exports.DIVETransformTool=u;exports.DragTool=D;exports.HoverTool=b;exports.SelectTool=g;exports.SelectionState=m;exports.Toolbox=M;exports.TransformTool=u;exports.isSelectTool=P;exports.isTransformTool=w;
|
|
1
|
+
"use strict";var y=Object.defineProperty;var S=(n,t,e)=>t in n?y(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>S(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("three/webgpu");require("../../chunks/FileTypes-EnUNPee7.cjs");const h=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("../../chunks/findInterface-C6mrvf_t.cjs"),T=require("three/examples/jsm/controls/TransformControls.js"),d=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class m{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){var e,s,i;this._selected!==t&&(this._selected&&((s=(e=this._selected).onDeselect)==null||s.call(e)),this._selected=t,(i=t.onSelect)==null||i.call(t),this.notifyListeners())}deselect(){var t,e;this._selected&&((e=(t=this._selected).onDeselect)==null||e.call(t),this._selected=null,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,a,l,p,f,v;const e=t.modelIntersects[0],s=_.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){(a=(o=this._hovered).onPointerLeave)==null||a.call(o),(l=s.onPointerEnter)==null||l.call(s,e),this._hovered=s;return}(p=s.onPointerOver)==null||p.call(s,e);return}this._hovered&&((v=(f=this._hovered).onPointerLeave)==null||v.call(f),this._hovered=null)}}const P=n=>n.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.modelIntersects[0],s=_.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=n=>n.name==="transform";class u extends c.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||e.uiIntersects.length>0&&e.uiIntersects.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&&_.implementsInterface(e,"isMovable")?this.attachGizmo(e):this._gizmo.detach()}attachGizmo(e){_.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,this._controller.domElement);return e.mode="translate",e.getHelper().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,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveStart)==null||o.call(i))}),e.addEventListener("objectChange",()=>{var i,o;if(_.implementsInterface(e.object,"isMovable")){if((o=(i=e.object).onMove)==null||o.call(i),this._scaleLinked&&e.object){const a=e.object.scale,l=(a.x+a.y+a.z)/3;e.object.scale.set(l,l,l)}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,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveEnd)==null||o.call(i))}),e}}const C=.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 c.Vector3);r(this,"_dragCurrent",new c.Vector3);r(this,"_dragEnd",new c.Vector3);r(this,"_dragDelta",new c.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new c.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=_.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),this._dragging||t.lastPointerDown.distanceTo(t.pointer)>C&&this.startDrag(t),this._dragging))return this.updateDrag(t),!0}onPointerUp(t){this._dragging&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),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 E=.001;class M{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,"_productLayerMask");r(this,"_uiLayerMask");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 m,this._raycaster=new c.Raycaster,this._pointer=new c.Vector2,this._lastPointerDown=new c.Vector2,this._productLayerMask=new c.Layers,this._productLayerMask.set(Math.log2(h.PRODUCT_LAYER_MASK)),this._uiLayerMask=new c.Layers,this._uiLayerMask.set(Math.log2(h.UI_LAYER_MASK)),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 a of this._sortedActiveTools)if((i=a.onPointerUp)==null?void 0:i.call(a,e))break;if(s){for(const a of this._sortedActiveTools)if((o=a.onClick)==null?void 0:o.call(a,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){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.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)}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(){this._raycaster.layers.mask=h.PRODUCT_LAYER_MASK|h.UI_LAYER_MASK;const t=this._scene.children.filter(e=>e.visible&&"isMesh"in e&&e.isMesh);return this._raycaster.intersectObjects(t,!0)}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)>E}}exports.DIVESelectTool=g;exports.DIVETransformTool=u;exports.DragTool=D;exports.HoverTool=b;exports.SelectTool=g;exports.SelectionState=m;exports.Toolbox=M;exports.TransformTool=u;exports.isSelectTool=P;exports.isTransformTool=w;
|
|
@@ -2,7 +2,7 @@ var S = Object.defineProperty;
|
|
|
2
2
|
var w = (n, t, e) => t in n ? S(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
3
|
var o = (n, t, e) => w(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { EventDispatcher as T, Vector3 as l, Raycaster as P, Vector2 as f, Layers as m } from "three/webgpu";
|
|
5
|
-
import "../../chunks/FileTypes-
|
|
5
|
+
import "../../chunks/FileTypes-DGNq8jnU.mjs";
|
|
6
6
|
import { P as _, U as d } from "../../chunks/PerspectiveCamera-B5TvUzTa.mjs";
|
|
7
7
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
8
8
|
import "three/tsl";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var _=(s,e,r)=>e in s?c(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var t=(s,e,r)=>_(s,typeof e!="symbol"?e+"":e,r);require("./FileTypes-Dol5v9ki.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const h=require("./network-error-CdDXil5g.cjs");class o{constructor(e){t(this,"_promise");t(this,"_resolve");t(this,"_arrayBuffer",null);t(this,"_size",0);t(this,"_createdAt");t(this,"_updatedAt");this._uri=e,this._promise=new Promise(r=>{this._resolve=r}),this._createdAt=new Date,this._updatedAt=new Date}get promise(){return this._promise}get size(){return this._size}get createdAt(){return this._createdAt}get updatedAt(){return this._updatedAt}get arrayBuffer(){return this._arrayBuffer}async load(){const e=await fetch(this._uri);if(console.log("response",e),!e.ok)throw new h.NetworkError(this._uri);try{this._arrayBuffer=await e.arrayBuffer(),console.log("this._arrayBuffer",this._arrayBuffer),this._size+=this._arrayBuffer.byteLength,console.log("this._size",this._size),this._updatedAt=new Date,console.log("this._updatedAt",this._updatedAt)}catch{throw new h.FileContentError(this._uri)}return console.log("this._resolve",this._resolve),this._resolve(this._arrayBuffer),console.log("this._arrayBuffer",this._arrayBuffer),this._arrayBuffer}}class u{constructor(){t(this,"_cache",new Map)}get(){return this._cache}create(e){const r=new o(e);return this._cache.set(e,r),r}write(e,r){this._cache.set(e,r)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(r=>{this._cache.delete(r)})}clear(){this._cache.clear()}}const a=Symbol.for("@shopware-ag/dive/assetcache"),i=globalThis;i[a]||(i[a]=new u);const n=i[a];exports.AssetCache=n;exports.Chunk=o;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
var o = Object.defineProperty;
|
|
2
|
-
var h = (s, e, t) => e in s ? o(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
-
var r = (s, e, t) => h(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import "./FileTypes-g6ZqzZse.mjs";
|
|
5
|
-
import "three/webgpu";
|
|
6
|
-
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
7
|
-
import "three/tsl";
|
|
8
|
-
import { N as c, F as _ } from "./network-error-BONfHWQq.mjs";
|
|
9
|
-
class n {
|
|
10
|
-
constructor(e) {
|
|
11
|
-
r(this, "_promise");
|
|
12
|
-
r(this, "_resolve");
|
|
13
|
-
r(this, "_arrayBuffer", null);
|
|
14
|
-
// metadata
|
|
15
|
-
r(this, "_size", 0);
|
|
16
|
-
r(this, "_createdAt");
|
|
17
|
-
r(this, "_updatedAt");
|
|
18
|
-
this._uri = e, this._promise = new Promise((t) => {
|
|
19
|
-
this._resolve = t;
|
|
20
|
-
}), this._createdAt = /* @__PURE__ */ new Date(), this._updatedAt = /* @__PURE__ */ new Date();
|
|
21
|
-
}
|
|
22
|
-
get promise() {
|
|
23
|
-
return this._promise;
|
|
24
|
-
}
|
|
25
|
-
get size() {
|
|
26
|
-
return this._size;
|
|
27
|
-
}
|
|
28
|
-
get createdAt() {
|
|
29
|
-
return this._createdAt;
|
|
30
|
-
}
|
|
31
|
-
get updatedAt() {
|
|
32
|
-
return this._updatedAt;
|
|
33
|
-
}
|
|
34
|
-
get arrayBuffer() {
|
|
35
|
-
return this._arrayBuffer;
|
|
36
|
-
}
|
|
37
|
-
async load() {
|
|
38
|
-
const e = await fetch(this._uri);
|
|
39
|
-
if (console.log("response", e), !e.ok)
|
|
40
|
-
throw new c(this._uri);
|
|
41
|
-
try {
|
|
42
|
-
this._arrayBuffer = await e.arrayBuffer(), console.log("this._arrayBuffer", this._arrayBuffer), this._size += this._arrayBuffer.byteLength, console.log("this._size", this._size), this._updatedAt = /* @__PURE__ */ new Date(), console.log("this._updatedAt", this._updatedAt);
|
|
43
|
-
} catch {
|
|
44
|
-
throw new _(this._uri);
|
|
45
|
-
}
|
|
46
|
-
return console.log("this._resolve", this._resolve), this._resolve(this._arrayBuffer), console.log("this._arrayBuffer", this._arrayBuffer), this._arrayBuffer;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
class u {
|
|
50
|
-
constructor() {
|
|
51
|
-
r(this, "_cache", /* @__PURE__ */ new Map());
|
|
52
|
-
}
|
|
53
|
-
get() {
|
|
54
|
-
return this._cache;
|
|
55
|
-
}
|
|
56
|
-
create(e) {
|
|
57
|
-
const t = new n(e);
|
|
58
|
-
return this._cache.set(e, t), t;
|
|
59
|
-
}
|
|
60
|
-
write(e, t) {
|
|
61
|
-
this._cache.set(e, t);
|
|
62
|
-
}
|
|
63
|
-
read(e) {
|
|
64
|
-
return this._cache.get(e) ?? null;
|
|
65
|
-
}
|
|
66
|
-
delete(...e) {
|
|
67
|
-
e.forEach((t) => {
|
|
68
|
-
this._cache.delete(t);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
clear() {
|
|
72
|
-
this._cache.clear();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const a = Symbol.for("@shopware-ag/dive/assetcache"), i = globalThis;
|
|
76
|
-
i[a] || (i[a] = new u());
|
|
77
|
-
const A = i[a];
|
|
78
|
-
export {
|
|
79
|
-
A,
|
|
80
|
-
n as C
|
|
81
|
-
};
|