@xeokit/xeokit-sdk 2.6.65 → 2.6.67

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.
Files changed (46) hide show
  1. package/{LICENSE.txt → LICENSE} +30 -27
  2. package/README.md +13 -6
  3. package/dist/xeokit-sdk.cjs.js +50322 -25848
  4. package/dist/xeokit-sdk.es.js +50322 -25848
  5. package/dist/xeokit-sdk.es5.js +7982 -4807
  6. package/dist/xeokit-sdk.min.cjs.js +5 -5
  7. package/dist/xeokit-sdk.min.es.js +5 -5
  8. package/dist/xeokit-sdk.min.es5.js +4 -4
  9. package/package.json +34 -32
  10. package/src/extras/PointerCircle/PointerCircle.js +1 -1
  11. package/src/plugins/AnnotationsPlugin/Annotation.js +45 -5
  12. package/src/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.js +1 -1
  13. package/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +3 -2
  14. package/src/plugins/LASLoaderPlugin/LASLoaderPlugin.js +1 -1
  15. package/src/plugins/SectionPlanesPlugin/Control.js +11 -12
  16. package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +57 -2
  17. package/src/plugins/XKTLoaderPlugin/parsers/ParserV10.js +6 -0
  18. package/src/plugins/XKTLoaderPlugin/parsers/ParserV11.js +6 -0
  19. package/src/plugins/XKTLoaderPlugin/parsers/ParserV12.js +822 -0
  20. package/src/plugins/XKTLoaderPlugin/parsers/ParserV6.js +6 -0
  21. package/src/plugins/XKTLoaderPlugin/parsers/ParserV7.js +6 -0
  22. package/src/plugins/XKTLoaderPlugin/parsers/ParserV8.js +6 -0
  23. package/src/plugins/XKTLoaderPlugin/parsers/ParserV9.js +6 -0
  24. package/src/{plugins/lib → viewer/scene/libs}/earcut.js +194 -189
  25. package/src/viewer/scene/materials/EmphasisMaterial.js +5 -1
  26. package/src/viewer/scene/math/math.js +6 -2
  27. package/src/viewer/scene/model/SceneModel.js +1 -0
  28. package/src/viewer/scene/model/SceneModelEntity.js +26 -0
  29. package/src/viewer/scene/model/SceneModelMesh.js +4 -0
  30. package/src/viewer/scene/model/dtx/triangles/DTXTrianglesLayer.js +1 -1
  31. package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +1 -1
  32. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorRenderer.js +4 -1
  33. package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +1 -1
  34. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorRenderer.js +4 -1
  35. package/src/viewer/scene/scene/Scene.js +50 -6
  36. package/src/viewer/scene/sectionCaps/SectionCaps.js +774 -0
  37. package/src/viewer/scene/sectionCaps/index.js +1 -0
  38. package/src/viewer/scene/sectionPlane/SectionPlane.js +79 -1
  39. package/src/viewer/scene/webgl/Renderer.js +19 -10
  40. package/types/extras/PointerCircle/PointerCircle.d.ts +50 -0
  41. package/types/extras/PointerCircle/index.d.ts +1 -0
  42. package/types/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.d.ts +2 -1
  43. package/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts +28 -0
  44. package/types/plugins/index.d.ts +1 -0
  45. package/types/plugins/lib/ui/index.d.ts +12 -0
  46. package/types/viewer/scene/models/SceneModelMesh.d.ts +7 -0
