@xeokit/xeokit-sdk 2.6.69 → 2.6.72
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 +4332 -207
- package/dist/xeokit-sdk.es.js +4332 -208
- package/dist/xeokit-sdk.es5.js +221 -204
- package/dist/xeokit-sdk.min.cjs.js +10 -4
- package/dist/xeokit-sdk.min.es.js +11 -5
- package/dist/xeokit-sdk.min.es5.js +10 -4
- package/package.json +3 -1
- package/src/extras/ContextMenu/ContextMenu.js +11 -9
- package/src/plugins/AnnotationsPlugin/Annotation.js +28 -16
- package/src/plugins/CxConverterIFCLoaderPlugin/CxConverterIFCLoaderPlugin.js +86 -0
- package/src/plugins/CxConverterIFCLoaderPlugin/index.js +1 -0
- package/src/plugins/LASLoaderPlugin/LASDefaultDataSource.js +13 -1
- package/src/plugins/LASLoaderPlugin/LASLoaderPlugin.js +89 -43
- package/src/plugins/NavCubePlugin/CubeTextureCanvas.js +2 -2
- package/src/plugins/NavCubePlugin/NavCubePlugin.js +10 -10
- package/src/plugins/SectionPlanesPlugin/Control.js +2 -2
- package/src/plugins/TreeViewPlugin/TreeViewPlugin.js +4 -3
- package/src/plugins/ZonesPlugin/ZonesPlugin.js +6 -151
- package/src/plugins/index.js +1 -0
- package/src/plugins/lib/ui/index.js +592 -34
- package/src/viewer/scene/geometry/ReadableGeometry.js +60 -0
- package/src/viewer/scene/geometry/builders/buildPlaneGeometry.js +1 -1
- package/src/viewer/scene/math/math.js +14 -2
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLineSnapInitRenderer.js +2 -0
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSnapInitRenderer.js +2 -0
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSnapRenderer.js +2 -0
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSnapInitRenderer.js +2 -0
- package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSnapRenderer.js +2 -0
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapInitRenderer.js +2 -0
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapRenderer.js +2 -0
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapInitRenderer.js +1 -24
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapRenderer.js +2 -19
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsSnapInitRenderer.js +1 -24
- package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsSnapRenderer.js +1 -19
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapInitRenderer.js +1 -24
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapRenderer.js +2 -19
- package/src/viewer/scene/scene/Scene.js +2 -3
- package/src/viewer/scene/sectionCaps/SectionCaps.js +46 -65
- package/types/plugins/CxConverterIFCLoaderPlugin/CxConverterIFCLoaderPlugin.d.ts +36 -0
- package/types/plugins/CxConverterIFCLoaderPlugin/index.d.ts +1 -0
- package/types/plugins/NavCubePlugin/NavCubePlugin.d.ts +1 -1
- package/types/plugins/index.d.ts +1 -0
- package/types/viewer/scene/ImagePlane/ImagePlane.d.ts +397 -0
- package/types/viewer/scene/ImagePlane/index.d.ts +1 -0
- package/types/viewer/scene/geometry/builders/index.d.ts +1 -0
- package/types/viewer/scene/index.d.ts +1 -0
|
@@ -613,6 +613,66 @@ class ReadableGeometry extends Geometry {
|
|
|
613
613
|
return this._obb;
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
+
_getMetrics() {
|
|
617
|
+
if (! ("_metrics" in this)) {
|
|
618
|
+
switch (this._state.primitiveName) {
|
|
619
|
+
case "solid":
|
|
620
|
+
case "surface":
|
|
621
|
+
case "triangles": {
|
|
622
|
+
const indices = this._state.indices;
|
|
623
|
+
const positions = this._state.positions;
|
|
624
|
+
const getPos = (i, out) => {
|
|
625
|
+
const idx = indices[i] * 3;
|
|
626
|
+
for (let j = 0; j < 3; ++j) {
|
|
627
|
+
out[j] = positions[idx + j];
|
|
628
|
+
};
|
|
629
|
+
return out;
|
|
630
|
+
};
|
|
631
|
+
const tmp = [ math.vec3(), math.vec3(), math.vec3(), math.vec3() ];
|
|
632
|
+
let totalArea = 0;
|
|
633
|
+
const centroid = math.vec3([ 0, 0, 0 ]);
|
|
634
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
635
|
+
const v0 = getPos(i, tmp[0]);
|
|
636
|
+
const v1 = getPos(i+1, tmp[1]);
|
|
637
|
+
const v2 = getPos(i+2, tmp[2]);
|
|
638
|
+
math.addVec3(v0, v1, tmp[3]);
|
|
639
|
+
math.addVec3(v2, tmp[3], tmp[3]);
|
|
640
|
+
const faceArea = math.lenVec3(
|
|
641
|
+
math.cross3Vec3(
|
|
642
|
+
math.subVec3(v1, v0, tmp[1]),
|
|
643
|
+
math.subVec3(v2, v0, tmp[2]),
|
|
644
|
+
tmp[0])) / 2;
|
|
645
|
+
totalArea += faceArea;
|
|
646
|
+
math.mulVec3Scalar(tmp[3], faceArea, tmp[3]);
|
|
647
|
+
math.addVec3(centroid, tmp[3], centroid);
|
|
648
|
+
}
|
|
649
|
+
this._metrics = { surfaceArea: totalArea, centroid: math.mulVec3Scalar(centroid, 1 / totalArea / 3, centroid) };
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
default:
|
|
653
|
+
this._metrics = { surfaceArea: 0 };
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return this._metrics;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Returns the surface area of this Mesh.
|
|
662
|
+
* @returns {number}
|
|
663
|
+
*/
|
|
664
|
+
get surfaceArea() {
|
|
665
|
+
return this._getMetrics().surfaceArea;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Returns the centroid of this Mesh.
|
|
670
|
+
* @returns {number}
|
|
671
|
+
*/
|
|
672
|
+
get centroid() {
|
|
673
|
+
return this._getMetrics().centroid;
|
|
674
|
+
}
|
|
675
|
+
|
|
616
676
|
/**
|
|
617
677
|
* Approximate number of triangles in this ReadableGeometry.
|
|
618
678
|
*
|
|
@@ -122,7 +122,7 @@ function buildPlaneGeometry(cfg = {}) {
|
|
|
122
122
|
positions[offset + 1] = centerY;
|
|
123
123
|
positions[offset + 2] = -z + centerZ;
|
|
124
124
|
|
|
125
|
-
normals[offset +
|
|
125
|
+
normals[offset + 1] = 1;
|
|
126
126
|
|
|
127
127
|
uvs[offset2] = (ix) / planeX;
|
|
128
128
|
uvs[offset2 + 1] = ((planeZ - iz) / planeZ);
|
|
@@ -158,8 +158,20 @@ const math = {
|
|
|
158
158
|
* @static
|
|
159
159
|
* @returns {Number[]}
|
|
160
160
|
*/
|
|
161
|
-
mat4ToMat3(mat4, mat3) {
|
|
162
|
-
|
|
161
|
+
mat4ToMat3(mat4, mat3 = new FloatArrayType(9)) {
|
|
162
|
+
mat3[0] = mat4[0];
|
|
163
|
+
mat3[1] = mat4[1];
|
|
164
|
+
mat3[2] = mat4[2];
|
|
165
|
+
|
|
166
|
+
mat3[3] = mat4[4];
|
|
167
|
+
mat3[4] = mat4[5];
|
|
168
|
+
mat3[5] = mat4[6];
|
|
169
|
+
|
|
170
|
+
mat3[6] = mat4[8];
|
|
171
|
+
mat3[7] = mat4[9];
|
|
172
|
+
mat3[8] = mat4[10];
|
|
173
|
+
|
|
174
|
+
return mat3;
|
|
163
175
|
},
|
|
164
176
|
|
|
165
177
|
/**
|
package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLineSnapInitRenderer.js
CHANGED
|
@@ -127,6 +127,8 @@ export class VBOBatchingLineSnapInitRenderer extends VBORenderer {
|
|
|
127
127
|
state.indicesBuf.bind();
|
|
128
128
|
gl.drawElements(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0);
|
|
129
129
|
state.indicesBuf.unbind();
|
|
130
|
+
|
|
131
|
+
gl.bindVertexArray(null);
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
_allocate() {
|
package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSnapInitRenderer.js
CHANGED
|
@@ -126,6 +126,8 @@ export class VBOBatchingLinesSnapInitRenderer extends VBORenderer {
|
|
|
126
126
|
state.indicesBuf.bind();
|
|
127
127
|
gl.drawElements(gl.LINES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0);
|
|
128
128
|
state.indicesBuf.unbind();
|
|
129
|
+
|
|
130
|
+
gl.bindVertexArray(null);
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
_allocate() {
|
package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSnapInitRenderer.js
CHANGED
|
@@ -125,6 +125,8 @@ export class VBOBatchingPointsSnapInitRenderer extends VBORenderer {
|
|
|
125
125
|
//=============================================================
|
|
126
126
|
|
|
127
127
|
gl.drawArrays(gl.POINTS, 0, state.positionsBuf.numItems);
|
|
128
|
+
|
|
129
|
+
gl.bindVertexArray(null);
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
_allocate() {
|
package/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSnapRenderer.js
CHANGED
|
@@ -129,6 +129,8 @@ export class VBOBatchingPointsSnapRenderer extends VBORenderer{
|
|
|
129
129
|
//=============================================================
|
|
130
130
|
|
|
131
131
|
gl.drawArrays(gl.POINTS, 0, state.positionsBuf.numItems);
|
|
132
|
+
|
|
133
|
+
gl.bindVertexArray(null);
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
_allocate() {
|
package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapInitRenderer.js
CHANGED
|
@@ -126,6 +126,8 @@ export class TrianglesSnapInitRenderer extends VBORenderer {
|
|
|
126
126
|
state.indicesBuf.bind();
|
|
127
127
|
gl.drawElements(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0);
|
|
128
128
|
state.indicesBuf.unbind();
|
|
129
|
+
|
|
130
|
+
gl.bindVertexArray(null);
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
_allocate() {
|
package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapInitRenderer.js
CHANGED
|
@@ -117,34 +117,11 @@ export class VBOInstancingLinesSnapInitRenderer extends VBORenderer {
|
|
|
117
117
|
|
|
118
118
|
this.setSectionPlanesStateUniforms(instancingLayer);
|
|
119
119
|
|
|
120
|
-
this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
|
|
121
|
-
this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
|
|
122
|
-
this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
|
|
123
|
-
|
|
124
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 1);
|
|
125
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
126
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (this._aFlags) {
|
|
130
|
-
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
131
|
-
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
120
|
state.indicesBuf.bind();
|
|
135
121
|
gl.drawElementsInstanced(gl.LINES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
|
|
136
122
|
state.indicesBuf.unbind();
|
|
137
123
|
|
|
138
|
-
|
|
139
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 0);
|
|
140
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
|
|
141
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
|
|
142
|
-
if (this._aFlags) {
|
|
143
|
-
gl.vertexAttribDivisor(this._aFlags.location, 0);
|
|
144
|
-
}
|
|
145
|
-
if (this._aOffset) {
|
|
146
|
-
gl.vertexAttribDivisor(this._aOffset.location, 0);
|
|
147
|
-
}
|
|
124
|
+
gl.bindVertexArray(null);
|
|
148
125
|
}
|
|
149
126
|
|
|
150
127
|
_allocate() {
|
package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapRenderer.js
CHANGED
|
@@ -116,17 +116,6 @@ export class VBOInstancingLinesSnapRenderer extends VBORenderer {
|
|
|
116
116
|
|
|
117
117
|
this.setSectionPlanesStateUniforms(instancingLayer);
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
|
|
121
|
-
this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
|
|
122
|
-
this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
|
|
123
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 1);
|
|
124
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
125
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
126
|
-
|
|
127
|
-
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
128
|
-
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
129
|
-
|
|
130
119
|
if (frameCtx.snapMode === "edge") {
|
|
131
120
|
state.indicesBuf.bind();
|
|
132
121
|
gl.drawElementsInstanced(gl.LINES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
|
|
@@ -134,14 +123,8 @@ export class VBOInstancingLinesSnapRenderer extends VBORenderer {
|
|
|
134
123
|
} else {
|
|
135
124
|
gl.drawArraysInstanced(gl.POINTS, 0, state.positionsBuf.numItems, state.numInstances);
|
|
136
125
|
}
|
|
137
|
-
|
|
138
|
-
gl.
|
|
139
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
|
|
140
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
|
|
141
|
-
gl.vertexAttribDivisor(this._aFlags.location, 0);
|
|
142
|
-
if (this._aOffset) {
|
|
143
|
-
gl.vertexAttribDivisor(this._aOffset.location, 0);
|
|
144
|
-
}
|
|
126
|
+
|
|
127
|
+
gl.bindVertexArray(null);
|
|
145
128
|
}
|
|
146
129
|
|
|
147
130
|
_allocate() {
|
|
@@ -117,32 +117,9 @@ export class VBOInstancingPointsSnapInitRenderer extends VBORenderer {
|
|
|
117
117
|
|
|
118
118
|
this.setSectionPlanesStateUniforms(instancingLayer);
|
|
119
119
|
|
|
120
|
-
this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
|
|
121
|
-
this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
|
|
122
|
-
this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
|
|
123
|
-
|
|
124
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 1);
|
|
125
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
126
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (this._aFlags) {
|
|
130
|
-
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
131
|
-
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
120
|
gl.drawArraysInstanced(gl.POINTS, 0, state.positionsBuf.numItems, state.numInstances);
|
|
135
121
|
|
|
136
|
-
|
|
137
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 0);
|
|
138
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
|
|
139
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
|
|
140
|
-
if (this._aFlags) {
|
|
141
|
-
gl.vertexAttribDivisor(this._aFlags.location, 0);
|
|
142
|
-
}
|
|
143
|
-
if (this._aOffset) {
|
|
144
|
-
gl.vertexAttribDivisor(this._aOffset.location, 0);
|
|
145
|
-
}
|
|
122
|
+
gl.bindVertexArray(null);
|
|
146
123
|
}
|
|
147
124
|
|
|
148
125
|
_allocate() {
|
package/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsSnapRenderer.js
CHANGED
|
@@ -116,27 +116,9 @@ export class VBOInstancingPointsSnapRenderer extends VBORenderer {
|
|
|
116
116
|
|
|
117
117
|
this.setSectionPlanesStateUniforms(instancingLayer);
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
|
|
121
|
-
this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
|
|
122
|
-
this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
|
|
123
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 1);
|
|
124
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
125
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
126
|
-
|
|
127
|
-
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
128
|
-
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
129
|
-
|
|
130
119
|
gl.drawArraysInstanced(gl.POINTS, 0, state.positionsBuf.numItems, state.numInstances);
|
|
131
120
|
|
|
132
|
-
|
|
133
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 0);
|
|
134
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
|
|
135
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
|
|
136
|
-
gl.vertexAttribDivisor(this._aFlags.location, 0);
|
|
137
|
-
if (this._aOffset) {
|
|
138
|
-
gl.vertexAttribDivisor(this._aOffset.location, 0);
|
|
139
|
-
}
|
|
121
|
+
gl.bindVertexArray(null);
|
|
140
122
|
}
|
|
141
123
|
|
|
142
124
|
_allocate() {
|
package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapInitRenderer.js
CHANGED
|
@@ -123,34 +123,11 @@ export class TrianglesSnapInitRenderer extends VBORenderer {
|
|
|
123
123
|
|
|
124
124
|
this.setSectionPlanesStateUniforms(instancingLayer);
|
|
125
125
|
|
|
126
|
-
this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
|
|
127
|
-
this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
|
|
128
|
-
this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
|
|
129
|
-
|
|
130
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 1);
|
|
131
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
132
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (this._aFlags) {
|
|
136
|
-
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
137
|
-
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
126
|
state.indicesBuf.bind();
|
|
141
127
|
gl.drawElementsInstanced(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
|
|
142
128
|
state.indicesBuf.unbind();
|
|
143
129
|
|
|
144
|
-
|
|
145
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 0);
|
|
146
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
|
|
147
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
|
|
148
|
-
if (this._aFlags) {
|
|
149
|
-
gl.vertexAttribDivisor(this._aFlags.location, 0);
|
|
150
|
-
}
|
|
151
|
-
if (this._aOffset) {
|
|
152
|
-
gl.vertexAttribDivisor(this._aOffset.location, 0);
|
|
153
|
-
}
|
|
130
|
+
gl.bindVertexArray(null);
|
|
154
131
|
}
|
|
155
132
|
|
|
156
133
|
_allocate() {
|
|
@@ -123,17 +123,6 @@ export class TrianglesSnapRenderer extends VBORenderer {
|
|
|
123
123
|
|
|
124
124
|
this.setSectionPlanesStateUniforms(instancingLayer);
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
|
|
128
|
-
this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
|
|
129
|
-
this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
|
|
130
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 1);
|
|
131
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
132
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
133
|
-
|
|
134
|
-
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
135
|
-
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
136
|
-
|
|
137
126
|
if (frameCtx.snapMode === "edge" ) {
|
|
138
127
|
if (state.edgeIndicesBuf) {
|
|
139
128
|
state.edgeIndicesBuf.bind();
|
|
@@ -143,14 +132,8 @@ export class TrianglesSnapRenderer extends VBORenderer {
|
|
|
143
132
|
} else {
|
|
144
133
|
gl.drawArraysInstanced(gl.POINTS, 0, state.positionsBuf.numItems, state.numInstances);
|
|
145
134
|
}
|
|
146
|
-
|
|
147
|
-
gl.
|
|
148
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
|
|
149
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
|
|
150
|
-
gl.vertexAttribDivisor(this._aFlags.location, 0);
|
|
151
|
-
if (this._aOffset) {
|
|
152
|
-
gl.vertexAttribDivisor(this._aOffset.location, 0);
|
|
153
|
-
}
|
|
135
|
+
|
|
136
|
+
gl.bindVertexArray(null);
|
|
154
137
|
}
|
|
155
138
|
|
|
156
139
|
_allocate() {
|
|
@@ -347,13 +347,12 @@ class Scene extends Component {
|
|
|
347
347
|
* configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
|
|
348
348
|
* responsiveness. It is important to consider that each SectionPlane imposes rendering performance, so it is recommended to set this value to a quantity that aligns with
|
|
349
349
|
* your expected usage.
|
|
350
|
-
* @throws {String} Throws an exception when
|
|
350
|
+
* @throws {String} Throws an exception when canvasId or canvasElement are missing or they aren't pointing to a valid HTMLCanvasElement.
|
|
351
351
|
*/
|
|
352
352
|
constructor(viewer, cfg = {}) {
|
|
353
353
|
|
|
354
354
|
super(null, cfg);
|
|
355
|
-
|
|
356
|
-
const canvas = cfg.canvasElement || document.getElementById(cfg.canvasId);
|
|
355
|
+
const canvas = cfg.canvasElement || document.querySelector(`#${cfg.canvasId}`);
|
|
357
356
|
|
|
358
357
|
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
359
358
|
throw "Mandatory config expected: valid canvasId or canvasElement";
|
|
@@ -127,8 +127,7 @@ class SectionCaps {
|
|
|
127
127
|
if(!this._resourcesAllocated) {
|
|
128
128
|
this._resourcesAllocated = true;
|
|
129
129
|
this._sectionPlanes = [];
|
|
130
|
-
this.
|
|
131
|
-
this._indicesMap = {};
|
|
130
|
+
this._sceneModelsData = {};
|
|
132
131
|
this._dirtyMap = {};
|
|
133
132
|
this._prevIntersectionModelsMap = {};
|
|
134
133
|
this._sectionPlaneTimeout = null;
|
|
@@ -143,7 +142,8 @@ class SectionCaps {
|
|
|
143
142
|
this._sectionPlanes.push(sectionPlane);
|
|
144
143
|
sectionPlane.on('pos', onSectionPlaneUpdated);
|
|
145
144
|
sectionPlane.on('dir', onSectionPlaneUpdated);
|
|
146
|
-
sectionPlane.
|
|
145
|
+
sectionPlane.on('active', onSectionPlaneUpdated);
|
|
146
|
+
sectionPlane.once('destroyed', (() => {
|
|
147
147
|
const sectionPlaneId = sectionPlane.id;
|
|
148
148
|
if (sectionPlaneId) {
|
|
149
149
|
this._sectionPlanes = this._sectionPlanes.filter((sectionPlane) => sectionPlane.id !== sectionPlaneId);
|
|
@@ -160,14 +160,20 @@ class SectionCaps {
|
|
|
160
160
|
|
|
161
161
|
this._onTick = this.scene.on("tick", () => {
|
|
162
162
|
//on ticks we only check if there is a model that we have saved vertices for,
|
|
163
|
-
//but it's no more available on the scene
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
delete this.
|
|
168
|
-
|
|
163
|
+
//but it's no more available on the scene, or if its visibility changed
|
|
164
|
+
let dirty = false;
|
|
165
|
+
for(const sceneModelId in this._sceneModelsData) {
|
|
166
|
+
if(!this.scene.models[sceneModelId]){
|
|
167
|
+
delete this._sceneModelsData[sceneModelId];
|
|
168
|
+
dirty = true;
|
|
169
|
+
} else if (this._sceneModelsData[sceneModelId].visible !== (!!this.scene.models[sceneModelId].visible)) {
|
|
170
|
+
this._sceneModelsData[sceneModelId].visible = !!this.scene.models[sceneModelId].visible;
|
|
171
|
+
dirty = true;
|
|
169
172
|
}
|
|
170
173
|
}
|
|
174
|
+
if (dirty) {
|
|
175
|
+
this._update();
|
|
176
|
+
}
|
|
171
177
|
})
|
|
172
178
|
}
|
|
173
179
|
|
|
@@ -183,8 +189,8 @@ class SectionCaps {
|
|
|
183
189
|
this._deletePreviousModels();
|
|
184
190
|
this._updateTimeout = setTimeout(() => {
|
|
185
191
|
clearTimeout(this._updateTimeout);
|
|
186
|
-
const sceneModels = Object.
|
|
187
|
-
this._addHatches(sceneModels, this._sectionPlanes);
|
|
192
|
+
const sceneModels = Object.values(this.scene.models).filter(sceneModel => sceneModel.visible);
|
|
193
|
+
this._addHatches(sceneModels, this._sectionPlanes.filter(sectionPlane => sectionPlane.active));
|
|
188
194
|
this._setAllDirty(false);
|
|
189
195
|
}, 100);
|
|
190
196
|
}
|
|
@@ -197,21 +203,9 @@ class SectionCaps {
|
|
|
197
203
|
|
|
198
204
|
_addHatches(sceneModels, planes) {
|
|
199
205
|
|
|
200
|
-
if (planes.length <= 0) return;
|
|
201
|
-
|
|
202
206
|
planes.forEach((plane) => {
|
|
203
207
|
sceneModels.forEach((sceneModel) => {
|
|
204
|
-
|
|
205
|
-
//we create a plane equation that will be used to slice through each triangle
|
|
206
|
-
const planeEquation = {
|
|
207
|
-
A: plane.dir[0],
|
|
208
|
-
B: plane.dir[1],
|
|
209
|
-
C: plane.dir[2],
|
|
210
|
-
D: -(plane.dir[0] * plane.pos[0] + plane.dir[1] * plane.pos[1] + plane.dir[2] * plane.pos[2])
|
|
211
|
-
}
|
|
212
|
-
//#endregion
|
|
213
|
-
|
|
214
|
-
if(!this._doesPlaneIntersectBoundingBox(sceneModel.aabb, planeEquation)) return;
|
|
208
|
+
if(!this._doesPlaneIntersectBoundingBox(sceneModel.aabb, plane)) return;
|
|
215
209
|
|
|
216
210
|
if(!this._dirtyMap[sceneModel.id]) return;
|
|
217
211
|
|
|
@@ -233,39 +227,35 @@ class SectionCaps {
|
|
|
233
227
|
|
|
234
228
|
const object = objects[objectId];
|
|
235
229
|
|
|
236
|
-
if(!this._doesPlaneIntersectBoundingBox(object.aabb,
|
|
230
|
+
if(!this._doesPlaneIntersectBoundingBox(object.aabb, plane)) return;
|
|
237
231
|
|
|
238
|
-
if(!this.
|
|
239
|
-
this.
|
|
240
|
-
|
|
232
|
+
if(!this._sceneModelsData[sceneModel.id]) {
|
|
233
|
+
this._sceneModelsData[sceneModel.id] = {
|
|
234
|
+
verticesMap: new Map(),
|
|
235
|
+
indicesMap: new Map()
|
|
236
|
+
};
|
|
241
237
|
}
|
|
242
238
|
|
|
243
|
-
|
|
239
|
+
const sceneModelData = this._sceneModelsData[sceneModel.id];
|
|
244
240
|
|
|
245
|
-
if(!
|
|
241
|
+
if(!sceneModelData.verticesMap.has(objectId)) {
|
|
246
242
|
const isSolid = object.meshes[0].isSolid();
|
|
243
|
+
const vertices = [ ];
|
|
244
|
+
const indices = [ ];
|
|
247
245
|
if(isSolid && object.capMaterial) {
|
|
248
|
-
object.getEachVertex(
|
|
249
|
-
|
|
250
|
-
})
|
|
251
|
-
object.getEachIndex((_indices) => {
|
|
252
|
-
indices.push(_indices);
|
|
253
|
-
})
|
|
246
|
+
object.getEachVertex(v => vertices.push(v[0], v[1], v[2]));
|
|
247
|
+
object.getEachIndex(i => indices.push(i));
|
|
254
248
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
vertices = this._verticesMap[sceneModel.id].get(objectId);
|
|
260
|
-
indices = this._indicesMap[sceneModel.id].get(objectId);
|
|
249
|
+
sceneModelData.verticesMap.set(objectId, vertices);
|
|
250
|
+
sceneModelData.indicesMap.set(objectId, indices);
|
|
261
251
|
}
|
|
262
|
-
|
|
252
|
+
|
|
253
|
+
const vertices = sceneModelData.verticesMap.get(objectId);
|
|
254
|
+
const indices = sceneModelData.indicesMap.get(objectId);
|
|
255
|
+
|
|
263
256
|
const capSegments = [];
|
|
264
257
|
const vertCount = indices.length;
|
|
265
|
-
|
|
266
|
-
// Preallocate intersection result array
|
|
267
|
-
const intersectionBuffer = new Float32Array(3);
|
|
268
|
-
|
|
258
|
+
|
|
269
259
|
for (let i = 0; i < vertCount; i += 3) {
|
|
270
260
|
// Reuse triangle buffer instead of creating new arrays
|
|
271
261
|
for (let j = 0; j < 3; j++) {
|
|
@@ -282,21 +272,15 @@ class SectionCaps {
|
|
|
282
272
|
for (let i = 0; i < 3; i++) {
|
|
283
273
|
const p1 = triangle[i];
|
|
284
274
|
const p2 = triangle[(i + 1) % 3];
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
275
|
+
|
|
276
|
+
const d1 = plane.dist + math.dotVec3(plane.dir, p1);
|
|
277
|
+
const d2 = plane.dist + math.dotVec3(plane.dir, p2);
|
|
278
|
+
|
|
290
279
|
if (d1 * d2 > 0) continue;
|
|
291
|
-
|
|
280
|
+
|
|
292
281
|
const t = -d1 / (d2 - d1);
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
intersectionBuffer[1] = p1[1] + t * (p2[1] - p1[1]);
|
|
296
|
-
intersectionBuffer[2] = p1[2] + t * (p2[2] - p1[2]);
|
|
297
|
-
|
|
298
|
-
// Clone the buffer for storage
|
|
299
|
-
intersections.push(new Float32Array(intersectionBuffer));
|
|
282
|
+
|
|
283
|
+
intersections.push(math.lerpVec3(t, 0, 1, p1, p2, math.vec3()));
|
|
300
284
|
}
|
|
301
285
|
|
|
302
286
|
if(intersections.length === 2) capSegments.push(intersections);
|
|
@@ -576,7 +560,7 @@ class SectionCaps {
|
|
|
576
560
|
|
|
577
561
|
}
|
|
578
562
|
|
|
579
|
-
_doesPlaneIntersectBoundingBox(bb,
|
|
563
|
+
_doesPlaneIntersectBoundingBox(bb, plane) {
|
|
580
564
|
const min = [bb[0], bb[1], bb[2]];
|
|
581
565
|
const max = [bb[3], bb[4], bb[5]];
|
|
582
566
|
|
|
@@ -596,10 +580,7 @@ class SectionCaps {
|
|
|
596
580
|
let hasNegative = false;
|
|
597
581
|
|
|
598
582
|
for (const corner of corners) {
|
|
599
|
-
const distance =
|
|
600
|
-
planeEquation.B * corner[1] +
|
|
601
|
-
planeEquation.C * corner[2] +
|
|
602
|
-
planeEquation.D;
|
|
583
|
+
const distance = plane.dist + math.dotVec3(plane.dir, corner);
|
|
603
584
|
|
|
604
585
|
if (distance > 0) hasPositive = true;
|
|
605
586
|
if (distance < 0) hasNegative = true;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Plugin } from "../../viewer/Plugin";
|
|
2
|
+
import { Viewer } from "../../viewer/Viewer";
|
|
3
|
+
import { GLTFLoaderPlugin } from "../GLTFLoaderPlugin/GLTFLoaderPlugin";
|
|
4
|
+
import { SceneModel } from "../../viewer/scene/models/SceneModel";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* {@link Viewer} plugin that loads IFC models using the CxConverter library.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CxConverterIFCLoaderPlugin extends Plugin {
|
|
10
|
+
/**
|
|
11
|
+
* @constructor
|
|
12
|
+
* @param {Viewer} viewer The Viewer.
|
|
13
|
+
* @param {Object} [cfg] Plugin configuration.
|
|
14
|
+
*/
|
|
15
|
+
constructor(viewer: Viewer, cfg?: {});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The GLTFLoaderPlugin used internally to load the converted GLTF.
|
|
19
|
+
*/
|
|
20
|
+
gltfLoader: GLTFLoaderPlugin;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Loads an IFC model from the given source.
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} params Loading parameters.
|
|
26
|
+
* @param {String} params.src Path to an IFC file.
|
|
27
|
+
* @param {Function} [params.progressCallback] Callback to track loading progress.
|
|
28
|
+
* @param {Function} [params.progressTextCallback] Callback to track loading progress with text updates.
|
|
29
|
+
* @returns {Promise<SceneModel>} A promise that resolves to the loaded SceneModel.
|
|
30
|
+
*/
|
|
31
|
+
load(params?: {
|
|
32
|
+
src: string;
|
|
33
|
+
progressCallback?: (progress: number) => void;
|
|
34
|
+
progressTextCallback?: (text: string) => void;
|
|
35
|
+
}): Promise<SceneModel>;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CxConverterIFCLoaderPlugin";
|
package/types/plugins/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./AnnotationsPlugin";
|
|
|
3
3
|
export * from "./AxisGizmoPlugin";
|
|
4
4
|
export * from "./BCFViewpointsPlugin";
|
|
5
5
|
export * from "./CityJSONLoaderPlugin";
|
|
6
|
+
export * from "./CxConverterIFCLoaderPlugin";
|
|
6
7
|
export * from "./DistanceMeasurementsPlugin";
|
|
7
8
|
export * from "./DotBIMLoaderPlugin";
|
|
8
9
|
export * from "./FastNavPlugin";
|