@shopware-ag/dive 1.8.0 → 1.9.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 +316 -28
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +25 -4
- package/build/dive.d.ts +25 -4
- package/build/dive.js +308 -20
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/com/index.ts +0 -1
- package/src/com/types.ts +26 -3
- package/src/mediacreator/__test__/MediaCreator.test.ts +1 -1
- package/src/primitive/Primitive.ts +210 -0
- package/src/primitive/__test__/Primitive.test.ts +434 -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/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 & {
|
|
@@ -227,7 +227,27 @@ type COMModel = COMBaseEntity & {
|
|
|
227
227
|
scale: Vector3Like;
|
|
228
228
|
loaded: boolean;
|
|
229
229
|
};
|
|
230
|
-
type
|
|
230
|
+
type COMGeometry = {
|
|
231
|
+
name: string;
|
|
232
|
+
width: number;
|
|
233
|
+
height: number;
|
|
234
|
+
depth: number;
|
|
235
|
+
};
|
|
236
|
+
type COMMaterial = {
|
|
237
|
+
color: string | number;
|
|
238
|
+
roughness: number;
|
|
239
|
+
roughnessMap: Texture | null;
|
|
240
|
+
metalness: number;
|
|
241
|
+
metalnessMap: Texture | null;
|
|
242
|
+
};
|
|
243
|
+
type COMPrimitive = COMBaseEntity & {
|
|
244
|
+
position: Vector3Like;
|
|
245
|
+
rotation: Vector3Like;
|
|
246
|
+
scale: Vector3Like;
|
|
247
|
+
geometry: COMGeometry;
|
|
248
|
+
material: COMMaterial;
|
|
249
|
+
};
|
|
250
|
+
type COMEntity = COMPov | COMLight | COMModel | COMPrimitive;
|
|
231
251
|
|
|
232
252
|
interface GET_ALL_OBJECTS {
|
|
233
253
|
'PAYLOAD': Map<string, COMEntity>;
|
|
@@ -386,6 +406,7 @@ declare class DIVEGrid extends Object3D {
|
|
|
386
406
|
declare class DIVERoot extends Object3D {
|
|
387
407
|
private lightRoot;
|
|
388
408
|
private modelRoot;
|
|
409
|
+
private primitiveRoot;
|
|
389
410
|
private floor;
|
|
390
411
|
private grid;
|
|
391
412
|
get Floor(): DIVEFloor;
|
|
@@ -396,7 +417,7 @@ declare class DIVERoot extends Object3D {
|
|
|
396
417
|
AddSceneObject(object: COMEntity): void;
|
|
397
418
|
UpdateSceneObject(object: Partial<COMEntity>): void;
|
|
398
419
|
DeleteSceneObject(object: Partial<COMEntity>): void;
|
|
399
|
-
PlaceOnFloor(object: Partial<
|
|
420
|
+
PlaceOnFloor(object: Partial<COMEntity>): void;
|
|
400
421
|
}
|
|
401
422
|
|
|
402
423
|
/**
|
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 & {
|
|
@@ -227,7 +227,27 @@ type COMModel = COMBaseEntity & {
|
|
|
227
227
|
scale: Vector3Like;
|
|
228
228
|
loaded: boolean;
|
|
229
229
|
};
|
|
230
|
-
type
|
|
230
|
+
type COMGeometry = {
|
|
231
|
+
name: string;
|
|
232
|
+
width: number;
|
|
233
|
+
height: number;
|
|
234
|
+
depth: number;
|
|
235
|
+
};
|
|
236
|
+
type COMMaterial = {
|
|
237
|
+
color: string | number;
|
|
238
|
+
roughness: number;
|
|
239
|
+
roughnessMap: Texture | null;
|
|
240
|
+
metalness: number;
|
|
241
|
+
metalnessMap: Texture | null;
|
|
242
|
+
};
|
|
243
|
+
type COMPrimitive = COMBaseEntity & {
|
|
244
|
+
position: Vector3Like;
|
|
245
|
+
rotation: Vector3Like;
|
|
246
|
+
scale: Vector3Like;
|
|
247
|
+
geometry: COMGeometry;
|
|
248
|
+
material: COMMaterial;
|
|
249
|
+
};
|
|
250
|
+
type COMEntity = COMPov | COMLight | COMModel | COMPrimitive;
|
|
231
251
|
|
|
232
252
|
interface GET_ALL_OBJECTS {
|
|
233
253
|
'PAYLOAD': Map<string, COMEntity>;
|
|
@@ -386,6 +406,7 @@ declare class DIVEGrid extends Object3D {
|
|
|
386
406
|
declare class DIVERoot extends Object3D {
|
|
387
407
|
private lightRoot;
|
|
388
408
|
private modelRoot;
|
|
409
|
+
private primitiveRoot;
|
|
389
410
|
private floor;
|
|
390
411
|
private grid;
|
|
391
412
|
get Floor(): DIVEFloor;
|
|
@@ -396,7 +417,7 @@ declare class DIVERoot extends Object3D {
|
|
|
396
417
|
AddSceneObject(object: COMEntity): void;
|
|
397
418
|
UpdateSceneObject(object: Partial<COMEntity>): void;
|
|
398
419
|
DeleteSceneObject(object: Partial<COMEntity>): void;
|
|
399
|
-
PlaceOnFloor(object: Partial<
|
|
420
|
+
PlaceOnFloor(object: Partial<COMEntity>): void;
|
|
400
421
|
}
|
|
401
422
|
|
|
402
423
|
/**
|
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 Color7, 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";
|
|
@@ -1388,12 +1388,265 @@ var DIVEModelRoot = class extends Object3D7 {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
};
|
|
1390
1390
|
|
|
1391
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1392
|
+
import { Object3D as Object3D9 } from "three";
|
|
1393
|
+
|
|
1394
|
+
// src/primitive/Primitive.ts
|
|
1395
|
+
import { Box3 as Box32, BoxGeometry, BufferGeometry, Color as Color5, CylinderGeometry, Float32BufferAttribute, Mesh as Mesh2, Object3D as Object3D8, Raycaster as Raycaster3, SphereGeometry as SphereGeometry2, Uint32BufferAttribute, Vector3 as Vector33 } from "three";
|
|
1396
|
+
init_VisibilityLayerMask();
|
|
1397
|
+
var DIVEPrimitive = class extends Object3D8 {
|
|
1398
|
+
constructor() {
|
|
1399
|
+
super();
|
|
1400
|
+
this.isSelectable = true;
|
|
1401
|
+
this.isMoveable = true;
|
|
1402
|
+
this.gizmo = null;
|
|
1403
|
+
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1404
|
+
this._mesh = new Mesh2();
|
|
1405
|
+
this._mesh.layers.mask = PRODUCT_LAYER_MASK;
|
|
1406
|
+
this._mesh.castShadow = true;
|
|
1407
|
+
this._mesh.receiveShadow = true;
|
|
1408
|
+
this.add(this._mesh);
|
|
1409
|
+
this._boundingBox = new Box32();
|
|
1410
|
+
}
|
|
1411
|
+
SetGeometry(geometry) {
|
|
1412
|
+
this.clear();
|
|
1413
|
+
this._mesh.geometry = this.assembleGeometry(geometry);
|
|
1414
|
+
this._boundingBox.setFromObject(this._mesh);
|
|
1415
|
+
}
|
|
1416
|
+
SetPosition(position) {
|
|
1417
|
+
this.position.set(position.x, position.y, position.z);
|
|
1418
|
+
}
|
|
1419
|
+
SetRotation(rotation) {
|
|
1420
|
+
this.rotation.setFromVector3(new Vector33(rotation.x, rotation.y, rotation.z));
|
|
1421
|
+
}
|
|
1422
|
+
SetScale(scale) {
|
|
1423
|
+
this.scale.set(scale.x, scale.y, scale.z);
|
|
1424
|
+
}
|
|
1425
|
+
SetVisibility(visible) {
|
|
1426
|
+
this.traverse((child) => {
|
|
1427
|
+
child.visible = visible;
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
SetMaterial(material) {
|
|
1431
|
+
const primitiveMaterial = this._mesh.material;
|
|
1432
|
+
primitiveMaterial.color = new Color5(material.color);
|
|
1433
|
+
if (material.roughnessMap) {
|
|
1434
|
+
primitiveMaterial.roughnessMap = material.roughnessMap;
|
|
1435
|
+
primitiveMaterial.roughness = 1;
|
|
1436
|
+
} else {
|
|
1437
|
+
primitiveMaterial.roughness = material.roughness;
|
|
1438
|
+
}
|
|
1439
|
+
if (material.metalnessMap) {
|
|
1440
|
+
primitiveMaterial.metalnessMap = material.metalnessMap;
|
|
1441
|
+
primitiveMaterial.metalness = 0;
|
|
1442
|
+
} else {
|
|
1443
|
+
primitiveMaterial.metalness = material.metalness;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
SetToWorldOrigin() {
|
|
1447
|
+
var _a;
|
|
1448
|
+
this.position.set(0, 0, 0);
|
|
1449
|
+
(_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 });
|
|
1450
|
+
}
|
|
1451
|
+
PlaceOnFloor() {
|
|
1452
|
+
var _a;
|
|
1453
|
+
this.position.y = -this._boundingBox.min.y * this.scale.y;
|
|
1454
|
+
(_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 });
|
|
1455
|
+
}
|
|
1456
|
+
DropIt() {
|
|
1457
|
+
var _a;
|
|
1458
|
+
if (!this.parent) {
|
|
1459
|
+
console.warn("DIVEModel: DropIt() called on a model that is not in the scene.", this);
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
1463
|
+
const bbBottomCenter = this.localToWorld(this._boundingBox.getCenter(new Vector33()).multiply(this.scale));
|
|
1464
|
+
bbBottomCenter.y = bottomY + this.position.y;
|
|
1465
|
+
const raycaster = new Raycaster3(bbBottomCenter, new Vector33(0, -1, 0));
|
|
1466
|
+
raycaster.layers.mask = PRODUCT_LAYER_MASK;
|
|
1467
|
+
const intersections = raycaster.intersectObjects(findSceneRecursive(this).Root.children, true);
|
|
1468
|
+
if (intersections.length > 0) {
|
|
1469
|
+
const mesh = intersections[0].object;
|
|
1470
|
+
mesh.geometry.computeBoundingBox();
|
|
1471
|
+
const meshBB = mesh.geometry.boundingBox;
|
|
1472
|
+
const worldPos = mesh.localToWorld(meshBB.max.clone());
|
|
1473
|
+
const oldPos = this.position.clone();
|
|
1474
|
+
const newPos = this.position.clone().setY(worldPos.y).sub(new Vector33(0, bottomY, 0));
|
|
1475
|
+
this.position.copy(newPos);
|
|
1476
|
+
if (this.position.y === oldPos.y) return;
|
|
1477
|
+
(_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 });
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
onMove() {
|
|
1481
|
+
var _a;
|
|
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
|
+
onSelect() {
|
|
1485
|
+
var _a;
|
|
1486
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
1487
|
+
}
|
|
1488
|
+
onDeselect() {
|
|
1489
|
+
var _a;
|
|
1490
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
1491
|
+
}
|
|
1492
|
+
assembleGeometry(geometry) {
|
|
1493
|
+
switch (geometry.name) {
|
|
1494
|
+
case "cylinder":
|
|
1495
|
+
return this.createCylinderGeometry(geometry);
|
|
1496
|
+
case "sphere":
|
|
1497
|
+
return this.createSphereGeometry(geometry);
|
|
1498
|
+
case "pyramid":
|
|
1499
|
+
return this.createPyramidGeometry(geometry);
|
|
1500
|
+
case "box":
|
|
1501
|
+
return this.createBoxGeometry(geometry);
|
|
1502
|
+
case "cone":
|
|
1503
|
+
return this.createConeGeometry(geometry);
|
|
1504
|
+
case "wall":
|
|
1505
|
+
return this.createWallGeometry(geometry);
|
|
1506
|
+
case "plane":
|
|
1507
|
+
return this.createPlaneGeometry(geometry);
|
|
1508
|
+
default:
|
|
1509
|
+
return new BufferGeometry();
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
createCylinderGeometry(geometry) {
|
|
1513
|
+
return new CylinderGeometry(geometry.width * 2, geometry.width * 2, geometry.height, 64);
|
|
1514
|
+
}
|
|
1515
|
+
createSphereGeometry(geometry) {
|
|
1516
|
+
return new SphereGeometry2(geometry.width * 2, 64);
|
|
1517
|
+
}
|
|
1518
|
+
createPyramidGeometry(geometry) {
|
|
1519
|
+
const geo = new BufferGeometry();
|
|
1520
|
+
const { width, height, depth } = geometry;
|
|
1521
|
+
geo.setAttribute("position", new Float32BufferAttribute([
|
|
1522
|
+
width / 2,
|
|
1523
|
+
0,
|
|
1524
|
+
depth / 2,
|
|
1525
|
+
// right back
|
|
1526
|
+
width / 2,
|
|
1527
|
+
0,
|
|
1528
|
+
-depth / 2,
|
|
1529
|
+
// right front
|
|
1530
|
+
-width / 2,
|
|
1531
|
+
0,
|
|
1532
|
+
-depth / 2,
|
|
1533
|
+
// left front
|
|
1534
|
+
-width / 2,
|
|
1535
|
+
0,
|
|
1536
|
+
depth / 2,
|
|
1537
|
+
// left back
|
|
1538
|
+
0,
|
|
1539
|
+
height,
|
|
1540
|
+
0
|
|
1541
|
+
// top
|
|
1542
|
+
], 3));
|
|
1543
|
+
geo.setIndex(new Uint32BufferAttribute([
|
|
1544
|
+
1,
|
|
1545
|
+
0,
|
|
1546
|
+
4,
|
|
1547
|
+
2,
|
|
1548
|
+
1,
|
|
1549
|
+
4,
|
|
1550
|
+
3,
|
|
1551
|
+
2,
|
|
1552
|
+
4,
|
|
1553
|
+
3,
|
|
1554
|
+
0,
|
|
1555
|
+
4,
|
|
1556
|
+
0,
|
|
1557
|
+
1,
|
|
1558
|
+
2,
|
|
1559
|
+
0,
|
|
1560
|
+
2,
|
|
1561
|
+
3
|
|
1562
|
+
], 1));
|
|
1563
|
+
return geo;
|
|
1564
|
+
}
|
|
1565
|
+
createBoxGeometry(geometry) {
|
|
1566
|
+
return new BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1567
|
+
}
|
|
1568
|
+
createConeGeometry(geometry) {
|
|
1569
|
+
return new CylinderGeometry(0, geometry.width * 2, geometry.height, 64);
|
|
1570
|
+
}
|
|
1571
|
+
createWallGeometry(geometry) {
|
|
1572
|
+
return new BoxGeometry(geometry.width, geometry.height, geometry.depth, 16);
|
|
1573
|
+
}
|
|
1574
|
+
createPlaneGeometry(geometry) {
|
|
1575
|
+
return new BoxGeometry(geometry.width, geometry.height, geometry.depth);
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1579
|
+
// src/scene/root/primitiveroot/PrimitiveRoot.ts
|
|
1580
|
+
var DIVEPrimitiveRoot = class extends Object3D9 {
|
|
1581
|
+
constructor() {
|
|
1582
|
+
super();
|
|
1583
|
+
this.name = "PrimitiveRoot";
|
|
1584
|
+
}
|
|
1585
|
+
GetPrimitive(object) {
|
|
1586
|
+
if (object.id === void 0) {
|
|
1587
|
+
console.warn("PrimitiveRoot.GetPrimitive: object.id is undefined");
|
|
1588
|
+
return void 0;
|
|
1589
|
+
}
|
|
1590
|
+
return this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1591
|
+
}
|
|
1592
|
+
UpdatePrimitive(object) {
|
|
1593
|
+
if (object.id === void 0) {
|
|
1594
|
+
console.warn("PrimitiveRoot.UpdatePrimitive: object.id is undefined");
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
let sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1598
|
+
if (!sceneObject && object.geometry !== void 0) {
|
|
1599
|
+
const primitive = new DIVEPrimitive();
|
|
1600
|
+
primitive.SetGeometry(object.geometry);
|
|
1601
|
+
sceneObject = primitive;
|
|
1602
|
+
sceneObject.userData.id = object.id;
|
|
1603
|
+
this.add(sceneObject);
|
|
1604
|
+
}
|
|
1605
|
+
if (object.position !== void 0) sceneObject.SetPosition(object.position);
|
|
1606
|
+
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
1607
|
+
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
1608
|
+
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
1609
|
+
if (object.material !== void 0) sceneObject.SetMaterial(object.material);
|
|
1610
|
+
}
|
|
1611
|
+
DeletePrimitive(object) {
|
|
1612
|
+
if (object.id === void 0) {
|
|
1613
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: object.id is undefined`);
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1617
|
+
if (!sceneObject) {
|
|
1618
|
+
console.warn(`PrimitiveRoot.DeletePrimitive: Primitive with id ${object.id} not found`);
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1621
|
+
const findScene = (object2) => {
|
|
1622
|
+
if (object2.parent !== null) {
|
|
1623
|
+
return findScene(object2.parent);
|
|
1624
|
+
}
|
|
1625
|
+
;
|
|
1626
|
+
return object2;
|
|
1627
|
+
};
|
|
1628
|
+
const scene = findScene(sceneObject);
|
|
1629
|
+
scene.children.find((object2) => {
|
|
1630
|
+
if ("isTransformControls" in object2) {
|
|
1631
|
+
object2.detach();
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
this.remove(sceneObject);
|
|
1635
|
+
}
|
|
1636
|
+
PlaceOnFloor(object) {
|
|
1637
|
+
if (object.id === void 0) console.warn("PrimitiveRoot.PlaceOnFloor: object.id is undefined");
|
|
1638
|
+
const sceneObject = this.children.find((object3D) => object3D.userData.id === object.id);
|
|
1639
|
+
if (!sceneObject) return;
|
|
1640
|
+
sceneObject.PlaceOnFloor();
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1391
1644
|
// src/primitive/floor/Floor.ts
|
|
1392
1645
|
init_VisibilityLayerMask();
|
|
1393
|
-
import { Color as
|
|
1394
|
-
var DIVEFloor = class extends
|
|
1646
|
+
import { Color as Color6, Mesh as Mesh3, MeshStandardMaterial as MeshStandardMaterial2, PlaneGeometry } from "three";
|
|
1647
|
+
var DIVEFloor = class extends Mesh3 {
|
|
1395
1648
|
constructor() {
|
|
1396
|
-
super(new PlaneGeometry(1e4, 1e4), new
|
|
1649
|
+
super(new PlaneGeometry(1e4, 1e4), new MeshStandardMaterial2({ color: new Color6(150 / 255, 150 / 255, 150 / 255) }));
|
|
1397
1650
|
this.isFloor = true;
|
|
1398
1651
|
this.name = "Floor";
|
|
1399
1652
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
@@ -1404,7 +1657,7 @@ var DIVEFloor = class extends Mesh2 {
|
|
|
1404
1657
|
this.visible = visible;
|
|
1405
1658
|
}
|
|
1406
1659
|
SetColor(color) {
|
|
1407
|
-
this.material.color = new
|
|
1660
|
+
this.material.color = new Color6(color);
|
|
1408
1661
|
}
|
|
1409
1662
|
};
|
|
1410
1663
|
|
|
@@ -1414,8 +1667,8 @@ var GRID_SIDE_LINE_COLOR = "#dddddd";
|
|
|
1414
1667
|
|
|
1415
1668
|
// src/grid/Grid.ts
|
|
1416
1669
|
init_VisibilityLayerMask();
|
|
1417
|
-
import { GridHelper, Object3D as
|
|
1418
|
-
var DIVEGrid = class extends
|
|
1670
|
+
import { GridHelper, Object3D as Object3D10 } from "three";
|
|
1671
|
+
var DIVEGrid = class extends Object3D10 {
|
|
1419
1672
|
constructor() {
|
|
1420
1673
|
super();
|
|
1421
1674
|
this.name = "Grid";
|
|
@@ -1430,7 +1683,7 @@ var DIVEGrid = class extends Object3D8 {
|
|
|
1430
1683
|
};
|
|
1431
1684
|
|
|
1432
1685
|
// src/scene/root/Root.ts
|
|
1433
|
-
var DIVERoot = class extends
|
|
1686
|
+
var DIVERoot = class extends Object3D11 {
|
|
1434
1687
|
get Floor() {
|
|
1435
1688
|
return this.floor;
|
|
1436
1689
|
}
|
|
@@ -1444,18 +1697,25 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1444
1697
|
this.add(this.lightRoot);
|
|
1445
1698
|
this.modelRoot = new DIVEModelRoot();
|
|
1446
1699
|
this.add(this.modelRoot);
|
|
1700
|
+
this.primitiveRoot = new DIVEPrimitiveRoot();
|
|
1701
|
+
this.add(this.primitiveRoot);
|
|
1447
1702
|
this.floor = new DIVEFloor();
|
|
1448
1703
|
this.add(this.floor);
|
|
1449
1704
|
this.grid = new DIVEGrid();
|
|
1450
1705
|
this.add(this.grid);
|
|
1451
1706
|
}
|
|
1452
1707
|
ComputeSceneBB() {
|
|
1453
|
-
const bb = new
|
|
1708
|
+
const bb = new Box33();
|
|
1454
1709
|
this.modelRoot.traverse((object) => {
|
|
1455
1710
|
if ("isObject3D" in object) {
|
|
1456
1711
|
bb.expandByObject(object);
|
|
1457
1712
|
}
|
|
1458
1713
|
});
|
|
1714
|
+
this.primitiveRoot.traverse((object) => {
|
|
1715
|
+
if ("isObject3D" in object) {
|
|
1716
|
+
bb.expandByObject(object);
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1459
1719
|
return bb;
|
|
1460
1720
|
}
|
|
1461
1721
|
GetSceneObject(object) {
|
|
@@ -1469,6 +1729,9 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1469
1729
|
case "model": {
|
|
1470
1730
|
return this.modelRoot.GetModel(object);
|
|
1471
1731
|
}
|
|
1732
|
+
case "primitive": {
|
|
1733
|
+
return this.primitiveRoot.GetPrimitive(object);
|
|
1734
|
+
}
|
|
1472
1735
|
}
|
|
1473
1736
|
}
|
|
1474
1737
|
AddSceneObject(object) {
|
|
@@ -1484,6 +1747,10 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1484
1747
|
this.modelRoot.UpdateModel(object);
|
|
1485
1748
|
break;
|
|
1486
1749
|
}
|
|
1750
|
+
case "primitive": {
|
|
1751
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1752
|
+
break;
|
|
1753
|
+
}
|
|
1487
1754
|
}
|
|
1488
1755
|
}
|
|
1489
1756
|
UpdateSceneObject(object) {
|
|
@@ -1499,6 +1766,10 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1499
1766
|
this.modelRoot.UpdateModel(object);
|
|
1500
1767
|
break;
|
|
1501
1768
|
}
|
|
1769
|
+
case "primitive": {
|
|
1770
|
+
this.primitiveRoot.UpdatePrimitive(object);
|
|
1771
|
+
break;
|
|
1772
|
+
}
|
|
1502
1773
|
}
|
|
1503
1774
|
}
|
|
1504
1775
|
DeleteSceneObject(object) {
|
|
@@ -1514,10 +1785,27 @@ var DIVERoot = class extends Object3D9 {
|
|
|
1514
1785
|
this.modelRoot.DeleteModel(object);
|
|
1515
1786
|
break;
|
|
1516
1787
|
}
|
|
1788
|
+
case "primitive": {
|
|
1789
|
+
this.primitiveRoot.DeletePrimitive(object);
|
|
1790
|
+
break;
|
|
1791
|
+
}
|
|
1517
1792
|
}
|
|
1518
1793
|
}
|
|
1519
1794
|
PlaceOnFloor(object) {
|
|
1520
|
-
|
|
1795
|
+
switch (object.entityType) {
|
|
1796
|
+
case "pov":
|
|
1797
|
+
case "light": {
|
|
1798
|
+
break;
|
|
1799
|
+
}
|
|
1800
|
+
case "model": {
|
|
1801
|
+
this.modelRoot.PlaceOnFloor(object);
|
|
1802
|
+
break;
|
|
1803
|
+
}
|
|
1804
|
+
case "primitive": {
|
|
1805
|
+
this.primitiveRoot.PlaceOnFloor(object);
|
|
1806
|
+
break;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1521
1809
|
}
|
|
1522
1810
|
};
|
|
1523
1811
|
|
|
@@ -1528,12 +1816,12 @@ var DIVEScene = class extends Scene2 {
|
|
|
1528
1816
|
}
|
|
1529
1817
|
constructor() {
|
|
1530
1818
|
super();
|
|
1531
|
-
this.background = new
|
|
1819
|
+
this.background = new Color7(16777215);
|
|
1532
1820
|
this.root = new DIVERoot();
|
|
1533
1821
|
this.add(this.root);
|
|
1534
1822
|
}
|
|
1535
1823
|
SetBackground(color) {
|
|
1536
|
-
this.background = new
|
|
1824
|
+
this.background = new Color7(color);
|
|
1537
1825
|
}
|
|
1538
1826
|
ComputeSceneBB() {
|
|
1539
1827
|
return this.Root.ComputeSceneBB();
|
|
@@ -1560,7 +1848,7 @@ init_PerspectiveCamera();
|
|
|
1560
1848
|
|
|
1561
1849
|
// src/controls/OrbitControls.ts
|
|
1562
1850
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
|
|
1563
|
-
import { MathUtils as MathUtils2, Vector3 as
|
|
1851
|
+
import { MathUtils as MathUtils2, Vector3 as Vector34 } from "three";
|
|
1564
1852
|
import { Easing } from "@tweenjs/tween.js";
|
|
1565
1853
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1566
1854
|
enableDamping: true,
|
|
@@ -1602,8 +1890,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
|
1602
1890
|
this.dispose();
|
|
1603
1891
|
}
|
|
1604
1892
|
ComputeEncompassingView(bb) {
|
|
1605
|
-
const center = bb.getCenter(new
|
|
1606
|
-
const size = bb.getSize(new
|
|
1893
|
+
const center = bb.getCenter(new Vector34());
|
|
1894
|
+
const size = bb.getSize(new Vector34());
|
|
1607
1895
|
const distance = Math.max(size.x, size.y, size.z) * 1.25;
|
|
1608
1896
|
const direction = this.object.position.clone().normalize();
|
|
1609
1897
|
return {
|
|
@@ -1771,7 +2059,7 @@ var DIVEAnimationSystem = class {
|
|
|
1771
2059
|
|
|
1772
2060
|
// src/axiscamera/AxisCamera.ts
|
|
1773
2061
|
init_VisibilityLayerMask();
|
|
1774
|
-
import { AxesHelper, Color as
|
|
2062
|
+
import { AxesHelper, Color as Color8, Matrix4, OrthographicCamera, Vector4 } from "three";
|
|
1775
2063
|
import SpriteText from "three-spritetext";
|
|
1776
2064
|
|
|
1777
2065
|
// src/constant/AxisHelperColors.ts
|
|
@@ -1792,9 +2080,9 @@ var DIVEAxisCamera = class extends OrthographicCamera {
|
|
|
1792
2080
|
this.axesHelper.material.depthTest = false;
|
|
1793
2081
|
this.axesHelper.position.set(0, 0, -1);
|
|
1794
2082
|
this.axesHelper.setColors(
|
|
1795
|
-
new
|
|
1796
|
-
new
|
|
1797
|
-
new
|
|
2083
|
+
new Color8(AxesColorRed),
|
|
2084
|
+
new Color8(AxesColorGreen),
|
|
2085
|
+
new Color8(AxesColorBlue)
|
|
1798
2086
|
);
|
|
1799
2087
|
const x = new SpriteText("X", 0.2, AxesColorRedLetter);
|
|
1800
2088
|
const y = new SpriteText("Y", 0.2, AxesColorGreenLetter);
|