@@ -224,7 +224,7 @@ class EmphasisMaterial extends Material {
224
224
  * @param {Number[]} [cfg.edgeColor=[0.2,0.2,0.2]] RGB color of xray edges.
225
225
  * @param {Number} [cfg.edgeAlpha=0.5] Transparency of xray edges. A value of ````0.0```` indicates fully transparent, ````1.0```` is fully opaque.
226
226
  * @param {Number} [cfg.edgeWidth=1] Width of xray edges, in pixels.
227
- * @param {String} [cfg.preset] Selects a preset EmphasisMaterial configuration - see {@link EmphasisMaterial#presets}.
227
+ * @param {String} [cfg.preset] Deprecated - will be removed in future releases - Selects a preset EmphasisMaterial configuration - see {@link EmphasisMaterial#presets}.
228
228
  * @param {Boolean} [cfg.backfaces=false] Whether to render geometry backfaces when emphasising.
229
229
  * @param {Boolean} [cfg.glowThrough=true] Whether to make the emphasized object appear to float on top of other objects, as if it were "glowing through" them.
230
230
  */
@@ -563,6 +563,7 @@ class EmphasisMaterial extends Material {
563
563
  }
564
564
 
565
565
  /**
566
+ * @deprecated
566
567
  * Selects a preset EmphasisMaterial configuration.
567
568
  *
568
569
  * Default value is "default".
@@ -570,6 +571,7 @@ class EmphasisMaterial extends Material {
570
571
  * @type {String}
571
572
  */
572
573
  set preset(value) {
574
+ console.warn("EmphasisMaterial.preset is deprecated and will be removed in future versions.");
573
575
  value = value || "default";
574
576
  if (this._preset === value) {
575
577
  return;
@@ -591,6 +593,7 @@ class EmphasisMaterial extends Material {
591
593
  }
592
594
 
593
595
  /**
596
+ * @deprecated
594
597
  * Gets the current preset EmphasisMaterial configuration.
595
598
  *
596
599
  * Default value is "default".
@@ -598,6 +601,7 @@ class EmphasisMaterial extends Material {
598
601
  * @type {String}
599
602
  */
600
603
  get preset() {
604
+ console.warn("EmphasisMaterial.preset is deprecated and will be removed in future versions.");
601
605
  return this._preset;
602
606
  }
603
607
 
@@ -1965,7 +1965,7 @@ const math = {
1965
1965
  * @param {Number[]} mat The 4x4 matrix.
1966
1966
  * @param {String} order Desired Euler angle order: "XYZ", "YXZ", "ZXY" etc.
1967
1967
  * @param {Number[]} [dest] Destination Euler angles, created by default.
1968
- * @returns {Number[]} The Euler angles.
1968
+ * @returns {Number[]} The Euler angles (in degrees).
1969
1969
  */
1970
1970
  mat4ToEuler(mat, order, dest = math.vec4()) {
1971
1971
  const clamp = math.clamp;
@@ -2057,6 +2057,10 @@ const math = {
2057
2057
  }
2058
2058
  }
2059
2059
 
2060
+ dest[0] *= math.RADTODEG;
2061
+ dest[1] *= math.RADTODEG;
2062
+ dest[2] *= math.RADTODEG;
2063
+
2060
2064
  return dest;
2061
2065
  },
2062
2066
 
@@ -2866,7 +2870,7 @@ const math = {
2866
2870
  /**
2867
2871
  * Initializes a quaternion from Euler angles.
2868
2872
  *
2869
- * @param {Number[]} euler The Euler angles.
2873
+ * @param {Number[]} euler The Euler angles (in degrees).
2870
2874
  * @param {String} order Euler angle order: "XYZ", "YXZ", "ZXY" etc.
2871
2875
  * @param {Number[]} [dest] Destination quaternion, created by default.
2872
2876
  * @returns {Number[]} The quaternion.
@@ -1563,6 +1563,7 @@ export class SceneModel extends Component {
1563
1563
  set matrix(value) {
1564
1564
  this._matrix.set(value || DEFAULT_MATRIX);
1565
1565
  math.decomposeMat4(this._matrix, this._position, this._quaternion, this._scale);
1566
+ math.quaternionToEuler(this._quaternion, "XYZ", this._rotation);
1566
1567
  this._matrixDirty = false;
1567
1568
  this._setWorldMatrixDirty();
1568
1569
  this._sceneModelDirty();
@@ -1,5 +1,6 @@
1
1
  import {ENTITY_FLAGS} from './ENTITY_FLAGS.js';
2
2
  import {math} from "../math/math.js";
3
+ import { Material } from '../materials/Material.js';
3
4
 
4
5
  const tempFloatRGB = new Float32Array([0, 0, 0]);
5
6
  const tempIntRGB = new Uint16Array([0, 0, 0]);
@@ -48,6 +49,7 @@ export class SceneModelEntity {
48
49
  this.meshes = meshes;
49
50
 
50
51
  this._numPrimitives = 0;
52
+ this._capMaterial = null;
51
53
 
52
54
  for (let i = 0, len = this.meshes.length; i < len; i++) { // TODO: tidier way? Refactor?
53
55
  const mesh = this.meshes[i];
@@ -649,6 +651,30 @@ export class SceneModelEntity {
649
651
  return this.model.saoEnabled;
650
652
  }
651
653
 
654
+ /**
655
+ * Sets the SceneModelEntity's capMaterial that will be used on the caps generated when this entity is sliced
656
+ *
657
+ * Default value is ````null````.
658
+ *
659
+ * @type {Material}
660
+ */
661
+ set capMaterial(value) {
662
+ if(!this.scene.readableGeometryEnabled) return;
663
+ this._capMaterial = value instanceof Material ? value : null;
664
+ this.scene._capMaterialUpdated(this.id, this.model.id);
665
+ }
666
+
667
+ /**
668
+ * Gets the SceneModelEntity's capMaterial.
669
+ *
670
+ * Default value is ````null````.
671
+ *
672
+ * @type {Material}
673
+ */
674
+ get capMaterial() {
675
+ return this._capMaterial;
676
+ }
677
+
652
678
  getEachVertex(callback) {
653
679
  for (let i = 0, len = this.meshes.length; i < len; i++) {
654
680
  this.meshes[i].getEachVertex(callback)
@@ -313,6 +313,10 @@ export class SceneModelMesh {
313
313
  }
314
314
  }
315
315
 
316
+ isSolid() {
317
+ return this.layer.solid;
318
+ }
319
+
316
320
  /**
317
321
  * Returns the volume of this SceneModelMesh.
318
322
  * @returns {number}
@@ -1170,7 +1170,7 @@ export class DTXTrianglesLayer {
1170
1170
  }
1171
1171
 
1172
1172
  _updateBackfaceCull(renderFlags, frameCtx) {
1173
- const backfaces = this.model.backfaces || renderFlags.sectioned;
1173
+ const backfaces = true; // See XCD-230
1174
1174
  if (frameCtx.backfaces !== backfaces) {
1175
1175
  const gl = frameCtx.gl;
1176
1176
  if (backfaces) {
@@ -929,7 +929,7 @@ export class VBOBatchingTrianglesLayer {
929
929
  }
930
930
 
931
931
  _updateBackfaceCull(renderFlags, frameCtx) {
932
- const backfaces = this.model.backfaces || (!this.solid) || renderFlags.sectioned;
932
+ const backfaces = true; // See XCD-230
933
933
  if (frameCtx.backfaces !== backfaces) {
934
934
  const gl = frameCtx.gl;
935
935
  if (backfaces) {
@@ -221,7 +221,10 @@ export class TrianglesColorRenderer extends TrianglesBatchingRenderer {
221
221
  }
222
222
 
223
223
  if (scene.logarithmicDepthBufferEnabled) {
224
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
224
+ src.push(" float dx = dFdx(vFragDepth);")
225
+ src.push(" float dy = dFdy(vFragDepth);")
226
+ src.push(" float diff = sqrt(dx*dx+dy*dy);");
227
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");
225
228
  }
226
229
 
227
230
  if (this._withSAO) {
@@ -843,7 +843,7 @@ export class VBOInstancingTrianglesLayer {
843
843
  }
844
844
 
845
845
  _updateBackfaceCull(renderFlags, frameCtx) {
846
- const backfaces = this.model.backfaces || (!this.solid) || renderFlags.sectioned;
846
+ const backfaces = true; // See XCD-230
847
847
  if (frameCtx.backfaces !== backfaces) {
848
848
  const gl = frameCtx.gl;
849
849
  if (backfaces) {
@@ -234,7 +234,10 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
234
234
  }
235
235
 
236
236
  if (scene.logarithmicDepthBufferEnabled) {
237
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
237
+ src.push(" float dx = dFdx(vFragDepth);")
238
+ src.push(" float dy = dFdy(vFragDepth);")
239
+ src.push(" float diff = sqrt(dx*dx+dy*dy);");
240
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");
238
241
  }
239
242
 
240
243
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -19,6 +19,7 @@ import {SAO} from "../postfx/SAO.js";
19
19
  import {CrossSections} from "../postfx/CrossSections.js";
20
20
  import {PointsMaterial} from "../materials/PointsMaterial.js";
21
21
  import {LinesMaterial} from "../materials/LinesMaterial.js";
22
+ import {SectionCaps} from '../sectionCaps/SectionCaps.js';
22
23
 
23
24
  // Enables runtime check for redundant calls to object state update methods, eg. Scene#_objectVisibilityUpdated
24
25
  const ASSERT_OBJECT_STATE_UPDATE = false;
@@ -887,6 +888,8 @@ class Scene extends Component {
887
888
  dontClear: true // Never destroy this component with Scene#clear();
888
889
  });
889
890
 
891
+ this._sectionCaps = new SectionCaps(this);
892
+
890
893
  // Default lights
891
894
 
892
895
  new AmbientLight(this, {
@@ -988,6 +991,10 @@ class Scene extends Component {
988
991
  // Scene. Violates Hollywood Principle, where we could just filter on type in _addComponent,
989
992
  // but this is faster than checking the type of each component in such a filter.
990
993
 
994
+ _capMaterialUpdated(entityId, modelId) {
995
+ this._sectionCaps._onCapMaterialUpdated(entityId, modelId);
996
+ }
997
+
991
998
  _sectionPlaneCreated(sectionPlane) {
992
999
  this.sectionPlanes[sectionPlane.id] = sectionPlane;
993
1000
  this.scene._sectionPlanesState.addSectionPlane(sectionPlane._state);
@@ -1994,7 +2001,13 @@ class Scene extends Component {
1994
2001
  get xrayMaterial() {
1995
2002
  return this.components["default.xrayMaterial"] || new EmphasisMaterial(this, {
1996
2003
  id: "default.xrayMaterial",
1997
- preset: "sepia",
2004
+ fill: true,
2005
+ fillColor: [0.970588207244873, 0.7965892553329468, 0.6660899519920349],
2006
+ fillAlpha: 0.4,
2007
+ edges: true,
2008
+ edgeColor: [0.529411792755127, 0.4577854573726654, 0.4100345969200134],
2009
+ edgeAlpha: 1.0,
2010
+ edgeWidth: 1,
1998
2011
  dontClear: true
1999
2012
  });
2000
2013
  }
@@ -2013,7 +2026,13 @@ class Scene extends Component {
2013
2026
  get highlightMaterial() {
2014
2027
  return this.components["default.highlightMaterial"] || new EmphasisMaterial(this, {
2015
2028
  id: "default.highlightMaterial",
2016
- preset: "yellowHighlight",
2029
+ fill: true,
2030
+ fillColor: [1.0, 1.0, 0.0],
2031
+ fillAlpha: 0.5,
2032
+ edges: true,
2033
+ edgeColor: [1.0, 1.0, 1.0],
2034
+ edgeAlpha: 1.0,
2035
+ edgeWidth: 1,
2017
2036
  dontClear: true
2018
2037
  });
2019
2038
  }
@@ -2032,7 +2051,13 @@ class Scene extends Component {
2032
2051
  get selectedMaterial() {
2033
2052
  return this.components["default.selectedMaterial"] || new EmphasisMaterial(this, {
2034
2053
  id: "default.selectedMaterial",
2035
- preset: "greenSelected",
2054
+ fill: true,
2055
+ fillColor: [0.0, 1.0, 0.0],
2056
+ fillAlpha: 0.5,
2057
+ edges: true,
2058
+ edgeColor: [1.0, 1.0, 1.0],
2059
+ edgeAlpha: 1.0,
2060
+ edgeWidth: 1,
2036
2061
  dontClear: true
2037
2062
  });
2038
2063
  }
@@ -2051,7 +2076,10 @@ class Scene extends Component {
2051
2076
  get edgeMaterial() {
2052
2077
  return this.components["default.edgeMaterial"] || new EdgeMaterial(this, {
2053
2078
  id: "default.edgeMaterial",
2054
- preset: "default",
2079
+ fill: true,
2080
+ fillColor: [0.4, 0.4, 0.4],
2081
+ fillAlpha: 0.2,
2082
+ edges: true,
2055
2083
  edgeColor: [0.0, 0.0, 0.0],
2056
2084
  edgeAlpha: 1.0,
2057
2085
  edgeWidth: 1,
@@ -2067,7 +2095,13 @@ class Scene extends Component {
2067
2095
  get pointsMaterial() {
2068
2096
  return this.components["default.pointsMaterial"] || new PointsMaterial(this, {
2069
2097
  id: "default.pointsMaterial",
2070
- preset: "default",
2098
+ fill: true,
2099
+ fillColor: [0.4, 0.4, 0.4],
2100
+ fillAlpha: 0.2,
2101
+ edges: true,
2102
+ edgeColor: [0.2, 0.2, 0.2],
2103
+ edgeAlpha: 0.5,
2104
+ edgeWidth: 1,
2071
2105
  dontClear: true
2072
2106
  });
2073
2107
  }
@@ -2080,7 +2114,13 @@ class Scene extends Component {
2080
2114
  get linesMaterial() {
2081
2115
  return this.components["default.linesMaterial"] || new LinesMaterial(this, {
2082
2116
  id: "default.linesMaterial",
2083
- preset: "default",
2117
+ fill: true,
2118
+ fillColor: [0.4, 0.4, 0.4],
2119
+ fillAlpha: 0.2,
2120
+ edges: true,
2121
+ edgeColor: [0.2, 0.2, 0.2],
2122
+ edgeAlpha: 0.5,
2123
+ edgeWidth: 1,
2084
2124
  dontClear: true
2085
2125
  });
2086
2126
  }
@@ -2796,6 +2836,9 @@ class Scene extends Component {
2796
2836
  }
2797
2837
  }
2798
2838
 
2839
+ //destroy section caps separately because it's not a component
2840
+ this._sectionCaps.destroy();
2841
+
2799
2842
  this.canvas.gl = null;
2800
2843
 
2801
2844
  // Memory leak prevention
@@ -2818,6 +2861,7 @@ class Scene extends Component {
2818
2861
  this._highlightedObjectIds = null;
2819
2862
  this._selectedObjectIds = null;
2820
2863
  this._colorizedObjectIds = null;
2864
+ this._sectionCaps = null;
2821
2865
  this.types = null;
2822
2866
  this.components = null;
2823
2867
  this.canvas = null;