@xeokit/xeokit-sdk 2.5.2-beta-7 → 2.5.2-beta-9
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 +42 -20
- package/dist/xeokit-sdk.es.js +138 -116
- package/dist/xeokit-sdk.es5.js +8 -6
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +1 -1
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +7 -2
- package/src/plugins/AnnotationsPlugin/Annotation.js +2 -2
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +9 -2
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV11.js +663 -0
- package/src/viewer/scene/core.js +24 -14
- package/types/viewer/scene/models/SceneModel.d.ts +46 -48
package/src/viewer/scene/core.js
CHANGED
|
@@ -135,8 +135,28 @@ function Core() {
|
|
|
135
135
|
*/
|
|
136
136
|
const core = new Core();
|
|
137
137
|
|
|
138
|
-
|
|
139
138
|
const frame = function () {
|
|
139
|
+
let time = Date.now();
|
|
140
|
+
elapsedTime = time - lastTime;
|
|
141
|
+
if (lastTime > 0 && elapsedTime > 0) { // Log FPS stats
|
|
142
|
+
var newFPS = 1000 / elapsedTime; // Moving average of FPS
|
|
143
|
+
totalFPS += newFPS;
|
|
144
|
+
fpsSamples.push(newFPS);
|
|
145
|
+
if (fpsSamples.length >= numFPSSamples) {
|
|
146
|
+
totalFPS -= fpsSamples.shift();
|
|
147
|
+
}
|
|
148
|
+
stats.frame.fps = Math.round(totalFPS / fpsSamples.length);
|
|
149
|
+
}
|
|
150
|
+
for (let id in core.scenes) {
|
|
151
|
+
core.scenes[id].compile();
|
|
152
|
+
}
|
|
153
|
+
runTasks(time);
|
|
154
|
+
lastTime = time;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
window.setInterval(frame, 1000 / 30);
|
|
158
|
+
|
|
159
|
+
const renderFrame = function () {
|
|
140
160
|
let time = Date.now();
|
|
141
161
|
elapsedTime = time - lastTime;
|
|
142
162
|
if (lastTime > 0 && elapsedTime > 0) { // Log FPS stats
|
|
@@ -151,10 +171,11 @@ const frame = function () {
|
|
|
151
171
|
runTasks(time);
|
|
152
172
|
fireTickEvents(time);
|
|
153
173
|
renderScenes();
|
|
154
|
-
|
|
155
|
-
(window.requestPostAnimationFrame !== undefined) ? window.requestPostAnimationFrame(frame) : requestAnimationFrame(frame);
|
|
174
|
+
(window.requestPostAnimationFrame !== undefined) ? window.requestPostAnimationFrame(frame) : requestAnimationFrame(renderFrame);
|
|
156
175
|
};
|
|
157
176
|
|
|
177
|
+
renderFrame();
|
|
178
|
+
|
|
158
179
|
function runTasks(time) { // Process as many enqueued tasks as we can within the per-frame task budget
|
|
159
180
|
const tasksRun = core.runTasks(time + taskBudget);
|
|
160
181
|
const tasksScheduled = core.getNumTasks();
|
|
@@ -228,15 +249,4 @@ function renderScenes() {
|
|
|
228
249
|
}
|
|
229
250
|
}
|
|
230
251
|
|
|
231
|
-
(window.requestPostAnimationFrame !== undefined) ? window.requestPostAnimationFrame(frame) : requestAnimationFrame(frame);
|
|
232
|
-
|
|
233
|
-
function compileScenes() {
|
|
234
|
-
|
|
235
|
-
for (let id in core.scenes) {
|
|
236
|
-
core.scenes[id].compile();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
window.setInterval(compileScenes, 1000 / 60);
|
|
241
|
-
|
|
242
252
|
export {core};
|
|
@@ -597,67 +597,63 @@ export declare class SceneModel extends Component {
|
|
|
597
597
|
}): SceneModelMesh;
|
|
598
598
|
|
|
599
599
|
/**
|
|
600
|
-
* Creates a
|
|
600
|
+
* Creates a new {@link SceneModelMesh} within this SceneModel.
|
|
601
601
|
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
* To share a geometry
|
|
605
|
-
* with {@link SceneModel
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
* Internally, SceneModel will batch all unique mesh geometries into the same arrays, which improves
|
|
610
|
-
* rendering performance.
|
|
611
|
-
*
|
|
612
|
-
* If you accompany the arrays with a ````positionsDecodeMatrix```` , then ````createMesh()```` will assume
|
|
613
|
-
* that the ````positions```` and ````normals```` arrays are compressed. When compressed, ````positions```` will be
|
|
614
|
-
* quantized and in World-space, and ````normals```` will be oct-encoded and in World-space.
|
|
615
|
-
*
|
|
616
|
-
* If you accompany the arrays with an ````origin````, then ````createMesh()```` will assume
|
|
617
|
-
* that the ````positions```` are in relative-to-center (RTC) coordinates, with ````origin```` being the origin of their
|
|
618
|
-
* RTC coordinate system.
|
|
619
|
-
*
|
|
620
|
-
* When providing either ````positionsDecodeMatrix```` or ````origin````, ````createMesh()```` will start a new
|
|
621
|
-
* batch each time either of those two parameters change since the last call. Therefore, to combine arrays into the
|
|
622
|
-
* minimum number of batches, it's best for performance to create your shared meshes in runs that have the same value
|
|
623
|
-
* for ````positionsDecodeMatrix```` and ````origin````.
|
|
624
|
-
*
|
|
625
|
-
* 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.
|
|
626
609
|
*
|
|
627
610
|
* @param {object} cfg Object properties.
|
|
628
|
-
* @param {
|
|
629
|
-
* @param {
|
|
630
|
-
* @param {
|
|
631
|
-
* @param {
|
|
632
|
-
* @param {
|
|
633
|
-
* @param {
|
|
634
|
-
* @param {
|
|
635
|
-
* @param {
|
|
636
|
-
* @param {
|
|
637
|
-
* @param {
|
|
638
|
-
* @param {
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* @param {
|
|
642
|
-
* @param {
|
|
643
|
-
* @param {
|
|
644
|
-
* @param {
|
|
645
|
-
* @param {
|
|
646
|
-
* @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.
|
|
647
638
|
*/
|
|
648
639
|
createMesh(cfg: {
|
|
649
640
|
id: string;
|
|
650
|
-
geometryId?: string | number;
|
|
651
|
-
transformId?: string | number;
|
|
652
641
|
textureSetId?: string | number;
|
|
642
|
+
transformId?: string | number;
|
|
643
|
+
geometryId?: string | number;
|
|
653
644
|
primitive: "lines" | "triangles" | "points";
|
|
654
645
|
positions: number[];
|
|
646
|
+
positionsCompressed: number[];
|
|
647
|
+
positionsDecodeMatrix: number[];
|
|
655
648
|
normals: number[];
|
|
649
|
+
normalsCompressed: number[];
|
|
656
650
|
colors: number[];
|
|
657
651
|
colorsCompressed: number[];
|
|
652
|
+
uv: number[];
|
|
653
|
+
uvCompressed: number[];
|
|
654
|
+
uvDecodeMatrix: number[];
|
|
658
655
|
indices: number[];
|
|
659
656
|
edgeIndices: number[];
|
|
660
|
-
positionsDecodeMatrix: number[];
|
|
661
657
|
origin?: number[];
|
|
662
658
|
position?: number[];
|
|
663
659
|
scale?: number[];
|
|
@@ -665,7 +661,9 @@ export declare class SceneModel extends Component {
|
|
|
665
661
|
matrix?: number[];
|
|
666
662
|
color?: number[];
|
|
667
663
|
opacity?: number;
|
|
668
|
-
|
|
664
|
+
metallic?: number;
|
|
665
|
+
roughness?: number;
|
|
666
|
+
}): boolean;
|
|
669
667
|
|
|
670
668
|
/**
|
|
671
669
|
* Creates an {@link SceneModelEntity} within this SceneModel, giving it one or more meshes previously created with {@link SceneModel.createMesh}.
|