@shopware-ag/dive 1.16.13 → 1.16.14-beta.0
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/package.json +1 -1
- package/build/dive.cjs +0 -3280
- package/build/dive.cjs.map +0 -1
- package/build/dive.d.cts +0 -1083
- package/build/dive.d.ts +0 -1083
- package/build/dive.js +0 -3298
- package/build/dive.js.map +0 -1
package/build/dive.js
DELETED
|
@@ -1,3298 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
var __esm = (fn, res) => function __init() {
|
|
23
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
24
|
-
};
|
|
25
|
-
var __export = (target, all) => {
|
|
26
|
-
for (var name in all)
|
|
27
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
-
};
|
|
29
|
-
var __copyProps = (to, from, except, desc) => {
|
|
30
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
-
for (let key of __getOwnPropNames(from))
|
|
32
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
-
}
|
|
35
|
-
return to;
|
|
36
|
-
};
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var __async = (__this, __arguments, generator) => {
|
|
39
|
-
return new Promise((resolve, reject) => {
|
|
40
|
-
var fulfilled = (value) => {
|
|
41
|
-
try {
|
|
42
|
-
step(generator.next(value));
|
|
43
|
-
} catch (e) {
|
|
44
|
-
reject(e);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var rejected = (value) => {
|
|
48
|
-
try {
|
|
49
|
-
step(generator.throw(value));
|
|
50
|
-
} catch (e) {
|
|
51
|
-
reject(e);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
55
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// src/constant/VisibilityLayerMask.ts
|
|
60
|
-
var DEFAULT_LAYER_MASK, COORDINATE_LAYER_MASK, UI_LAYER_MASK, HELPER_LAYER_MASK, PRODUCT_LAYER_MASK;
|
|
61
|
-
var init_VisibilityLayerMask = __esm({
|
|
62
|
-
"src/constant/VisibilityLayerMask.ts"() {
|
|
63
|
-
"use strict";
|
|
64
|
-
DEFAULT_LAYER_MASK = 1;
|
|
65
|
-
COORDINATE_LAYER_MASK = 2;
|
|
66
|
-
UI_LAYER_MASK = 4;
|
|
67
|
-
HELPER_LAYER_MASK = 8;
|
|
68
|
-
PRODUCT_LAYER_MASK = 16;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// src/helper/isInterface/implementsInterface.ts
|
|
73
|
-
function implementsInterface(object, discriminator) {
|
|
74
|
-
if (!object) return false;
|
|
75
|
-
return discriminator in object;
|
|
76
|
-
}
|
|
77
|
-
var init_implementsInterface = __esm({
|
|
78
|
-
"src/helper/isInterface/implementsInterface.ts"() {
|
|
79
|
-
"use strict";
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// src/helper/findInterface/findInterface.ts
|
|
84
|
-
function findInterface(object, discriminator) {
|
|
85
|
-
if (!object) return void 0;
|
|
86
|
-
if (implementsInterface(object, discriminator)) return object;
|
|
87
|
-
return findInterface(object.parent, discriminator);
|
|
88
|
-
}
|
|
89
|
-
var init_findInterface = __esm({
|
|
90
|
-
"src/helper/findInterface/findInterface.ts"() {
|
|
91
|
-
"use strict";
|
|
92
|
-
init_implementsInterface();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// src/toolbox/BaseTool.ts
|
|
97
|
-
import { Raycaster, Vector2, Vector3 } from "three";
|
|
98
|
-
var DIVEBaseTool;
|
|
99
|
-
var init_BaseTool = __esm({
|
|
100
|
-
"src/toolbox/BaseTool.ts"() {
|
|
101
|
-
"use strict";
|
|
102
|
-
init_VisibilityLayerMask();
|
|
103
|
-
init_findInterface();
|
|
104
|
-
DIVEBaseTool = class {
|
|
105
|
-
constructor(scene, controller) {
|
|
106
|
-
this.POINTER_DRAG_THRESHOLD = 1e-3;
|
|
107
|
-
this.name = "BaseTool";
|
|
108
|
-
this._canvas = controller.domElement;
|
|
109
|
-
this._scene = scene;
|
|
110
|
-
this._controller = controller;
|
|
111
|
-
this._pointer = new Vector2();
|
|
112
|
-
this._pointerPrimaryDown = false;
|
|
113
|
-
this._pointerMiddleDown = false;
|
|
114
|
-
this._pointerSecondaryDown = false;
|
|
115
|
-
this._lastPointerDown = new Vector2();
|
|
116
|
-
this._lastPointerUp = new Vector2();
|
|
117
|
-
this._raycaster = new Raycaster();
|
|
118
|
-
this._raycaster.layers.mask = PRODUCT_LAYER_MASK | UI_LAYER_MASK;
|
|
119
|
-
this._intersects = [];
|
|
120
|
-
this._hovered = null;
|
|
121
|
-
this._dragging = false;
|
|
122
|
-
this._dragStart = new Vector3();
|
|
123
|
-
this._dragCurrent = new Vector3();
|
|
124
|
-
this._dragEnd = new Vector3();
|
|
125
|
-
this._dragDelta = new Vector3();
|
|
126
|
-
this._draggable = null;
|
|
127
|
-
this._dragRaycastOnObjects = null;
|
|
128
|
-
}
|
|
129
|
-
get _pointerAnyDown() {
|
|
130
|
-
return this._pointerPrimaryDown || this._pointerMiddleDown || this._pointerSecondaryDown;
|
|
131
|
-
}
|
|
132
|
-
Activate() {
|
|
133
|
-
}
|
|
134
|
-
Deactivate() {
|
|
135
|
-
}
|
|
136
|
-
onPointerDown(e) {
|
|
137
|
-
var _a;
|
|
138
|
-
switch (e.button) {
|
|
139
|
-
case 0: {
|
|
140
|
-
this._pointerPrimaryDown = true;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
case 1: {
|
|
144
|
-
this._pointerMiddleDown = true;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case 2: {
|
|
148
|
-
this._pointerSecondaryDown = true;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
default: {
|
|
152
|
-
console.warn(
|
|
153
|
-
"DIVEBaseTool.onPointerDown: Unknown button: " + e.button
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
this._lastPointerDown.copy(this._pointer);
|
|
158
|
-
this._draggable = findInterface(
|
|
159
|
-
(_a = this._intersects[0]) == null ? void 0 : _a.object,
|
|
160
|
-
"isDraggable"
|
|
161
|
-
) || null;
|
|
162
|
-
}
|
|
163
|
-
onDragStart(e) {
|
|
164
|
-
if (!this._draggable) return;
|
|
165
|
-
if (this._dragRaycastOnObjects !== null) {
|
|
166
|
-
this._intersects = this._raycaster.intersectObjects(
|
|
167
|
-
this._dragRaycastOnObjects,
|
|
168
|
-
true
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
if (this._intersects.length === 0) return;
|
|
172
|
-
this._dragStart.copy(this._intersects[0].point.clone());
|
|
173
|
-
this._dragCurrent.copy(this._intersects[0].point.clone());
|
|
174
|
-
this._dragEnd.copy(this._dragStart.clone());
|
|
175
|
-
this._dragDelta.set(0, 0, 0);
|
|
176
|
-
if (this._draggable && this._draggable.onDragStart) {
|
|
177
|
-
this._draggable.onDragStart({
|
|
178
|
-
dragStart: this._dragStart,
|
|
179
|
-
dragCurrent: this._dragCurrent,
|
|
180
|
-
dragEnd: this._dragEnd,
|
|
181
|
-
dragDelta: this._dragDelta
|
|
182
|
-
});
|
|
183
|
-
this._dragging = true;
|
|
184
|
-
this._controller.enabled = false;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
onPointerMove(e) {
|
|
188
|
-
var _a;
|
|
189
|
-
this._pointer.x = e.offsetX / this._canvas.clientWidth * 2 - 1;
|
|
190
|
-
this._pointer.y = -(e.offsetY / this._canvas.clientHeight) * 2 + 1;
|
|
191
|
-
this._raycaster.setFromCamera(this._pointer, this._controller.object);
|
|
192
|
-
this._intersects = this.raycast(this._scene.children);
|
|
193
|
-
const hoverable = findInterface(
|
|
194
|
-
(_a = this._intersects[0]) == null ? void 0 : _a.object,
|
|
195
|
-
"isHoverable"
|
|
196
|
-
);
|
|
197
|
-
if (this._intersects[0] && hoverable) {
|
|
198
|
-
if (!this._hovered) {
|
|
199
|
-
if (hoverable.onPointerEnter)
|
|
200
|
-
hoverable.onPointerEnter(this._intersects[0]);
|
|
201
|
-
this._hovered = hoverable;
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (this._hovered.uuid !== hoverable.uuid) {
|
|
205
|
-
if (this._hovered.onPointerLeave)
|
|
206
|
-
this._hovered.onPointerLeave();
|
|
207
|
-
if (hoverable.onPointerEnter)
|
|
208
|
-
hoverable.onPointerEnter(this._intersects[0]);
|
|
209
|
-
this._hovered = hoverable;
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (hoverable.onPointerOver)
|
|
213
|
-
hoverable.onPointerOver(this._intersects[0]);
|
|
214
|
-
this._hovered = hoverable;
|
|
215
|
-
} else {
|
|
216
|
-
if (this._hovered) {
|
|
217
|
-
if (this._hovered.onPointerLeave)
|
|
218
|
-
this._hovered.onPointerLeave();
|
|
219
|
-
}
|
|
220
|
-
this._hovered = null;
|
|
221
|
-
}
|
|
222
|
-
if (this._pointerAnyDown) {
|
|
223
|
-
if (!this._dragging) {
|
|
224
|
-
this.onDragStart(e);
|
|
225
|
-
}
|
|
226
|
-
this.onDrag(e);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
onDrag(e) {
|
|
230
|
-
if (this._dragRaycastOnObjects !== null) {
|
|
231
|
-
this._intersects = this._raycaster.intersectObjects(
|
|
232
|
-
this._dragRaycastOnObjects,
|
|
233
|
-
true
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
const intersect = this._intersects[0];
|
|
237
|
-
if (!intersect) return;
|
|
238
|
-
this._dragCurrent.copy(intersect.point.clone());
|
|
239
|
-
this._dragEnd.copy(intersect.point.clone());
|
|
240
|
-
this._dragDelta.subVectors(
|
|
241
|
-
this._dragCurrent.clone(),
|
|
242
|
-
this._dragStart.clone()
|
|
243
|
-
);
|
|
244
|
-
if (this._draggable && this._draggable.onDrag) {
|
|
245
|
-
this._draggable.onDrag({
|
|
246
|
-
dragStart: this._dragStart,
|
|
247
|
-
dragCurrent: this._dragCurrent,
|
|
248
|
-
dragEnd: this._dragEnd,
|
|
249
|
-
dragDelta: this._dragDelta
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
onPointerUp(e) {
|
|
254
|
-
if (this.pointerWasDragged() || this._dragging) {
|
|
255
|
-
if (this._draggable) {
|
|
256
|
-
this.onDragEnd(e);
|
|
257
|
-
}
|
|
258
|
-
} else {
|
|
259
|
-
this.onClick(e);
|
|
260
|
-
}
|
|
261
|
-
switch (e.button) {
|
|
262
|
-
case 0:
|
|
263
|
-
this._pointerPrimaryDown = false;
|
|
264
|
-
break;
|
|
265
|
-
case 1:
|
|
266
|
-
this._pointerMiddleDown = false;
|
|
267
|
-
break;
|
|
268
|
-
case 2:
|
|
269
|
-
this._pointerSecondaryDown = false;
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
this._lastPointerUp.copy(this._pointer);
|
|
273
|
-
}
|
|
274
|
-
onClick(e) {
|
|
275
|
-
}
|
|
276
|
-
onDragEnd(e) {
|
|
277
|
-
const intersect = this._intersects[0];
|
|
278
|
-
if (intersect) {
|
|
279
|
-
this._dragEnd.copy(intersect.point.clone());
|
|
280
|
-
this._dragCurrent.copy(intersect.point.clone());
|
|
281
|
-
this._dragDelta.subVectors(
|
|
282
|
-
this._dragCurrent.clone(),
|
|
283
|
-
this._dragStart.clone()
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
if (this._draggable && this._draggable.onDragEnd) {
|
|
287
|
-
this._draggable.onDragEnd({
|
|
288
|
-
dragStart: this._dragStart,
|
|
289
|
-
dragCurrent: this._dragCurrent,
|
|
290
|
-
dragEnd: this._dragEnd,
|
|
291
|
-
dragDelta: this._dragDelta
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
this._draggable = null;
|
|
295
|
-
this._dragging = false;
|
|
296
|
-
this._dragStart.set(0, 0, 0);
|
|
297
|
-
this._dragCurrent.set(0, 0, 0);
|
|
298
|
-
this._dragEnd.set(0, 0, 0);
|
|
299
|
-
this._dragDelta.set(0, 0, 0);
|
|
300
|
-
this._controller.enabled = true;
|
|
301
|
-
}
|
|
302
|
-
onWheel(e) {
|
|
303
|
-
}
|
|
304
|
-
raycast(objects) {
|
|
305
|
-
if (objects !== void 0)
|
|
306
|
-
return this._raycaster.intersectObjects(objects, true).filter((i) => i.object.visible);
|
|
307
|
-
return this._raycaster.intersectObjects(this._scene.children, true).filter((i) => i.object.visible);
|
|
308
|
-
}
|
|
309
|
-
pointerWasDragged() {
|
|
310
|
-
return this._lastPointerDown.distanceTo(this._pointer) > this.POINTER_DRAG_THRESHOLD;
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
// src/toolbox/transform/TransformTool.ts
|
|
317
|
-
import { TransformControls } from "three/examples/jsm/Addons";
|
|
318
|
-
var DIVETransformTool;
|
|
319
|
-
var init_TransformTool = __esm({
|
|
320
|
-
"src/toolbox/transform/TransformTool.ts"() {
|
|
321
|
-
"use strict";
|
|
322
|
-
init_BaseTool();
|
|
323
|
-
init_implementsInterface();
|
|
324
|
-
DIVETransformTool = class extends DIVEBaseTool {
|
|
325
|
-
constructor(scene, controller) {
|
|
326
|
-
super(scene, controller);
|
|
327
|
-
this.isTransformTool = true;
|
|
328
|
-
this.name = "DIVETransformTool";
|
|
329
|
-
this._gizmo = new TransformControls(
|
|
330
|
-
this._controller.object,
|
|
331
|
-
this._controller.domElement
|
|
332
|
-
);
|
|
333
|
-
this._gizmo.mode = "translate";
|
|
334
|
-
this._gizmo.addEventListener("mouseDown", () => {
|
|
335
|
-
controller.enabled = false;
|
|
336
|
-
if (!implementsInterface(
|
|
337
|
-
this._gizmo.object,
|
|
338
|
-
"isMovable"
|
|
339
|
-
))
|
|
340
|
-
return;
|
|
341
|
-
if (!this._gizmo.object.onMoveStart) return;
|
|
342
|
-
this._gizmo.object.onMoveStart();
|
|
343
|
-
});
|
|
344
|
-
this._gizmo.addEventListener("objectChange", () => {
|
|
345
|
-
if (!implementsInterface(
|
|
346
|
-
this._gizmo.object,
|
|
347
|
-
"isMovable"
|
|
348
|
-
))
|
|
349
|
-
return;
|
|
350
|
-
if (!this._gizmo.object.onMove) return;
|
|
351
|
-
this._gizmo.object.onMove();
|
|
352
|
-
});
|
|
353
|
-
this._gizmo.addEventListener("mouseUp", () => {
|
|
354
|
-
controller.enabled = true;
|
|
355
|
-
if (!implementsInterface(
|
|
356
|
-
this._gizmo.object,
|
|
357
|
-
"isMovable"
|
|
358
|
-
))
|
|
359
|
-
return;
|
|
360
|
-
if (!this._gizmo.object.onMoveEnd) return;
|
|
361
|
-
this._gizmo.object.onMoveEnd();
|
|
362
|
-
});
|
|
363
|
-
scene.add(this._gizmo);
|
|
364
|
-
}
|
|
365
|
-
Activate() {
|
|
366
|
-
}
|
|
367
|
-
SetGizmoMode(mode) {
|
|
368
|
-
this._gizmo.mode = mode;
|
|
369
|
-
}
|
|
370
|
-
SetGizmoVisibility(active) {
|
|
371
|
-
const contains = this._scene.children.includes(this._gizmo);
|
|
372
|
-
if (active && !contains) {
|
|
373
|
-
this._scene.add(this._gizmo);
|
|
374
|
-
} else if (!active && contains) {
|
|
375
|
-
this._scene.remove(this._gizmo);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
// public onPointerDown(e: PointerEvent): void {
|
|
379
|
-
// super.onPointerDown(e);
|
|
380
|
-
// // if (this._hovered) {
|
|
381
|
-
// // this._dragRaycastOnObjects = this._gizmo.gizmoPlane.children;
|
|
382
|
-
// // }
|
|
383
|
-
// }
|
|
384
|
-
// protected raycast(): Intersection[] {
|
|
385
|
-
// return super.raycast(this._gizmo.gizmoNode.children);
|
|
386
|
-
// }
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
// src/toolbox/select/SelectTool.ts
|
|
392
|
-
var SelectTool_exports = {};
|
|
393
|
-
__export(SelectTool_exports, {
|
|
394
|
-
DIVESelectTool: () => DIVESelectTool,
|
|
395
|
-
isSelectTool: () => isSelectTool
|
|
396
|
-
});
|
|
397
|
-
var isSelectTool, DIVESelectTool;
|
|
398
|
-
var init_SelectTool = __esm({
|
|
399
|
-
"src/toolbox/select/SelectTool.ts"() {
|
|
400
|
-
"use strict";
|
|
401
|
-
init_TransformTool();
|
|
402
|
-
init_findInterface();
|
|
403
|
-
isSelectTool = (tool) => {
|
|
404
|
-
return tool.isSelectTool !== void 0;
|
|
405
|
-
};
|
|
406
|
-
DIVESelectTool = class extends DIVETransformTool {
|
|
407
|
-
constructor(scene, controller) {
|
|
408
|
-
super(scene, controller);
|
|
409
|
-
this.isSelectTool = true;
|
|
410
|
-
this.name = "SelectTool";
|
|
411
|
-
}
|
|
412
|
-
Activate() {
|
|
413
|
-
}
|
|
414
|
-
Select(selectable) {
|
|
415
|
-
this.AttachGizmo(selectable);
|
|
416
|
-
if (selectable.onSelect) selectable.onSelect();
|
|
417
|
-
}
|
|
418
|
-
Deselect(selectable) {
|
|
419
|
-
this.DetachGizmo();
|
|
420
|
-
if (selectable.onDeselect) selectable.onDeselect();
|
|
421
|
-
}
|
|
422
|
-
AttachGizmo(selectable) {
|
|
423
|
-
if ("isMovable" in selectable) {
|
|
424
|
-
const movable = selectable;
|
|
425
|
-
this._gizmo.attach(movable);
|
|
426
|
-
this.SetGizmoVisibility(movable.visible);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
DetachGizmo() {
|
|
430
|
-
this._gizmo.detach();
|
|
431
|
-
}
|
|
432
|
-
onClick(e) {
|
|
433
|
-
super.onClick(e);
|
|
434
|
-
const first = this._raycaster.intersectObjects(this._scene.Root.children, true).filter((intersect) => intersect.object.visible)[0];
|
|
435
|
-
const selectable = findInterface(
|
|
436
|
-
first == null ? void 0 : first.object,
|
|
437
|
-
"isSelectable"
|
|
438
|
-
);
|
|
439
|
-
if (!first || !selectable) {
|
|
440
|
-
if (this._gizmo.object) {
|
|
441
|
-
this.Deselect(this._gizmo.object);
|
|
442
|
-
}
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
if (this._gizmo.object) {
|
|
446
|
-
if (this._gizmo.object.uuid === selectable.uuid) return;
|
|
447
|
-
this.Deselect(this._gizmo.object);
|
|
448
|
-
}
|
|
449
|
-
this.Select(selectable);
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
// src/camera/PerspectiveCamera.ts
|
|
456
|
-
import { PerspectiveCamera } from "three";
|
|
457
|
-
var DIVEPerspectiveCameraDefaultSettings, _DIVEPerspectiveCamera, DIVEPerspectiveCamera;
|
|
458
|
-
var init_PerspectiveCamera = __esm({
|
|
459
|
-
"src/camera/PerspectiveCamera.ts"() {
|
|
460
|
-
"use strict";
|
|
461
|
-
init_VisibilityLayerMask();
|
|
462
|
-
DIVEPerspectiveCameraDefaultSettings = {
|
|
463
|
-
fov: 80,
|
|
464
|
-
near: 0.1,
|
|
465
|
-
far: 1e3
|
|
466
|
-
};
|
|
467
|
-
_DIVEPerspectiveCamera = class _DIVEPerspectiveCamera extends PerspectiveCamera {
|
|
468
|
-
constructor(settings = DIVEPerspectiveCameraDefaultSettings) {
|
|
469
|
-
super(
|
|
470
|
-
settings.fov || DIVEPerspectiveCameraDefaultSettings.fov,
|
|
471
|
-
1,
|
|
472
|
-
settings.near || DIVEPerspectiveCameraDefaultSettings.near,
|
|
473
|
-
settings.far || DIVEPerspectiveCameraDefaultSettings.far
|
|
474
|
-
);
|
|
475
|
-
this.onSetCameraLayer = () => {
|
|
476
|
-
};
|
|
477
|
-
this.layers.mask = _DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
478
|
-
}
|
|
479
|
-
OnResize(width, height) {
|
|
480
|
-
this.aspect = width / height;
|
|
481
|
-
this.updateProjectionMatrix();
|
|
482
|
-
}
|
|
483
|
-
SetCameraLayer(layer) {
|
|
484
|
-
this.layers.mask = layer === "LIVE" ? _DIVEPerspectiveCamera.LIVE_VIEW_LAYER_MASK : _DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
485
|
-
this.onSetCameraLayer(this.layers.mask);
|
|
486
|
-
}
|
|
487
|
-
};
|
|
488
|
-
_DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK = DEFAULT_LAYER_MASK | UI_LAYER_MASK | HELPER_LAYER_MASK | PRODUCT_LAYER_MASK;
|
|
489
|
-
_DIVEPerspectiveCamera.LIVE_VIEW_LAYER_MASK = PRODUCT_LAYER_MASK;
|
|
490
|
-
DIVEPerspectiveCamera = _DIVEPerspectiveCamera;
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
// src/mediacreator/MediaCreator.ts
|
|
495
|
-
var MediaCreator_exports = {};
|
|
496
|
-
__export(MediaCreator_exports, {
|
|
497
|
-
DIVEMediaCreator: () => DIVEMediaCreator
|
|
498
|
-
});
|
|
499
|
-
var DIVEMediaCreator;
|
|
500
|
-
var init_MediaCreator = __esm({
|
|
501
|
-
"src/mediacreator/MediaCreator.ts"() {
|
|
502
|
-
"use strict";
|
|
503
|
-
init_PerspectiveCamera();
|
|
504
|
-
DIVEMediaCreator = class {
|
|
505
|
-
constructor(renderer, scene, controller) {
|
|
506
|
-
this.renderer = renderer;
|
|
507
|
-
this.scene = scene;
|
|
508
|
-
this.controller = controller;
|
|
509
|
-
}
|
|
510
|
-
GenerateMedia(position, target, width, height) {
|
|
511
|
-
const resetPosition = this.controller.object.position.clone();
|
|
512
|
-
const resetRotation = this.controller.object.quaternion.clone();
|
|
513
|
-
this.renderer.OnResize(width, height);
|
|
514
|
-
this.controller.object.OnResize(width, height);
|
|
515
|
-
this.controller.object.position.copy(position);
|
|
516
|
-
this.controller.target.copy(target);
|
|
517
|
-
this.controller.update();
|
|
518
|
-
const dataUri = this.DrawCanvas().toDataURL();
|
|
519
|
-
this.controller.object.position.copy(resetPosition);
|
|
520
|
-
this.controller.object.quaternion.copy(resetRotation);
|
|
521
|
-
return dataUri;
|
|
522
|
-
}
|
|
523
|
-
DrawCanvas(canvasElement) {
|
|
524
|
-
const restore = this.renderer.domElement;
|
|
525
|
-
if (canvasElement) {
|
|
526
|
-
this.renderer.domElement = canvasElement;
|
|
527
|
-
}
|
|
528
|
-
this.controller.object.layers.mask = DIVEPerspectiveCamera.LIVE_VIEW_LAYER_MASK;
|
|
529
|
-
this.renderer.render(this.scene, this.controller.object);
|
|
530
|
-
this.controller.object.layers.mask = DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
531
|
-
const returnCanvas = this.renderer.domElement;
|
|
532
|
-
if (canvasElement) {
|
|
533
|
-
this.renderer.domElement = restore;
|
|
534
|
-
}
|
|
535
|
-
return returnCanvas;
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
// src/io/gltf/GLTFIO.ts
|
|
542
|
-
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
543
|
-
import { GLTFExporter } from "three/examples/jsm/exporters/GLTFExporter";
|
|
544
|
-
var DIVEGLTFIO;
|
|
545
|
-
var init_GLTFIO = __esm({
|
|
546
|
-
"src/io/gltf/GLTFIO.ts"() {
|
|
547
|
-
"use strict";
|
|
548
|
-
DIVEGLTFIO = class {
|
|
549
|
-
constructor() {
|
|
550
|
-
this._importer = new GLTFLoader();
|
|
551
|
-
this._exporter = new GLTFExporter();
|
|
552
|
-
}
|
|
553
|
-
Import(url, onProgress) {
|
|
554
|
-
return this._importer.loadAsync(url, (progress) => {
|
|
555
|
-
if (!onProgress) return;
|
|
556
|
-
onProgress(progress.loaded / progress.total);
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
Export(object, binary, onlyVisible) {
|
|
560
|
-
if (binary) {
|
|
561
|
-
return this._exporter.parseAsync(object, {
|
|
562
|
-
binary,
|
|
563
|
-
onlyVisible
|
|
564
|
-
});
|
|
565
|
-
} else {
|
|
566
|
-
return this._exporter.parseAsync(object, {
|
|
567
|
-
binary,
|
|
568
|
-
onlyVisible
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
// src/io/IO.ts
|
|
577
|
-
var IO_exports = {};
|
|
578
|
-
__export(IO_exports, {
|
|
579
|
-
DIVEIO: () => DIVEIO
|
|
580
|
-
});
|
|
581
|
-
var DIVEIO;
|
|
582
|
-
var init_IO = __esm({
|
|
583
|
-
"src/io/IO.ts"() {
|
|
584
|
-
"use strict";
|
|
585
|
-
init_GLTFIO();
|
|
586
|
-
DIVEIO = class {
|
|
587
|
-
constructor(scene) {
|
|
588
|
-
this._scene = scene;
|
|
589
|
-
this._gltfIO = new DIVEGLTFIO();
|
|
590
|
-
}
|
|
591
|
-
Import(type, url) {
|
|
592
|
-
switch (type) {
|
|
593
|
-
case "glb": {
|
|
594
|
-
return this._gltfIO.Import(url).catch((error) => {
|
|
595
|
-
console.error(error);
|
|
596
|
-
return null;
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
default: {
|
|
600
|
-
console.error("DIVEIO.Import: Unsupported file type: " + type);
|
|
601
|
-
return Promise.reject();
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
Export(type) {
|
|
606
|
-
switch (type) {
|
|
607
|
-
case "glb": {
|
|
608
|
-
return this._gltfIO.Export(this._scene, true, true).then((data) => {
|
|
609
|
-
return this._createBlobURL(data);
|
|
610
|
-
}).catch((error) => {
|
|
611
|
-
console.error(error);
|
|
612
|
-
return null;
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
default: {
|
|
616
|
-
console.error("DIVEIO.Export: Unsupported file type: " + type);
|
|
617
|
-
return Promise.reject();
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
_createBlobURL(data) {
|
|
622
|
-
return URL.createObjectURL(new Blob([data]));
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
// src/renderer/Renderer.ts
|
|
629
|
-
import {
|
|
630
|
-
MathUtils,
|
|
631
|
-
NoToneMapping,
|
|
632
|
-
PCFSoftShadowMap,
|
|
633
|
-
WebGLRenderer
|
|
634
|
-
} from "three";
|
|
635
|
-
var DIVERendererDefaultSettings = {
|
|
636
|
-
antialias: true,
|
|
637
|
-
alpha: true,
|
|
638
|
-
stencil: false,
|
|
639
|
-
shadowMapEnabled: true,
|
|
640
|
-
shadowMapType: PCFSoftShadowMap,
|
|
641
|
-
toneMapping: NoToneMapping,
|
|
642
|
-
canvas: void 0
|
|
643
|
-
};
|
|
644
|
-
var DIVERenderer = class extends WebGLRenderer {
|
|
645
|
-
constructor(rendererSettings = DIVERendererDefaultSettings) {
|
|
646
|
-
super({
|
|
647
|
-
antialias: rendererSettings.antialias || DIVERendererDefaultSettings.antialias,
|
|
648
|
-
alpha: rendererSettings.alpha || DIVERendererDefaultSettings.alpha,
|
|
649
|
-
preserveDrawingBuffer: true,
|
|
650
|
-
canvas: rendererSettings.canvas
|
|
651
|
-
});
|
|
652
|
-
// basic functionality members
|
|
653
|
-
this.paused = false;
|
|
654
|
-
this.running = false;
|
|
655
|
-
this.force = false;
|
|
656
|
-
// pre- and post-render callbacks
|
|
657
|
-
this.preRenderCallbacks = /* @__PURE__ */ new Map();
|
|
658
|
-
this.postRenderCallbacks = /* @__PURE__ */ new Map();
|
|
659
|
-
this.setPixelRatio(window.devicePixelRatio);
|
|
660
|
-
this.shadowMap.enabled = rendererSettings.shadowMapEnabled || DIVERendererDefaultSettings.shadowMapEnabled;
|
|
661
|
-
this.shadowMap.type = rendererSettings.shadowMapType || DIVERendererDefaultSettings.shadowMapType;
|
|
662
|
-
this.toneMapping = rendererSettings.toneMapping || DIVERendererDefaultSettings.toneMapping;
|
|
663
|
-
this.debug.checkShaderErrors = false;
|
|
664
|
-
}
|
|
665
|
-
// Stops renderings and disposes the renderer.
|
|
666
|
-
Dispose() {
|
|
667
|
-
this.StopRenderer();
|
|
668
|
-
this.dispose();
|
|
669
|
-
}
|
|
670
|
-
// Starts the renderer with the given scene and camera.
|
|
671
|
-
StartRenderer(scene, cam) {
|
|
672
|
-
this.setAnimationLoop(() => {
|
|
673
|
-
this.internal_render(scene, cam);
|
|
674
|
-
});
|
|
675
|
-
this.running = true;
|
|
676
|
-
}
|
|
677
|
-
// Pauses the renderer.
|
|
678
|
-
PauseRenderer() {
|
|
679
|
-
this.paused = true;
|
|
680
|
-
}
|
|
681
|
-
// Resumes the renderer after pausing.
|
|
682
|
-
ResumeRenderer() {
|
|
683
|
-
this.paused = false;
|
|
684
|
-
}
|
|
685
|
-
// Stops the renderer completely. Has to be started again with StartRenderer().
|
|
686
|
-
StopRenderer() {
|
|
687
|
-
this.setAnimationLoop(null);
|
|
688
|
-
this.running = false;
|
|
689
|
-
}
|
|
690
|
-
// Resizes the renderer to the given width and height.
|
|
691
|
-
OnResize(width, height) {
|
|
692
|
-
this.setSize(width, height);
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Adds a callback to the render loop before actual render call.
|
|
696
|
-
* @param callback Executed before rendering.
|
|
697
|
-
* @returns uuid to remove the callback.
|
|
698
|
-
*/
|
|
699
|
-
AddPreRenderCallback(callback) {
|
|
700
|
-
const newUUID = MathUtils.generateUUID();
|
|
701
|
-
this.preRenderCallbacks.set(newUUID, callback);
|
|
702
|
-
return newUUID;
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* Removes a callback from the render loop before actual render call.
|
|
706
|
-
* @param uuid of callback to remove.
|
|
707
|
-
* @returns if removing was successful.
|
|
708
|
-
*/
|
|
709
|
-
RemovePreRenderCallback(uuid) {
|
|
710
|
-
if (!this.preRenderCallbacks.has(uuid)) return false;
|
|
711
|
-
this.preRenderCallbacks.delete(uuid);
|
|
712
|
-
return true;
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* Adds a callback to the render loop after actual render call.
|
|
716
|
-
* @param callback Executed after rendering.
|
|
717
|
-
* @returns uuid to remove the callback.
|
|
718
|
-
*/
|
|
719
|
-
AddPostRenderCallback(callback) {
|
|
720
|
-
const newUUID = MathUtils.generateUUID();
|
|
721
|
-
this.postRenderCallbacks.set(newUUID, callback);
|
|
722
|
-
return newUUID;
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Removes a callback from the render loop after actual render call.
|
|
726
|
-
* @param uuid of callback to remove.
|
|
727
|
-
* @returns if removing was successful.
|
|
728
|
-
*/
|
|
729
|
-
RemovePostRenderCallback(uuid) {
|
|
730
|
-
if (!this.postRenderCallbacks.has(uuid)) return false;
|
|
731
|
-
this.postRenderCallbacks.delete(uuid);
|
|
732
|
-
return true;
|
|
733
|
-
}
|
|
734
|
-
/**
|
|
735
|
-
* Forces the renderer to render the next frame.
|
|
736
|
-
*/
|
|
737
|
-
ForceRendering() {
|
|
738
|
-
this.force = true;
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* Internal render loop.
|
|
742
|
-
*
|
|
743
|
-
* To control renderloop you can add callbacks via AddPreRenderCallback() and AddPostRenderCallback().
|
|
744
|
-
* @param scene Scene to render.
|
|
745
|
-
* @param cam Camera to render with.
|
|
746
|
-
*/
|
|
747
|
-
internal_render(scene, cam) {
|
|
748
|
-
if ((this.paused || !this.running) && !this.force) return;
|
|
749
|
-
this.preRenderCallbacks.forEach((callback) => {
|
|
750
|
-
callback();
|
|
751
|
-
});
|
|
752
|
-
this.render(scene, cam);
|
|
753
|
-
this.postRenderCallbacks.forEach((callback) => {
|
|
754
|
-
callback();
|
|
755
|
-
});
|
|
756
|
-
this.force = false;
|
|
757
|
-
}
|
|
758
|
-
};
|
|
759
|
-
|
|
760
|
-
// src/scene/Scene.ts
|
|
761
|
-
import { Color as Color7, Scene as Scene2 } from "three";
|
|
762
|
-
|
|
763
|
-
// src/scene/root/Root.ts
|
|
764
|
-
import { Box3 as Box32, Color as Color5, Object3D as Object3D6 } from "three";
|
|
765
|
-
|
|
766
|
-
// src/light/AmbientLight.ts
|
|
767
|
-
init_VisibilityLayerMask();
|
|
768
|
-
import { AmbientLight, Object3D } from "three";
|
|
769
|
-
var DIVEAmbientLight = class extends Object3D {
|
|
770
|
-
constructor() {
|
|
771
|
-
super();
|
|
772
|
-
this.isDIVELight = true;
|
|
773
|
-
this.isDIVEAmbientLight = true;
|
|
774
|
-
this.name = "DIVEAmbientLight";
|
|
775
|
-
this._light = new AmbientLight(16777215, 1);
|
|
776
|
-
this._light.layers.mask = PRODUCT_LAYER_MASK;
|
|
777
|
-
this.add(this._light);
|
|
778
|
-
}
|
|
779
|
-
SetColor(color) {
|
|
780
|
-
this._light.color = color;
|
|
781
|
-
}
|
|
782
|
-
SetIntensity(intensity) {
|
|
783
|
-
this._light.intensity = intensity;
|
|
784
|
-
}
|
|
785
|
-
SetEnabled(enabled) {
|
|
786
|
-
this._light.visible = enabled;
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
|
|
790
|
-
// src/light/PointLight.ts
|
|
791
|
-
import {
|
|
792
|
-
PointLight,
|
|
793
|
-
SphereGeometry,
|
|
794
|
-
MeshBasicMaterial,
|
|
795
|
-
Mesh,
|
|
796
|
-
FrontSide,
|
|
797
|
-
Object3D as Object3D3
|
|
798
|
-
} from "three";
|
|
799
|
-
|
|
800
|
-
// src/com/Communication.ts
|
|
801
|
-
init_SelectTool();
|
|
802
|
-
import { generateUUID } from "three/src/math/MathUtils";
|
|
803
|
-
import { merge } from "lodash";
|
|
804
|
-
var _DIVECommunication = class _DIVECommunication {
|
|
805
|
-
constructor(renderer, scene, controls, toolbox) {
|
|
806
|
-
this.registered = /* @__PURE__ */ new Map();
|
|
807
|
-
// private listeners: { [key: string]: EventListener[] } = {};
|
|
808
|
-
this.listeners = /* @__PURE__ */ new Map();
|
|
809
|
-
this._id = generateUUID();
|
|
810
|
-
this.renderer = renderer;
|
|
811
|
-
this.scene = scene;
|
|
812
|
-
this.controller = controls;
|
|
813
|
-
this.toolbox = toolbox;
|
|
814
|
-
this._mediaGenerator = null;
|
|
815
|
-
this._io = null;
|
|
816
|
-
_DIVECommunication.__instances.push(this);
|
|
817
|
-
}
|
|
818
|
-
static get(id) {
|
|
819
|
-
const fromComID = this.__instances.find(
|
|
820
|
-
(instance) => instance.id === id
|
|
821
|
-
);
|
|
822
|
-
if (fromComID) return fromComID;
|
|
823
|
-
return this.__instances.find(
|
|
824
|
-
(instance) => Array.from(instance.registered.values()).find(
|
|
825
|
-
(object) => object.id === id
|
|
826
|
-
)
|
|
827
|
-
);
|
|
828
|
-
}
|
|
829
|
-
get id() {
|
|
830
|
-
return this._id;
|
|
831
|
-
}
|
|
832
|
-
get mediaGenerator() {
|
|
833
|
-
if (!this._mediaGenerator) {
|
|
834
|
-
const DIVEMediaCreator2 = (init_MediaCreator(), __toCommonJS(MediaCreator_exports)).DIVEMediaCreator;
|
|
835
|
-
this._mediaGenerator = new DIVEMediaCreator2(
|
|
836
|
-
this.renderer,
|
|
837
|
-
this.scene,
|
|
838
|
-
this.controller
|
|
839
|
-
);
|
|
840
|
-
}
|
|
841
|
-
return this._mediaGenerator;
|
|
842
|
-
}
|
|
843
|
-
get io() {
|
|
844
|
-
if (!this._io) {
|
|
845
|
-
const DIVEIO2 = (init_IO(), __toCommonJS(IO_exports)).DIVEIO;
|
|
846
|
-
this._io = new DIVEIO2(this.scene);
|
|
847
|
-
}
|
|
848
|
-
return this._io;
|
|
849
|
-
}
|
|
850
|
-
DestroyInstance() {
|
|
851
|
-
const existingIndex = _DIVECommunication.__instances.findIndex(
|
|
852
|
-
(entry) => entry.id === this.id
|
|
853
|
-
);
|
|
854
|
-
if (existingIndex === -1) return false;
|
|
855
|
-
_DIVECommunication.__instances.splice(existingIndex, 1);
|
|
856
|
-
return true;
|
|
857
|
-
}
|
|
858
|
-
PerformAction(action, payload) {
|
|
859
|
-
let returnValue = false;
|
|
860
|
-
switch (action) {
|
|
861
|
-
case "GET_ALL_SCENE_DATA": {
|
|
862
|
-
returnValue = this.getAllSceneData(
|
|
863
|
-
payload
|
|
864
|
-
);
|
|
865
|
-
break;
|
|
866
|
-
}
|
|
867
|
-
case "GET_ALL_OBJECTS": {
|
|
868
|
-
returnValue = this.getAllObjects(
|
|
869
|
-
payload
|
|
870
|
-
);
|
|
871
|
-
break;
|
|
872
|
-
}
|
|
873
|
-
case "GET_OBJECTS": {
|
|
874
|
-
returnValue = this.getObjects(
|
|
875
|
-
payload
|
|
876
|
-
);
|
|
877
|
-
break;
|
|
878
|
-
}
|
|
879
|
-
case "ADD_OBJECT": {
|
|
880
|
-
returnValue = this.addObject(
|
|
881
|
-
payload
|
|
882
|
-
);
|
|
883
|
-
break;
|
|
884
|
-
}
|
|
885
|
-
case "UPDATE_OBJECT": {
|
|
886
|
-
returnValue = this.updateObject(
|
|
887
|
-
payload
|
|
888
|
-
);
|
|
889
|
-
break;
|
|
890
|
-
}
|
|
891
|
-
case "DELETE_OBJECT": {
|
|
892
|
-
returnValue = this.deleteObject(
|
|
893
|
-
payload
|
|
894
|
-
);
|
|
895
|
-
break;
|
|
896
|
-
}
|
|
897
|
-
case "SELECT_OBJECT": {
|
|
898
|
-
returnValue = this.selectObject(
|
|
899
|
-
payload
|
|
900
|
-
);
|
|
901
|
-
break;
|
|
902
|
-
}
|
|
903
|
-
case "DESELECT_OBJECT": {
|
|
904
|
-
returnValue = this.deselectObject(
|
|
905
|
-
payload
|
|
906
|
-
);
|
|
907
|
-
break;
|
|
908
|
-
}
|
|
909
|
-
case "SET_BACKGROUND": {
|
|
910
|
-
returnValue = this.setBackground(
|
|
911
|
-
payload
|
|
912
|
-
);
|
|
913
|
-
break;
|
|
914
|
-
}
|
|
915
|
-
case "DROP_IT": {
|
|
916
|
-
returnValue = this.dropIt(
|
|
917
|
-
payload
|
|
918
|
-
);
|
|
919
|
-
break;
|
|
920
|
-
}
|
|
921
|
-
case "PLACE_ON_FLOOR": {
|
|
922
|
-
returnValue = this.placeOnFloor(
|
|
923
|
-
payload
|
|
924
|
-
);
|
|
925
|
-
break;
|
|
926
|
-
}
|
|
927
|
-
case "SET_CAMERA_TRANSFORM": {
|
|
928
|
-
returnValue = this.setCameraTransform(
|
|
929
|
-
payload
|
|
930
|
-
);
|
|
931
|
-
break;
|
|
932
|
-
}
|
|
933
|
-
case "GET_CAMERA_TRANSFORM": {
|
|
934
|
-
returnValue = this.getCameraTransform(
|
|
935
|
-
payload
|
|
936
|
-
);
|
|
937
|
-
break;
|
|
938
|
-
}
|
|
939
|
-
case "MOVE_CAMERA": {
|
|
940
|
-
returnValue = this.moveCamera(
|
|
941
|
-
payload
|
|
942
|
-
);
|
|
943
|
-
break;
|
|
944
|
-
}
|
|
945
|
-
case "RESET_CAMERA": {
|
|
946
|
-
returnValue = this.resetCamera(
|
|
947
|
-
payload
|
|
948
|
-
);
|
|
949
|
-
break;
|
|
950
|
-
}
|
|
951
|
-
case "COMPUTE_ENCOMPASSING_VIEW": {
|
|
952
|
-
returnValue = this.computeEncompassingView(
|
|
953
|
-
payload
|
|
954
|
-
);
|
|
955
|
-
break;
|
|
956
|
-
}
|
|
957
|
-
case "SET_CAMERA_LAYER": {
|
|
958
|
-
returnValue = this.setCameraLayer(
|
|
959
|
-
payload
|
|
960
|
-
);
|
|
961
|
-
break;
|
|
962
|
-
}
|
|
963
|
-
case "ZOOM_CAMERA": {
|
|
964
|
-
returnValue = this.zoomCamera(
|
|
965
|
-
payload
|
|
966
|
-
);
|
|
967
|
-
break;
|
|
968
|
-
}
|
|
969
|
-
case "SET_GIZMO_MODE": {
|
|
970
|
-
returnValue = this.setGizmoMode(
|
|
971
|
-
payload
|
|
972
|
-
);
|
|
973
|
-
break;
|
|
974
|
-
}
|
|
975
|
-
case "SET_GIZMO_VISIBILITY": {
|
|
976
|
-
returnValue = this.setGizmoVisibility(
|
|
977
|
-
payload
|
|
978
|
-
);
|
|
979
|
-
break;
|
|
980
|
-
}
|
|
981
|
-
case "USE_TOOL": {
|
|
982
|
-
returnValue = this.useTool(
|
|
983
|
-
payload
|
|
984
|
-
);
|
|
985
|
-
break;
|
|
986
|
-
}
|
|
987
|
-
case "MODEL_LOADED": {
|
|
988
|
-
returnValue = this.modelLoaded(
|
|
989
|
-
payload
|
|
990
|
-
);
|
|
991
|
-
break;
|
|
992
|
-
}
|
|
993
|
-
case "UPDATE_SCENE": {
|
|
994
|
-
returnValue = this.updateScene(
|
|
995
|
-
payload
|
|
996
|
-
);
|
|
997
|
-
break;
|
|
998
|
-
}
|
|
999
|
-
case "GENERATE_MEDIA": {
|
|
1000
|
-
returnValue = this.generateMedia(
|
|
1001
|
-
payload
|
|
1002
|
-
);
|
|
1003
|
-
break;
|
|
1004
|
-
}
|
|
1005
|
-
case "SET_PARENT": {
|
|
1006
|
-
returnValue = this.setParent(
|
|
1007
|
-
payload
|
|
1008
|
-
);
|
|
1009
|
-
break;
|
|
1010
|
-
}
|
|
1011
|
-
case "EXPORT_SCENE": {
|
|
1012
|
-
returnValue = this.exportScene(
|
|
1013
|
-
payload
|
|
1014
|
-
);
|
|
1015
|
-
break;
|
|
1016
|
-
}
|
|
1017
|
-
default: {
|
|
1018
|
-
console.warn(
|
|
1019
|
-
`DIVECommunication.PerformAction: has been executed with unknown Action type ${action}`
|
|
1020
|
-
);
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
this.dispatch(action, payload);
|
|
1024
|
-
return returnValue;
|
|
1025
|
-
}
|
|
1026
|
-
Subscribe(type, listener) {
|
|
1027
|
-
if (!this.listeners.get(type)) this.listeners.set(type, []);
|
|
1028
|
-
this.listeners.get(type).push(listener);
|
|
1029
|
-
return () => {
|
|
1030
|
-
const listenerArray = this.listeners.get(type);
|
|
1031
|
-
if (!listenerArray) return false;
|
|
1032
|
-
const existingIndex = listenerArray.findIndex(
|
|
1033
|
-
(entry) => entry === listener
|
|
1034
|
-
);
|
|
1035
|
-
if (existingIndex === -1) return false;
|
|
1036
|
-
listenerArray.splice(existingIndex, 1);
|
|
1037
|
-
return true;
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
dispatch(type, payload) {
|
|
1041
|
-
const listenerArray = this.listeners.get(type);
|
|
1042
|
-
if (!listenerArray) return;
|
|
1043
|
-
listenerArray.forEach((listener) => listener(payload));
|
|
1044
|
-
}
|
|
1045
|
-
getAllSceneData(payload) {
|
|
1046
|
-
const sceneData = {
|
|
1047
|
-
name: this.scene.name,
|
|
1048
|
-
mediaItem: null,
|
|
1049
|
-
backgroundColor: "#" + this.scene.background.getHexString(),
|
|
1050
|
-
floorEnabled: this.scene.Floor.visible,
|
|
1051
|
-
floorColor: "#" + this.scene.Floor.material.color.getHexString(),
|
|
1052
|
-
userCamera: {
|
|
1053
|
-
position: this.controller.object.position.clone(),
|
|
1054
|
-
target: this.controller.target.clone()
|
|
1055
|
-
},
|
|
1056
|
-
spotmarks: [],
|
|
1057
|
-
lights: Array.from(this.registered.values()).filter(
|
|
1058
|
-
(object) => object.entityType === "light"
|
|
1059
|
-
),
|
|
1060
|
-
objects: Array.from(this.registered.values()).filter(
|
|
1061
|
-
(object) => object.entityType === "model"
|
|
1062
|
-
),
|
|
1063
|
-
cameras: Array.from(this.registered.values()).filter(
|
|
1064
|
-
(object) => object.entityType === "pov"
|
|
1065
|
-
),
|
|
1066
|
-
primitives: Array.from(this.registered.values()).filter(
|
|
1067
|
-
(object) => object.entityType === "primitive"
|
|
1068
|
-
),
|
|
1069
|
-
groups: Array.from(this.registered.values()).filter(
|
|
1070
|
-
(object) => object.entityType === "group"
|
|
1071
|
-
)
|
|
1072
|
-
};
|
|
1073
|
-
Object.assign(payload, sceneData);
|
|
1074
|
-
return sceneData;
|
|
1075
|
-
}
|
|
1076
|
-
getAllObjects(payload) {
|
|
1077
|
-
Object.assign(payload, this.registered);
|
|
1078
|
-
return this.registered;
|
|
1079
|
-
}
|
|
1080
|
-
getObjects(payload) {
|
|
1081
|
-
if (payload.ids.length === 0) return [];
|
|
1082
|
-
const objects = [];
|
|
1083
|
-
this.registered.forEach((object) => {
|
|
1084
|
-
if (!payload.ids.includes(object.id)) return;
|
|
1085
|
-
objects.push(object);
|
|
1086
|
-
});
|
|
1087
|
-
return objects;
|
|
1088
|
-
}
|
|
1089
|
-
addObject(payload) {
|
|
1090
|
-
if (this.registered.get(payload.id)) return false;
|
|
1091
|
-
if (payload.parentId === void 0) payload.parentId = null;
|
|
1092
|
-
this.registered.set(payload.id, payload);
|
|
1093
|
-
this.scene.AddSceneObject(payload);
|
|
1094
|
-
return true;
|
|
1095
|
-
}
|
|
1096
|
-
updateObject(payload) {
|
|
1097
|
-
const objectToUpdate = this.registered.get(payload.id);
|
|
1098
|
-
if (!objectToUpdate) return false;
|
|
1099
|
-
this.registered.set(payload.id, merge(objectToUpdate, payload));
|
|
1100
|
-
const updatedObject = this.registered.get(payload.id);
|
|
1101
|
-
this.scene.UpdateSceneObject(__spreadProps(__spreadValues({}, payload), {
|
|
1102
|
-
id: updatedObject.id,
|
|
1103
|
-
entityType: updatedObject.entityType
|
|
1104
|
-
}));
|
|
1105
|
-
Object.assign(payload, updatedObject);
|
|
1106
|
-
return true;
|
|
1107
|
-
}
|
|
1108
|
-
deleteObject(payload) {
|
|
1109
|
-
const deletedObject = this.registered.get(payload.id);
|
|
1110
|
-
if (!deletedObject) return false;
|
|
1111
|
-
Object.assign(payload, deletedObject);
|
|
1112
|
-
this.registered.delete(payload.id);
|
|
1113
|
-
Array.from(this.registered.values()).forEach((object) => {
|
|
1114
|
-
if (!object.parentId) return;
|
|
1115
|
-
if (object.parentId !== payload.id) return;
|
|
1116
|
-
object.parentId = null;
|
|
1117
|
-
});
|
|
1118
|
-
this.scene.DeleteSceneObject(deletedObject);
|
|
1119
|
-
return true;
|
|
1120
|
-
}
|
|
1121
|
-
selectObject(payload) {
|
|
1122
|
-
const object = this.registered.get(payload.id);
|
|
1123
|
-
if (!object) return false;
|
|
1124
|
-
const sceneObject = this.scene.GetSceneObject(object);
|
|
1125
|
-
if (!sceneObject) return false;
|
|
1126
|
-
if (!("isSelectable" in sceneObject)) return false;
|
|
1127
|
-
const activeTool = this.toolbox.GetActiveTool();
|
|
1128
|
-
if (activeTool && isSelectTool(activeTool)) {
|
|
1129
|
-
activeTool.AttachGizmo(sceneObject);
|
|
1130
|
-
}
|
|
1131
|
-
Object.assign(payload, object);
|
|
1132
|
-
return true;
|
|
1133
|
-
}
|
|
1134
|
-
deselectObject(payload) {
|
|
1135
|
-
const object = this.registered.get(payload.id);
|
|
1136
|
-
if (!object) return false;
|
|
1137
|
-
const sceneObject = this.scene.GetSceneObject(object);
|
|
1138
|
-
if (!sceneObject) return false;
|
|
1139
|
-
if (!("isSelectable" in sceneObject)) return false;
|
|
1140
|
-
const activeTool = this.toolbox.GetActiveTool();
|
|
1141
|
-
if (activeTool && isSelectTool(activeTool)) {
|
|
1142
|
-
activeTool.DetachGizmo();
|
|
1143
|
-
}
|
|
1144
|
-
Object.assign(payload, object);
|
|
1145
|
-
return true;
|
|
1146
|
-
}
|
|
1147
|
-
setBackground(payload) {
|
|
1148
|
-
this.scene.SetBackground(payload.color);
|
|
1149
|
-
return true;
|
|
1150
|
-
}
|
|
1151
|
-
dropIt(payload) {
|
|
1152
|
-
const object = this.registered.get(payload.id);
|
|
1153
|
-
if (!object) return false;
|
|
1154
|
-
const model = this.scene.GetSceneObject(object);
|
|
1155
|
-
model.DropIt();
|
|
1156
|
-
return true;
|
|
1157
|
-
}
|
|
1158
|
-
placeOnFloor(payload) {
|
|
1159
|
-
const object = this.registered.get(payload.id);
|
|
1160
|
-
if (!object) return false;
|
|
1161
|
-
this.scene.PlaceOnFloor(object);
|
|
1162
|
-
return true;
|
|
1163
|
-
}
|
|
1164
|
-
setCameraTransform(payload) {
|
|
1165
|
-
this.controller.object.position.copy(payload.position);
|
|
1166
|
-
this.controller.target.copy(payload.target);
|
|
1167
|
-
this.controller.update();
|
|
1168
|
-
return true;
|
|
1169
|
-
}
|
|
1170
|
-
getCameraTransform(payload) {
|
|
1171
|
-
const transform = {
|
|
1172
|
-
position: this.controller.object.position.clone(),
|
|
1173
|
-
target: this.controller.target.clone()
|
|
1174
|
-
};
|
|
1175
|
-
Object.assign(payload, transform);
|
|
1176
|
-
return transform;
|
|
1177
|
-
}
|
|
1178
|
-
moveCamera(payload) {
|
|
1179
|
-
let position = { x: 0, y: 0, z: 0 };
|
|
1180
|
-
let target = { x: 0, y: 0, z: 0 };
|
|
1181
|
-
if ("id" in payload) {
|
|
1182
|
-
position = this.registered.get(payload.id).position;
|
|
1183
|
-
target = this.registered.get(payload.id).target;
|
|
1184
|
-
} else {
|
|
1185
|
-
position = payload.position;
|
|
1186
|
-
target = payload.target;
|
|
1187
|
-
}
|
|
1188
|
-
this.controller.MoveTo(
|
|
1189
|
-
position,
|
|
1190
|
-
target,
|
|
1191
|
-
payload.duration,
|
|
1192
|
-
payload.locked
|
|
1193
|
-
);
|
|
1194
|
-
return true;
|
|
1195
|
-
}
|
|
1196
|
-
setCameraLayer(payload) {
|
|
1197
|
-
this.controller.object.SetCameraLayer(payload.layer);
|
|
1198
|
-
return true;
|
|
1199
|
-
}
|
|
1200
|
-
resetCamera(payload) {
|
|
1201
|
-
this.controller.RevertLast(payload.duration);
|
|
1202
|
-
return true;
|
|
1203
|
-
}
|
|
1204
|
-
computeEncompassingView(payload) {
|
|
1205
|
-
const sceneBB = this.scene.ComputeSceneBB();
|
|
1206
|
-
const transform = this.controller.ComputeEncompassingView(sceneBB);
|
|
1207
|
-
Object.assign(payload, transform);
|
|
1208
|
-
return transform;
|
|
1209
|
-
}
|
|
1210
|
-
zoomCamera(payload) {
|
|
1211
|
-
if (payload.direction === "IN") this.controller.ZoomIn(payload.by);
|
|
1212
|
-
if (payload.direction === "OUT") this.controller.ZoomOut(payload.by);
|
|
1213
|
-
return true;
|
|
1214
|
-
}
|
|
1215
|
-
setGizmoMode(payload) {
|
|
1216
|
-
this.toolbox.SetGizmoMode(payload.mode);
|
|
1217
|
-
return true;
|
|
1218
|
-
}
|
|
1219
|
-
setGizmoVisibility(payload) {
|
|
1220
|
-
this.toolbox.SetGizmoVisibility(payload);
|
|
1221
|
-
return payload;
|
|
1222
|
-
}
|
|
1223
|
-
useTool(payload) {
|
|
1224
|
-
this.toolbox.UseTool(payload.tool);
|
|
1225
|
-
return true;
|
|
1226
|
-
}
|
|
1227
|
-
modelLoaded(payload) {
|
|
1228
|
-
this.registered.get(payload.id).loaded = true;
|
|
1229
|
-
return true;
|
|
1230
|
-
}
|
|
1231
|
-
updateScene(payload) {
|
|
1232
|
-
if (payload.name !== void 0) this.scene.name = payload.name;
|
|
1233
|
-
if (payload.backgroundColor !== void 0)
|
|
1234
|
-
this.scene.SetBackground(payload.backgroundColor);
|
|
1235
|
-
if (payload.gridEnabled !== void 0)
|
|
1236
|
-
this.scene.Grid.SetVisibility(payload.gridEnabled);
|
|
1237
|
-
if (payload.floorEnabled !== void 0)
|
|
1238
|
-
this.scene.Floor.SetVisibility(payload.floorEnabled);
|
|
1239
|
-
if (payload.floorColor !== void 0)
|
|
1240
|
-
this.scene.Floor.SetColor(payload.floorColor);
|
|
1241
|
-
payload.name = this.scene.name;
|
|
1242
|
-
payload.backgroundColor = "#" + this.scene.background.getHexString();
|
|
1243
|
-
payload.gridEnabled = this.scene.Grid.visible;
|
|
1244
|
-
payload.floorEnabled = this.scene.Floor.visible;
|
|
1245
|
-
payload.floorColor = "#" + this.scene.Floor.material.color.getHexString();
|
|
1246
|
-
return true;
|
|
1247
|
-
}
|
|
1248
|
-
generateMedia(payload) {
|
|
1249
|
-
let position = { x: 0, y: 0, z: 0 };
|
|
1250
|
-
let target = { x: 0, y: 0, z: 0 };
|
|
1251
|
-
if ("id" in payload) {
|
|
1252
|
-
position = this.registered.get(payload.id).position;
|
|
1253
|
-
target = this.registered.get(payload.id).target;
|
|
1254
|
-
} else {
|
|
1255
|
-
position = payload.position;
|
|
1256
|
-
target = payload.target;
|
|
1257
|
-
}
|
|
1258
|
-
payload.dataUri = this.mediaGenerator.GenerateMedia(
|
|
1259
|
-
position,
|
|
1260
|
-
target,
|
|
1261
|
-
payload.width,
|
|
1262
|
-
payload.height
|
|
1263
|
-
);
|
|
1264
|
-
return true;
|
|
1265
|
-
}
|
|
1266
|
-
setParent(payload) {
|
|
1267
|
-
const object = this.registered.get(payload.object.id);
|
|
1268
|
-
if (!object) return false;
|
|
1269
|
-
const sceneObject = this.scene.GetSceneObject(object);
|
|
1270
|
-
if (!sceneObject) return false;
|
|
1271
|
-
if (payload.parent === null) {
|
|
1272
|
-
this.scene.Root.attach(sceneObject);
|
|
1273
|
-
return true;
|
|
1274
|
-
}
|
|
1275
|
-
if (payload.object.id === payload.parent.id) {
|
|
1276
|
-
return false;
|
|
1277
|
-
}
|
|
1278
|
-
const parent = this.registered.get(payload.parent.id);
|
|
1279
|
-
if (!parent) {
|
|
1280
|
-
this.scene.Root.attach(sceneObject);
|
|
1281
|
-
return true;
|
|
1282
|
-
}
|
|
1283
|
-
const parentObject = this.scene.GetSceneObject(parent);
|
|
1284
|
-
if (!parentObject) {
|
|
1285
|
-
this.scene.Root.attach(sceneObject);
|
|
1286
|
-
return true;
|
|
1287
|
-
}
|
|
1288
|
-
parentObject.attach(sceneObject);
|
|
1289
|
-
return true;
|
|
1290
|
-
}
|
|
1291
|
-
exportScene(payload) {
|
|
1292
|
-
return this.io.Export(payload.type);
|
|
1293
|
-
}
|
|
1294
|
-
};
|
|
1295
|
-
_DIVECommunication.__instances = [];
|
|
1296
|
-
var DIVECommunication = _DIVECommunication;
|
|
1297
|
-
|
|
1298
|
-
// src/light/PointLight.ts
|
|
1299
|
-
init_VisibilityLayerMask();
|
|
1300
|
-
var DIVEPointLight = class extends Object3D3 {
|
|
1301
|
-
constructor() {
|
|
1302
|
-
super();
|
|
1303
|
-
this.isDIVELight = true;
|
|
1304
|
-
this.isDIVEPointLight = true;
|
|
1305
|
-
this.isMovable = true;
|
|
1306
|
-
this.isSelectable = true;
|
|
1307
|
-
this.gizmo = null;
|
|
1308
|
-
this.name = "DIVEPointLight";
|
|
1309
|
-
this.light = new PointLight(16777215, 1);
|
|
1310
|
-
this.light.layers.mask = PRODUCT_LAYER_MASK;
|
|
1311
|
-
this.light.castShadow = true;
|
|
1312
|
-
this.light.shadow.mapSize.width = 512;
|
|
1313
|
-
this.light.shadow.mapSize.height = 512;
|
|
1314
|
-
this.add(this.light);
|
|
1315
|
-
const geoSize = 0.1;
|
|
1316
|
-
const geometry = new SphereGeometry(
|
|
1317
|
-
geoSize,
|
|
1318
|
-
geoSize * 320,
|
|
1319
|
-
geoSize * 320
|
|
1320
|
-
);
|
|
1321
|
-
const material = new MeshBasicMaterial({
|
|
1322
|
-
color: this.light.color,
|
|
1323
|
-
transparent: true,
|
|
1324
|
-
opacity: 0.8,
|
|
1325
|
-
side: FrontSide
|
|
1326
|
-
});
|
|
1327
|
-
this.mesh = new Mesh(geometry, material);
|
|
1328
|
-
this.mesh.layers.mask = UI_LAYER_MASK;
|
|
1329
|
-
this.add(this.mesh);
|
|
1330
|
-
}
|
|
1331
|
-
SetColor(color) {
|
|
1332
|
-
this.light.color = color;
|
|
1333
|
-
this.mesh.material.color = color;
|
|
1334
|
-
}
|
|
1335
|
-
SetIntensity(intensity) {
|
|
1336
|
-
this.light.intensity = intensity;
|
|
1337
|
-
this.mesh.material.opacity = intensity > 0.8 ? 0.8 : intensity * 0.8;
|
|
1338
|
-
}
|
|
1339
|
-
SetEnabled(enabled) {
|
|
1340
|
-
this.light.visible = enabled;
|
|
1341
|
-
}
|
|
1342
|
-
onMove() {
|
|
1343
|
-
var _a;
|
|
1344
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1345
|
-
"UPDATE_OBJECT",
|
|
1346
|
-
{ id: this.userData.id, position: this.position }
|
|
1347
|
-
);
|
|
1348
|
-
}
|
|
1349
|
-
onSelect() {
|
|
1350
|
-
var _a;
|
|
1351
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1352
|
-
"SELECT_OBJECT",
|
|
1353
|
-
{ id: this.userData.id }
|
|
1354
|
-
);
|
|
1355
|
-
}
|
|
1356
|
-
onDeselect() {
|
|
1357
|
-
var _a;
|
|
1358
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1359
|
-
"DESELECT_OBJECT",
|
|
1360
|
-
{ id: this.userData.id }
|
|
1361
|
-
);
|
|
1362
|
-
}
|
|
1363
|
-
};
|
|
1364
|
-
|
|
1365
|
-
// src/light/SceneLight.ts
|
|
1366
|
-
init_VisibilityLayerMask();
|
|
1367
|
-
import { DirectionalLight, HemisphereLight, Object3D as Object3D4 } from "three";
|
|
1368
|
-
var DIVESceneLight = class extends Object3D4 {
|
|
1369
|
-
constructor() {
|
|
1370
|
-
super();
|
|
1371
|
-
this.isDIVELight = true;
|
|
1372
|
-
this.isDIVESceneLight = true;
|
|
1373
|
-
this.name = "DIVESceneLight";
|
|
1374
|
-
this._hemiLight = new HemisphereLight(16777215, 16777215, 2);
|
|
1375
|
-
this._hemiLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
1376
|
-
this._hemiLight.position.set(0, 50, 0);
|
|
1377
|
-
this.add(this._hemiLight);
|
|
1378
|
-
this._dirLight = new DirectionalLight(16777215, 3);
|
|
1379
|
-
this._dirLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
1380
|
-
this._dirLight.position.set(1, 1.75, 1);
|
|
1381
|
-
this._dirLight.position.multiplyScalar(30);
|
|
1382
|
-
this._dirLight.castShadow = true;
|
|
1383
|
-
this._dirLight.shadow.mapSize.width = 2048;
|
|
1384
|
-
this._dirLight.shadow.mapSize.height = 2048;
|
|
1385
|
-
const d = 5;
|
|
1386
|
-
this._dirLight.shadow.camera.left = -d;
|
|
1387
|
-
this._dirLight.shadow.camera.right = d;
|
|
1388
|
-
this._dirLight.shadow.camera.top = d;
|
|
1389
|
-
this._dirLight.shadow.camera.bottom = -d;
|
|
1390
|
-
this._dirLight.shadow.camera.far = 3500;
|
|
1391
|
-
this.add(this._dirLight);
|
|
1392
|
-
}
|
|
1393
|
-
SetColor(color) {
|
|
1394
|
-
this._hemiLight.color = color;
|
|
1395
|
-
this._dirLight.color = color;
|
|
1396
|
-
}
|
|
1397
|
-
SetIntensity(intensity) {
|
|
1398
|
-
this._hemiLight.intensity = intensity * 2;
|
|
1399
|
-
this._dirLight.intensity = intensity * 3;
|
|
1400
|
-
}
|
|
1401
|
-
SetEnabled(enabled) {
|
|
1402
|
-
this._hemiLight.visible = enabled;
|
|
1403
|
-
this._dirLight.visible = enabled;
|
|
1404
|
-
}
|
|
1405
|
-
};
|
|
1406
|
-
|
|
1407
|
-
// src/model/Model.ts
|
|
1408
|
-
init_VisibilityLayerMask();
|
|
1409
|
-
import { MeshStandardMaterial, Raycaster as Raycaster2, Vector3 as Vector33 } from "three";
|
|
1410
|
-
|
|
1411
|
-
// src/helper/findSceneRecursive/findSceneRecursive.ts
|
|
1412
|
-
var findSceneRecursive = (object) => {
|
|
1413
|
-
if (object.parent) {
|
|
1414
|
-
return findSceneRecursive(object.parent);
|
|
1415
|
-
}
|
|
1416
|
-
return object;
|
|
1417
|
-
};
|
|
1418
|
-
|
|
1419
|
-
// src/node/Node.ts
|
|
1420
|
-
init_VisibilityLayerMask();
|
|
1421
|
-
import { Box3, Object3D as Object3D5, Vector3 as Vector32 } from "three";
|
|
1422
|
-
var DIVENode = class extends Object3D5 {
|
|
1423
|
-
constructor() {
|
|
1424
|
-
super();
|
|
1425
|
-
this.isDIVENode = true;
|
|
1426
|
-
this.isSelectable = true;
|
|
1427
|
-
this.isMovable = true;
|
|
1428
|
-
this.gizmo = null;
|
|
1429
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1430
|
-
this._positionWorldBuffer = new Vector32();
|
|
1431
|
-
this._boundingBox = new Box3();
|
|
1432
|
-
}
|
|
1433
|
-
SetPosition(position) {
|
|
1434
|
-
if (!this.parent) {
|
|
1435
|
-
this.position.set(position.x, position.y, position.z);
|
|
1436
|
-
return;
|
|
1437
|
-
}
|
|
1438
|
-
const newPosition = new Vector32(position.x, position.y, position.z);
|
|
1439
|
-
this.position.copy(this.parent.worldToLocal(newPosition));
|
|
1440
|
-
if ("isDIVEGroup" in this.parent) {
|
|
1441
|
-
this.parent.UpdateLineTo(this);
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
SetRotation(rotation) {
|
|
1445
|
-
this.rotation.set(rotation.x, rotation.y, rotation.z);
|
|
1446
|
-
}
|
|
1447
|
-
SetScale(scale) {
|
|
1448
|
-
this.scale.set(scale.x, scale.y, scale.z);
|
|
1449
|
-
}
|
|
1450
|
-
SetVisibility(visible) {
|
|
1451
|
-
this.visible = visible;
|
|
1452
|
-
}
|
|
1453
|
-
SetToWorldOrigin() {
|
|
1454
|
-
var _a;
|
|
1455
|
-
this.position.set(0, 0, 0);
|
|
1456
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1457
|
-
"UPDATE_OBJECT",
|
|
1458
|
-
{
|
|
1459
|
-
id: this.userData.id,
|
|
1460
|
-
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
1461
|
-
rotation: this.rotation,
|
|
1462
|
-
scale: this.scale
|
|
1463
|
-
}
|
|
1464
|
-
);
|
|
1465
|
-
}
|
|
1466
|
-
/**
|
|
1467
|
-
* Can be called when the object is moved from a foreign object (gizmo, parent, etc.) to update the object's position.
|
|
1468
|
-
*/
|
|
1469
|
-
onMove() {
|
|
1470
|
-
var _a;
|
|
1471
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1472
|
-
"UPDATE_OBJECT",
|
|
1473
|
-
{
|
|
1474
|
-
id: this.userData.id,
|
|
1475
|
-
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
1476
|
-
rotation: this.rotation,
|
|
1477
|
-
scale: this.scale
|
|
1478
|
-
}
|
|
1479
|
-
);
|
|
1480
|
-
}
|
|
1481
|
-
onSelect() {
|
|
1482
|
-
var _a;
|
|
1483
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1484
|
-
"SELECT_OBJECT",
|
|
1485
|
-
{ id: this.userData.id }
|
|
1486
|
-
);
|
|
1487
|
-
}
|
|
1488
|
-
onDeselect() {
|
|
1489
|
-
var _a;
|
|
1490
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1491
|
-
"DESELECT_OBJECT",
|
|
1492
|
-
{ id: this.userData.id }
|
|
1493
|
-
);
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
|
|
1497
|
-
// src/model/Model.ts
|
|
1498
|
-
var DIVEModel = class extends DIVENode {
|
|
1499
|
-
constructor() {
|
|
1500
|
-
super(...arguments);
|
|
1501
|
-
this.isDIVEModel = true;
|
|
1502
|
-
this._mesh = null;
|
|
1503
|
-
this._material = null;
|
|
1504
|
-
}
|
|
1505
|
-
SetModel(gltf) {
|
|
1506
|
-
this.clear();
|
|
1507
|
-
this._boundingBox.makeEmpty();
|
|
1508
|
-
gltf.scene.traverse((child) => {
|
|
1509
|
-
child.castShadow = true;
|
|
1510
|
-
child.receiveShadow = true;
|
|
1511
|
-
child.layers.mask = this.layers.mask;
|
|
1512
|
-
this._boundingBox.expandByObject(child);
|
|
1513
|
-
if (!this._mesh && "isMesh" in child) {
|
|
1514
|
-
this._mesh = child;
|
|
1515
|
-
if (this._material) {
|
|
1516
|
-
this._mesh.material = this._material;
|
|
1517
|
-
} else {
|
|
1518
|
-
this._material = child.material;
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
});
|
|
1522
|
-
this.add(gltf.scene);
|
|
1523
|
-
}
|
|
1524
|
-
SetMaterial(material) {
|
|
1525
|
-
if (!this._material) {
|
|
1526
|
-
this._material = new MeshStandardMaterial();
|
|
1527
|
-
}
|
|
1528
|
-
if (material.vertexColors !== void 0) {
|
|
1529
|
-
this._material.vertexColors = material.vertexColors;
|
|
1530
|
-
}
|
|
1531
|
-
if (material.color !== void 0) {
|
|
1532
|
-
this._material.color.set(material.color);
|
|
1533
|
-
}
|
|
1534
|
-
if (material.map !== void 0) {
|
|
1535
|
-
this._material.map = material.map;
|
|
1536
|
-
}
|
|
1537
|
-
if (material.normalMap !== void 0) {
|
|
1538
|
-
this._material.normalMap = material.normalMap;
|
|
1539
|
-
}
|
|
1540
|
-
if (material.roughness !== void 0) {
|
|
1541
|
-
this._material.roughness = material.roughness;
|
|
1542
|
-
}
|
|
1543
|
-
if (material.roughnessMap !== void 0) {
|
|
1544
|
-
this._material.roughnessMap = material.roughnessMap;
|
|
1545
|
-
if (this._material.roughnessMap) {
|
|
1546
|
-
this._material.roughness = 1;
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
if (material.metalness !== void 0) {
|
|
1550
|
-
this._material.metalness = material.metalness;
|
|
1551
|
-
}
|
|
1552
|
-
if (material.metalnessMap !== void 0) {
|
|
1553
|
-
this._material.metalnessMap = material.metalnessMap;
|
|
1554
|
-
if (this._material.metalnessMap) {
|
|
1555
|
-
this._material.metalness = 1;
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
if (this._mesh) {
|
|
1559
|
-
this._mesh.material = this._material;
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
PlaceOnFloor() {
|
|
1563
|
-
var _a;
|
|
1564
|
-
const worldPos = this.getWorldPosition(this._positionWorldBuffer);
|
|
1565
|
-
const oldWorldPos = worldPos.clone();
|
|
1566
|
-
worldPos.y = (this._boundingBox.max.y - this._boundingBox.min.y) / 2;
|
|
1567
|
-
if (worldPos.y === oldWorldPos.y) return;
|
|
1568
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1569
|
-
"UPDATE_OBJECT",
|
|
1570
|
-
{
|
|
1571
|
-
id: this.userData.id,
|
|
1572
|
-
position: worldPos,
|
|
1573
|
-
rotation: this.rotation,
|
|
1574
|
-
scale: this.scale
|
|
1575
|
-
}
|
|
1576
|
-
);
|
|
1577
|
-
}
|
|
1578
|
-
DropIt() {
|
|
1579
|
-
if (!this.parent) {
|
|
1580
|
-
console.warn(
|
|
1581
|
-
"DIVEModel: DropIt() called on a model that is not in the scene.",
|
|
1582
|
-
this
|
|
1583
|
-
);
|
|
1584
|
-
return;
|
|
1585
|
-
}
|
|
1586
|
-
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1587
|
-
const bbBottomCenter = this.localToWorld(
|
|
1588
|
-
this._boundingBox.getCenter(new Vector33()).multiply(this.scale)
|
|
1589
|
-
);
|
|
1590
|
-
bbBottomCenter.y = bottomY + this.position.y;
|
|
1591
|
-
const raycaster = new Raycaster2(bbBottomCenter, new Vector33(0, -1, 0));
|
|
1592
|
-
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1593
|
-
const intersections = raycaster.intersectObjects(
|
|
1594
|
-
findSceneRecursive(this).Root.children,
|
|
1595
|
-
true
|
|
1596
|
-
);
|
|
1597
|
-
if (intersections.length > 0) {
|
|
1598
|
-
const mesh = intersections[0].object;
|
|
1599
|
-
mesh.geometry.computeBoundingBox();
|
|
1600
|
-
const meshBB = mesh.geometry.boundingBox;
|
|
1601
|
-
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1602
|
-
const oldPos = this.position.clone();
|
|
1603
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new Vector33(0, bottomY, 0));
|
|
1604
|
-
this.position.copy(newPos);
|
|
1605
|
-
if (this.position.y === oldPos.y) return;
|
|
1606
|
-
this.onMove();
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
};
|
|
1610
|
-
|
|
1611
|
-
// src/loadingmanager/LoadingManager.ts
|
|
1612
|
-
import { DRACOLoader, GLTFLoader as GLTFLoader2 } from "three/examples/jsm/Addons.js";
|
|
1613
|
-
var DIVELoadingManager = class {
|
|
1614
|
-
// ... maybe extend with other loaders later
|
|
1615
|
-
constructor() {
|
|
1616
|
-
this.progress = /* @__PURE__ */ new Map();
|
|
1617
|
-
this.gltfloader = new GLTFLoader2();
|
|
1618
|
-
this.dracoloader = new DRACOLoader();
|
|
1619
|
-
this.dracoloader.setDecoderPath(
|
|
1620
|
-
"https://www.gstatic.com/draco/v1/decoders/"
|
|
1621
|
-
);
|
|
1622
|
-
this.gltfloader.setDRACOLoader(this.dracoloader);
|
|
1623
|
-
}
|
|
1624
|
-
LoadGLTF(uri) {
|
|
1625
|
-
return __async(this, null, function* () {
|
|
1626
|
-
const progEvent = (p) => {
|
|
1627
|
-
this.progress.set(uri, p.loaded / p.total);
|
|
1628
|
-
};
|
|
1629
|
-
this.progress.set(uri, 0);
|
|
1630
|
-
return new Promise((resolve, reject) => {
|
|
1631
|
-
this.gltfloader.loadAsync(uri, progEvent).then(resolve).catch(reject);
|
|
1632
|
-
});
|
|
1633
|
-
});
|
|
1634
|
-
}
|
|
1635
|
-
PollProgress() {
|
|
1636
|
-
let total = 0;
|
|
1637
|
-
this.progress.forEach((progress) => {
|
|
1638
|
-
total += progress;
|
|
1639
|
-
});
|
|
1640
|
-
if (this.progress.size === 0) return 1;
|
|
1641
|
-
return total / this.progress.size;
|
|
1642
|
-
}
|
|
1643
|
-
};
|
|
1644
|
-
|
|
1645
|
-
// src/primitive/Primitive.ts
|
|
1646
|
-
init_VisibilityLayerMask();
|
|
1647
|
-
import {
|
|
1648
|
-
BoxGeometry,
|
|
1649
|
-
BufferAttribute,
|
|
1650
|
-
BufferGeometry,
|
|
1651
|
-
Color as Color4,
|
|
1652
|
-
ConeGeometry,
|
|
1653
|
-
CylinderGeometry,
|
|
1654
|
-
Mesh as Mesh3,
|
|
1655
|
-
MeshStandardMaterial as MeshStandardMaterial2,
|
|
1656
|
-
Raycaster as Raycaster3,
|
|
1657
|
-
SphereGeometry as SphereGeometry2,
|
|
1658
|
-
Vector3 as Vector34
|
|
1659
|
-
} from "three";
|
|
1660
|
-
var DIVEPrimitive = class extends DIVENode {
|
|
1661
|
-
constructor() {
|
|
1662
|
-
super();
|
|
1663
|
-
this.isDIVEPrimitive = true;
|
|
1664
|
-
this._mesh = new Mesh3();
|
|
1665
|
-
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1666
|
-
this._mesh.castShadow = true;
|
|
1667
|
-
this._mesh.receiveShadow = true;
|
|
1668
|
-
this._mesh.material = new MeshStandardMaterial2();
|
|
1669
|
-
this.add(this._mesh);
|
|
1670
|
-
}
|
|
1671
|
-
SetGeometry(geometry) {
|
|
1672
|
-
const geo = this.assembleGeometry(geometry);
|
|
1673
|
-
if (!geo) return;
|
|
1674
|
-
this._mesh.geometry = geo;
|
|
1675
|
-
this._boundingBox.setFromObject(this._mesh);
|
|
1676
|
-
}
|
|
1677
|
-
SetMaterial(material) {
|
|
1678
|
-
const primitiveMaterial = this._mesh.material;
|
|
1679
|
-
if (material.vertexColors !== void 0) {
|
|
1680
|
-
primitiveMaterial.vertexColors = material.vertexColors;
|
|
1681
|
-
}
|
|
1682
|
-
if (material.color !== void 0) {
|
|
1683
|
-
primitiveMaterial.color = new Color4(material.color);
|
|
1684
|
-
}
|
|
1685
|
-
if (material.map !== void 0) {
|
|
1686
|
-
primitiveMaterial.map = material.map;
|
|
1687
|
-
}
|
|
1688
|
-
if (material.normalMap !== void 0) {
|
|
1689
|
-
primitiveMaterial.normalMap = material.normalMap;
|
|
1690
|
-
}
|
|
1691
|
-
if (material.roughness !== void 0) {
|
|
1692
|
-
primitiveMaterial.roughness = material.roughness;
|
|
1693
|
-
}
|
|
1694
|
-
if (material.roughnessMap !== void 0) {
|
|
1695
|
-
primitiveMaterial.roughnessMap = material.roughnessMap;
|
|
1696
|
-
if (primitiveMaterial.roughnessMap) {
|
|
1697
|
-
primitiveMaterial.roughness = 1;
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
if (material.metalness !== void 0) {
|
|
1701
|
-
primitiveMaterial.metalness = material.metalness;
|
|
1702
|
-
}
|
|
1703
|
-
if (material.metalnessMap !== void 0) {
|
|
1704
|
-
primitiveMaterial.metalnessMap = material.metalnessMap;
|
|
1705
|
-
if (primitiveMaterial.metalnessMap) {
|
|
1706
|
-
primitiveMaterial.metalness = 0;
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
if (this._mesh) this._mesh.material = primitiveMaterial;
|
|
1710
|
-
}
|
|
1711
|
-
PlaceOnFloor() {
|
|
1712
|
-
var _a;
|
|
1713
|
-
const worldPos = this.getWorldPosition(this._positionWorldBuffer);
|
|
1714
|
-
const oldWorldPos = worldPos.clone();
|
|
1715
|
-
worldPos.y = (this._boundingBox.max.y - this._boundingBox.min.y) / 2;
|
|
1716
|
-
if (worldPos.y === oldWorldPos.y) return;
|
|
1717
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
1718
|
-
"UPDATE_OBJECT",
|
|
1719
|
-
{
|
|
1720
|
-
id: this.userData.id,
|
|
1721
|
-
position: worldPos,
|
|
1722
|
-
rotation: this.rotation,
|
|
1723
|
-
scale: this.scale
|
|
1724
|
-
}
|
|
1725
|
-
);
|
|
1726
|
-
}
|
|
1727
|
-
DropIt() {
|
|
1728
|
-
if (!this.parent) {
|
|
1729
|
-
console.warn(
|
|
1730
|
-
"DIVEPrimitive: DropIt() called on a model that is not in the scene.",
|
|
1731
|
-
this
|
|
1732
|
-
);
|
|
1733
|
-
return;
|
|
1734
|
-
}
|
|
1735
|
-
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1736
|
-
const bbBottomCenter = this.localToWorld(
|
|
1737
|
-
this._boundingBox.getCenter(new Vector34()).multiply(this.scale)
|
|
1738
|
-
);
|
|
1739
|
-
bbBottomCenter.y = bottomY + this.position.y;
|
|
1740
|
-
const raycaster = new Raycaster3(bbBottomCenter, new Vector34(0, -1, 0));
|
|
1741
|
-
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1742
|
-
const intersections = raycaster.intersectObjects(
|
|
1743
|
-
findSceneRecursive(this).Root.children,
|
|
1744
|
-
true
|
|
1745
|
-
);
|
|
1746
|
-
if (intersections.length > 0) {
|
|
1747
|
-
const mesh = intersections[0].object;
|
|
1748
|
-
mesh.geometry.computeBoundingBox();
|
|
1749
|
-
const meshBB = mesh.geometry.boundingBox;
|
|
1750
|
-
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1751
|
-
const oldPos = this.position.clone();
|
|
1752
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new Vector34(0, bottomY, 0));
|
|
1753
|
-
this.position.copy(newPos);
|
|
1754
|
-
if (this.position.y === oldPos.y) return;
|
|
1755
|
-
this.onMove();
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
assembleGeometry(geometry) {
|
|
1759
|
-
this._mesh.material.flatShading = false;
|
|
1760
|
-
switch (geometry.name.toLowerCase()) {
|
|
1761
|
-
case "cylinder":
|
|
1762
|
-
return this.createCylinderGeometry(geometry);
|
|
1763
|
-
case "sphere":
|
|
1764
|
-
return this.createSphereGeometry(geometry);
|
|
1765
|
-
case "pyramid":
|
|
1766
|
-
this._mesh.material.flatShading = true;
|
|
1767
|
-
return this.createPyramidGeometry(geometry);
|
|
1768
|
-
case "cube":
|
|
1769
|
-
case "box":
|
|
1770
|
-
return this.createBoxGeometry(geometry);
|
|
1771
|
-
case "cone":
|
|
1772
|
-
return this.createConeGeometry(geometry);
|
|
1773
|
-
case "wall":
|
|
1774
|
-
return this.createWallGeometry(geometry);
|
|
1775
|
-
case "plane":
|
|
1776
|
-
return this.createPlaneGeometry(geometry);
|
|
1777
|
-
default: {
|
|
1778
|
-
console.warn(
|
|
1779
|
-
"DIVEPrimitive.assembleGeometry: Invalid geometry type:",
|
|
1780
|
-
geometry.name.toLowerCase()
|
|
1781
|
-
);
|
|
1782
|
-
return null;
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
createCylinderGeometry(geometry) {
|
|
1787
|
-
const geo = new CylinderGeometry(
|
|
1788
|
-
geometry.width / 2,
|
|
1789
|
-
geometry.width / 2,
|
|
1790
|
-
geometry.height,
|
|
1791
|
-
64
|
|
1792
|
-
);
|
|
1793
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
1794
|
-
return geo;
|
|
1795
|
-
}
|
|
1796
|
-
createSphereGeometry(geometry) {
|
|
1797
|
-
const geo = new SphereGeometry2(geometry.width / 2, 256, 256);
|
|
1798
|
-
return geo;
|
|
1799
|
-
}
|
|
1800
|
-
createPyramidGeometry(geometry) {
|
|
1801
|
-
const vertices = new Float32Array([
|
|
1802
|
-
-geometry.width / 2,
|
|
1803
|
-
0,
|
|
1804
|
-
-geometry.depth / 2,
|
|
1805
|
-
// 0
|
|
1806
|
-
geometry.width / 2,
|
|
1807
|
-
0,
|
|
1808
|
-
-geometry.depth / 2,
|
|
1809
|
-
// 1
|
|
1810
|
-
geometry.width / 2,
|
|
1811
|
-
0,
|
|
1812
|
-
geometry.depth / 2,
|
|
1813
|
-
// 2
|
|
1814
|
-
-geometry.width / 2,
|
|
1815
|
-
0,
|
|
1816
|
-
geometry.depth / 2,
|
|
1817
|
-
// 3
|
|
1818
|
-
0,
|
|
1819
|
-
geometry.height,
|
|
1820
|
-
0
|
|
1821
|
-
]);
|
|
1822
|
-
const indices = new Uint16Array([
|
|
1823
|
-
0,
|
|
1824
|
-
1,
|
|
1825
|
-
2,
|
|
1826
|
-
0,
|
|
1827
|
-
2,
|
|
1828
|
-
3,
|
|
1829
|
-
0,
|
|
1830
|
-
4,
|
|
1831
|
-
1,
|
|
1832
|
-
1,
|
|
1833
|
-
4,
|
|
1834
|
-
2,
|
|
1835
|
-
2,
|
|
1836
|
-
4,
|
|
1837
|
-
3,
|
|
1838
|
-
3,
|
|
1839
|
-
4,
|
|
1840
|
-
0
|
|
1841
|
-
]);
|
|
1842
|
-
const geometryBuffer = new BufferGeometry();
|
|
1843
|
-
geometryBuffer.setAttribute(
|
|
1844
|
-
"position",
|
|
1845
|
-
new BufferAttribute(vertices, 3)
|
|
1846
|
-
);
|
|
1847
|
-
geometryBuffer.setIndex(new BufferAttribute(indices, 1));
|
|
1848
|
-
geometryBuffer.computeVertexNormals();
|
|
1849
|
-
geometryBuffer.computeBoundingBox();
|
|
1850
|
-
geometryBuffer.computeBoundingSphere();
|
|
1851
|
-
return geometryBuffer;
|
|
1852
|
-
}
|
|
1853
|
-
createBoxGeometry(geometry) {
|
|
1854
|
-
const geo = new BoxGeometry(
|
|
1855
|
-
geometry.width,
|
|
1856
|
-
geometry.height,
|
|
1857
|
-
geometry.depth
|
|
1858
|
-
);
|
|
1859
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
1860
|
-
return geo;
|
|
1861
|
-
}
|
|
1862
|
-
createConeGeometry(geometry) {
|
|
1863
|
-
const geo = new ConeGeometry(geometry.width / 2, geometry.height, 256);
|
|
1864
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
1865
|
-
return geo;
|
|
1866
|
-
}
|
|
1867
|
-
createWallGeometry(geometry) {
|
|
1868
|
-
const geo = new BoxGeometry(
|
|
1869
|
-
geometry.width,
|
|
1870
|
-
geometry.height,
|
|
1871
|
-
geometry.depth || 0.05,
|
|
1872
|
-
16
|
|
1873
|
-
);
|
|
1874
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
1875
|
-
return geo;
|
|
1876
|
-
}
|
|
1877
|
-
createPlaneGeometry(geometry) {
|
|
1878
|
-
const geo = new BoxGeometry(
|
|
1879
|
-
geometry.width,
|
|
1880
|
-
geometry.height,
|
|
1881
|
-
geometry.depth
|
|
1882
|
-
);
|
|
1883
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
1884
|
-
return geo;
|
|
1885
|
-
}
|
|
1886
|
-
};
|
|
1887
|
-
|
|
1888
|
-
// src/group/Group.ts
|
|
1889
|
-
import {
|
|
1890
|
-
BufferGeometry as BufferGeometry2,
|
|
1891
|
-
Line,
|
|
1892
|
-
LineDashedMaterial,
|
|
1893
|
-
Vector3 as Vector35
|
|
1894
|
-
} from "three";
|
|
1895
|
-
var DIVEGroup = class extends DIVENode {
|
|
1896
|
-
// lines to children
|
|
1897
|
-
constructor() {
|
|
1898
|
-
super();
|
|
1899
|
-
this.isDIVEGroup = true;
|
|
1900
|
-
this.name = "DIVEGroup";
|
|
1901
|
-
this._members = [];
|
|
1902
|
-
this._lines = [];
|
|
1903
|
-
}
|
|
1904
|
-
// children objects
|
|
1905
|
-
get members() {
|
|
1906
|
-
return this._members;
|
|
1907
|
-
}
|
|
1908
|
-
SetPosition(position) {
|
|
1909
|
-
super.SetPosition(position);
|
|
1910
|
-
this._members.forEach((member) => {
|
|
1911
|
-
if ("isDIVENode" in member) {
|
|
1912
|
-
member.onMove();
|
|
1913
|
-
}
|
|
1914
|
-
});
|
|
1915
|
-
}
|
|
1916
|
-
SetLinesVisibility(visible, object) {
|
|
1917
|
-
if (!object) {
|
|
1918
|
-
this._lines.forEach((line) => {
|
|
1919
|
-
line.visible = visible;
|
|
1920
|
-
});
|
|
1921
|
-
return;
|
|
1922
|
-
}
|
|
1923
|
-
const index = this._members.indexOf(object);
|
|
1924
|
-
if (index === -1) return;
|
|
1925
|
-
this._lines[index].visible = visible;
|
|
1926
|
-
}
|
|
1927
|
-
attach(object) {
|
|
1928
|
-
const line = this.createLine();
|
|
1929
|
-
this.add(line);
|
|
1930
|
-
this._lines.push(line);
|
|
1931
|
-
super.attach(object);
|
|
1932
|
-
this._members.push(object);
|
|
1933
|
-
this.updateLineTo(line, object);
|
|
1934
|
-
this.SetLinesVisibility(true, object);
|
|
1935
|
-
return this;
|
|
1936
|
-
}
|
|
1937
|
-
remove(object) {
|
|
1938
|
-
const index = this._members.indexOf(object);
|
|
1939
|
-
if (index === -1) return this;
|
|
1940
|
-
const line = this._lines[index];
|
|
1941
|
-
super.remove(line);
|
|
1942
|
-
this._lines.splice(index, 1);
|
|
1943
|
-
super.remove(object);
|
|
1944
|
-
this._members.splice(index, 1);
|
|
1945
|
-
return this;
|
|
1946
|
-
}
|
|
1947
|
-
UpdateLineTo(object) {
|
|
1948
|
-
const index = this._members.indexOf(object);
|
|
1949
|
-
if (index === -1) return;
|
|
1950
|
-
this.updateLineTo(this._lines[index], object);
|
|
1951
|
-
}
|
|
1952
|
-
/**
|
|
1953
|
-
* Adds a line to this grouo as last child.
|
|
1954
|
-
*/
|
|
1955
|
-
createLine() {
|
|
1956
|
-
const geo = new BufferGeometry2();
|
|
1957
|
-
const mat = new LineDashedMaterial({
|
|
1958
|
-
color: 6710886,
|
|
1959
|
-
dashSize: 0.05,
|
|
1960
|
-
gapSize: 0.025
|
|
1961
|
-
});
|
|
1962
|
-
const line = new Line(geo, mat);
|
|
1963
|
-
line.visible = false;
|
|
1964
|
-
return line;
|
|
1965
|
-
}
|
|
1966
|
-
/**
|
|
1967
|
-
* Updates a line to the object.
|
|
1968
|
-
*/
|
|
1969
|
-
updateLineTo(line, object) {
|
|
1970
|
-
line.geometry.setFromPoints([
|
|
1971
|
-
new Vector35(0, 0, 0),
|
|
1972
|
-
object.position.clone()
|
|
1973
|
-
]);
|
|
1974
|
-
line.computeLineDistances();
|
|
1975
|
-
}
|
|
1976
|
-
// public SetBoundingBoxVisibility(visible: boolean): void {
|
|
1977
|
-
// this._boxMesh.visible = visible;
|
|
1978
|
-
// }
|
|
1979
|
-
// /**
|
|
1980
|
-
// * Recalculates the position of the group based on it's bounding box.
|
|
1981
|
-
// * Children's world positions are kept.
|
|
1982
|
-
// */
|
|
1983
|
-
// private recalculatePosition(): void {
|
|
1984
|
-
// // store all children's world positions
|
|
1985
|
-
// const childrensWorldPositions: Vector3[] = this.children.map((child) => child.getWorldPosition(new Vector3()));
|
|
1986
|
-
// // calculate new center and set it as the group's position
|
|
1987
|
-
// const bbcenter = this.updateBB();
|
|
1988
|
-
// this.position.copy(bbcenter);
|
|
1989
|
-
// // set childrens's positions so their world positions are kept
|
|
1990
|
-
// this.children.forEach((child, i) => {
|
|
1991
|
-
// if (child.uuid === this._boxMesh.uuid) return;
|
|
1992
|
-
// child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
1993
|
-
// });
|
|
1994
|
-
// DIVECommunication.get(this.userData.id)?.PerformAction('UPDATE_OBJECT', { id: this.userData.id, position: this.position });
|
|
1995
|
-
// }
|
|
1996
|
-
// /**
|
|
1997
|
-
// * Updates the bounding box of the group.
|
|
1998
|
-
// * @returns {Vector3} The new center of the bounding box.
|
|
1999
|
-
// */
|
|
2000
|
-
// private updateBB(): Vector3 {
|
|
2001
|
-
// this._boundingBox.makeEmpty();
|
|
2002
|
-
// if (this.children.length === 1) {
|
|
2003
|
-
// // because we always have the box mesh as 1 child
|
|
2004
|
-
// return this.position.clone();
|
|
2005
|
-
// }
|
|
2006
|
-
// this.children.forEach((child) => {
|
|
2007
|
-
// if (child.uuid === this._boxMesh.uuid) return;
|
|
2008
|
-
// this._boundingBox.expandByObject(child);
|
|
2009
|
-
// });
|
|
2010
|
-
// return this._boundingBox.getCenter(new Vector3());
|
|
2011
|
-
// }
|
|
2012
|
-
// private updateBoxMesh(): void {
|
|
2013
|
-
// if (this.children.length === 1) {
|
|
2014
|
-
// // because we always have the box mesh as 1 child
|
|
2015
|
-
// this._boxMesh.visible = false;
|
|
2016
|
-
// return;
|
|
2017
|
-
// }
|
|
2018
|
-
// this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
|
|
2019
|
-
// this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
|
|
2020
|
-
// this._boxMesh.geometry = new BoxGeometry(this._boundingBox.max.x - this._boundingBox.min.x, this._boundingBox.max.y - this._boundingBox.min.y, this._boundingBox.max.z - this._boundingBox.min.z);
|
|
2021
|
-
// this._boxMesh.visible = true;
|
|
2022
|
-
// }
|
|
2023
|
-
};
|
|
2024
|
-
|
|
2025
|
-
// src/scene/root/Root.ts
|
|
2026
|
-
var DIVERoot = class extends Object3D6 {
|
|
2027
|
-
constructor() {
|
|
2028
|
-
super();
|
|
2029
|
-
this.isDIVERoot = true;
|
|
2030
|
-
this.name = "Root";
|
|
2031
|
-
this.loadingManager = new DIVELoadingManager();
|
|
2032
|
-
}
|
|
2033
|
-
ComputeSceneBB() {
|
|
2034
|
-
const bb = new Box32();
|
|
2035
|
-
this.traverse((object) => {
|
|
2036
|
-
if ("isObject3D" in object) {
|
|
2037
|
-
bb.expandByObject(object);
|
|
2038
|
-
}
|
|
2039
|
-
});
|
|
2040
|
-
return bb;
|
|
2041
|
-
}
|
|
2042
|
-
GetSceneObject(object) {
|
|
2043
|
-
let foundObject;
|
|
2044
|
-
this.traverse((object3D) => {
|
|
2045
|
-
if (foundObject) return;
|
|
2046
|
-
if (object3D.userData.id === object.id) {
|
|
2047
|
-
foundObject = object3D;
|
|
2048
|
-
}
|
|
2049
|
-
});
|
|
2050
|
-
return foundObject;
|
|
2051
|
-
}
|
|
2052
|
-
AddSceneObject(object) {
|
|
2053
|
-
switch (object.entityType) {
|
|
2054
|
-
case "pov": {
|
|
2055
|
-
break;
|
|
2056
|
-
}
|
|
2057
|
-
case "light": {
|
|
2058
|
-
this.updateLight(object);
|
|
2059
|
-
break;
|
|
2060
|
-
}
|
|
2061
|
-
case "model": {
|
|
2062
|
-
this.updateModel(object);
|
|
2063
|
-
break;
|
|
2064
|
-
}
|
|
2065
|
-
case "primitive": {
|
|
2066
|
-
this.updatePrimitive(object);
|
|
2067
|
-
break;
|
|
2068
|
-
}
|
|
2069
|
-
case "group": {
|
|
2070
|
-
this.updateGroup(object);
|
|
2071
|
-
break;
|
|
2072
|
-
}
|
|
2073
|
-
default: {
|
|
2074
|
-
console.warn(
|
|
2075
|
-
`DIVERoot.AddSceneObject: Unknown entity type: ${object.entityType}`
|
|
2076
|
-
);
|
|
2077
|
-
}
|
|
2078
|
-
}
|
|
2079
|
-
}
|
|
2080
|
-
UpdateSceneObject(object) {
|
|
2081
|
-
switch (object.entityType) {
|
|
2082
|
-
case "pov": {
|
|
2083
|
-
break;
|
|
2084
|
-
}
|
|
2085
|
-
case "light": {
|
|
2086
|
-
this.updateLight(object);
|
|
2087
|
-
break;
|
|
2088
|
-
}
|
|
2089
|
-
case "model": {
|
|
2090
|
-
this.updateModel(object);
|
|
2091
|
-
break;
|
|
2092
|
-
}
|
|
2093
|
-
case "primitive": {
|
|
2094
|
-
this.updatePrimitive(object);
|
|
2095
|
-
break;
|
|
2096
|
-
}
|
|
2097
|
-
case "group": {
|
|
2098
|
-
this.updateGroup(object);
|
|
2099
|
-
break;
|
|
2100
|
-
}
|
|
2101
|
-
default: {
|
|
2102
|
-
console.warn(
|
|
2103
|
-
`DIVERoot.UpdateSceneObject: Unknown entity type: ${object.entityType}`
|
|
2104
|
-
);
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
|
-
DeleteSceneObject(object) {
|
|
2109
|
-
switch (object.entityType) {
|
|
2110
|
-
case "pov": {
|
|
2111
|
-
break;
|
|
2112
|
-
}
|
|
2113
|
-
case "light": {
|
|
2114
|
-
this.deleteLight(object);
|
|
2115
|
-
break;
|
|
2116
|
-
}
|
|
2117
|
-
case "model": {
|
|
2118
|
-
this.deleteModel(object);
|
|
2119
|
-
break;
|
|
2120
|
-
}
|
|
2121
|
-
case "primitive": {
|
|
2122
|
-
this.deletePrimitive(object);
|
|
2123
|
-
break;
|
|
2124
|
-
}
|
|
2125
|
-
case "group": {
|
|
2126
|
-
this.deleteGroup(object);
|
|
2127
|
-
break;
|
|
2128
|
-
}
|
|
2129
|
-
default: {
|
|
2130
|
-
console.warn(
|
|
2131
|
-
`DIVERoot.DeleteSceneObject: Unknown entity type: ${object.entityType}`
|
|
2132
|
-
);
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
}
|
|
2136
|
-
PlaceOnFloor(object) {
|
|
2137
|
-
switch (object.entityType) {
|
|
2138
|
-
case "pov":
|
|
2139
|
-
case "light": {
|
|
2140
|
-
break;
|
|
2141
|
-
}
|
|
2142
|
-
case "model":
|
|
2143
|
-
case "primitive": {
|
|
2144
|
-
this.placeOnFloor(object);
|
|
2145
|
-
break;
|
|
2146
|
-
}
|
|
2147
|
-
default: {
|
|
2148
|
-
console.warn(
|
|
2149
|
-
`DIVERoot.PlaceOnFloor: Unknown entity type: ${object.entityType}`
|
|
2150
|
-
);
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
updateLight(light) {
|
|
2155
|
-
let sceneObject = this.GetSceneObject(light);
|
|
2156
|
-
if (!sceneObject) {
|
|
2157
|
-
switch (light.type) {
|
|
2158
|
-
case "scene": {
|
|
2159
|
-
sceneObject = new DIVESceneLight();
|
|
2160
|
-
break;
|
|
2161
|
-
}
|
|
2162
|
-
case "ambient": {
|
|
2163
|
-
sceneObject = new DIVEAmbientLight();
|
|
2164
|
-
break;
|
|
2165
|
-
}
|
|
2166
|
-
case "point": {
|
|
2167
|
-
sceneObject = new DIVEPointLight();
|
|
2168
|
-
break;
|
|
2169
|
-
}
|
|
2170
|
-
default: {
|
|
2171
|
-
console.warn(
|
|
2172
|
-
`DIVERoot.updateLight: Unknown light type: ${light.type}`
|
|
2173
|
-
);
|
|
2174
|
-
return;
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
sceneObject.userData.id = light.id;
|
|
2178
|
-
this.add(sceneObject);
|
|
2179
|
-
}
|
|
2180
|
-
if (light.name !== void 0 && light.name !== null)
|
|
2181
|
-
sceneObject.name = light.name;
|
|
2182
|
-
if (light.position !== void 0 && light.position !== null)
|
|
2183
|
-
sceneObject.position.set(
|
|
2184
|
-
light.position.x,
|
|
2185
|
-
light.position.y,
|
|
2186
|
-
light.position.z
|
|
2187
|
-
);
|
|
2188
|
-
if (light.intensity !== void 0 && light.intensity !== null)
|
|
2189
|
-
sceneObject.SetIntensity(
|
|
2190
|
-
light.intensity
|
|
2191
|
-
);
|
|
2192
|
-
if (light.enabled !== void 0 && light.enabled !== null)
|
|
2193
|
-
sceneObject.SetEnabled(
|
|
2194
|
-
light.enabled
|
|
2195
|
-
);
|
|
2196
|
-
if (light.color !== void 0 && light.color !== null)
|
|
2197
|
-
sceneObject.SetColor(
|
|
2198
|
-
new Color5(light.color)
|
|
2199
|
-
);
|
|
2200
|
-
if (light.visible !== void 0 && light.visible !== null)
|
|
2201
|
-
sceneObject.visible = light.visible;
|
|
2202
|
-
if (light.parentId !== void 0)
|
|
2203
|
-
this.setParent(__spreadProps(__spreadValues({}, light), { parentId: light.parentId }));
|
|
2204
|
-
}
|
|
2205
|
-
updateModel(model) {
|
|
2206
|
-
let sceneObject = this.GetSceneObject(model);
|
|
2207
|
-
if (!sceneObject) {
|
|
2208
|
-
const created = new DIVEModel();
|
|
2209
|
-
sceneObject = created;
|
|
2210
|
-
sceneObject.userData.id = model.id;
|
|
2211
|
-
this.add(sceneObject);
|
|
2212
|
-
}
|
|
2213
|
-
if (model.uri !== void 0) {
|
|
2214
|
-
this.loadingManager.LoadGLTF(model.uri).then((gltf) => {
|
|
2215
|
-
var _a;
|
|
2216
|
-
sceneObject.SetModel(gltf);
|
|
2217
|
-
(_a = DIVECommunication.get(model.id)) == null ? void 0 : _a.PerformAction(
|
|
2218
|
-
"MODEL_LOADED",
|
|
2219
|
-
{ id: model.id }
|
|
2220
|
-
);
|
|
2221
|
-
});
|
|
2222
|
-
}
|
|
2223
|
-
if (model.name !== void 0) sceneObject.name = model.name;
|
|
2224
|
-
if (model.position !== void 0)
|
|
2225
|
-
sceneObject.SetPosition(model.position);
|
|
2226
|
-
if (model.rotation !== void 0)
|
|
2227
|
-
sceneObject.SetRotation(model.rotation);
|
|
2228
|
-
if (model.scale !== void 0)
|
|
2229
|
-
sceneObject.SetScale(model.scale);
|
|
2230
|
-
if (model.visible !== void 0)
|
|
2231
|
-
sceneObject.SetVisibility(model.visible);
|
|
2232
|
-
if (model.material !== void 0)
|
|
2233
|
-
sceneObject.SetMaterial(model.material);
|
|
2234
|
-
if (model.parentId !== void 0)
|
|
2235
|
-
this.setParent(__spreadProps(__spreadValues({}, model), { parentId: model.parentId }));
|
|
2236
|
-
}
|
|
2237
|
-
updatePrimitive(primitive) {
|
|
2238
|
-
let sceneObject = this.GetSceneObject(primitive);
|
|
2239
|
-
if (!sceneObject) {
|
|
2240
|
-
const created = new DIVEPrimitive();
|
|
2241
|
-
sceneObject = created;
|
|
2242
|
-
sceneObject.userData.id = primitive.id;
|
|
2243
|
-
this.add(sceneObject);
|
|
2244
|
-
}
|
|
2245
|
-
if (primitive.name !== void 0) sceneObject.name = primitive.name;
|
|
2246
|
-
if (primitive.geometry !== void 0)
|
|
2247
|
-
sceneObject.SetGeometry(primitive.geometry);
|
|
2248
|
-
if (primitive.position !== void 0)
|
|
2249
|
-
sceneObject.SetPosition(primitive.position);
|
|
2250
|
-
if (primitive.rotation !== void 0)
|
|
2251
|
-
sceneObject.SetRotation(primitive.rotation);
|
|
2252
|
-
if (primitive.scale !== void 0)
|
|
2253
|
-
sceneObject.SetScale(primitive.scale);
|
|
2254
|
-
if (primitive.visible !== void 0)
|
|
2255
|
-
sceneObject.SetVisibility(primitive.visible);
|
|
2256
|
-
if (primitive.material !== void 0)
|
|
2257
|
-
sceneObject.SetMaterial(primitive.material);
|
|
2258
|
-
if (primitive.parentId !== void 0)
|
|
2259
|
-
this.setParent(__spreadProps(__spreadValues({}, primitive), { parentId: primitive.parentId }));
|
|
2260
|
-
}
|
|
2261
|
-
updateGroup(group) {
|
|
2262
|
-
let sceneObject = this.GetSceneObject(group);
|
|
2263
|
-
if (!sceneObject) {
|
|
2264
|
-
const created = new DIVEGroup();
|
|
2265
|
-
sceneObject = created;
|
|
2266
|
-
sceneObject.userData.id = group.id;
|
|
2267
|
-
this.add(sceneObject);
|
|
2268
|
-
}
|
|
2269
|
-
if (group.name !== void 0) sceneObject.name = group.name;
|
|
2270
|
-
if (group.position !== void 0)
|
|
2271
|
-
sceneObject.SetPosition(group.position);
|
|
2272
|
-
if (group.rotation !== void 0)
|
|
2273
|
-
sceneObject.SetRotation(group.rotation);
|
|
2274
|
-
if (group.scale !== void 0)
|
|
2275
|
-
sceneObject.SetScale(group.scale);
|
|
2276
|
-
if (group.visible !== void 0)
|
|
2277
|
-
sceneObject.SetVisibility(group.visible);
|
|
2278
|
-
if (group.bbVisible !== void 0)
|
|
2279
|
-
sceneObject.SetLinesVisibility(group.bbVisible);
|
|
2280
|
-
if (group.parentId !== void 0)
|
|
2281
|
-
this.setParent(__spreadProps(__spreadValues({}, group), { parentId: group.parentId }));
|
|
2282
|
-
}
|
|
2283
|
-
deleteLight(light) {
|
|
2284
|
-
const sceneObject = this.GetSceneObject(light);
|
|
2285
|
-
if (!sceneObject) {
|
|
2286
|
-
console.warn(
|
|
2287
|
-
`DIVERoot.deleteLight: Light with id ${light.id} not found`
|
|
2288
|
-
);
|
|
2289
|
-
return;
|
|
2290
|
-
}
|
|
2291
|
-
this.detachTransformControls(sceneObject);
|
|
2292
|
-
sceneObject.parent.remove(sceneObject);
|
|
2293
|
-
}
|
|
2294
|
-
deleteModel(model) {
|
|
2295
|
-
const sceneObject = this.GetSceneObject(model);
|
|
2296
|
-
if (!sceneObject) {
|
|
2297
|
-
console.warn(
|
|
2298
|
-
`DIVERoot.deleteModel: Model with id ${model.id} not found`
|
|
2299
|
-
);
|
|
2300
|
-
return;
|
|
2301
|
-
}
|
|
2302
|
-
this.detachTransformControls(sceneObject);
|
|
2303
|
-
sceneObject.parent.remove(sceneObject);
|
|
2304
|
-
}
|
|
2305
|
-
deletePrimitive(primitive) {
|
|
2306
|
-
const sceneObject = this.GetSceneObject(primitive);
|
|
2307
|
-
if (!sceneObject) {
|
|
2308
|
-
console.warn(
|
|
2309
|
-
`DIVERoot.deletePrimitive: Primitive with id ${primitive.id} not found`
|
|
2310
|
-
);
|
|
2311
|
-
return;
|
|
2312
|
-
}
|
|
2313
|
-
this.detachTransformControls(sceneObject);
|
|
2314
|
-
sceneObject.parent.remove(sceneObject);
|
|
2315
|
-
}
|
|
2316
|
-
deleteGroup(group) {
|
|
2317
|
-
const sceneObject = this.GetSceneObject(group);
|
|
2318
|
-
if (!sceneObject) {
|
|
2319
|
-
console.warn(
|
|
2320
|
-
`DIVERoot.deleteGroup: Group with id ${group.id} not found`
|
|
2321
|
-
);
|
|
2322
|
-
return;
|
|
2323
|
-
}
|
|
2324
|
-
this.detachTransformControls(sceneObject);
|
|
2325
|
-
for (let i = sceneObject.members.length - 1; i >= 0; i--) {
|
|
2326
|
-
this.attach(sceneObject.members[i]);
|
|
2327
|
-
}
|
|
2328
|
-
sceneObject.parent.remove(sceneObject);
|
|
2329
|
-
}
|
|
2330
|
-
placeOnFloor(object) {
|
|
2331
|
-
const sceneObject = this.GetSceneObject(object);
|
|
2332
|
-
if (!sceneObject) return;
|
|
2333
|
-
sceneObject.PlaceOnFloor();
|
|
2334
|
-
}
|
|
2335
|
-
setParent(object) {
|
|
2336
|
-
const sceneObject = this.GetSceneObject(object);
|
|
2337
|
-
if (!sceneObject) return;
|
|
2338
|
-
if (object.parentId !== null) {
|
|
2339
|
-
const parent = this.GetSceneObject({
|
|
2340
|
-
id: object.parentId
|
|
2341
|
-
});
|
|
2342
|
-
if (!parent) return;
|
|
2343
|
-
parent.attach(sceneObject);
|
|
2344
|
-
} else {
|
|
2345
|
-
this.attach(sceneObject);
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
detachTransformControls(object) {
|
|
2349
|
-
this.findScene(object).children.find((object2) => {
|
|
2350
|
-
if ("isTransformControls" in object2) {
|
|
2351
|
-
object2.detach();
|
|
2352
|
-
}
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
2355
|
-
findScene(object) {
|
|
2356
|
-
if (object.parent !== null) {
|
|
2357
|
-
return this.findScene(object.parent);
|
|
2358
|
-
}
|
|
2359
|
-
return object;
|
|
2360
|
-
}
|
|
2361
|
-
};
|
|
2362
|
-
|
|
2363
|
-
// src/constant/GridColors.ts
|
|
2364
|
-
var GRID_CENTER_LINE_COLOR = "#888888";
|
|
2365
|
-
var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
2366
|
-
|
|
2367
|
-
// src/grid/Grid.ts
|
|
2368
|
-
init_VisibilityLayerMask();
|
|
2369
|
-
import { GridHelper, Object3D as Object3D7 } from "three";
|
|
2370
|
-
var DIVEGrid = class extends Object3D7 {
|
|
2371
|
-
constructor() {
|
|
2372
|
-
super();
|
|
2373
|
-
this.name = "Grid";
|
|
2374
|
-
const grid = new GridHelper(
|
|
2375
|
-
100,
|
|
2376
|
-
100,
|
|
2377
|
-
GRID_CENTER_LINE_COLOR,
|
|
2378
|
-
GRID_SIDE_LINE_COLOR
|
|
2379
|
-
);
|
|
2380
|
-
grid.material.depthTest = false;
|
|
2381
|
-
grid.layers.mask = HELPER_LAYER_MASK;
|
|
2382
|
-
this.add(grid);
|
|
2383
|
-
}
|
|
2384
|
-
SetVisibility(visible) {
|
|
2385
|
-
this.visible = visible;
|
|
2386
|
-
}
|
|
2387
|
-
};
|
|
2388
|
-
|
|
2389
|
-
// src/primitive/floor/Floor.ts
|
|
2390
|
-
init_VisibilityLayerMask();
|
|
2391
|
-
import {
|
|
2392
|
-
Color as Color6,
|
|
2393
|
-
Mesh as Mesh4,
|
|
2394
|
-
MeshStandardMaterial as MeshStandardMaterial3,
|
|
2395
|
-
PlaneGeometry
|
|
2396
|
-
} from "three";
|
|
2397
|
-
var DIVEFloor = class extends Mesh4 {
|
|
2398
|
-
constructor() {
|
|
2399
|
-
super(
|
|
2400
|
-
new PlaneGeometry(1e4, 1e4),
|
|
2401
|
-
new MeshStandardMaterial3({
|
|
2402
|
-
color: new Color6(150 / 255, 150 / 255, 150 / 255)
|
|
2403
|
-
})
|
|
2404
|
-
);
|
|
2405
|
-
this.isFloor = true;
|
|
2406
|
-
this.name = "Floor";
|
|
2407
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
2408
|
-
this.receiveShadow = true;
|
|
2409
|
-
this.rotateX(-Math.PI / 2);
|
|
2410
|
-
}
|
|
2411
|
-
SetVisibility(visible) {
|
|
2412
|
-
this.visible = visible;
|
|
2413
|
-
}
|
|
2414
|
-
SetColor(color) {
|
|
2415
|
-
this.material.color = new Color6(color);
|
|
2416
|
-
}
|
|
2417
|
-
};
|
|
2418
|
-
|
|
2419
|
-
// src/scene/Scene.ts
|
|
2420
|
-
var DIVEScene = class extends Scene2 {
|
|
2421
|
-
get Root() {
|
|
2422
|
-
return this.root;
|
|
2423
|
-
}
|
|
2424
|
-
get Floor() {
|
|
2425
|
-
return this.floor;
|
|
2426
|
-
}
|
|
2427
|
-
get Grid() {
|
|
2428
|
-
return this.grid;
|
|
2429
|
-
}
|
|
2430
|
-
constructor() {
|
|
2431
|
-
super();
|
|
2432
|
-
this.background = new Color7(16777215);
|
|
2433
|
-
this.root = new DIVERoot();
|
|
2434
|
-
this.add(this.root);
|
|
2435
|
-
this.floor = new DIVEFloor();
|
|
2436
|
-
this.add(this.floor);
|
|
2437
|
-
this.grid = new DIVEGrid();
|
|
2438
|
-
this.add(this.grid);
|
|
2439
|
-
}
|
|
2440
|
-
SetBackground(color) {
|
|
2441
|
-
this.background = new Color7(color);
|
|
2442
|
-
}
|
|
2443
|
-
ComputeSceneBB() {
|
|
2444
|
-
return this.Root.ComputeSceneBB();
|
|
2445
|
-
}
|
|
2446
|
-
GetSceneObject(object) {
|
|
2447
|
-
return this.Root.GetSceneObject(object);
|
|
2448
|
-
}
|
|
2449
|
-
AddSceneObject(object) {
|
|
2450
|
-
this.Root.AddSceneObject(object);
|
|
2451
|
-
}
|
|
2452
|
-
UpdateSceneObject(object) {
|
|
2453
|
-
this.Root.UpdateSceneObject(object);
|
|
2454
|
-
}
|
|
2455
|
-
DeleteSceneObject(object) {
|
|
2456
|
-
this.Root.DeleteSceneObject(object);
|
|
2457
|
-
}
|
|
2458
|
-
PlaceOnFloor(object) {
|
|
2459
|
-
this.Root.PlaceOnFloor(object);
|
|
2460
|
-
}
|
|
2461
|
-
};
|
|
2462
|
-
|
|
2463
|
-
// src/dive.ts
|
|
2464
|
-
init_PerspectiveCamera();
|
|
2465
|
-
|
|
2466
|
-
// src/controls/OrbitControls.ts
|
|
2467
|
-
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
|
|
2468
|
-
import { MathUtils as MathUtils2, Vector3 as Vector36 } from "three";
|
|
2469
|
-
import { Easing } from "@tweenjs/tween.js";
|
|
2470
|
-
var DIVEOrbitControlsDefaultSettings = {
|
|
2471
|
-
enableDamping: true,
|
|
2472
|
-
dampingFactor: 0.04
|
|
2473
|
-
};
|
|
2474
|
-
var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
2475
|
-
constructor(camera, renderer, animationSystem, settings = DIVEOrbitControlsDefaultSettings) {
|
|
2476
|
-
super(camera, renderer.domElement);
|
|
2477
|
-
this.last = null;
|
|
2478
|
-
this.animating = false;
|
|
2479
|
-
this.locked = false;
|
|
2480
|
-
this.stopMoveTo = () => {
|
|
2481
|
-
};
|
|
2482
|
-
this.stopRevertLast = () => {
|
|
2483
|
-
};
|
|
2484
|
-
this._removePreRenderCallback = () => {
|
|
2485
|
-
};
|
|
2486
|
-
this.preRenderCallback = () => {
|
|
2487
|
-
if (this.locked) return;
|
|
2488
|
-
this.update();
|
|
2489
|
-
};
|
|
2490
|
-
this._animationSystem = animationSystem;
|
|
2491
|
-
this.domElement = renderer.domElement;
|
|
2492
|
-
this.object = camera;
|
|
2493
|
-
const id = renderer.AddPreRenderCallback(() => {
|
|
2494
|
-
this.preRenderCallback();
|
|
2495
|
-
});
|
|
2496
|
-
this._removePreRenderCallback = () => {
|
|
2497
|
-
renderer.RemovePreRenderCallback(id);
|
|
2498
|
-
};
|
|
2499
|
-
this.enableDamping = settings.enableDamping || DIVEOrbitControlsDefaultSettings.enableDamping;
|
|
2500
|
-
this.dampingFactor = settings.dampingFactor || DIVEOrbitControlsDefaultSettings.dampingFactor;
|
|
2501
|
-
this.object.position.set(0, 2, 2);
|
|
2502
|
-
this.target.copy({ x: 0, y: 0.5, z: 0 });
|
|
2503
|
-
this.update();
|
|
2504
|
-
}
|
|
2505
|
-
Dispose() {
|
|
2506
|
-
this._removePreRenderCallback();
|
|
2507
|
-
this.dispose();
|
|
2508
|
-
}
|
|
2509
|
-
ComputeEncompassingView(bb) {
|
|
2510
|
-
const center = bb.getCenter(new Vector36());
|
|
2511
|
-
const size = bb.getSize(new Vector36());
|
|
2512
|
-
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
2513
|
-
const direction = this.object.position.clone().normalize();
|
|
2514
|
-
return {
|
|
2515
|
-
position: direction.multiplyScalar(distance),
|
|
2516
|
-
target: center
|
|
2517
|
-
};
|
|
2518
|
-
}
|
|
2519
|
-
ZoomIn(by) {
|
|
2520
|
-
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
2521
|
-
const { minDistance, maxDistance } = this;
|
|
2522
|
-
this.minDistance = this.maxDistance = MathUtils2.clamp(
|
|
2523
|
-
this.getDistance() - zoomBy,
|
|
2524
|
-
minDistance + zoomBy,
|
|
2525
|
-
maxDistance - zoomBy
|
|
2526
|
-
);
|
|
2527
|
-
this.update();
|
|
2528
|
-
this.minDistance = minDistance;
|
|
2529
|
-
this.maxDistance = maxDistance;
|
|
2530
|
-
}
|
|
2531
|
-
ZoomOut(by) {
|
|
2532
|
-
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
2533
|
-
const { minDistance, maxDistance } = this;
|
|
2534
|
-
this.minDistance = this.maxDistance = MathUtils2.clamp(
|
|
2535
|
-
this.getDistance() + zoomBy,
|
|
2536
|
-
minDistance + zoomBy,
|
|
2537
|
-
maxDistance - zoomBy
|
|
2538
|
-
);
|
|
2539
|
-
this.update();
|
|
2540
|
-
this.minDistance = minDistance;
|
|
2541
|
-
this.maxDistance = maxDistance;
|
|
2542
|
-
}
|
|
2543
|
-
MoveTo(pos, target, duration, lock) {
|
|
2544
|
-
if (this.animating) return;
|
|
2545
|
-
const toPosition = pos || this.object.position.clone();
|
|
2546
|
-
const toTarget = target || this.target.clone();
|
|
2547
|
-
this.stopRevertLast();
|
|
2548
|
-
if (!this.locked)
|
|
2549
|
-
this.last = {
|
|
2550
|
-
pos: this.object.position.clone(),
|
|
2551
|
-
target: this.target.clone()
|
|
2552
|
-
};
|
|
2553
|
-
this.animating = duration > 0;
|
|
2554
|
-
this.locked = lock;
|
|
2555
|
-
this.enabled = false;
|
|
2556
|
-
const tweenPos = this._animationSystem.Animate(this.object.position).to(toPosition, duration).easing(Easing.Quadratic.Out).start();
|
|
2557
|
-
const tweenQuat = this._animationSystem.Animate(this.target).to(toTarget, duration).easing(Easing.Quadratic.Out).onUpdate(() => {
|
|
2558
|
-
this.object.lookAt(this.target);
|
|
2559
|
-
}).onComplete(() => {
|
|
2560
|
-
this.animating = false;
|
|
2561
|
-
this.enabled = !lock;
|
|
2562
|
-
}).start();
|
|
2563
|
-
this.stopMoveTo = () => {
|
|
2564
|
-
tweenPos.stop();
|
|
2565
|
-
tweenQuat.stop();
|
|
2566
|
-
};
|
|
2567
|
-
}
|
|
2568
|
-
RevertLast(duration) {
|
|
2569
|
-
if (this.animating || !this.locked) return;
|
|
2570
|
-
this.stopMoveTo();
|
|
2571
|
-
this.animating = duration > 0;
|
|
2572
|
-
this.enabled = false;
|
|
2573
|
-
const { pos, target } = this.last;
|
|
2574
|
-
const tweenPos = this._animationSystem.Animate(this.object.position).to(pos, duration).easing(Easing.Quadratic.Out).start();
|
|
2575
|
-
const tweenQuat = this._animationSystem.Animate(this.target).to(target, duration).easing(Easing.Quadratic.Out).onUpdate(() => {
|
|
2576
|
-
this.object.lookAt(this.target);
|
|
2577
|
-
}).onComplete(() => {
|
|
2578
|
-
this.animating = false;
|
|
2579
|
-
this.locked = false;
|
|
2580
|
-
this.enabled = true;
|
|
2581
|
-
}).start();
|
|
2582
|
-
this.stopRevertLast = () => {
|
|
2583
|
-
tweenPos.stop();
|
|
2584
|
-
tweenQuat.stop();
|
|
2585
|
-
};
|
|
2586
|
-
}
|
|
2587
|
-
};
|
|
2588
|
-
_DIVEOrbitControls.DEFAULT_ZOOM_FACTOR = 1;
|
|
2589
|
-
var DIVEOrbitControls = _DIVEOrbitControls;
|
|
2590
|
-
|
|
2591
|
-
// src/toolbox/Toolbox.ts
|
|
2592
|
-
var DIVEToolbox = class {
|
|
2593
|
-
get selectTool() {
|
|
2594
|
-
if (!this._selectTool) {
|
|
2595
|
-
const DIVESelectTool2 = (init_SelectTool(), __toCommonJS(SelectTool_exports)).DIVESelectTool;
|
|
2596
|
-
this._selectTool = new DIVESelectTool2(
|
|
2597
|
-
this._scene,
|
|
2598
|
-
this._controller
|
|
2599
|
-
);
|
|
2600
|
-
}
|
|
2601
|
-
return this._selectTool;
|
|
2602
|
-
}
|
|
2603
|
-
constructor(scene, controller) {
|
|
2604
|
-
this._scene = scene;
|
|
2605
|
-
this._controller = controller;
|
|
2606
|
-
this._selectTool = null;
|
|
2607
|
-
this._activeTool = null;
|
|
2608
|
-
}
|
|
2609
|
-
Dispose() {
|
|
2610
|
-
this.removeEventListeners();
|
|
2611
|
-
}
|
|
2612
|
-
GetActiveTool() {
|
|
2613
|
-
return this._activeTool;
|
|
2614
|
-
}
|
|
2615
|
-
UseTool(tool) {
|
|
2616
|
-
var _a;
|
|
2617
|
-
(_a = this._activeTool) == null ? void 0 : _a.Deactivate();
|
|
2618
|
-
switch (tool) {
|
|
2619
|
-
case "select": {
|
|
2620
|
-
this.addEventListeners();
|
|
2621
|
-
this.selectTool.Activate();
|
|
2622
|
-
this._activeTool = this.selectTool;
|
|
2623
|
-
break;
|
|
2624
|
-
}
|
|
2625
|
-
case "none": {
|
|
2626
|
-
this.removeEventListeners();
|
|
2627
|
-
this._activeTool = null;
|
|
2628
|
-
break;
|
|
2629
|
-
}
|
|
2630
|
-
default: {
|
|
2631
|
-
console.warn(`DIVEToolBox.UseTool: Unknown tool: ${tool}`);
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
}
|
|
2635
|
-
SetGizmoMode(mode) {
|
|
2636
|
-
this.selectTool.SetGizmoMode(mode);
|
|
2637
|
-
}
|
|
2638
|
-
SetGizmoVisibility(active) {
|
|
2639
|
-
this.selectTool.SetGizmoVisibility(active);
|
|
2640
|
-
}
|
|
2641
|
-
onPointerMove(e) {
|
|
2642
|
-
var _a;
|
|
2643
|
-
(_a = this._activeTool) == null ? void 0 : _a.onPointerMove(e);
|
|
2644
|
-
}
|
|
2645
|
-
onPointerDown(e) {
|
|
2646
|
-
var _a;
|
|
2647
|
-
(_a = this._activeTool) == null ? void 0 : _a.onPointerDown(e);
|
|
2648
|
-
}
|
|
2649
|
-
onPointerUp(e) {
|
|
2650
|
-
var _a;
|
|
2651
|
-
(_a = this._activeTool) == null ? void 0 : _a.onPointerUp(e);
|
|
2652
|
-
}
|
|
2653
|
-
onWheel(e) {
|
|
2654
|
-
var _a;
|
|
2655
|
-
(_a = this._activeTool) == null ? void 0 : _a.onWheel(e);
|
|
2656
|
-
}
|
|
2657
|
-
addEventListeners() {
|
|
2658
|
-
this._controller.domElement.addEventListener(
|
|
2659
|
-
"pointermove",
|
|
2660
|
-
(e) => this.onPointerMove(e)
|
|
2661
|
-
);
|
|
2662
|
-
this._controller.domElement.addEventListener(
|
|
2663
|
-
"pointerdown",
|
|
2664
|
-
(e) => this.onPointerDown(e)
|
|
2665
|
-
);
|
|
2666
|
-
this._controller.domElement.addEventListener(
|
|
2667
|
-
"pointerup",
|
|
2668
|
-
(e) => this.onPointerUp(e)
|
|
2669
|
-
);
|
|
2670
|
-
this._controller.domElement.addEventListener(
|
|
2671
|
-
"wheel",
|
|
2672
|
-
(e) => this.onWheel(e)
|
|
2673
|
-
);
|
|
2674
|
-
}
|
|
2675
|
-
removeEventListeners() {
|
|
2676
|
-
this._controller.domElement.removeEventListener(
|
|
2677
|
-
"pointermove",
|
|
2678
|
-
(e) => this.onPointerMove(e)
|
|
2679
|
-
);
|
|
2680
|
-
this._controller.domElement.removeEventListener(
|
|
2681
|
-
"pointerdown",
|
|
2682
|
-
(e) => this.onPointerDown(e)
|
|
2683
|
-
);
|
|
2684
|
-
this._controller.domElement.removeEventListener(
|
|
2685
|
-
"pointerup",
|
|
2686
|
-
(e) => this.onPointerUp(e)
|
|
2687
|
-
);
|
|
2688
|
-
this._controller.domElement.removeEventListener(
|
|
2689
|
-
"wheel",
|
|
2690
|
-
(e) => this.onWheel(e)
|
|
2691
|
-
);
|
|
2692
|
-
}
|
|
2693
|
-
};
|
|
2694
|
-
DIVEToolbox.DefaultTool = "select";
|
|
2695
|
-
|
|
2696
|
-
// src/animation/AnimationSystem.ts
|
|
2697
|
-
import { Tween, update as updateTween } from "@tweenjs/tween.js";
|
|
2698
|
-
var DIVEAnimationSystem = class {
|
|
2699
|
-
constructor(renderer) {
|
|
2700
|
-
this._renderer = renderer;
|
|
2701
|
-
this._rendererCallbackId = this._renderer.AddPreRenderCallback(() => {
|
|
2702
|
-
this.Update();
|
|
2703
|
-
});
|
|
2704
|
-
}
|
|
2705
|
-
Dispose() {
|
|
2706
|
-
this._renderer.RemovePreRenderCallback(this._rendererCallbackId);
|
|
2707
|
-
}
|
|
2708
|
-
Update() {
|
|
2709
|
-
updateTween();
|
|
2710
|
-
}
|
|
2711
|
-
Animate(object) {
|
|
2712
|
-
return new Tween(object);
|
|
2713
|
-
}
|
|
2714
|
-
};
|
|
2715
|
-
|
|
2716
|
-
// src/axiscamera/AxisCamera.ts
|
|
2717
|
-
init_VisibilityLayerMask();
|
|
2718
|
-
import {
|
|
2719
|
-
AxesHelper,
|
|
2720
|
-
Color as Color8,
|
|
2721
|
-
Matrix4,
|
|
2722
|
-
OrthographicCamera,
|
|
2723
|
-
Vector4
|
|
2724
|
-
} from "three";
|
|
2725
|
-
import SpriteText from "three-spritetext";
|
|
2726
|
-
|
|
2727
|
-
// src/constant/AxisHelperColors.ts
|
|
2728
|
-
var AxesColorRedLetter = "#c20017";
|
|
2729
|
-
var AxesColorGreenLetter = "#00ab26";
|
|
2730
|
-
var AxesColorBlueLetter = "#0081d4";
|
|
2731
|
-
var AxesColorRed = AxesColorRedLetter;
|
|
2732
|
-
var AxesColorGreen = AxesColorGreenLetter;
|
|
2733
|
-
var AxesColorBlue = AxesColorBlueLetter;
|
|
2734
|
-
|
|
2735
|
-
// src/axiscamera/AxisCamera.ts
|
|
2736
|
-
var DIVEAxisCamera = class extends OrthographicCamera {
|
|
2737
|
-
constructor(renderer, scene, controls) {
|
|
2738
|
-
super(-1, 1, 1, -1, 0.1, 100);
|
|
2739
|
-
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
2740
|
-
this.axesHelper = new AxesHelper(0.5);
|
|
2741
|
-
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
2742
|
-
this.axesHelper.material.depthTest = false;
|
|
2743
|
-
this.axesHelper.position.set(0, 0, -1);
|
|
2744
|
-
this.axesHelper.setColors(
|
|
2745
|
-
new Color8(AxesColorRed),
|
|
2746
|
-
new Color8(AxesColorGreen),
|
|
2747
|
-
new Color8(AxesColorBlue)
|
|
2748
|
-
);
|
|
2749
|
-
const x = new SpriteText("X", 0.2, AxesColorRedLetter);
|
|
2750
|
-
const y = new SpriteText("Y", 0.2, AxesColorGreenLetter);
|
|
2751
|
-
const z = new SpriteText("Z", 0.2, AxesColorBlueLetter);
|
|
2752
|
-
x.layers.mask = COORDINATE_LAYER_MASK;
|
|
2753
|
-
y.layers.mask = COORDINATE_LAYER_MASK;
|
|
2754
|
-
z.layers.mask = COORDINATE_LAYER_MASK;
|
|
2755
|
-
x.position.set(0.7, 0, 0);
|
|
2756
|
-
y.position.set(0, 0.7, 0);
|
|
2757
|
-
z.position.set(0, 0, 0.7);
|
|
2758
|
-
this.axesHelper.add(x);
|
|
2759
|
-
this.axesHelper.add(y);
|
|
2760
|
-
this.axesHelper.add(z);
|
|
2761
|
-
this.add(this.axesHelper);
|
|
2762
|
-
this._renderer = renderer;
|
|
2763
|
-
this._scene = scene;
|
|
2764
|
-
this._scene.add(this);
|
|
2765
|
-
const restoreViewport = new Vector4();
|
|
2766
|
-
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
2767
|
-
const restoreBackground = scene.background;
|
|
2768
|
-
scene.background = null;
|
|
2769
|
-
renderer.getViewport(restoreViewport);
|
|
2770
|
-
renderer.setViewport(0, 0, 150, 150);
|
|
2771
|
-
renderer.autoClear = false;
|
|
2772
|
-
this.SetFromCameraMatrix(controls.object.matrix);
|
|
2773
|
-
renderer.render(scene, this);
|
|
2774
|
-
renderer.setViewport(restoreViewport);
|
|
2775
|
-
renderer.autoClear = true;
|
|
2776
|
-
scene.background = restoreBackground;
|
|
2777
|
-
});
|
|
2778
|
-
}
|
|
2779
|
-
Dispose() {
|
|
2780
|
-
this._renderer.RemovePostRenderCallback(this._renderCallbackId);
|
|
2781
|
-
this._scene.remove(this);
|
|
2782
|
-
}
|
|
2783
|
-
SetFromCameraMatrix(matrix) {
|
|
2784
|
-
this.axesHelper.rotation.setFromRotationMatrix(
|
|
2785
|
-
new Matrix4().extractRotation(matrix).invert()
|
|
2786
|
-
);
|
|
2787
|
-
}
|
|
2788
|
-
};
|
|
2789
|
-
|
|
2790
|
-
// src/helper/getObjectDelta/getObjectDelta.ts
|
|
2791
|
-
var getObjectDelta = (a, b) => {
|
|
2792
|
-
if (Object.keys(a).length === 0 && Object.keys(b).length === 0) {
|
|
2793
|
-
return {};
|
|
2794
|
-
}
|
|
2795
|
-
if (typeof a !== "object" || typeof b !== "object") {
|
|
2796
|
-
return b;
|
|
2797
|
-
}
|
|
2798
|
-
let delta = {};
|
|
2799
|
-
Object.keys(b).forEach((key) => {
|
|
2800
|
-
if (!Object.keys(a).includes(key)) {
|
|
2801
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
2802
|
-
return;
|
|
2803
|
-
}
|
|
2804
|
-
if (Array.isArray(b[key])) {
|
|
2805
|
-
if (!Array.isArray(a[key])) {
|
|
2806
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
2807
|
-
return;
|
|
2808
|
-
}
|
|
2809
|
-
const aArray = a[key];
|
|
2810
|
-
const bArray = b[key];
|
|
2811
|
-
if (aArray.length === 0 && bArray.length === 0) {
|
|
2812
|
-
delta = __spreadValues({}, delta);
|
|
2813
|
-
return;
|
|
2814
|
-
}
|
|
2815
|
-
if (aArray.length !== bArray.length) {
|
|
2816
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
2817
|
-
return;
|
|
2818
|
-
}
|
|
2819
|
-
const arrayDeltas = [];
|
|
2820
|
-
bArray.forEach((entry, index) => {
|
|
2821
|
-
const inArrayDelta = getObjectDelta(
|
|
2822
|
-
aArray[index],
|
|
2823
|
-
bArray[index]
|
|
2824
|
-
);
|
|
2825
|
-
if (Object.keys(inArrayDelta).length) {
|
|
2826
|
-
arrayDeltas.push(bArray[index]);
|
|
2827
|
-
}
|
|
2828
|
-
});
|
|
2829
|
-
if (Object.keys(arrayDeltas).length) {
|
|
2830
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: arrayDeltas });
|
|
2831
|
-
return;
|
|
2832
|
-
}
|
|
2833
|
-
return;
|
|
2834
|
-
}
|
|
2835
|
-
if (typeof b[key] === "object") {
|
|
2836
|
-
if (typeof a[key] !== "object") {
|
|
2837
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
2838
|
-
return;
|
|
2839
|
-
}
|
|
2840
|
-
const objectDelta = getObjectDelta(
|
|
2841
|
-
a[key],
|
|
2842
|
-
b[key]
|
|
2843
|
-
);
|
|
2844
|
-
if (Object.keys(objectDelta).length) {
|
|
2845
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: objectDelta });
|
|
2846
|
-
return;
|
|
2847
|
-
}
|
|
2848
|
-
}
|
|
2849
|
-
if (a[key] !== b[key]) {
|
|
2850
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
2851
|
-
}
|
|
2852
|
-
});
|
|
2853
|
-
return delta;
|
|
2854
|
-
};
|
|
2855
|
-
|
|
2856
|
-
// src/dive.ts
|
|
2857
|
-
import { generateUUID as generateUUID2 } from "three/src/math/MathUtils";
|
|
2858
|
-
|
|
2859
|
-
// src/info/Info.ts
|
|
2860
|
-
var DIVEInfo = class {
|
|
2861
|
-
/**
|
|
2862
|
-
*
|
|
2863
|
-
* @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
|
|
2864
|
-
*/
|
|
2865
|
-
static GetSystem() {
|
|
2866
|
-
const platform = navigator.platform;
|
|
2867
|
-
if (/Android/.test(navigator.userAgent)) {
|
|
2868
|
-
return "Android";
|
|
2869
|
-
} else if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
|
|
2870
|
-
return "iOS";
|
|
2871
|
-
} else if (platform.startsWith("Win")) {
|
|
2872
|
-
return "Windows";
|
|
2873
|
-
} else if (platform.startsWith("Mac")) {
|
|
2874
|
-
return "MacOS";
|
|
2875
|
-
} else if (platform.startsWith("Linux")) {
|
|
2876
|
-
return "Linux";
|
|
2877
|
-
} else {
|
|
2878
|
-
return "Unknown";
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2881
|
-
/**
|
|
2882
|
-
* @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
|
|
2883
|
-
*/
|
|
2884
|
-
static GetSupportsWebXR() {
|
|
2885
|
-
return __async(this, null, function* () {
|
|
2886
|
-
if (this._supportsWebXR !== null) {
|
|
2887
|
-
return this._supportsWebXR;
|
|
2888
|
-
}
|
|
2889
|
-
if (!navigator.xr) {
|
|
2890
|
-
this._supportsWebXR = false;
|
|
2891
|
-
return this._supportsWebXR;
|
|
2892
|
-
}
|
|
2893
|
-
try {
|
|
2894
|
-
const supported = yield navigator.xr.isSessionSupported("immersive-ar");
|
|
2895
|
-
this._supportsWebXR = supported;
|
|
2896
|
-
} catch (error) {
|
|
2897
|
-
this._supportsWebXR = false;
|
|
2898
|
-
}
|
|
2899
|
-
return this._supportsWebXR;
|
|
2900
|
-
});
|
|
2901
|
-
}
|
|
2902
|
-
/**
|
|
2903
|
-
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
2904
|
-
*/
|
|
2905
|
-
static GetSupportsARQuickLook() {
|
|
2906
|
-
const a = document.createElement("a");
|
|
2907
|
-
if (a.relList.supports("ar")) {
|
|
2908
|
-
return true;
|
|
2909
|
-
}
|
|
2910
|
-
const userAgent = navigator.userAgent;
|
|
2911
|
-
const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream;
|
|
2912
|
-
if (!isIOS) {
|
|
2913
|
-
return false;
|
|
2914
|
-
}
|
|
2915
|
-
const match = userAgent.match(/OS (\d+)_/);
|
|
2916
|
-
if (!match || match.length < 2) {
|
|
2917
|
-
return false;
|
|
2918
|
-
}
|
|
2919
|
-
const iOSVersion = parseInt(match[1], 10);
|
|
2920
|
-
const minQuickLookVersion = 12;
|
|
2921
|
-
if (iOSVersion < minQuickLookVersion) {
|
|
2922
|
-
return false;
|
|
2923
|
-
}
|
|
2924
|
-
const isSupportedBrowser = /^((?!chrome|android).)*safari|CriOS|FxiOS/i.test(userAgent);
|
|
2925
|
-
if (isSupportedBrowser) {
|
|
2926
|
-
return true;
|
|
2927
|
-
}
|
|
2928
|
-
return false;
|
|
2929
|
-
}
|
|
2930
|
-
/**
|
|
2931
|
-
* @returns A boolean indicating whether the user's device is a mobile device.
|
|
2932
|
-
*/
|
|
2933
|
-
static get isMobile() {
|
|
2934
|
-
return this.GetSystem() === "Android" || this.GetSystem() === "iOS";
|
|
2935
|
-
}
|
|
2936
|
-
/**
|
|
2937
|
-
* @returns A boolean indicating whether the user's device is a desktop device.
|
|
2938
|
-
*/
|
|
2939
|
-
static get isDesktop() {
|
|
2940
|
-
return !this.isMobile;
|
|
2941
|
-
}
|
|
2942
|
-
/**
|
|
2943
|
-
* @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
|
|
2944
|
-
*/
|
|
2945
|
-
static GetIsARCapable() {
|
|
2946
|
-
return __async(this, null, function* () {
|
|
2947
|
-
if (this.GetSupportsARQuickLook()) {
|
|
2948
|
-
return true;
|
|
2949
|
-
}
|
|
2950
|
-
return yield this.GetSupportsWebXR();
|
|
2951
|
-
});
|
|
2952
|
-
}
|
|
2953
|
-
};
|
|
2954
|
-
DIVEInfo._supportsWebXR = null;
|
|
2955
|
-
|
|
2956
|
-
// package.json
|
|
2957
|
-
var package_default = {
|
|
2958
|
-
name: "@shopware-ag/dive",
|
|
2959
|
-
version: "1.16.13",
|
|
2960
|
-
description: "Shopware Spatial Framework",
|
|
2961
|
-
type: "module",
|
|
2962
|
-
main: "./build/dive.cjs",
|
|
2963
|
-
module: "./build/dive.js",
|
|
2964
|
-
types: "./build/dive.d.ts",
|
|
2965
|
-
files: [
|
|
2966
|
-
"build",
|
|
2967
|
-
"LICENSE",
|
|
2968
|
-
"package.json",
|
|
2969
|
-
"README.md",
|
|
2970
|
-
"src"
|
|
2971
|
-
],
|
|
2972
|
-
keywords: [
|
|
2973
|
-
"dive",
|
|
2974
|
-
"shopware",
|
|
2975
|
-
"sw6",
|
|
2976
|
-
"three",
|
|
2977
|
-
"three.js",
|
|
2978
|
-
"3d",
|
|
2979
|
-
"typescript"
|
|
2980
|
-
],
|
|
2981
|
-
repository: "git@github.com:shopware/dive.git",
|
|
2982
|
-
author: "ffrank <f.frank@shopware.com>",
|
|
2983
|
-
license: "MIT",
|
|
2984
|
-
browserslist: [
|
|
2985
|
-
"> 1%, not dead, not ie 11, not op_mini all"
|
|
2986
|
-
],
|
|
2987
|
-
dependencies: {
|
|
2988
|
-
"@tweenjs/tween.js": "^23.1.1",
|
|
2989
|
-
lodash: "^4.17.21",
|
|
2990
|
-
three: "^0.163.0",
|
|
2991
|
-
"three-spritetext": "^1.8.2"
|
|
2992
|
-
},
|
|
2993
|
-
devDependencies: {
|
|
2994
|
-
"@eslint/js": "^9.1.1",
|
|
2995
|
-
"@types/jest": "^29.5.12",
|
|
2996
|
-
"@types/lodash": "^4.17.12",
|
|
2997
|
-
"@types/node": "^20.12.7",
|
|
2998
|
-
"@types/three": "^0.163.0",
|
|
2999
|
-
eslint: "^9.1.1",
|
|
3000
|
-
globals: "^15.0.0",
|
|
3001
|
-
jest: "^29.7.0",
|
|
3002
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
3003
|
-
jsdom: "^24.0.0",
|
|
3004
|
-
prettier: "^3.3.3",
|
|
3005
|
-
"prettier-plugin-multiline-arrays": "^3.0.6",
|
|
3006
|
-
"ts-jest": "^29.1.2",
|
|
3007
|
-
"ts-node": "^10.9.2",
|
|
3008
|
-
tsc: "^2.0.4",
|
|
3009
|
-
tsup: "^8.0.2",
|
|
3010
|
-
typescript: "^5.4.5",
|
|
3011
|
-
"typescript-eslint": "^7.7.1"
|
|
3012
|
-
},
|
|
3013
|
-
scripts: {
|
|
3014
|
-
build: "tsup --env.DIVE_NODE_ENV production",
|
|
3015
|
-
dev: "tsup --watch --env.DIVE_NODE_ENV development",
|
|
3016
|
-
lint: "eslint",
|
|
3017
|
-
"lint:actions": "yarn lint:actions:transpile && yarn lint:actions:check && yarn lint:actions:cleanup",
|
|
3018
|
-
"lint:actions:transpile": "yarn tsc --resolveJsonModule --esModuleInterop ci/lint/lint-actions.ts && mv ci/lint/lint-actions.js ci/lint/lint-actions.cjs",
|
|
3019
|
-
"lint:actions:check": "yarn node ci/lint/lint-actions.cjs",
|
|
3020
|
-
"lint:actions:cleanup": `node -e "require('fs').unlinkSync('ci/lint/lint-actions.cjs')"`,
|
|
3021
|
-
"prettier:check": "prettier --check .",
|
|
3022
|
-
"prettier:fix": "prettier --write .",
|
|
3023
|
-
unit: "jest",
|
|
3024
|
-
coverage: "jest --coverage",
|
|
3025
|
-
"generate-readme": "yarn generate-readme:transpile && yarn generate-readme:write && yarn generate-readme:cleanup",
|
|
3026
|
-
"generate-readme:transpile": "yarn tsc --resolveJsonModule --esModuleInterop ci/readme/generate-readme.ts && mv ci/readme/generate-readme.js ci/readme/generate-readme.cjs",
|
|
3027
|
-
"generate-readme:write": "node ci/readme/generate-readme.cjs",
|
|
3028
|
-
"generate-readme:cleanup": `node -e "require('fs').unlinkSync('ci/readme/generate-readme.cjs')"`
|
|
3029
|
-
}
|
|
3030
|
-
};
|
|
3031
|
-
|
|
3032
|
-
// src/math/helper/shift.ts
|
|
3033
|
-
function shift(value, exponent) {
|
|
3034
|
-
const subvalues = (value + "e").split("e");
|
|
3035
|
-
return +(subvalues[0] + "e" + (+subvalues[1] + (exponent || 0)));
|
|
3036
|
-
}
|
|
3037
|
-
|
|
3038
|
-
// src/math/ceil/ceilExp.ts
|
|
3039
|
-
function ceilExp(number, decimals = 0) {
|
|
3040
|
-
const n = shift(number, +decimals);
|
|
3041
|
-
return shift(Math.ceil(n), -decimals);
|
|
3042
|
-
}
|
|
3043
|
-
|
|
3044
|
-
// src/math/floor/floorExp.ts
|
|
3045
|
-
function floorExp(number, decimals = 0) {
|
|
3046
|
-
const n = shift(number, +decimals);
|
|
3047
|
-
return shift(Math.floor(n), -decimals);
|
|
3048
|
-
}
|
|
3049
|
-
|
|
3050
|
-
// src/math/round/roundExp.ts
|
|
3051
|
-
function roundExponential(number, decimals = 0) {
|
|
3052
|
-
if (number < 0) return -roundExponential(-number, decimals);
|
|
3053
|
-
const n = shift(number, +decimals);
|
|
3054
|
-
return shift(Math.round(n), -decimals);
|
|
3055
|
-
}
|
|
3056
|
-
|
|
3057
|
-
// src/math/signedAngleTo/signedAngleTo.ts
|
|
3058
|
-
function signedAngleTo(vecA, vecB, planeNormal) {
|
|
3059
|
-
return Math.atan2(
|
|
3060
|
-
vecA.clone().cross(vecB).dot(planeNormal),
|
|
3061
|
-
vecB.clone().dot(vecA)
|
|
3062
|
-
);
|
|
3063
|
-
}
|
|
3064
|
-
|
|
3065
|
-
// src/math/toFixed/toFixedExp.ts
|
|
3066
|
-
function toFixedExp(number, decimals = 0) {
|
|
3067
|
-
const n = shift(number, +decimals);
|
|
3068
|
-
return shift(Math.round(n), -decimals).toFixed(decimals);
|
|
3069
|
-
}
|
|
3070
|
-
|
|
3071
|
-
// src/math/truncate/truncateExp.ts
|
|
3072
|
-
function truncateExp(number, decimals = 0) {
|
|
3073
|
-
const n = shift(number, +decimals);
|
|
3074
|
-
return shift(Math.trunc(n), -decimals);
|
|
3075
|
-
}
|
|
3076
|
-
|
|
3077
|
-
// src/math/radToDeg/radToDeg.ts
|
|
3078
|
-
import { MathUtils as MathUtils3 } from "three";
|
|
3079
|
-
function radToDeg(radians) {
|
|
3080
|
-
return (MathUtils3.radToDeg(radians) + 360) % 360;
|
|
3081
|
-
}
|
|
3082
|
-
|
|
3083
|
-
// src/math/degToRad/degToRad.ts
|
|
3084
|
-
import { MathUtils as MathUtils4 } from "three";
|
|
3085
|
-
function degToRad(degrees) {
|
|
3086
|
-
return MathUtils4.degToRad(degrees);
|
|
3087
|
-
}
|
|
3088
|
-
|
|
3089
|
-
// src/math/index.ts
|
|
3090
|
-
var DIVEMath = {
|
|
3091
|
-
ceilExp,
|
|
3092
|
-
floorExp,
|
|
3093
|
-
roundExp: roundExponential,
|
|
3094
|
-
toFixedExp,
|
|
3095
|
-
truncateExp,
|
|
3096
|
-
signedAngleTo,
|
|
3097
|
-
radToDeg,
|
|
3098
|
-
degToRad
|
|
3099
|
-
};
|
|
3100
|
-
|
|
3101
|
-
// src/dive.ts
|
|
3102
|
-
var DIVEDefaultSettings = {
|
|
3103
|
-
autoResize: true,
|
|
3104
|
-
displayAxes: false,
|
|
3105
|
-
renderer: DIVERendererDefaultSettings,
|
|
3106
|
-
perspectiveCamera: DIVEPerspectiveCameraDefaultSettings,
|
|
3107
|
-
orbitControls: DIVEOrbitControlsDefaultSettings
|
|
3108
|
-
};
|
|
3109
|
-
var DIVE = class _DIVE {
|
|
3110
|
-
// static members
|
|
3111
|
-
static QuickView(uri) {
|
|
3112
|
-
const dive = new _DIVE();
|
|
3113
|
-
dive.Communication.PerformAction("SET_CAMERA_TRANSFORM", {
|
|
3114
|
-
position: { x: 0, y: 2, z: 2 },
|
|
3115
|
-
target: { x: 0, y: 0.5, z: 0 }
|
|
3116
|
-
});
|
|
3117
|
-
const lightid = generateUUID2();
|
|
3118
|
-
dive.Communication.PerformAction("ADD_OBJECT", {
|
|
3119
|
-
entityType: "light",
|
|
3120
|
-
type: "scene",
|
|
3121
|
-
name: "light",
|
|
3122
|
-
id: lightid,
|
|
3123
|
-
enabled: true,
|
|
3124
|
-
visible: true,
|
|
3125
|
-
intensity: 1,
|
|
3126
|
-
color: 16777215
|
|
3127
|
-
});
|
|
3128
|
-
const modelid = generateUUID2();
|
|
3129
|
-
dive.Communication.Subscribe("MODEL_LOADED", (data) => {
|
|
3130
|
-
if (data.id !== modelid) return;
|
|
3131
|
-
dive.Communication.PerformAction("PLACE_ON_FLOOR", {
|
|
3132
|
-
id: modelid
|
|
3133
|
-
});
|
|
3134
|
-
const transform = dive.Communication.PerformAction(
|
|
3135
|
-
"COMPUTE_ENCOMPASSING_VIEW",
|
|
3136
|
-
{}
|
|
3137
|
-
);
|
|
3138
|
-
dive.Communication.PerformAction("SET_CAMERA_TRANSFORM", {
|
|
3139
|
-
position: transform.position,
|
|
3140
|
-
target: transform.target
|
|
3141
|
-
});
|
|
3142
|
-
});
|
|
3143
|
-
dive.Communication.PerformAction("ADD_OBJECT", {
|
|
3144
|
-
entityType: "model",
|
|
3145
|
-
name: "object",
|
|
3146
|
-
id: modelid,
|
|
3147
|
-
position: { x: 0, y: 0, z: 0 },
|
|
3148
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
3149
|
-
scale: { x: 1, y: 1, z: 1 },
|
|
3150
|
-
uri,
|
|
3151
|
-
visible: true,
|
|
3152
|
-
loaded: false
|
|
3153
|
-
});
|
|
3154
|
-
dive.Communication.PerformAction("UPDATE_SCENE", {
|
|
3155
|
-
backgroundColor: 16777215,
|
|
3156
|
-
gridEnabled: false,
|
|
3157
|
-
floorColor: 16777215
|
|
3158
|
-
});
|
|
3159
|
-
return dive;
|
|
3160
|
-
}
|
|
3161
|
-
// getters
|
|
3162
|
-
get Communication() {
|
|
3163
|
-
return this.communication;
|
|
3164
|
-
}
|
|
3165
|
-
get Canvas() {
|
|
3166
|
-
return this.renderer.domElement;
|
|
3167
|
-
}
|
|
3168
|
-
get Info() {
|
|
3169
|
-
return DIVEInfo;
|
|
3170
|
-
}
|
|
3171
|
-
// setters
|
|
3172
|
-
set Settings(settings) {
|
|
3173
|
-
var _a;
|
|
3174
|
-
const settingsDelta = getObjectDelta(this._settings, settings);
|
|
3175
|
-
if (settingsDelta.renderer)
|
|
3176
|
-
this.renderer = new DIVERenderer(this._settings.renderer);
|
|
3177
|
-
if (settingsDelta.perspectiveCamera) {
|
|
3178
|
-
if (settingsDelta.perspectiveCamera.fov !== void 0)
|
|
3179
|
-
this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov;
|
|
3180
|
-
if (settingsDelta.perspectiveCamera.near !== void 0)
|
|
3181
|
-
this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near;
|
|
3182
|
-
if (settingsDelta.perspectiveCamera.far !== void 0)
|
|
3183
|
-
this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far;
|
|
3184
|
-
this.perspectiveCamera.OnResize(
|
|
3185
|
-
this.renderer.domElement.width,
|
|
3186
|
-
this.renderer.domElement.height
|
|
3187
|
-
);
|
|
3188
|
-
}
|
|
3189
|
-
if (settingsDelta.orbitControls) {
|
|
3190
|
-
if (settingsDelta.orbitControls.enableDamping !== void 0)
|
|
3191
|
-
this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping;
|
|
3192
|
-
if (settingsDelta.orbitControls.dampingFactor !== void 0)
|
|
3193
|
-
this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor;
|
|
3194
|
-
}
|
|
3195
|
-
if (settingsDelta.autoResize !== this._settings.autoResize) {
|
|
3196
|
-
if (settingsDelta.autoResize) {
|
|
3197
|
-
this.addResizeObserver();
|
|
3198
|
-
} else {
|
|
3199
|
-
this.removeResizeObserver();
|
|
3200
|
-
}
|
|
3201
|
-
}
|
|
3202
|
-
if (settingsDelta.displayAxes) {
|
|
3203
|
-
this.axisCamera = new DIVEAxisCamera(
|
|
3204
|
-
this.renderer,
|
|
3205
|
-
this.scene,
|
|
3206
|
-
this.orbitControls
|
|
3207
|
-
);
|
|
3208
|
-
} else {
|
|
3209
|
-
(_a = this.axisCamera) == null ? void 0 : _a.Dispose();
|
|
3210
|
-
this.axisCamera = null;
|
|
3211
|
-
}
|
|
3212
|
-
Object.assign(this._settings, settings);
|
|
3213
|
-
}
|
|
3214
|
-
constructor(settings) {
|
|
3215
|
-
this._settings = __spreadValues(__spreadValues({}, DIVEDefaultSettings), settings !== void 0 ? settings : {});
|
|
3216
|
-
this._resizeObserverId = "";
|
|
3217
|
-
this._width = 0;
|
|
3218
|
-
this._height = 0;
|
|
3219
|
-
this.renderer = new DIVERenderer(this._settings.renderer);
|
|
3220
|
-
this.scene = new DIVEScene();
|
|
3221
|
-
this.perspectiveCamera = new DIVEPerspectiveCamera(
|
|
3222
|
-
this._settings.perspectiveCamera
|
|
3223
|
-
);
|
|
3224
|
-
this.animationSystem = new DIVEAnimationSystem(this.renderer);
|
|
3225
|
-
this.orbitControls = new DIVEOrbitControls(
|
|
3226
|
-
this.perspectiveCamera,
|
|
3227
|
-
this.renderer,
|
|
3228
|
-
this.animationSystem,
|
|
3229
|
-
this._settings.orbitControls
|
|
3230
|
-
);
|
|
3231
|
-
this.toolbox = new DIVEToolbox(this.scene, this.orbitControls);
|
|
3232
|
-
this.communication = new DIVECommunication(
|
|
3233
|
-
this.renderer,
|
|
3234
|
-
this.scene,
|
|
3235
|
-
this.orbitControls,
|
|
3236
|
-
this.toolbox
|
|
3237
|
-
);
|
|
3238
|
-
if (this._settings.displayAxes) {
|
|
3239
|
-
this.axisCamera = new DIVEAxisCamera(
|
|
3240
|
-
this.renderer,
|
|
3241
|
-
this.scene,
|
|
3242
|
-
this.orbitControls
|
|
3243
|
-
);
|
|
3244
|
-
} else {
|
|
3245
|
-
this.axisCamera = null;
|
|
3246
|
-
}
|
|
3247
|
-
if (this._settings.autoResize) {
|
|
3248
|
-
this.addResizeObserver();
|
|
3249
|
-
}
|
|
3250
|
-
this.renderer.StartRenderer(this.scene, this.perspectiveCamera);
|
|
3251
|
-
window.DIVE = {
|
|
3252
|
-
PrintScene: () => {
|
|
3253
|
-
console.log(this.scene);
|
|
3254
|
-
}
|
|
3255
|
-
};
|
|
3256
|
-
console.log(
|
|
3257
|
-
`DIVE ${package_default.version} initialized ${false ? "in development mode" : ""}`
|
|
3258
|
-
);
|
|
3259
|
-
}
|
|
3260
|
-
Dispose() {
|
|
3261
|
-
var _a;
|
|
3262
|
-
this.removeResizeObserver();
|
|
3263
|
-
this.renderer.Dispose();
|
|
3264
|
-
this.orbitControls.Dispose();
|
|
3265
|
-
(_a = this.axisCamera) == null ? void 0 : _a.Dispose();
|
|
3266
|
-
this.animationSystem.Dispose();
|
|
3267
|
-
this.toolbox.Dispose();
|
|
3268
|
-
this.communication.DestroyInstance();
|
|
3269
|
-
}
|
|
3270
|
-
// methods
|
|
3271
|
-
OnResize(width, height) {
|
|
3272
|
-
this.renderer.OnResize(width, height);
|
|
3273
|
-
this.perspectiveCamera.OnResize(width, height);
|
|
3274
|
-
}
|
|
3275
|
-
addResizeObserver() {
|
|
3276
|
-
this._resizeObserverId = this.renderer.AddPreRenderCallback(() => {
|
|
3277
|
-
const canvasWrapper = this.renderer.domElement.parentElement;
|
|
3278
|
-
if (!canvasWrapper) return;
|
|
3279
|
-
const { clientWidth, clientHeight } = canvasWrapper;
|
|
3280
|
-
if (clientWidth === this._width && clientHeight === this._height)
|
|
3281
|
-
return;
|
|
3282
|
-
this.OnResize(clientWidth, clientHeight);
|
|
3283
|
-
this._width = clientWidth;
|
|
3284
|
-
this._height = clientHeight;
|
|
3285
|
-
});
|
|
3286
|
-
}
|
|
3287
|
-
removeResizeObserver() {
|
|
3288
|
-
this.renderer.RemovePreRenderCallback(this._resizeObserverId);
|
|
3289
|
-
}
|
|
3290
|
-
};
|
|
3291
|
-
export {
|
|
3292
|
-
DIVE,
|
|
3293
|
-
DIVECommunication,
|
|
3294
|
-
DIVEDefaultSettings,
|
|
3295
|
-
DIVEMath,
|
|
3296
|
-
DIVE as default
|
|
3297
|
-
};
|
|
3298
|
-
//# sourceMappingURL=dive.js.map
|