@xeokit/xeokit-sdk 2.5.2-beta-5 → 2.5.2-beta-7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.5.2-beta-5",
3
+ "version": "2.5.2-beta-7",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -28,12 +28,20 @@ class TreeViewNode {
28
28
  get title() {
29
29
  }
30
30
 
31
+ /** Type of the corresponding {@link MetaObject}.
32
+ *
33
+ * @type {String}
34
+ * @abstract
35
+ */
36
+ get type() {
37
+ }
38
+
31
39
  /**
32
40
  * ID of the corresponding {@link MetaObject}.
33
41
  *
34
42
  * This is only defined if the TreeViewNode represents an object.
35
43
  *
36
- * @type {Number|String}
44
+ * @type {String}
37
45
  * @abstract
38
46
  */
39
47
  get objectId() {
@@ -54,7 +62,6 @@ class TreeViewNode {
54
62
  * @abstract
55
63
  */
56
64
  get parent() {
57
-
58
65
  }
59
66
 
60
67
  /** The number of {@link Entity}s within the subtree of this TreeViewNode.
@@ -72,7 +79,6 @@ class TreeViewNode {
72
79
  * @abstract
73
80
  */
74
81
  get numVisibleEntities() {
75
-
76
82
  }
77
83
 
78
84
  /** Whether or not the TreeViewNode is currently checked.
@@ -81,7 +87,6 @@ class TreeViewNode {
81
87
  * @abstract
82
88
  */
83
89
  get checked() {
84
-
85
90
  }
86
91
 
87
92
  /** Whether or not the TreeViewNode is currently xrayed.
@@ -89,9 +94,8 @@ class TreeViewNode {
89
94
  * @type {Boolean}
90
95
  * @abstract
91
96
  */
92
- get xrayed() {
93
-
97
+ get xrayed() {
94
98
  }
95
99
  }
96
100
 
97
- export {TreeViewNode};
101
+ export {TreeViewNode};
@@ -1146,8 +1146,6 @@ export class SceneModel extends Component {
1146
1146
  this._vboBatchingLayers = {};
1147
1147
  this._dtxLayers = {};
1148
1148
 
1149
- this._meshList = [];
1150
-
1151
1149
  this.layerList = []; // For GL state efficiency when drawing, InstancingLayers are in first part, BatchingLayers are in second
1152
1150
  this._entityList = [];
1153
1151
 
@@ -1159,7 +1157,8 @@ export class SceneModel extends Component {
1159
1157
  this._meshes = {};
1160
1158
  this._entities = {};
1161
1159
 
1162
- this._scheduledMeshes = {}
1160
+ this._scheduledMeshes = {};
1161
+ this._meshesCfgsBeforeMeshCreation = {};
1163
1162
 
1164
1163
  /** @private **/
1165
1164
  this.renderFlags = new RenderFlags();
@@ -2690,7 +2689,7 @@ export class SceneModel extends Component {
2690
2689
  /**
2691
2690
  * Creates a new {@link SceneModelMesh} within this SceneModel.
2692
2691
  *
2693
- * * Stores the new SceneModelMesh in {@link SceneModel#meshes}.
2692
+ * * It prepares and saves data for a SceneModelMesh {@link SceneModel#meshes} creation. SceneModelMesh will be created only once the SceneModelEntity (which references this particular SceneModelMesh) will be created.
2694
2693
  * * The SceneModelMesh can either define its own geometry or share it with other SceneModelMeshes. To define own geometry, provide the
2695
2694
  * various geometry arrays to this method. To share a geometry, provide the ID of a geometry created earlier
2696
2695
  * with {@link SceneModel#createGeometry}.
@@ -2725,18 +2724,18 @@ export class SceneModel extends Component {
2725
2724
  * @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
2726
2725
  * @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
2727
2726
  * @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
2728
- * @returns {SceneModelMesh} The new mesh.
2727
+ * @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
2729
2728
  */
2730
2729
  createMesh(cfg) {
2731
2730
 
2732
2731
  if (cfg.id === undefined || cfg.id === null) {
2733
2732
  this.error("[createMesh] SceneModel.createMesh() config missing: id");
2734
- return;
2733
+ return false;
2735
2734
  }
2736
2735
 
2737
2736
  if (this._scheduledMeshes[cfg.id]) {
2738
2737
  this.error(`[createMesh] SceneModel already has a mesh with this ID: ${cfg.id}`);
2739
- return;
2738
+ return false;
2740
2739
  }
2741
2740
 
2742
2741
  const instancing = (cfg.geometryId !== undefined);
@@ -2751,31 +2750,31 @@ export class SceneModel extends Component {
2751
2750
  }
2752
2751
  if (cfg.primitive !== "points" && cfg.primitive !== "lines" && cfg.primitive !== "triangles" && cfg.primitive !== "solid" && cfg.primitive !== "surface") {
2753
2752
  this.error(`Unsupported value for 'primitive': '${primitive}' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'.`);
2754
- return;
2753
+ return false;
2755
2754
  }
2756
2755
  if (!cfg.positions && !cfg.positionsCompressed && !cfg.buckets) {
2757
2756
  this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)");
2758
- return null;
2757
+ return false;
2759
2758
  }
2760
2759
  if (cfg.positions && (cfg.positionsDecodeMatrix || cfg.positionsDecodeBoundary)) {
2761
2760
  this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");
2762
- return null;
2761
+ return false;
2763
2762
  }
2764
2763
  if (cfg.positionsCompressed && !cfg.positionsDecodeMatrix && !cfg.positionsDecodeBoundary) {
2765
2764
  this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");
2766
- return null;
2765
+ return false;
2767
2766
  }
2768
2767
  if (cfg.uvCompressed && !cfg.uvDecodeMatrix) {
2769
2768
  this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)");
2770
- return null;
2769
+ return false;
2771
2770
  }
2772
2771
  if (!cfg.buckets && !cfg.indices && cfg.primitive !== "points") {
2773
2772
  this.error(`Param expected: indices (required for '${cfg.primitive}' primitive type)`);
2774
- return null;
2773
+ return false;
2775
2774
  }
2776
2775
  if ((cfg.matrix || cfg.position || cfg.rotation || cfg.scale) && (cfg.positionsCompressed || cfg.positionsDecodeBoundary)) {
2777
2776
  this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'");
2778
- return null;
2777
+ return false;
2779
2778
  }
2780
2779
 
2781
2780
  const useDTX = (!!this._dtxEnabled && (cfg.primitive === "triangles"
@@ -2940,7 +2939,7 @@ export class SceneModel extends Component {
2940
2939
  cfg.textureSet = this._textureSets[cfg.textureSetId];
2941
2940
  if (!cfg.textureSet) {
2942
2941
  this.error(`[createMesh] Texture set not found: ${cfg.textureSetId} - ensure that you create it first with createTextureSet()`);
2943
- return;
2942
+ return false;
2944
2943
  }
2945
2944
  }
2946
2945
  }
@@ -2951,13 +2950,13 @@ export class SceneModel extends Component {
2951
2950
 
2952
2951
  if (cfg.positions || cfg.positionsCompressed || cfg.indices || cfg.edgeIndices || cfg.normals || cfg.normalsCompressed || cfg.uv || cfg.uvCompressed || cfg.positionsDecodeMatrix) {
2953
2952
  this.error(`Mesh geometry parameters not expected when instancing a geometry (not expected: positions, positionsCompressed, indices, edgeIndices, normals, normalsCompressed, uv, uvCompressed, positionsDecodeMatrix)`);
2954
- return;
2953
+ return false;
2955
2954
  }
2956
2955
 
2957
2956
  cfg.geometry = this._geometries[cfg.geometryId];
2958
2957
  if (!cfg.geometry) {
2959
2958
  this.error(`[createMesh] Geometry not found: ${cfg.geometryId} - ensure that you create it first with createGeometry()`);
2960
- return;
2959
+ return false;
2961
2960
  }
2962
2961
 
2963
2962
  cfg.origin = cfg.origin ? math.addVec3(this._origin, cfg.origin, math.vec3()) : this._origin;
@@ -2971,7 +2970,7 @@ export class SceneModel extends Component {
2971
2970
 
2972
2971
  if (!cfg.transform) {
2973
2972
  this.error(`[createMesh] Transform not found: ${cfg.transformId} - ensure that you create it first with createTransform()`);
2974
- return;
2973
+ return false;
2975
2974
  }
2976
2975
 
2977
2976
  cfg.aabb = cfg.geometry.aabb;
@@ -3039,7 +3038,7 @@ export class SceneModel extends Component {
3039
3038
  cfg.textureSet = this._textureSets[cfg.textureSetId];
3040
3039
  // if (!cfg.textureSet) {
3041
3040
  // this.error(`[createMesh] Texture set not found: ${cfg.textureSetId} - ensure that you create it first with createTextureSet()`);
3042
- // return;
3041
+ // return false;
3043
3042
  // }
3044
3043
  }
3045
3044
  }
@@ -3047,7 +3046,9 @@ export class SceneModel extends Component {
3047
3046
 
3048
3047
  cfg.numPrimitives = this._getNumPrimitives(cfg);
3049
3048
 
3050
- return this._createMesh(cfg);
3049
+ this._meshesCfgsBeforeMeshCreation[cfg.id] = cfg;
3050
+
3051
+ return true;
3051
3052
  }
3052
3053
 
3053
3054
  _createMesh(cfg) {
@@ -3079,8 +3080,6 @@ export class SceneModel extends Component {
3079
3080
  cfg.meshMatrix = cfg.transform.worldMatrix;
3080
3081
  }
3081
3082
  mesh.portionId = mesh.layer.createPortion(mesh, cfg);
3082
- this._meshes[cfg.id] = mesh;
3083
- this._meshList.push(mesh);
3084
3083
  return mesh;
3085
3084
  }
3086
3085
 
@@ -3439,10 +3438,15 @@ export class SceneModel extends Component {
3439
3438
  let meshes = [];
3440
3439
  for (let i = 0, len = cfg.meshIds.length; i < len; i++) {
3441
3440
  const meshId = cfg.meshIds[i];
3442
- const mesh = this._meshes[meshId];
3443
- if (!mesh) {
3444
- this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`);
3445
- continue;
3441
+ let mesh = this._meshes[meshId]; // Trying to get already created mesh
3442
+ if (!mesh) { // Checks if there is already created mesh for this meshId
3443
+ let meshCfg = this._meshesCfgsBeforeMeshCreation[meshId]; // Trying to get already created cfg
3444
+ if (!meshCfg) { // Checks if there is already created cfg for this meshId
3445
+ this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`); // There is no such cfg
3446
+ continue;
3447
+ }
3448
+ mesh = this._createMesh(meshCfg) // There is no such mesh yet, but there is already created cfg, so it creates this mesh
3449
+ this._meshes[cfg.id] = mesh; // Now it will also add this mesh to dictionary of created meshes
3446
3450
  }
3447
3451
  if (mesh.parent) {
3448
3452
  this.error(`Mesh with ID "${meshId}" already belongs to object with ID "${mesh.parent.id}" - ignoring this mesh`);
@@ -6,7 +6,6 @@ export declare class TreeViewNode {
6
6
  * Globally unique node ID.
7
7
  *
8
8
  * @type {String}
9
- * @abstract
10
9
  */
11
10
  get nodeId(): string;
12
11
 
@@ -14,7 +13,6 @@ export declare class TreeViewNode {
14
13
  * Title of the TreeViewNode.
15
14
  *
16
15
  * @type {String}
17
- * @abstract
18
16
  */
19
17
  get title(): string;
20
18
 
@@ -23,51 +21,51 @@ export declare class TreeViewNode {
23
21
  *
24
22
  * This is only defined if the TreeViewNode represents an object.
25
23
  *
26
- * @type {Number|String}
27
- * @abstract
24
+ * @type {String}
25
+ */
26
+ get objectId(): string;
27
+
28
+ /**
29
+ * Type of the corresponding {@link MetaObject}.
30
+ *
31
+ * @type {String}
28
32
  */
29
- get objectId(): string | number;
33
+ get type(): string;
30
34
 
31
35
  /**
32
36
  * The child TreeViewNodes.
33
37
  *
34
38
  * @type {Array}
35
- * @abstract
36
39
  */
37
40
  get children(): any[];
38
41
 
39
42
  /** The parent TreeViewNode.
40
43
  *
41
- * @type {TreeViewNode}
42
- * @abstract
44
+ * @type {TreeViewNode|null}
43
45
  */
44
- get parent(): TreeViewNode;
46
+ get parent(): TreeViewNode | null;
45
47
 
46
48
  /** The number of {@link Entity}s within the subtree of this TreeViewNode.
47
49
  *
48
50
  * @type {Number}
49
- * @abstract
50
51
  */
51
52
  get numEntities(): number;
52
53
 
53
54
  /** The number of {@link Entity}s that are currently visible within the subtree of this TreeViewNode.
54
55
  *
55
56
  * @type {Number}
56
- * @abstract
57
57
  */
58
58
  get numVisibleEntities(): number;
59
59
 
60
60
  /** Whether or not the TreeViewNode is currently checked.
61
61
  *
62
62
  * @type {Boolean}
63
- * @abstract
64
63
  */
65
64
  get checked(): boolean;
66
65
 
67
66
  /** Whether or not the TreeViewNode is currently xrayed.
68
67
  *
69
68
  * @type {Boolean}
70
- * @abstract
71
69
  */
72
- get xrayed(): boolean;
70
+ get xrayed(): boolean;
73
71
  }
@@ -72,7 +72,7 @@ export declare interface ITreeViewRenderService {
72
72
  *
73
73
  * @returns {String} The node id.
74
74
  */
75
- getId(element: HTMLElement): string;
75
+ getId(element: HTMLElement): string | undefined;
76
76
 
77
77
  /**
78
78
  * Returns the node id from the checkbox element.
@@ -90,7 +90,7 @@ export declare interface ITreeViewRenderService {
90
90
  *
91
91
  * @returns {HTMLElement} The expand/collapse element.
92
92
  */
93
- getSwitchElement(nodeId: string): HTMLElement
93
+ getSwitchElement(nodeId: string): HTMLElement | null;
94
94
 
95
95
  /**
96
96
  * Returns the node's checkbox state.
@@ -1,8 +1,8 @@
1
- import {Component} from "../Component";
2
- import {SceneModelEntity} from "./SceneModelEntity";
3
- import {EdgeMaterial, EmphasisMaterial} from "../materials";
4
- import {SceneModelMesh} from "./SceneModelMesh";
5
- import {SceneModelTextureSet} from "./SceneModelTextureSet";
1
+ import { Component } from "../Component";
2
+ import { SceneModelEntity } from "./SceneModelEntity";
3
+ import { EdgeMaterial, EmphasisMaterial } from "../materials";
4
+ import { SceneModelMesh } from "./SceneModelMesh";
5
+ import { SceneModelTextureSet } from "./SceneModelTextureSet";
6
6
 
7
7
  /**
8
8
  * A high-performance model representation for efficient rendering and low memory usage.
@@ -168,6 +168,16 @@ export declare class SceneModel extends Component {
168
168
  */
169
169
  get aabb(): number[];
170
170
 
171
+
172
+ get numEntities(): number;
173
+
174
+ /**
175
+ * The number of entities in this SceneModel.
176
+ *
177
+ * @type {number}
178
+ */
179
+ get numEntities(): number;
180
+
171
181
  /**
172
182
  * The approximate number of triangle primitives in this SceneModel.
173
183
  *
@@ -297,7 +307,7 @@ export declare class SceneModel extends Component {
297
307
  *
298
308
  * @type {Boolean}
299
309
  */
300
- set clippable(clippable: boolean) ;
310
+ set clippable(clippable: boolean);
301
311
 
302
312
  /**
303
313
  * Gets if this SceneModel is collidable.
@@ -395,7 +405,7 @@ export declare class SceneModel extends Component {
395
405
  *
396
406
  * @type {Boolean}
397
407
  */
398
- set receivesShadow(receivesShadow: boolean) ;
408
+ set receivesShadow(receivesShadow: boolean);
399
409
 
400
410
  /**
401
411
  * Gets if Scalable Ambient Obscurance (SAO) will apply to this SceneModel.