@shopware-ag/dive 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dive.cjs +113 -150
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +20 -34
- package/build/dive.d.ts +20 -34
- package/build/dive.js +71 -108
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/group/Group.ts +18 -32
- package/src/group/__test__/Group.test.ts +42 -17
- package/src/model/Model.ts +8 -58
- package/src/model/__test__/Model.test.ts +1 -56
- package/src/node/Node.ts +58 -0
- package/src/node/__test__/Node.test.ts +229 -0
- package/src/primitive/Primitive.ts +3 -49
- package/src/primitive/__test__/Primitive.test.ts +0 -55
package/build/dive.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Object3D, Color, Mesh, ColorRepresentation, Intersection, Vector2, Raycaster, Vector3 } from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
|
3
3
|
import { Tween } from '@tweenjs/tween.js';
|
|
4
|
-
import { TransformControls
|
|
5
|
-
import { TransformControls as TransformControls$1 } from 'three/examples/jsm/
|
|
4
|
+
import { TransformControls } from 'three/examples/jsm/controls/TransformControls';
|
|
5
|
+
import { TransformControls as TransformControls$1, GLTF } from 'three/examples/jsm/Addons.js';
|
|
6
6
|
import { TransformControls as TransformControls$2 } from 'three/examples/jsm/Addons';
|
|
7
7
|
|
|
8
8
|
type DIVERendererSettings = {
|
|
@@ -421,17 +421,27 @@ interface DIVESelectable {
|
|
|
421
421
|
onDeselect?: () => void;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
-
declare class
|
|
425
|
-
readonly
|
|
424
|
+
declare class DIVENode extends Object3D implements DIVESelectable, DIVEMoveable {
|
|
425
|
+
readonly isDIVENode: true;
|
|
426
426
|
readonly isSelectable: true;
|
|
427
427
|
readonly isMoveable: true;
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
gizmo: TransformControls | null;
|
|
429
|
+
protected _boundingBox: Box3;
|
|
430
430
|
constructor();
|
|
431
431
|
SetPosition(position: Vector3Like): void;
|
|
432
432
|
SetRotation(rotation: Vector3Like): void;
|
|
433
433
|
SetScale(scale: Vector3Like): void;
|
|
434
434
|
SetVisibility(visible: boolean): void;
|
|
435
|
+
SetToWorldOrigin(): void;
|
|
436
|
+
onMove(): void;
|
|
437
|
+
onSelect(): void;
|
|
438
|
+
onDeselect(): void;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
declare class DIVEGroup extends DIVENode {
|
|
442
|
+
readonly isDIVEGroup: true;
|
|
443
|
+
private _boxMesh;
|
|
444
|
+
constructor();
|
|
435
445
|
SetBoundingBoxVisibility(visible: boolean): void;
|
|
436
446
|
attach(object: DIVESceneObject): this;
|
|
437
447
|
remove(object: DIVESceneObject): this;
|
|
@@ -446,6 +456,7 @@ declare class DIVEGroup extends Object3D implements DIVESelectable, DIVEMoveable
|
|
|
446
456
|
*/
|
|
447
457
|
private updateBB;
|
|
448
458
|
private updateBoxMesh;
|
|
459
|
+
onMove(): void;
|
|
449
460
|
}
|
|
450
461
|
|
|
451
462
|
/**
|
|
@@ -479,7 +490,7 @@ declare class DIVEPointLight extends Object3D implements DIVESelectable, DIVEMov
|
|
|
479
490
|
readonly isDIVEPointLight: true;
|
|
480
491
|
readonly isMoveable: true;
|
|
481
492
|
readonly isSelectable: true;
|
|
482
|
-
gizmo: TransformControls | null;
|
|
493
|
+
gizmo: TransformControls$1 | null;
|
|
483
494
|
private light;
|
|
484
495
|
private mesh;
|
|
485
496
|
constructor();
|
|
@@ -518,27 +529,14 @@ declare class DIVESceneLight extends Object3D {
|
|
|
518
529
|
*
|
|
519
530
|
* @module
|
|
520
531
|
*/
|
|
521
|
-
declare class DIVEModel extends
|
|
532
|
+
declare class DIVEModel extends DIVENode {
|
|
522
533
|
readonly isDIVEModel: true;
|
|
523
|
-
readonly isSelectable: true;
|
|
524
|
-
readonly isMoveable: true;
|
|
525
|
-
gizmo: TransformControls | null;
|
|
526
|
-
private boundingBox;
|
|
527
534
|
private _mesh;
|
|
528
535
|
private _material;
|
|
529
|
-
constructor();
|
|
530
536
|
SetModel(gltf: GLTF): void;
|
|
531
|
-
SetPosition(position: Vector3Like): void;
|
|
532
|
-
SetRotation(rotation: Vector3Like): void;
|
|
533
|
-
SetScale(scale: Vector3Like): void;
|
|
534
|
-
SetVisibility(visible: boolean): void;
|
|
535
537
|
SetMaterial(material: Partial<COMMaterial>): void;
|
|
536
|
-
SetToWorldOrigin(): void;
|
|
537
538
|
PlaceOnFloor(): void;
|
|
538
539
|
DropIt(): void;
|
|
539
|
-
onMove(): void;
|
|
540
|
-
onSelect(): void;
|
|
541
|
-
onDeselect(): void;
|
|
542
540
|
}
|
|
543
541
|
|
|
544
542
|
/**
|
|
@@ -550,26 +548,14 @@ declare class DIVEModel extends Object3D implements DIVESelectable, DIVEMoveable
|
|
|
550
548
|
*
|
|
551
549
|
* @module
|
|
552
550
|
*/
|
|
553
|
-
declare class DIVEPrimitive extends
|
|
551
|
+
declare class DIVEPrimitive extends DIVENode {
|
|
554
552
|
readonly isDIVEPrimitive: true;
|
|
555
|
-
readonly isSelectable: true;
|
|
556
|
-
readonly isMoveable: true;
|
|
557
|
-
gizmo: TransformControls$1 | null;
|
|
558
553
|
private _mesh;
|
|
559
|
-
private _boundingBox;
|
|
560
554
|
constructor();
|
|
561
555
|
SetGeometry(geometry: COMGeometry): void;
|
|
562
|
-
SetPosition(position: Vector3Like): void;
|
|
563
|
-
SetRotation(rotation: Vector3Like): void;
|
|
564
|
-
SetScale(scale: Vector3Like): void;
|
|
565
|
-
SetVisibility(visible: boolean): void;
|
|
566
556
|
SetMaterial(material: Partial<COMMaterial>): void;
|
|
567
|
-
SetToWorldOrigin(): void;
|
|
568
557
|
PlaceOnFloor(): void;
|
|
569
558
|
DropIt(): void;
|
|
570
|
-
onMove(): void;
|
|
571
|
-
onSelect(): void;
|
|
572
|
-
onDeselect(): void;
|
|
573
559
|
private assembleGeometry;
|
|
574
560
|
private createCylinderGeometry;
|
|
575
561
|
private createSphereGeometry;
|
package/build/dive.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Object3D, Color, Mesh, ColorRepresentation, Intersection, Vector2, Raycaster, Vector3 } from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
|
3
3
|
import { Tween } from '@tweenjs/tween.js';
|
|
4
|
-
import { TransformControls
|
|
5
|
-
import { TransformControls as TransformControls$1 } from 'three/examples/jsm/
|
|
4
|
+
import { TransformControls } from 'three/examples/jsm/controls/TransformControls';
|
|
5
|
+
import { TransformControls as TransformControls$1, GLTF } from 'three/examples/jsm/Addons.js';
|
|
6
6
|
import { TransformControls as TransformControls$2 } from 'three/examples/jsm/Addons';
|
|
7
7
|
|
|
8
8
|
type DIVERendererSettings = {
|
|
@@ -421,17 +421,27 @@ interface DIVESelectable {
|
|
|
421
421
|
onDeselect?: () => void;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
-
declare class
|
|
425
|
-
readonly
|
|
424
|
+
declare class DIVENode extends Object3D implements DIVESelectable, DIVEMoveable {
|
|
425
|
+
readonly isDIVENode: true;
|
|
426
426
|
readonly isSelectable: true;
|
|
427
427
|
readonly isMoveable: true;
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
gizmo: TransformControls | null;
|
|
429
|
+
protected _boundingBox: Box3;
|
|
430
430
|
constructor();
|
|
431
431
|
SetPosition(position: Vector3Like): void;
|
|
432
432
|
SetRotation(rotation: Vector3Like): void;
|
|
433
433
|
SetScale(scale: Vector3Like): void;
|
|
434
434
|
SetVisibility(visible: boolean): void;
|
|
435
|
+
SetToWorldOrigin(): void;
|
|
436
|
+
onMove(): void;
|
|
437
|
+
onSelect(): void;
|
|
438
|
+
onDeselect(): void;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
declare class DIVEGroup extends DIVENode {
|
|
442
|
+
readonly isDIVEGroup: true;
|
|
443
|
+
private _boxMesh;
|
|
444
|
+
constructor();
|
|
435
445
|
SetBoundingBoxVisibility(visible: boolean): void;
|
|
436
446
|
attach(object: DIVESceneObject): this;
|
|
437
447
|
remove(object: DIVESceneObject): this;
|
|
@@ -446,6 +456,7 @@ declare class DIVEGroup extends Object3D implements DIVESelectable, DIVEMoveable
|
|
|
446
456
|
*/
|
|
447
457
|
private updateBB;
|
|
448
458
|
private updateBoxMesh;
|
|
459
|
+
onMove(): void;
|
|
449
460
|
}
|
|
450
461
|
|
|
451
462
|
/**
|
|
@@ -479,7 +490,7 @@ declare class DIVEPointLight extends Object3D implements DIVESelectable, DIVEMov
|
|
|
479
490
|
readonly isDIVEPointLight: true;
|
|
480
491
|
readonly isMoveable: true;
|
|
481
492
|
readonly isSelectable: true;
|
|
482
|
-
gizmo: TransformControls | null;
|
|
493
|
+
gizmo: TransformControls$1 | null;
|
|
483
494
|
private light;
|
|
484
495
|
private mesh;
|
|
485
496
|
constructor();
|
|
@@ -518,27 +529,14 @@ declare class DIVESceneLight extends Object3D {
|
|
|
518
529
|
*
|
|
519
530
|
* @module
|
|
520
531
|
*/
|
|
521
|
-
declare class DIVEModel extends
|
|
532
|
+
declare class DIVEModel extends DIVENode {
|
|
522
533
|
readonly isDIVEModel: true;
|
|
523
|
-
readonly isSelectable: true;
|
|
524
|
-
readonly isMoveable: true;
|
|
525
|
-
gizmo: TransformControls | null;
|
|
526
|
-
private boundingBox;
|
|
527
534
|
private _mesh;
|
|
528
535
|
private _material;
|
|
529
|
-
constructor();
|
|
530
536
|
SetModel(gltf: GLTF): void;
|
|
531
|
-
SetPosition(position: Vector3Like): void;
|
|
532
|
-
SetRotation(rotation: Vector3Like): void;
|
|
533
|
-
SetScale(scale: Vector3Like): void;
|
|
534
|
-
SetVisibility(visible: boolean): void;
|
|
535
537
|
SetMaterial(material: Partial<COMMaterial>): void;
|
|
536
|
-
SetToWorldOrigin(): void;
|
|
537
538
|
PlaceOnFloor(): void;
|
|
538
539
|
DropIt(): void;
|
|
539
|
-
onMove(): void;
|
|
540
|
-
onSelect(): void;
|
|
541
|
-
onDeselect(): void;
|
|
542
540
|
}
|
|
543
541
|
|
|
544
542
|
/**
|
|
@@ -550,26 +548,14 @@ declare class DIVEModel extends Object3D implements DIVESelectable, DIVEMoveable
|
|
|
550
548
|
*
|
|
551
549
|
* @module
|
|
552
550
|
*/
|
|
553
|
-
declare class DIVEPrimitive extends
|
|
551
|
+
declare class DIVEPrimitive extends DIVENode {
|
|
554
552
|
readonly isDIVEPrimitive: true;
|
|
555
|
-
readonly isSelectable: true;
|
|
556
|
-
readonly isMoveable: true;
|
|
557
|
-
gizmo: TransformControls$1 | null;
|
|
558
553
|
private _mesh;
|
|
559
|
-
private _boundingBox;
|
|
560
554
|
constructor();
|
|
561
555
|
SetGeometry(geometry: COMGeometry): void;
|
|
562
|
-
SetPosition(position: Vector3Like): void;
|
|
563
|
-
SetRotation(rotation: Vector3Like): void;
|
|
564
|
-
SetScale(scale: Vector3Like): void;
|
|
565
|
-
SetVisibility(visible: boolean): void;
|
|
566
556
|
SetMaterial(material: Partial<COMMaterial>): void;
|
|
567
|
-
SetToWorldOrigin(): void;
|
|
568
557
|
PlaceOnFloor(): void;
|
|
569
558
|
DropIt(): void;
|
|
570
|
-
onMove(): void;
|
|
571
|
-
onSelect(): void;
|
|
572
|
-
onDeselect(): void;
|
|
573
559
|
private assembleGeometry;
|
|
574
560
|
private createCylinderGeometry;
|
|
575
561
|
private createSphereGeometry;
|
package/build/dive.js
CHANGED
|
@@ -652,7 +652,7 @@ var DIVERenderer = class extends WebGLRenderer {
|
|
|
652
652
|
import { Color as Color7, Scene as Scene2 } from "three";
|
|
653
653
|
|
|
654
654
|
// src/scene/root/Root.ts
|
|
655
|
-
import { Box3 as
|
|
655
|
+
import { Box3 as Box32, Color as Color5, Object3D as Object3D6 } from "three";
|
|
656
656
|
|
|
657
657
|
// src/light/AmbientLight.ts
|
|
658
658
|
init_VisibilityLayerMask();
|
|
@@ -1150,7 +1150,7 @@ var DIVESceneLight = class extends Object3D4 {
|
|
|
1150
1150
|
|
|
1151
1151
|
// src/model/Model.ts
|
|
1152
1152
|
init_VisibilityLayerMask();
|
|
1153
|
-
import {
|
|
1153
|
+
import { MeshStandardMaterial, Raycaster as Raycaster2, Vector3 as Vector32 } from "three";
|
|
1154
1154
|
|
|
1155
1155
|
// src/helper/findSceneRecursive/findSceneRecursive.ts
|
|
1156
1156
|
var findSceneRecursive = (object) => {
|
|
@@ -1160,18 +1160,57 @@ var findSceneRecursive = (object) => {
|
|
|
1160
1160
|
return object;
|
|
1161
1161
|
};
|
|
1162
1162
|
|
|
1163
|
-
// src/
|
|
1164
|
-
|
|
1163
|
+
// src/node/Node.ts
|
|
1164
|
+
init_VisibilityLayerMask();
|
|
1165
|
+
import { Box3, Object3D as Object3D5 } from "three";
|
|
1166
|
+
var DIVENode = class extends Object3D5 {
|
|
1165
1167
|
constructor() {
|
|
1166
1168
|
super();
|
|
1167
|
-
this.
|
|
1169
|
+
this.isDIVENode = true;
|
|
1168
1170
|
this.isSelectable = true;
|
|
1169
1171
|
this.isMoveable = true;
|
|
1170
1172
|
this.gizmo = null;
|
|
1173
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1174
|
+
this._boundingBox = new Box3();
|
|
1175
|
+
}
|
|
1176
|
+
SetPosition(position) {
|
|
1177
|
+
this.position.set(position.x, position.y, position.z);
|
|
1178
|
+
}
|
|
1179
|
+
SetRotation(rotation) {
|
|
1180
|
+
this.rotation.set(rotation.x, rotation.y, rotation.z);
|
|
1181
|
+
}
|
|
1182
|
+
SetScale(scale) {
|
|
1183
|
+
this.scale.set(scale.x, scale.y, scale.z);
|
|
1184
|
+
}
|
|
1185
|
+
SetVisibility(visible) {
|
|
1186
|
+
this.visible = visible;
|
|
1187
|
+
}
|
|
1188
|
+
SetToWorldOrigin() {
|
|
1189
|
+
var _a;
|
|
1190
|
+
this.position.set(0, 0, 0);
|
|
1191
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1192
|
+
}
|
|
1193
|
+
onMove() {
|
|
1194
|
+
var _a;
|
|
1195
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1196
|
+
}
|
|
1197
|
+
onSelect() {
|
|
1198
|
+
var _a;
|
|
1199
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1200
|
+
}
|
|
1201
|
+
onDeselect() {
|
|
1202
|
+
var _a;
|
|
1203
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
// src/model/Model.ts
|
|
1208
|
+
var DIVEModel = class extends DIVENode {
|
|
1209
|
+
constructor() {
|
|
1210
|
+
super(...arguments);
|
|
1211
|
+
this.isDIVEModel = true;
|
|
1171
1212
|
this._mesh = null;
|
|
1172
1213
|
this._material = null;
|
|
1173
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1174
|
-
this.boundingBox = new Box3();
|
|
1175
1214
|
}
|
|
1176
1215
|
SetModel(gltf) {
|
|
1177
1216
|
this.clear();
|
|
@@ -1179,7 +1218,7 @@ var DIVEModel = class extends Object3D5 {
|
|
|
1179
1218
|
child.castShadow = true;
|
|
1180
1219
|
child.receiveShadow = true;
|
|
1181
1220
|
child.layers.mask = this.layers.mask;
|
|
1182
|
-
this.
|
|
1221
|
+
this._boundingBox.expandByObject(child);
|
|
1183
1222
|
if (!this._mesh && "isMesh" in child) {
|
|
1184
1223
|
this._mesh = child;
|
|
1185
1224
|
if (this._material) {
|
|
@@ -1191,20 +1230,6 @@ var DIVEModel = class extends Object3D5 {
|
|
|
1191
1230
|
});
|
|
1192
1231
|
this.add(gltf.scene);
|
|
1193
1232
|
}
|
|
1194
|
-
SetPosition(position) {
|
|
1195
|
-
this.position.set(position.x, position.y, position.z);
|
|
1196
|
-
}
|
|
1197
|
-
SetRotation(rotation) {
|
|
1198
|
-
this.rotation.setFromVector3(new Vector32(rotation.x, rotation.y, rotation.z));
|
|
1199
|
-
}
|
|
1200
|
-
SetScale(scale) {
|
|
1201
|
-
this.scale.set(scale.x, scale.y, scale.z);
|
|
1202
|
-
}
|
|
1203
|
-
SetVisibility(visible) {
|
|
1204
|
-
this.traverse((child) => {
|
|
1205
|
-
child.visible = visible;
|
|
1206
|
-
});
|
|
1207
|
-
}
|
|
1208
1233
|
SetMaterial(material) {
|
|
1209
1234
|
if (!this._material) {
|
|
1210
1235
|
this._material = new MeshStandardMaterial();
|
|
@@ -1243,14 +1268,9 @@ var DIVEModel = class extends Object3D5 {
|
|
|
1243
1268
|
this._mesh.material = this._material;
|
|
1244
1269
|
}
|
|
1245
1270
|
}
|
|
1246
|
-
SetToWorldOrigin() {
|
|
1247
|
-
var _a;
|
|
1248
|
-
this.position.set(0, 0, 0);
|
|
1249
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1250
|
-
}
|
|
1251
1271
|
PlaceOnFloor() {
|
|
1252
1272
|
var _a;
|
|
1253
|
-
this.position.y = -this.
|
|
1273
|
+
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
1254
1274
|
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1255
1275
|
}
|
|
1256
1276
|
DropIt() {
|
|
@@ -1259,8 +1279,8 @@ var DIVEModel = class extends Object3D5 {
|
|
|
1259
1279
|
console.warn("DIVEModel: DropIt() called on a model that is not in the scene.", this);
|
|
1260
1280
|
return;
|
|
1261
1281
|
}
|
|
1262
|
-
const bottomY = this.
|
|
1263
|
-
const bbBottomCenter = this.localToWorld(this.
|
|
1282
|
+
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1283
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new Vector32()).multiply(this.scale));
|
|
1264
1284
|
bbBottomCenter.y = bottomY + this.position.y;
|
|
1265
1285
|
const raycaster = new Raycaster2(bbBottomCenter, new Vector32(0, -1, 0));
|
|
1266
1286
|
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1277,18 +1297,6 @@ var DIVEModel = class extends Object3D5 {
|
|
|
1277
1297
|
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1278
1298
|
}
|
|
1279
1299
|
}
|
|
1280
|
-
onMove() {
|
|
1281
|
-
var _a;
|
|
1282
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1283
|
-
}
|
|
1284
|
-
onSelect() {
|
|
1285
|
-
var _a;
|
|
1286
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1287
|
-
}
|
|
1288
|
-
onDeselect() {
|
|
1289
|
-
var _a;
|
|
1290
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1291
|
-
}
|
|
1292
1300
|
};
|
|
1293
1301
|
|
|
1294
1302
|
// src/loadingmanager/LoadingManager.ts
|
|
@@ -1324,42 +1332,23 @@ var DIVELoadingManager = class {
|
|
|
1324
1332
|
};
|
|
1325
1333
|
|
|
1326
1334
|
// src/primitive/Primitive.ts
|
|
1327
|
-
import {
|
|
1335
|
+
import { BoxGeometry, BufferGeometry, Color as Color4, ConeGeometry, CylinderGeometry, Mesh as Mesh3, MeshStandardMaterial as MeshStandardMaterial2, Raycaster as Raycaster3, SphereGeometry as SphereGeometry2, Vector3 as Vector33 } from "three";
|
|
1328
1336
|
init_VisibilityLayerMask();
|
|
1329
|
-
var DIVEPrimitive = class extends
|
|
1337
|
+
var DIVEPrimitive = class extends DIVENode {
|
|
1330
1338
|
constructor() {
|
|
1331
1339
|
super();
|
|
1332
1340
|
this.isDIVEPrimitive = true;
|
|
1333
|
-
this.isSelectable = true;
|
|
1334
|
-
this.isMoveable = true;
|
|
1335
|
-
this.gizmo = null;
|
|
1336
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1337
1341
|
this._mesh = new Mesh3();
|
|
1338
1342
|
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1339
1343
|
this._mesh.castShadow = true;
|
|
1340
1344
|
this._mesh.receiveShadow = true;
|
|
1341
1345
|
this._mesh.material = new MeshStandardMaterial2();
|
|
1342
1346
|
this.add(this._mesh);
|
|
1343
|
-
this._boundingBox = new Box32();
|
|
1344
1347
|
}
|
|
1345
1348
|
SetGeometry(geometry) {
|
|
1346
1349
|
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
1347
1350
|
this._boundingBox.setFromObject(this._mesh);
|
|
1348
1351
|
}
|
|
1349
|
-
SetPosition(position) {
|
|
1350
|
-
this.position.set(position.x, position.y, position.z);
|
|
1351
|
-
}
|
|
1352
|
-
SetRotation(rotation) {
|
|
1353
|
-
this.rotation.setFromVector3(new Vector33(rotation.x, rotation.y, rotation.z));
|
|
1354
|
-
}
|
|
1355
|
-
SetScale(scale) {
|
|
1356
|
-
this.scale.set(scale.x, scale.y, scale.z);
|
|
1357
|
-
}
|
|
1358
|
-
SetVisibility(visible) {
|
|
1359
|
-
this.traverse((child) => {
|
|
1360
|
-
child.visible = visible;
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
1352
|
SetMaterial(material) {
|
|
1364
1353
|
const primitiveMaterial = this._mesh.material;
|
|
1365
1354
|
if (material.vertexColors !== void 0) {
|
|
@@ -1394,11 +1383,6 @@ var DIVEPrimitive = class extends Object3D6 {
|
|
|
1394
1383
|
}
|
|
1395
1384
|
if (this._mesh) this._mesh.material = primitiveMaterial;
|
|
1396
1385
|
}
|
|
1397
|
-
SetToWorldOrigin() {
|
|
1398
|
-
var _a;
|
|
1399
|
-
this.position.set(0, 0, 0);
|
|
1400
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1401
|
-
}
|
|
1402
1386
|
PlaceOnFloor() {
|
|
1403
1387
|
var _a;
|
|
1404
1388
|
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
@@ -1428,18 +1412,6 @@ var DIVEPrimitive = class extends Object3D6 {
|
|
|
1428
1412
|
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1429
1413
|
}
|
|
1430
1414
|
}
|
|
1431
|
-
onMove() {
|
|
1432
|
-
var _a;
|
|
1433
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1434
|
-
}
|
|
1435
|
-
onSelect() {
|
|
1436
|
-
var _a;
|
|
1437
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1438
|
-
}
|
|
1439
|
-
onDeselect() {
|
|
1440
|
-
var _a;
|
|
1441
|
-
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1442
|
-
}
|
|
1443
1415
|
assembleGeometry(geometry) {
|
|
1444
1416
|
switch (geometry.name) {
|
|
1445
1417
|
case "cylinder":
|
|
@@ -1498,34 +1470,16 @@ var DIVEPrimitive = class extends Object3D6 {
|
|
|
1498
1470
|
};
|
|
1499
1471
|
|
|
1500
1472
|
// src/group/Group.ts
|
|
1501
|
-
import {
|
|
1502
|
-
var DIVEGroup = class extends
|
|
1473
|
+
import { BoxGeometry as BoxGeometry2, Mesh as Mesh4, MeshBasicMaterial as MeshBasicMaterial2, Vector3 as Vector34 } from "three";
|
|
1474
|
+
var DIVEGroup = class extends DIVENode {
|
|
1503
1475
|
constructor() {
|
|
1504
1476
|
super();
|
|
1505
1477
|
this.isDIVEGroup = true;
|
|
1506
|
-
this.isSelectable = true;
|
|
1507
|
-
this.isMoveable = true;
|
|
1508
1478
|
this.name = "DIVEGroup";
|
|
1509
|
-
this._bb = new Box33();
|
|
1510
1479
|
this._boxMesh = new Mesh4(new BoxGeometry2(0, 0, 0), new MeshBasicMaterial2({ color: 16711680, wireframe: true }));
|
|
1511
1480
|
this._boxMesh.visible = false;
|
|
1512
1481
|
this.add(this._boxMesh);
|
|
1513
1482
|
}
|
|
1514
|
-
SetPosition(position) {
|
|
1515
|
-
this.position.set(position.x, position.y, position.z);
|
|
1516
|
-
}
|
|
1517
|
-
SetRotation(rotation) {
|
|
1518
|
-
this.rotation.setFromVector3(new Vector34(rotation.x, rotation.y, rotation.z));
|
|
1519
|
-
}
|
|
1520
|
-
SetScale(scale) {
|
|
1521
|
-
this.scale.set(scale.x, scale.y, scale.z);
|
|
1522
|
-
}
|
|
1523
|
-
SetVisibility(visible) {
|
|
1524
|
-
this.traverse((child) => {
|
|
1525
|
-
if (child.uuid === this._boxMesh.uuid) return;
|
|
1526
|
-
child.visible = visible;
|
|
1527
|
-
});
|
|
1528
|
-
}
|
|
1529
1483
|
SetBoundingBoxVisibility(visible) {
|
|
1530
1484
|
this._boxMesh.visible = visible;
|
|
1531
1485
|
}
|
|
@@ -1546,6 +1500,7 @@ var DIVEGroup = class extends Object3D7 {
|
|
|
1546
1500
|
* Children's world positions are kept.
|
|
1547
1501
|
*/
|
|
1548
1502
|
recalculatePosition() {
|
|
1503
|
+
var _a;
|
|
1549
1504
|
const childrensWorldPositions = this.children.map((child) => child.getWorldPosition(new Vector34()));
|
|
1550
1505
|
const bbcenter = this.updateBB();
|
|
1551
1506
|
this.position.copy(bbcenter);
|
|
@@ -1553,26 +1508,34 @@ var DIVEGroup = class extends Object3D7 {
|
|
|
1553
1508
|
if (child.uuid === this._boxMesh.uuid) return;
|
|
1554
1509
|
child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
1555
1510
|
});
|
|
1511
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position });
|
|
1556
1512
|
}
|
|
1557
1513
|
/**
|
|
1558
1514
|
* Updates the bounding box of the group.
|
|
1559
1515
|
* @returns {Vector3} The new center of the bounding box.
|
|
1560
1516
|
*/
|
|
1561
1517
|
updateBB() {
|
|
1562
|
-
this.
|
|
1518
|
+
this._boundingBox.makeEmpty();
|
|
1563
1519
|
this.children.forEach((child) => {
|
|
1564
1520
|
if (child.uuid === this._boxMesh.uuid) return;
|
|
1565
|
-
this.
|
|
1521
|
+
this._boundingBox.expandByObject(child);
|
|
1566
1522
|
});
|
|
1567
|
-
return this.
|
|
1523
|
+
return this._boundingBox.getCenter(new Vector34());
|
|
1568
1524
|
}
|
|
1569
1525
|
updateBoxMesh() {
|
|
1570
|
-
this._boxMesh.
|
|
1526
|
+
this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
|
|
1527
|
+
this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
|
|
1528
|
+
this._boxMesh.geometry = new BoxGeometry2(this._boundingBox.max.x - this._boundingBox.min.x, this._boundingBox.max.y - this._boundingBox.min.y, this._boundingBox.max.z - this._boundingBox.min.z);
|
|
1529
|
+
}
|
|
1530
|
+
onMove() {
|
|
1531
|
+
super.onMove();
|
|
1532
|
+
this.updateBB();
|
|
1533
|
+
this.updateBoxMesh();
|
|
1571
1534
|
}
|
|
1572
1535
|
};
|
|
1573
1536
|
|
|
1574
1537
|
// src/scene/root/Root.ts
|
|
1575
|
-
var DIVERoot = class extends
|
|
1538
|
+
var DIVERoot = class extends Object3D6 {
|
|
1576
1539
|
constructor() {
|
|
1577
1540
|
super();
|
|
1578
1541
|
this.isDIVERoot = true;
|
|
@@ -1580,7 +1543,7 @@ var DIVERoot = class extends Object3D8 {
|
|
|
1580
1543
|
this.loadingManager = new DIVELoadingManager();
|
|
1581
1544
|
}
|
|
1582
1545
|
ComputeSceneBB() {
|
|
1583
|
-
const bb = new
|
|
1546
|
+
const bb = new Box32();
|
|
1584
1547
|
this.traverse((object) => {
|
|
1585
1548
|
if ("isObject3D" in object) {
|
|
1586
1549
|
bb.expandByObject(object);
|
|
@@ -1841,8 +1804,8 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
1841
1804
|
|
|
1842
1805
|
// src/grid/Grid.ts
|
|
1843
1806
|
init_VisibilityLayerMask();
|
|
1844
|
-
import { GridHelper, Object3D as
|
|
1845
|
-
var DIVEGrid = class extends
|
|
1807
|
+
import { GridHelper, Object3D as Object3D7 } from "three";
|
|
1808
|
+
var DIVEGrid = class extends Object3D7 {
|
|
1846
1809
|
constructor() {
|
|
1847
1810
|
super();
|
|
1848
1811
|
this.name = "Grid";
|