@xeokit/xeokit-sdk 2.6.78-rc1-no-las → 2.6.78
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/dist/xeokit-sdk.cjs.js +32532 -15213
- package/dist/xeokit-sdk.es.js +32531 -15214
- package/dist/xeokit-sdk.es5.js +29446 -30855
- package/dist/xeokit-sdk.min.cjs.js +8 -8
- package/dist/xeokit-sdk.min.es.js +8 -8
- package/dist/xeokit-sdk.min.es5.js +33 -34
- package/package.json +4 -7
- package/src/plugins/CxConverterIFCLoaderPlugin/CxConverterIFCLoaderPlugin.js +68 -68
- package/src/plugins/CxConverterIFCLoaderPlugin/index.js +1 -1
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV1.js +5 -5
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV10.js +5 -5
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV12.js +9 -9
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV2.js +5 -5
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV3.js +5 -5
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV4.js +5 -5
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV5.js +5 -5
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV6.js +5 -5
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV7.js +5 -5
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV8.js +5 -5
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV9.js +5 -5
- package/src/plugins/index.js +2 -2
- package/src/viewer/scene/Entity.js +6 -0
- package/src/viewer/scene/model/SceneModelEntity.js +26 -0
- package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +44 -0
- package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +58 -0
- package/src/viewer/scene/sectionCaps/SectionCaps.js +33 -27
- package/src/viewer/scene/webgl/ArrayBuf.js +20 -0
- package/types/viewer/scene/Entity.d.ts +5 -0
- package/types/viewer/scene/models/SceneModelEntity.d.ts +5 -0
- package/dist/xeokit-sdk.es5.js.map +0 -1
- package/dist/xeokit-sdk.min.es5.js.map +0 -1
|
@@ -12,6 +12,7 @@ const tempVec3a = math.vec3();
|
|
|
12
12
|
const tempVec3b = math.vec3();
|
|
13
13
|
const tempVec3c = math.vec3();
|
|
14
14
|
const tempVec3d = math.vec3();
|
|
15
|
+
const planeOff = math.vec3();
|
|
15
16
|
|
|
16
17
|
function pointsEqual(p1, p2) {
|
|
17
18
|
return (
|
|
@@ -215,9 +216,9 @@ class SectionCaps {
|
|
|
215
216
|
const objects = sceneModel.objects;
|
|
216
217
|
// Preallocate arrays for triangle vertices to avoid repeated allocation
|
|
217
218
|
const triangle = [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
math.vec3(),
|
|
220
|
+
math.vec3(),
|
|
221
|
+
math.vec3()
|
|
221
222
|
];
|
|
222
223
|
|
|
223
224
|
this._dirtyMap[sceneModel.id].forEach((isDirty, objectId) => {
|
|
@@ -230,20 +231,29 @@ class SectionCaps {
|
|
|
230
231
|
if(!this._doesPlaneIntersectBoundingBox(object.aabb, plane)) return;
|
|
231
232
|
|
|
232
233
|
if(!this._sceneModelsData[sceneModel.id]) {
|
|
234
|
+
const aabb = sceneModel.aabb;
|
|
233
235
|
this._sceneModelsData[sceneModel.id] = {
|
|
234
236
|
verticesMap: new Map(),
|
|
235
|
-
indicesMap: new Map()
|
|
237
|
+
indicesMap: new Map(),
|
|
238
|
+
// modelOrigin is critical to use when handling models with large coordinates.
|
|
239
|
+
// See XCD-306 and examples/slicing/SectionCaps_at_distance.html for more details.
|
|
240
|
+
modelOrigin: math.vec3([
|
|
241
|
+
(aabb[0] + aabb[3]) / 2,
|
|
242
|
+
(aabb[1] + aabb[4]) / 2,
|
|
243
|
+
(aabb[2] + aabb[5]) / 2
|
|
244
|
+
])
|
|
236
245
|
};
|
|
237
246
|
}
|
|
238
247
|
|
|
239
248
|
const sceneModelData = this._sceneModelsData[sceneModel.id];
|
|
249
|
+
const modelOrigin = sceneModelData.modelOrigin;
|
|
240
250
|
|
|
241
251
|
if(!sceneModelData.verticesMap.has(objectId)) {
|
|
242
252
|
const isSolid = object.meshes[0].isSolid();
|
|
243
253
|
const vertices = [ ];
|
|
244
254
|
const indices = [ ];
|
|
245
255
|
if(isSolid && object.capMaterial) {
|
|
246
|
-
object.getEachVertex(v => vertices.push(v[0], v[1], v[2]));
|
|
256
|
+
object.getEachVertex(v => vertices.push(v[0]-modelOrigin[0], v[1]-modelOrigin[1], v[2]-modelOrigin[2]));
|
|
247
257
|
object.getEachIndex(i => indices.push(i));
|
|
248
258
|
}
|
|
249
259
|
sceneModelData.verticesMap.set(objectId, vertices);
|
|
@@ -252,6 +262,7 @@ class SectionCaps {
|
|
|
252
262
|
|
|
253
263
|
const vertices = sceneModelData.verticesMap.get(objectId);
|
|
254
264
|
const indices = sceneModelData.indicesMap.get(objectId);
|
|
265
|
+
const planeDist = -math.dotVec3(math.subVec3(plane.pos, modelOrigin, tempVec3a), plane.dir);
|
|
255
266
|
|
|
256
267
|
const capSegments = [];
|
|
257
268
|
const vertCount = indices.length;
|
|
@@ -273,8 +284,8 @@ class SectionCaps {
|
|
|
273
284
|
const p1 = triangle[i];
|
|
274
285
|
const p2 = triangle[(i + 1) % 3];
|
|
275
286
|
|
|
276
|
-
const d1 =
|
|
277
|
-
const d2 =
|
|
287
|
+
const d1 = planeDist + math.dotVec3(plane.dir, p1);
|
|
288
|
+
const d2 = planeDist + math.dotVec3(plane.dir, p2);
|
|
278
289
|
|
|
279
290
|
if (d1 * d2 > 0) continue;
|
|
280
291
|
|
|
@@ -364,6 +375,7 @@ class SectionCaps {
|
|
|
364
375
|
const caps = new Map();
|
|
365
376
|
let arr;
|
|
366
377
|
projectedSegments.forEach((segment, segmentId) => {
|
|
378
|
+
const modelOrigin = this._sceneModelsData[sceneModel.id].modelOrigin;
|
|
367
379
|
arr = [];
|
|
368
380
|
const loops = segment;
|
|
369
381
|
|
|
@@ -446,7 +458,7 @@ class SectionCaps {
|
|
|
446
458
|
for (let j = 0; j < 3; j++) {
|
|
447
459
|
const idx = triangles[i + j] * 2;
|
|
448
460
|
const point2D = [vertices[idx], vertices[idx + 1]];
|
|
449
|
-
const point3D = this._convertTo3D(point2D, plane);
|
|
461
|
+
const point3D = this._convertTo3D(point2D, plane, modelOrigin);
|
|
450
462
|
triangle.push(point3D);
|
|
451
463
|
}
|
|
452
464
|
|
|
@@ -509,11 +521,10 @@ class SectionCaps {
|
|
|
509
521
|
this._prevIntersectionModelsMap[sceneModel.id] = new Map();
|
|
510
522
|
|
|
511
523
|
// Cache plane direction values
|
|
512
|
-
|
|
513
|
-
const offsetY = plane.dir[1] * 0.001;
|
|
514
|
-
const offsetZ = plane.dir[2] * 0.001;
|
|
524
|
+
math.mulVec3Scalar(plane.dir, 0.001, planeOff); // Use dedicated planeOff, as tempVec* are overwritten by _createUVs
|
|
515
525
|
|
|
516
526
|
geometryData.forEach((geometries, objectId) => {
|
|
527
|
+
const modelOrigin = this._sceneModelsData[sceneModel.id].modelOrigin;
|
|
517
528
|
const meshArray = new Array(geometries.size); // Pre-allocate array with known size
|
|
518
529
|
let meshIndex = 0;
|
|
519
530
|
|
|
@@ -522,16 +533,10 @@ class SectionCaps {
|
|
|
522
533
|
const indices = geometry.indices;
|
|
523
534
|
const verticesLength = vertices.length;
|
|
524
535
|
|
|
525
|
-
for (let i = 0; i < verticesLength; i += 3) {
|
|
526
|
-
vertices[i] += offsetX;
|
|
527
|
-
vertices[i + 1] += offsetY;
|
|
528
|
-
vertices[i + 2] += offsetZ;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
536
|
// Build normals and UVs in parallel if possible
|
|
532
537
|
const meshNormals = math.buildNormals(vertices, indices);
|
|
533
|
-
const uvs = this._createUVs(vertices, plane);
|
|
534
|
-
|
|
538
|
+
const uvs = this._createUVs(vertices, plane, modelOrigin);
|
|
539
|
+
|
|
535
540
|
// Create mesh with transformed vertices
|
|
536
541
|
meshArray[meshIndex++] = new Mesh(this.scene, {
|
|
537
542
|
id: `${plane.id}-${objectId}-${index}`,
|
|
@@ -542,6 +547,7 @@ class SectionCaps {
|
|
|
542
547
|
normals: meshNormals,
|
|
543
548
|
uv: uvs
|
|
544
549
|
}),
|
|
550
|
+
origin: math.addVec3(modelOrigin, planeOff, tempVec3a),
|
|
545
551
|
position: [0, 0, 0],
|
|
546
552
|
rotation: [0, 0, 0],
|
|
547
553
|
material: sceneModel.objects[objectId].capMaterial
|
|
@@ -651,7 +657,7 @@ class SectionCaps {
|
|
|
651
657
|
return inside;
|
|
652
658
|
}
|
|
653
659
|
|
|
654
|
-
_convertTo3D(point2D, plane) {
|
|
660
|
+
_convertTo3D(point2D, plane, origin) {
|
|
655
661
|
// Reconstruct the same basis vectors used in _projectTo2D
|
|
656
662
|
let u, normal = plane.dir, planePosition = plane.pos;
|
|
657
663
|
if (Math.abs(normal[0]) > Math.abs(normal[1])) {
|
|
@@ -677,9 +683,9 @@ class SectionCaps {
|
|
|
677
683
|
// Project the point onto the cutting plane
|
|
678
684
|
|
|
679
685
|
const t = math.dotVec3(normal, [
|
|
680
|
-
planePosition[0] - result[0],
|
|
681
|
-
planePosition[1] - result[1],
|
|
682
|
-
planePosition[2] - result[2]
|
|
686
|
+
planePosition[0] - result[0] - origin[0],
|
|
687
|
+
planePosition[1] - result[1] - origin[1],
|
|
688
|
+
planePosition[2] - result[2] - origin[2]
|
|
683
689
|
]);
|
|
684
690
|
|
|
685
691
|
return [
|
|
@@ -708,7 +714,7 @@ class SectionCaps {
|
|
|
708
714
|
|
|
709
715
|
}
|
|
710
716
|
|
|
711
|
-
_createUVs(vertices, plane) {
|
|
717
|
+
_createUVs(vertices, plane, origin) {
|
|
712
718
|
const O = plane.pos;
|
|
713
719
|
const D = tempVec3a;
|
|
714
720
|
D.set(plane.dir);
|
|
@@ -717,9 +723,9 @@ class SectionCaps {
|
|
|
717
723
|
|
|
718
724
|
const uvs = [ ];
|
|
719
725
|
for (let i = 0; i < vertices.length; i += 3) {
|
|
720
|
-
P[0] = vertices[i];
|
|
721
|
-
P[1] = vertices[i + 1];
|
|
722
|
-
P[2] = vertices[i + 2];
|
|
726
|
+
P[0] = vertices[i] + origin[0];
|
|
727
|
+
P[1] = vertices[i + 1] + origin[1];
|
|
728
|
+
P[2] = vertices[i + 2] + origin[2];
|
|
723
729
|
|
|
724
730
|
// Project P onto the plane
|
|
725
731
|
const OP = math.subVec3(P, O, tempVec3c);
|
|
@@ -10,6 +10,7 @@ class ArrayBuf {
|
|
|
10
10
|
this._gl = gl;
|
|
11
11
|
this.type = type;
|
|
12
12
|
this.allocated = false;
|
|
13
|
+
this.ConstructorType = data.constructor;
|
|
13
14
|
|
|
14
15
|
switch (data.constructor) {
|
|
15
16
|
|
|
@@ -94,6 +95,25 @@ class ArrayBuf {
|
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
getData(baseIndex = 0, length = (this.numItems) - baseIndex) {
|
|
99
|
+
if (!this.allocated) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const array = new (this.ConstructorType)(length * this.itemSize);
|
|
104
|
+
|
|
105
|
+
this._gl.bindBuffer(this.type, this._handle);
|
|
106
|
+
this._gl.getBufferSubData(
|
|
107
|
+
this.type,
|
|
108
|
+
baseIndex * this.itemByteSize * this.itemSize,
|
|
109
|
+
array,
|
|
110
|
+
0,
|
|
111
|
+
length * this.itemSize
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return array;
|
|
115
|
+
}
|
|
116
|
+
|
|
97
117
|
bind() {
|
|
98
118
|
if (!this.allocated) {
|
|
99
119
|
return;
|
|
@@ -394,6 +394,11 @@ export declare abstract class Entity {
|
|
|
394
394
|
*/
|
|
395
395
|
getEachVertex(callback: any): void;
|
|
396
396
|
|
|
397
|
+
/**
|
|
398
|
+
* Gets the complete geometry of this entity.
|
|
399
|
+
*/
|
|
400
|
+
getGeometryData(): {indices: number[],positions:number[]}
|
|
401
|
+
|
|
397
402
|
/**
|
|
398
403
|
* Destroys this Entity.
|
|
399
404
|
*/
|
|
@@ -443,6 +443,11 @@ export declare abstract class SceneModelEntity implements Entity {
|
|
|
443
443
|
*/
|
|
444
444
|
getEachIndex(callback: any): void;
|
|
445
445
|
|
|
446
|
+
/**
|
|
447
|
+
* Gets the complete geometry of this entity.
|
|
448
|
+
*/
|
|
449
|
+
getGeometryData(): {indices: number[],positions:number[]}
|
|
450
|
+
|
|
446
451
|
/**
|
|
447
452
|
* Returns the volume of this SceneModelEntity.
|
|
448
453
|
*
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xeokit-sdk.es5.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xeokit-sdk.min.es5.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|