@xeokit/xeokit-sdk 2.5.2-beta-5 → 2.5.2-beta-8
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 +45 -29
- package/dist/xeokit-sdk.es.js +45 -29
- package/dist/xeokit-sdk.es5.js +22 -15
- package/dist/xeokit-sdk.min.cjs.js +2 -2
- package/dist/xeokit-sdk.min.es.js +2 -2
- package/dist/xeokit-sdk.min.es5.js +2 -2
- package/package.json +1 -1
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +7 -2
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +9 -2
- package/src/plugins/TreeViewPlugin/TreeViewNode.js +11 -7
- package/src/viewer/scene/model/SceneModel.js +30 -26
- package/types/plugins/TreeViewPlugin/TreeViewNode.d.ts +12 -14
- package/types/plugins/TreeViewPlugin/renderService.d.ts +2 -2
- package/types/viewer/scene/models/SceneModel.d.ts +63 -55
package/package.json
CHANGED
|
@@ -218,8 +218,13 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
218
218
|
mouseHoverCanvasPos.set(canvasPos);
|
|
219
219
|
switch (this._mouseState) {
|
|
220
220
|
case MOUSE_FINDING_ORIGIN:
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
const canvasBoundRect = canvas.getBoundingClientRect();
|
|
222
|
+
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
223
|
+
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
224
|
+
const canvasLeftEdge = canvasBoundRect.left + scrollLeft;
|
|
225
|
+
const canvasTopEdge = canvasBoundRect.top + scrollTop;
|
|
226
|
+
this._markerDiv.style.marginLeft = `${canvasLeftEdge + canvasPos[0] - 5}px`;
|
|
227
|
+
this._markerDiv.style.marginTop = `${canvasTopEdge + canvasPos[1] - 5}px`;
|
|
223
228
|
break;
|
|
224
229
|
case MOUSE_FINDING_CORNER:
|
|
225
230
|
if (this._currentAngleMeasurement) {
|
|
@@ -204,8 +204,15 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
|
|
|
204
204
|
pointerWorldPos.set(event.worldPos);
|
|
205
205
|
pointerCanvasPos.set(event.canvasPos);
|
|
206
206
|
if (this._mouseState === MOUSE_FIRST_CLICK_EXPECTED) {
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
|
|
208
|
+
const canvasBoundRect = canvas.getBoundingClientRect();
|
|
209
|
+
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
210
|
+
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
211
|
+
const canvasLeftEdge = canvasBoundRect.left + scrollLeft;
|
|
212
|
+
const canvasTopEdge = canvasBoundRect.top + scrollTop;
|
|
213
|
+
|
|
214
|
+
this._markerDiv.style.marginLeft = `${canvasLeftEdge + canvasPos[0] - 5}px`;
|
|
215
|
+
this._markerDiv.style.marginTop = `${canvasTopEdge + canvasPos[1] - 5}px`;
|
|
209
216
|
this._markerDiv.style.background = "pink";
|
|
210
217
|
if (event.snappedToVertex || event.snappedToEdge) {
|
|
211
218
|
if (this.pointerLens) {
|
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
* *
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
3443
|
-
if (!mesh) {
|
|
3444
|
-
|
|
3445
|
-
|
|
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 {
|
|
27
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
|
@@ -587,67 +597,63 @@ export declare class SceneModel extends Component {
|
|
|
587
597
|
}): SceneModelMesh;
|
|
588
598
|
|
|
589
599
|
/**
|
|
590
|
-
* Creates a
|
|
600
|
+
* Creates a new {@link SceneModelMesh} within this SceneModel.
|
|
591
601
|
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
* To share a geometry
|
|
595
|
-
* with {@link SceneModel
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
* Internally, SceneModel will batch all unique mesh geometries into the same arrays, which improves
|
|
600
|
-
* rendering performance.
|
|
601
|
-
*
|
|
602
|
-
* If you accompany the arrays with a ````positionsDecodeMatrix```` , then ````createMesh()```` will assume
|
|
603
|
-
* that the ````positions```` and ````normals```` arrays are compressed. When compressed, ````positions```` will be
|
|
604
|
-
* quantized and in World-space, and ````normals```` will be oct-encoded and in World-space.
|
|
605
|
-
*
|
|
606
|
-
* If you accompany the arrays with an ````origin````, then ````createMesh()```` will assume
|
|
607
|
-
* that the ````positions```` are in relative-to-center (RTC) coordinates, with ````origin```` being the origin of their
|
|
608
|
-
* RTC coordinate system.
|
|
609
|
-
*
|
|
610
|
-
* When providing either ````positionsDecodeMatrix```` or ````origin````, ````createMesh()```` will start a new
|
|
611
|
-
* batch each time either of those two parameters change since the last call. Therefore, to combine arrays into the
|
|
612
|
-
* minimum number of batches, it's best for performance to create your shared meshes in runs that have the same value
|
|
613
|
-
* for ````positionsDecodeMatrix```` and ````origin````.
|
|
614
|
-
*
|
|
615
|
-
* Note that ````positions````, ````normals```` and ````indices```` are all required together.
|
|
602
|
+
* * 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.
|
|
603
|
+
* * The SceneModelMesh can either define its own geometry or share it with other SceneModelMeshes. To define own geometry, provide the
|
|
604
|
+
* various geometry arrays to this method. To share a geometry, provide the ID of a geometry created earlier
|
|
605
|
+
* with {@link SceneModel#createGeometry}.
|
|
606
|
+
* * If you accompany the arrays with an ````origin````, then ````createMesh()```` will assume
|
|
607
|
+
* that the geometry ````positions```` are in relative-to-center (RTC) coordinates, with ````origin```` being the
|
|
608
|
+
* origin of their RTC coordinate system.
|
|
616
609
|
*
|
|
617
610
|
* @param {object} cfg Object properties.
|
|
618
|
-
* @param {
|
|
619
|
-
* @param {
|
|
620
|
-
* @param {
|
|
621
|
-
* @param {
|
|
622
|
-
* @param {
|
|
623
|
-
* @param {
|
|
624
|
-
* @param {
|
|
625
|
-
* @param {
|
|
626
|
-
* @param {
|
|
627
|
-
* @param {
|
|
628
|
-
* @param {
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
* @param {
|
|
632
|
-
* @param {
|
|
633
|
-
* @param {
|
|
634
|
-
* @param {
|
|
635
|
-
* @param {
|
|
636
|
-
* @param {
|
|
611
|
+
* @param {String} cfg.id Mandatory ID for the new mesh. Must not clash with any existing components within the {@link Scene}.
|
|
612
|
+
* @param {String|Number} [cfg.textureSetId] ID of a {@link SceneModelTextureSet} previously created with {@link SceneModel#createTextureSet}.
|
|
613
|
+
* @param {String|Number} [cfg.transformId] ID of a {@link SceneModelTransform} to instance, previously created with {@link SceneModel#createTransform}. Overrides all other transform parameters given to this method.
|
|
614
|
+
* @param {String|Number} [cfg.geometryId] ID of a geometry to instance, previously created with {@link SceneModel#createGeometry}. Overrides all other geometry parameters given to this method.
|
|
615
|
+
* @param {String} cfg.primitive The primitive type. Accepted values are 'points', 'lines', 'triangles', 'solid' and 'surface'.
|
|
616
|
+
* @param {Number[]} [cfg.positions] Flat array of uncompressed 3D vertex positions positions. Required for all primitive types. Overridden by ````positionsCompressed````.
|
|
617
|
+
* @param {Number[]} [cfg.positionsCompressed] Flat array of quantized 3D vertex positions. Overrides ````positions````, and must be accompanied by ````positionsDecodeMatrix````.
|
|
618
|
+
* @param {Number[]} [cfg.positionsDecodeMatrix] A 4x4 matrix for decompressing ````positionsCompressed````. Must be accompanied by ````positionsCompressed````.
|
|
619
|
+
* @param {Number[]} [cfg.normals] Flat array of normal vectors. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.
|
|
620
|
+
* @param {Number[]} [cfg.normalsCompressed] Flat array of oct-encoded normal vectors. Overrides ````normals````. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.
|
|
621
|
+
* @param {Number[]} [cfg.colors] Flat array of uncompressed RGBA vertex colors, as float values in range ````[0..1]````. Ignored when ````geometryId```` is given. Overridden by ````color```` and ````colorsCompressed````.
|
|
622
|
+
* @param {Number[]} [cfg.colorsCompressed] Flat array of compressed RGBA vertex colors, as unsigned short integers in range ````[0..255]````. Ignored when ````geometryId```` is given. Overrides ````colors```` and is overridden by ````color````.
|
|
623
|
+
* @param {Number[]} [cfg.uv] Flat array of uncompressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.
|
|
624
|
+
* @param {Number[]} [cfg.uvCompressed] Flat array of compressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Overrides ````uv````. Must be accompanied by ````uvDecodeMatrix````. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.
|
|
625
|
+
* @param {Number[]} [cfg.uvDecodeMatrix] A 3x3 matrix for decompressing ````uvCompressed````.
|
|
626
|
+
* @param {Number[]} [cfg.indices] Array of primitive connectivity indices. Not required for `points` primitives.
|
|
627
|
+
* @param {Number[]} [cfg.edgeIndices] Array of edge line indices. Used only with 'triangles', 'solid' and 'surface' primitives. Automatically generated internally if not supplied, using the optional ````edgeThreshold```` given to the ````SceneModel```` constructor.
|
|
628
|
+
* @param {Number[]} [cfg.origin] Optional geometry origin, relative to {@link SceneModel#origin}. When this is given, then ````positions```` are assumed to be relative to this.
|
|
629
|
+
* @param {Number[]} [cfg.position=[0,0,0]] Local 3D position of the mesh. Overridden by ````transformId````.
|
|
630
|
+
* @param {Number[]} [cfg.scale=[1,1,1]] Scale of the mesh. Overridden by ````transformId````.
|
|
631
|
+
* @param {Number[]} [cfg.rotation=[0,0,0]] Rotation of the mesh as Euler angles given in degrees, for each of the X, Y and Z axis. Overridden by ````transformId````.
|
|
632
|
+
* @param {Number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Mesh modelling transform matrix. Overrides the ````position````, ````scale```` and ````rotation```` parameters. Also overridden by ````transformId````.
|
|
633
|
+
* @param {Number[]} [cfg.color=[1,1,1]] RGB color in range ````[0..1, 0..1, 0..1]````. Overridden by texture set ````colorTexture````. Overrides ````colors```` and ````colorsCompressed````.
|
|
634
|
+
* @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
|
|
635
|
+
* @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
|
|
636
|
+
* @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
|
|
637
|
+
* @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
|
|
637
638
|
*/
|
|
638
639
|
createMesh(cfg: {
|
|
639
640
|
id: string;
|
|
640
|
-
geometryId?: string | number;
|
|
641
|
-
transformId?: string | number;
|
|
642
641
|
textureSetId?: string | number;
|
|
642
|
+
transformId?: string | number;
|
|
643
|
+
geometryId?: string | number;
|
|
643
644
|
primitive: "lines" | "triangles" | "points";
|
|
644
645
|
positions: number[];
|
|
646
|
+
positionsCompressed: number[];
|
|
647
|
+
positionsDecodeMatrix: number[];
|
|
645
648
|
normals: number[];
|
|
649
|
+
normalsCompressed: number[];
|
|
646
650
|
colors: number[];
|
|
647
651
|
colorsCompressed: number[];
|
|
652
|
+
uv: number[];
|
|
653
|
+
uvCompressed: number[];
|
|
654
|
+
uvDecodeMatrix: number[];
|
|
648
655
|
indices: number[];
|
|
649
656
|
edgeIndices: number[];
|
|
650
|
-
positionsDecodeMatrix: number[];
|
|
651
657
|
origin?: number[];
|
|
652
658
|
position?: number[];
|
|
653
659
|
scale?: number[];
|
|
@@ -655,7 +661,9 @@ export declare class SceneModel extends Component {
|
|
|
655
661
|
matrix?: number[];
|
|
656
662
|
color?: number[];
|
|
657
663
|
opacity?: number;
|
|
658
|
-
|
|
664
|
+
metallic?: number;
|
|
665
|
+
roughness?: number;
|
|
666
|
+
}): boolean;
|
|
659
667
|
|
|
660
668
|
/**
|
|
661
669
|
* Creates an {@link SceneModelEntity} within this SceneModel, giving it one or more meshes previously created with {@link SceneModel.createMesh}.
|