@xeokit/xeokit-sdk 2.6.29 → 2.6.31
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 +635 -468
- package/dist/xeokit-sdk.es.js +635 -468
- package/dist/xeokit-sdk.es5.js +318 -330
- package/dist/xeokit-sdk.min.cjs.js +4 -4
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.js +110 -33
- package/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js +2 -110
- package/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +257 -222
- package/src/plugins/TreeViewPlugin/TreeViewPlugin.js +1 -1
- package/src/viewer/metadata/MetaScene.js +0 -2
- package/src/viewer/scene/model/SceneModel.js +9 -0
- package/src/viewer/scene/model/SceneModelTextureSet.js +5 -0
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSnapInitRenderer.js +8 -0
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSnapRenderer.js +8 -0
- package/src/viewer/scene/model/vbo/VBORenderer.js +10 -1
- package/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSnapRenderer.js +1 -1
- package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +26 -6
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/Renderers.js +40 -12
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesBatchingRenderer.js +2 -3
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorTextureRenderer.js +25 -7
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapRenderer.js +1 -1
- package/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapRenderer.js +1 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +17 -4
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/Renderers.js +74 -47
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorTextureRenderer.js +29 -14
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesInstancingRenderer.js +5 -4
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapRenderer.js +1 -1
- package/src/viewer/scene/webgl/Renderer.js +6 -3
- package/src/viewer/scene/webgl/occlusion/OcclusionLayer.js +1 -1
- package/src/viewer/scene/webgl/occlusion/OcclusionTester.js +1 -4
- package/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts +5 -3
- package/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts +2 -2
- package/types/plugins/OBJLoaderPlugin/OBJLoaderPlugin.d.ts +3 -3
package/package.json
CHANGED
|
@@ -426,50 +426,127 @@ export class DotBIMLoaderPlugin extends Plugin {
|
|
|
426
426
|
|
|
427
427
|
const dbMeshId = element.mesh_id;
|
|
428
428
|
|
|
429
|
-
parseDBMesh(dbMeshId);
|
|
430
|
-
|
|
431
|
-
const meshId = `${objectId}-mesh`;
|
|
432
429
|
const vector = element.vector;
|
|
433
430
|
const rotation = element.rotation;
|
|
434
431
|
const props = objectDefaults ? objectDefaults[elementType] || objectDefaults["DEFAULT"] : null;
|
|
435
|
-
|
|
436
432
|
let visible = true;
|
|
437
433
|
let pickable = true;
|
|
438
|
-
let color = element.color ? [element.color.r / 255, element.color.g / 255, element.color.b / 255] : [1, 1, 1];
|
|
439
|
-
let opacity = element.color ? element.color.a / 255 : 1.0;
|
|
440
434
|
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
435
|
+
if (element.face_colors === undefined) {
|
|
436
|
+
|
|
437
|
+
parseDBMesh(dbMeshId);
|
|
438
|
+
|
|
439
|
+
const meshId = `${objectId}-mesh`;
|
|
440
|
+
|
|
441
|
+
let color = element.color ? [element.color.r / 255.0, element.color.g / 255.0, element.color.b / 255.0] : [1, 1, 1];
|
|
442
|
+
let opacity = element.color ? element.color.a / 255.0 : 1.0;
|
|
443
|
+
|
|
444
|
+
if (props) {
|
|
445
|
+
if (props.visible === false) {
|
|
446
|
+
visible = false;
|
|
447
|
+
}
|
|
448
|
+
if (props.pickable === false) {
|
|
449
|
+
pickable = false;
|
|
450
|
+
}
|
|
451
|
+
if (props.colorize) {
|
|
452
|
+
color = props.colorize;
|
|
453
|
+
}
|
|
454
|
+
if (props.opacity !== undefined && props.opacity !== null) {
|
|
455
|
+
opacity = props.opacity;
|
|
456
|
+
}
|
|
447
457
|
}
|
|
448
|
-
|
|
449
|
-
|
|
458
|
+
|
|
459
|
+
sceneModel.createMesh({
|
|
460
|
+
id: meshId,
|
|
461
|
+
geometryId: dbMeshId,
|
|
462
|
+
color: color,
|
|
463
|
+
opacity: opacity,
|
|
464
|
+
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
465
|
+
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
sceneModel.createEntity({
|
|
469
|
+
id: objectId,
|
|
470
|
+
meshIds: [meshId],
|
|
471
|
+
visible: visible,
|
|
472
|
+
pickable: pickable,
|
|
473
|
+
isObject: true
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
let faceColors = element.face_colors;
|
|
478
|
+
let coloredTrianglesDictionary = {};
|
|
479
|
+
let currentTriangleIndicesCount = 0;
|
|
480
|
+
let dbMesh = fileData.meshes[element.mesh_id];
|
|
481
|
+
for (let i = 0, len = faceColors.length; i < len; i+=4) {
|
|
482
|
+
let faceColor = [faceColors[i], faceColors[i+1], faceColors[i+2], faceColors[i+3]];
|
|
483
|
+
if (coloredTrianglesDictionary[faceColor] === undefined) {
|
|
484
|
+
coloredTrianglesDictionary[faceColor] = [];
|
|
485
|
+
}
|
|
486
|
+
let indexForPoint0 = dbMesh.indices[currentTriangleIndicesCount];
|
|
487
|
+
let x0 = dbMesh.coordinates[indexForPoint0*3];
|
|
488
|
+
let y0 = dbMesh.coordinates[indexForPoint0*3+1];
|
|
489
|
+
let z0 = dbMesh.coordinates[indexForPoint0*3+2];
|
|
490
|
+
let indexForPoint1 = dbMesh.indices[currentTriangleIndicesCount+1];
|
|
491
|
+
let x1 = dbMesh.coordinates[indexForPoint1*3];
|
|
492
|
+
let y1 = dbMesh.coordinates[indexForPoint1*3+1];
|
|
493
|
+
let z1 = dbMesh.coordinates[indexForPoint1*3+2];
|
|
494
|
+
let indexForPoint2 = dbMesh.indices[currentTriangleIndicesCount+2];
|
|
495
|
+
let x2 = dbMesh.coordinates[indexForPoint2*3];
|
|
496
|
+
let y2 = dbMesh.coordinates[indexForPoint2*3+1];
|
|
497
|
+
let z2 = dbMesh.coordinates[indexForPoint2*3+2];
|
|
498
|
+
coloredTrianglesDictionary[faceColor].push(x0, y0, z0, x1, y1, z1, x2, y2, z2);
|
|
499
|
+
|
|
500
|
+
currentTriangleIndicesCount += 3;
|
|
450
501
|
}
|
|
451
|
-
|
|
452
|
-
|
|
502
|
+
let meshIds = [];
|
|
503
|
+
for (const [faceColor, trianglesCoordinates] of Object.entries(coloredTrianglesDictionary)) {
|
|
504
|
+
sceneModel.createGeometry({
|
|
505
|
+
id: `${dbMeshId}-${faceColor}`,
|
|
506
|
+
primitive: "triangles",
|
|
507
|
+
positions: trianglesCoordinates,
|
|
508
|
+
indices: [...Array(trianglesCoordinates.length).keys()]
|
|
509
|
+
});
|
|
510
|
+
const meshId = `${objectId}-mesh-${faceColor}`;
|
|
511
|
+
const faceColorArray = faceColor.split(',').map(Number);
|
|
512
|
+
|
|
513
|
+
let color = [faceColorArray[0] / 255.0, faceColorArray[1] / 255.0, faceColorArray[2] / 255.0];
|
|
514
|
+
let opacity = faceColorArray[3] / 255.0;
|
|
515
|
+
|
|
516
|
+
if (props) {
|
|
517
|
+
if (props.visible === false) {
|
|
518
|
+
visible = false;
|
|
519
|
+
}
|
|
520
|
+
if (props.pickable === false) {
|
|
521
|
+
pickable = false;
|
|
522
|
+
}
|
|
523
|
+
if (props.colorize) {
|
|
524
|
+
color = props.colorize;
|
|
525
|
+
}
|
|
526
|
+
if (props.opacity !== undefined && props.opacity !== null) {
|
|
527
|
+
opacity = props.opacity;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
sceneModel.createMesh({
|
|
532
|
+
id: meshId,
|
|
533
|
+
geometryId: `${dbMeshId}-${faceColor}`,
|
|
534
|
+
color: color,
|
|
535
|
+
opacity: opacity,
|
|
536
|
+
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
537
|
+
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
538
|
+
});
|
|
539
|
+
meshIds.push(meshId);
|
|
453
540
|
}
|
|
541
|
+
sceneModel.createEntity({
|
|
542
|
+
id: objectId,
|
|
543
|
+
meshIds: meshIds,
|
|
544
|
+
visible: visible,
|
|
545
|
+
pickable: pickable,
|
|
546
|
+
isObject: true
|
|
547
|
+
});
|
|
454
548
|
}
|
|
455
549
|
|
|
456
|
-
sceneModel.createMesh({
|
|
457
|
-
id: meshId,
|
|
458
|
-
geometryId: dbMeshId,
|
|
459
|
-
color,
|
|
460
|
-
opacity,
|
|
461
|
-
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
462
|
-
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
sceneModel.createEntity({
|
|
466
|
-
id: objectId,
|
|
467
|
-
meshIds: [meshId],
|
|
468
|
-
visible,
|
|
469
|
-
pickable,
|
|
470
|
-
isObject: true
|
|
471
|
-
});
|
|
472
|
-
|
|
473
550
|
for (let infoKey in info) {
|
|
474
551
|
let properties;
|
|
475
552
|
if (infoKey.startsWith("IFC_Pset_")) {
|
|
@@ -306,8 +306,6 @@ class GLTFLoaderPlugin extends Plugin {
|
|
|
306
306
|
* @param {String} [params.metaModelSrc] Path to an optional metadata file, as an alternative to the ````metaModelJSON```` parameter.
|
|
307
307
|
* @param {*} [params.metaModelJSON] JSON model metadata, as an alternative to the ````metaModelSrc```` parameter.
|
|
308
308
|
* @param {{String:Object}} [params.objectDefaults] Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}.
|
|
309
|
-
* @param {String[]} [params.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
310
|
-
* @param {String[]} [params.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
311
309
|
* @param {Boolean} [params.edges=false] Whether or not xeokit renders the model with edges emphasized.
|
|
312
310
|
* @param {Number[]} [params.origin=[0,0,0]] The double-precision World-space origin of the model's coordinates.
|
|
313
311
|
* @param {Number[]} [params.position=[0,0,0]] The single-precision position, relative to ````origin````.
|
|
@@ -323,153 +321,47 @@ class GLTFLoaderPlugin extends Plugin {
|
|
|
323
321
|
* represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
|
|
324
322
|
* to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
|
|
325
323
|
* primitives. Only works while {@link DTX#enabled} is also ````true````.
|
|
326
|
-
* @param {
|
|
324
|
+
* @param {Boolean} [params.autoMetaModel] When supplied, creates a default MetaModel with a single MetaObject.
|
|
327
325
|
* @returns {Entity} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}
|
|
328
326
|
*/
|
|
329
327
|
load(params = {}) {
|
|
330
|
-
|
|
331
328
|
if (params.id && this.viewer.scene.components[params.id]) {
|
|
332
329
|
this.error("Component with this ID already exists in viewer: " + params.id + " - will autogenerate this ID");
|
|
333
330
|
delete params.id;
|
|
334
331
|
}
|
|
335
|
-
|
|
336
332
|
const sceneModel = new SceneModel(this.viewer.scene, utils.apply(params, {
|
|
337
333
|
isModel: true,
|
|
338
334
|
dtxEnabled: params.dtxEnabled
|
|
339
335
|
}));
|
|
340
|
-
|
|
341
336
|
const modelId = sceneModel.id; // In case ID was auto-generated
|
|
342
|
-
|
|
343
337
|
if (!params.src && !params.gltf) {
|
|
344
338
|
this.error("load() param expected: src or gltf");
|
|
345
339
|
return sceneModel; // Return new empty model
|
|
346
340
|
}
|
|
347
|
-
|
|
348
341
|
if (params.metaModelSrc || params.metaModelJSON) {
|
|
349
|
-
|
|
350
|
-
const objectDefaults = params.objectDefaults || this._objectDefaults || IFCObjectDefaults;
|
|
351
|
-
|
|
352
342
|
const processMetaModelJSON = (metaModelJSON) => {
|
|
353
|
-
|
|
354
|
-
this.viewer.metaScene.createMetaModel(modelId, metaModelJSON, {
|
|
355
|
-
includeTypes: params.includeTypes,
|
|
356
|
-
excludeTypes: params.excludeTypes
|
|
357
|
-
});
|
|
358
|
-
|
|
343
|
+
this.viewer.metaScene.createMetaModel(modelId, metaModelJSON, {});
|
|
359
344
|
this.viewer.scene.canvas.spinner.processes--;
|
|
360
|
-
|
|
361
|
-
let includeTypes;
|
|
362
|
-
if (params.includeTypes) {
|
|
363
|
-
includeTypes = {};
|
|
364
|
-
for (let i = 0, len = params.includeTypes.length; i < len; i++) {
|
|
365
|
-
includeTypes[params.includeTypes[i]] = true;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
let excludeTypes;
|
|
370
|
-
if (params.excludeTypes) {
|
|
371
|
-
excludeTypes = {};
|
|
372
|
-
if (!includeTypes) {
|
|
373
|
-
includeTypes = {};
|
|
374
|
-
}
|
|
375
|
-
for (let i = 0, len = params.excludeTypes.length; i < len; i++) {
|
|
376
|
-
includeTypes[params.excludeTypes[i]] = true;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
params.readableGeometry = false;
|
|
381
|
-
|
|
382
|
-
params.handleGLTFNode = (modelId, glTFNode, actions) => {
|
|
383
|
-
|
|
384
|
-
const name = glTFNode.name;
|
|
385
|
-
|
|
386
|
-
if (!name) {
|
|
387
|
-
return true; // Continue descending this node subtree
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
const nodeId = name;
|
|
391
|
-
const metaObject = this.viewer.metaScene.metaObjects[nodeId];
|
|
392
|
-
const type = (metaObject ? metaObject.type : "DEFAULT") || "DEFAULT";
|
|
393
|
-
|
|
394
|
-
actions.createEntity = {
|
|
395
|
-
id: nodeId,
|
|
396
|
-
isObject: true // Registers the Entity in Scene#objects
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
const props = objectDefaults[type];
|
|
400
|
-
|
|
401
|
-
if (props) { // Set Entity's initial rendering state for recognized type
|
|
402
|
-
|
|
403
|
-
if (props.visible === false) {
|
|
404
|
-
actions.createEntity.visible = false;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (props.colorize) {
|
|
408
|
-
actions.createEntity.colorize = props.colorize;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (props.pickable === false) {
|
|
412
|
-
actions.createEntity.pickable = false;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
if (props.opacity !== undefined && props.opacity !== null) {
|
|
416
|
-
actions.createEntity.opacity = props.opacity;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return true; // Continue descending this glTF node subtree
|
|
421
|
-
};
|
|
422
|
-
|
|
423
345
|
if (params.src) {
|
|
424
346
|
this._sceneModelLoader.load(this, params.src, metaModelJSON, params, sceneModel);
|
|
425
347
|
} else {
|
|
426
348
|
this._sceneModelLoader.parse(this, params.gltf, metaModelJSON, params, sceneModel);
|
|
427
349
|
}
|
|
428
350
|
};
|
|
429
|
-
|
|
430
351
|
if (params.metaModelSrc) {
|
|
431
|
-
|
|
432
352
|
const metaModelSrc = params.metaModelSrc;
|
|
433
|
-
|
|
434
353
|
this.viewer.scene.canvas.spinner.processes++;
|
|
435
|
-
|
|
436
354
|
this._dataSource.getMetaModel(metaModelSrc, (metaModelJSON) => {
|
|
437
|
-
|
|
438
355
|
this.viewer.scene.canvas.spinner.processes--;
|
|
439
|
-
|
|
440
356
|
processMetaModelJSON(metaModelJSON);
|
|
441
|
-
|
|
442
357
|
}, (errMsg) => {
|
|
443
358
|
this.error(`load(): Failed to load model metadata for model '${modelId} from '${metaModelSrc}' - ${errMsg}`);
|
|
444
359
|
this.viewer.scene.canvas.spinner.processes--;
|
|
445
360
|
});
|
|
446
|
-
|
|
447
361
|
} else if (params.metaModelJSON) {
|
|
448
|
-
|
|
449
362
|
processMetaModelJSON(params.metaModelJSON);
|
|
450
363
|
}
|
|
451
|
-
|
|
452
364
|
} else {
|
|
453
|
-
|
|
454
|
-
params.handleGLTFNode = (modelId, glTFNode, actions) => {
|
|
455
|
-
|
|
456
|
-
const name = glTFNode.name;
|
|
457
|
-
|
|
458
|
-
if (!name) {
|
|
459
|
-
return true; // Continue descending this node subtree
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
const id = name;
|
|
463
|
-
|
|
464
|
-
actions.createEntity = { // Create an Entity for this glTF scene node
|
|
465
|
-
id: id,
|
|
466
|
-
isObject: true // Registers the Entity in Scene#objects
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
return true; // Continue descending this glTF node subtree
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
|
|
473
365
|
if (params.src) {
|
|
474
366
|
this._sceneModelLoader.load(this, params.src, null, params, sceneModel);
|
|
475
367
|
} else {
|