@shopware-ag/dive 1.8.0 → 1.10.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 +349 -28
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +26 -4
- package/build/dive.d.ts +26 -4
- package/build/dive.js +342 -21
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/com/index.ts +0 -1
- package/src/com/types.ts +27 -3
- package/src/mediacreator/__test__/MediaCreator.test.ts +1 -1
- package/src/model/Model.ts +50 -1
- package/src/model/__test__/Model.test.ts +68 -19
- package/src/primitive/Primitive.ts +210 -0
- package/src/primitive/__test__/Primitive.test.ts +432 -0
- package/src/scene/__test__/Scene.test.ts +2 -2
- package/src/scene/root/Root.ts +44 -3
- package/src/scene/root/__test__/Root.test.ts +71 -27
- package/src/scene/root/lightroot/__test__/LightRoot.test.ts +2 -3
- package/src/scene/root/modelroot/ModelRoot.ts +1 -0
- package/src/scene/root/modelroot/__test__/ModelRoot.test.ts +3 -0
- package/src/scene/root/primitiveroot/PrimitiveRoot.ts +88 -0
- package/src/scene/root/primitiveroot/__test__/PrimitiveRoot.test.ts +181 -0
package/build/dive.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Mesh, ColorRepresentation, Object3D, Intersection, Vector2, Raycaster, Vector3 } from 'three';
|
|
1
|
+
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Mesh, ColorRepresentation, Object3D, 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
4
|
import { TransformControls } from 'three/examples/jsm/Addons';
|
|
@@ -205,7 +205,7 @@ interface PLACE_ON_FLOOR {
|
|
|
205
205
|
type COMBaseEntity = {
|
|
206
206
|
id: string;
|
|
207
207
|
name: string;
|
|
208
|
-
entityType: 'pov' | 'light' | 'model';
|
|
208
|
+
entityType: 'pov' | 'light' | 'model' | 'primitive';
|
|
209
209
|
visible: boolean;
|
|
210
210
|
};
|
|
211
211
|
type COMPov = COMBaseEntity & {
|
|
@@ -226,8 +226,29 @@ type COMModel = COMBaseEntity & {
|
|
|
226
226
|
rotation: Vector3Like;
|
|
227
227
|
scale: Vector3Like;
|
|
228
228
|
loaded: boolean;
|
|
229
|
+
material?: COMMaterial;
|
|
229
230
|
};
|
|
230
|
-
type
|
|
231
|
+
type COMGeometry = {
|
|
232
|
+
name: string;
|
|
233
|
+
width: number;
|
|
234
|
+
height: number;
|
|
235
|
+
depth: number;
|
|
236
|
+
};
|
|
237
|
+
type COMMaterial = {
|
|
238
|
+
color: string | number;
|
|
239
|
+
roughness: number;
|
|
240
|
+
roughnessMap?: Texture;
|
|
241
|
+
metalness: number;
|
|
242
|
+
metalnessMap?: Texture;
|
|
243
|
+
};
|
|
244
|
+
type COMPrimitive = COMBaseEntity & {
|
|
245
|
+
position: Vector3Like;
|
|
246
|
+
rotation: Vector3Like;
|
|
247
|
+
scale: Vector3Like;
|
|
248
|
+
geometry: COMGeometry;
|
|
249
|
+
material: COMMaterial;
|
|
250
|
+
};
|
|
251
|
+
type COMEntity = COMPov | COMLight | COMModel | COMPrimitive;
|
|
231
252
|
|
|
232
253
|
interface GET_ALL_OBJECTS {
|
|
233
254
|
'PAYLOAD': Map<string, COMEntity>;
|
|
@@ -386,6 +407,7 @@ declare class DIVEGrid extends Object3D {
|
|
|
386
407
|
declare class DIVERoot extends Object3D {
|
|
387
408
|
private lightRoot;
|
|
388
409
|
private modelRoot;
|
|
410
|
+
private primitiveRoot;
|
|
389
411
|
private floor;
|
|
390
412
|
private grid;
|
|
391
413
|
get Floor(): DIVEFloor;
|
|
@@ -396,7 +418,7 @@ declare class DIVERoot extends Object3D {
|
|
|
396
418
|
AddSceneObject(object: COMEntity): void;
|
|
397
419
|
UpdateSceneObject(object: Partial<COMEntity>): void;
|
|
398
420
|
DeleteSceneObject(object: Partial<COMEntity>): void;
|
|
399
|
-
PlaceOnFloor(object: Partial<
|
|
421
|
+
PlaceOnFloor(object: Partial<COMEntity>): void;
|
|
400
422
|
}
|
|
401
423
|
|
|
402
424
|
/**
|
package/build/dive.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Mesh, ColorRepresentation, Object3D, Intersection, Vector2, Raycaster, Vector3 } from 'three';
|
|
1
|
+
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Mesh, ColorRepresentation, Object3D, 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
4
|
import { TransformControls } from 'three/examples/jsm/Addons';
|
|
@@ -205,7 +205,7 @@ interface PLACE_ON_FLOOR {
|
|
|
205
205
|
type COMBaseEntity = {
|
|
206
206
|
id: string;
|
|
207
207
|
name: string;
|
|
208
|
-
entityType: 'pov' | 'light' | 'model';
|
|
208
|
+
entityType: 'pov' | 'light' | 'model' | 'primitive';
|
|
209
209
|
visible: boolean;
|
|
210
210
|
};
|
|
211
211
|
type COMPov = COMBaseEntity & {
|
|
@@ -226,8 +226,29 @@ type COMModel = COMBaseEntity & {
|
|
|
226
226
|
rotation: Vector3Like;
|
|
227
227
|
scale: Vector3Like;
|
|
228
228
|
loaded: boolean;
|
|
229
|
+
material?: COMMaterial;
|
|
229
230
|
};
|
|
230
|
-
type
|
|
231
|
+
type COMGeometry = {
|
|
232
|
+
name: string;
|
|
233
|
+
width: number;
|
|
234
|
+
height: number;
|
|
235
|
+
depth: number;
|
|
236
|
+
};
|
|
237
|
+
type COMMaterial = {
|
|
238
|
+
color: string | number;
|
|
239
|
+
roughness: number;
|
|
240
|
+
roughnessMap?: Texture;
|
|
241
|
+
metalness: number;
|
|
242
|
+
metalnessMap?: Texture;
|
|
243
|
+
};
|
|
244
|
+
type COMPrimitive = COMBaseEntity & {
|
|
245
|
+
position: Vector3Like;
|
|
246
|
+
rotation: Vector3Like;
|
|
247
|
+
scale: Vector3Like;
|
|
248
|
+
geometry: COMGeometry;
|
|
249
|
+
material: COMMaterial;
|
|
250
|
+
};
|
|
251
|
+
type COMEntity = COMPov | COMLight | COMModel | COMPrimitive;
|
|
231
252
|
|
|
232
253
|
interface GET_ALL_OBJECTS {
|
|
233
254
|
'PAYLOAD': Map<string, COMEntity>;
|
|
@@ -386,6 +407,7 @@ declare class DIVEGrid extends Object3D {
|
|
|
386
407
|
declare class DIVERoot extends Object3D {
|
|
387
408
|
private lightRoot;
|
|
388
409
|
private modelRoot;
|
|
410
|
+
private primitiveRoot;
|
|
389
411
|
private floor;
|
|
390
412
|
private grid;
|
|
391
413
|
get Floor(): DIVEFloor;
|
|
@@ -396,7 +418,7 @@ declare class DIVERoot extends Object3D {
|
|
|
396
418
|
AddSceneObject(object: COMEntity): void;
|
|
397
419
|
UpdateSceneObject(object: Partial<COMEntity>): void;
|
|
398
420
|
DeleteSceneObject(object: Partial<COMEntity>): void;
|
|
399
|
-
PlaceOnFloor(object: Partial<
|
|
421
|
+
PlaceOnFloor(object: Partial<COMEntity>): void;
|
|
400
422
|
}
|
|
401
423
|
|
|
402
424
|
/**
|
package/build/dive.js
CHANGED
|
@@ -649,10 +649,10 @@ var DIVERenderer = class extends WebGLRenderer {
|
|
|
649
649
|
};
|
|
650
650
|
|
|
651
651
|
// src/scene/Scene.ts
|
|
652
|
-
import { Color as
|
|
652
|
+
import { Color as Color8, Scene as Scene2 } from "three";
|
|
653
653
|
|
|
654
654
|
// src/scene/root/Root.ts
|
|
655
|
-
import { Box3 as
|
|
655
|
+
import { Box3 as Box33, Object3D as Object3D11 } from "three";
|
|
656
656
|
|
|
657
657
|
// src/scene/root/lightroot/LightRoot.ts
|
|
658
658
|
import { Color as Color4, Object3D as Object3D5 } from "three";
|
|
@@ -1195,7 +1195,7 @@ import { Object3D as Object3D7 } from "three";
|
|
|
1195
1195
|
|
|
1196
1196
|
// src/model/Model.ts
|
|
1197
1197
|
init_VisibilityLayerMask();
|
|
1198
|
-
import { Box3, Object3D as Object3D6, Raycaster as Raycaster2, Vector3 as Vector32 } from "three";
|
|
1198
|
+
import { Box3, Color as Color5, MeshStandardMaterial, Object3D as Object3D6, Raycaster as Raycaster2, Vector3 as Vector32 } from "three";
|
|
1199
1199
|
|
|
1200
1200
|
// src/helper/findSceneRecursive/findSceneRecursive.ts
|
|
1201
1201
|
var findSceneRecursive = (object) => {
|
|
@@ -1212,6 +1212,8 @@ var DIVEModel = class extends Object3D6 {
|
|
|
1212
1212
|
this.isSelectable = true;
|
|
1213
1213
|
this.isMoveable = true;
|
|
1214
1214
|
this.gizmo = null;
|
|
1215
|
+
this._mesh = null;
|
|
1216
|
+
this._material = null;
|
|
1215
1217
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1216
1218
|
this.boundingBox = new Box3();
|
|
1217
1219
|
}
|
|
@@ -1222,6 +1224,14 @@ var DIVEModel = class extends Object3D6 {
|
|
|
1222
1224
|
child.receiveShadow = true;
|
|
1223
1225
|
child.layers.mask = this.layers.mask;
|
|
1224
1226
|
this.boundingBox.expandByObject(child);
|
|
1227
|
+
if (!this._mesh && "isMesh" in child) {
|
|
1228
|
+
this._mesh = child;
|
|
1229
|
+
if (this._material) {
|
|
1230
|
+
this._mesh.material = this._material;
|
|
1231
|
+
} else {
|
|
1232
|
+
this._material = child.material;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1225
1235
|
});
|
|
1226
1236
|
this.add(gltf.scene);
|
|
1227
1237
|
}
|
|
@@ -1239,6 +1249,28 @@ var DIVEModel = class extends Object3D6 {
|
|
|
1239
1249
|
child.visible = visible;
|
|
1240
1250
|
});
|
|
1241
1251
|
}
|
|
1252
|
+
SetMaterial(material) {
|
|
1253
|
+
console.error("HERE", this._mesh);
|
|
1254
|
+
if (!this._material) {
|
|
1255
|
+
this._material = new MeshStandardMaterial();
|
|
1256
|
+
}
|
|
1257
|
+
this._material.color = new Color5(material.color);
|
|
1258
|
+
if (material.roughnessMap) {
|
|
1259
|
+
this._material.roughnessMap = material.roughnessMap;
|
|
1260
|
+
this._material.roughness = 1;
|
|
1261
|
+
} else {
|
|
1262
|
+
this._material.roughness = material.roughness;
|
|
1263
|
+
}
|
|
1264
|
+
if (material.metalnessMap) {
|
|
1265
|
+
this._material.metalnessMap = material.metalnessMap;
|
|
1266
|
+
this._material.metalness = 0;
|
|
1267
|
+
} else {
|
|
1268
|
+
this._material.metalness = material.metalness;
|
|
1269
|
+
}
|
|
1270
|
+
if (this._mesh) {
|
|
1271
|
+
this._mesh.material = this._material;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1242
1274
|
SetToWorldOrigin() {
|
|
1243
1275
|
var _a;
|
|
1244
1276
|
this.position.set(0, 0, 0);
|
|
@@ -1354,6 +1386,7 @@ var DIVEModelRoot = class extends Object3D7 {
|
|
|
1354
1386
|
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1355
1387
|
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1356
1388
|
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1389
|
+
if (object.material !== void 0) sceneObject.SetMaterial(object.material);
|
|
1357
1390
|
}
|
|
1358
1391
|
DeleteModel(object) {
|
|
1359
1392
|
if (object.id === void 0) {
|
|
@@ -1388,12 +1421,265 @@ var DIVEModelRoot = class extends Object3D7 {
|
|
|
1388
1421
|
}
|
|
1389
1422
|
};
|
|
1390
1423
|
|
|
1424
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1425
|
+
import { Object3D as Object3D9 } from "three";
|
|
1426
|
+
|
|
1427
|
+
// src/primitive/Primitive.ts
|
|
1428
|
+
import { Box3 as Box32, BoxGeometry, BufferGeometry, Color as Color6, CylinderGeometry, Float32BufferAttribute, Mesh as Mesh3, Object3D as Object3D8, Raycaster as Raycaster3, SphereGeometry as SphereGeometry2, Uint32BufferAttribute, Vector3 as Vector33 } from "three";
|
|
1429
|
+
init_VisibilityLayerMask();
|
|
1430
|
+
var DIVEPrimitive = class extends Object3D8 {
|
|
1431
|
+
constructor() {
|
|
1432
|
+
super();
|
|
1433
|
+
this.isSelectable = true;
|
|
1434
|
+
this.isMoveable = true;
|
|
1435
|
+
this.gizmo = null;
|
|
1436
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1437
|
+
this._mesh = new Mesh3();
|
|
1438
|
+
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1439
|
+
this._mesh.castShadow = true;
|
|
1440
|
+
this._mesh.receiveShadow = true;
|
|
1441
|
+
this.add(this._mesh);
|
|
1442
|
+
this._boundingBox = new Box32();
|
|
1443
|
+
}
|
|
1444
|
+
SetGeometry(geometry) {
|
|
1445
|
+
this.clear();
|
|
1446
|
+
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
1447
|
+
this._boundingBox.setFromObject(this._mesh);
|
|
1448
|
+
}
|
|
1449
|
+
SetPosition(position) {
|
|
1450
|
+
this.position.set(position.x, position.y, position.z);
|
|
1451
|
+
}
|
|
1452
|
+
SetRotation(rotation) {
|
|
1453
|
+
this.rotation.setFromVector3(new Vector33(rotation.x, rotation.y, rotation.z));
|
|
1454
|
+
}
|
|
1455
|
+
SetScale(scale) {
|
|
1456
|
+
this.scale.set(scale.x, scale.y, scale.z);
|
|
1457
|
+
}
|
|
1458
|
+
SetVisibility(visible) {
|
|
1459
|
+
this.traverse((child) => {
|
|
1460
|
+
child.visible = visible;
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
SetMaterial(material) {
|
|
1464
|
+
const primitiveMaterial = this._mesh.material;
|
|
1465
|
+
primitiveMaterial.color = new Color6(material.color);
|
|
1466
|
+
if (material.roughnessMap) {
|
|
1467
|
+
primitiveMaterial.roughnessMap = material.roughnessMap;
|
|
1468
|
+
primitiveMaterial.roughness = 1;
|
|
1469
|
+
} else {
|
|
1470
|
+
primitiveMaterial.roughness = material.roughness;
|
|
1471
|
+
}
|
|
1472
|
+
if (material.metalnessMap) {
|
|
1473
|
+
primitiveMaterial.metalnessMap = material.metalnessMap;
|
|
1474
|
+
primitiveMaterial.metalness = 0;
|
|
1475
|
+
} else {
|
|
1476
|
+
primitiveMaterial.metalness = material.metalness;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
SetToWorldOrigin() {
|
|
1480
|
+
var _a;
|
|
1481
|
+
this.position.set(0, 0, 0);
|
|
1482
|
+
(_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 });
|
|
1483
|
+
}
|
|
1484
|
+
PlaceOnFloor() {
|
|
1485
|
+
var _a;
|
|
1486
|
+
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
1487
|
+
(_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 });
|
|
1488
|
+
}
|
|
1489
|
+
DropIt() {
|
|
1490
|
+
var _a;
|
|
1491
|
+
if (!this.parent) {
|
|
1492
|
+
console.warn("DIVEModel: DropIt() called on a model that is not in the scene.", this);
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1496
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new Vector33()).multiply(this.scale));
|
|
1497
|
+
bbBottomCenter.y = bottomY + this.position.y;
|
|
1498
|
+
const raycaster = new Raycaster3(bbBottomCenter, new Vector33(0, -1, 0));
|
|
1499
|
+
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1500
|
+
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1501
|
+
if (intersections.length > 0) {
|
|
1502
|
+
const mesh = intersections[0].object;
|
|
1503
|
+
mesh.geometry.computeBoundingBox();
|
|
1504
|
+
const meshBB = mesh.geometry.boundingBox;
|
|
1505
|
+
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1506
|
+
const oldPos = this.position.clone();
|
|
1507
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new Vector33(0, bottomY, 0));
|
|
1508
|
+
this.position.copy(newPos);
|
|
1509
|
+
if (this.position.y === oldPos.y) return;
|
|
1510
|
+
(_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 });
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
onMove() {
|
|
1514
|
+
var _a;
|
|
1515
|
+
(_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 });
|
|
1516
|
+
}
|
|
1517
|
+
onSelect() {
|
|
1518
|
+
var _a;
|
|
1519
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1520
|
+
}
|
|
1521
|
+
onDeselect() {
|
|
1522
|
+
var _a;
|
|
1523
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1524
|
+
}
|
|
1525
|
+
assembleGeometry(geometry) {
|
|
1526
|
+
switch (geometry.name) {
|
|
1527
|
+
case "cylinder":
|
|
1528
|
+
return this.createCylinderGeometry(geometry);
|
|
1529
|
+
case "sphere":
|
|
1530
|
+
return this.createSphereGeometry(geometry);
|
|
1531
|
+
case "pyramid":
|
|
1532
|
+
return this.createPyramidGeometry(geometry);
|
|
1533
|
+
case "box":
|
|
1534
|
+
return this.createBoxGeometry(geometry);
|
|
1535
|
+
case "cone":
|
|
1536
|
+
return this.createConeGeometry(geometry);
|
|
1537
|
+
case "wall":
|
|
1538
|
+
return this.createWallGeometry(geometry);
|
|
1539
|
+
case "plane":
|
|
1540
|
+
return this.createPlaneGeometry(geometry);
|
|
1541
|
+
default:
|
|
1542
|
+
return new BufferGeometry();
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
createCylinderGeometry(geometry) {
|
|
1546
|
+
return new CylinderGeometry(geometry.width * 2, geometry.width * 2, geometry.height, 64);
|
|
1547
|
+
}
|
|
1548
|
+
createSphereGeometry(geometry) {
|
|
1549
|
+
return new SphereGeometry2(geometry.width * 2, 64);
|
|
1550
|
+
}
|
|
1551
|
+
createPyramidGeometry(geometry) {
|
|
1552
|
+
const geo = new BufferGeometry();
|
|
1553
|
+
const { width, height, depth } = geometry;
|
|
1554
|
+
geo.setAttribute("position", new Float32BufferAttribute([
|
|
1555
|
+
width / 2,
|
|
1556
|
+
0,
|
|
1557
|
+
depth / 2,
|
|
1558
|
+
// right back
|
|
1559
|
+
width / 2,
|
|
1560
|
+
0,
|
|
1561
|
+
-depth / 2,
|
|
1562
|
+
// right front
|
|
1563
|
+
-width / 2,
|
|
1564
|
+
0,
|
|
1565
|
+
-depth / 2,
|
|
1566
|
+
// left front
|
|
1567
|
+
-width / 2,
|
|
1568
|
+
0,
|
|
1569
|
+
depth / 2,
|
|
1570
|
+
// left back
|
|
1571
|
+
0,
|
|
1572
|
+
height,
|
|
1573
|
+
0
|
|
1574
|
+
// top
|
|
1575
|
+
], 3));
|
|
1576
|
+
geo.setIndex(new Uint32BufferAttribute([
|
|
1577
|
+
1,
|
|
1578
|
+
0,
|
|
1579
|
+
4,
|
|
1580
|
+
2,
|
|
1581
|
+
1,
|
|
1582
|
+
4,
|
|
1583
|
+
3,
|
|
1584
|
+
2,
|
|
1585
|
+
4,
|
|
1586
|
+
3,
|
|
1587
|
+
0,
|
|
1588
|
+
4,
|
|
1589
|
+
0,
|
|
1590
|
+
1,
|
|
1591
|
+
2,
|
|
1592
|
+
0,
|
|
1593
|
+
2,
|
|
1594
|
+
3
|
|
1595
|
+
], 1));
|
|
1596
|
+
return geo;
|
|
1597
|
+
}
|
|
1598
|
+
createBoxGeometry(geometry) {
|
|
1599
|
+
return new BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1600
|
+
}
|
|
1601
|
+
createConeGeometry(geometry) {
|
|
1602
|
+
return new CylinderGeometry(0, geometry.width * 2, geometry.height, 64);
|
|
1603
|
+
}
|
|
1604
|
+
createWallGeometry(geometry) {
|
|
1605
|
+
return new BoxGeometry(geometry.width, geometry.height, geometry.depth, 16);
|
|
1606
|
+
}
|
|
1607
|
+
createPlaneGeometry(geometry) {
|
|
1608
|
+
return new BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1612
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1613
|
+
var DIVEPrimitiveRoot = class extends Object3D9 {
|
|
1614
|
+
constructor() {
|
|
1615
|
+
super();
|
|
1616
|
+
this.name = "PrimitiveRoot";
|
|
1617
|
+
}
|
|
1618
|
+
GetPrimitive(object) {
|
|
1619
|
+
if (object.id === void 0) {
|
|
1620
|
+
console.warn("PrimitiveRoot.GetPrimitive: object.id is undefined");
|
|
1621
|
+
return void 0;
|
|
1622
|
+
}
|
|
1623
|
+
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1624
|
+
}
|
|
1625
|
+
UpdatePrimitive(object) {
|
|
1626
|
+
if (object.id === void 0) {
|
|
1627
|
+
console.warn("PrimitiveRoot.UpdatePrimitive: object.id is undefined");
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1631
|
+
if (!sceneObject && object.geometry !== void 0) {
|
|
1632
|
+
const primitive = new DIVEPrimitive();
|
|
1633
|
+
primitive.SetGeometry(object.geometry);
|
|
1634
|
+
sceneObject = primitive;
|
|
1635
|
+
sceneObject.userData.id = object.id;
|
|
1636
|
+
this.add(sceneObject);
|
|
1637
|
+
}
|
|
1638
|
+
if (object.position !== void 0) sceneObject.SetPosition(object.position);
|
|
1639
|
+
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1640
|
+
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1641
|
+
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1642
|
+
if (object.material !== void 0) sceneObject.SetMaterial(object.material);
|
|
1643
|
+
}
|
|
1644
|
+
DeletePrimitive(object) {
|
|
1645
|
+
if (object.id === void 0) {
|
|
1646
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: object.id is undefined`);
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1650
|
+
if (!sceneObject) {
|
|
1651
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: Primitive with id ${object.id} not found`);
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
const findScene = (object2) => {
|
|
1655
|
+
if (object2.parent !== null) {
|
|
1656
|
+
return findScene(object2.parent);
|
|
1657
|
+
}
|
|
1658
|
+
;
|
|
1659
|
+
return object2;
|
|
1660
|
+
};
|
|
1661
|
+
const scene = findScene(sceneObject);
|
|
1662
|
+
scene.children.find((object2) => {
|
|
1663
|
+
if ("isTransformControls" in object2) {
|
|
1664
|
+
object2.detach();
|
|
1665
|
+
}
|
|
1666
|
+
});
|
|
1667
|
+
this.remove(sceneObject);
|
|
1668
|
+
}
|
|
1669
|
+
PlaceOnFloor(object) {
|
|
1670
|
+
if (object.id === void 0) console.warn("PrimitiveRoot.PlaceOnFloor: object.id is undefined");
|
|
1671
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1672
|
+
if (!sceneObject) return;
|
|
1673
|
+
sceneObject.PlaceOnFloor();
|
|
1674
|
+
}
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1391
1677
|
// src/primitive/floor/Floor.ts
|
|
1392
1678
|
init_VisibilityLayerMask();
|
|
1393
|
-
import { Color as
|
|
1394
|
-
var DIVEFloor = class extends
|
|
1679
|
+
import { Color as Color7, Mesh as Mesh4, MeshStandardMaterial as MeshStandardMaterial3, PlaneGeometry } from "three";
|
|
1680
|
+
var DIVEFloor = class extends Mesh4 {
|
|
1395
1681
|
constructor() {
|
|
1396
|
-
super(new PlaneGeometry(1e4, 1e4), new
|
|
1682
|
+
super(new PlaneGeometry(1e4, 1e4), new MeshStandardMaterial3({ color: new Color7(150 / 255, 150 / 255, 150 / 255) }));
|
|
1397
1683
|
this.isFloor = true;
|
|
1398
1684
|
this.name = "Floor";
|
|
1399
1685
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1404,7 +1690,7 @@ var DIVEFloor = class extends Mesh2 {
|
|
|
1404
1690
|
this.visible = visible;
|
|
1405
1691
|
}
|
|
1406
1692
|
SetColor(color) {
|
|
1407
|
-
this.material.color = new
|
|
1693
|
+
this.material.color = new Color7(color);
|
|
1408
1694
|
}
|
|
1409
1695
|
};
|
|
1410
1696
|
|
|
@@ -1414,8 +1700,8 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
1414
1700
|
|
|
1415
1701
|
// src/grid/Grid.ts
|
|
1416
1702
|
init_VisibilityLayerMask();
|
|
1417
|
-
import { GridHelper, Object3D as
|
|
1418
|
-
var DIVEGrid = class extends
|
|
1703
|
+
import { GridHelper, Object3D as Object3D10 } from "three";
|
|
1704
|
+
var DIVEGrid = class extends Object3D10 {
|
|
1419
1705
|
constructor() {
|
|
1420
1706
|
super();
|
|
1421
1707
|
this.name = "Grid";
|
|
@@ -1430,7 +1716,7 @@ var DIVEGrid = class extends Object3D8 {
|
|
|
1430
1716
|
};
|
|
1431
1717
|
|
|
1432
1718
|
// src/scene/root/Root.ts
|
|
1433
|
-
var DIVERoot = class extends
|
|
1719
|
+
var DIVERoot = class extends Object3D11 {
|
|
1434
1720
|
get Floor() {
|
|
1435
1721
|
return this.floor;
|
|
1436
1722
|
}
|
|
@@ -1444,18 +1730,25 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1444
1730
|
this.add(this.lightRoot);
|
|
1445
1731
|
this.modelRoot = new DIVEModelRoot();
|
|
1446
1732
|
this.add(this.modelRoot);
|
|
1733
|
+
this.primitiveRoot = new DIVEPrimitiveRoot();
|
|
1734
|
+
this.add(this.primitiveRoot);
|
|
1447
1735
|
this.floor = new DIVEFloor();
|
|
1448
1736
|
this.add(this.floor);
|
|
1449
1737
|
this.grid = new DIVEGrid();
|
|
1450
1738
|
this.add(this.grid);
|
|
1451
1739
|
}
|
|
1452
1740
|
ComputeSceneBB() {
|
|
1453
|
-
const bb = new
|
|
1741
|
+
const bb = new Box33();
|
|
1454
1742
|
this.modelRoot.traverse((object) => {
|
|
1455
1743
|
if ("isObject3D" in object) {
|
|
1456
1744
|
bb.expandByObject(object);
|
|
1457
1745
|
}
|
|
1458
1746
|
});
|
|
1747
|
+
this.primitiveRoot.traverse((object) => {
|
|
1748
|
+
if ("isObject3D" in object) {
|
|
1749
|
+
bb.expandByObject(object);
|
|
1750
|
+
}
|
|
1751
|
+
});
|
|
1459
1752
|
return bb;
|
|
1460
1753
|
}
|
|
1461
1754
|
GetSceneObject(object) {
|
|
@@ -1469,6 +1762,9 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1469
1762
|
case "model": {
|
|
1470
1763
|
return this.modelRoot.GetModel(object);
|
|
1471
1764
|
}
|
|
1765
|
+
case "primitive": {
|
|
1766
|
+
return this.primitiveRoot.GetPrimitive(object);
|
|
1767
|
+
}
|
|
1472
1768
|
}
|
|
1473
1769
|
}
|
|
1474
1770
|
AddSceneObject(object) {
|
|
@@ -1484,6 +1780,10 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1484
1780
|
this.modelRoot.UpdateModel(object);
|
|
1485
1781
|
break;
|
|
1486
1782
|
}
|
|
1783
|
+
case "primitive": {
|
|
1784
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1785
|
+
break;
|
|
1786
|
+
}
|
|
1487
1787
|
}
|
|
1488
1788
|
}
|
|
1489
1789
|
UpdateSceneObject(object) {
|
|
@@ -1499,6 +1799,10 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1499
1799
|
this.modelRoot.UpdateModel(object);
|
|
1500
1800
|
break;
|
|
1501
1801
|
}
|
|
1802
|
+
case "primitive": {
|
|
1803
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1804
|
+
break;
|
|
1805
|
+
}
|
|
1502
1806
|
}
|
|
1503
1807
|
}
|
|
1504
1808
|
DeleteSceneObject(object) {
|
|
@@ -1514,10 +1818,27 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1514
1818
|
this.modelRoot.DeleteModel(object);
|
|
1515
1819
|
break;
|
|
1516
1820
|
}
|
|
1821
|
+
case "primitive": {
|
|
1822
|
+
this.primitiveRoot.DeletePrimitive(object);
|
|
1823
|
+
break;
|
|
1824
|
+
}
|
|
1517
1825
|
}
|
|
1518
1826
|
}
|
|
1519
1827
|
PlaceOnFloor(object) {
|
|
1520
|
-
|
|
1828
|
+
switch (object.entityType) {
|
|
1829
|
+
case "pov":
|
|
1830
|
+
case "light": {
|
|
1831
|
+
break;
|
|
1832
|
+
}
|
|
1833
|
+
case "model": {
|
|
1834
|
+
this.modelRoot.PlaceOnFloor(object);
|
|
1835
|
+
break;
|
|
1836
|
+
}
|
|
1837
|
+
case "primitive": {
|
|
1838
|
+
this.primitiveRoot.PlaceOnFloor(object);
|
|
1839
|
+
break;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1521
1842
|
}
|
|
1522
1843
|
};
|
|
1523
1844
|
|
|
@@ -1528,12 +1849,12 @@ var DIVEScene = class extends Scene2 {
|
|
|
1528
1849
|
}
|
|
1529
1850
|
constructor() {
|
|
1530
1851
|
super();
|
|
1531
|
-
this.background = new
|
|
1852
|
+
this.background = new Color8(16777215);
|
|
1532
1853
|
this.root = new DIVERoot();
|
|
1533
1854
|
this.add(this.root);
|
|
1534
1855
|
}
|
|
1535
1856
|
SetBackground(color) {
|
|
1536
|
-
this.background = new
|
|
1857
|
+
this.background = new Color8(color);
|
|
1537
1858
|
}
|
|
1538
1859
|
ComputeSceneBB() {
|
|
1539
1860
|
return this.Root.ComputeSceneBB();
|
|
@@ -1560,7 +1881,7 @@ init_PerspectiveCamera();
|
|
|
1560
1881
|
|
|
1561
1882
|
// src/controls/OrbitControls.ts
|
|
1562
1883
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
|
|
1563
|
-
import { MathUtils as MathUtils2, Vector3 as
|
|
1884
|
+
import { MathUtils as MathUtils2, Vector3 as Vector34 } from "three";
|
|
1564
1885
|
import { Easing } from "@tweenjs/tween.js";
|
|
1565
1886
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1566
1887
|
enableDamping: true,
|
|
@@ -1602,8 +1923,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
|
1602
1923
|
this.dispose();
|
|
1603
1924
|
}
|
|
1604
1925
|
ComputeEncompassingView(bb) {
|
|
1605
|
-
const center = bb.getCenter(new
|
|
1606
|
-
const size = bb.getSize(new
|
|
1926
|
+
const center = bb.getCenter(new Vector34());
|
|
1927
|
+
const size = bb.getSize(new Vector34());
|
|
1607
1928
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
1608
1929
|
const direction = this.object.position.clone().normalize();
|
|
1609
1930
|
return {
|
|
@@ -1771,7 +2092,7 @@ var DIVEAnimationSystem = class {
|
|
|
1771
2092
|
|
|
1772
2093
|
// src/axiscamera/AxisCamera.ts
|
|
1773
2094
|
init_VisibilityLayerMask();
|
|
1774
|
-
import { AxesHelper, Color as
|
|
2095
|
+
import { AxesHelper, Color as Color9, Matrix4, OrthographicCamera, Vector4 } from "three";
|
|
1775
2096
|
import SpriteText from "three-spritetext";
|
|
1776
2097
|
|
|
1777
2098
|
// src/constant/AxisHelperColors.ts
|
|
@@ -1792,9 +2113,9 @@ var DIVEAxisCamera = class extends OrthographicCamera {
|
|
|
1792
2113
|
this.axesHelper.material.depthTest = false;
|
|
1793
2114
|
this.axesHelper.position.set(0, 0, -1);
|
|
1794
2115
|
this.axesHelper.setColors(
|
|
1795
|
-
new
|
|
1796
|
-
new
|
|
1797
|
-
new
|
|
2116
|
+
new Color9(AxesColorRed),
|
|
2117
|
+
new Color9(AxesColorGreen),
|
|
2118
|
+
new Color9(AxesColorBlue)
|
|
1798
2119
|
);
|
|
1799
2120
|
const x = new SpriteText("X", 0.2, AxesColorRedLetter);
|
|
1800
2121
|
const y = new SpriteText("Y", 0.2, AxesColorGreenLetter);
|