@xeokit/xeokit-sdk 2.6.28 → 2.6.29
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/README.md +1 -0
- package/dist/xeokit-sdk.cjs.js +915 -220
- package/dist/xeokit-sdk.es.js +910 -221
- package/dist/xeokit-sdk.es5.js +576 -486
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +1 -1
- package/src/extras/PointerCircle/PointerCircle.js +1 -1
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +22 -41
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.js +3 -18
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +20 -41
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.js +4 -20
- package/src/plugins/DistanceMeasurementsPlugin/index.js +1 -1
- package/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +31 -1
- package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +20 -8
- package/src/plugins/ZonesPlugin/ZonesPlugin.js +1939 -0
- package/src/plugins/ZonesPlugin/index.js +1 -1875
- package/src/viewer/Viewer.js +2 -2
- package/src/viewer/scene/math/MeshSurfaceArea.js +90 -0
- package/src/viewer/scene/math/MeshVolume.js +102 -0
- package/src/viewer/scene/math/index.js +3 -0
- package/src/viewer/scene/math/isTriangleMeshSolid.js +162 -0
- package/src/viewer/scene/math/math.js +8 -0
- package/src/viewer/scene/model/SceneModel.js +64 -34
- package/src/viewer/scene/model/SceneModelEntity.js +46 -1
- package/src/viewer/scene/model/SceneModelMesh.js +74 -1
- package/src/viewer/scene/model/dtx/lines/DTXLinesLayer.js +7 -1
- package/src/viewer/scene/model/dtx/triangles/DTXTrianglesLayer.js +77 -1
- package/src/viewer/scene/model/vbo/batching/lines/VBOBatchingLinesLayer.js +6 -1
- package/src/viewer/scene/model/vbo/batching/points/VBOBatchingPointsLayer.js +6 -1
- package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +33 -12
- package/src/viewer/scene/model/vbo/instancing/lines/VBOInstancingLinesLayer.js +6 -1
- package/src/viewer/scene/model/vbo/instancing/points/VBOInstancingPointsLayer.js +6 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +31 -10
- package/src/viewer/scene/scene/Scene.js +16 -5
- package/src/viewer/scene/webgl/occlusion/OcclusionTester.js +0 -1
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts +7 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.d.ts +26 -1
- package/types/plugins/DistanceMeasurementsPlugin/index.d.ts +3 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {math} from "../math/math.js";
|
|
2
|
+
import {meshSurfaceArea, meshVolume} from "../math/index.js";
|
|
2
3
|
|
|
3
4
|
const tempOBB3 = math.OBB3();
|
|
4
5
|
const tempOBB3b = math.OBB3();
|
|
5
6
|
const tempOBB3c = math.OBB3();
|
|
6
7
|
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* A mesh within a {@link SceneModel}.
|
|
9
11
|
*
|
|
@@ -116,6 +118,9 @@ export class SceneModelMesh {
|
|
|
116
118
|
if (transform) {
|
|
117
119
|
transform._addMesh(this);
|
|
118
120
|
}
|
|
121
|
+
|
|
122
|
+
this._volume = null;
|
|
123
|
+
this._surfaceArea = null;
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
_sceneModelDirty() {
|
|
@@ -294,7 +299,75 @@ export class SceneModelMesh {
|
|
|
294
299
|
* @private
|
|
295
300
|
*/
|
|
296
301
|
getEachVertex(callback) {
|
|
297
|
-
this.layer.getEachVertex
|
|
302
|
+
if (this.layer.getEachVertex) {
|
|
303
|
+
this.layer.getEachVertex(this.portionId, callback);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @private
|
|
309
|
+
*/
|
|
310
|
+
getEachIndex(callback) {
|
|
311
|
+
if (this.layer.getEachIndex ) {
|
|
312
|
+
this.layer.getEachIndex(this.portionId, callback);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Returns the volume of this SceneModelMesh.
|
|
318
|
+
* @returns {number}
|
|
319
|
+
*/
|
|
320
|
+
get volume() {
|
|
321
|
+
if (this._volume !== null) {
|
|
322
|
+
return this._volume;
|
|
323
|
+
}
|
|
324
|
+
switch (this.layer.primitive) {
|
|
325
|
+
case "solid":
|
|
326
|
+
case "surface":
|
|
327
|
+
case "triangles":
|
|
328
|
+
meshVolume.reset();
|
|
329
|
+
meshVolume.setPrimitive(this.layer.primitive);
|
|
330
|
+
this.getEachVertex((vertex) =>{
|
|
331
|
+
meshVolume.addVertex(vertex);
|
|
332
|
+
});
|
|
333
|
+
this.getEachIndex((index)=>{
|
|
334
|
+
meshVolume.addIndex(index);
|
|
335
|
+
});
|
|
336
|
+
this._volume = meshVolume.volume;
|
|
337
|
+
break;
|
|
338
|
+
default:
|
|
339
|
+
this._volume = 0;
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
return this._volume;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Returns the surface area of this SceneModelMesh.
|
|
347
|
+
* @returns {number}
|
|
348
|
+
*/
|
|
349
|
+
get surfaceArea() {
|
|
350
|
+
if (this._surfaceArea !== null) {
|
|
351
|
+
return this._surfaceArea;
|
|
352
|
+
}
|
|
353
|
+
switch (this.layer.primitive) {
|
|
354
|
+
case "solid":
|
|
355
|
+
case "surface":
|
|
356
|
+
case "triangles":
|
|
357
|
+
meshSurfaceArea.reset();
|
|
358
|
+
this.getEachVertex((vertex) =>{
|
|
359
|
+
meshSurfaceArea.addVertex(vertex);
|
|
360
|
+
});
|
|
361
|
+
this.getEachIndex((index)=>{
|
|
362
|
+
meshSurfaceArea.addIndex(index);
|
|
363
|
+
});
|
|
364
|
+
this._surfaceArea = meshSurfaceArea.surfaceArea;
|
|
365
|
+
break;
|
|
366
|
+
default:
|
|
367
|
+
this._surfaceArea = 0;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
return this._surfaceArea;
|
|
298
371
|
}
|
|
299
372
|
|
|
300
373
|
/**
|
|
@@ -31,7 +31,7 @@ export class DTXLinesLayer {
|
|
|
31
31
|
|
|
32
32
|
constructor(model, cfg) {
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
// console.info("Creating DTXLinesLayer");
|
|
35
35
|
|
|
36
36
|
dataTextureRamStats.numberOfLayers++;
|
|
37
37
|
|
|
@@ -70,6 +70,12 @@ export class DTXLinesLayer {
|
|
|
70
70
|
this._aabb = math.collapseAABB3();
|
|
71
71
|
this.aabbDirty = true;
|
|
72
72
|
this._numUpdatesInFrame = 0;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The type of primitives in this layer.
|
|
76
|
+
*/
|
|
77
|
+
this.primitive = cfg.primitive;
|
|
78
|
+
|
|
73
79
|
this._finalized = false;
|
|
74
80
|
}
|
|
75
81
|
|
|
@@ -38,6 +38,7 @@ const INDICES_EDGE_INDICES_ALIGNEMENT_SIZE = 8;
|
|
|
38
38
|
*/
|
|
39
39
|
const MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE = 10;
|
|
40
40
|
|
|
41
|
+
const tempVec4a = math.vec4();
|
|
41
42
|
const tempMat4a = new Float32Array(16);
|
|
42
43
|
const tempUint8Array4 = new Uint8Array(4);
|
|
43
44
|
const tempFloat32Array3 = new Float32Array(3);
|
|
@@ -53,7 +54,7 @@ export class DTXTrianglesLayer {
|
|
|
53
54
|
|
|
54
55
|
constructor(model, cfg) {
|
|
55
56
|
|
|
56
|
-
console.info("Creating DTXTrianglesLayer");
|
|
57
|
+
//console.info("Creating DTXTrianglesLayer");
|
|
57
58
|
|
|
58
59
|
dataTextureRamStats.numberOfLayers++;
|
|
59
60
|
|
|
@@ -93,6 +94,10 @@ export class DTXTrianglesLayer {
|
|
|
93
94
|
|
|
94
95
|
this._subPortions = [];
|
|
95
96
|
|
|
97
|
+
if (this.model.scene.readableGeometryEnabled) {
|
|
98
|
+
this._subPortionReadableGeometries = {};
|
|
99
|
+
}
|
|
100
|
+
|
|
96
101
|
/**
|
|
97
102
|
* Due to `index rebucketting` process in ```prepareMeshGeometry``` function, it's possible that a single
|
|
98
103
|
* portion is expanded to more than 1 real sub-portion.
|
|
@@ -122,6 +127,11 @@ export class DTXTrianglesLayer {
|
|
|
122
127
|
*/
|
|
123
128
|
this._numUpdatesInFrame = 0;
|
|
124
129
|
|
|
130
|
+
/**
|
|
131
|
+
* The type of primitives in this layer.
|
|
132
|
+
*/
|
|
133
|
+
this.primitive = cfg.primitive;
|
|
134
|
+
|
|
125
135
|
this._finalized = false;
|
|
126
136
|
}
|
|
127
137
|
|
|
@@ -426,6 +436,15 @@ export class DTXTrianglesLayer {
|
|
|
426
436
|
numVertices: bucketGeometry.numTriangles
|
|
427
437
|
});
|
|
428
438
|
|
|
439
|
+
if (this.model.scene.readableGeometryEnabled) {
|
|
440
|
+
this._subPortionReadableGeometries[subPortionId] = {
|
|
441
|
+
indices: bucket.indices,
|
|
442
|
+
positionsCompressed: bucket.positionsCompressed,
|
|
443
|
+
positionsDecodeMatrix: portionCfg.positionsDecodeMatrix,
|
|
444
|
+
meshMatrix: portionCfg.meshMatrix
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
429
448
|
this._numPortions++;
|
|
430
449
|
|
|
431
450
|
dataTextureRamStats.numberOfPortions++;
|
|
@@ -1076,6 +1095,63 @@ export class DTXTrianglesLayer {
|
|
|
1076
1095
|
// gl.bindTexture (gl.TEXTURE_2D, null);
|
|
1077
1096
|
}
|
|
1078
1097
|
|
|
1098
|
+
getEachVertex(portionId, callback) {
|
|
1099
|
+
if (!this.model.scene.readableGeometryEnabled) {
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
const state = this._state;
|
|
1103
|
+
const subPortionIds = this._portionToSubPortionsMap[portionId];
|
|
1104
|
+
if (!subPortionIds) {
|
|
1105
|
+
this.model.error("portion not found: " + portionId);
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
for (let i = 0, len = subPortionIds.length; i < len; i++) {
|
|
1109
|
+
const subPortionId = subPortionIds[i];
|
|
1110
|
+
const subPortionReadableGeometry = this._subPortionReadableGeometries[subPortionId];
|
|
1111
|
+
const positions = subPortionReadableGeometry.positionsCompressed;
|
|
1112
|
+
const positionsDecodeMatrix = subPortionReadableGeometry.positionsDecodeMatrix;
|
|
1113
|
+
const meshMatrix = subPortionReadableGeometry.meshMatrix;
|
|
1114
|
+
const origin = state.origin;
|
|
1115
|
+
const offsetX = origin[0] ;
|
|
1116
|
+
const offsetY = origin[1] ;
|
|
1117
|
+
const offsetZ = origin[2] ;
|
|
1118
|
+
const worldPos = tempVec4a;
|
|
1119
|
+
for (let i = 0, len = positions.length; i < len; i += 3) {
|
|
1120
|
+
worldPos[0] = positions[i];
|
|
1121
|
+
worldPos[1] = positions[i + 1];
|
|
1122
|
+
worldPos[2] = positions[i + 2];
|
|
1123
|
+
worldPos[3] = 1.0;
|
|
1124
|
+
math.decompressPosition(worldPos, positionsDecodeMatrix);
|
|
1125
|
+
math.transformPoint4(this.model.worldMatrix, worldPos);
|
|
1126
|
+
math.transformPoint4(this.model.worldMatrix, worldPos);
|
|
1127
|
+
worldPos[0] += offsetX;
|
|
1128
|
+
worldPos[1] += offsetY;
|
|
1129
|
+
worldPos[2] += offsetZ;
|
|
1130
|
+
callback(worldPos);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
getEachIndex(portionId, callback) {
|
|
1136
|
+
if (!this.model.scene.readableGeometryEnabled) {
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
const subPortionIds = this._portionToSubPortionsMap[portionId];
|
|
1140
|
+
if (!subPortionIds) {
|
|
1141
|
+
this.model.error("portion not found: " + portionId);
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
for (let i = 0, len = subPortionIds.length; i < len; i++) {
|
|
1145
|
+
const subPortionId = subPortionIds[i];
|
|
1146
|
+
const subPortionReadableGeometry = this._subPortionReadableGeometries[subPortionId];
|
|
1147
|
+
const indices = subPortionReadableGeometry.indices;
|
|
1148
|
+
for (let i = 0, len = indices.length; i < len; i++) {
|
|
1149
|
+
callback(indices[i]);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
|
|
1079
1155
|
// ---------------------- COLOR RENDERING -----------------------------------
|
|
1080
1156
|
|
|
1081
1157
|
drawColorOpaque(renderFlags, frameCtx) {
|
|
@@ -24,7 +24,7 @@ export class VBOBatchingLinesLayer {
|
|
|
24
24
|
*/
|
|
25
25
|
constructor(cfg) {
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// console.info("Creating VBOBatchingLinesLayer");
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Index of this LinesBatchingLayer in {@link VBOSceneModel#_layerList}.
|
|
@@ -79,6 +79,11 @@ export class VBOBatchingLinesLayer {
|
|
|
79
79
|
if (cfg.origin) {
|
|
80
80
|
this._state.origin = math.vec3(cfg.origin);
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The type of primitives in this layer.
|
|
85
|
+
*/
|
|
86
|
+
this.primitive = cfg.primitive;
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
get aabb() {
|
|
@@ -24,7 +24,7 @@ export class VBOBatchingPointsLayer {
|
|
|
24
24
|
*/
|
|
25
25
|
constructor(cfg) {
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// console.info("Creating VBOBatchingPointsLayer");
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Owner model
|
|
@@ -99,6 +99,11 @@ export class VBOBatchingPointsLayer {
|
|
|
99
99
|
this.aabbDirty = false;
|
|
100
100
|
}
|
|
101
101
|
return this._aabb;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The type of primitives in this layer.
|
|
105
|
+
*/
|
|
106
|
+
this.primitive = cfg.primitive;
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
/**
|
|
@@ -41,7 +41,7 @@ export class VBOBatchingTrianglesLayer {
|
|
|
41
41
|
*/
|
|
42
42
|
constructor(cfg) {
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
// console.info("Creating VBOBatchingTrianglesLayer");
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Owner model
|
|
@@ -131,6 +131,11 @@ export class VBOBatchingTrianglesLayer {
|
|
|
131
131
|
* @type {boolean}
|
|
132
132
|
*/
|
|
133
133
|
this.solid = !!cfg.solid;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The type of primitives in this layer.
|
|
137
|
+
*/
|
|
138
|
+
this.primitive = cfg.primitive;
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
get aabb() {
|
|
@@ -327,7 +332,7 @@ export class VBOBatchingTrianglesLayer {
|
|
|
327
332
|
numIndices: indices.length,
|
|
328
333
|
};
|
|
329
334
|
|
|
330
|
-
if (scene.
|
|
335
|
+
if (scene.readableGeometryEnabled) {
|
|
331
336
|
// Quantized in-memory positions are initialized in finalize()
|
|
332
337
|
|
|
333
338
|
portion.indices = indices;
|
|
@@ -364,7 +369,7 @@ export class VBOBatchingTrianglesLayer {
|
|
|
364
369
|
? new Uint16Array(buffer.positions)
|
|
365
370
|
: quantizePositions(buffer.positions, this._modelAABB, this._state.positionsDecodeMatrix = math.mat4()); // BOTTLENECK
|
|
366
371
|
state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, quantizedPositions, quantizedPositions.length, 3, gl.STATIC_DRAW);
|
|
367
|
-
if (this.model.scene.
|
|
372
|
+
if (this.model.scene.readableGeometryEnabled) {
|
|
368
373
|
for (let i = 0, numPortions = this._portions.length; i < numPortions; i++) {
|
|
369
374
|
const portion = this._portions[i];
|
|
370
375
|
const start = portion.vertsBaseIndex * 3;
|
|
@@ -793,7 +798,7 @@ export class VBOBatchingTrianglesLayer {
|
|
|
793
798
|
if (this._state.offsetsBuf) {
|
|
794
799
|
this._state.offsetsBuf.setData(tempArray, firstOffset, lenOffsets);
|
|
795
800
|
}
|
|
796
|
-
if (this.model.scene.
|
|
801
|
+
if (this.model.scene.readableGeometryEnabled) {
|
|
797
802
|
portion.offset[0] = offset[0];
|
|
798
803
|
portion.offset[1] = offset[1];
|
|
799
804
|
portion.offset[2] = offset[2];
|
|
@@ -801,7 +806,7 @@ export class VBOBatchingTrianglesLayer {
|
|
|
801
806
|
}
|
|
802
807
|
|
|
803
808
|
getEachVertex(portionId, callback) {
|
|
804
|
-
if (!this.model.scene.
|
|
809
|
+
if (!this.model.scene.readableGeometryEnabled) {
|
|
805
810
|
return;
|
|
806
811
|
}
|
|
807
812
|
const state = this._state;
|
|
@@ -812,18 +817,19 @@ export class VBOBatchingTrianglesLayer {
|
|
|
812
817
|
}
|
|
813
818
|
const positions = portion.quantizedPositions;
|
|
814
819
|
const origin = state.origin;
|
|
815
|
-
const
|
|
816
|
-
const
|
|
817
|
-
const
|
|
818
|
-
const offsetZ = origin[2] + offset[2];
|
|
820
|
+
const offsetX = origin[0] ;
|
|
821
|
+
const offsetY = origin[1] ;
|
|
822
|
+
const offsetZ = origin[2] ;
|
|
819
823
|
const worldPos = tempVec4a;
|
|
824
|
+
const sceneModelMatrix = this.model.matrix;
|
|
825
|
+
const positionsDecodeMatrix = state.positionsDecodeMatrix;
|
|
820
826
|
for (let i = 0, len = positions.length; i < len; i += 3) {
|
|
821
827
|
worldPos[0] = positions[i];
|
|
822
828
|
worldPos[1] = positions[i + 1];
|
|
823
829
|
worldPos[2] = positions[i + 2];
|
|
824
830
|
worldPos[3] = 1.0;
|
|
825
|
-
math.decompressPosition(worldPos,
|
|
826
|
-
math.transformPoint4(
|
|
831
|
+
math.decompressPosition(worldPos, positionsDecodeMatrix);
|
|
832
|
+
math.transformPoint4(sceneModelMatrix, worldPos);
|
|
827
833
|
worldPos[0] += offsetX;
|
|
828
834
|
worldPos[1] += offsetY;
|
|
829
835
|
worldPos[2] += offsetZ;
|
|
@@ -831,6 +837,21 @@ export class VBOBatchingTrianglesLayer {
|
|
|
831
837
|
}
|
|
832
838
|
}
|
|
833
839
|
|
|
840
|
+
getEachIndex(portionId, callback) {
|
|
841
|
+
if (!this.model.scene.readableGeometryEnabled) {
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
const portion = this._portions[portionId];
|
|
845
|
+
if (!portion) {
|
|
846
|
+
this.model.error("portion not found: " + portionId);
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
const indices = portion.indices;
|
|
850
|
+
for (let i = 0, len = indices.length; i < len; i++) {
|
|
851
|
+
callback(indices[i]);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
834
855
|
getElementsCountAndOffset(portionId) {
|
|
835
856
|
let count = null;
|
|
836
857
|
let offset = null;
|
|
@@ -1118,7 +1139,7 @@ export class VBOBatchingTrianglesLayer {
|
|
|
1118
1139
|
|
|
1119
1140
|
precisionRayPickSurface(portionId, worldRayOrigin, worldRayDir, worldSurfacePos, worldNormal) {
|
|
1120
1141
|
|
|
1121
|
-
if (!this.model.scene.
|
|
1142
|
+
if (!this.model.scene.readableGeometryEnabled) {
|
|
1122
1143
|
return false;
|
|
1123
1144
|
}
|
|
1124
1145
|
|
|
@@ -28,7 +28,7 @@ class VBOInstancingLinesLayer {
|
|
|
28
28
|
*/
|
|
29
29
|
constructor(cfg) {
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
// console.info("VBOInstancingLinesLayer");
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Owner model
|
|
@@ -108,6 +108,11 @@ class VBOInstancingLinesLayer {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
this._finalized = false;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The type of primitives in this layer.
|
|
114
|
+
*/
|
|
115
|
+
this.primitive = cfg.primitive;
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
get aabb() {
|
|
@@ -27,7 +27,7 @@ export class VBOInstancingPointsLayer {
|
|
|
27
27
|
*/
|
|
28
28
|
constructor(cfg) {
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
// console.info("VBOInstancingPointsLayer");
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Owner model
|
|
@@ -101,6 +101,11 @@ export class VBOInstancingPointsLayer {
|
|
|
101
101
|
this.aabbDirty = true;
|
|
102
102
|
|
|
103
103
|
this._finalized = false;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The type of primitives in this layer.
|
|
107
|
+
*/
|
|
108
|
+
this.primitive = cfg.geometry.primitive;
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
get aabb() {
|
|
@@ -36,7 +36,7 @@ export class VBOInstancingTrianglesLayer {
|
|
|
36
36
|
*/
|
|
37
37
|
constructor(cfg) {
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
// console.info("Creating VBOInstancingTrianglesLayer");
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Owner model
|
|
@@ -139,6 +139,11 @@ export class VBOInstancingTrianglesLayer {
|
|
|
139
139
|
* @type {number|*}
|
|
140
140
|
*/
|
|
141
141
|
this.numIndices = cfg.geometry.numIndices;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The type of primitives in this layer.
|
|
145
|
+
*/
|
|
146
|
+
this.primitive = cfg.geometry.primitive;
|
|
142
147
|
}
|
|
143
148
|
|
|
144
149
|
get aabb() {
|
|
@@ -252,7 +257,7 @@ export class VBOInstancingTrianglesLayer {
|
|
|
252
257
|
|
|
253
258
|
const portion = {};
|
|
254
259
|
|
|
255
|
-
if (this.model.scene.
|
|
260
|
+
if (this.model.scene.readableGeometryEnabled) {
|
|
256
261
|
portion.matrix = meshMatrix.slice();
|
|
257
262
|
portion.inverseMatrix = null; // Lazy-computed in precisionRayPickSurface
|
|
258
263
|
portion.normalMatrix = null; // Lazy-computed in precisionRayPickSurface
|
|
@@ -690,7 +695,7 @@ export class VBOInstancingTrianglesLayer {
|
|
|
690
695
|
}
|
|
691
696
|
|
|
692
697
|
getEachVertex(portionId, callback) {
|
|
693
|
-
if (!this.model.scene.
|
|
698
|
+
if (!this.model.scene.readableGeometryEnabled) {
|
|
694
699
|
return false;
|
|
695
700
|
}
|
|
696
701
|
const state = this._state;
|
|
@@ -702,13 +707,12 @@ export class VBOInstancingTrianglesLayer {
|
|
|
702
707
|
}
|
|
703
708
|
const positions = geometry.quantizedPositions;
|
|
704
709
|
const origin = state.origin;
|
|
705
|
-
const
|
|
706
|
-
const
|
|
707
|
-
const
|
|
708
|
-
const offsetZ = origin[2] + offset[2];
|
|
710
|
+
const offsetX = origin[0] ;
|
|
711
|
+
const offsetY = origin[1] ;
|
|
712
|
+
const offsetZ = origin[2] ;
|
|
709
713
|
const worldPos = tempVec4a;
|
|
710
714
|
const portionMatrix = portion.matrix;
|
|
711
|
-
const
|
|
715
|
+
const sceneModelMatrix = this.model.matrix;
|
|
712
716
|
const positionsDecodeMatrix = state.positionsDecodeMatrix;
|
|
713
717
|
for (let i = 0, len = positions.length; i < len; i += 3) {
|
|
714
718
|
worldPos[0] = positions[i];
|
|
@@ -716,7 +720,7 @@ export class VBOInstancingTrianglesLayer {
|
|
|
716
720
|
worldPos[2] = positions[i + 2];
|
|
717
721
|
math.decompressPosition(worldPos, positionsDecodeMatrix);
|
|
718
722
|
math.transformPoint3(portionMatrix, worldPos);
|
|
719
|
-
math.transformPoint3(
|
|
723
|
+
math.transformPoint3(sceneModelMatrix, worldPos);
|
|
720
724
|
worldPos[0] += offsetX;
|
|
721
725
|
worldPos[1] += offsetY;
|
|
722
726
|
worldPos[2] += offsetZ;
|
|
@@ -724,6 +728,23 @@ export class VBOInstancingTrianglesLayer {
|
|
|
724
728
|
}
|
|
725
729
|
}
|
|
726
730
|
|
|
731
|
+
getEachIndex(portionId, callback) {
|
|
732
|
+
if (!this.model.scene.readableGeometryEnabled) {
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
const state = this._state;
|
|
736
|
+
const geometry = state.geometry;
|
|
737
|
+
const portion = this._portions[portionId];
|
|
738
|
+
if (!portion) {
|
|
739
|
+
this.model.error("portion not found: " + portionId);
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
const indices = geometry.indices;
|
|
743
|
+
for (let i = 0, len = indices.length; i < len; i++) {
|
|
744
|
+
callback(indices[i]);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
727
748
|
setMatrix(portionId, matrix) {
|
|
728
749
|
if (!this._finalized) {
|
|
729
750
|
throw "Not finalized";
|
|
@@ -1030,7 +1051,7 @@ export class VBOInstancingTrianglesLayer {
|
|
|
1030
1051
|
|
|
1031
1052
|
precisionRayPickSurface(portionId, worldRayOrigin, worldRayDir, worldSurfacePos, worldNormal) {
|
|
1032
1053
|
|
|
1033
|
-
if (!this.model.scene.
|
|
1054
|
+
if (!this.model.scene.readableGeometryEnabled) {
|
|
1034
1055
|
return false;
|
|
1035
1056
|
}
|
|
1036
1057
|
|
|
@@ -368,6 +368,8 @@ class Scene extends Component {
|
|
|
368
368
|
|
|
369
369
|
this._aabbDirty = true;
|
|
370
370
|
|
|
371
|
+
this._readableGeometry = !!cfg.readableGeometryEnabled;
|
|
372
|
+
|
|
371
373
|
/**
|
|
372
374
|
* The {@link Viewer} this Scene belongs to.
|
|
373
375
|
* @type {Viewer}
|
|
@@ -1292,18 +1294,27 @@ class Scene extends Component {
|
|
|
1292
1294
|
}
|
|
1293
1295
|
|
|
1294
1296
|
/**
|
|
1295
|
-
* Whether
|
|
1297
|
+
* Whether geometry is readable.
|
|
1296
1298
|
*
|
|
1297
1299
|
* This is set via the {@link Viewer} constructor and is ````false```` by default.
|
|
1298
1300
|
*
|
|
1299
|
-
* The ````
|
|
1301
|
+
* The ````readableGeometryEnabled```` option for ````Scene#pick```` only works if this is set ````true````.
|
|
1300
1302
|
*
|
|
1301
1303
|
* Note that when ````true````, this configuration will increase the amount of browser memory used by the Viewer.
|
|
1302
1304
|
*
|
|
1303
|
-
* @returns {Boolean} True if
|
|
1305
|
+
* @returns {Boolean} True if geometry is readable.
|
|
1306
|
+
*/
|
|
1307
|
+
get readableGeometryEnabled() {
|
|
1308
|
+
return this._readableGeometry;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Whether precision surface picking is enabled.
|
|
1313
|
+
* @deprecated
|
|
1314
|
+
* @returns {*|boolean}
|
|
1304
1315
|
*/
|
|
1305
1316
|
get pickSurfacePrecisionEnabled() {
|
|
1306
|
-
return
|
|
1317
|
+
return this._readableGeometry;
|
|
1307
1318
|
}
|
|
1308
1319
|
|
|
1309
1320
|
/**
|
|
@@ -2284,7 +2295,7 @@ class Scene extends Component {
|
|
|
2284
2295
|
*
|
|
2285
2296
|
* @param {*} params Picking parameters.
|
|
2286
2297
|
* @param {Boolean} [params.pickSurface=false] Whether to find the picked position on the surface of the Entity.
|
|
2287
|
-
* @param {Boolean} [params.pickSurfacePrecision=false] When picking an Entity surface position, indicates whether or not we want full-precision {@link PickResult#worldPos}. Only works when {@link Scene#
|
|
2298
|
+
* @param {Boolean} [params.pickSurfacePrecision=false] When picking an Entity surface position, indicates whether or not we want full-precision {@link PickResult#worldPos}. Only works when {@link Scene#readableGeometryEnabled} is ````true````. If pick succeeds, the returned {@link PickResult} will have {@link PickResult#precision} set ````true````, to indicate that it contains full-precision surface pick results.
|
|
2288
2299
|
* @param {Boolean} [params.pickSurfaceNormal=false] Whether to find the picked normal on the surface of the Entity. Only works if ````pickSurface```` is given.
|
|
2289
2300
|
* @param {Number[]} [params.canvasPos] Canvas-space coordinates. When ray-picking, this will override the **origin** and ** direction** parameters and will cause the ray to be fired through the canvas at this position, directly along the negative View-space Z-axis.
|
|
2290
2301
|
* @param {Number[]} [params.origin] World-space ray origin when ray-picking. Ignored when canvasPos given.
|
|
@@ -2,7 +2,6 @@ import {math} from '../../math/math.js';
|
|
|
2
2
|
import {Program} from "./../Program.js";
|
|
3
3
|
import {OcclusionLayer} from "./OcclusionLayer.js";
|
|
4
4
|
import {createRTCViewMat, getPlaneRTCPos} from "../../math/rtcCoords.js";
|
|
5
|
-
import {WEBGL_INFO} from "../../webglInfo.js";
|
|
6
5
|
|
|
7
6
|
const TEST_MODE = false;
|
|
8
7
|
const MARKER_COLOR = math.vec3([1.0, 0.0, 0.0]);
|
|
@@ -231,4 +231,11 @@ export declare class DistanceMeasurement extends Component {
|
|
|
231
231
|
* @type {Boolean}
|
|
232
232
|
*/
|
|
233
233
|
get labelsOnWires() : boolean;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Sets the higlihted state on a measurement
|
|
237
|
+
*
|
|
238
|
+
* @type {String}
|
|
239
|
+
*/
|
|
240
|
+
setHighlighted(highlighted: boolean): void;
|
|
234
241
|
}
|
|
@@ -91,6 +91,31 @@ export declare type DistanceMeasurementMouseLeaveEvent = {
|
|
|
91
91
|
event: MouseEvent;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Event fire by {@link DistanceMeasurementsPlugin} when context menu is shown on {@link DistanceMeasurement}.
|
|
96
|
+
*/
|
|
97
|
+
export declare type DistanceMeasurementMouseContextMenuEvent = {
|
|
98
|
+
/**
|
|
99
|
+
* The plugin.
|
|
100
|
+
*/
|
|
101
|
+
plugin: DistanceMeasurementsPlugin;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The measurement.
|
|
105
|
+
*/
|
|
106
|
+
distanceMeasurement: DistanceMeasurement;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The measurement.
|
|
110
|
+
*/
|
|
111
|
+
measurement: DistanceMeasurement;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The original mouse event.
|
|
115
|
+
*/
|
|
116
|
+
event: MouseEvent;
|
|
117
|
+
}
|
|
118
|
+
|
|
94
119
|
/**
|
|
95
120
|
* {@link Viewer} plugin for measuring point-to-point distances.
|
|
96
121
|
*/
|
|
@@ -206,7 +231,7 @@ export declare class DistanceMeasurementsPlugin extends Plugin {
|
|
|
206
231
|
* @param {String} event The contextMenu event
|
|
207
232
|
* @param {Function} callback Callback fired on the event
|
|
208
233
|
*/
|
|
209
|
-
on(event: "contextMenu", callback: (
|
|
234
|
+
on(event: "contextMenu", callback: (event: DistanceMeasurementMouseContextMenuEvent)=> void): string;
|
|
210
235
|
|
|
211
236
|
/**
|
|
212
237
|
* Fires when a measurement is created.
|