@shopware-ag/dive 1.18.4 → 1.18.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/AR-B6LRgTEL.js +1482 -0
- package/build/AR-B6LRgTEL.js.map +1 -0
- package/build/AR-YJZL1lm5.cjs +170 -0
- package/build/AR-YJZL1lm5.cjs.map +1 -0
- package/build/dive-BmDCwQRo.js +24811 -0
- package/build/dive-BmDCwQRo.js.map +1 -0
- package/build/dive-C-5_QywE.cjs +3857 -0
- package/build/dive-C-5_QywE.cjs.map +1 -0
- package/build/dive.cjs +2 -4860
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.ts +6 -1186
- package/build/dive.js +7 -4889
- package/build/dive.js.map +1 -1
- package/build/src/animation/AnimationSystem.d.ts +16 -0
- package/build/src/ar/AR.d.ts +21 -0
- package/build/src/ar/arquicklook/ARQuickLook.d.ts +8 -0
- package/build/src/ar/sceneviewer/SceneViewer.d.ts +7 -0
- package/build/src/ar/webxr/WebXR.d.ts +21 -0
- package/build/src/ar/webxr/controller/WebXRController.d.ts +46 -0
- package/build/src/ar/webxr/crosshair/WebXRCrosshair.d.ts +7 -0
- package/build/src/ar/webxr/origin/WebXROrigin.d.ts +31 -0
- package/build/src/ar/webxr/overlay/Overlay.d.ts +8 -0
- package/build/src/ar/webxr/raycaster/WebXRRaycaster.d.ts +40 -0
- package/build/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.d.ts +15 -0
- package/build/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.d.ts +12 -0
- package/build/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +73 -0
- package/build/src/axiscamera/AxisCamera.d.ts +18 -0
- package/build/src/camera/PerspectiveCamera.d.ts +20 -0
- package/build/src/com/Communication.d.ts +77 -0
- package/build/src/com/actions/camera/computeencompassingview.d.ts +9 -0
- package/build/src/com/actions/camera/getcameratransform.d.ts +9 -0
- package/build/src/com/actions/camera/movecamera.d.ts +15 -0
- package/build/src/com/actions/camera/resetcamera.d.ts +7 -0
- package/build/src/com/actions/camera/setcameralayer.d.ts +7 -0
- package/build/src/com/actions/camera/setcameratransform.d.ts +9 -0
- package/build/src/com/actions/camera/zoomcamera.d.ts +8 -0
- package/build/src/com/actions/index.d.ts +58 -0
- package/build/src/com/actions/media/generatemedia.d.ts +15 -0
- package/build/src/com/actions/object/addobject.d.ts +6 -0
- package/build/src/com/actions/object/deleteobject.d.ts +8 -0
- package/build/src/com/actions/object/deselectobject.d.ts +8 -0
- package/build/src/com/actions/object/getallobjects.d.ts +6 -0
- package/build/src/com/actions/object/getobjects.d.ts +8 -0
- package/build/src/com/actions/object/model/dropit.d.ts +7 -0
- package/build/src/com/actions/object/model/modelloaded.d.ts +7 -0
- package/build/src/com/actions/object/model/placeonfloor.d.ts +7 -0
- package/build/src/com/actions/object/selectobject.d.ts +8 -0
- package/build/src/com/actions/object/setparent.d.ts +13 -0
- package/build/src/com/actions/object/updateobject.d.ts +8 -0
- package/build/src/com/actions/scene/exportscene.d.ts +8 -0
- package/build/src/com/actions/scene/getallscenedata.d.ts +6 -0
- package/build/src/com/actions/scene/launchar.d.ts +6 -0
- package/build/src/com/actions/scene/setbackground.d.ts +7 -0
- package/build/src/com/actions/scene/updatescene.d.ts +11 -0
- package/build/src/com/actions/toolbox/select/setgizmomode.d.ts +7 -0
- package/build/src/com/actions/toolbox/transform/setgizmoscalelinked.d.ts +5 -0
- package/build/src/com/actions/toolbox/transform/setgizmovisible.d.ts +5 -0
- package/build/src/com/actions/toolbox/usetool.d.ts +8 -0
- package/build/src/com/types/COMBaseEntity.d.ts +8 -0
- package/build/src/com/types/COMEntity.d.ts +6 -0
- package/build/src/com/types/COMEntityType.d.ts +1 -0
- package/build/src/com/types/COMGeometry.d.ts +7 -0
- package/build/src/com/types/COMGeometryType.d.ts +1 -0
- package/build/src/com/types/COMGroup.d.ts +8 -0
- package/build/src/com/types/COMLight.d.ts +10 -0
- package/build/src/com/types/COMMaterial.d.ts +11 -0
- package/build/src/com/types/COMModel.d.ts +11 -0
- package/build/src/com/types/COMPov.d.ts +7 -0
- package/build/src/com/types/COMPrimitive.d.ts +11 -0
- package/build/src/com/types/index.d.ts +11 -0
- package/build/src/constant/AxisHelperColors.d.ts +6 -0
- package/build/src/constant/GridColors.d.ts +2 -0
- package/build/src/constant/VisibilityLayerMask.d.ts +5 -0
- package/build/src/controls/OrbitControls.d.ts +38 -0
- package/build/src/dive.d.ts +64 -0
- package/build/src/events/EventExecutor.d.ts +5 -0
- package/build/src/exporters/usdz/USDZExporter.d.ts +15 -0
- package/build/src/gizmo/Gizmo.d.ts +27 -0
- package/build/src/gizmo/handles/AxisHandle.d.ts +30 -0
- package/build/src/gizmo/handles/RadialHandle.d.ts +30 -0
- package/build/src/gizmo/handles/ScaleHandle.d.ts +33 -0
- package/build/src/gizmo/plane/GizmoPlane.d.ts +12 -0
- package/build/src/gizmo/rotate/RotateGizmo.d.ts +17 -0
- package/build/src/gizmo/scale/ScaleGizmo.d.ts +20 -0
- package/build/src/gizmo/translate/TranslateGizmo.d.ts +17 -0
- package/build/src/grid/Grid.d.ts +10 -0
- package/build/src/group/Group.d.ts +23 -0
- package/build/src/helper/applyMixins/applyMixins.d.ts +8 -0
- package/build/src/helper/findInterface/findInterface.d.ts +2 -0
- package/build/src/helper/findSceneRecursive/findSceneRecursive.d.ts +9 -0
- package/build/src/helper/getObjectDelta/getObjectDelta.d.ts +4 -0
- package/build/src/helper/isInterface/implementsInterface.d.ts +2 -0
- package/build/src/info/Info.d.ts +39 -0
- package/build/src/interface/Draggable.d.ts +7 -0
- package/build/src/interface/Hoverable.d.ts +7 -0
- package/build/src/interface/Movable.d.ts +11 -0
- package/build/src/interface/Rotatable.d.ts +9 -0
- package/build/src/interface/Scalable.d.ts +9 -0
- package/build/src/interface/Selectable.d.ts +10 -0
- package/build/src/io/IO.d.ts +10 -0
- package/build/src/io/gltf/GLTFIO.d.ts +12 -0
- package/build/src/light/AmbientLight.d.ts +17 -0
- package/build/src/light/PointLight.d.ts +29 -0
- package/build/src/light/SceneLight.d.ts +18 -0
- package/build/src/loadingmanager/LoadingManager.d.ts +14 -0
- package/build/src/math/ceil/ceilExp.d.ts +1 -0
- package/build/src/math/degToRad/degToRad.d.ts +1 -0
- package/build/src/math/floor/floorExp.d.ts +1 -0
- package/build/src/math/helper/shift.d.ts +1 -0
- package/build/src/math/index.d.ts +18 -0
- package/build/src/math/radToDeg/radToDeg.d.ts +1 -0
- package/build/src/math/round/roundExp.d.ts +1 -0
- package/build/src/math/signedAngleTo/signedAngleTo.d.ts +9 -0
- package/build/src/math/toFixed/toFixedExp.d.ts +1 -0
- package/build/src/math/truncate/truncateExp.d.ts +1 -0
- package/build/src/mediacreator/MediaCreator.d.ts +17 -0
- package/build/src/model/Model.d.ts +21 -0
- package/build/src/node/Node.d.ts +24 -0
- package/build/src/primitive/Primitive.d.ts +28 -0
- package/build/src/primitive/floor/Floor.d.ts +14 -0
- package/build/src/renderer/Renderer.d.ts +69 -0
- package/build/src/scene/Scene.d.ts +46 -0
- package/build/src/scene/root/Root.d.ts +42 -0
- package/build/src/scene/xrroot/XRRoot.d.ts +17 -0
- package/build/src/scene/xrroot/xrlightroot/XRLightRoot.d.ts +13 -0
- package/build/src/toolbox/BaseTool.d.ts +48 -0
- package/build/src/toolbox/Toolbox.d.ts +31 -0
- package/build/src/toolbox/select/SelectTool.d.ts +26 -0
- package/build/src/toolbox/transform/TransformTool.d.ts +27 -0
- package/build/src/types/SceneData.d.ts +19 -0
- package/build/src/types/SceneObjects.d.ts +7 -0
- package/build/src/types/SceneType.d.ts +4 -0
- package/build/src/types/index.d.ts +4 -0
- package/package.json +9 -8
- package/src/camera/PerspectiveCamera.ts +1 -1
- package/src/com/Communication.ts +33 -8
- package/src/com/__test__/Communication.test.ts +2 -1
- package/src/dive.ts +0 -3
- package/build/dive.d.cts +0 -1186
package/build/dive.js
CHANGED
|
@@ -1,4891 +1,9 @@
|
|
|
1
|
-
|
|
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 {
|
|
98
|
-
Raycaster,
|
|
99
|
-
Vector2,
|
|
100
|
-
Vector3
|
|
101
|
-
} from "three";
|
|
102
|
-
var DIVEBaseTool;
|
|
103
|
-
var init_BaseTool = __esm({
|
|
104
|
-
"src/toolbox/BaseTool.ts"() {
|
|
105
|
-
"use strict";
|
|
106
|
-
init_VisibilityLayerMask();
|
|
107
|
-
init_findInterface();
|
|
108
|
-
DIVEBaseTool = class {
|
|
109
|
-
constructor(scene, controller) {
|
|
110
|
-
this.POINTER_DRAG_THRESHOLD = 1e-3;
|
|
111
|
-
this.name = "BaseTool";
|
|
112
|
-
this._canvas = controller.domElement;
|
|
113
|
-
this._scene = scene;
|
|
114
|
-
this._controller = controller;
|
|
115
|
-
this._pointer = new Vector2();
|
|
116
|
-
this._pointerPrimaryDown = false;
|
|
117
|
-
this._pointerMiddleDown = false;
|
|
118
|
-
this._pointerSecondaryDown = false;
|
|
119
|
-
this._lastPointerDown = new Vector2();
|
|
120
|
-
this._lastPointerUp = new Vector2();
|
|
121
|
-
this._raycaster = new Raycaster();
|
|
122
|
-
this._raycaster.layers.mask = PRODUCT_LAYER_MASK | UI_LAYER_MASK;
|
|
123
|
-
this._intersects = [];
|
|
124
|
-
this._hovered = null;
|
|
125
|
-
this._dragging = false;
|
|
126
|
-
this._dragStart = new Vector3();
|
|
127
|
-
this._dragCurrent = new Vector3();
|
|
128
|
-
this._dragEnd = new Vector3();
|
|
129
|
-
this._dragDelta = new Vector3();
|
|
130
|
-
this._draggable = null;
|
|
131
|
-
this._dragRaycastOnObjects = null;
|
|
132
|
-
}
|
|
133
|
-
get _pointerAnyDown() {
|
|
134
|
-
return this._pointerPrimaryDown || this._pointerMiddleDown || this._pointerSecondaryDown;
|
|
135
|
-
}
|
|
136
|
-
Activate() {
|
|
137
|
-
}
|
|
138
|
-
Deactivate() {
|
|
139
|
-
}
|
|
140
|
-
onPointerDown(e) {
|
|
141
|
-
var _a;
|
|
142
|
-
switch (e.button) {
|
|
143
|
-
case 0: {
|
|
144
|
-
this._pointerPrimaryDown = true;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case 1: {
|
|
148
|
-
this._pointerMiddleDown = true;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
case 2: {
|
|
152
|
-
this._pointerSecondaryDown = true;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
default: {
|
|
156
|
-
console.warn(
|
|
157
|
-
"DIVEBaseTool.onPointerDown: Unknown button: " + e.button
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
this._lastPointerDown.copy(this._pointer);
|
|
162
|
-
this._draggable = findInterface(
|
|
163
|
-
(_a = this._intersects[0]) == null ? void 0 : _a.object,
|
|
164
|
-
"isDraggable"
|
|
165
|
-
) || null;
|
|
166
|
-
}
|
|
167
|
-
onDragStart(e) {
|
|
168
|
-
if (!this._draggable) return;
|
|
169
|
-
if (this._dragRaycastOnObjects !== null) {
|
|
170
|
-
this._intersects = this._raycaster.intersectObjects(
|
|
171
|
-
this._dragRaycastOnObjects,
|
|
172
|
-
true
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
if (this._intersects.length === 0) return;
|
|
176
|
-
this._dragStart.copy(this._intersects[0].point.clone());
|
|
177
|
-
this._dragCurrent.copy(this._intersects[0].point.clone());
|
|
178
|
-
this._dragEnd.copy(this._dragStart.clone());
|
|
179
|
-
this._dragDelta.set(0, 0, 0);
|
|
180
|
-
if (this._draggable && this._draggable.onDragStart) {
|
|
181
|
-
this._draggable.onDragStart({
|
|
182
|
-
dragStart: this._dragStart,
|
|
183
|
-
dragCurrent: this._dragCurrent,
|
|
184
|
-
dragEnd: this._dragEnd,
|
|
185
|
-
dragDelta: this._dragDelta
|
|
186
|
-
});
|
|
187
|
-
this._dragging = true;
|
|
188
|
-
this._controller.enabled = false;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
onPointerMove(e) {
|
|
192
|
-
var _a;
|
|
193
|
-
this._pointer.x = e.offsetX / this._canvas.clientWidth * 2 - 1;
|
|
194
|
-
this._pointer.y = -(e.offsetY / this._canvas.clientHeight) * 2 + 1;
|
|
195
|
-
this._raycaster.setFromCamera(this._pointer, this._controller.object);
|
|
196
|
-
this._intersects = this.raycast(this._scene.children);
|
|
197
|
-
const hoverable = findInterface(
|
|
198
|
-
(_a = this._intersects[0]) == null ? void 0 : _a.object,
|
|
199
|
-
"isHoverable"
|
|
200
|
-
);
|
|
201
|
-
if (this._intersects[0] && hoverable) {
|
|
202
|
-
if (!this._hovered) {
|
|
203
|
-
if (hoverable.onPointerEnter)
|
|
204
|
-
hoverable.onPointerEnter(this._intersects[0]);
|
|
205
|
-
this._hovered = hoverable;
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
if (this._hovered.uuid !== hoverable.uuid) {
|
|
209
|
-
if (this._hovered.onPointerLeave)
|
|
210
|
-
this._hovered.onPointerLeave();
|
|
211
|
-
if (hoverable.onPointerEnter)
|
|
212
|
-
hoverable.onPointerEnter(this._intersects[0]);
|
|
213
|
-
this._hovered = hoverable;
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
if (hoverable.onPointerOver)
|
|
217
|
-
hoverable.onPointerOver(this._intersects[0]);
|
|
218
|
-
this._hovered = hoverable;
|
|
219
|
-
} else {
|
|
220
|
-
if (this._hovered) {
|
|
221
|
-
if (this._hovered.onPointerLeave)
|
|
222
|
-
this._hovered.onPointerLeave();
|
|
223
|
-
}
|
|
224
|
-
this._hovered = null;
|
|
225
|
-
}
|
|
226
|
-
if (this._pointerAnyDown) {
|
|
227
|
-
if (!this._dragging) {
|
|
228
|
-
this.onDragStart(e);
|
|
229
|
-
}
|
|
230
|
-
this.onDrag(e);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
onDrag(e) {
|
|
234
|
-
if (this._dragRaycastOnObjects !== null) {
|
|
235
|
-
this._intersects = this._raycaster.intersectObjects(
|
|
236
|
-
this._dragRaycastOnObjects,
|
|
237
|
-
true
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
const intersect = this._intersects[0];
|
|
241
|
-
if (!intersect) return;
|
|
242
|
-
this._dragCurrent.copy(intersect.point.clone());
|
|
243
|
-
this._dragEnd.copy(intersect.point.clone());
|
|
244
|
-
this._dragDelta.subVectors(
|
|
245
|
-
this._dragCurrent.clone(),
|
|
246
|
-
this._dragStart.clone()
|
|
247
|
-
);
|
|
248
|
-
if (this._draggable && this._draggable.onDrag) {
|
|
249
|
-
this._draggable.onDrag({
|
|
250
|
-
dragStart: this._dragStart,
|
|
251
|
-
dragCurrent: this._dragCurrent,
|
|
252
|
-
dragEnd: this._dragEnd,
|
|
253
|
-
dragDelta: this._dragDelta
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
onPointerUp(e) {
|
|
258
|
-
if (this.pointerWasDragged() || this._dragging) {
|
|
259
|
-
if (this._draggable) {
|
|
260
|
-
this.onDragEnd(e);
|
|
261
|
-
}
|
|
262
|
-
} else {
|
|
263
|
-
this.onClick(e);
|
|
264
|
-
}
|
|
265
|
-
switch (e.button) {
|
|
266
|
-
case 0:
|
|
267
|
-
this._pointerPrimaryDown = false;
|
|
268
|
-
break;
|
|
269
|
-
case 1:
|
|
270
|
-
this._pointerMiddleDown = false;
|
|
271
|
-
break;
|
|
272
|
-
case 2:
|
|
273
|
-
this._pointerSecondaryDown = false;
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
this._lastPointerUp.copy(this._pointer);
|
|
277
|
-
}
|
|
278
|
-
onClick(e) {
|
|
279
|
-
}
|
|
280
|
-
onDragEnd(e) {
|
|
281
|
-
const intersect = this._intersects[0];
|
|
282
|
-
if (intersect) {
|
|
283
|
-
this._dragEnd.copy(intersect.point.clone());
|
|
284
|
-
this._dragCurrent.copy(intersect.point.clone());
|
|
285
|
-
this._dragDelta.subVectors(
|
|
286
|
-
this._dragCurrent.clone(),
|
|
287
|
-
this._dragStart.clone()
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
if (this._draggable && this._draggable.onDragEnd) {
|
|
291
|
-
this._draggable.onDragEnd({
|
|
292
|
-
dragStart: this._dragStart,
|
|
293
|
-
dragCurrent: this._dragCurrent,
|
|
294
|
-
dragEnd: this._dragEnd,
|
|
295
|
-
dragDelta: this._dragDelta
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
this._draggable = null;
|
|
299
|
-
this._dragging = false;
|
|
300
|
-
this._dragStart.set(0, 0, 0);
|
|
301
|
-
this._dragCurrent.set(0, 0, 0);
|
|
302
|
-
this._dragEnd.set(0, 0, 0);
|
|
303
|
-
this._dragDelta.set(0, 0, 0);
|
|
304
|
-
this._controller.enabled = true;
|
|
305
|
-
}
|
|
306
|
-
onWheel(e) {
|
|
307
|
-
}
|
|
308
|
-
raycast(objects) {
|
|
309
|
-
if (objects !== void 0)
|
|
310
|
-
return this._raycaster.intersectObjects(objects, true).filter((i) => i.object.visible);
|
|
311
|
-
return this._raycaster.intersectObjects(this._scene.children, true).filter((i) => i.object.visible);
|
|
312
|
-
}
|
|
313
|
-
pointerWasDragged() {
|
|
314
|
-
return this._lastPointerDown.distanceTo(this._pointer) > this.POINTER_DRAG_THRESHOLD;
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
// src/constant/AxisHelperColors.ts
|
|
321
|
-
var AxesColorRedLetter, AxesColorGreenLetter, AxesColorBlueLetter, AxesColorRed, AxesColorGreen, AxesColorBlue;
|
|
322
|
-
var init_AxisHelperColors = __esm({
|
|
323
|
-
"src/constant/AxisHelperColors.ts"() {
|
|
324
|
-
"use strict";
|
|
325
|
-
AxesColorRedLetter = "#c20017";
|
|
326
|
-
AxesColorGreenLetter = "#00ab26";
|
|
327
|
-
AxesColorBlueLetter = "#0081d4";
|
|
328
|
-
AxesColorRed = AxesColorRedLetter;
|
|
329
|
-
AxesColorGreen = AxesColorGreenLetter;
|
|
330
|
-
AxesColorBlue = AxesColorBlueLetter;
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
// src/toolbox/transform/TransformTool.ts
|
|
335
|
-
import { TransformControls } from "three/examples/jsm/controls/TransformControls";
|
|
336
|
-
var DIVETransformTool;
|
|
337
|
-
var init_TransformTool = __esm({
|
|
338
|
-
"src/toolbox/transform/TransformTool.ts"() {
|
|
339
|
-
"use strict";
|
|
340
|
-
init_BaseTool();
|
|
341
|
-
init_implementsInterface();
|
|
342
|
-
init_AxisHelperColors();
|
|
343
|
-
DIVETransformTool = class extends DIVEBaseTool {
|
|
344
|
-
constructor(scene, controller) {
|
|
345
|
-
super(scene, controller);
|
|
346
|
-
this.isTransformTool = true;
|
|
347
|
-
this.name = "DIVETransformTool";
|
|
348
|
-
this._scaleLinked = false;
|
|
349
|
-
this._gizmo = this.initGizmo();
|
|
350
|
-
this._scene.add(this._gizmo);
|
|
351
|
-
}
|
|
352
|
-
Activate() {
|
|
353
|
-
}
|
|
354
|
-
SetGizmoMode(mode) {
|
|
355
|
-
this._gizmo.mode = mode;
|
|
356
|
-
}
|
|
357
|
-
SetGizmoVisibility(active) {
|
|
358
|
-
const contains = this._scene.children.includes(this._gizmo);
|
|
359
|
-
if (active && !contains) {
|
|
360
|
-
this._scene.add(this._gizmo);
|
|
361
|
-
if ("isTransformControls" in this._gizmo) {
|
|
362
|
-
this._gizmo.getRaycaster().layers.enableAll();
|
|
363
|
-
}
|
|
364
|
-
} else if (!active && contains) {
|
|
365
|
-
this._scene.remove(this._gizmo);
|
|
366
|
-
if ("isTransformControls" in this._gizmo) {
|
|
367
|
-
this._gizmo.getRaycaster().layers.disableAll();
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
SetGizmoScaleLinked(linked) {
|
|
372
|
-
this._scaleLinked = linked;
|
|
373
|
-
}
|
|
374
|
-
// only used for optimizing pointer events with DIVEGizmo
|
|
375
|
-
// public onPointerDown(e: PointerEvent): void {
|
|
376
|
-
// super.onPointerDown(e);
|
|
377
|
-
// if (this._hovered) {
|
|
378
|
-
// this._dragRaycastOnObjects = (
|
|
379
|
-
// this._gizmo as DIVEGizmo
|
|
380
|
-
// ).gizmoPlane?.children;
|
|
381
|
-
// }
|
|
382
|
-
// }
|
|
383
|
-
// only used for optimizing pointer events with DIVEGizmo
|
|
384
|
-
// protected raycast(): Intersection[] {
|
|
385
|
-
// return super.raycast((this._gizmo as DIVEGizmo).gizmoNode.children);
|
|
386
|
-
// }
|
|
387
|
-
initGizmo() {
|
|
388
|
-
const g = new TransformControls(
|
|
389
|
-
// this._controller,
|
|
390
|
-
this._controller.object,
|
|
391
|
-
this._controller.domElement
|
|
392
|
-
);
|
|
393
|
-
g.mode = "translate";
|
|
394
|
-
g.traverse((child) => {
|
|
395
|
-
if (!("isMesh" in child)) return;
|
|
396
|
-
const material = child.material;
|
|
397
|
-
if (child.name === "X") {
|
|
398
|
-
material.color.set(AxesColorRed);
|
|
399
|
-
}
|
|
400
|
-
if (child.name === "Y") {
|
|
401
|
-
material.color.set(AxesColorGreen);
|
|
402
|
-
}
|
|
403
|
-
if (child.name === "Z") {
|
|
404
|
-
material.color.set(AxesColorBlue);
|
|
405
|
-
}
|
|
406
|
-
if (child.name === "XY") {
|
|
407
|
-
material.color.set(AxesColorBlue);
|
|
408
|
-
}
|
|
409
|
-
if (child.name === "YZ") {
|
|
410
|
-
material.color.set(AxesColorRed);
|
|
411
|
-
}
|
|
412
|
-
if (child.name === "XZ") {
|
|
413
|
-
material.color.set(AxesColorGreen);
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
g.addEventListener("mouseDown", () => {
|
|
417
|
-
this._controller.enabled = false;
|
|
418
|
-
if (!implementsInterface(g.object, "isMovable"))
|
|
419
|
-
return;
|
|
420
|
-
if (!g.object.onMoveStart) return;
|
|
421
|
-
g.object.onMoveStart();
|
|
422
|
-
});
|
|
423
|
-
g.addEventListener("objectChange", () => {
|
|
424
|
-
if (!implementsInterface(g.object, "isMovable"))
|
|
425
|
-
return;
|
|
426
|
-
if (!g.object.onMove) return;
|
|
427
|
-
g.object.onMove();
|
|
428
|
-
if (this._scaleLinked) {
|
|
429
|
-
const scale = g.object.scale;
|
|
430
|
-
const averageScale = (scale.x + scale.y + scale.z) / 3;
|
|
431
|
-
g.object.scale.set(averageScale, averageScale, averageScale);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
g.addEventListener("mouseUp", () => {
|
|
435
|
-
this._controller.enabled = true;
|
|
436
|
-
if (!implementsInterface(g.object, "isMovable"))
|
|
437
|
-
return;
|
|
438
|
-
if (!g.object.onMoveEnd) return;
|
|
439
|
-
g.object.onMoveEnd();
|
|
440
|
-
});
|
|
441
|
-
return g;
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
// src/toolbox/select/SelectTool.ts
|
|
448
|
-
var SelectTool_exports = {};
|
|
449
|
-
__export(SelectTool_exports, {
|
|
450
|
-
DIVESelectTool: () => DIVESelectTool,
|
|
451
|
-
isSelectTool: () => isSelectTool
|
|
452
|
-
});
|
|
453
|
-
var isSelectTool, DIVESelectTool;
|
|
454
|
-
var init_SelectTool = __esm({
|
|
455
|
-
"src/toolbox/select/SelectTool.ts"() {
|
|
456
|
-
"use strict";
|
|
457
|
-
init_TransformTool();
|
|
458
|
-
init_findInterface();
|
|
459
|
-
isSelectTool = (tool) => {
|
|
460
|
-
return tool.isSelectTool !== void 0;
|
|
461
|
-
};
|
|
462
|
-
DIVESelectTool = class extends DIVETransformTool {
|
|
463
|
-
constructor(scene, controller) {
|
|
464
|
-
super(scene, controller);
|
|
465
|
-
this.isSelectTool = true;
|
|
466
|
-
this.name = "SelectTool";
|
|
467
|
-
}
|
|
468
|
-
Activate() {
|
|
469
|
-
}
|
|
470
|
-
Select(selectable) {
|
|
471
|
-
this.AttachGizmo(selectable);
|
|
472
|
-
if (selectable.onSelect) selectable.onSelect();
|
|
473
|
-
}
|
|
474
|
-
Deselect(selectable) {
|
|
475
|
-
this.DetachGizmo();
|
|
476
|
-
if (selectable.onDeselect) selectable.onDeselect();
|
|
477
|
-
}
|
|
478
|
-
AttachGizmo(selectable) {
|
|
479
|
-
if ("isMovable" in selectable) {
|
|
480
|
-
const movable = selectable;
|
|
481
|
-
this._gizmo.attach(movable);
|
|
482
|
-
this.SetGizmoVisibility(movable.visible);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
DetachGizmo() {
|
|
486
|
-
this._gizmo.detach();
|
|
487
|
-
}
|
|
488
|
-
onClick(e) {
|
|
489
|
-
super.onClick(e);
|
|
490
|
-
const first = this._raycaster.intersectObjects(this._scene.Root.children, true).filter((intersect) => intersect.object.visible)[0];
|
|
491
|
-
const selectable = findInterface(
|
|
492
|
-
first == null ? void 0 : first.object,
|
|
493
|
-
"isSelectable"
|
|
494
|
-
);
|
|
495
|
-
if (!first || !selectable) {
|
|
496
|
-
if (this._gizmo.object) {
|
|
497
|
-
this.Deselect(this._gizmo.object);
|
|
498
|
-
}
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
if (this._gizmo.object) {
|
|
502
|
-
if (this._gizmo.object.uuid === selectable.uuid) return;
|
|
503
|
-
this.Deselect(this._gizmo.object);
|
|
504
|
-
}
|
|
505
|
-
this.Select(selectable);
|
|
506
|
-
}
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
// src/camera/PerspectiveCamera.ts
|
|
512
|
-
import { PerspectiveCamera } from "three";
|
|
513
|
-
var DIVEPerspectiveCameraDefaultSettings, _DIVEPerspectiveCamera, DIVEPerspectiveCamera;
|
|
514
|
-
var init_PerspectiveCamera = __esm({
|
|
515
|
-
"src/camera/PerspectiveCamera.ts"() {
|
|
516
|
-
"use strict";
|
|
517
|
-
init_VisibilityLayerMask();
|
|
518
|
-
DIVEPerspectiveCameraDefaultSettings = {
|
|
519
|
-
fov: 80,
|
|
520
|
-
near: 0.1,
|
|
521
|
-
far: 1e3
|
|
522
|
-
};
|
|
523
|
-
_DIVEPerspectiveCamera = class _DIVEPerspectiveCamera extends PerspectiveCamera {
|
|
524
|
-
constructor(settings = DIVEPerspectiveCameraDefaultSettings) {
|
|
525
|
-
super(
|
|
526
|
-
settings.fov || DIVEPerspectiveCameraDefaultSettings.fov,
|
|
527
|
-
1,
|
|
528
|
-
settings.near || DIVEPerspectiveCameraDefaultSettings.near,
|
|
529
|
-
settings.far || DIVEPerspectiveCameraDefaultSettings.far
|
|
530
|
-
);
|
|
531
|
-
this.onSetCameraLayer = () => {
|
|
532
|
-
};
|
|
533
|
-
this.layers.mask = _DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
534
|
-
}
|
|
535
|
-
OnResize(width, height) {
|
|
536
|
-
this.aspect = width / height;
|
|
537
|
-
this.updateProjectionMatrix();
|
|
538
|
-
}
|
|
539
|
-
SetCameraLayer(layer) {
|
|
540
|
-
this.layers.mask = layer === "LIVE" ? _DIVEPerspectiveCamera.LIVE_VIEW_LAYER_MASK : _DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
541
|
-
this.onSetCameraLayer(this.layers.mask);
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
_DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK = DEFAULT_LAYER_MASK | UI_LAYER_MASK | HELPER_LAYER_MASK | PRODUCT_LAYER_MASK;
|
|
545
|
-
_DIVEPerspectiveCamera.LIVE_VIEW_LAYER_MASK = PRODUCT_LAYER_MASK;
|
|
546
|
-
DIVEPerspectiveCamera = _DIVEPerspectiveCamera;
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
// src/mediacreator/MediaCreator.ts
|
|
551
|
-
var MediaCreator_exports = {};
|
|
552
|
-
__export(MediaCreator_exports, {
|
|
553
|
-
DIVEMediaCreator: () => DIVEMediaCreator
|
|
554
|
-
});
|
|
555
|
-
var DIVEMediaCreator;
|
|
556
|
-
var init_MediaCreator = __esm({
|
|
557
|
-
"src/mediacreator/MediaCreator.ts"() {
|
|
558
|
-
"use strict";
|
|
559
|
-
init_PerspectiveCamera();
|
|
560
|
-
DIVEMediaCreator = class {
|
|
561
|
-
constructor(renderer, scene, controller) {
|
|
562
|
-
this.renderer = renderer;
|
|
563
|
-
this.scene = scene;
|
|
564
|
-
this.controller = controller;
|
|
565
|
-
}
|
|
566
|
-
GenerateMedia(position, target, width, height) {
|
|
567
|
-
const resetPosition = this.controller.object.position.clone();
|
|
568
|
-
const resetRotation = this.controller.object.quaternion.clone();
|
|
569
|
-
this.renderer.OnResize(width, height);
|
|
570
|
-
this.controller.object.OnResize(width, height);
|
|
571
|
-
this.controller.object.position.copy(position);
|
|
572
|
-
this.controller.target.copy(target);
|
|
573
|
-
this.controller.update();
|
|
574
|
-
const dataUri = this.DrawCanvas().toDataURL();
|
|
575
|
-
this.controller.object.position.copy(resetPosition);
|
|
576
|
-
this.controller.object.quaternion.copy(resetRotation);
|
|
577
|
-
return dataUri;
|
|
578
|
-
}
|
|
579
|
-
DrawCanvas(canvasElement) {
|
|
580
|
-
const restore = this.renderer.domElement;
|
|
581
|
-
if (canvasElement) {
|
|
582
|
-
this.renderer.domElement = canvasElement;
|
|
583
|
-
}
|
|
584
|
-
this.controller.object.layers.mask = DIVEPerspectiveCamera.LIVE_VIEW_LAYER_MASK;
|
|
585
|
-
this.renderer.render(this.scene, this.controller.object);
|
|
586
|
-
this.controller.object.layers.mask = DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK;
|
|
587
|
-
const returnCanvas = this.renderer.domElement;
|
|
588
|
-
if (canvasElement) {
|
|
589
|
-
this.renderer.domElement = restore;
|
|
590
|
-
}
|
|
591
|
-
return returnCanvas;
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
// src/io/gltf/GLTFIO.ts
|
|
598
|
-
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
599
|
-
import { GLTFExporter } from "three/examples/jsm/exporters/GLTFExporter";
|
|
600
|
-
var DIVEGLTFIO;
|
|
601
|
-
var init_GLTFIO = __esm({
|
|
602
|
-
"src/io/gltf/GLTFIO.ts"() {
|
|
603
|
-
"use strict";
|
|
604
|
-
DIVEGLTFIO = class {
|
|
605
|
-
constructor() {
|
|
606
|
-
this._importer = new GLTFLoader();
|
|
607
|
-
this._exporter = new GLTFExporter();
|
|
608
|
-
}
|
|
609
|
-
Import(url, onProgress) {
|
|
610
|
-
return this._importer.loadAsync(url, (progress) => {
|
|
611
|
-
if (!onProgress) return;
|
|
612
|
-
onProgress(progress.loaded / progress.total);
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
Export(object, binary, onlyVisible) {
|
|
616
|
-
if (binary) {
|
|
617
|
-
return this._exporter.parseAsync(object, {
|
|
618
|
-
binary,
|
|
619
|
-
onlyVisible
|
|
620
|
-
});
|
|
621
|
-
} else {
|
|
622
|
-
return this._exporter.parseAsync(object, {
|
|
623
|
-
binary,
|
|
624
|
-
onlyVisible
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
// src/io/IO.ts
|
|
633
|
-
var IO_exports = {};
|
|
634
|
-
__export(IO_exports, {
|
|
635
|
-
DIVEIO: () => DIVEIO
|
|
636
|
-
});
|
|
637
|
-
var DIVEIO;
|
|
638
|
-
var init_IO = __esm({
|
|
639
|
-
"src/io/IO.ts"() {
|
|
640
|
-
"use strict";
|
|
641
|
-
init_GLTFIO();
|
|
642
|
-
DIVEIO = class {
|
|
643
|
-
constructor(scene) {
|
|
644
|
-
this._scene = scene;
|
|
645
|
-
this._gltfIO = new DIVEGLTFIO();
|
|
646
|
-
}
|
|
647
|
-
Import(type, url) {
|
|
648
|
-
switch (type) {
|
|
649
|
-
case "glb": {
|
|
650
|
-
return this._gltfIO.Import(url).catch((error) => {
|
|
651
|
-
console.error(error);
|
|
652
|
-
return null;
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
default: {
|
|
656
|
-
console.error("DIVEIO.Import: Unsupported file type: " + type);
|
|
657
|
-
return Promise.reject();
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
Export(type) {
|
|
662
|
-
switch (type) {
|
|
663
|
-
case "glb": {
|
|
664
|
-
return this._gltfIO.Export(this._scene, true, true).then((data) => {
|
|
665
|
-
return this._createBlobURL(data);
|
|
666
|
-
}).catch((error) => {
|
|
667
|
-
console.error(error);
|
|
668
|
-
return null;
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
default: {
|
|
672
|
-
console.error("DIVEIO.Export: Unsupported file type: " + type);
|
|
673
|
-
return Promise.reject();
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
_createBlobURL(data) {
|
|
678
|
-
return URL.createObjectURL(new Blob([data]));
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
// src/info/Info.ts
|
|
685
|
-
var WebXRUnsupportedReason, DIVEInfo;
|
|
686
|
-
var init_Info = __esm({
|
|
687
|
-
"src/info/Info.ts"() {
|
|
688
|
-
"use strict";
|
|
689
|
-
WebXRUnsupportedReason = /* @__PURE__ */ ((WebXRUnsupportedReason2) => {
|
|
690
|
-
WebXRUnsupportedReason2[WebXRUnsupportedReason2["UNKNWON_ERROR"] = 0] = "UNKNWON_ERROR";
|
|
691
|
-
WebXRUnsupportedReason2[WebXRUnsupportedReason2["NO_HTTPS"] = 1] = "NO_HTTPS";
|
|
692
|
-
WebXRUnsupportedReason2[WebXRUnsupportedReason2["IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE"] = 2] = "IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE";
|
|
693
|
-
WebXRUnsupportedReason2[WebXRUnsupportedReason2["AR_SESSION_NOT_ALLOWED"] = 3] = "AR_SESSION_NOT_ALLOWED";
|
|
694
|
-
return WebXRUnsupportedReason2;
|
|
695
|
-
})(WebXRUnsupportedReason || {});
|
|
696
|
-
DIVEInfo = class {
|
|
697
|
-
/**
|
|
698
|
-
*
|
|
699
|
-
* @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
|
|
700
|
-
*/
|
|
701
|
-
static GetSystem() {
|
|
702
|
-
const platform = navigator.platform;
|
|
703
|
-
if (/Android/.test(navigator.userAgent)) {
|
|
704
|
-
return "Android";
|
|
705
|
-
} else if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
|
|
706
|
-
return "iOS";
|
|
707
|
-
} else if (platform.startsWith("Win")) {
|
|
708
|
-
return "Windows";
|
|
709
|
-
} else if (platform.startsWith("Mac")) {
|
|
710
|
-
return "MacOS";
|
|
711
|
-
} else if (platform.startsWith("Linux")) {
|
|
712
|
-
return "Linux";
|
|
713
|
-
} else {
|
|
714
|
-
return "Unknown";
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
|
|
719
|
-
*/
|
|
720
|
-
static GetSupportsWebXR() {
|
|
721
|
-
return __async(this, null, function* () {
|
|
722
|
-
if (this._supportsWebXR !== null) {
|
|
723
|
-
return this._supportsWebXR;
|
|
724
|
-
}
|
|
725
|
-
if (!navigator.xr) {
|
|
726
|
-
this._supportsWebXR = false;
|
|
727
|
-
if (window.isSecureContext === false) {
|
|
728
|
-
this._webXRUnsupportedReason = 1 /* NO_HTTPS */;
|
|
729
|
-
} else {
|
|
730
|
-
this._webXRUnsupportedReason = 0 /* UNKNWON_ERROR */;
|
|
731
|
-
}
|
|
732
|
-
return this._supportsWebXR;
|
|
733
|
-
}
|
|
734
|
-
try {
|
|
735
|
-
const supported = yield navigator.xr.isSessionSupported("immersive-ar");
|
|
736
|
-
if (!supported) {
|
|
737
|
-
this._webXRUnsupportedReason = 2 /* IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE */;
|
|
738
|
-
}
|
|
739
|
-
this._supportsWebXR = supported;
|
|
740
|
-
} catch (error) {
|
|
741
|
-
this._supportsWebXR = false;
|
|
742
|
-
this._webXRUnsupportedReason = 3 /* AR_SESSION_NOT_ALLOWED */;
|
|
743
|
-
}
|
|
744
|
-
return this._supportsWebXR;
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
/**
|
|
748
|
-
* @returns The reason why WebXR is not supported on the user's device. Returns null if WebXR is supported nor not has been checked yet.
|
|
749
|
-
*/
|
|
750
|
-
static GetWebXRUnsupportedReason() {
|
|
751
|
-
if (this._supportsWebXR === null) {
|
|
752
|
-
console.log("WebXR support has not been checked yet.");
|
|
753
|
-
return null;
|
|
754
|
-
}
|
|
755
|
-
return this._webXRUnsupportedReason;
|
|
756
|
-
}
|
|
757
|
-
/**
|
|
758
|
-
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
759
|
-
*/
|
|
760
|
-
static GetSupportsARQuickLook() {
|
|
761
|
-
const a = document.createElement("a");
|
|
762
|
-
if (a.relList.supports("ar")) {
|
|
763
|
-
return true;
|
|
764
|
-
}
|
|
765
|
-
const userAgent = navigator.userAgent;
|
|
766
|
-
const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream;
|
|
767
|
-
if (!isIOS) {
|
|
768
|
-
return false;
|
|
769
|
-
}
|
|
770
|
-
const match = userAgent.match(/OS (\d+)_/);
|
|
771
|
-
if (!match || match.length < 2) {
|
|
772
|
-
return false;
|
|
773
|
-
}
|
|
774
|
-
const iOSVersion = parseInt(match[1], 10);
|
|
775
|
-
const minQuickLookVersion = 12;
|
|
776
|
-
if (iOSVersion < minQuickLookVersion) {
|
|
777
|
-
return false;
|
|
778
|
-
}
|
|
779
|
-
const isSupportedBrowser = /^((?!chrome|android).)*safari|CriOS|FxiOS/i.test(userAgent);
|
|
780
|
-
if (isSupportedBrowser) {
|
|
781
|
-
return true;
|
|
782
|
-
}
|
|
783
|
-
return false;
|
|
784
|
-
}
|
|
785
|
-
/**
|
|
786
|
-
* @returns A boolean indicating whether the user's device is a mobile device.
|
|
787
|
-
*/
|
|
788
|
-
static get isMobile() {
|
|
789
|
-
return this.GetSystem() === "Android" || this.GetSystem() === "iOS";
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* @returns A boolean indicating whether the user's device is a desktop device.
|
|
793
|
-
*/
|
|
794
|
-
static get isDesktop() {
|
|
795
|
-
return !this.isMobile;
|
|
796
|
-
}
|
|
797
|
-
/**
|
|
798
|
-
* @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
|
|
799
|
-
*/
|
|
800
|
-
static GetIsARCapable() {
|
|
801
|
-
return __async(this, null, function* () {
|
|
802
|
-
if (this.GetSupportsARQuickLook()) {
|
|
803
|
-
return true;
|
|
804
|
-
}
|
|
805
|
-
return yield this.GetSupportsWebXR();
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
};
|
|
809
|
-
DIVEInfo._supportsWebXR = null;
|
|
810
|
-
DIVEInfo._webXRUnsupportedReason = null;
|
|
811
|
-
}
|
|
812
|
-
});
|
|
813
|
-
|
|
814
|
-
// src/exporters/usdz/USDZExporter.ts
|
|
815
|
-
import {
|
|
816
|
-
USDZExporter
|
|
817
|
-
} from "three/examples/jsm/exporters/USDZExporter";
|
|
818
|
-
var DIVEUSDZExporter;
|
|
819
|
-
var init_USDZExporter = __esm({
|
|
820
|
-
"src/exporters/usdz/USDZExporter.ts"() {
|
|
821
|
-
"use strict";
|
|
822
|
-
DIVEUSDZExporter = class extends USDZExporter {
|
|
823
|
-
parse(scene, options) {
|
|
824
|
-
return super.parse(scene, options);
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
|
|
830
|
-
// src/ar/arquicklook/ARQuickLook.ts
|
|
831
|
-
import { Object3D as Object3D2 } from "three";
|
|
832
|
-
var DIVEARQuickLook;
|
|
833
|
-
var init_ARQuickLook = __esm({
|
|
834
|
-
"src/ar/arquicklook/ARQuickLook.ts"() {
|
|
835
|
-
"use strict";
|
|
836
|
-
init_USDZExporter();
|
|
837
|
-
DIVEARQuickLook = class {
|
|
838
|
-
static Launch(scene, options) {
|
|
839
|
-
const quickLookScene = new Object3D2();
|
|
840
|
-
quickLookScene.add(...this.extractModels(scene));
|
|
841
|
-
return this.launchARFromNode(quickLookScene, options);
|
|
842
|
-
}
|
|
843
|
-
static extractModels(scene) {
|
|
844
|
-
return scene.Root.children;
|
|
845
|
-
}
|
|
846
|
-
static launchARFromNode(node, options) {
|
|
847
|
-
return this._usdzExporter.parse(node, {
|
|
848
|
-
quickLookCompatible: true,
|
|
849
|
-
ar: {
|
|
850
|
-
anchoring: { type: "plane" },
|
|
851
|
-
planeAnchoring: {
|
|
852
|
-
alignment: (options == null ? void 0 : options.arPlacement) === "vertical" ? "vertical" : "horizontal"
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
}).then((usdz) => {
|
|
856
|
-
const blob = new Blob([usdz], { type: "model/vnd.usdz+zip" });
|
|
857
|
-
let url = URL.createObjectURL(blob);
|
|
858
|
-
if ((options == null ? void 0 : options.arScale) === "fixed") {
|
|
859
|
-
url = url.concat("#allowsContentScaling=0");
|
|
860
|
-
}
|
|
861
|
-
const a = document.createElement("a");
|
|
862
|
-
a.innerHTML = "<picture></picture>";
|
|
863
|
-
a.rel = "ar";
|
|
864
|
-
a.href = url;
|
|
865
|
-
a.download = "scene.usdz";
|
|
866
|
-
a.click();
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
DIVEARQuickLook._usdzExporter = new DIVEUSDZExporter();
|
|
871
|
-
}
|
|
872
|
-
});
|
|
873
|
-
|
|
874
|
-
// src/ar/webxr/overlay/Overlay.ts
|
|
875
|
-
var Overlay;
|
|
876
|
-
var init_Overlay = __esm({
|
|
877
|
-
"src/ar/webxr/overlay/Overlay.ts"() {
|
|
878
|
-
"use strict";
|
|
879
|
-
Overlay = class {
|
|
880
|
-
get Element() {
|
|
881
|
-
return this._element;
|
|
882
|
-
}
|
|
883
|
-
get CloseButton() {
|
|
884
|
-
return this._closeButton;
|
|
885
|
-
}
|
|
886
|
-
constructor() {
|
|
887
|
-
this._element = document.createElement("div");
|
|
888
|
-
this._closeButton = this.createCloseButton();
|
|
889
|
-
this._element.appendChild(this._closeButton);
|
|
890
|
-
document.body.appendChild(this._element);
|
|
891
|
-
}
|
|
892
|
-
createCloseButton() {
|
|
893
|
-
const path = document.createElementNS(
|
|
894
|
-
"http://www.w3.org/2000/svg",
|
|
895
|
-
"path"
|
|
896
|
-
);
|
|
897
|
-
path.setAttribute("d", "M 12,12 L 28,28 M 28,12 12,28");
|
|
898
|
-
path.setAttribute("stroke", "#fff");
|
|
899
|
-
path.setAttribute("stroke-width", "2");
|
|
900
|
-
const svg = document.createElementNS(
|
|
901
|
-
"http://www.w3.org/2000/svg",
|
|
902
|
-
"svg"
|
|
903
|
-
);
|
|
904
|
-
svg.setAttribute("width", "38");
|
|
905
|
-
svg.setAttribute("height", "38");
|
|
906
|
-
svg.style.position = "absolute";
|
|
907
|
-
svg.style.right = "20px";
|
|
908
|
-
svg.style.top = "20px";
|
|
909
|
-
svg.appendChild(path);
|
|
910
|
-
return svg;
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
// src/ar/webxr/crosshair/WebXRCrosshair.ts
|
|
917
|
-
import { Mesh, MeshBasicMaterial, Object3D as Object3D3, RingGeometry } from "three";
|
|
918
|
-
var DIVEWebXRCrosshair;
|
|
919
|
-
var init_WebXRCrosshair = __esm({
|
|
920
|
-
"src/ar/webxr/crosshair/WebXRCrosshair.ts"() {
|
|
921
|
-
"use strict";
|
|
922
|
-
DIVEWebXRCrosshair = class extends Object3D3 {
|
|
923
|
-
set mesh(mesh) {
|
|
924
|
-
this.clear();
|
|
925
|
-
if (mesh) {
|
|
926
|
-
this.add(mesh);
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
constructor(mesh) {
|
|
930
|
-
super();
|
|
931
|
-
if (mesh) {
|
|
932
|
-
this.mesh = mesh;
|
|
933
|
-
} else {
|
|
934
|
-
this.UseDefaultMesh();
|
|
935
|
-
}
|
|
936
|
-
this.matrixAutoUpdate = false;
|
|
937
|
-
return this;
|
|
938
|
-
}
|
|
939
|
-
UseDefaultMesh() {
|
|
940
|
-
const geometry = new RingGeometry(0.08, 0.1, 32).rotateX(-Math.PI / 2);
|
|
941
|
-
const material = new MeshBasicMaterial();
|
|
942
|
-
this.mesh = new Mesh(geometry, material);
|
|
943
|
-
}
|
|
944
|
-
UpdateFromPose(pose) {
|
|
945
|
-
this.matrix.fromArray(pose.transform.matrix);
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
}
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
// src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts
|
|
952
|
-
import { Matrix4, Vector3 as Vector32 } from "three";
|
|
953
|
-
var DIVEWebXRRaycasterAR;
|
|
954
|
-
var init_WebXRRaycasterAR = __esm({
|
|
955
|
-
"src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts"() {
|
|
956
|
-
"use strict";
|
|
957
|
-
DIVEWebXRRaycasterAR = class {
|
|
958
|
-
constructor(session, renderer) {
|
|
959
|
-
this._referenceSpaceBuffer = null;
|
|
960
|
-
this._requesting = false;
|
|
961
|
-
this._initialized = false;
|
|
962
|
-
this._session = session;
|
|
963
|
-
this._renderer = renderer;
|
|
964
|
-
this._hitMatrixBuffer = new Matrix4();
|
|
965
|
-
}
|
|
966
|
-
Dispose() {
|
|
967
|
-
var _a;
|
|
968
|
-
(_a = this._transientHitTestSource) == null ? void 0 : _a.cancel();
|
|
969
|
-
this._transientHitTestSource = void 0;
|
|
970
|
-
this._initialized = false;
|
|
971
|
-
}
|
|
972
|
-
Init() {
|
|
973
|
-
return __async(this, null, function* () {
|
|
974
|
-
if (!this._session) {
|
|
975
|
-
console.error(
|
|
976
|
-
"DIVEWebXRRaycaster: No session set in Init()! Aborting initialization..."
|
|
977
|
-
);
|
|
978
|
-
return Promise.reject();
|
|
979
|
-
}
|
|
980
|
-
if (this._requesting) {
|
|
981
|
-
console.error(
|
|
982
|
-
"DIVEWebXRRaycaster: Currently initializing! Aborting initialization..."
|
|
983
|
-
);
|
|
984
|
-
return Promise.reject();
|
|
985
|
-
}
|
|
986
|
-
if (this._initialized) {
|
|
987
|
-
console.error(
|
|
988
|
-
"DIVEWebXRRaycaster: Already initialized! Aborting initialization..."
|
|
989
|
-
);
|
|
990
|
-
return Promise.reject();
|
|
991
|
-
}
|
|
992
|
-
this._requesting = true;
|
|
993
|
-
this._transientHitTestSource = yield this._session.requestHitTestSourceForTransientInput({
|
|
994
|
-
profile: "generic-touchscreen"
|
|
995
|
-
});
|
|
996
|
-
this._referenceSpaceBuffer = this._renderer.xr.getReferenceSpace();
|
|
997
|
-
this._requesting = false;
|
|
998
|
-
if (!this._transientHitTestSource) {
|
|
999
|
-
return Promise.reject();
|
|
1000
|
-
}
|
|
1001
|
-
this._initialized = true;
|
|
1002
|
-
console.log("DIVEWebXRRaycasterAR: Initialized");
|
|
1003
|
-
return Promise.resolve(this);
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
GetIntersections(frame) {
|
|
1007
|
-
if (!this._transientHitTestSource) return [];
|
|
1008
|
-
const touches = frame.getHitTestResultsForTransientInput(
|
|
1009
|
-
this._transientHitTestSource
|
|
1010
|
-
);
|
|
1011
|
-
if (touches.length === 0) return [];
|
|
1012
|
-
const hits = touches.map((touch) => {
|
|
1013
|
-
if (!this._referenceSpaceBuffer) return void 0;
|
|
1014
|
-
if (!touch.results[0]) return void 0;
|
|
1015
|
-
if (!touch.results[0].getPose) return void 0;
|
|
1016
|
-
const pose = touch.results[0].getPose(this._referenceSpaceBuffer);
|
|
1017
|
-
if (!pose) return void 0;
|
|
1018
|
-
this._hitMatrixBuffer.fromArray(pose.transform.matrix);
|
|
1019
|
-
const position = new Vector32().setFromMatrixPosition(
|
|
1020
|
-
this._hitMatrixBuffer
|
|
1021
|
-
);
|
|
1022
|
-
return {
|
|
1023
|
-
point: position,
|
|
1024
|
-
matrix: this._hitMatrixBuffer,
|
|
1025
|
-
object: void 0
|
|
1026
|
-
};
|
|
1027
|
-
});
|
|
1028
|
-
return hits.filter((hit) => hit !== void 0);
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
});
|
|
1033
|
-
|
|
1034
|
-
// src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts
|
|
1035
|
-
import {
|
|
1036
|
-
Raycaster as Raycaster2
|
|
1037
|
-
} from "three";
|
|
1038
|
-
var DIVEWebXRRaycasterTHREE;
|
|
1039
|
-
var init_WebXRRaycasterTHREE = __esm({
|
|
1040
|
-
"src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts"() {
|
|
1041
|
-
"use strict";
|
|
1042
|
-
DIVEWebXRRaycasterTHREE = class {
|
|
1043
|
-
constructor(renderer, scene) {
|
|
1044
|
-
// internal raycaster
|
|
1045
|
-
this._raycaster = new Raycaster2();
|
|
1046
|
-
this._renderer = renderer;
|
|
1047
|
-
this._scene = scene;
|
|
1048
|
-
this._controller = this._renderer.xr.getController(0);
|
|
1049
|
-
}
|
|
1050
|
-
Init() {
|
|
1051
|
-
return __async(this, null, function* () {
|
|
1052
|
-
console.log("DIVEWebXRRaycasterTHREE: Initialized");
|
|
1053
|
-
return Promise.resolve(this);
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
GetIntersections() {
|
|
1057
|
-
this._controller.updateMatrixWorld();
|
|
1058
|
-
this._raycaster.setFromXRController(this._controller);
|
|
1059
|
-
const intersections = this._raycaster.intersectObjects(
|
|
1060
|
-
this._scene.XRRoot.XRModelRoot.children
|
|
1061
|
-
);
|
|
1062
|
-
if (intersections.length === 0) return [];
|
|
1063
|
-
return intersections.map((intersection) => {
|
|
1064
|
-
return {
|
|
1065
|
-
point: intersection.point,
|
|
1066
|
-
matrix: intersection.object.matrixWorld,
|
|
1067
|
-
object: intersection.object
|
|
1068
|
-
};
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
};
|
|
1072
|
-
}
|
|
1073
|
-
});
|
|
1074
|
-
|
|
1075
|
-
// src/events/EventExecutor.ts
|
|
1076
|
-
var DIVEEventExecutor;
|
|
1077
|
-
var init_EventExecutor = __esm({
|
|
1078
|
-
"src/events/EventExecutor.ts"() {
|
|
1079
|
-
"use strict";
|
|
1080
|
-
DIVEEventExecutor = class {
|
|
1081
|
-
constructor() {
|
|
1082
|
-
this._listeners = /* @__PURE__ */ new Map();
|
|
1083
|
-
}
|
|
1084
|
-
Subscribe(type, listener) {
|
|
1085
|
-
if (!this._listeners.get(type)) this._listeners.set(type, []);
|
|
1086
|
-
this._listeners.get(type).push(listener);
|
|
1087
|
-
return () => {
|
|
1088
|
-
const listenerArray = this._listeners.get(type);
|
|
1089
|
-
if (!listenerArray) return false;
|
|
1090
|
-
const existingIndex = listenerArray.findIndex(
|
|
1091
|
-
(entry) => entry === listener
|
|
1092
|
-
);
|
|
1093
|
-
if (existingIndex === -1) return false;
|
|
1094
|
-
listenerArray.splice(existingIndex, 1);
|
|
1095
|
-
return true;
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
dispatch(type, payload) {
|
|
1099
|
-
const listenerArray = this._listeners.get(type);
|
|
1100
|
-
if (!listenerArray) return;
|
|
1101
|
-
listenerArray.forEach((listener) => listener(payload));
|
|
1102
|
-
}
|
|
1103
|
-
};
|
|
1104
|
-
}
|
|
1105
|
-
});
|
|
1106
|
-
|
|
1107
|
-
// src/ar/webxr/raycaster/WebXRRaycaster.ts
|
|
1108
|
-
var DIVEWebXRRaycaster;
|
|
1109
|
-
var init_WebXRRaycaster = __esm({
|
|
1110
|
-
"src/ar/webxr/raycaster/WebXRRaycaster.ts"() {
|
|
1111
|
-
"use strict";
|
|
1112
|
-
init_WebXRRaycasterAR();
|
|
1113
|
-
init_WebXRRaycasterTHREE();
|
|
1114
|
-
init_EventExecutor();
|
|
1115
|
-
DIVEWebXRRaycaster = class extends DIVEEventExecutor {
|
|
1116
|
-
constructor(session, renderer, scene) {
|
|
1117
|
-
super();
|
|
1118
|
-
this._initialized = false;
|
|
1119
|
-
this._arHitResultBuffer = [];
|
|
1120
|
-
this._sceneHitResultBuffer = [];
|
|
1121
|
-
// buffers
|
|
1122
|
-
this._hasHit = false;
|
|
1123
|
-
this._session = session;
|
|
1124
|
-
this._threeRaycaster = new DIVEWebXRRaycasterTHREE(renderer, scene);
|
|
1125
|
-
this._arRaycaster = new DIVEWebXRRaycasterAR(session, renderer);
|
|
1126
|
-
}
|
|
1127
|
-
Dispose() {
|
|
1128
|
-
this._initialized = false;
|
|
1129
|
-
}
|
|
1130
|
-
Init() {
|
|
1131
|
-
return __async(this, null, function* () {
|
|
1132
|
-
if (!this._session) {
|
|
1133
|
-
console.error(
|
|
1134
|
-
"DIVEWebXRRaycaster: No session set in Init()! Aborting initialization..."
|
|
1135
|
-
);
|
|
1136
|
-
return Promise.reject();
|
|
1137
|
-
}
|
|
1138
|
-
if (this._initialized) {
|
|
1139
|
-
console.error(
|
|
1140
|
-
"DIVEWebXRRaycaster: Already initialized! Aborting initialization..."
|
|
1141
|
-
);
|
|
1142
|
-
return Promise.reject();
|
|
1143
|
-
}
|
|
1144
|
-
yield this._threeRaycaster.Init();
|
|
1145
|
-
yield this._arRaycaster.Init();
|
|
1146
|
-
console.log("DIVEWebXRRaycaster: Initialized");
|
|
1147
|
-
this._initialized = true;
|
|
1148
|
-
return Promise.resolve(this);
|
|
1149
|
-
});
|
|
1150
|
-
}
|
|
1151
|
-
GetARIntersections(frame) {
|
|
1152
|
-
this._arHitResultBuffer = this._arRaycaster.GetIntersections(frame);
|
|
1153
|
-
if (this._arHitResultBuffer.length > 0) {
|
|
1154
|
-
this.onARHitFound(this._arHitResultBuffer[0]);
|
|
1155
|
-
} else {
|
|
1156
|
-
this.onARHitLost();
|
|
1157
|
-
}
|
|
1158
|
-
return this._arHitResultBuffer;
|
|
1159
|
-
}
|
|
1160
|
-
GetSceneIntersections() {
|
|
1161
|
-
this._sceneHitResultBuffer = this._threeRaycaster.GetIntersections();
|
|
1162
|
-
if (this._sceneHitResultBuffer.length > 0) {
|
|
1163
|
-
this.onSceneHitFound(this._sceneHitResultBuffer[0]);
|
|
1164
|
-
} else {
|
|
1165
|
-
this.onSceneHitLost();
|
|
1166
|
-
}
|
|
1167
|
-
return this._sceneHitResultBuffer;
|
|
1168
|
-
}
|
|
1169
|
-
onARHitFound(hit) {
|
|
1170
|
-
this._hasHit = true;
|
|
1171
|
-
this.dispatch("AR_HIT_FOUND", { hit });
|
|
1172
|
-
}
|
|
1173
|
-
onARHitLost() {
|
|
1174
|
-
if (!this._hasHit) return;
|
|
1175
|
-
this._hasHit = false;
|
|
1176
|
-
this.dispatch("AR_HIT_LOST");
|
|
1177
|
-
}
|
|
1178
|
-
onSceneHitFound(hit) {
|
|
1179
|
-
this._hasHit = true;
|
|
1180
|
-
this.dispatch("SCENE_HIT_FOUND", { hit });
|
|
1181
|
-
}
|
|
1182
|
-
onSceneHitLost() {
|
|
1183
|
-
if (!this._hasHit) return;
|
|
1184
|
-
this._hasHit = false;
|
|
1185
|
-
this.dispatch("SCENE_HIT_LOST");
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
|
-
});
|
|
1190
|
-
|
|
1191
|
-
// src/ar/webxr/origin/WebXROrigin.ts
|
|
1192
|
-
import { Matrix4 as Matrix42, Quaternion, Vector3 as Vector33 } from "three";
|
|
1193
|
-
var DIVEWebXROrigin;
|
|
1194
|
-
var init_WebXROrigin = __esm({
|
|
1195
|
-
"src/ar/webxr/origin/WebXROrigin.ts"() {
|
|
1196
|
-
"use strict";
|
|
1197
|
-
DIVEWebXROrigin = class {
|
|
1198
|
-
constructor(session, renderer, entityTypes) {
|
|
1199
|
-
this._raycastHitCounter = 0;
|
|
1200
|
-
this._originSetResolve = () => {
|
|
1201
|
-
};
|
|
1202
|
-
this._renderer = renderer;
|
|
1203
|
-
this._session = session;
|
|
1204
|
-
this._originSet = new Promise((resolve) => {
|
|
1205
|
-
this._originSetResolve = resolve;
|
|
1206
|
-
});
|
|
1207
|
-
this._requesting = false;
|
|
1208
|
-
this._initialized = false;
|
|
1209
|
-
this._referenceSpaceBuffer = null;
|
|
1210
|
-
this._hitTestSource = null;
|
|
1211
|
-
this._entityTypes = entityTypes || ["plane"];
|
|
1212
|
-
this._hitTestResultBuffer = [];
|
|
1213
|
-
this._matrix = new Matrix42();
|
|
1214
|
-
this._position = new Vector33();
|
|
1215
|
-
this._quaternion = new Quaternion();
|
|
1216
|
-
this._scale = new Vector33();
|
|
1217
|
-
this._originSet.then(() => {
|
|
1218
|
-
this._matrix.decompose(
|
|
1219
|
-
this._position,
|
|
1220
|
-
this._quaternion,
|
|
1221
|
-
this._scale
|
|
1222
|
-
);
|
|
1223
|
-
});
|
|
1224
|
-
}
|
|
1225
|
-
get originSet() {
|
|
1226
|
-
return this._originSet;
|
|
1227
|
-
}
|
|
1228
|
-
get matrix() {
|
|
1229
|
-
return this._matrix;
|
|
1230
|
-
}
|
|
1231
|
-
set matrix(value) {
|
|
1232
|
-
this._matrix = value;
|
|
1233
|
-
this._matrix.decompose(this._position, this._quaternion, this._scale);
|
|
1234
|
-
}
|
|
1235
|
-
get position() {
|
|
1236
|
-
return this._position;
|
|
1237
|
-
}
|
|
1238
|
-
get quaternion() {
|
|
1239
|
-
return this._quaternion;
|
|
1240
|
-
}
|
|
1241
|
-
get scale() {
|
|
1242
|
-
return this._scale;
|
|
1243
|
-
}
|
|
1244
|
-
Init() {
|
|
1245
|
-
return __async(this, null, function* () {
|
|
1246
|
-
if (this._initialized) {
|
|
1247
|
-
return Promise.resolve(this);
|
|
1248
|
-
}
|
|
1249
|
-
if (!this._session) {
|
|
1250
|
-
console.error(
|
|
1251
|
-
"DIVEWebXROrigin: No session set in Init()! Aborting initialization..."
|
|
1252
|
-
);
|
|
1253
|
-
return Promise.reject();
|
|
1254
|
-
}
|
|
1255
|
-
if (this._requesting) {
|
|
1256
|
-
console.error(
|
|
1257
|
-
"DIVEWebXROrigin: Currently initializing! Aborting initialization..."
|
|
1258
|
-
);
|
|
1259
|
-
return Promise.reject();
|
|
1260
|
-
}
|
|
1261
|
-
this._requesting = true;
|
|
1262
|
-
const referenceSpace = yield this._session.requestReferenceSpace("viewer");
|
|
1263
|
-
this._hitTestSource = (yield this._session.requestHitTestSource({
|
|
1264
|
-
space: referenceSpace,
|
|
1265
|
-
entityTypes: this._entityTypes
|
|
1266
|
-
})) || null;
|
|
1267
|
-
this._requesting = false;
|
|
1268
|
-
if (!this._hitTestSource) {
|
|
1269
|
-
return Promise.reject();
|
|
1270
|
-
}
|
|
1271
|
-
this._initialized = true;
|
|
1272
|
-
return Promise.resolve(this);
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
Dispose() {
|
|
1276
|
-
var _a;
|
|
1277
|
-
this._initialized = false;
|
|
1278
|
-
this._requesting = false;
|
|
1279
|
-
(_a = this._hitTestSource) == null ? void 0 : _a.cancel();
|
|
1280
|
-
this._hitTestSource = null;
|
|
1281
|
-
this._hitTestResultBuffer = [];
|
|
1282
|
-
this._matrix = new Matrix42();
|
|
1283
|
-
this._position = new Vector33();
|
|
1284
|
-
this._quaternion = new Quaternion();
|
|
1285
|
-
this._scale = new Vector33();
|
|
1286
|
-
}
|
|
1287
|
-
Update(frame) {
|
|
1288
|
-
if (!this._initialized) return;
|
|
1289
|
-
if (!this._hitTestSource) {
|
|
1290
|
-
throw new Error(
|
|
1291
|
-
"DIVEWebXRRaycaster: Critical Error: HitTestSource not available but WebXROrigin is initialized!"
|
|
1292
|
-
);
|
|
1293
|
-
}
|
|
1294
|
-
this._hitTestResultBuffer = frame.getHitTestResults(
|
|
1295
|
-
this._hitTestSource
|
|
1296
|
-
);
|
|
1297
|
-
if (this._hitTestResultBuffer.length > 0) {
|
|
1298
|
-
this._referenceSpaceBuffer = this._renderer.xr.getReferenceSpace();
|
|
1299
|
-
if (!this._referenceSpaceBuffer) {
|
|
1300
|
-
this.onHitLost();
|
|
1301
|
-
return;
|
|
1302
|
-
}
|
|
1303
|
-
const pose = this._hitTestResultBuffer[0].getPose(
|
|
1304
|
-
this._referenceSpaceBuffer
|
|
1305
|
-
);
|
|
1306
|
-
if (!pose) {
|
|
1307
|
-
this.onHitLost();
|
|
1308
|
-
return;
|
|
1309
|
-
}
|
|
1310
|
-
this.onHitFound(pose);
|
|
1311
|
-
} else {
|
|
1312
|
-
this.onHitLost();
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
onHitFound(pose) {
|
|
1316
|
-
this._raycastHitCounter++;
|
|
1317
|
-
this.matrix.fromArray(pose.transform.matrix);
|
|
1318
|
-
if (this._raycastHitCounter > 50) {
|
|
1319
|
-
this._originSetResolve();
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
onHitLost() {
|
|
1323
|
-
this._raycastHitCounter = 0;
|
|
1324
|
-
}
|
|
1325
|
-
};
|
|
1326
|
-
}
|
|
1327
|
-
});
|
|
1328
|
-
|
|
1329
|
-
// src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts
|
|
1330
|
-
import { Vector2 as Vector22 } from "three";
|
|
1331
|
-
var DIVEWebXRTouchscreenControls;
|
|
1332
|
-
var init_WebXRTouchscreenControls = __esm({
|
|
1333
|
-
"src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts"() {
|
|
1334
|
-
"use strict";
|
|
1335
|
-
init_EventExecutor();
|
|
1336
|
-
DIVEWebXRTouchscreenControls = class extends DIVEEventExecutor {
|
|
1337
|
-
constructor(session) {
|
|
1338
|
-
super();
|
|
1339
|
-
// touch members
|
|
1340
|
-
this._touchCount = 0;
|
|
1341
|
-
this._touches = [];
|
|
1342
|
-
// rotate members
|
|
1343
|
-
this._handleRotateStarted = false;
|
|
1344
|
-
this._handleRotateMoved = false;
|
|
1345
|
-
this._handleRotateEnded = false;
|
|
1346
|
-
this._startAngle = 0;
|
|
1347
|
-
this._lastAngle = 0;
|
|
1348
|
-
this._angleDelta = 0;
|
|
1349
|
-
// scale members
|
|
1350
|
-
this._handlePinchStarted = false;
|
|
1351
|
-
this._handlePinchMoved = false;
|
|
1352
|
-
this._handlePinchEnded = false;
|
|
1353
|
-
this._scaleDistanceStart = 0;
|
|
1354
|
-
this._currentDistance = 1;
|
|
1355
|
-
this._deltaDistance = 0;
|
|
1356
|
-
this._session = session;
|
|
1357
|
-
this._touches = [
|
|
1358
|
-
{
|
|
1359
|
-
start: new Vector22(),
|
|
1360
|
-
current: new Vector22(),
|
|
1361
|
-
delta: new Vector22()
|
|
1362
|
-
},
|
|
1363
|
-
{
|
|
1364
|
-
start: new Vector22(),
|
|
1365
|
-
current: new Vector22(),
|
|
1366
|
-
delta: new Vector22()
|
|
1367
|
-
}
|
|
1368
|
-
];
|
|
1369
|
-
this._handleRotateStarted = false;
|
|
1370
|
-
window.addEventListener(
|
|
1371
|
-
"touchstart",
|
|
1372
|
-
(e) => this.onTouchStart(e)
|
|
1373
|
-
);
|
|
1374
|
-
window.addEventListener(
|
|
1375
|
-
"touchmove",
|
|
1376
|
-
(e) => this.onTouchMove(e)
|
|
1377
|
-
);
|
|
1378
|
-
window.addEventListener(
|
|
1379
|
-
"touchend",
|
|
1380
|
-
(e) => this.onTouchEnd(e)
|
|
1381
|
-
);
|
|
1382
|
-
this._session.addEventListener(
|
|
1383
|
-
"selectstart",
|
|
1384
|
-
() => this.onSessionSelectStart()
|
|
1385
|
-
);
|
|
1386
|
-
this._session.addEventListener(
|
|
1387
|
-
"selectend",
|
|
1388
|
-
() => this.onSessionSelectEnd()
|
|
1389
|
-
);
|
|
1390
|
-
}
|
|
1391
|
-
Dispose() {
|
|
1392
|
-
window.removeEventListener(
|
|
1393
|
-
"touchstart",
|
|
1394
|
-
(e) => this.onTouchStart(e)
|
|
1395
|
-
);
|
|
1396
|
-
window.removeEventListener(
|
|
1397
|
-
"touchmove",
|
|
1398
|
-
(e) => this.onTouchMove(e)
|
|
1399
|
-
);
|
|
1400
|
-
window.removeEventListener(
|
|
1401
|
-
"touchend",
|
|
1402
|
-
(e) => this.onTouchEnd(e)
|
|
1403
|
-
);
|
|
1404
|
-
this._session.removeEventListener(
|
|
1405
|
-
"selectstart",
|
|
1406
|
-
() => this.onSessionSelectStart()
|
|
1407
|
-
);
|
|
1408
|
-
this._session.removeEventListener(
|
|
1409
|
-
"selectend",
|
|
1410
|
-
() => this.onSessionSelectEnd()
|
|
1411
|
-
);
|
|
1412
|
-
}
|
|
1413
|
-
onTouchStart(event) {
|
|
1414
|
-
this._touchCount = event.touches.length;
|
|
1415
|
-
this._touches[0].start.set(
|
|
1416
|
-
event.touches[0].clientX,
|
|
1417
|
-
event.touches[0].clientY
|
|
1418
|
-
);
|
|
1419
|
-
this._touches[0].current.set(
|
|
1420
|
-
event.touches[0].clientX,
|
|
1421
|
-
event.touches[0].clientY
|
|
1422
|
-
);
|
|
1423
|
-
this._touches[0].delta.set(0, 0);
|
|
1424
|
-
if (this._touchCount > 1) {
|
|
1425
|
-
this._touches[1].start.set(
|
|
1426
|
-
event.touches[1].clientX,
|
|
1427
|
-
event.touches[1].clientY
|
|
1428
|
-
);
|
|
1429
|
-
this._touches[1].current.set(
|
|
1430
|
-
event.touches[1].clientX,
|
|
1431
|
-
event.touches[1].clientY
|
|
1432
|
-
);
|
|
1433
|
-
this._touches[1].delta.set(0, 0);
|
|
1434
|
-
}
|
|
1435
|
-
if (this._touchCount === 2) {
|
|
1436
|
-
this.handleRotateStart();
|
|
1437
|
-
this.handlePinchStart();
|
|
1438
|
-
}
|
|
1439
|
-
if (this._handleRotateStarted) {
|
|
1440
|
-
this.dispatch("ROTATE_START", {
|
|
1441
|
-
current: 0
|
|
1442
|
-
});
|
|
1443
|
-
this._handleRotateStarted = false;
|
|
1444
|
-
}
|
|
1445
|
-
if (this._handlePinchStarted) {
|
|
1446
|
-
this.dispatch("PINCH_START", {
|
|
1447
|
-
current: 0
|
|
1448
|
-
});
|
|
1449
|
-
this._handlePinchStarted = false;
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
onTouchMove(event) {
|
|
1453
|
-
this._touchCount = event.touches.length;
|
|
1454
|
-
this._touches[0].start.set(
|
|
1455
|
-
event.touches[0].clientX,
|
|
1456
|
-
event.touches[0].clientY
|
|
1457
|
-
);
|
|
1458
|
-
this._touches[0].current.set(
|
|
1459
|
-
event.touches[0].clientX,
|
|
1460
|
-
event.touches[0].clientY
|
|
1461
|
-
);
|
|
1462
|
-
this._touches[0].delta.copy(
|
|
1463
|
-
this._touches[0].current.clone().sub(this._touches[0].start)
|
|
1464
|
-
);
|
|
1465
|
-
if (this._touchCount > 1) {
|
|
1466
|
-
this._touches[1].start.set(
|
|
1467
|
-
event.touches[1].clientX,
|
|
1468
|
-
event.touches[1].clientY
|
|
1469
|
-
);
|
|
1470
|
-
this._touches[1].current.set(
|
|
1471
|
-
event.touches[1].clientX,
|
|
1472
|
-
event.touches[1].clientY
|
|
1473
|
-
);
|
|
1474
|
-
this._touches[1].delta.copy(
|
|
1475
|
-
this._touches[1].current.clone().sub(this._touches[1].start)
|
|
1476
|
-
);
|
|
1477
|
-
}
|
|
1478
|
-
if (this._touchCount === 2) {
|
|
1479
|
-
this.handleRotateMoved();
|
|
1480
|
-
this.handlePinchMoved();
|
|
1481
|
-
}
|
|
1482
|
-
if (this._touchCount === 1) {
|
|
1483
|
-
this.dispatch("TOUCH_MOVE", {
|
|
1484
|
-
touches: [
|
|
1485
|
-
{
|
|
1486
|
-
current: this._touches[0].current.clone(),
|
|
1487
|
-
delta: this._touches[0].delta.clone()
|
|
1488
|
-
},
|
|
1489
|
-
{
|
|
1490
|
-
current: this._touches[1].current.clone(),
|
|
1491
|
-
delta: this._touches[1].delta.clone()
|
|
1492
|
-
}
|
|
1493
|
-
],
|
|
1494
|
-
touchCount: this._touchCount
|
|
1495
|
-
});
|
|
1496
|
-
}
|
|
1497
|
-
if (this._touchCount === 2) {
|
|
1498
|
-
if (this._handleRotateMoved) {
|
|
1499
|
-
this.dispatch("ROTATE_MOVE", {
|
|
1500
|
-
current: this._lastAngle,
|
|
1501
|
-
delta: this._angleDelta
|
|
1502
|
-
});
|
|
1503
|
-
this._handleRotateMoved = false;
|
|
1504
|
-
}
|
|
1505
|
-
if (this._handlePinchMoved) {
|
|
1506
|
-
this.dispatch("PINCH_MOVE", {
|
|
1507
|
-
current: this._currentDistance,
|
|
1508
|
-
delta: this._deltaDistance
|
|
1509
|
-
});
|
|
1510
|
-
this._handlePinchMoved = false;
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
onTouchEnd(event) {
|
|
1515
|
-
this._touchCount = event.touches.length;
|
|
1516
|
-
if (this._touchCount === 0) {
|
|
1517
|
-
this._touches[0].start.set(0, 0);
|
|
1518
|
-
this._touches[0].current.set(0, 0);
|
|
1519
|
-
this._touches[0].delta.set(0, 0);
|
|
1520
|
-
}
|
|
1521
|
-
if (this._touchCount === 1) {
|
|
1522
|
-
this.handleRotateEnded();
|
|
1523
|
-
this.handlePinchEnded();
|
|
1524
|
-
this._touches[1].start.set(0, 0);
|
|
1525
|
-
this._touches[1].current.set(0, 0);
|
|
1526
|
-
this._touches[1].delta.set(0, 0);
|
|
1527
|
-
}
|
|
1528
|
-
if (this._handleRotateEnded) {
|
|
1529
|
-
this.dispatch("ROTATE_END", {
|
|
1530
|
-
current: this._lastAngle
|
|
1531
|
-
});
|
|
1532
|
-
this._handleRotateEnded = false;
|
|
1533
|
-
}
|
|
1534
|
-
if (this._handlePinchEnded) {
|
|
1535
|
-
this.dispatch("PINCH_END", {
|
|
1536
|
-
current: this._currentDistance
|
|
1537
|
-
});
|
|
1538
|
-
this._handlePinchEnded = false;
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
onSessionSelectStart() {
|
|
1542
|
-
this.dispatch("TOUCH_START", {
|
|
1543
|
-
touches: [
|
|
1544
|
-
{
|
|
1545
|
-
current: this._touches[0].current.clone()
|
|
1546
|
-
},
|
|
1547
|
-
{
|
|
1548
|
-
current: this._touches[1].current.clone()
|
|
1549
|
-
}
|
|
1550
|
-
],
|
|
1551
|
-
touchCount: this._touchCount
|
|
1552
|
-
});
|
|
1553
|
-
}
|
|
1554
|
-
onSessionSelectEnd() {
|
|
1555
|
-
this.dispatch("TOUCH_END", {
|
|
1556
|
-
touches: [
|
|
1557
|
-
{
|
|
1558
|
-
current: this._touches[0].current.clone()
|
|
1559
|
-
},
|
|
1560
|
-
{
|
|
1561
|
-
current: this._touches[1].current.clone()
|
|
1562
|
-
}
|
|
1563
|
-
],
|
|
1564
|
-
touchCount: this._touchCount
|
|
1565
|
-
});
|
|
1566
|
-
}
|
|
1567
|
-
// rotation handler
|
|
1568
|
-
handleRotateStart() {
|
|
1569
|
-
this._handleRotateStarted = true;
|
|
1570
|
-
this._startAngle = this._touches[1].start.clone().sub(this._touches[0].current).angle();
|
|
1571
|
-
}
|
|
1572
|
-
handleRotateMoved() {
|
|
1573
|
-
this._handleRotateMoved = true;
|
|
1574
|
-
const currentAngle = this._touches[1].current.clone().sub(this._touches[0].current).angle();
|
|
1575
|
-
this._angleDelta = currentAngle - this._startAngle;
|
|
1576
|
-
this._lastAngle = this._angleDelta * -1;
|
|
1577
|
-
}
|
|
1578
|
-
handleRotateEnded() {
|
|
1579
|
-
this._handleRotateEnded = true;
|
|
1580
|
-
}
|
|
1581
|
-
// pinch handler
|
|
1582
|
-
handlePinchStart() {
|
|
1583
|
-
this._handlePinchStarted = true;
|
|
1584
|
-
this._scaleDistanceStart = this._touches[1].start.distanceTo(
|
|
1585
|
-
this._touches[0].current
|
|
1586
|
-
);
|
|
1587
|
-
}
|
|
1588
|
-
handlePinchMoved() {
|
|
1589
|
-
this._handlePinchMoved = true;
|
|
1590
|
-
const beforeDistance = this._currentDistance;
|
|
1591
|
-
const distance = this._touches[1].current.distanceTo(
|
|
1592
|
-
this._touches[0].current
|
|
1593
|
-
);
|
|
1594
|
-
this._currentDistance = distance / this._scaleDistanceStart;
|
|
1595
|
-
this._deltaDistance = this._currentDistance - beforeDistance;
|
|
1596
|
-
}
|
|
1597
|
-
handlePinchEnded() {
|
|
1598
|
-
this._handlePinchEnded = true;
|
|
1599
|
-
}
|
|
1600
|
-
};
|
|
1601
|
-
}
|
|
1602
|
-
});
|
|
1603
|
-
|
|
1604
|
-
// src/ar/webxr/controller/WebXRController.ts
|
|
1605
|
-
import {
|
|
1606
|
-
Mesh as Mesh2,
|
|
1607
|
-
Object3D as Object3D4,
|
|
1608
|
-
Quaternion as Quaternion2,
|
|
1609
|
-
Vector3 as Vector34
|
|
1610
|
-
} from "three";
|
|
1611
|
-
var DIVEWebXRController;
|
|
1612
|
-
var init_WebXRController = __esm({
|
|
1613
|
-
"src/ar/webxr/controller/WebXRController.ts"() {
|
|
1614
|
-
"use strict";
|
|
1615
|
-
init_WebXRCrosshair();
|
|
1616
|
-
init_WebXRRaycaster();
|
|
1617
|
-
init_WebXROrigin();
|
|
1618
|
-
init_WebXRTouchscreenControls();
|
|
1619
|
-
init_findInterface();
|
|
1620
|
-
DIVEWebXRController = class extends Object3D4 {
|
|
1621
|
-
constructor(session, renderer, scene) {
|
|
1622
|
-
super();
|
|
1623
|
-
this._frameBuffer = null;
|
|
1624
|
-
this._handNodeInitialPosition = new Vector34();
|
|
1625
|
-
this._placed = false;
|
|
1626
|
-
// grabbing
|
|
1627
|
-
this._grabbedObject = null;
|
|
1628
|
-
this._arHitPosition = new Vector34();
|
|
1629
|
-
this._arHitQuaternion = new Quaternion2();
|
|
1630
|
-
this._arHitScale = new Vector34(1, 1, 1);
|
|
1631
|
-
// grabbing position
|
|
1632
|
-
this._initialObjectPosition = null;
|
|
1633
|
-
this._initialRaycastHit = null;
|
|
1634
|
-
this._deltaRaycastHit = new Vector34();
|
|
1635
|
-
// grabbing rotation
|
|
1636
|
-
this._touchQuaterion = new Quaternion2();
|
|
1637
|
-
// grabbing scale
|
|
1638
|
-
this._touchScale = 1;
|
|
1639
|
-
this._scaleThreshold = 0.1;
|
|
1640
|
-
this._startTouchQuaternion = new Quaternion2();
|
|
1641
|
-
this._startTouchScale = 1;
|
|
1642
|
-
this._renderer = renderer;
|
|
1643
|
-
this._scene = scene;
|
|
1644
|
-
this._session = session;
|
|
1645
|
-
this._xrRaycaster = new DIVEWebXRRaycaster(session, renderer, scene);
|
|
1646
|
-
this._origin = new DIVEWebXROrigin(this._session, this._renderer, [
|
|
1647
|
-
"plane"
|
|
1648
|
-
]);
|
|
1649
|
-
this._crosshair = new DIVEWebXRCrosshair();
|
|
1650
|
-
this._crosshair.visible = false;
|
|
1651
|
-
this._xrCamera = this._renderer.xr.getCamera();
|
|
1652
|
-
this._scene.XRRoot.XRHandNode.position.set(0, -0.05, -0.25);
|
|
1653
|
-
this._handNodeInitialPosition = this._scene.XRRoot.XRHandNode.position.clone();
|
|
1654
|
-
this._touchscreenControls = new DIVEWebXRTouchscreenControls(
|
|
1655
|
-
this._session
|
|
1656
|
-
);
|
|
1657
|
-
this._touchscreenControls.Subscribe(
|
|
1658
|
-
"TOUCH_START",
|
|
1659
|
-
() => this.onTouchStart()
|
|
1660
|
-
);
|
|
1661
|
-
this._touchscreenControls.Subscribe(
|
|
1662
|
-
"TOUCH_MOVE",
|
|
1663
|
-
() => this.onTouchMove()
|
|
1664
|
-
);
|
|
1665
|
-
this._touchscreenControls.Subscribe(
|
|
1666
|
-
"TOUCH_END",
|
|
1667
|
-
(p) => this.onTouchEnd(p)
|
|
1668
|
-
);
|
|
1669
|
-
this._touchscreenControls.Subscribe(
|
|
1670
|
-
"ROTATE_START",
|
|
1671
|
-
() => this.onRotateStart()
|
|
1672
|
-
);
|
|
1673
|
-
this._touchscreenControls.Subscribe(
|
|
1674
|
-
"ROTATE_MOVE",
|
|
1675
|
-
(p) => this.onRotateMove(p)
|
|
1676
|
-
);
|
|
1677
|
-
this._touchscreenControls.Subscribe(
|
|
1678
|
-
"PINCH_START",
|
|
1679
|
-
() => this.onPinchStart()
|
|
1680
|
-
);
|
|
1681
|
-
this._touchscreenControls.Subscribe(
|
|
1682
|
-
"PINCH_MOVE",
|
|
1683
|
-
(p) => this.onPinchMove(p)
|
|
1684
|
-
);
|
|
1685
|
-
}
|
|
1686
|
-
Init() {
|
|
1687
|
-
return __async(this, null, function* () {
|
|
1688
|
-
this.prepareScene();
|
|
1689
|
-
yield this.initOrigin();
|
|
1690
|
-
yield this.initRaycaster();
|
|
1691
|
-
return Promise.resolve(this);
|
|
1692
|
-
});
|
|
1693
|
-
}
|
|
1694
|
-
Dispose() {
|
|
1695
|
-
this.restoreScene();
|
|
1696
|
-
this._origin.Dispose();
|
|
1697
|
-
this._xrRaycaster.Dispose();
|
|
1698
|
-
this._placed = false;
|
|
1699
|
-
}
|
|
1700
|
-
Update(frame) {
|
|
1701
|
-
this._frameBuffer = frame;
|
|
1702
|
-
if (!this._placed) {
|
|
1703
|
-
this.updateHandNode();
|
|
1704
|
-
if (this._origin) {
|
|
1705
|
-
this._origin.Update(frame);
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
updateHandNode() {
|
|
1710
|
-
this._xrCamera.updateMatrixWorld();
|
|
1711
|
-
this._scene.XRRoot.XRHandNode.position.copy(
|
|
1712
|
-
this._handNodeInitialPosition.clone().applyMatrix4(this._xrCamera.matrixWorld)
|
|
1713
|
-
);
|
|
1714
|
-
this._scene.XRRoot.XRHandNode.quaternion.setFromRotationMatrix(
|
|
1715
|
-
this._xrCamera.matrixWorld
|
|
1716
|
-
);
|
|
1717
|
-
}
|
|
1718
|
-
// placement
|
|
1719
|
-
initOrigin() {
|
|
1720
|
-
return __async(this, null, function* () {
|
|
1721
|
-
this._origin = yield this._origin.Init();
|
|
1722
|
-
this._origin.originSet.then(() => {
|
|
1723
|
-
this.placeObjects(this._origin.matrix);
|
|
1724
|
-
});
|
|
1725
|
-
});
|
|
1726
|
-
}
|
|
1727
|
-
placeObjects(matrix) {
|
|
1728
|
-
this._scene.XRRoot.XRModelRoot.matrix.copy(matrix);
|
|
1729
|
-
[...this._scene.XRRoot.XRHandNode.children].forEach((child) => {
|
|
1730
|
-
this._scene.XRRoot.XRModelRoot.add(child);
|
|
1731
|
-
});
|
|
1732
|
-
this._placed = true;
|
|
1733
|
-
}
|
|
1734
|
-
// grabbing
|
|
1735
|
-
updateObject() {
|
|
1736
|
-
if (!this._grabbedObject) return;
|
|
1737
|
-
this._grabbedObject.position.copy(this._arHitPosition);
|
|
1738
|
-
this._grabbedObject.quaternion.copy(
|
|
1739
|
-
this._arHitQuaternion.clone().multiply(this._touchQuaterion)
|
|
1740
|
-
);
|
|
1741
|
-
this._grabbedObject.scale.copy(
|
|
1742
|
-
new Vector34(
|
|
1743
|
-
this._touchScale,
|
|
1744
|
-
this._touchScale,
|
|
1745
|
-
this._touchScale
|
|
1746
|
-
).multiply(this._arHitScale)
|
|
1747
|
-
);
|
|
1748
|
-
}
|
|
1749
|
-
onTouchStart() {
|
|
1750
|
-
const sceneHits = this._xrRaycaster.GetSceneIntersections();
|
|
1751
|
-
console.log("sceneHits", sceneHits);
|
|
1752
|
-
if (sceneHits.length === 0) return;
|
|
1753
|
-
if (!sceneHits[0].object) return;
|
|
1754
|
-
const moveable = findInterface(
|
|
1755
|
-
sceneHits[0].object,
|
|
1756
|
-
"isMovable"
|
|
1757
|
-
);
|
|
1758
|
-
if (!moveable) return;
|
|
1759
|
-
this._grabbedObject = moveable;
|
|
1760
|
-
}
|
|
1761
|
-
onTouchMove() {
|
|
1762
|
-
if (!this._frameBuffer) return;
|
|
1763
|
-
if (!this._grabbedObject) return;
|
|
1764
|
-
const intersections = this._xrRaycaster.GetARIntersections(
|
|
1765
|
-
this._frameBuffer
|
|
1766
|
-
);
|
|
1767
|
-
if (intersections.length === 0) {
|
|
1768
|
-
this._crosshair.visible = false;
|
|
1769
|
-
return;
|
|
1770
|
-
}
|
|
1771
|
-
const hit = intersections[0];
|
|
1772
|
-
this._crosshair.visible = true;
|
|
1773
|
-
this._crosshair.matrix.copy(hit.matrix);
|
|
1774
|
-
if (!this._grabbedObject) return;
|
|
1775
|
-
if (!this._initialObjectPosition || !this._initialRaycastHit) {
|
|
1776
|
-
this._initialObjectPosition = this._grabbedObject.position.clone();
|
|
1777
|
-
this._initialRaycastHit = hit.point.clone();
|
|
1778
|
-
}
|
|
1779
|
-
hit.matrix.decompose(
|
|
1780
|
-
this._arHitPosition,
|
|
1781
|
-
this._arHitQuaternion,
|
|
1782
|
-
this._arHitScale
|
|
1783
|
-
);
|
|
1784
|
-
this._deltaRaycastHit.copy(
|
|
1785
|
-
hit.point.clone().sub(this._initialRaycastHit)
|
|
1786
|
-
);
|
|
1787
|
-
this._arHitPosition.copy(
|
|
1788
|
-
this._initialObjectPosition.clone().add(this._deltaRaycastHit)
|
|
1789
|
-
);
|
|
1790
|
-
console.log("arHitPosition", this._arHitPosition);
|
|
1791
|
-
this.updateObject();
|
|
1792
|
-
}
|
|
1793
|
-
onTouchEnd(payload) {
|
|
1794
|
-
if (payload.touchCount === 0) {
|
|
1795
|
-
this._crosshair.visible = false;
|
|
1796
|
-
this._initialObjectPosition = null;
|
|
1797
|
-
this._initialRaycastHit = null;
|
|
1798
|
-
this._grabbedObject = null;
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
onRotateStart() {
|
|
1802
|
-
this._startTouchQuaternion = this._touchQuaterion.clone();
|
|
1803
|
-
}
|
|
1804
|
-
onRotateMove(payload) {
|
|
1805
|
-
this._touchQuaterion.setFromAxisAngle(
|
|
1806
|
-
new Vector34(0, -1, 0),
|
|
1807
|
-
payload.delta * 3
|
|
1808
|
-
);
|
|
1809
|
-
this._touchQuaterion.multiply(this._startTouchQuaternion);
|
|
1810
|
-
this.updateObject();
|
|
1811
|
-
}
|
|
1812
|
-
onPinchStart() {
|
|
1813
|
-
this._startTouchScale = this._touchScale;
|
|
1814
|
-
}
|
|
1815
|
-
onPinchMove(payload) {
|
|
1816
|
-
this._touchScale = this._startTouchScale * payload.current;
|
|
1817
|
-
this.updateObject();
|
|
1818
|
-
}
|
|
1819
|
-
// prepare & cleanup scene
|
|
1820
|
-
prepareScene() {
|
|
1821
|
-
this._scene.XRRoot.XRModelRoot.matrixAutoUpdate = false;
|
|
1822
|
-
this._scene.add(this._crosshair);
|
|
1823
|
-
const children = [];
|
|
1824
|
-
this._scene.Root.children.forEach((child) => {
|
|
1825
|
-
const clone = child.clone();
|
|
1826
|
-
clone.layers.enableAll();
|
|
1827
|
-
clone.traverse((obj) => {
|
|
1828
|
-
obj.layers.enableAll();
|
|
1829
|
-
if (obj instanceof Mesh2) {
|
|
1830
|
-
obj.scale.set(0.1, 0.1, 0.1);
|
|
1831
|
-
}
|
|
1832
|
-
});
|
|
1833
|
-
clone.position.set(0, 0, 0);
|
|
1834
|
-
children.push(clone);
|
|
1835
|
-
});
|
|
1836
|
-
this._scene.XRRoot.XRHandNode.add(...children);
|
|
1837
|
-
}
|
|
1838
|
-
restoreScene() {
|
|
1839
|
-
this._scene.remove(this._crosshair);
|
|
1840
|
-
this._scene.XRRoot.XRHandNode.clear();
|
|
1841
|
-
this._scene.XRRoot.XRModelRoot.clear();
|
|
1842
|
-
this._scene.XRRoot.XRModelRoot.matrixAutoUpdate = true;
|
|
1843
|
-
}
|
|
1844
|
-
// raycast
|
|
1845
|
-
initRaycaster() {
|
|
1846
|
-
return __async(this, null, function* () {
|
|
1847
|
-
yield this._xrRaycaster.Init();
|
|
1848
|
-
if (!this._xrRaycaster) {
|
|
1849
|
-
console.error(
|
|
1850
|
-
"Raycaster not initialized successfully. Aborting WebXR..."
|
|
1851
|
-
);
|
|
1852
|
-
this.Dispose();
|
|
1853
|
-
return Promise.reject();
|
|
1854
|
-
}
|
|
1855
|
-
});
|
|
1856
|
-
}
|
|
1857
|
-
};
|
|
1858
|
-
}
|
|
1859
|
-
});
|
|
1860
|
-
|
|
1861
|
-
// src/ar/webxr/WebXR.ts
|
|
1862
|
-
var _DIVEWebXR, DIVEWebXR;
|
|
1863
|
-
var init_WebXR = __esm({
|
|
1864
|
-
"src/ar/webxr/WebXR.ts"() {
|
|
1865
|
-
"use strict";
|
|
1866
|
-
init_Overlay();
|
|
1867
|
-
init_WebXRController();
|
|
1868
|
-
_DIVEWebXR = class _DIVEWebXR {
|
|
1869
|
-
static Launch(renderer, scene, controller) {
|
|
1870
|
-
return __async(this, null, function* () {
|
|
1871
|
-
this._renderer = renderer;
|
|
1872
|
-
this._scene = scene;
|
|
1873
|
-
this._controller = controller;
|
|
1874
|
-
this._cameraPosition = this._controller.object.position.clone();
|
|
1875
|
-
this._cameraTarget = this._controller.target.clone();
|
|
1876
|
-
if (!navigator.xr) {
|
|
1877
|
-
console.error("WebXR not supported");
|
|
1878
|
-
return Promise.reject();
|
|
1879
|
-
}
|
|
1880
|
-
this._renderer.xr.enabled = true;
|
|
1881
|
-
this._scene.InitXR(renderer);
|
|
1882
|
-
if (!_DIVEWebXR._overlay) {
|
|
1883
|
-
const overlay = new Overlay();
|
|
1884
|
-
_DIVEWebXR._overlay = overlay;
|
|
1885
|
-
}
|
|
1886
|
-
_DIVEWebXR._options.domOverlay = { root: _DIVEWebXR._overlay.Element };
|
|
1887
|
-
const session = yield navigator.xr.requestSession(
|
|
1888
|
-
"immersive-ar",
|
|
1889
|
-
this._options
|
|
1890
|
-
);
|
|
1891
|
-
session.addEventListener("end", () => {
|
|
1892
|
-
this._onSessionEnded();
|
|
1893
|
-
});
|
|
1894
|
-
renderer.xr.setReferenceSpaceType(this._referenceSpaceType);
|
|
1895
|
-
yield renderer.xr.setSession(session);
|
|
1896
|
-
_DIVEWebXR._overlay.Element.style.display = "";
|
|
1897
|
-
this._session = session;
|
|
1898
|
-
_DIVEWebXR._overlay.CloseButton.addEventListener(
|
|
1899
|
-
"click",
|
|
1900
|
-
() => this.End()
|
|
1901
|
-
);
|
|
1902
|
-
yield this._onSessionStarted();
|
|
1903
|
-
return Promise.resolve();
|
|
1904
|
-
});
|
|
1905
|
-
}
|
|
1906
|
-
static Update(_time, frame) {
|
|
1907
|
-
if (!this._session) return;
|
|
1908
|
-
if (this._xrController) {
|
|
1909
|
-
this._xrController.Update(frame);
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
static End() {
|
|
1913
|
-
if (!this._session) return;
|
|
1914
|
-
this._session.end();
|
|
1915
|
-
}
|
|
1916
|
-
static _onSessionStarted() {
|
|
1917
|
-
return __async(this, null, function* () {
|
|
1918
|
-
if (!this._session) return;
|
|
1919
|
-
this._renderCallbackId = this._renderer.AddPreRenderCallback(
|
|
1920
|
-
(time, frame) => {
|
|
1921
|
-
this.Update(time, frame);
|
|
1922
|
-
}
|
|
1923
|
-
);
|
|
1924
|
-
this._xrController = new DIVEWebXRController(
|
|
1925
|
-
this._session,
|
|
1926
|
-
this._renderer,
|
|
1927
|
-
this._scene
|
|
1928
|
-
);
|
|
1929
|
-
yield this._xrController.Init().catch(() => {
|
|
1930
|
-
this.End();
|
|
1931
|
-
});
|
|
1932
|
-
return Promise.resolve();
|
|
1933
|
-
});
|
|
1934
|
-
}
|
|
1935
|
-
static _onSessionEnded() {
|
|
1936
|
-
if (!this._session) return;
|
|
1937
|
-
if (this._xrController) {
|
|
1938
|
-
this._xrController.Dispose();
|
|
1939
|
-
}
|
|
1940
|
-
if (this._renderCallbackId) {
|
|
1941
|
-
this._renderer.RemovePreRenderCallback(this._renderCallbackId);
|
|
1942
|
-
this._renderCallbackId = null;
|
|
1943
|
-
}
|
|
1944
|
-
this._renderer.xr.enabled = false;
|
|
1945
|
-
const canvasWrapper = this._renderer.domElement.parentElement;
|
|
1946
|
-
if (canvasWrapper) {
|
|
1947
|
-
const { clientWidth, clientHeight } = canvasWrapper;
|
|
1948
|
-
this._renderer.OnResize(clientWidth, clientHeight);
|
|
1949
|
-
this._controller.object.OnResize(clientWidth, clientHeight);
|
|
1950
|
-
}
|
|
1951
|
-
this._controller.object.position.copy(this._cameraPosition);
|
|
1952
|
-
this._controller.target.copy(this._cameraTarget);
|
|
1953
|
-
this._cameraPosition.set(0, 0, 0);
|
|
1954
|
-
this._cameraTarget.set(0, 0, 0);
|
|
1955
|
-
this._scene.DisposeXR();
|
|
1956
|
-
this._session.removeEventListener("end", this._onSessionEnded);
|
|
1957
|
-
_DIVEWebXR._overlay.Element.style.display = "none";
|
|
1958
|
-
this._session = null;
|
|
1959
|
-
}
|
|
1960
|
-
};
|
|
1961
|
-
// render loop members
|
|
1962
|
-
_DIVEWebXR._renderCallbackId = null;
|
|
1963
|
-
// setup members
|
|
1964
|
-
_DIVEWebXR._session = null;
|
|
1965
|
-
_DIVEWebXR._referenceSpaceType = "local";
|
|
1966
|
-
_DIVEWebXR._overlay = null;
|
|
1967
|
-
_DIVEWebXR._options = {
|
|
1968
|
-
requiredFeatures: [
|
|
1969
|
-
"local",
|
|
1970
|
-
"hit-test"
|
|
1971
|
-
],
|
|
1972
|
-
optionalFeatures: [
|
|
1973
|
-
"light-estimation",
|
|
1974
|
-
"local-floor",
|
|
1975
|
-
"dom-overlay",
|
|
1976
|
-
"depth-sensing"
|
|
1977
|
-
],
|
|
1978
|
-
depthSensing: {
|
|
1979
|
-
usagePreference: ["gpu-optimized"],
|
|
1980
|
-
dataFormatPreference: []
|
|
1981
|
-
},
|
|
1982
|
-
domOverlay: { root: {} }
|
|
1983
|
-
};
|
|
1984
|
-
_DIVEWebXR._xrController = null;
|
|
1985
|
-
DIVEWebXR = _DIVEWebXR;
|
|
1986
|
-
}
|
|
1987
|
-
});
|
|
1988
|
-
|
|
1989
|
-
// src/ar/sceneviewer/SceneViewer.ts
|
|
1990
|
-
var DIVESceneViewer;
|
|
1991
|
-
var init_SceneViewer = __esm({
|
|
1992
|
-
"src/ar/sceneviewer/SceneViewer.ts"() {
|
|
1993
|
-
"use strict";
|
|
1994
|
-
DIVESceneViewer = class {
|
|
1995
|
-
static Launch(scene, options) {
|
|
1996
|
-
const url = this.findSceneViewerSrc(scene);
|
|
1997
|
-
this.launchSceneViewer(url, options);
|
|
1998
|
-
}
|
|
1999
|
-
static launchSceneViewer(url, options) {
|
|
2000
|
-
const anchor = document.createElement("a");
|
|
2001
|
-
const noArViewerSigil = "#model-viewer-no-ar-fallback";
|
|
2002
|
-
const location = self.location.toString();
|
|
2003
|
-
const locationUrl = new URL(location);
|
|
2004
|
-
const modelUrl = new URL(url, location);
|
|
2005
|
-
const params = new URLSearchParams(modelUrl.search);
|
|
2006
|
-
locationUrl.hash = noArViewerSigil;
|
|
2007
|
-
params.set("mode", "ar_only");
|
|
2008
|
-
if ((options == null ? void 0 : options.arScale) === "fixed") {
|
|
2009
|
-
params.set("resizable", "false");
|
|
2010
|
-
}
|
|
2011
|
-
if ((options == null ? void 0 : options.arPlacement) === "vertical") {
|
|
2012
|
-
params.set("enable_vertical_placement", "true");
|
|
2013
|
-
}
|
|
2014
|
-
const intent = `intent://arvr.google.com/scene-viewer/1.2?${params.toString() + "&file=" + modelUrl.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(
|
|
2015
|
-
locationUrl.toString()
|
|
2016
|
-
)};end;`;
|
|
2017
|
-
anchor.setAttribute("href", intent);
|
|
2018
|
-
anchor.click();
|
|
2019
|
-
}
|
|
2020
|
-
static findSceneViewerSrc(scene) {
|
|
2021
|
-
let uri = null;
|
|
2022
|
-
scene.traverse((object) => {
|
|
2023
|
-
if (uri) return;
|
|
2024
|
-
if (object.userData.uri) {
|
|
2025
|
-
uri = object.userData.uri;
|
|
2026
|
-
}
|
|
2027
|
-
});
|
|
2028
|
-
if (!uri) {
|
|
2029
|
-
throw new Error("No model found in scene");
|
|
2030
|
-
}
|
|
2031
|
-
return uri;
|
|
2032
|
-
}
|
|
2033
|
-
};
|
|
2034
|
-
}
|
|
2035
|
-
});
|
|
2036
|
-
|
|
2037
|
-
// src/ar/AR.ts
|
|
2038
|
-
var AR_exports = {};
|
|
2039
|
-
__export(AR_exports, {
|
|
2040
|
-
DIVEAR: () => DIVEAR
|
|
2041
|
-
});
|
|
2042
|
-
var DIVEAR;
|
|
2043
|
-
var init_AR = __esm({
|
|
2044
|
-
"src/ar/AR.ts"() {
|
|
2045
|
-
"use strict";
|
|
2046
|
-
init_Info();
|
|
2047
|
-
init_ARQuickLook();
|
|
2048
|
-
init_WebXR();
|
|
2049
|
-
init_SceneViewer();
|
|
2050
|
-
DIVEAR = class {
|
|
2051
|
-
constructor(renderer, scene, controller) {
|
|
2052
|
-
this._renderer = renderer;
|
|
2053
|
-
this._scene = scene;
|
|
2054
|
-
this._controller = controller;
|
|
2055
|
-
}
|
|
2056
|
-
Launch(options) {
|
|
2057
|
-
return __async(this, null, function* () {
|
|
2058
|
-
const system = DIVEInfo.GetSystem();
|
|
2059
|
-
if (system === "iOS") {
|
|
2060
|
-
return this.tryARQuickLook();
|
|
2061
|
-
}
|
|
2062
|
-
if (system === "Android") {
|
|
2063
|
-
if (options == null ? void 0 : options.useWebXR) {
|
|
2064
|
-
console.warn("DIVE: WebXR is experimental on Android.");
|
|
2065
|
-
return this.tryWebXR();
|
|
2066
|
-
}
|
|
2067
|
-
return this.trySceneViewer();
|
|
2068
|
-
}
|
|
2069
|
-
console.log(
|
|
2070
|
-
"DIVE: AR not supported. Not a mobile system. (System is " + system + ")"
|
|
2071
|
-
);
|
|
2072
|
-
});
|
|
2073
|
-
}
|
|
2074
|
-
tryARQuickLook(options) {
|
|
2075
|
-
return __async(this, null, function* () {
|
|
2076
|
-
const support = DIVEInfo.GetSupportsARQuickLook();
|
|
2077
|
-
if (!support) {
|
|
2078
|
-
console.log("ARQuickLook not supported");
|
|
2079
|
-
return Promise.reject();
|
|
2080
|
-
}
|
|
2081
|
-
console.log("DIVE: Launching AR with ARQuickLook ...");
|
|
2082
|
-
yield DIVEARQuickLook.Launch(this._scene, options);
|
|
2083
|
-
return Promise.resolve();
|
|
2084
|
-
});
|
|
2085
|
-
}
|
|
2086
|
-
tryWebXR() {
|
|
2087
|
-
return __async(this, null, function* () {
|
|
2088
|
-
const support = yield DIVEInfo.GetSupportsWebXR();
|
|
2089
|
-
if (!support) {
|
|
2090
|
-
console.log(
|
|
2091
|
-
"WebXR not supported. Reason: " + WebXRUnsupportedReason[DIVEInfo.GetWebXRUnsupportedReason()]
|
|
2092
|
-
);
|
|
2093
|
-
return Promise.reject();
|
|
2094
|
-
}
|
|
2095
|
-
console.log("DIVE: Launching AR with WebXR ...");
|
|
2096
|
-
yield DIVEWebXR.Launch(this._renderer, this._scene, this._controller);
|
|
2097
|
-
return Promise.resolve();
|
|
2098
|
-
});
|
|
2099
|
-
}
|
|
2100
|
-
trySceneViewer(options) {
|
|
2101
|
-
return __async(this, null, function* () {
|
|
2102
|
-
console.log("DIVE: Launching AR with SceneViewer ...");
|
|
2103
|
-
DIVESceneViewer.Launch(this._scene, options);
|
|
2104
|
-
return Promise.resolve();
|
|
2105
|
-
});
|
|
2106
|
-
}
|
|
2107
|
-
};
|
|
2108
|
-
}
|
|
2109
|
-
});
|
|
2110
|
-
|
|
2111
|
-
// src/renderer/Renderer.ts
|
|
2112
|
-
import {
|
|
2113
|
-
MathUtils,
|
|
2114
|
-
NoToneMapping,
|
|
2115
|
-
PCFSoftShadowMap,
|
|
2116
|
-
WebGLRenderer
|
|
2117
|
-
} from "three";
|
|
2118
|
-
var DIVERendererDefaultSettings = {
|
|
2119
|
-
antialias: true,
|
|
2120
|
-
alpha: true,
|
|
2121
|
-
stencil: false,
|
|
2122
|
-
shadowMapEnabled: true,
|
|
2123
|
-
shadowMapType: PCFSoftShadowMap,
|
|
2124
|
-
toneMapping: NoToneMapping,
|
|
2125
|
-
canvas: void 0
|
|
2126
|
-
};
|
|
2127
|
-
var DIVERenderer = class extends WebGLRenderer {
|
|
2128
|
-
constructor(rendererSettings = DIVERendererDefaultSettings) {
|
|
2129
|
-
super({
|
|
2130
|
-
antialias: rendererSettings.antialias || DIVERendererDefaultSettings.antialias,
|
|
2131
|
-
alpha: rendererSettings.alpha || DIVERendererDefaultSettings.alpha,
|
|
2132
|
-
preserveDrawingBuffer: true,
|
|
2133
|
-
canvas: rendererSettings.canvas
|
|
2134
|
-
});
|
|
2135
|
-
// basic functionality members
|
|
2136
|
-
this.paused = false;
|
|
2137
|
-
this.running = false;
|
|
2138
|
-
this.force = false;
|
|
2139
|
-
// pre- and post-render callbacks
|
|
2140
|
-
this.preRenderCallbacks = /* @__PURE__ */ new Map();
|
|
2141
|
-
this.postRenderCallbacks = /* @__PURE__ */ new Map();
|
|
2142
|
-
this.setPixelRatio(window.devicePixelRatio);
|
|
2143
|
-
this.shadowMap.enabled = rendererSettings.shadowMapEnabled || DIVERendererDefaultSettings.shadowMapEnabled;
|
|
2144
|
-
this.shadowMap.type = rendererSettings.shadowMapType || DIVERendererDefaultSettings.shadowMapType;
|
|
2145
|
-
this.toneMapping = rendererSettings.toneMapping || DIVERendererDefaultSettings.toneMapping;
|
|
2146
|
-
this.debug.checkShaderErrors = false;
|
|
2147
|
-
}
|
|
2148
|
-
// Stops renderings and disposes the renderer.
|
|
2149
|
-
Dispose() {
|
|
2150
|
-
this.StopRenderer();
|
|
2151
|
-
this.dispose();
|
|
2152
|
-
}
|
|
2153
|
-
// Starts the renderer with the given scene and camera.
|
|
2154
|
-
StartRenderer(scene, cam) {
|
|
2155
|
-
this.setAnimationLoop((time, frame) => {
|
|
2156
|
-
this.internal_render(scene, cam, time, frame);
|
|
2157
|
-
});
|
|
2158
|
-
this.running = true;
|
|
2159
|
-
}
|
|
2160
|
-
// Pauses the renderer.
|
|
2161
|
-
PauseRenderer() {
|
|
2162
|
-
this.paused = true;
|
|
2163
|
-
}
|
|
2164
|
-
// Resumes the renderer after pausing.
|
|
2165
|
-
ResumeRenderer() {
|
|
2166
|
-
this.paused = false;
|
|
2167
|
-
}
|
|
2168
|
-
// Stops the renderer completely. Has to be started again with StartRenderer().
|
|
2169
|
-
StopRenderer() {
|
|
2170
|
-
this.setAnimationLoop(null);
|
|
2171
|
-
this.running = false;
|
|
2172
|
-
}
|
|
2173
|
-
// Resizes the renderer to the given width and height.
|
|
2174
|
-
OnResize(width, height) {
|
|
2175
|
-
this.setSize(width, height);
|
|
2176
|
-
}
|
|
2177
|
-
/**
|
|
2178
|
-
* Adds a callback to the render loop before actual render call.
|
|
2179
|
-
* @param callback Executed before rendering.
|
|
2180
|
-
* @returns uuid to remove the callback.
|
|
2181
|
-
*/
|
|
2182
|
-
AddPreRenderCallback(callback) {
|
|
2183
|
-
const newUUID = MathUtils.generateUUID();
|
|
2184
|
-
this.preRenderCallbacks.set(newUUID, callback);
|
|
2185
|
-
return newUUID;
|
|
2186
|
-
}
|
|
2187
|
-
/**
|
|
2188
|
-
* Removes a callback from the render loop before actual render call.
|
|
2189
|
-
* @param uuid of callback to remove.
|
|
2190
|
-
* @returns if removing was successful.
|
|
2191
|
-
*/
|
|
2192
|
-
RemovePreRenderCallback(uuid) {
|
|
2193
|
-
if (!this.preRenderCallbacks.has(uuid)) return false;
|
|
2194
|
-
this.preRenderCallbacks.delete(uuid);
|
|
2195
|
-
return true;
|
|
2196
|
-
}
|
|
2197
|
-
/**
|
|
2198
|
-
* Adds a callback to the render loop after actual render call.
|
|
2199
|
-
* @param callback Executed after rendering.
|
|
2200
|
-
* @returns uuid to remove the callback.
|
|
2201
|
-
*/
|
|
2202
|
-
AddPostRenderCallback(callback) {
|
|
2203
|
-
const newUUID = MathUtils.generateUUID();
|
|
2204
|
-
this.postRenderCallbacks.set(newUUID, callback);
|
|
2205
|
-
return newUUID;
|
|
2206
|
-
}
|
|
2207
|
-
/**
|
|
2208
|
-
* Removes a callback from the render loop after actual render call.
|
|
2209
|
-
* @param uuid of callback to remove.
|
|
2210
|
-
* @returns if removing was successful.
|
|
2211
|
-
*/
|
|
2212
|
-
RemovePostRenderCallback(uuid) {
|
|
2213
|
-
if (!this.postRenderCallbacks.has(uuid)) return false;
|
|
2214
|
-
this.postRenderCallbacks.delete(uuid);
|
|
2215
|
-
return true;
|
|
2216
|
-
}
|
|
2217
|
-
/**
|
|
2218
|
-
* Forces the renderer to render the next frame.
|
|
2219
|
-
*/
|
|
2220
|
-
ForceRendering() {
|
|
2221
|
-
this.force = true;
|
|
2222
|
-
}
|
|
2223
|
-
/**
|
|
2224
|
-
* Internal render loop.
|
|
2225
|
-
*
|
|
2226
|
-
* To control renderloop you can add callbacks via AddPreRenderCallback() and AddPostRenderCallback().
|
|
2227
|
-
* @param scene Scene to render.
|
|
2228
|
-
* @param cam Camera to render with.
|
|
2229
|
-
*/
|
|
2230
|
-
internal_render(scene, cam, time, frame) {
|
|
2231
|
-
if ((this.paused || !this.running) && !this.force) return;
|
|
2232
|
-
this.preRenderCallbacks.forEach((callback) => {
|
|
2233
|
-
callback(time, frame);
|
|
2234
|
-
});
|
|
2235
|
-
this.render(scene, cam);
|
|
2236
|
-
this.postRenderCallbacks.forEach((callback) => {
|
|
2237
|
-
callback(time, frame);
|
|
2238
|
-
});
|
|
2239
|
-
this.force = false;
|
|
2240
|
-
}
|
|
2241
|
-
};
|
|
2242
|
-
|
|
2243
|
-
// src/scene/Scene.ts
|
|
2244
|
-
import { Color as Color7, Scene as Scene2 } from "three";
|
|
2245
|
-
|
|
2246
|
-
// src/scene/root/Root.ts
|
|
2247
|
-
import { Box3 as Box32, Color as Color5, Object3D as Object3D8 } from "three";
|
|
2248
|
-
|
|
2249
|
-
// src/light/AmbientLight.ts
|
|
2250
|
-
init_VisibilityLayerMask();
|
|
2251
|
-
import { AmbientLight, Object3D } from "three";
|
|
2252
|
-
var DIVEAmbientLight = class extends Object3D {
|
|
2253
|
-
constructor() {
|
|
2254
|
-
super();
|
|
2255
|
-
this.isDIVELight = true;
|
|
2256
|
-
this.isDIVEAmbientLight = true;
|
|
2257
|
-
this.name = "DIVEAmbientLight";
|
|
2258
|
-
this._light = new AmbientLight(16777215, 1);
|
|
2259
|
-
this._light.layers.mask = PRODUCT_LAYER_MASK;
|
|
2260
|
-
this.add(this._light);
|
|
2261
|
-
}
|
|
2262
|
-
SetColor(color) {
|
|
2263
|
-
this._light.color = color;
|
|
2264
|
-
}
|
|
2265
|
-
SetIntensity(intensity) {
|
|
2266
|
-
this._light.intensity = intensity;
|
|
2267
|
-
}
|
|
2268
|
-
SetEnabled(enabled) {
|
|
2269
|
-
this._light.visible = enabled;
|
|
2270
|
-
}
|
|
2271
|
-
};
|
|
2272
|
-
|
|
2273
|
-
// src/light/PointLight.ts
|
|
2274
|
-
import {
|
|
2275
|
-
PointLight,
|
|
2276
|
-
SphereGeometry,
|
|
2277
|
-
MeshBasicMaterial as MeshBasicMaterial2,
|
|
2278
|
-
Mesh as Mesh3,
|
|
2279
|
-
FrontSide,
|
|
2280
|
-
Object3D as Object3D5
|
|
2281
|
-
} from "three";
|
|
2282
|
-
|
|
2283
|
-
// src/com/Communication.ts
|
|
2284
|
-
init_SelectTool();
|
|
2285
|
-
import { generateUUID } from "three/src/math/MathUtils";
|
|
2286
|
-
import { merge } from "lodash";
|
|
2287
|
-
var _DIVECommunication = class _DIVECommunication {
|
|
2288
|
-
constructor(renderer, scene, controls, toolbox) {
|
|
2289
|
-
this.registered = /* @__PURE__ */ new Map();
|
|
2290
|
-
// private listeners: { [key: string]: EventListener[] } = {};
|
|
2291
|
-
this.listeners = /* @__PURE__ */ new Map();
|
|
2292
|
-
this._id = generateUUID();
|
|
2293
|
-
this.renderer = renderer;
|
|
2294
|
-
this.scene = scene;
|
|
2295
|
-
this.controller = controls;
|
|
2296
|
-
this.toolbox = toolbox;
|
|
2297
|
-
this._mediaGenerator = null;
|
|
2298
|
-
this._io = null;
|
|
2299
|
-
this._ar = null;
|
|
2300
|
-
_DIVECommunication.__instances.push(this);
|
|
2301
|
-
}
|
|
2302
|
-
static get(id) {
|
|
2303
|
-
const fromComID = this.__instances.find(
|
|
2304
|
-
(instance) => instance.id === id
|
|
2305
|
-
);
|
|
2306
|
-
if (fromComID) return fromComID;
|
|
2307
|
-
return this.__instances.find(
|
|
2308
|
-
(instance) => Array.from(instance.registered.values()).find(
|
|
2309
|
-
(object) => object.id === id
|
|
2310
|
-
)
|
|
2311
|
-
);
|
|
2312
|
-
}
|
|
2313
|
-
get id() {
|
|
2314
|
-
return this._id;
|
|
2315
|
-
}
|
|
2316
|
-
get mediaGenerator() {
|
|
2317
|
-
if (!this._mediaGenerator) {
|
|
2318
|
-
const DIVEMediaCreator2 = (init_MediaCreator(), __toCommonJS(MediaCreator_exports)).DIVEMediaCreator;
|
|
2319
|
-
this._mediaGenerator = new DIVEMediaCreator2(
|
|
2320
|
-
this.renderer,
|
|
2321
|
-
this.scene,
|
|
2322
|
-
this.controller
|
|
2323
|
-
);
|
|
2324
|
-
}
|
|
2325
|
-
return this._mediaGenerator;
|
|
2326
|
-
}
|
|
2327
|
-
get io() {
|
|
2328
|
-
if (!this._io) {
|
|
2329
|
-
const DIVEIO2 = (init_IO(), __toCommonJS(IO_exports)).DIVEIO;
|
|
2330
|
-
this._io = new DIVEIO2(this.scene);
|
|
2331
|
-
}
|
|
2332
|
-
return this._io;
|
|
2333
|
-
}
|
|
2334
|
-
get ar() {
|
|
2335
|
-
if (!this._ar) {
|
|
2336
|
-
const DIVEAR2 = (init_AR(), __toCommonJS(AR_exports)).DIVEAR;
|
|
2337
|
-
this._ar = new DIVEAR2(this.renderer, this.scene, this.controller);
|
|
2338
|
-
}
|
|
2339
|
-
return this._ar;
|
|
2340
|
-
}
|
|
2341
|
-
DestroyInstance() {
|
|
2342
|
-
const existingIndex = _DIVECommunication.__instances.findIndex(
|
|
2343
|
-
(entry) => entry.id === this.id
|
|
2344
|
-
);
|
|
2345
|
-
if (existingIndex === -1) return false;
|
|
2346
|
-
_DIVECommunication.__instances.splice(existingIndex, 1);
|
|
2347
|
-
return true;
|
|
2348
|
-
}
|
|
2349
|
-
PerformAction(action, payload) {
|
|
2350
|
-
let returnValue = false;
|
|
2351
|
-
switch (action) {
|
|
2352
|
-
case "GET_ALL_SCENE_DATA": {
|
|
2353
|
-
returnValue = this.getAllSceneData(
|
|
2354
|
-
payload
|
|
2355
|
-
);
|
|
2356
|
-
break;
|
|
2357
|
-
}
|
|
2358
|
-
case "GET_ALL_OBJECTS": {
|
|
2359
|
-
returnValue = this.getAllObjects(
|
|
2360
|
-
payload
|
|
2361
|
-
);
|
|
2362
|
-
break;
|
|
2363
|
-
}
|
|
2364
|
-
case "GET_OBJECTS": {
|
|
2365
|
-
returnValue = this.getObjects(
|
|
2366
|
-
payload
|
|
2367
|
-
);
|
|
2368
|
-
break;
|
|
2369
|
-
}
|
|
2370
|
-
case "ADD_OBJECT": {
|
|
2371
|
-
returnValue = this.addObject(
|
|
2372
|
-
payload
|
|
2373
|
-
);
|
|
2374
|
-
break;
|
|
2375
|
-
}
|
|
2376
|
-
case "UPDATE_OBJECT": {
|
|
2377
|
-
returnValue = this.updateObject(
|
|
2378
|
-
payload
|
|
2379
|
-
);
|
|
2380
|
-
break;
|
|
2381
|
-
}
|
|
2382
|
-
case "DELETE_OBJECT": {
|
|
2383
|
-
returnValue = this.deleteObject(
|
|
2384
|
-
payload
|
|
2385
|
-
);
|
|
2386
|
-
break;
|
|
2387
|
-
}
|
|
2388
|
-
case "SELECT_OBJECT": {
|
|
2389
|
-
returnValue = this.selectObject(
|
|
2390
|
-
payload
|
|
2391
|
-
);
|
|
2392
|
-
break;
|
|
2393
|
-
}
|
|
2394
|
-
case "DESELECT_OBJECT": {
|
|
2395
|
-
returnValue = this.deselectObject(
|
|
2396
|
-
payload
|
|
2397
|
-
);
|
|
2398
|
-
break;
|
|
2399
|
-
}
|
|
2400
|
-
case "SET_BACKGROUND": {
|
|
2401
|
-
returnValue = this.setBackground(
|
|
2402
|
-
payload
|
|
2403
|
-
);
|
|
2404
|
-
break;
|
|
2405
|
-
}
|
|
2406
|
-
case "DROP_IT": {
|
|
2407
|
-
returnValue = this.dropIt(
|
|
2408
|
-
payload
|
|
2409
|
-
);
|
|
2410
|
-
break;
|
|
2411
|
-
}
|
|
2412
|
-
case "PLACE_ON_FLOOR": {
|
|
2413
|
-
returnValue = this.placeOnFloor(
|
|
2414
|
-
payload
|
|
2415
|
-
);
|
|
2416
|
-
break;
|
|
2417
|
-
}
|
|
2418
|
-
case "SET_CAMERA_TRANSFORM": {
|
|
2419
|
-
returnValue = this.setCameraTransform(
|
|
2420
|
-
payload
|
|
2421
|
-
);
|
|
2422
|
-
break;
|
|
2423
|
-
}
|
|
2424
|
-
case "GET_CAMERA_TRANSFORM": {
|
|
2425
|
-
returnValue = this.getCameraTransform(
|
|
2426
|
-
payload
|
|
2427
|
-
);
|
|
2428
|
-
break;
|
|
2429
|
-
}
|
|
2430
|
-
case "MOVE_CAMERA": {
|
|
2431
|
-
returnValue = this.moveCamera(
|
|
2432
|
-
payload
|
|
2433
|
-
);
|
|
2434
|
-
break;
|
|
2435
|
-
}
|
|
2436
|
-
case "RESET_CAMERA": {
|
|
2437
|
-
returnValue = this.resetCamera(
|
|
2438
|
-
payload
|
|
2439
|
-
);
|
|
2440
|
-
break;
|
|
2441
|
-
}
|
|
2442
|
-
case "COMPUTE_ENCOMPASSING_VIEW": {
|
|
2443
|
-
returnValue = this.computeEncompassingView(
|
|
2444
|
-
payload
|
|
2445
|
-
);
|
|
2446
|
-
break;
|
|
2447
|
-
}
|
|
2448
|
-
case "SET_CAMERA_LAYER": {
|
|
2449
|
-
returnValue = this.setCameraLayer(
|
|
2450
|
-
payload
|
|
2451
|
-
);
|
|
2452
|
-
break;
|
|
2453
|
-
}
|
|
2454
|
-
case "ZOOM_CAMERA": {
|
|
2455
|
-
returnValue = this.zoomCamera(
|
|
2456
|
-
payload
|
|
2457
|
-
);
|
|
2458
|
-
break;
|
|
2459
|
-
}
|
|
2460
|
-
case "SET_GIZMO_MODE": {
|
|
2461
|
-
returnValue = this.setGizmoMode(
|
|
2462
|
-
payload
|
|
2463
|
-
);
|
|
2464
|
-
break;
|
|
2465
|
-
}
|
|
2466
|
-
case "SET_GIZMO_VISIBILITY": {
|
|
2467
|
-
returnValue = this.setGizmoVisibility(
|
|
2468
|
-
payload
|
|
2469
|
-
);
|
|
2470
|
-
break;
|
|
2471
|
-
}
|
|
2472
|
-
case "SET_GIZMO_SCALE_LINKED": {
|
|
2473
|
-
returnValue = this.setGizmoScaleLinked(
|
|
2474
|
-
payload
|
|
2475
|
-
);
|
|
2476
|
-
break;
|
|
2477
|
-
}
|
|
2478
|
-
case "USE_TOOL": {
|
|
2479
|
-
returnValue = this.useTool(
|
|
2480
|
-
payload
|
|
2481
|
-
);
|
|
2482
|
-
break;
|
|
2483
|
-
}
|
|
2484
|
-
case "MODEL_LOADED": {
|
|
2485
|
-
returnValue = this.modelLoaded(
|
|
2486
|
-
payload
|
|
2487
|
-
);
|
|
2488
|
-
break;
|
|
2489
|
-
}
|
|
2490
|
-
case "UPDATE_SCENE": {
|
|
2491
|
-
returnValue = this.updateScene(
|
|
2492
|
-
payload
|
|
2493
|
-
);
|
|
2494
|
-
break;
|
|
2495
|
-
}
|
|
2496
|
-
case "GENERATE_MEDIA": {
|
|
2497
|
-
returnValue = this.generateMedia(
|
|
2498
|
-
payload
|
|
2499
|
-
);
|
|
2500
|
-
break;
|
|
2501
|
-
}
|
|
2502
|
-
case "SET_PARENT": {
|
|
2503
|
-
returnValue = this.setParent(
|
|
2504
|
-
payload
|
|
2505
|
-
);
|
|
2506
|
-
break;
|
|
2507
|
-
}
|
|
2508
|
-
case "EXPORT_SCENE": {
|
|
2509
|
-
returnValue = this.exportScene(
|
|
2510
|
-
payload
|
|
2511
|
-
);
|
|
2512
|
-
break;
|
|
2513
|
-
}
|
|
2514
|
-
case "LAUNCH_AR": {
|
|
2515
|
-
returnValue = this.ar.Launch(
|
|
2516
|
-
payload
|
|
2517
|
-
);
|
|
2518
|
-
break;
|
|
2519
|
-
}
|
|
2520
|
-
default: {
|
|
2521
|
-
console.warn(
|
|
2522
|
-
`DIVECommunication.PerformAction: has been executed with unknown Action type ${action}`
|
|
2523
|
-
);
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
this.dispatch(action, payload);
|
|
2527
|
-
return returnValue;
|
|
2528
|
-
}
|
|
2529
|
-
Subscribe(type, listener) {
|
|
2530
|
-
if (!this.listeners.get(type)) this.listeners.set(type, []);
|
|
2531
|
-
this.listeners.get(type).push(listener);
|
|
2532
|
-
return () => {
|
|
2533
|
-
const listenerArray = this.listeners.get(type);
|
|
2534
|
-
if (!listenerArray) return false;
|
|
2535
|
-
const existingIndex = listenerArray.findIndex(
|
|
2536
|
-
(entry) => entry === listener
|
|
2537
|
-
);
|
|
2538
|
-
if (existingIndex === -1) return false;
|
|
2539
|
-
listenerArray.splice(existingIndex, 1);
|
|
2540
|
-
return true;
|
|
2541
|
-
};
|
|
2542
|
-
}
|
|
2543
|
-
dispatch(type, payload) {
|
|
2544
|
-
const listenerArray = this.listeners.get(type);
|
|
2545
|
-
if (!listenerArray) return;
|
|
2546
|
-
listenerArray.forEach((listener) => listener(payload));
|
|
2547
|
-
}
|
|
2548
|
-
getAllSceneData(payload) {
|
|
2549
|
-
const sceneData = {
|
|
2550
|
-
name: this.scene.name,
|
|
2551
|
-
mediaItem: null,
|
|
2552
|
-
backgroundColor: "#" + this.scene.background.getHexString(),
|
|
2553
|
-
floorEnabled: this.scene.Floor.visible,
|
|
2554
|
-
floorColor: "#" + this.scene.Floor.material.color.getHexString(),
|
|
2555
|
-
userCamera: {
|
|
2556
|
-
position: this.controller.object.position.clone(),
|
|
2557
|
-
target: this.controller.target.clone()
|
|
2558
|
-
},
|
|
2559
|
-
spotmarks: [],
|
|
2560
|
-
lights: Array.from(this.registered.values()).filter(
|
|
2561
|
-
(object) => object.entityType === "light"
|
|
2562
|
-
),
|
|
2563
|
-
objects: Array.from(this.registered.values()).filter(
|
|
2564
|
-
(object) => object.entityType === "model"
|
|
2565
|
-
),
|
|
2566
|
-
cameras: Array.from(this.registered.values()).filter(
|
|
2567
|
-
(object) => object.entityType === "pov"
|
|
2568
|
-
),
|
|
2569
|
-
primitives: Array.from(this.registered.values()).filter(
|
|
2570
|
-
(object) => object.entityType === "primitive"
|
|
2571
|
-
),
|
|
2572
|
-
groups: Array.from(this.registered.values()).filter(
|
|
2573
|
-
(object) => object.entityType === "group"
|
|
2574
|
-
)
|
|
2575
|
-
};
|
|
2576
|
-
Object.assign(payload, sceneData);
|
|
2577
|
-
return sceneData;
|
|
2578
|
-
}
|
|
2579
|
-
getAllObjects(payload) {
|
|
2580
|
-
Object.assign(payload, this.registered);
|
|
2581
|
-
return this.registered;
|
|
2582
|
-
}
|
|
2583
|
-
getObjects(payload) {
|
|
2584
|
-
if (payload.ids.length === 0) return [];
|
|
2585
|
-
const objects = [];
|
|
2586
|
-
this.registered.forEach((object) => {
|
|
2587
|
-
if (!payload.ids.includes(object.id)) return;
|
|
2588
|
-
objects.push(object);
|
|
2589
|
-
});
|
|
2590
|
-
return objects;
|
|
2591
|
-
}
|
|
2592
|
-
addObject(payload) {
|
|
2593
|
-
if (this.registered.get(payload.id)) return false;
|
|
2594
|
-
if (payload.parentId === void 0) payload.parentId = null;
|
|
2595
|
-
this.registered.set(payload.id, payload);
|
|
2596
|
-
this.scene.AddSceneObject(payload);
|
|
2597
|
-
return true;
|
|
2598
|
-
}
|
|
2599
|
-
updateObject(payload) {
|
|
2600
|
-
const objectToUpdate = this.registered.get(payload.id);
|
|
2601
|
-
if (!objectToUpdate) return false;
|
|
2602
|
-
this.registered.set(payload.id, merge(objectToUpdate, payload));
|
|
2603
|
-
const updatedObject = this.registered.get(payload.id);
|
|
2604
|
-
this.scene.UpdateSceneObject(__spreadProps(__spreadValues({}, payload), {
|
|
2605
|
-
id: updatedObject.id,
|
|
2606
|
-
entityType: updatedObject.entityType
|
|
2607
|
-
}));
|
|
2608
|
-
Object.assign(payload, updatedObject);
|
|
2609
|
-
return true;
|
|
2610
|
-
}
|
|
2611
|
-
deleteObject(payload) {
|
|
2612
|
-
const deletedObject = this.registered.get(payload.id);
|
|
2613
|
-
if (!deletedObject) return false;
|
|
2614
|
-
if (deletedObject.parentId) {
|
|
2615
|
-
this.setParent({
|
|
2616
|
-
object: { id: deletedObject.id },
|
|
2617
|
-
parent: null
|
|
2618
|
-
});
|
|
2619
|
-
}
|
|
2620
|
-
if (deletedObject.entityType === "group") {
|
|
2621
|
-
this.registered.forEach((object) => {
|
|
2622
|
-
if (object.parentId === deletedObject.id) {
|
|
2623
|
-
this.updateObject({
|
|
2624
|
-
id: object.id,
|
|
2625
|
-
parentId: null
|
|
2626
|
-
});
|
|
2627
|
-
}
|
|
2628
|
-
});
|
|
2629
|
-
}
|
|
2630
|
-
Object.assign(payload, deletedObject);
|
|
2631
|
-
this.registered.delete(payload.id);
|
|
2632
|
-
Array.from(this.registered.values()).forEach((object) => {
|
|
2633
|
-
if (!object.parentId) return;
|
|
2634
|
-
if (object.parentId !== payload.id) return;
|
|
2635
|
-
object.parentId = null;
|
|
2636
|
-
});
|
|
2637
|
-
this.scene.DeleteSceneObject(deletedObject);
|
|
2638
|
-
return true;
|
|
2639
|
-
}
|
|
2640
|
-
selectObject(payload) {
|
|
2641
|
-
const object = this.registered.get(payload.id);
|
|
2642
|
-
if (!object) return false;
|
|
2643
|
-
const sceneObject = this.scene.GetSceneObject(object);
|
|
2644
|
-
if (!sceneObject) return false;
|
|
2645
|
-
if (!("isSelectable" in sceneObject)) return false;
|
|
2646
|
-
const activeTool = this.toolbox.GetActiveTool();
|
|
2647
|
-
if (activeTool && isSelectTool(activeTool)) {
|
|
2648
|
-
activeTool.AttachGizmo(sceneObject);
|
|
2649
|
-
}
|
|
2650
|
-
Object.assign(payload, object);
|
|
2651
|
-
return true;
|
|
2652
|
-
}
|
|
2653
|
-
deselectObject(payload) {
|
|
2654
|
-
const object = this.registered.get(payload.id);
|
|
2655
|
-
if (!object) return false;
|
|
2656
|
-
const sceneObject = this.scene.GetSceneObject(object);
|
|
2657
|
-
if (!sceneObject) return false;
|
|
2658
|
-
if (!("isSelectable" in sceneObject)) return false;
|
|
2659
|
-
const activeTool = this.toolbox.GetActiveTool();
|
|
2660
|
-
if (activeTool && isSelectTool(activeTool)) {
|
|
2661
|
-
activeTool.DetachGizmo();
|
|
2662
|
-
}
|
|
2663
|
-
Object.assign(payload, object);
|
|
2664
|
-
return true;
|
|
2665
|
-
}
|
|
2666
|
-
setBackground(payload) {
|
|
2667
|
-
this.scene.SetBackground(payload.color);
|
|
2668
|
-
return true;
|
|
2669
|
-
}
|
|
2670
|
-
dropIt(payload) {
|
|
2671
|
-
const object = this.registered.get(payload.id);
|
|
2672
|
-
if (!object) return false;
|
|
2673
|
-
const model = this.scene.GetSceneObject(object);
|
|
2674
|
-
model.DropIt();
|
|
2675
|
-
return true;
|
|
2676
|
-
}
|
|
2677
|
-
placeOnFloor(payload) {
|
|
2678
|
-
const object = this.registered.get(payload.id);
|
|
2679
|
-
if (!object) return false;
|
|
2680
|
-
this.scene.PlaceOnFloor(object);
|
|
2681
|
-
return true;
|
|
2682
|
-
}
|
|
2683
|
-
setCameraTransform(payload) {
|
|
2684
|
-
this.controller.object.position.copy(payload.position);
|
|
2685
|
-
this.controller.target.copy(payload.target);
|
|
2686
|
-
this.controller.update();
|
|
2687
|
-
return true;
|
|
2688
|
-
}
|
|
2689
|
-
getCameraTransform(payload) {
|
|
2690
|
-
const transform = {
|
|
2691
|
-
position: this.controller.object.position.clone(),
|
|
2692
|
-
target: this.controller.target.clone()
|
|
2693
|
-
};
|
|
2694
|
-
Object.assign(payload, transform);
|
|
2695
|
-
return transform;
|
|
2696
|
-
}
|
|
2697
|
-
moveCamera(payload) {
|
|
2698
|
-
let position = { x: 0, y: 0, z: 0 };
|
|
2699
|
-
let target = { x: 0, y: 0, z: 0 };
|
|
2700
|
-
if ("id" in payload) {
|
|
2701
|
-
position = this.registered.get(payload.id).position;
|
|
2702
|
-
target = this.registered.get(payload.id).target;
|
|
2703
|
-
} else {
|
|
2704
|
-
position = payload.position;
|
|
2705
|
-
target = payload.target;
|
|
2706
|
-
}
|
|
2707
|
-
this.controller.MoveTo(
|
|
2708
|
-
position,
|
|
2709
|
-
target,
|
|
2710
|
-
payload.duration,
|
|
2711
|
-
payload.locked
|
|
2712
|
-
);
|
|
2713
|
-
return true;
|
|
2714
|
-
}
|
|
2715
|
-
setCameraLayer(payload) {
|
|
2716
|
-
this.controller.object.SetCameraLayer(payload.layer);
|
|
2717
|
-
return true;
|
|
2718
|
-
}
|
|
2719
|
-
resetCamera(payload) {
|
|
2720
|
-
this.controller.RevertLast(payload.duration);
|
|
2721
|
-
return true;
|
|
2722
|
-
}
|
|
2723
|
-
computeEncompassingView(payload) {
|
|
2724
|
-
const sceneBB = this.scene.ComputeSceneBB();
|
|
2725
|
-
const transform = this.controller.ComputeEncompassingView(sceneBB);
|
|
2726
|
-
Object.assign(payload, transform);
|
|
2727
|
-
return transform;
|
|
2728
|
-
}
|
|
2729
|
-
zoomCamera(payload) {
|
|
2730
|
-
if (payload.direction === "IN") this.controller.ZoomIn(payload.by);
|
|
2731
|
-
if (payload.direction === "OUT") this.controller.ZoomOut(payload.by);
|
|
2732
|
-
return true;
|
|
2733
|
-
}
|
|
2734
|
-
setGizmoMode(payload) {
|
|
2735
|
-
this.toolbox.SetGizmoMode(payload.mode);
|
|
2736
|
-
return true;
|
|
2737
|
-
}
|
|
2738
|
-
setGizmoVisibility(payload) {
|
|
2739
|
-
this.toolbox.SetGizmoVisibility(payload);
|
|
2740
|
-
return payload;
|
|
2741
|
-
}
|
|
2742
|
-
setGizmoScaleLinked(payload) {
|
|
2743
|
-
this.toolbox.SetGizmoScaleLinked(payload);
|
|
2744
|
-
return payload;
|
|
2745
|
-
}
|
|
2746
|
-
useTool(payload) {
|
|
2747
|
-
this.toolbox.UseTool(payload.tool);
|
|
2748
|
-
return true;
|
|
2749
|
-
}
|
|
2750
|
-
modelLoaded(payload) {
|
|
2751
|
-
this.registered.get(payload.id).loaded = true;
|
|
2752
|
-
return true;
|
|
2753
|
-
}
|
|
2754
|
-
updateScene(payload) {
|
|
2755
|
-
if (payload.name !== void 0) this.scene.name = payload.name;
|
|
2756
|
-
if (payload.backgroundColor !== void 0)
|
|
2757
|
-
this.scene.SetBackground(payload.backgroundColor);
|
|
2758
|
-
if (payload.gridEnabled !== void 0)
|
|
2759
|
-
this.scene.Grid.SetVisibility(payload.gridEnabled);
|
|
2760
|
-
if (payload.floorEnabled !== void 0)
|
|
2761
|
-
this.scene.Floor.SetVisibility(payload.floorEnabled);
|
|
2762
|
-
if (payload.floorColor !== void 0)
|
|
2763
|
-
this.scene.Floor.SetColor(payload.floorColor);
|
|
2764
|
-
payload.name = this.scene.name;
|
|
2765
|
-
payload.backgroundColor = "#" + this.scene.background.getHexString();
|
|
2766
|
-
payload.gridEnabled = this.scene.Grid.visible;
|
|
2767
|
-
payload.floorEnabled = this.scene.Floor.visible;
|
|
2768
|
-
payload.floorColor = "#" + this.scene.Floor.material.color.getHexString();
|
|
2769
|
-
return true;
|
|
2770
|
-
}
|
|
2771
|
-
generateMedia(payload) {
|
|
2772
|
-
let position = { x: 0, y: 0, z: 0 };
|
|
2773
|
-
let target = { x: 0, y: 0, z: 0 };
|
|
2774
|
-
if ("id" in payload) {
|
|
2775
|
-
position = this.registered.get(payload.id).position;
|
|
2776
|
-
target = this.registered.get(payload.id).target;
|
|
2777
|
-
} else {
|
|
2778
|
-
position = payload.position;
|
|
2779
|
-
target = payload.target;
|
|
2780
|
-
}
|
|
2781
|
-
payload.dataUri = this.mediaGenerator.GenerateMedia(
|
|
2782
|
-
position,
|
|
2783
|
-
target,
|
|
2784
|
-
payload.width,
|
|
2785
|
-
payload.height
|
|
2786
|
-
);
|
|
2787
|
-
return true;
|
|
2788
|
-
}
|
|
2789
|
-
setParent(payload) {
|
|
2790
|
-
const object = this.registered.get(payload.object.id);
|
|
2791
|
-
if (!object) return false;
|
|
2792
|
-
const sceneObject = this.scene.GetSceneObject(object);
|
|
2793
|
-
if (!sceneObject) return false;
|
|
2794
|
-
if (payload.parent === null) {
|
|
2795
|
-
this.scene.Root.attach(sceneObject);
|
|
2796
|
-
this.updateObject({
|
|
2797
|
-
id: object.id,
|
|
2798
|
-
parentId: null
|
|
2799
|
-
});
|
|
2800
|
-
return true;
|
|
2801
|
-
}
|
|
2802
|
-
if (payload.object.id === payload.parent.id) {
|
|
2803
|
-
return false;
|
|
2804
|
-
}
|
|
2805
|
-
const parent = this.registered.get(payload.parent.id);
|
|
2806
|
-
if (!parent) {
|
|
2807
|
-
this.scene.Root.attach(sceneObject);
|
|
2808
|
-
this.updateObject({
|
|
2809
|
-
id: object.id,
|
|
2810
|
-
parentId: null
|
|
2811
|
-
});
|
|
2812
|
-
return true;
|
|
2813
|
-
}
|
|
2814
|
-
const parentObject = this.scene.GetSceneObject(parent);
|
|
2815
|
-
if (!parentObject) {
|
|
2816
|
-
this.scene.Root.attach(sceneObject);
|
|
2817
|
-
this.updateObject({
|
|
2818
|
-
id: object.id,
|
|
2819
|
-
parentId: null
|
|
2820
|
-
});
|
|
2821
|
-
return true;
|
|
2822
|
-
}
|
|
2823
|
-
parentObject.attach(sceneObject);
|
|
2824
|
-
this.updateObject({
|
|
2825
|
-
id: object.id,
|
|
2826
|
-
parentId: parent.id
|
|
2827
|
-
});
|
|
2828
|
-
return true;
|
|
2829
|
-
}
|
|
2830
|
-
exportScene(payload) {
|
|
2831
|
-
return this.io.Export(payload.type);
|
|
2832
|
-
}
|
|
2833
|
-
};
|
|
2834
|
-
_DIVECommunication.__instances = [];
|
|
2835
|
-
var DIVECommunication = _DIVECommunication;
|
|
2836
|
-
|
|
2837
|
-
// src/light/PointLight.ts
|
|
2838
|
-
init_VisibilityLayerMask();
|
|
2839
|
-
var DIVEPointLight = class extends Object3D5 {
|
|
2840
|
-
constructor() {
|
|
2841
|
-
super();
|
|
2842
|
-
this.isDIVELight = true;
|
|
2843
|
-
this.isDIVEPointLight = true;
|
|
2844
|
-
this.isMovable = true;
|
|
2845
|
-
this.isSelectable = true;
|
|
2846
|
-
this.gizmo = null;
|
|
2847
|
-
this.name = "DIVEPointLight";
|
|
2848
|
-
this.light = new PointLight(16777215, 1);
|
|
2849
|
-
this.light.layers.mask = PRODUCT_LAYER_MASK;
|
|
2850
|
-
this.light.castShadow = true;
|
|
2851
|
-
this.light.shadow.mapSize.width = 512;
|
|
2852
|
-
this.light.shadow.mapSize.height = 512;
|
|
2853
|
-
this.add(this.light);
|
|
2854
|
-
const geoSize = 0.1;
|
|
2855
|
-
const geometry = new SphereGeometry(
|
|
2856
|
-
geoSize,
|
|
2857
|
-
geoSize * 320,
|
|
2858
|
-
geoSize * 320
|
|
2859
|
-
);
|
|
2860
|
-
const material = new MeshBasicMaterial2({
|
|
2861
|
-
color: this.light.color,
|
|
2862
|
-
transparent: true,
|
|
2863
|
-
opacity: 0.8,
|
|
2864
|
-
side: FrontSide
|
|
2865
|
-
});
|
|
2866
|
-
this.mesh = new Mesh3(geometry, material);
|
|
2867
|
-
this.mesh.layers.mask = UI_LAYER_MASK;
|
|
2868
|
-
this.add(this.mesh);
|
|
2869
|
-
}
|
|
2870
|
-
SetColor(color) {
|
|
2871
|
-
this.light.color = color;
|
|
2872
|
-
this.mesh.material.color = color;
|
|
2873
|
-
}
|
|
2874
|
-
SetIntensity(intensity) {
|
|
2875
|
-
this.light.intensity = intensity;
|
|
2876
|
-
this.mesh.material.opacity = intensity > 0.8 ? 0.8 : intensity * 0.8;
|
|
2877
|
-
}
|
|
2878
|
-
SetEnabled(enabled) {
|
|
2879
|
-
this.light.visible = enabled;
|
|
2880
|
-
}
|
|
2881
|
-
onMove() {
|
|
2882
|
-
var _a;
|
|
2883
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
2884
|
-
"UPDATE_OBJECT",
|
|
2885
|
-
{ id: this.userData.id, position: this.position }
|
|
2886
|
-
);
|
|
2887
|
-
}
|
|
2888
|
-
onSelect() {
|
|
2889
|
-
var _a;
|
|
2890
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
2891
|
-
"SELECT_OBJECT",
|
|
2892
|
-
{ id: this.userData.id }
|
|
2893
|
-
);
|
|
2894
|
-
}
|
|
2895
|
-
onDeselect() {
|
|
2896
|
-
var _a;
|
|
2897
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
2898
|
-
"DESELECT_OBJECT",
|
|
2899
|
-
{ id: this.userData.id }
|
|
2900
|
-
);
|
|
2901
|
-
}
|
|
2902
|
-
};
|
|
2903
|
-
|
|
2904
|
-
// src/light/SceneLight.ts
|
|
2905
|
-
init_VisibilityLayerMask();
|
|
2906
|
-
import { DirectionalLight, HemisphereLight, Object3D as Object3D6 } from "three";
|
|
2907
|
-
var DIVESceneLight = class extends Object3D6 {
|
|
2908
|
-
constructor() {
|
|
2909
|
-
super();
|
|
2910
|
-
this.isDIVELight = true;
|
|
2911
|
-
this.isDIVESceneLight = true;
|
|
2912
|
-
this.name = "DIVESceneLight";
|
|
2913
|
-
this._hemiLight = new HemisphereLight(16777215, 16777215, 2);
|
|
2914
|
-
this._hemiLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
2915
|
-
this._hemiLight.position.set(0, 50, 0);
|
|
2916
|
-
this.add(this._hemiLight);
|
|
2917
|
-
this._dirLight = new DirectionalLight(16777215, 3);
|
|
2918
|
-
this._dirLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
2919
|
-
this._dirLight.position.set(1, 1.75, 1);
|
|
2920
|
-
this._dirLight.position.multiplyScalar(30);
|
|
2921
|
-
this._dirLight.castShadow = true;
|
|
2922
|
-
this._dirLight.shadow.mapSize.width = 2048;
|
|
2923
|
-
this._dirLight.shadow.mapSize.height = 2048;
|
|
2924
|
-
const d = 5;
|
|
2925
|
-
this._dirLight.shadow.camera.left = -d;
|
|
2926
|
-
this._dirLight.shadow.camera.right = d;
|
|
2927
|
-
this._dirLight.shadow.camera.top = d;
|
|
2928
|
-
this._dirLight.shadow.camera.bottom = -d;
|
|
2929
|
-
this._dirLight.shadow.camera.far = 3500;
|
|
2930
|
-
this.add(this._dirLight);
|
|
2931
|
-
}
|
|
2932
|
-
SetColor(color) {
|
|
2933
|
-
this._hemiLight.color = color;
|
|
2934
|
-
this._dirLight.color = color;
|
|
2935
|
-
}
|
|
2936
|
-
SetIntensity(intensity) {
|
|
2937
|
-
this._hemiLight.intensity = intensity * 2;
|
|
2938
|
-
this._dirLight.intensity = intensity * 3;
|
|
2939
|
-
}
|
|
2940
|
-
SetEnabled(enabled) {
|
|
2941
|
-
this._hemiLight.visible = enabled;
|
|
2942
|
-
this._dirLight.visible = enabled;
|
|
2943
|
-
}
|
|
2944
|
-
};
|
|
2945
|
-
|
|
2946
|
-
// src/model/Model.ts
|
|
2947
|
-
init_VisibilityLayerMask();
|
|
2948
|
-
import { MeshStandardMaterial, Raycaster as Raycaster3, Vector3 as Vector36 } from "three";
|
|
2949
|
-
|
|
2950
|
-
// src/helper/findSceneRecursive/findSceneRecursive.ts
|
|
2951
|
-
var findSceneRecursive = (object) => {
|
|
2952
|
-
if (object.parent) {
|
|
2953
|
-
return findSceneRecursive(object.parent);
|
|
2954
|
-
}
|
|
2955
|
-
return object;
|
|
2956
|
-
};
|
|
2957
|
-
|
|
2958
|
-
// src/node/Node.ts
|
|
2959
|
-
init_VisibilityLayerMask();
|
|
2960
|
-
import { Box3, Object3D as Object3D7, Vector3 as Vector35 } from "three";
|
|
2961
|
-
var DIVENode = class extends Object3D7 {
|
|
2962
|
-
constructor() {
|
|
2963
|
-
super();
|
|
2964
|
-
this.isDIVENode = true;
|
|
2965
|
-
this.isSelectable = true;
|
|
2966
|
-
this.isMovable = true;
|
|
2967
|
-
this.gizmo = null;
|
|
2968
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
2969
|
-
this._positionWorldBuffer = new Vector35();
|
|
2970
|
-
this._boundingBox = new Box3();
|
|
2971
|
-
}
|
|
2972
|
-
SetPosition(position) {
|
|
2973
|
-
if (!this.parent) {
|
|
2974
|
-
this.position.set(position.x, position.y, position.z);
|
|
2975
|
-
return;
|
|
2976
|
-
}
|
|
2977
|
-
const newPosition = new Vector35(position.x, position.y, position.z);
|
|
2978
|
-
this.position.copy(this.parent.worldToLocal(newPosition));
|
|
2979
|
-
if ("isDIVEGroup" in this.parent) {
|
|
2980
|
-
this.parent.UpdateLineTo(this);
|
|
2981
|
-
}
|
|
2982
|
-
}
|
|
2983
|
-
SetRotation(rotation) {
|
|
2984
|
-
this.rotation.set(rotation.x, rotation.y, rotation.z);
|
|
2985
|
-
}
|
|
2986
|
-
SetScale(scale) {
|
|
2987
|
-
this.scale.set(scale.x, scale.y, scale.z);
|
|
2988
|
-
}
|
|
2989
|
-
SetVisibility(visible) {
|
|
2990
|
-
this.visible = visible;
|
|
2991
|
-
}
|
|
2992
|
-
SetToWorldOrigin() {
|
|
2993
|
-
var _a;
|
|
2994
|
-
this.position.set(0, 0, 0);
|
|
2995
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
2996
|
-
"UPDATE_OBJECT",
|
|
2997
|
-
{
|
|
2998
|
-
id: this.userData.id,
|
|
2999
|
-
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
3000
|
-
rotation: this.rotation,
|
|
3001
|
-
scale: this.scale
|
|
3002
|
-
}
|
|
3003
|
-
);
|
|
3004
|
-
}
|
|
3005
|
-
/**
|
|
3006
|
-
* Can be called when the object is moved from a foreign object (gizmo, parent, etc.) to update the object's position.
|
|
3007
|
-
*/
|
|
3008
|
-
onMove() {
|
|
3009
|
-
var _a;
|
|
3010
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
3011
|
-
"UPDATE_OBJECT",
|
|
3012
|
-
{
|
|
3013
|
-
id: this.userData.id,
|
|
3014
|
-
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
3015
|
-
rotation: this.rotation,
|
|
3016
|
-
scale: this.scale
|
|
3017
|
-
}
|
|
3018
|
-
);
|
|
3019
|
-
}
|
|
3020
|
-
onSelect() {
|
|
3021
|
-
var _a;
|
|
3022
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
3023
|
-
"SELECT_OBJECT",
|
|
3024
|
-
{ id: this.userData.id }
|
|
3025
|
-
);
|
|
3026
|
-
}
|
|
3027
|
-
onDeselect() {
|
|
3028
|
-
var _a;
|
|
3029
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction(
|
|
3030
|
-
"DESELECT_OBJECT",
|
|
3031
|
-
{ id: this.userData.id }
|
|
3032
|
-
);
|
|
3033
|
-
}
|
|
3034
|
-
};
|
|
3035
|
-
|
|
3036
|
-
// src/model/Model.ts
|
|
3037
|
-
var DIVEModel = class extends DIVENode {
|
|
3038
|
-
constructor() {
|
|
3039
|
-
super(...arguments);
|
|
3040
|
-
this.isDIVEModel = true;
|
|
3041
|
-
this._mesh = null;
|
|
3042
|
-
this._material = null;
|
|
3043
|
-
}
|
|
3044
|
-
SetModel(gltf) {
|
|
3045
|
-
this.clear();
|
|
3046
|
-
this._boundingBox.makeEmpty();
|
|
3047
|
-
gltf.scene.traverse((child) => {
|
|
3048
|
-
child.castShadow = true;
|
|
3049
|
-
child.receiveShadow = true;
|
|
3050
|
-
child.layers.mask = this.layers.mask;
|
|
3051
|
-
this._boundingBox.expandByObject(child);
|
|
3052
|
-
if (!this._mesh && "isMesh" in child) {
|
|
3053
|
-
this._mesh = child;
|
|
3054
|
-
if (this._material) {
|
|
3055
|
-
this._mesh.material = this._material;
|
|
3056
|
-
} else {
|
|
3057
|
-
this._material = child.material;
|
|
3058
|
-
}
|
|
3059
|
-
}
|
|
3060
|
-
});
|
|
3061
|
-
this.add(gltf.scene);
|
|
3062
|
-
}
|
|
3063
|
-
SetMaterial(material) {
|
|
3064
|
-
if (!this._material) {
|
|
3065
|
-
this._material = new MeshStandardMaterial();
|
|
3066
|
-
}
|
|
3067
|
-
if (material.vertexColors !== void 0) {
|
|
3068
|
-
this._material.vertexColors = material.vertexColors;
|
|
3069
|
-
}
|
|
3070
|
-
if (material.color !== void 0) {
|
|
3071
|
-
this._material.color.set(material.color);
|
|
3072
|
-
}
|
|
3073
|
-
if (material.map !== void 0) {
|
|
3074
|
-
this._material.map = material.map;
|
|
3075
|
-
}
|
|
3076
|
-
if (material.normalMap !== void 0) {
|
|
3077
|
-
this._material.normalMap = material.normalMap;
|
|
3078
|
-
}
|
|
3079
|
-
if (material.roughness !== void 0) {
|
|
3080
|
-
this._material.roughness = material.roughness;
|
|
3081
|
-
}
|
|
3082
|
-
if (material.roughnessMap !== void 0) {
|
|
3083
|
-
this._material.roughnessMap = material.roughnessMap;
|
|
3084
|
-
if (this._material.roughnessMap) {
|
|
3085
|
-
this._material.roughness = 1;
|
|
3086
|
-
}
|
|
3087
|
-
}
|
|
3088
|
-
if (material.metalness !== void 0) {
|
|
3089
|
-
this._material.metalness = material.metalness;
|
|
3090
|
-
}
|
|
3091
|
-
if (material.metalnessMap !== void 0) {
|
|
3092
|
-
this._material.metalnessMap = material.metalnessMap;
|
|
3093
|
-
if (this._material.metalnessMap) {
|
|
3094
|
-
this._material.metalness = 1;
|
|
3095
|
-
}
|
|
3096
|
-
}
|
|
3097
|
-
if (this._mesh) {
|
|
3098
|
-
this._mesh.material = this._material;
|
|
3099
|
-
}
|
|
3100
|
-
}
|
|
3101
|
-
PlaceOnFloor() {
|
|
3102
|
-
var _a, _b, _c, _d, _e;
|
|
3103
|
-
const worldPos = this.getWorldPosition(this._positionWorldBuffer);
|
|
3104
|
-
const oldWorldPos = worldPos.clone();
|
|
3105
|
-
(_b = (_a = this._mesh) == null ? void 0 : _a.geometry) == null ? void 0 : _b.computeBoundingBox();
|
|
3106
|
-
const meshBB = (_d = (_c = this._mesh) == null ? void 0 : _c.geometry) == null ? void 0 : _d.boundingBox;
|
|
3107
|
-
if (!meshBB || !this._mesh) return;
|
|
3108
|
-
worldPos.y = worldPos.y - this._mesh.localToWorld(meshBB.min.clone()).y;
|
|
3109
|
-
if (worldPos.y === oldWorldPos.y) return;
|
|
3110
|
-
(_e = DIVECommunication.get(this.userData.id)) == null ? void 0 : _e.PerformAction(
|
|
3111
|
-
"UPDATE_OBJECT",
|
|
3112
|
-
{
|
|
3113
|
-
id: this.userData.id,
|
|
3114
|
-
position: worldPos,
|
|
3115
|
-
rotation: this.rotation,
|
|
3116
|
-
scale: this.scale
|
|
3117
|
-
}
|
|
3118
|
-
);
|
|
3119
|
-
}
|
|
3120
|
-
DropIt() {
|
|
3121
|
-
if (!this.parent) {
|
|
3122
|
-
console.warn(
|
|
3123
|
-
"DIVEModel: DropIt() called on a model that is not in the scene.",
|
|
3124
|
-
this
|
|
3125
|
-
);
|
|
3126
|
-
return;
|
|
3127
|
-
}
|
|
3128
|
-
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
3129
|
-
const bbBottomCenter = this.localToWorld(
|
|
3130
|
-
this._boundingBox.getCenter(new Vector36()).multiply(this.scale)
|
|
3131
|
-
);
|
|
3132
|
-
bbBottomCenter.y = bottomY + this.position.y;
|
|
3133
|
-
const raycaster = new Raycaster3(bbBottomCenter, new Vector36(0, -1, 0));
|
|
3134
|
-
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
3135
|
-
const intersections = raycaster.intersectObjects(
|
|
3136
|
-
findSceneRecursive(this).Root.children,
|
|
3137
|
-
true
|
|
3138
|
-
);
|
|
3139
|
-
if (intersections.length > 0) {
|
|
3140
|
-
const mesh = intersections[0].object;
|
|
3141
|
-
mesh.geometry.computeBoundingBox();
|
|
3142
|
-
const meshBB = mesh.geometry.boundingBox;
|
|
3143
|
-
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
3144
|
-
const oldPos = this.position.clone();
|
|
3145
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new Vector36(0, bottomY, 0));
|
|
3146
|
-
this.position.copy(newPos);
|
|
3147
|
-
if (this.position.y === oldPos.y) return;
|
|
3148
|
-
this.onMove();
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3151
|
-
};
|
|
3152
|
-
|
|
3153
|
-
// src/loadingmanager/LoadingManager.ts
|
|
3154
|
-
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
|
3155
|
-
import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader";
|
|
3156
|
-
var DIVELoadingManager = class {
|
|
3157
|
-
// ... maybe extend with other loaders later
|
|
3158
|
-
constructor() {
|
|
3159
|
-
this.progress = /* @__PURE__ */ new Map();
|
|
3160
|
-
this.gltfloader = new GLTFLoader2();
|
|
3161
|
-
this.dracoloader = new DRACOLoader();
|
|
3162
|
-
this.dracoloader.setDecoderPath(
|
|
3163
|
-
"https://www.gstatic.com/draco/v1/decoders/"
|
|
3164
|
-
);
|
|
3165
|
-
this.gltfloader.setDRACOLoader(this.dracoloader);
|
|
3166
|
-
}
|
|
3167
|
-
LoadGLTF(uri) {
|
|
3168
|
-
return __async(this, null, function* () {
|
|
3169
|
-
const progEvent = (p) => {
|
|
3170
|
-
this.progress.set(uri, p.loaded / p.total);
|
|
3171
|
-
};
|
|
3172
|
-
this.progress.set(uri, 0);
|
|
3173
|
-
return new Promise((resolve, reject) => {
|
|
3174
|
-
this.gltfloader.loadAsync(uri, progEvent).then(resolve).catch(reject);
|
|
3175
|
-
});
|
|
3176
|
-
});
|
|
3177
|
-
}
|
|
3178
|
-
PollProgress() {
|
|
3179
|
-
let total = 0;
|
|
3180
|
-
this.progress.forEach((progress) => {
|
|
3181
|
-
total += progress;
|
|
3182
|
-
});
|
|
3183
|
-
if (this.progress.size === 0) return 1;
|
|
3184
|
-
return total / this.progress.size;
|
|
3185
|
-
}
|
|
3186
|
-
};
|
|
3187
|
-
|
|
3188
|
-
// src/primitive/Primitive.ts
|
|
3189
|
-
init_VisibilityLayerMask();
|
|
3190
|
-
import {
|
|
3191
|
-
BoxGeometry,
|
|
3192
|
-
BufferAttribute,
|
|
3193
|
-
BufferGeometry,
|
|
3194
|
-
Color as Color4,
|
|
3195
|
-
ConeGeometry,
|
|
3196
|
-
CylinderGeometry,
|
|
3197
|
-
Mesh as Mesh5,
|
|
3198
|
-
MeshStandardMaterial as MeshStandardMaterial2,
|
|
3199
|
-
Raycaster as Raycaster4,
|
|
3200
|
-
SphereGeometry as SphereGeometry2,
|
|
3201
|
-
Vector3 as Vector37
|
|
3202
|
-
} from "three";
|
|
3203
|
-
var DIVEPrimitive = class extends DIVENode {
|
|
3204
|
-
constructor() {
|
|
3205
|
-
super();
|
|
3206
|
-
this.isDIVEPrimitive = true;
|
|
3207
|
-
this._mesh = new Mesh5();
|
|
3208
|
-
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
3209
|
-
this._mesh.castShadow = true;
|
|
3210
|
-
this._mesh.receiveShadow = true;
|
|
3211
|
-
this._mesh.material = new MeshStandardMaterial2();
|
|
3212
|
-
this.add(this._mesh);
|
|
3213
|
-
}
|
|
3214
|
-
SetGeometry(geometry) {
|
|
3215
|
-
const geo = this.assembleGeometry(geometry);
|
|
3216
|
-
if (!geo) return;
|
|
3217
|
-
this._mesh.geometry = geo;
|
|
3218
|
-
this._boundingBox.setFromObject(this._mesh);
|
|
3219
|
-
}
|
|
3220
|
-
SetMaterial(material) {
|
|
3221
|
-
const primitiveMaterial = this._mesh.material;
|
|
3222
|
-
if (material.vertexColors !== void 0) {
|
|
3223
|
-
primitiveMaterial.vertexColors = material.vertexColors;
|
|
3224
|
-
}
|
|
3225
|
-
if (material.color !== void 0) {
|
|
3226
|
-
primitiveMaterial.color = new Color4(material.color);
|
|
3227
|
-
}
|
|
3228
|
-
if (material.map !== void 0) {
|
|
3229
|
-
primitiveMaterial.map = material.map;
|
|
3230
|
-
}
|
|
3231
|
-
if (material.normalMap !== void 0) {
|
|
3232
|
-
primitiveMaterial.normalMap = material.normalMap;
|
|
3233
|
-
}
|
|
3234
|
-
if (material.roughness !== void 0) {
|
|
3235
|
-
primitiveMaterial.roughness = material.roughness;
|
|
3236
|
-
}
|
|
3237
|
-
if (material.roughnessMap !== void 0) {
|
|
3238
|
-
primitiveMaterial.roughnessMap = material.roughnessMap;
|
|
3239
|
-
if (primitiveMaterial.roughnessMap) {
|
|
3240
|
-
primitiveMaterial.roughness = 1;
|
|
3241
|
-
}
|
|
3242
|
-
}
|
|
3243
|
-
if (material.metalness !== void 0) {
|
|
3244
|
-
primitiveMaterial.metalness = material.metalness;
|
|
3245
|
-
}
|
|
3246
|
-
if (material.metalnessMap !== void 0) {
|
|
3247
|
-
primitiveMaterial.metalnessMap = material.metalnessMap;
|
|
3248
|
-
if (primitiveMaterial.metalnessMap) {
|
|
3249
|
-
primitiveMaterial.metalness = 0;
|
|
3250
|
-
}
|
|
3251
|
-
}
|
|
3252
|
-
if (this._mesh) this._mesh.material = primitiveMaterial;
|
|
3253
|
-
}
|
|
3254
|
-
PlaceOnFloor() {
|
|
3255
|
-
var _a, _b, _c, _d, _e;
|
|
3256
|
-
const worldPos = this.getWorldPosition(this._positionWorldBuffer);
|
|
3257
|
-
const oldWorldPos = worldPos.clone();
|
|
3258
|
-
(_b = (_a = this._mesh) == null ? void 0 : _a.geometry) == null ? void 0 : _b.computeBoundingBox();
|
|
3259
|
-
const meshBB = (_d = (_c = this._mesh) == null ? void 0 : _c.geometry) == null ? void 0 : _d.boundingBox;
|
|
3260
|
-
if (!meshBB || !this._mesh) return;
|
|
3261
|
-
worldPos.y = worldPos.y - this._mesh.localToWorld(meshBB.min.clone()).y;
|
|
3262
|
-
if (worldPos.y === oldWorldPos.y) return;
|
|
3263
|
-
(_e = DIVECommunication.get(this.userData.id)) == null ? void 0 : _e.PerformAction(
|
|
3264
|
-
"UPDATE_OBJECT",
|
|
3265
|
-
{
|
|
3266
|
-
id: this.userData.id,
|
|
3267
|
-
position: worldPos,
|
|
3268
|
-
rotation: this.rotation,
|
|
3269
|
-
scale: this.scale
|
|
3270
|
-
}
|
|
3271
|
-
);
|
|
3272
|
-
}
|
|
3273
|
-
DropIt() {
|
|
3274
|
-
if (!this.parent) {
|
|
3275
|
-
console.warn(
|
|
3276
|
-
"DIVEPrimitive: DropIt() called on a model that is not in the scene.",
|
|
3277
|
-
this
|
|
3278
|
-
);
|
|
3279
|
-
return;
|
|
3280
|
-
}
|
|
3281
|
-
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
3282
|
-
const bbBottomCenter = this.localToWorld(
|
|
3283
|
-
this._boundingBox.getCenter(new Vector37()).multiply(this.scale)
|
|
3284
|
-
);
|
|
3285
|
-
bbBottomCenter.y = bottomY + this.position.y;
|
|
3286
|
-
const raycaster = new Raycaster4(bbBottomCenter, new Vector37(0, -1, 0));
|
|
3287
|
-
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
3288
|
-
const intersections = raycaster.intersectObjects(
|
|
3289
|
-
findSceneRecursive(this).Root.children,
|
|
3290
|
-
true
|
|
3291
|
-
);
|
|
3292
|
-
if (intersections.length > 0) {
|
|
3293
|
-
const mesh = intersections[0].object;
|
|
3294
|
-
mesh.geometry.computeBoundingBox();
|
|
3295
|
-
const meshBB = mesh.geometry.boundingBox;
|
|
3296
|
-
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
3297
|
-
const oldPos = this.position.clone();
|
|
3298
|
-
const newPos = this.position.clone().setY(worldPos.y).sub(new Vector37(0, bottomY, 0));
|
|
3299
|
-
this.position.copy(newPos);
|
|
3300
|
-
if (this.position.y === oldPos.y) return;
|
|
3301
|
-
this.onMove();
|
|
3302
|
-
}
|
|
3303
|
-
}
|
|
3304
|
-
assembleGeometry(geometry) {
|
|
3305
|
-
this._mesh.material.flatShading = false;
|
|
3306
|
-
switch (geometry.name.toLowerCase()) {
|
|
3307
|
-
case "cylinder":
|
|
3308
|
-
return this.createCylinderGeometry(geometry);
|
|
3309
|
-
case "sphere":
|
|
3310
|
-
return this.createSphereGeometry(geometry);
|
|
3311
|
-
case "pyramid":
|
|
3312
|
-
this._mesh.material.flatShading = true;
|
|
3313
|
-
return this.createPyramidGeometry(geometry);
|
|
3314
|
-
case "cube":
|
|
3315
|
-
case "box":
|
|
3316
|
-
return this.createBoxGeometry(geometry);
|
|
3317
|
-
case "cone":
|
|
3318
|
-
return this.createConeGeometry(geometry);
|
|
3319
|
-
case "wall":
|
|
3320
|
-
return this.createWallGeometry(geometry);
|
|
3321
|
-
case "plane":
|
|
3322
|
-
return this.createPlaneGeometry(geometry);
|
|
3323
|
-
default: {
|
|
3324
|
-
console.warn(
|
|
3325
|
-
"DIVEPrimitive.assembleGeometry: Invalid geometry type:",
|
|
3326
|
-
geometry.name.toLowerCase()
|
|
3327
|
-
);
|
|
3328
|
-
return null;
|
|
3329
|
-
}
|
|
3330
|
-
}
|
|
3331
|
-
}
|
|
3332
|
-
createCylinderGeometry(geometry) {
|
|
3333
|
-
const geo = new CylinderGeometry(
|
|
3334
|
-
geometry.width / 2,
|
|
3335
|
-
geometry.width / 2,
|
|
3336
|
-
geometry.height,
|
|
3337
|
-
64
|
|
3338
|
-
);
|
|
3339
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
3340
|
-
return geo;
|
|
3341
|
-
}
|
|
3342
|
-
createSphereGeometry(geometry) {
|
|
3343
|
-
const geo = new SphereGeometry2(geometry.width / 2, 256, 256);
|
|
3344
|
-
return geo;
|
|
3345
|
-
}
|
|
3346
|
-
createPyramidGeometry(geometry) {
|
|
3347
|
-
const vertices = new Float32Array([
|
|
3348
|
-
-geometry.width / 2,
|
|
3349
|
-
0,
|
|
3350
|
-
-geometry.depth / 2,
|
|
3351
|
-
// 0
|
|
3352
|
-
geometry.width / 2,
|
|
3353
|
-
0,
|
|
3354
|
-
-geometry.depth / 2,
|
|
3355
|
-
// 1
|
|
3356
|
-
geometry.width / 2,
|
|
3357
|
-
0,
|
|
3358
|
-
geometry.depth / 2,
|
|
3359
|
-
// 2
|
|
3360
|
-
-geometry.width / 2,
|
|
3361
|
-
0,
|
|
3362
|
-
geometry.depth / 2,
|
|
3363
|
-
// 3
|
|
3364
|
-
0,
|
|
3365
|
-
geometry.height,
|
|
3366
|
-
0
|
|
3367
|
-
]);
|
|
3368
|
-
const indices = new Uint16Array([
|
|
3369
|
-
0,
|
|
3370
|
-
1,
|
|
3371
|
-
2,
|
|
3372
|
-
0,
|
|
3373
|
-
2,
|
|
3374
|
-
3,
|
|
3375
|
-
0,
|
|
3376
|
-
4,
|
|
3377
|
-
1,
|
|
3378
|
-
1,
|
|
3379
|
-
4,
|
|
3380
|
-
2,
|
|
3381
|
-
2,
|
|
3382
|
-
4,
|
|
3383
|
-
3,
|
|
3384
|
-
3,
|
|
3385
|
-
4,
|
|
3386
|
-
0
|
|
3387
|
-
]);
|
|
3388
|
-
const geometryBuffer = new BufferGeometry();
|
|
3389
|
-
geometryBuffer.setAttribute(
|
|
3390
|
-
"position",
|
|
3391
|
-
new BufferAttribute(vertices, 3)
|
|
3392
|
-
);
|
|
3393
|
-
geometryBuffer.setIndex(new BufferAttribute(indices, 1));
|
|
3394
|
-
geometryBuffer.computeVertexNormals();
|
|
3395
|
-
geometryBuffer.computeBoundingBox();
|
|
3396
|
-
geometryBuffer.computeBoundingSphere();
|
|
3397
|
-
return geometryBuffer;
|
|
3398
|
-
}
|
|
3399
|
-
createBoxGeometry(geometry) {
|
|
3400
|
-
const geo = new BoxGeometry(
|
|
3401
|
-
geometry.width,
|
|
3402
|
-
geometry.height,
|
|
3403
|
-
geometry.depth
|
|
3404
|
-
);
|
|
3405
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
3406
|
-
return geo;
|
|
3407
|
-
}
|
|
3408
|
-
createConeGeometry(geometry) {
|
|
3409
|
-
const geo = new ConeGeometry(geometry.width / 2, geometry.height, 256);
|
|
3410
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
3411
|
-
return geo;
|
|
3412
|
-
}
|
|
3413
|
-
createWallGeometry(geometry) {
|
|
3414
|
-
const geo = new BoxGeometry(
|
|
3415
|
-
geometry.width,
|
|
3416
|
-
geometry.height,
|
|
3417
|
-
geometry.depth || 0.05,
|
|
3418
|
-
16
|
|
3419
|
-
);
|
|
3420
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
3421
|
-
return geo;
|
|
3422
|
-
}
|
|
3423
|
-
createPlaneGeometry(geometry) {
|
|
3424
|
-
const geo = new BoxGeometry(
|
|
3425
|
-
geometry.width,
|
|
3426
|
-
geometry.height,
|
|
3427
|
-
geometry.depth
|
|
3428
|
-
);
|
|
3429
|
-
geo.translate(0, geometry.height / 2, 0);
|
|
3430
|
-
return geo;
|
|
3431
|
-
}
|
|
3432
|
-
};
|
|
3433
|
-
|
|
3434
|
-
// src/group/Group.ts
|
|
3435
|
-
import {
|
|
3436
|
-
BufferGeometry as BufferGeometry2,
|
|
3437
|
-
Line,
|
|
3438
|
-
LineDashedMaterial,
|
|
3439
|
-
Vector3 as Vector38
|
|
3440
|
-
} from "three";
|
|
3441
|
-
var DIVEGroup = class extends DIVENode {
|
|
3442
|
-
// lines to children
|
|
3443
|
-
constructor() {
|
|
3444
|
-
super();
|
|
3445
|
-
this.isDIVEGroup = true;
|
|
3446
|
-
this.name = "DIVEGroup";
|
|
3447
|
-
this._members = [];
|
|
3448
|
-
this._lines = [];
|
|
3449
|
-
}
|
|
3450
|
-
// children objects
|
|
3451
|
-
get members() {
|
|
3452
|
-
return this._members;
|
|
3453
|
-
}
|
|
3454
|
-
SetPosition(position) {
|
|
3455
|
-
super.SetPosition(position);
|
|
3456
|
-
this._members.forEach((member) => {
|
|
3457
|
-
if ("isDIVENode" in member) {
|
|
3458
|
-
member.onMove();
|
|
3459
|
-
}
|
|
3460
|
-
});
|
|
3461
|
-
}
|
|
3462
|
-
SetLinesVisibility(visible, object) {
|
|
3463
|
-
if (!object) {
|
|
3464
|
-
this._lines.forEach((line) => {
|
|
3465
|
-
line.visible = visible;
|
|
3466
|
-
});
|
|
3467
|
-
return;
|
|
3468
|
-
}
|
|
3469
|
-
const index = this._members.indexOf(object);
|
|
3470
|
-
if (index === -1) return;
|
|
3471
|
-
this._lines[index].visible = visible;
|
|
3472
|
-
}
|
|
3473
|
-
attach(object) {
|
|
3474
|
-
if (this._members.includes(object)) {
|
|
3475
|
-
return this;
|
|
3476
|
-
}
|
|
3477
|
-
const line = this.createLine();
|
|
3478
|
-
this.add(line);
|
|
3479
|
-
this._lines.push(line);
|
|
3480
|
-
super.attach(object);
|
|
3481
|
-
this._members.push(object);
|
|
3482
|
-
this.updateLineTo(line, object);
|
|
3483
|
-
this.SetLinesVisibility(true, object);
|
|
3484
|
-
return this;
|
|
3485
|
-
}
|
|
3486
|
-
remove(object) {
|
|
3487
|
-
const index = this._members.indexOf(object);
|
|
3488
|
-
if (index === -1) return this;
|
|
3489
|
-
const line = this._lines[index];
|
|
3490
|
-
super.remove(line);
|
|
3491
|
-
this._lines.splice(index, 1);
|
|
3492
|
-
super.remove(object);
|
|
3493
|
-
this._members.splice(index, 1);
|
|
3494
|
-
return this;
|
|
3495
|
-
}
|
|
3496
|
-
UpdateLineTo(object) {
|
|
3497
|
-
const index = this._members.indexOf(object);
|
|
3498
|
-
if (index === -1) return;
|
|
3499
|
-
this.updateLineTo(this._lines[index], object);
|
|
3500
|
-
}
|
|
3501
|
-
/**
|
|
3502
|
-
* Adds a line to this grouo as last child.
|
|
3503
|
-
*/
|
|
3504
|
-
createLine() {
|
|
3505
|
-
const geo = new BufferGeometry2();
|
|
3506
|
-
const mat = new LineDashedMaterial({
|
|
3507
|
-
color: 6710886,
|
|
3508
|
-
dashSize: 0.05,
|
|
3509
|
-
gapSize: 0.025
|
|
3510
|
-
});
|
|
3511
|
-
const line = new Line(geo, mat);
|
|
3512
|
-
line.visible = false;
|
|
3513
|
-
return line;
|
|
3514
|
-
}
|
|
3515
|
-
/**
|
|
3516
|
-
* Updates a line to the object.
|
|
3517
|
-
*/
|
|
3518
|
-
updateLineTo(line, object) {
|
|
3519
|
-
line.geometry.setFromPoints([
|
|
3520
|
-
new Vector38(0, 0, 0),
|
|
3521
|
-
object.position.clone()
|
|
3522
|
-
]);
|
|
3523
|
-
line.computeLineDistances();
|
|
3524
|
-
}
|
|
3525
|
-
// public SetBoundingBoxVisibility(visible: boolean): void {
|
|
3526
|
-
// this._boxMesh.visible = visible;
|
|
3527
|
-
// }
|
|
3528
|
-
// /**
|
|
3529
|
-
// * Recalculates the position of the group based on it's bounding box.
|
|
3530
|
-
// * Children's world positions are kept.
|
|
3531
|
-
// */
|
|
3532
|
-
// private recalculatePosition(): void {
|
|
3533
|
-
// // store all children's world positions
|
|
3534
|
-
// const childrensWorldPositions: Vector3[] = this.children.map((child) => child.getWorldPosition(new Vector3()));
|
|
3535
|
-
// // calculate new center and set it as the group's position
|
|
3536
|
-
// const bbcenter = this.updateBB();
|
|
3537
|
-
// this.position.copy(bbcenter);
|
|
3538
|
-
// // set childrens's positions so their world positions are kept
|
|
3539
|
-
// this.children.forEach((child, i) => {
|
|
3540
|
-
// if (child.uuid === this._boxMesh.uuid) return;
|
|
3541
|
-
// child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
3542
|
-
// });
|
|
3543
|
-
// DIVECommunication.get(this.userData.id)?.PerformAction('UPDATE_OBJECT', { id: this.userData.id, position: this.position });
|
|
3544
|
-
// }
|
|
3545
|
-
// /**
|
|
3546
|
-
// * Updates the bounding box of the group.
|
|
3547
|
-
// * @returns {Vector3} The new center of the bounding box.
|
|
3548
|
-
// */
|
|
3549
|
-
// private updateBB(): Vector3 {
|
|
3550
|
-
// this._boundingBox.makeEmpty();
|
|
3551
|
-
// if (this.children.length === 1) {
|
|
3552
|
-
// // because we always have the box mesh as 1 child
|
|
3553
|
-
// return this.position.clone();
|
|
3554
|
-
// }
|
|
3555
|
-
// this.children.forEach((child) => {
|
|
3556
|
-
// if (child.uuid === this._boxMesh.uuid) return;
|
|
3557
|
-
// this._boundingBox.expandByObject(child);
|
|
3558
|
-
// });
|
|
3559
|
-
// return this._boundingBox.getCenter(new Vector3());
|
|
3560
|
-
// }
|
|
3561
|
-
// private updateBoxMesh(): void {
|
|
3562
|
-
// if (this.children.length === 1) {
|
|
3563
|
-
// // because we always have the box mesh as 1 child
|
|
3564
|
-
// this._boxMesh.visible = false;
|
|
3565
|
-
// return;
|
|
3566
|
-
// }
|
|
3567
|
-
// this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
|
|
3568
|
-
// this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
|
|
3569
|
-
// 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);
|
|
3570
|
-
// this._boxMesh.visible = true;
|
|
3571
|
-
// }
|
|
3572
|
-
};
|
|
3573
|
-
|
|
3574
|
-
// src/scene/root/Root.ts
|
|
3575
|
-
var DIVERoot = class extends Object3D8 {
|
|
3576
|
-
constructor() {
|
|
3577
|
-
super();
|
|
3578
|
-
this.isDIVERoot = true;
|
|
3579
|
-
this.name = "Root";
|
|
3580
|
-
this.loadingManager = new DIVELoadingManager();
|
|
3581
|
-
}
|
|
3582
|
-
ComputeSceneBB() {
|
|
3583
|
-
const bb = new Box32();
|
|
3584
|
-
this.traverse((object) => {
|
|
3585
|
-
if ("isObject3D" in object) {
|
|
3586
|
-
bb.expandByObject(object);
|
|
3587
|
-
}
|
|
3588
|
-
});
|
|
3589
|
-
return bb;
|
|
3590
|
-
}
|
|
3591
|
-
GetSceneObject(object) {
|
|
3592
|
-
let foundObject;
|
|
3593
|
-
this.traverse((object3D) => {
|
|
3594
|
-
if (foundObject) return;
|
|
3595
|
-
if (object3D.userData.id === object.id) {
|
|
3596
|
-
foundObject = object3D;
|
|
3597
|
-
}
|
|
3598
|
-
});
|
|
3599
|
-
return foundObject;
|
|
3600
|
-
}
|
|
3601
|
-
AddSceneObject(object) {
|
|
3602
|
-
switch (object.entityType) {
|
|
3603
|
-
case "pov": {
|
|
3604
|
-
break;
|
|
3605
|
-
}
|
|
3606
|
-
case "light": {
|
|
3607
|
-
this.updateLight(object);
|
|
3608
|
-
break;
|
|
3609
|
-
}
|
|
3610
|
-
case "model": {
|
|
3611
|
-
this.updateModel(object);
|
|
3612
|
-
break;
|
|
3613
|
-
}
|
|
3614
|
-
case "primitive": {
|
|
3615
|
-
this.updatePrimitive(object);
|
|
3616
|
-
break;
|
|
3617
|
-
}
|
|
3618
|
-
case "group": {
|
|
3619
|
-
this.updateGroup(object);
|
|
3620
|
-
break;
|
|
3621
|
-
}
|
|
3622
|
-
default: {
|
|
3623
|
-
console.warn(
|
|
3624
|
-
`DIVERoot.AddSceneObject: Unknown entity type: ${object.entityType}`
|
|
3625
|
-
);
|
|
3626
|
-
}
|
|
3627
|
-
}
|
|
3628
|
-
}
|
|
3629
|
-
UpdateSceneObject(object) {
|
|
3630
|
-
switch (object.entityType) {
|
|
3631
|
-
case "pov": {
|
|
3632
|
-
break;
|
|
3633
|
-
}
|
|
3634
|
-
case "light": {
|
|
3635
|
-
this.updateLight(object);
|
|
3636
|
-
break;
|
|
3637
|
-
}
|
|
3638
|
-
case "model": {
|
|
3639
|
-
this.updateModel(object);
|
|
3640
|
-
break;
|
|
3641
|
-
}
|
|
3642
|
-
case "primitive": {
|
|
3643
|
-
this.updatePrimitive(object);
|
|
3644
|
-
break;
|
|
3645
|
-
}
|
|
3646
|
-
case "group": {
|
|
3647
|
-
this.updateGroup(object);
|
|
3648
|
-
break;
|
|
3649
|
-
}
|
|
3650
|
-
default: {
|
|
3651
|
-
console.warn(
|
|
3652
|
-
`DIVERoot.UpdateSceneObject: Unknown entity type: ${object.entityType}`
|
|
3653
|
-
);
|
|
3654
|
-
}
|
|
3655
|
-
}
|
|
3656
|
-
}
|
|
3657
|
-
DeleteSceneObject(object) {
|
|
3658
|
-
switch (object.entityType) {
|
|
3659
|
-
case "pov": {
|
|
3660
|
-
break;
|
|
3661
|
-
}
|
|
3662
|
-
case "light": {
|
|
3663
|
-
this.deleteLight(object);
|
|
3664
|
-
break;
|
|
3665
|
-
}
|
|
3666
|
-
case "model": {
|
|
3667
|
-
this.deleteModel(object);
|
|
3668
|
-
break;
|
|
3669
|
-
}
|
|
3670
|
-
case "primitive": {
|
|
3671
|
-
this.deletePrimitive(object);
|
|
3672
|
-
break;
|
|
3673
|
-
}
|
|
3674
|
-
case "group": {
|
|
3675
|
-
this.deleteGroup(object);
|
|
3676
|
-
break;
|
|
3677
|
-
}
|
|
3678
|
-
default: {
|
|
3679
|
-
console.warn(
|
|
3680
|
-
`DIVERoot.DeleteSceneObject: Unknown entity type: ${object.entityType}`
|
|
3681
|
-
);
|
|
3682
|
-
}
|
|
3683
|
-
}
|
|
3684
|
-
}
|
|
3685
|
-
PlaceOnFloor(object) {
|
|
3686
|
-
switch (object.entityType) {
|
|
3687
|
-
case "pov":
|
|
3688
|
-
case "light": {
|
|
3689
|
-
break;
|
|
3690
|
-
}
|
|
3691
|
-
case "model":
|
|
3692
|
-
case "primitive": {
|
|
3693
|
-
this.placeOnFloor(object);
|
|
3694
|
-
break;
|
|
3695
|
-
}
|
|
3696
|
-
default: {
|
|
3697
|
-
console.warn(
|
|
3698
|
-
`DIVERoot.PlaceOnFloor: Unknown entity type: ${object.entityType}`
|
|
3699
|
-
);
|
|
3700
|
-
}
|
|
3701
|
-
}
|
|
3702
|
-
}
|
|
3703
|
-
updateLight(light) {
|
|
3704
|
-
let sceneObject = this.GetSceneObject(light);
|
|
3705
|
-
if (!sceneObject) {
|
|
3706
|
-
switch (light.type) {
|
|
3707
|
-
case "scene": {
|
|
3708
|
-
sceneObject = new DIVESceneLight();
|
|
3709
|
-
break;
|
|
3710
|
-
}
|
|
3711
|
-
case "ambient": {
|
|
3712
|
-
sceneObject = new DIVEAmbientLight();
|
|
3713
|
-
break;
|
|
3714
|
-
}
|
|
3715
|
-
case "point": {
|
|
3716
|
-
sceneObject = new DIVEPointLight();
|
|
3717
|
-
break;
|
|
3718
|
-
}
|
|
3719
|
-
default: {
|
|
3720
|
-
console.warn(
|
|
3721
|
-
`DIVERoot.updateLight: Unknown light type: ${light.type}`
|
|
3722
|
-
);
|
|
3723
|
-
return;
|
|
3724
|
-
}
|
|
3725
|
-
}
|
|
3726
|
-
sceneObject.userData.id = light.id;
|
|
3727
|
-
this.add(sceneObject);
|
|
3728
|
-
}
|
|
3729
|
-
if (light.name !== void 0 && light.name !== null)
|
|
3730
|
-
sceneObject.name = light.name;
|
|
3731
|
-
if (light.position !== void 0 && light.position !== null)
|
|
3732
|
-
sceneObject.position.set(
|
|
3733
|
-
light.position.x,
|
|
3734
|
-
light.position.y,
|
|
3735
|
-
light.position.z
|
|
3736
|
-
);
|
|
3737
|
-
if (light.intensity !== void 0 && light.intensity !== null)
|
|
3738
|
-
sceneObject.SetIntensity(
|
|
3739
|
-
light.intensity
|
|
3740
|
-
);
|
|
3741
|
-
if (light.enabled !== void 0 && light.enabled !== null)
|
|
3742
|
-
sceneObject.SetEnabled(
|
|
3743
|
-
light.enabled
|
|
3744
|
-
);
|
|
3745
|
-
if (light.color !== void 0 && light.color !== null)
|
|
3746
|
-
sceneObject.SetColor(
|
|
3747
|
-
new Color5(light.color)
|
|
3748
|
-
);
|
|
3749
|
-
if (light.visible !== void 0 && light.visible !== null)
|
|
3750
|
-
sceneObject.visible = light.visible;
|
|
3751
|
-
if (light.parentId !== void 0)
|
|
3752
|
-
this.setParent(__spreadProps(__spreadValues({}, light), { parentId: light.parentId }));
|
|
3753
|
-
}
|
|
3754
|
-
updateModel(model) {
|
|
3755
|
-
let sceneObject = this.GetSceneObject(model);
|
|
3756
|
-
if (!sceneObject) {
|
|
3757
|
-
const created = new DIVEModel();
|
|
3758
|
-
sceneObject = created;
|
|
3759
|
-
sceneObject.userData.id = model.id;
|
|
3760
|
-
sceneObject.userData.uri = model.uri;
|
|
3761
|
-
this.add(sceneObject);
|
|
3762
|
-
}
|
|
3763
|
-
if (model.uri !== void 0) {
|
|
3764
|
-
this.loadingManager.LoadGLTF(model.uri).then((gltf) => {
|
|
3765
|
-
var _a;
|
|
3766
|
-
sceneObject.SetModel(gltf);
|
|
3767
|
-
(_a = DIVECommunication.get(model.id)) == null ? void 0 : _a.PerformAction(
|
|
3768
|
-
"MODEL_LOADED",
|
|
3769
|
-
{ id: model.id }
|
|
3770
|
-
);
|
|
3771
|
-
});
|
|
3772
|
-
}
|
|
3773
|
-
if (model.name !== void 0) sceneObject.name = model.name;
|
|
3774
|
-
if (model.position !== void 0)
|
|
3775
|
-
sceneObject.SetPosition(model.position);
|
|
3776
|
-
if (model.rotation !== void 0)
|
|
3777
|
-
sceneObject.SetRotation(model.rotation);
|
|
3778
|
-
if (model.scale !== void 0)
|
|
3779
|
-
sceneObject.SetScale(model.scale);
|
|
3780
|
-
if (model.visible !== void 0)
|
|
3781
|
-
sceneObject.SetVisibility(model.visible);
|
|
3782
|
-
if (model.material !== void 0)
|
|
3783
|
-
sceneObject.SetMaterial(model.material);
|
|
3784
|
-
if (model.parentId !== void 0)
|
|
3785
|
-
this.setParent(__spreadProps(__spreadValues({}, model), { parentId: model.parentId }));
|
|
3786
|
-
}
|
|
3787
|
-
updatePrimitive(primitive) {
|
|
3788
|
-
let sceneObject = this.GetSceneObject(primitive);
|
|
3789
|
-
if (!sceneObject) {
|
|
3790
|
-
const created = new DIVEPrimitive();
|
|
3791
|
-
sceneObject = created;
|
|
3792
|
-
sceneObject.userData.id = primitive.id;
|
|
3793
|
-
this.add(sceneObject);
|
|
3794
|
-
}
|
|
3795
|
-
if (primitive.name !== void 0) sceneObject.name = primitive.name;
|
|
3796
|
-
if (primitive.geometry !== void 0)
|
|
3797
|
-
sceneObject.SetGeometry(primitive.geometry);
|
|
3798
|
-
if (primitive.position !== void 0)
|
|
3799
|
-
sceneObject.SetPosition(primitive.position);
|
|
3800
|
-
if (primitive.rotation !== void 0)
|
|
3801
|
-
sceneObject.SetRotation(primitive.rotation);
|
|
3802
|
-
if (primitive.scale !== void 0)
|
|
3803
|
-
sceneObject.SetScale(primitive.scale);
|
|
3804
|
-
if (primitive.visible !== void 0)
|
|
3805
|
-
sceneObject.SetVisibility(primitive.visible);
|
|
3806
|
-
if (primitive.material !== void 0)
|
|
3807
|
-
sceneObject.SetMaterial(primitive.material);
|
|
3808
|
-
if (primitive.parentId !== void 0)
|
|
3809
|
-
this.setParent(__spreadProps(__spreadValues({}, primitive), { parentId: primitive.parentId }));
|
|
3810
|
-
}
|
|
3811
|
-
updateGroup(group) {
|
|
3812
|
-
let sceneObject = this.GetSceneObject(group);
|
|
3813
|
-
if (!sceneObject) {
|
|
3814
|
-
const created = new DIVEGroup();
|
|
3815
|
-
sceneObject = created;
|
|
3816
|
-
sceneObject.userData.id = group.id;
|
|
3817
|
-
this.add(sceneObject);
|
|
3818
|
-
}
|
|
3819
|
-
if (group.name !== void 0) sceneObject.name = group.name;
|
|
3820
|
-
if (group.position !== void 0)
|
|
3821
|
-
sceneObject.SetPosition(group.position);
|
|
3822
|
-
if (group.rotation !== void 0)
|
|
3823
|
-
sceneObject.SetRotation(group.rotation);
|
|
3824
|
-
if (group.scale !== void 0)
|
|
3825
|
-
sceneObject.SetScale(group.scale);
|
|
3826
|
-
if (group.visible !== void 0)
|
|
3827
|
-
sceneObject.SetVisibility(group.visible);
|
|
3828
|
-
if (group.bbVisible !== void 0)
|
|
3829
|
-
sceneObject.SetLinesVisibility(group.bbVisible);
|
|
3830
|
-
if (group.parentId !== void 0)
|
|
3831
|
-
this.setParent(__spreadProps(__spreadValues({}, group), { parentId: group.parentId }));
|
|
3832
|
-
}
|
|
3833
|
-
deleteLight(light) {
|
|
3834
|
-
const sceneObject = this.GetSceneObject(light);
|
|
3835
|
-
if (!sceneObject) {
|
|
3836
|
-
console.warn(
|
|
3837
|
-
`DIVERoot.deleteLight: Light with id ${light.id} not found`
|
|
3838
|
-
);
|
|
3839
|
-
return;
|
|
3840
|
-
}
|
|
3841
|
-
this.detachTransformControls(sceneObject);
|
|
3842
|
-
sceneObject.parent.remove(sceneObject);
|
|
3843
|
-
}
|
|
3844
|
-
deleteModel(model) {
|
|
3845
|
-
const sceneObject = this.GetSceneObject(model);
|
|
3846
|
-
if (!sceneObject) {
|
|
3847
|
-
console.warn(
|
|
3848
|
-
`DIVERoot.deleteModel: Model with id ${model.id} not found`
|
|
3849
|
-
);
|
|
3850
|
-
return;
|
|
3851
|
-
}
|
|
3852
|
-
this.detachTransformControls(sceneObject);
|
|
3853
|
-
sceneObject.parent.remove(sceneObject);
|
|
3854
|
-
}
|
|
3855
|
-
deletePrimitive(primitive) {
|
|
3856
|
-
const sceneObject = this.GetSceneObject(primitive);
|
|
3857
|
-
if (!sceneObject) {
|
|
3858
|
-
console.warn(
|
|
3859
|
-
`DIVERoot.deletePrimitive: Primitive with id ${primitive.id} not found`
|
|
3860
|
-
);
|
|
3861
|
-
return;
|
|
3862
|
-
}
|
|
3863
|
-
this.detachTransformControls(sceneObject);
|
|
3864
|
-
sceneObject.parent.remove(sceneObject);
|
|
3865
|
-
}
|
|
3866
|
-
deleteGroup(group) {
|
|
3867
|
-
const sceneObject = this.GetSceneObject(group);
|
|
3868
|
-
if (!sceneObject) {
|
|
3869
|
-
console.warn(
|
|
3870
|
-
`DIVERoot.deleteGroup: Group with id ${group.id} not found`
|
|
3871
|
-
);
|
|
3872
|
-
return;
|
|
3873
|
-
}
|
|
3874
|
-
this.detachTransformControls(sceneObject);
|
|
3875
|
-
for (let i = sceneObject.members.length - 1; i >= 0; i--) {
|
|
3876
|
-
this.attach(sceneObject.members[i]);
|
|
3877
|
-
}
|
|
3878
|
-
sceneObject.parent.remove(sceneObject);
|
|
3879
|
-
}
|
|
3880
|
-
placeOnFloor(object) {
|
|
3881
|
-
const sceneObject = this.GetSceneObject(object);
|
|
3882
|
-
if (!sceneObject) return;
|
|
3883
|
-
sceneObject.PlaceOnFloor();
|
|
3884
|
-
}
|
|
3885
|
-
setParent(object) {
|
|
3886
|
-
const sceneObject = this.GetSceneObject(object);
|
|
3887
|
-
if (!sceneObject) return;
|
|
3888
|
-
if (object.parentId !== null) {
|
|
3889
|
-
const parent = this.GetSceneObject({
|
|
3890
|
-
id: object.parentId
|
|
3891
|
-
});
|
|
3892
|
-
if (!parent) return;
|
|
3893
|
-
parent.attach(sceneObject);
|
|
3894
|
-
} else {
|
|
3895
|
-
this.attach(sceneObject);
|
|
3896
|
-
}
|
|
3897
|
-
}
|
|
3898
|
-
detachTransformControls(object) {
|
|
3899
|
-
this.findScene(object).children.find((object2) => {
|
|
3900
|
-
if ("isTransformControls" in object2) {
|
|
3901
|
-
object2.detach();
|
|
3902
|
-
}
|
|
3903
|
-
});
|
|
3904
|
-
}
|
|
3905
|
-
findScene(object) {
|
|
3906
|
-
if (object.parent !== null) {
|
|
3907
|
-
return this.findScene(object.parent);
|
|
3908
|
-
}
|
|
3909
|
-
return object;
|
|
3910
|
-
}
|
|
3911
|
-
};
|
|
3912
|
-
|
|
3913
|
-
// src/constant/GridColors.ts
|
|
3914
|
-
var GRID_CENTER_LINE_COLOR = "#888888";
|
|
3915
|
-
var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
3916
|
-
|
|
3917
|
-
// src/grid/Grid.ts
|
|
3918
|
-
init_VisibilityLayerMask();
|
|
3919
|
-
import { GridHelper, Object3D as Object3D9 } from "three";
|
|
3920
|
-
var DIVEGrid = class extends Object3D9 {
|
|
3921
|
-
constructor() {
|
|
3922
|
-
super();
|
|
3923
|
-
this.name = "Grid";
|
|
3924
|
-
const grid = new GridHelper(
|
|
3925
|
-
100,
|
|
3926
|
-
100,
|
|
3927
|
-
GRID_CENTER_LINE_COLOR,
|
|
3928
|
-
GRID_SIDE_LINE_COLOR
|
|
3929
|
-
);
|
|
3930
|
-
grid.material.depthTest = false;
|
|
3931
|
-
grid.layers.mask = HELPER_LAYER_MASK;
|
|
3932
|
-
this.add(grid);
|
|
3933
|
-
}
|
|
3934
|
-
SetVisibility(visible) {
|
|
3935
|
-
this.visible = visible;
|
|
3936
|
-
}
|
|
3937
|
-
};
|
|
3938
|
-
|
|
3939
|
-
// src/primitive/floor/Floor.ts
|
|
3940
|
-
init_VisibilityLayerMask();
|
|
3941
|
-
import {
|
|
3942
|
-
Color as Color6,
|
|
3943
|
-
Mesh as Mesh6,
|
|
3944
|
-
MeshStandardMaterial as MeshStandardMaterial3,
|
|
3945
|
-
PlaneGeometry
|
|
3946
|
-
} from "three";
|
|
3947
|
-
var DIVEFloor = class extends Mesh6 {
|
|
3948
|
-
constructor() {
|
|
3949
|
-
super(
|
|
3950
|
-
new PlaneGeometry(1e4, 1e4),
|
|
3951
|
-
new MeshStandardMaterial3({
|
|
3952
|
-
color: new Color6(150 / 255, 150 / 255, 150 / 255)
|
|
3953
|
-
})
|
|
3954
|
-
);
|
|
3955
|
-
this.isFloor = true;
|
|
3956
|
-
this.name = "Floor";
|
|
3957
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
3958
|
-
this.receiveShadow = true;
|
|
3959
|
-
this.rotateX(-Math.PI / 2);
|
|
3960
|
-
}
|
|
3961
|
-
SetVisibility(visible) {
|
|
3962
|
-
this.visible = visible;
|
|
3963
|
-
}
|
|
3964
|
-
SetColor(color) {
|
|
3965
|
-
this.material.color = new Color6(color);
|
|
3966
|
-
}
|
|
3967
|
-
};
|
|
3968
|
-
|
|
3969
|
-
// src/scene/xrroot/XRRoot.ts
|
|
3970
|
-
import { Mesh as Mesh7, Object3D as Object3D11, PlaneGeometry as PlaneGeometry2, ShadowMaterial } from "three";
|
|
3971
|
-
|
|
3972
|
-
// src/scene/xrroot/xrlightroot/XRLightRoot.ts
|
|
3973
|
-
init_VisibilityLayerMask();
|
|
3974
|
-
import { XREstimatedLight } from "three/examples/jsm/webxr/XREstimatedLight";
|
|
3975
|
-
import { Object3D as Object3D10 } from "three";
|
|
3976
|
-
var DIVEXRLightRoot = class extends Object3D10 {
|
|
3977
|
-
constructor(scene) {
|
|
3978
|
-
super();
|
|
3979
|
-
this.name = "XRLightRoot";
|
|
3980
|
-
this._scene = scene;
|
|
3981
|
-
this._xrLight = null;
|
|
3982
|
-
this._lightRoot = new DIVERoot();
|
|
3983
|
-
this._lightRoot.UpdateSceneObject({
|
|
3984
|
-
id: "XRSceneLight",
|
|
3985
|
-
entityType: "light",
|
|
3986
|
-
name: "XRSceneLight",
|
|
3987
|
-
type: "scene",
|
|
3988
|
-
color: 16777215,
|
|
3989
|
-
intensity: 1,
|
|
3990
|
-
enabled: true,
|
|
3991
|
-
visible: true
|
|
3992
|
-
});
|
|
3993
|
-
this.add(this._lightRoot);
|
|
3994
|
-
}
|
|
3995
|
-
InitLightEstimation(renderer) {
|
|
3996
|
-
if (!this._xrLight) {
|
|
3997
|
-
this._xrLight = new XREstimatedLight(renderer, true);
|
|
3998
|
-
this._xrLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
3999
|
-
this.add(this._xrLight);
|
|
4000
|
-
}
|
|
4001
|
-
this._xrLight.addEventListener("estimationstart", () => {
|
|
4002
|
-
this.onEstimationStart();
|
|
4003
|
-
});
|
|
4004
|
-
this._xrLight.addEventListener("estimationend", () => {
|
|
4005
|
-
this.onEstimationEnd();
|
|
4006
|
-
});
|
|
4007
|
-
}
|
|
4008
|
-
DisposeLightEstimation() {
|
|
4009
|
-
if (!this._xrLight) return;
|
|
4010
|
-
this._xrLight.removeEventListener("estimationstart", () => {
|
|
4011
|
-
this.onEstimationStart();
|
|
4012
|
-
});
|
|
4013
|
-
this._xrLight.removeEventListener("estimationend", () => {
|
|
4014
|
-
this.onEstimationEnd();
|
|
4015
|
-
});
|
|
4016
|
-
}
|
|
4017
|
-
onEstimationStart() {
|
|
4018
|
-
this._lightRoot.visible = false;
|
|
4019
|
-
if (!this._xrLight) return;
|
|
4020
|
-
if (this._xrLight.environment) {
|
|
4021
|
-
this._scene.environment = this._xrLight.environment;
|
|
4022
|
-
}
|
|
4023
|
-
}
|
|
4024
|
-
onEstimationEnd() {
|
|
4025
|
-
this._lightRoot.visible = true;
|
|
4026
|
-
this._scene.environment = null;
|
|
4027
|
-
if (!this._xrLight) return;
|
|
4028
|
-
}
|
|
4029
|
-
};
|
|
4030
|
-
|
|
4031
|
-
// src/scene/xrroot/XRRoot.ts
|
|
4032
|
-
var DIVEXRRoot = class extends Object3D11 {
|
|
4033
|
-
get XRModelRoot() {
|
|
4034
|
-
return this._xrModelRoot;
|
|
4035
|
-
}
|
|
4036
|
-
get XRLightRoot() {
|
|
4037
|
-
return this._xrLightRoot;
|
|
4038
|
-
}
|
|
4039
|
-
get XRHandNode() {
|
|
4040
|
-
return this._xrHandNode;
|
|
4041
|
-
}
|
|
4042
|
-
constructor(scene) {
|
|
4043
|
-
super();
|
|
4044
|
-
this.name = "XRRoot";
|
|
4045
|
-
this._xrModelRoot = new DIVERoot();
|
|
4046
|
-
this._xrModelRoot.name = "XRModelRoot";
|
|
4047
|
-
this.add(this._xrModelRoot);
|
|
4048
|
-
this._xrShadowPlane = new Mesh7(
|
|
4049
|
-
new PlaneGeometry2(100, 100),
|
|
4050
|
-
new ShadowMaterial({ opacity: 1, transparent: true })
|
|
4051
|
-
);
|
|
4052
|
-
this._xrModelRoot.add(this._xrShadowPlane);
|
|
4053
|
-
this._xrLightRoot = new DIVEXRLightRoot(scene);
|
|
4054
|
-
this._xrLightRoot.name = "XRLightRoot";
|
|
4055
|
-
this.add(this._xrLightRoot);
|
|
4056
|
-
this._xrHandNode = new Object3D11();
|
|
4057
|
-
this._xrHandNode.name = "XRHandNode";
|
|
4058
|
-
this.add(this._xrHandNode);
|
|
4059
|
-
}
|
|
4060
|
-
InitLightEstimation(renderer) {
|
|
4061
|
-
this._xrLightRoot.InitLightEstimation(renderer);
|
|
4062
|
-
}
|
|
4063
|
-
DisposeLightEstimation() {
|
|
4064
|
-
this._xrLightRoot.DisposeLightEstimation();
|
|
4065
|
-
}
|
|
4066
|
-
};
|
|
4067
|
-
|
|
4068
|
-
// src/scene/Scene.ts
|
|
4069
|
-
var DIVEScene = class extends Scene2 {
|
|
4070
|
-
get Root() {
|
|
4071
|
-
return this._root;
|
|
4072
|
-
}
|
|
4073
|
-
get XRRoot() {
|
|
4074
|
-
return this._xrRoot;
|
|
4075
|
-
}
|
|
4076
|
-
get Floor() {
|
|
4077
|
-
return this._floor;
|
|
4078
|
-
}
|
|
4079
|
-
get Grid() {
|
|
4080
|
-
return this._grid;
|
|
4081
|
-
}
|
|
4082
|
-
constructor() {
|
|
4083
|
-
super();
|
|
4084
|
-
this.background = new Color7(16777215);
|
|
4085
|
-
this._root = new DIVERoot();
|
|
4086
|
-
this.add(this._root);
|
|
4087
|
-
this._floor = new DIVEFloor();
|
|
4088
|
-
this.add(this._floor);
|
|
4089
|
-
this._grid = new DIVEGrid();
|
|
4090
|
-
this.add(this._grid);
|
|
4091
|
-
this._xrRoot = new DIVEXRRoot(this);
|
|
4092
|
-
this._xrRoot.visible = false;
|
|
4093
|
-
this.add(this._xrRoot);
|
|
4094
|
-
}
|
|
4095
|
-
InitXR(renderer) {
|
|
4096
|
-
this._root.visible = false;
|
|
4097
|
-
this._xrRoot.visible = true;
|
|
4098
|
-
this._xrRoot.InitLightEstimation(renderer);
|
|
4099
|
-
}
|
|
4100
|
-
DisposeXR() {
|
|
4101
|
-
this._root.visible = true;
|
|
4102
|
-
this._xrRoot.visible = false;
|
|
4103
|
-
this._xrRoot.DisposeLightEstimation();
|
|
4104
|
-
}
|
|
4105
|
-
SetBackground(color) {
|
|
4106
|
-
this.background = new Color7(color);
|
|
4107
|
-
}
|
|
4108
|
-
ComputeSceneBB() {
|
|
4109
|
-
return this.Root.ComputeSceneBB();
|
|
4110
|
-
}
|
|
4111
|
-
GetSceneObject(object) {
|
|
4112
|
-
return this.Root.GetSceneObject(object);
|
|
4113
|
-
}
|
|
4114
|
-
AddSceneObject(object) {
|
|
4115
|
-
this.Root.AddSceneObject(object);
|
|
4116
|
-
}
|
|
4117
|
-
UpdateSceneObject(object) {
|
|
4118
|
-
this.Root.UpdateSceneObject(object);
|
|
4119
|
-
}
|
|
4120
|
-
DeleteSceneObject(object) {
|
|
4121
|
-
this.Root.DeleteSceneObject(object);
|
|
4122
|
-
}
|
|
4123
|
-
PlaceOnFloor(object) {
|
|
4124
|
-
this.Root.PlaceOnFloor(object);
|
|
4125
|
-
}
|
|
4126
|
-
};
|
|
4127
|
-
|
|
4128
|
-
// src/dive.ts
|
|
4129
|
-
init_PerspectiveCamera();
|
|
4130
|
-
|
|
4131
|
-
// src/controls/OrbitControls.ts
|
|
4132
|
-
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
|
|
4133
|
-
import { MathUtils as MathUtils2, Vector3 as Vector39 } from "three";
|
|
4134
|
-
import { Easing } from "@tweenjs/tween.js";
|
|
4135
|
-
var DIVEOrbitControlsDefaultSettings = {
|
|
4136
|
-
enableDamping: true,
|
|
4137
|
-
dampingFactor: 0.04
|
|
4138
|
-
};
|
|
4139
|
-
var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
4140
|
-
constructor(camera, renderer, animationSystem, settings = DIVEOrbitControlsDefaultSettings) {
|
|
4141
|
-
super(camera, renderer.domElement);
|
|
4142
|
-
this.last = null;
|
|
4143
|
-
this.animating = false;
|
|
4144
|
-
this.locked = false;
|
|
4145
|
-
this.stopMoveTo = () => {
|
|
4146
|
-
};
|
|
4147
|
-
this.stopRevertLast = () => {
|
|
4148
|
-
};
|
|
4149
|
-
this._removePreRenderCallback = () => {
|
|
4150
|
-
};
|
|
4151
|
-
this.preRenderCallback = () => {
|
|
4152
|
-
if (this.locked) return;
|
|
4153
|
-
this.update();
|
|
4154
|
-
};
|
|
4155
|
-
this._animationSystem = animationSystem;
|
|
4156
|
-
this.domElement = renderer.domElement;
|
|
4157
|
-
this.object = camera;
|
|
4158
|
-
const id = renderer.AddPreRenderCallback(() => {
|
|
4159
|
-
this.preRenderCallback();
|
|
4160
|
-
});
|
|
4161
|
-
this._removePreRenderCallback = () => {
|
|
4162
|
-
renderer.RemovePreRenderCallback(id);
|
|
4163
|
-
};
|
|
4164
|
-
this.enableDamping = settings.enableDamping || DIVEOrbitControlsDefaultSettings.enableDamping;
|
|
4165
|
-
this.dampingFactor = settings.dampingFactor || DIVEOrbitControlsDefaultSettings.dampingFactor;
|
|
4166
|
-
this.object.position.set(0, 2, 2);
|
|
4167
|
-
this.target.copy({ x: 0, y: 0.5, z: 0 });
|
|
4168
|
-
this.update();
|
|
4169
|
-
}
|
|
4170
|
-
Dispose() {
|
|
4171
|
-
this._removePreRenderCallback();
|
|
4172
|
-
this.dispose();
|
|
4173
|
-
}
|
|
4174
|
-
ComputeEncompassingView(bb) {
|
|
4175
|
-
const center = bb.getCenter(new Vector39());
|
|
4176
|
-
const size = bb.getSize(new Vector39());
|
|
4177
|
-
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
4178
|
-
const direction = this.object.position.clone().normalize();
|
|
4179
|
-
return {
|
|
4180
|
-
position: direction.multiplyScalar(distance),
|
|
4181
|
-
target: center
|
|
4182
|
-
};
|
|
4183
|
-
}
|
|
4184
|
-
ZoomIn(by) {
|
|
4185
|
-
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
4186
|
-
const { minDistance, maxDistance } = this;
|
|
4187
|
-
this.minDistance = this.maxDistance = MathUtils2.clamp(
|
|
4188
|
-
this.getDistance() - zoomBy,
|
|
4189
|
-
minDistance + zoomBy,
|
|
4190
|
-
maxDistance - zoomBy
|
|
4191
|
-
);
|
|
4192
|
-
this.update();
|
|
4193
|
-
this.minDistance = minDistance;
|
|
4194
|
-
this.maxDistance = maxDistance;
|
|
4195
|
-
}
|
|
4196
|
-
ZoomOut(by) {
|
|
4197
|
-
const zoomBy = by || _DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
|
|
4198
|
-
const { minDistance, maxDistance } = this;
|
|
4199
|
-
this.minDistance = this.maxDistance = MathUtils2.clamp(
|
|
4200
|
-
this.getDistance() + zoomBy,
|
|
4201
|
-
minDistance + zoomBy,
|
|
4202
|
-
maxDistance - zoomBy
|
|
4203
|
-
);
|
|
4204
|
-
this.update();
|
|
4205
|
-
this.minDistance = minDistance;
|
|
4206
|
-
this.maxDistance = maxDistance;
|
|
4207
|
-
}
|
|
4208
|
-
MoveTo(pos, target, duration, lock) {
|
|
4209
|
-
if (this.animating) return;
|
|
4210
|
-
const toPosition = pos || this.object.position.clone();
|
|
4211
|
-
const toTarget = target || this.target.clone();
|
|
4212
|
-
this.stopRevertLast();
|
|
4213
|
-
if (!this.locked)
|
|
4214
|
-
this.last = {
|
|
4215
|
-
pos: this.object.position.clone(),
|
|
4216
|
-
target: this.target.clone()
|
|
4217
|
-
};
|
|
4218
|
-
this.animating = duration > 0;
|
|
4219
|
-
this.locked = lock;
|
|
4220
|
-
this.enabled = false;
|
|
4221
|
-
const tweenPos = this._animationSystem.Animate(this.object.position).to(toPosition, duration).easing(Easing.Quadratic.Out).start();
|
|
4222
|
-
const tweenQuat = this._animationSystem.Animate(this.target).to(toTarget, duration).easing(Easing.Quadratic.Out).onUpdate(() => {
|
|
4223
|
-
this.object.lookAt(this.target);
|
|
4224
|
-
}).onComplete(() => {
|
|
4225
|
-
this.animating = false;
|
|
4226
|
-
this.enabled = !lock;
|
|
4227
|
-
}).start();
|
|
4228
|
-
this.stopMoveTo = () => {
|
|
4229
|
-
tweenPos.stop();
|
|
4230
|
-
tweenQuat.stop();
|
|
4231
|
-
};
|
|
4232
|
-
}
|
|
4233
|
-
RevertLast(duration) {
|
|
4234
|
-
if (this.animating || !this.locked) return;
|
|
4235
|
-
this.stopMoveTo();
|
|
4236
|
-
this.animating = duration > 0;
|
|
4237
|
-
this.enabled = false;
|
|
4238
|
-
const { pos, target } = this.last;
|
|
4239
|
-
const tweenPos = this._animationSystem.Animate(this.object.position).to(pos, duration).easing(Easing.Quadratic.Out).start();
|
|
4240
|
-
const tweenQuat = this._animationSystem.Animate(this.target).to(target, duration).easing(Easing.Quadratic.Out).onUpdate(() => {
|
|
4241
|
-
this.object.lookAt(this.target);
|
|
4242
|
-
}).onComplete(() => {
|
|
4243
|
-
this.animating = false;
|
|
4244
|
-
this.locked = false;
|
|
4245
|
-
this.enabled = true;
|
|
4246
|
-
}).start();
|
|
4247
|
-
this.stopRevertLast = () => {
|
|
4248
|
-
tweenPos.stop();
|
|
4249
|
-
tweenQuat.stop();
|
|
4250
|
-
};
|
|
4251
|
-
}
|
|
4252
|
-
};
|
|
4253
|
-
_DIVEOrbitControls.DEFAULT_ZOOM_FACTOR = 1;
|
|
4254
|
-
var DIVEOrbitControls = _DIVEOrbitControls;
|
|
4255
|
-
|
|
4256
|
-
// src/toolbox/Toolbox.ts
|
|
4257
|
-
var DIVEToolbox = class {
|
|
4258
|
-
get selectTool() {
|
|
4259
|
-
if (!this._selectTool) {
|
|
4260
|
-
const DIVESelectTool2 = (init_SelectTool(), __toCommonJS(SelectTool_exports)).DIVESelectTool;
|
|
4261
|
-
this._selectTool = new DIVESelectTool2(
|
|
4262
|
-
this._scene,
|
|
4263
|
-
this._controller
|
|
4264
|
-
);
|
|
4265
|
-
}
|
|
4266
|
-
return this._selectTool;
|
|
4267
|
-
}
|
|
4268
|
-
constructor(scene, controller) {
|
|
4269
|
-
this._scene = scene;
|
|
4270
|
-
this._controller = controller;
|
|
4271
|
-
this._selectTool = null;
|
|
4272
|
-
this._activeTool = null;
|
|
4273
|
-
}
|
|
4274
|
-
Dispose() {
|
|
4275
|
-
this.removeEventListeners();
|
|
4276
|
-
}
|
|
4277
|
-
GetActiveTool() {
|
|
4278
|
-
return this._activeTool;
|
|
4279
|
-
}
|
|
4280
|
-
UseTool(tool) {
|
|
4281
|
-
var _a;
|
|
4282
|
-
(_a = this._activeTool) == null ? void 0 : _a.Deactivate();
|
|
4283
|
-
switch (tool) {
|
|
4284
|
-
case "select": {
|
|
4285
|
-
this.addEventListeners();
|
|
4286
|
-
this.selectTool.Activate();
|
|
4287
|
-
this._activeTool = this.selectTool;
|
|
4288
|
-
break;
|
|
4289
|
-
}
|
|
4290
|
-
case "none": {
|
|
4291
|
-
this.removeEventListeners();
|
|
4292
|
-
this._activeTool = null;
|
|
4293
|
-
break;
|
|
4294
|
-
}
|
|
4295
|
-
default: {
|
|
4296
|
-
console.warn(`DIVEToolBox.UseTool: Unknown tool: ${tool}`);
|
|
4297
|
-
}
|
|
4298
|
-
}
|
|
4299
|
-
}
|
|
4300
|
-
SetGizmoMode(mode) {
|
|
4301
|
-
this.selectTool.SetGizmoMode(mode);
|
|
4302
|
-
}
|
|
4303
|
-
SetGizmoVisibility(active) {
|
|
4304
|
-
this.selectTool.SetGizmoVisibility(active);
|
|
4305
|
-
}
|
|
4306
|
-
SetGizmoScaleLinked(linked) {
|
|
4307
|
-
this.selectTool.SetGizmoScaleLinked(linked);
|
|
4308
|
-
}
|
|
4309
|
-
onPointerMove(e) {
|
|
4310
|
-
var _a;
|
|
4311
|
-
(_a = this._activeTool) == null ? void 0 : _a.onPointerMove(e);
|
|
4312
|
-
}
|
|
4313
|
-
onPointerDown(e) {
|
|
4314
|
-
var _a;
|
|
4315
|
-
(_a = this._activeTool) == null ? void 0 : _a.onPointerDown(e);
|
|
4316
|
-
}
|
|
4317
|
-
onPointerUp(e) {
|
|
4318
|
-
var _a;
|
|
4319
|
-
(_a = this._activeTool) == null ? void 0 : _a.onPointerUp(e);
|
|
4320
|
-
}
|
|
4321
|
-
onWheel(e) {
|
|
4322
|
-
var _a;
|
|
4323
|
-
(_a = this._activeTool) == null ? void 0 : _a.onWheel(e);
|
|
4324
|
-
}
|
|
4325
|
-
addEventListeners() {
|
|
4326
|
-
this._controller.domElement.addEventListener(
|
|
4327
|
-
"pointermove",
|
|
4328
|
-
(e) => this.onPointerMove(e)
|
|
4329
|
-
);
|
|
4330
|
-
this._controller.domElement.addEventListener(
|
|
4331
|
-
"pointerdown",
|
|
4332
|
-
(e) => this.onPointerDown(e)
|
|
4333
|
-
);
|
|
4334
|
-
this._controller.domElement.addEventListener(
|
|
4335
|
-
"pointerup",
|
|
4336
|
-
(e) => this.onPointerUp(e)
|
|
4337
|
-
);
|
|
4338
|
-
this._controller.domElement.addEventListener(
|
|
4339
|
-
"wheel",
|
|
4340
|
-
(e) => this.onWheel(e)
|
|
4341
|
-
);
|
|
4342
|
-
}
|
|
4343
|
-
removeEventListeners() {
|
|
4344
|
-
this._controller.domElement.removeEventListener(
|
|
4345
|
-
"pointermove",
|
|
4346
|
-
(e) => this.onPointerMove(e)
|
|
4347
|
-
);
|
|
4348
|
-
this._controller.domElement.removeEventListener(
|
|
4349
|
-
"pointerdown",
|
|
4350
|
-
(e) => this.onPointerDown(e)
|
|
4351
|
-
);
|
|
4352
|
-
this._controller.domElement.removeEventListener(
|
|
4353
|
-
"pointerup",
|
|
4354
|
-
(e) => this.onPointerUp(e)
|
|
4355
|
-
);
|
|
4356
|
-
this._controller.domElement.removeEventListener(
|
|
4357
|
-
"wheel",
|
|
4358
|
-
(e) => this.onWheel(e)
|
|
4359
|
-
);
|
|
4360
|
-
}
|
|
4361
|
-
};
|
|
4362
|
-
DIVEToolbox.DefaultTool = "select";
|
|
4363
|
-
|
|
4364
|
-
// src/animation/AnimationSystem.ts
|
|
4365
|
-
import { Tween, update as updateTween } from "@tweenjs/tween.js";
|
|
4366
|
-
var DIVEAnimationSystem = class {
|
|
4367
|
-
constructor(renderer) {
|
|
4368
|
-
this._renderer = renderer;
|
|
4369
|
-
this._rendererCallbackId = this._renderer.AddPreRenderCallback(() => {
|
|
4370
|
-
this.Update();
|
|
4371
|
-
});
|
|
4372
|
-
}
|
|
4373
|
-
Dispose() {
|
|
4374
|
-
this._renderer.RemovePreRenderCallback(this._rendererCallbackId);
|
|
4375
|
-
}
|
|
4376
|
-
Update() {
|
|
4377
|
-
updateTween();
|
|
4378
|
-
}
|
|
4379
|
-
Animate(object) {
|
|
4380
|
-
return new Tween(object);
|
|
4381
|
-
}
|
|
4382
|
-
};
|
|
4383
|
-
|
|
4384
|
-
// src/axiscamera/AxisCamera.ts
|
|
4385
|
-
init_VisibilityLayerMask();
|
|
4386
|
-
init_AxisHelperColors();
|
|
4387
|
-
import {
|
|
4388
|
-
AxesHelper,
|
|
4389
|
-
Color as Color8,
|
|
4390
|
-
Matrix4 as Matrix44,
|
|
4391
|
-
OrthographicCamera,
|
|
4392
|
-
Vector4
|
|
4393
|
-
} from "three";
|
|
4394
|
-
import SpriteText from "three-spritetext";
|
|
4395
|
-
var DIVEAxisCamera = class extends OrthographicCamera {
|
|
4396
|
-
constructor(renderer, scene, controls) {
|
|
4397
|
-
super(-1, 1, 1, -1, 0.1, 100);
|
|
4398
|
-
this.layers.mask = COORDINATE_LAYER_MASK;
|
|
4399
|
-
this.axesHelper = new AxesHelper(0.5);
|
|
4400
|
-
this.axesHelper.layers.mask = COORDINATE_LAYER_MASK;
|
|
4401
|
-
this.axesHelper.material.depthTest = false;
|
|
4402
|
-
this.axesHelper.position.set(0, 0, -1);
|
|
4403
|
-
this.axesHelper.setColors(
|
|
4404
|
-
new Color8(AxesColorRed),
|
|
4405
|
-
new Color8(AxesColorGreen),
|
|
4406
|
-
new Color8(AxesColorBlue)
|
|
4407
|
-
);
|
|
4408
|
-
const x = new SpriteText("X", 0.2, AxesColorRedLetter);
|
|
4409
|
-
const y = new SpriteText("Y", 0.2, AxesColorGreenLetter);
|
|
4410
|
-
const z = new SpriteText("Z", 0.2, AxesColorBlueLetter);
|
|
4411
|
-
x.layers.mask = COORDINATE_LAYER_MASK;
|
|
4412
|
-
y.layers.mask = COORDINATE_LAYER_MASK;
|
|
4413
|
-
z.layers.mask = COORDINATE_LAYER_MASK;
|
|
4414
|
-
x.position.set(0.7, 0, 0);
|
|
4415
|
-
y.position.set(0, 0.7, 0);
|
|
4416
|
-
z.position.set(0, 0, 0.7);
|
|
4417
|
-
this.axesHelper.add(x);
|
|
4418
|
-
this.axesHelper.add(y);
|
|
4419
|
-
this.axesHelper.add(z);
|
|
4420
|
-
this.add(this.axesHelper);
|
|
4421
|
-
this._renderer = renderer;
|
|
4422
|
-
this._scene = scene;
|
|
4423
|
-
this._scene.add(this);
|
|
4424
|
-
const restoreViewport = new Vector4();
|
|
4425
|
-
this._renderCallbackId = renderer.AddPostRenderCallback(() => {
|
|
4426
|
-
const restoreBackground = scene.background;
|
|
4427
|
-
scene.background = null;
|
|
4428
|
-
renderer.getViewport(restoreViewport);
|
|
4429
|
-
renderer.setViewport(0, 0, 150, 150);
|
|
4430
|
-
renderer.autoClear = false;
|
|
4431
|
-
this.SetFromCameraMatrix(controls.object.matrix);
|
|
4432
|
-
renderer.render(scene, this);
|
|
4433
|
-
renderer.setViewport(restoreViewport);
|
|
4434
|
-
renderer.autoClear = true;
|
|
4435
|
-
scene.background = restoreBackground;
|
|
4436
|
-
});
|
|
4437
|
-
}
|
|
4438
|
-
Dispose() {
|
|
4439
|
-
this._renderer.RemovePostRenderCallback(this._renderCallbackId);
|
|
4440
|
-
this._scene.remove(this);
|
|
4441
|
-
}
|
|
4442
|
-
SetFromCameraMatrix(matrix) {
|
|
4443
|
-
this.axesHelper.rotation.setFromRotationMatrix(
|
|
4444
|
-
new Matrix44().extractRotation(matrix).invert()
|
|
4445
|
-
);
|
|
4446
|
-
}
|
|
4447
|
-
};
|
|
4448
|
-
|
|
4449
|
-
// src/helper/getObjectDelta/getObjectDelta.ts
|
|
4450
|
-
var getObjectDelta = (a, b) => {
|
|
4451
|
-
if (Object.keys(a).length === 0 && Object.keys(b).length === 0) {
|
|
4452
|
-
return {};
|
|
4453
|
-
}
|
|
4454
|
-
if (typeof a !== "object" || typeof b !== "object") {
|
|
4455
|
-
return b;
|
|
4456
|
-
}
|
|
4457
|
-
let delta = {};
|
|
4458
|
-
Object.keys(b).forEach((key) => {
|
|
4459
|
-
if (!Object.keys(a).includes(key)) {
|
|
4460
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
4461
|
-
return;
|
|
4462
|
-
}
|
|
4463
|
-
if (Array.isArray(b[key])) {
|
|
4464
|
-
if (!Array.isArray(a[key])) {
|
|
4465
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
4466
|
-
return;
|
|
4467
|
-
}
|
|
4468
|
-
const aArray = a[key];
|
|
4469
|
-
const bArray = b[key];
|
|
4470
|
-
if (aArray.length === 0 && bArray.length === 0) {
|
|
4471
|
-
delta = __spreadValues({}, delta);
|
|
4472
|
-
return;
|
|
4473
|
-
}
|
|
4474
|
-
if (aArray.length !== bArray.length) {
|
|
4475
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
4476
|
-
return;
|
|
4477
|
-
}
|
|
4478
|
-
const arrayDeltas = [];
|
|
4479
|
-
bArray.forEach((entry, index) => {
|
|
4480
|
-
const inArrayDelta = getObjectDelta(
|
|
4481
|
-
aArray[index],
|
|
4482
|
-
bArray[index]
|
|
4483
|
-
);
|
|
4484
|
-
if (Object.keys(inArrayDelta).length) {
|
|
4485
|
-
arrayDeltas.push(bArray[index]);
|
|
4486
|
-
}
|
|
4487
|
-
});
|
|
4488
|
-
if (Object.keys(arrayDeltas).length) {
|
|
4489
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: arrayDeltas });
|
|
4490
|
-
return;
|
|
4491
|
-
}
|
|
4492
|
-
return;
|
|
4493
|
-
}
|
|
4494
|
-
if (typeof b[key] === "object") {
|
|
4495
|
-
if (typeof a[key] !== "object") {
|
|
4496
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
4497
|
-
return;
|
|
4498
|
-
}
|
|
4499
|
-
const objectDelta = getObjectDelta(
|
|
4500
|
-
a[key],
|
|
4501
|
-
b[key]
|
|
4502
|
-
);
|
|
4503
|
-
if (Object.keys(objectDelta).length) {
|
|
4504
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: objectDelta });
|
|
4505
|
-
return;
|
|
4506
|
-
}
|
|
4507
|
-
}
|
|
4508
|
-
if (a[key] !== b[key]) {
|
|
4509
|
-
delta = __spreadProps(__spreadValues({}, delta), { [key]: b[key] });
|
|
4510
|
-
}
|
|
4511
|
-
});
|
|
4512
|
-
return delta;
|
|
4513
|
-
};
|
|
4514
|
-
|
|
4515
|
-
// src/dive.ts
|
|
4516
|
-
init_Info();
|
|
4517
|
-
import { MathUtils as MathUtils5 } from "three";
|
|
4518
|
-
|
|
4519
|
-
// package.json
|
|
4520
|
-
var package_default = {
|
|
4521
|
-
name: "@shopware-ag/dive",
|
|
4522
|
-
version: "1.18.4",
|
|
4523
|
-
description: "Shopware Spatial Framework",
|
|
4524
|
-
type: "module",
|
|
4525
|
-
main: "./build/dive.cjs",
|
|
4526
|
-
module: "./build/dive.js",
|
|
4527
|
-
types: "./build/dive.d.ts",
|
|
4528
|
-
files: [
|
|
4529
|
-
"build",
|
|
4530
|
-
"LICENSE",
|
|
4531
|
-
"package.json",
|
|
4532
|
-
"README.md",
|
|
4533
|
-
"src"
|
|
4534
|
-
],
|
|
4535
|
-
keywords: [
|
|
4536
|
-
"dive",
|
|
4537
|
-
"shopware",
|
|
4538
|
-
"sw6",
|
|
4539
|
-
"three",
|
|
4540
|
-
"three.js",
|
|
4541
|
-
"3d",
|
|
4542
|
-
"typescript"
|
|
4543
|
-
],
|
|
4544
|
-
repository: "git@github.com:shopware/dive.git",
|
|
4545
|
-
author: "ffrank <f.frank@shopware.com>",
|
|
4546
|
-
license: "MIT",
|
|
4547
|
-
browserslist: [
|
|
4548
|
-
"> 1%, not dead, not ie 11, not op_mini all"
|
|
4549
|
-
],
|
|
4550
|
-
dependencies: {
|
|
4551
|
-
"@tweenjs/tween.js": "^23.1.1",
|
|
4552
|
-
lodash: "^4.17.21",
|
|
4553
|
-
three: "^0.163.0",
|
|
4554
|
-
"three-spritetext": "^1.8.2"
|
|
4555
|
-
},
|
|
4556
|
-
devDependencies: {
|
|
4557
|
-
"@eslint/js": "^9.1.1",
|
|
4558
|
-
"@types/jest": "^29.5.12",
|
|
4559
|
-
"@types/lodash": "^4.17.12",
|
|
4560
|
-
"@types/node": "^20.12.7",
|
|
4561
|
-
"@types/three": "^0.163.0",
|
|
4562
|
-
eslint: "^9.1.1",
|
|
4563
|
-
globals: "^15.0.0",
|
|
4564
|
-
jest: "^29.7.0",
|
|
4565
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
4566
|
-
"jest-junit": "^16.0.0",
|
|
4567
|
-
jsdom: "^24.0.0",
|
|
4568
|
-
prettier: "^3.3.3",
|
|
4569
|
-
"prettier-plugin-multiline-arrays": "^3.0.6",
|
|
4570
|
-
"ts-jest": "^29.1.2",
|
|
4571
|
-
"ts-node": "^10.9.2",
|
|
4572
|
-
tsc: "^2.0.4",
|
|
4573
|
-
tsup: "^8.0.2",
|
|
4574
|
-
typescript: "^5.4.5",
|
|
4575
|
-
"typescript-eslint": "^7.7.1"
|
|
4576
|
-
},
|
|
4577
|
-
scripts: {
|
|
4578
|
-
build: "tsup --env.DIVE_NODE_ENV production",
|
|
4579
|
-
dev: "tsup --watch --env.DIVE_NODE_ENV development",
|
|
4580
|
-
lint: "eslint",
|
|
4581
|
-
"lint:actions": "yarn lint:actions:transpile && yarn lint:actions:check && yarn lint:actions:cleanup",
|
|
4582
|
-
"lint:actions:transpile": "yarn tsc --resolveJsonModule --esModuleInterop ci/lint/lint-actions.ts && mv ci/lint/lint-actions.js ci/lint/lint-actions.cjs",
|
|
4583
|
-
"lint:actions:check": "yarn node ci/lint/lint-actions.cjs",
|
|
4584
|
-
"lint:actions:cleanup": `node -e "require('fs').unlinkSync('ci/lint/lint-actions.cjs')"`,
|
|
4585
|
-
"prettier:check": "prettier --check .",
|
|
4586
|
-
"prettier:fix": "prettier --write .",
|
|
4587
|
-
unit: "jest",
|
|
4588
|
-
coverage: "jest --coverage",
|
|
4589
|
-
"generate-readme": "yarn generate-readme:transpile && yarn generate-readme:write && yarn generate-readme:cleanup",
|
|
4590
|
-
"generate-readme:transpile": "yarn tsc --resolveJsonModule --esModuleInterop ci/readme/generate-readme.ts && mv ci/readme/generate-readme.js ci/readme/generate-readme.cjs",
|
|
4591
|
-
"generate-readme:write": "node ci/readme/generate-readme.cjs",
|
|
4592
|
-
"generate-readme:cleanup": `node -e "require('fs').unlinkSync('ci/readme/generate-readme.cjs')"`,
|
|
4593
|
-
ci: "yarn lint && yarn coverage && yarn prettier:check && yarn build && bash ci/lint/lint-actions.sh"
|
|
4594
|
-
}
|
|
4595
|
-
};
|
|
4596
|
-
|
|
4597
|
-
// src/math/helper/shift.ts
|
|
4598
|
-
function shift(value, exponent) {
|
|
4599
|
-
const subvalues = (value + "e").split("e");
|
|
4600
|
-
return +(subvalues[0] + "e" + (+subvalues[1] + (exponent || 0)));
|
|
4601
|
-
}
|
|
4602
|
-
|
|
4603
|
-
// src/math/ceil/ceilExp.ts
|
|
4604
|
-
function ceilExp(number, decimals = 0) {
|
|
4605
|
-
const n = shift(number, +decimals);
|
|
4606
|
-
return shift(Math.ceil(n), -decimals);
|
|
4607
|
-
}
|
|
4608
|
-
|
|
4609
|
-
// src/math/floor/floorExp.ts
|
|
4610
|
-
function floorExp(number, decimals = 0) {
|
|
4611
|
-
const n = shift(number, +decimals);
|
|
4612
|
-
return shift(Math.floor(n), -decimals);
|
|
4613
|
-
}
|
|
4614
|
-
|
|
4615
|
-
// src/math/round/roundExp.ts
|
|
4616
|
-
function roundExponential(number, decimals = 0) {
|
|
4617
|
-
if (number < 0) return -roundExponential(-number, decimals);
|
|
4618
|
-
const n = shift(number, +decimals);
|
|
4619
|
-
return shift(Math.round(n), -decimals);
|
|
4620
|
-
}
|
|
4621
|
-
|
|
4622
|
-
// src/math/signedAngleTo/signedAngleTo.ts
|
|
4623
|
-
function signedAngleTo(vecA, vecB, planeNormal) {
|
|
4624
|
-
return Math.atan2(
|
|
4625
|
-
vecA.clone().cross(vecB).dot(planeNormal),
|
|
4626
|
-
vecB.clone().dot(vecA)
|
|
4627
|
-
);
|
|
4628
|
-
}
|
|
4629
|
-
|
|
4630
|
-
// src/math/toFixed/toFixedExp.ts
|
|
4631
|
-
function toFixedExp(number, decimals = 0) {
|
|
4632
|
-
const n = shift(number, +decimals);
|
|
4633
|
-
return shift(Math.round(n), -decimals).toFixed(decimals);
|
|
4634
|
-
}
|
|
4635
|
-
|
|
4636
|
-
// src/math/truncate/truncateExp.ts
|
|
4637
|
-
function truncateExp(number, decimals = 0) {
|
|
4638
|
-
const n = shift(number, +decimals);
|
|
4639
|
-
return shift(Math.trunc(n), -decimals);
|
|
4640
|
-
}
|
|
4641
|
-
|
|
4642
|
-
// src/math/radToDeg/radToDeg.ts
|
|
4643
|
-
import { MathUtils as MathUtils3 } from "three";
|
|
4644
|
-
function radToDeg(radians) {
|
|
4645
|
-
return (MathUtils3.radToDeg(radians) + 360) % 360;
|
|
4646
|
-
}
|
|
4647
|
-
|
|
4648
|
-
// src/math/degToRad/degToRad.ts
|
|
4649
|
-
import { MathUtils as MathUtils4 } from "three";
|
|
4650
|
-
function degToRad(degrees) {
|
|
4651
|
-
return MathUtils4.degToRad(degrees);
|
|
4652
|
-
}
|
|
4653
|
-
|
|
4654
|
-
// src/math/index.ts
|
|
4655
|
-
var DIVEMath = {
|
|
4656
|
-
ceilExp,
|
|
4657
|
-
floorExp,
|
|
4658
|
-
roundExp: roundExponential,
|
|
4659
|
-
toFixedExp,
|
|
4660
|
-
truncateExp,
|
|
4661
|
-
signedAngleTo,
|
|
4662
|
-
radToDeg,
|
|
4663
|
-
degToRad
|
|
4664
|
-
};
|
|
4665
|
-
|
|
4666
|
-
// src/dive.ts
|
|
4667
|
-
var DIVEDefaultSettings = {
|
|
4668
|
-
autoResize: true,
|
|
4669
|
-
displayAxes: false,
|
|
4670
|
-
renderer: DIVERendererDefaultSettings,
|
|
4671
|
-
perspectiveCamera: DIVEPerspectiveCameraDefaultSettings,
|
|
4672
|
-
orbitControls: DIVEOrbitControlsDefaultSettings
|
|
4673
|
-
};
|
|
4674
|
-
var DIVE = class _DIVE {
|
|
4675
|
-
// static members
|
|
4676
|
-
static QuickView(uri, settings) {
|
|
4677
|
-
const dive = new _DIVE(settings);
|
|
4678
|
-
dive.Communication.PerformAction("SET_CAMERA_TRANSFORM", {
|
|
4679
|
-
position: { x: 0, y: 2, z: 2 },
|
|
4680
|
-
target: { x: 0, y: 0.5, z: 0 }
|
|
4681
|
-
});
|
|
4682
|
-
const lightid = MathUtils5.generateUUID();
|
|
4683
|
-
dive.Communication.PerformAction("ADD_OBJECT", {
|
|
4684
|
-
entityType: "light",
|
|
4685
|
-
type: "scene",
|
|
4686
|
-
name: "light",
|
|
4687
|
-
id: lightid,
|
|
4688
|
-
enabled: true,
|
|
4689
|
-
visible: true,
|
|
4690
|
-
intensity: 1,
|
|
4691
|
-
color: 16777215
|
|
4692
|
-
});
|
|
4693
|
-
const modelid = MathUtils5.generateUUID();
|
|
4694
|
-
dive.Communication.Subscribe("MODEL_LOADED", (data) => {
|
|
4695
|
-
if (data.id !== modelid) return;
|
|
4696
|
-
const transform = dive.Communication.PerformAction(
|
|
4697
|
-
"COMPUTE_ENCOMPASSING_VIEW",
|
|
4698
|
-
{}
|
|
4699
|
-
);
|
|
4700
|
-
dive.Communication.PerformAction("SET_CAMERA_TRANSFORM", {
|
|
4701
|
-
position: transform.position,
|
|
4702
|
-
target: transform.target
|
|
4703
|
-
});
|
|
4704
|
-
});
|
|
4705
|
-
dive.Communication.PerformAction("ADD_OBJECT", {
|
|
4706
|
-
entityType: "model",
|
|
4707
|
-
name: "object",
|
|
4708
|
-
id: modelid,
|
|
4709
|
-
position: { x: 0, y: 0, z: 0 },
|
|
4710
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
4711
|
-
scale: { x: 1, y: 1, z: 1 },
|
|
4712
|
-
uri,
|
|
4713
|
-
visible: true,
|
|
4714
|
-
loaded: false
|
|
4715
|
-
});
|
|
4716
|
-
dive.Communication.PerformAction("UPDATE_SCENE", {
|
|
4717
|
-
backgroundColor: 16777215,
|
|
4718
|
-
gridEnabled: false,
|
|
4719
|
-
floorColor: 16777215
|
|
4720
|
-
});
|
|
4721
|
-
return dive;
|
|
4722
|
-
}
|
|
4723
|
-
// getters
|
|
4724
|
-
get Communication() {
|
|
4725
|
-
return this.communication;
|
|
4726
|
-
}
|
|
4727
|
-
get Canvas() {
|
|
4728
|
-
return this.renderer.domElement;
|
|
4729
|
-
}
|
|
4730
|
-
get Info() {
|
|
4731
|
-
return DIVEInfo;
|
|
4732
|
-
}
|
|
4733
|
-
// setters
|
|
4734
|
-
set Settings(settings) {
|
|
4735
|
-
var _a;
|
|
4736
|
-
const settingsDelta = getObjectDelta(this._settings, settings);
|
|
4737
|
-
if (settingsDelta.renderer)
|
|
4738
|
-
this.renderer = new DIVERenderer(this._settings.renderer);
|
|
4739
|
-
if (settingsDelta.perspectiveCamera) {
|
|
4740
|
-
if (settingsDelta.perspectiveCamera.fov !== void 0)
|
|
4741
|
-
this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov;
|
|
4742
|
-
if (settingsDelta.perspectiveCamera.near !== void 0)
|
|
4743
|
-
this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near;
|
|
4744
|
-
if (settingsDelta.perspectiveCamera.far !== void 0)
|
|
4745
|
-
this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far;
|
|
4746
|
-
this.perspectiveCamera.OnResize(
|
|
4747
|
-
this.renderer.domElement.width,
|
|
4748
|
-
this.renderer.domElement.height
|
|
4749
|
-
);
|
|
4750
|
-
}
|
|
4751
|
-
if (settingsDelta.orbitControls) {
|
|
4752
|
-
if (settingsDelta.orbitControls.enableDamping !== void 0)
|
|
4753
|
-
this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping;
|
|
4754
|
-
if (settingsDelta.orbitControls.dampingFactor !== void 0)
|
|
4755
|
-
this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor;
|
|
4756
|
-
}
|
|
4757
|
-
if (settingsDelta.autoResize !== this._settings.autoResize) {
|
|
4758
|
-
if (settingsDelta.autoResize) {
|
|
4759
|
-
this.addResizeObserver();
|
|
4760
|
-
} else {
|
|
4761
|
-
this.removeResizeObserver();
|
|
4762
|
-
}
|
|
4763
|
-
}
|
|
4764
|
-
if (settingsDelta.displayAxes) {
|
|
4765
|
-
this.axisCamera = new DIVEAxisCamera(
|
|
4766
|
-
this.renderer,
|
|
4767
|
-
this.scene,
|
|
4768
|
-
this.orbitControls
|
|
4769
|
-
);
|
|
4770
|
-
} else {
|
|
4771
|
-
(_a = this.axisCamera) == null ? void 0 : _a.Dispose();
|
|
4772
|
-
this.axisCamera = null;
|
|
4773
|
-
}
|
|
4774
|
-
Object.assign(this._settings, settings);
|
|
4775
|
-
}
|
|
4776
|
-
constructor(settings) {
|
|
4777
|
-
this._settings = __spreadValues(__spreadValues({}, DIVEDefaultSettings), settings !== void 0 ? settings : {});
|
|
4778
|
-
this._resizeObserverId = "";
|
|
4779
|
-
this._width = 0;
|
|
4780
|
-
this._height = 0;
|
|
4781
|
-
this.renderer = new DIVERenderer(this._settings.renderer);
|
|
4782
|
-
this.scene = new DIVEScene();
|
|
4783
|
-
this.perspectiveCamera = new DIVEPerspectiveCamera(
|
|
4784
|
-
this._settings.perspectiveCamera
|
|
4785
|
-
);
|
|
4786
|
-
this.animationSystem = new DIVEAnimationSystem(this.renderer);
|
|
4787
|
-
this.orbitControls = new DIVEOrbitControls(
|
|
4788
|
-
this.perspectiveCamera,
|
|
4789
|
-
this.renderer,
|
|
4790
|
-
this.animationSystem,
|
|
4791
|
-
this._settings.orbitControls
|
|
4792
|
-
);
|
|
4793
|
-
this.toolbox = new DIVEToolbox(this.scene, this.orbitControls);
|
|
4794
|
-
this.communication = new DIVECommunication(
|
|
4795
|
-
this.renderer,
|
|
4796
|
-
this.scene,
|
|
4797
|
-
this.orbitControls,
|
|
4798
|
-
this.toolbox
|
|
4799
|
-
);
|
|
4800
|
-
if (this._settings.displayAxes) {
|
|
4801
|
-
this.axisCamera = new DIVEAxisCamera(
|
|
4802
|
-
this.renderer,
|
|
4803
|
-
this.scene,
|
|
4804
|
-
this.orbitControls
|
|
4805
|
-
);
|
|
4806
|
-
} else {
|
|
4807
|
-
this.axisCamera = null;
|
|
4808
|
-
}
|
|
4809
|
-
if (this._settings.autoResize) {
|
|
4810
|
-
this.addResizeObserver();
|
|
4811
|
-
}
|
|
4812
|
-
this.renderer.StartRenderer(this.scene, this.perspectiveCamera);
|
|
4813
|
-
window.DIVE = {
|
|
4814
|
-
PrintScene: () => {
|
|
4815
|
-
console.log(this.scene);
|
|
4816
|
-
}
|
|
4817
|
-
};
|
|
4818
|
-
console.log(`DIVE ${package_default.version} initialized successfully!`);
|
|
4819
|
-
if (false) {
|
|
4820
|
-
console.log("DIVE is running in development mode.");
|
|
4821
|
-
}
|
|
4822
|
-
console.log(`
|
|
4823
|
-
@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@
|
|
4824
|
-
@@@@+-:::::::---------------------==------------------------------=#@@@@
|
|
4825
|
-
@@%=::::.......::---------------------------------------------------------+@@
|
|
4826
|
-
@@+:::...........::-----------------------------------------------------------#@@
|
|
4827
|
-
@@=:::.........::::::-------------------------------------------------------------%@
|
|
4828
|
-
@%:::.......:::::::-----------------------------------------------------------------#@
|
|
4829
|
-
@*:::.....:::::-----------------------------------------------------------------------*@
|
|
4830
|
-
@%::::::.::::---------------------------------------------------------------------------@@
|
|
4831
|
-
@@-:::::::::-----------------------------------------------------------------------------=@
|
|
4832
|
-
@%::::::::--------------------------------------------------------------------------------%@
|
|
4833
|
-
@+::::::::--------------------------------=@@@@@%-----------------------------------------%@
|
|
4834
|
-
@=:::::::--------------------------------*@@ @@+---------------------------------------#@
|
|
4835
|
-
@+:::::::-------------------------------*@ @*--------------------------------------%@
|
|
4836
|
-
@#::::::::-----------------------------=@@ @@=-------------------------------------%@
|
|
4837
|
-
@@-::::::::----------------------------@@ @@------------------------------------=@
|
|
4838
|
-
@%:::::::::--------------------------*@ @*-----------------------------------@@
|
|
4839
|
-
@*:::::::::-------------------------@@ @@----------------------------------%@
|
|
4840
|
-
@#::::::::::----------------------%@ @%--------------------------------%@
|
|
4841
|
-
@#:::::::::::-------------------=@@ @@=------------------------------%@
|
|
4842
|
-
@@-::::::::::::----------------%@ @%----------------------------=@@
|
|
4843
|
-
@@#::::::::::::::------------*@ @*--------------------------#@@
|
|
4844
|
-
@@+::::::::::::::::--------@@ @@------------------------+@@
|
|
4845
|
-
@@*:::::::::::::::::----@@ @@---------------------+@@
|
|
4846
|
-
@@@-:::::::::::::::--#@ @#-----------------=%@@
|
|
4847
|
-
@@%-::::::::::::-%@ @%-------------=%@@
|
|
4848
|
-
@@@@+:::::::#@@ @@*-------*@@@@
|
|
4849
|
-
@@@@@@@ @@@@@@
|
|
4850
|
-
|
|
4851
|
-
`);
|
|
4852
|
-
}
|
|
4853
|
-
Dispose() {
|
|
4854
|
-
var _a;
|
|
4855
|
-
this.removeResizeObserver();
|
|
4856
|
-
this.renderer.Dispose();
|
|
4857
|
-
this.orbitControls.Dispose();
|
|
4858
|
-
(_a = this.axisCamera) == null ? void 0 : _a.Dispose();
|
|
4859
|
-
this.animationSystem.Dispose();
|
|
4860
|
-
this.toolbox.Dispose();
|
|
4861
|
-
this.communication.DestroyInstance();
|
|
4862
|
-
}
|
|
4863
|
-
// methods
|
|
4864
|
-
OnResize(width, height) {
|
|
4865
|
-
this.renderer.OnResize(width, height);
|
|
4866
|
-
this.perspectiveCamera.OnResize(width, height);
|
|
4867
|
-
}
|
|
4868
|
-
addResizeObserver() {
|
|
4869
|
-
this._resizeObserverId = this.renderer.AddPreRenderCallback(() => {
|
|
4870
|
-
const canvasWrapper = this.renderer.domElement.parentElement;
|
|
4871
|
-
if (!canvasWrapper) return;
|
|
4872
|
-
const { clientWidth, clientHeight } = canvasWrapper;
|
|
4873
|
-
if (clientWidth === this._width && clientHeight === this._height)
|
|
4874
|
-
return;
|
|
4875
|
-
this.OnResize(clientWidth, clientHeight);
|
|
4876
|
-
this._width = clientWidth;
|
|
4877
|
-
this._height = clientHeight;
|
|
4878
|
-
});
|
|
4879
|
-
}
|
|
4880
|
-
removeResizeObserver() {
|
|
4881
|
-
this.renderer.RemovePreRenderCallback(this._resizeObserverId);
|
|
4882
|
-
}
|
|
4883
|
-
};
|
|
1
|
+
import { k as s, l as D, j as e, m, k as o } from "./dive-BmDCwQRo.js";
|
|
4884
2
|
export {
|
|
4885
|
-
DIVE,
|
|
4886
|
-
DIVECommunication,
|
|
4887
|
-
DIVEDefaultSettings,
|
|
4888
|
-
DIVEMath,
|
|
4889
|
-
|
|
3
|
+
s as DIVE,
|
|
4
|
+
D as DIVECommunication,
|
|
5
|
+
e as DIVEDefaultSettings,
|
|
6
|
+
m as DIVEMath,
|
|
7
|
+
o as default
|
|
4890
8
|
};
|
|
4891
|
-
//# sourceMappingURL=dive.js.map
|
|
9
|
+
//# sourceMappingURL=dive.js.map
|