@xeokit/xeokit-sdk 2.6.37 → 2.6.38
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 +65 -158
- package/dist/xeokit-sdk.es.js +65 -158
- package/dist/xeokit-sdk.es5.js +54 -58
- package/dist/xeokit-sdk.min.cjs.js +2 -2
- package/dist/xeokit-sdk.min.es.js +3 -3
- package/dist/xeokit-sdk.min.es5.js +2 -2
- package/package.json +1 -1
- package/src/extras/ContextMenu/ContextMenu.js +19 -14
- package/src/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.js +1 -1
- package/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +47 -146
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Map} from "../../viewer/scene/utils/Map.js";
|
|
1
|
+
import { Map } from "../../viewer/scene/utils/Map.js";
|
|
2
2
|
|
|
3
3
|
const idMap = new Map();
|
|
4
4
|
|
|
@@ -636,21 +636,27 @@ class ContextMenu {
|
|
|
636
636
|
if (itemSubMenu) {
|
|
637
637
|
|
|
638
638
|
html.push(
|
|
639
|
-
'<li id="' + item.id + '" class="xeokit-context-menu-item"
|
|
640
|
-
((groupIdx === groupLen - 1) || ((j < lenj - 1)) ? 'border-bottom: 0' : 'border-bottom: 1px solid black') +
|
|
641
|
-
'">' +
|
|
639
|
+
'<li id="' + item.id + '" class="xeokit-context-menu-item">' +
|
|
642
640
|
actionTitle +
|
|
643
641
|
' [MORE]' +
|
|
644
642
|
'</li>');
|
|
643
|
+
if (!((groupIdx === groupLen - 1) || (j < lenj - 1))) {
|
|
644
|
+
html.push(
|
|
645
|
+
'<li id="' + item.id + '" class="xeokit-context-menu-item-seperator"></li>'
|
|
646
|
+
);
|
|
647
|
+
}
|
|
645
648
|
|
|
646
649
|
} else {
|
|
647
650
|
|
|
648
651
|
html.push(
|
|
649
|
-
'<li id="' + item.id + '" class="xeokit-context-menu-item"
|
|
650
|
-
((groupIdx === groupLen - 1) || ((j < lenj - 1)) ? 'border-bottom: 0' : 'border-bottom: 1px solid black') +
|
|
651
|
-
'">' +
|
|
652
|
+
'<li id="' + item.id + '" class="xeokit-context-menu-item">' +
|
|
652
653
|
actionTitle +
|
|
653
654
|
'</li>');
|
|
655
|
+
if (!((groupIdx === groupLen - 1) || (j < lenj - 1))) {
|
|
656
|
+
html.push(
|
|
657
|
+
'<li id="' + item.id + '" class="xeokit-context-menu-item-seperator"></li>'
|
|
658
|
+
);
|
|
659
|
+
}
|
|
654
660
|
}
|
|
655
661
|
}
|
|
656
662
|
}
|
|
@@ -848,14 +854,13 @@ class ContextMenu {
|
|
|
848
854
|
const shown = getShown(this._context);
|
|
849
855
|
item.shown = shown;
|
|
850
856
|
if (!shown) {
|
|
851
|
-
itemElement.
|
|
852
|
-
itemElement.
|
|
853
|
-
itemElement.style.padding = "0";
|
|
857
|
+
itemElement.classList.remove("xeokit-context-menu-item-visible");
|
|
858
|
+
itemElement.classList.add("xeokit-context-menu-item-hidden");
|
|
854
859
|
continue;
|
|
855
860
|
} else {
|
|
856
|
-
itemElement.
|
|
857
|
-
itemElement.
|
|
858
|
-
|
|
861
|
+
itemElement.classList.remove("ceokit-context-menu-item-hidden");
|
|
862
|
+
itemElement.classList.add("xeokit-context-menu-item-visible");
|
|
863
|
+
|
|
859
864
|
}
|
|
860
865
|
const enabled = getEnabled(this._context);
|
|
861
866
|
item.enabled = enabled;
|
|
@@ -925,4 +930,4 @@ class ContextMenu {
|
|
|
925
930
|
}
|
|
926
931
|
}
|
|
927
932
|
|
|
928
|
-
export {ContextMenu};
|
|
933
|
+
export { ContextMenu };
|
|
@@ -503,7 +503,7 @@ export class DotBIMLoaderPlugin extends Plugin {
|
|
|
503
503
|
id: `${dbMeshId}-${faceColor}`,
|
|
504
504
|
primitive: "triangles",
|
|
505
505
|
positions: trianglesCoordinates,
|
|
506
|
-
indices: [...Array(trianglesCoordinates.length).keys()]
|
|
506
|
+
indices: [...Array(trianglesCoordinates.length / 3).keys()]
|
|
507
507
|
});
|
|
508
508
|
const meshId = `${objectId}-mesh-${faceColor}`;
|
|
509
509
|
const faceColorArray = faceColor.split(',').map(Number);
|
|
@@ -395,173 +395,74 @@ function loadDefaultScene(ctx) {
|
|
|
395
395
|
error(ctx, "glTF has no default scene");
|
|
396
396
|
return;
|
|
397
397
|
}
|
|
398
|
-
loadScene(ctx, scene);
|
|
399
|
-
}
|
|
400
398
|
|
|
401
|
-
function loadScene(ctx, scene) {
|
|
402
399
|
const nodes = scene.nodes;
|
|
403
400
|
if (!nodes) {
|
|
404
401
|
return;
|
|
405
402
|
}
|
|
406
|
-
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
407
|
-
const node = nodes[i];
|
|
408
|
-
countMeshUsage(ctx, node);
|
|
409
|
-
}
|
|
410
|
-
for (let i = 0, len = nodes.length; i < len && !ctx.nodesHaveNames; i++) {
|
|
411
|
-
const node = nodes[i];
|
|
412
|
-
if (testIfNodesHaveNames(node)) {
|
|
413
|
-
ctx.nodesHaveNames = true;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
if (!ctx.nodesHaveNames) {
|
|
417
|
-
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
418
|
-
const node = nodes[i];
|
|
419
|
-
parseNodesWithoutNames(ctx, node, 0, null);
|
|
420
|
-
}
|
|
421
|
-
} else {
|
|
422
|
-
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
423
|
-
const node = nodes[i];
|
|
424
|
-
parseNodesWithNames(ctx, node, 0, null);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
403
|
|
|
429
|
-
function
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
const children = node.children;
|
|
436
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
437
|
-
const childNode = children[i];
|
|
438
|
-
if (!childNode) {
|
|
439
|
-
error(ctx, "Node not found: " + i);
|
|
440
|
-
continue;
|
|
404
|
+
(function accumulateMeshInstantes(nodes) {
|
|
405
|
+
nodes.forEach(node => {
|
|
406
|
+
const mesh = node.mesh;
|
|
407
|
+
if (mesh) {
|
|
408
|
+
mesh.instances ||= 0;
|
|
409
|
+
mesh.instances += 1;
|
|
441
410
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
function testIfNodesHaveNames(node) {
|
|
448
|
-
if (node.name) {
|
|
449
|
-
return true;
|
|
450
|
-
}
|
|
451
|
-
if (node.children) {
|
|
452
|
-
const children = node.children;
|
|
453
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
454
|
-
const childNode = children[i];
|
|
455
|
-
if (testIfNodesHaveNames(childNode)) {
|
|
456
|
-
return true;
|
|
411
|
+
if (node.children) {
|
|
412
|
+
accumulateMeshInstantes(node.children);
|
|
457
413
|
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
return false;
|
|
461
|
-
}
|
|
414
|
+
});
|
|
415
|
+
})(nodes);
|
|
462
416
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
477
|
-
const childNode = children[i];
|
|
478
|
-
parseNodesWithoutNames(ctx, childNode, depth + 1, matrix, node);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
if (depth === 0) {
|
|
482
|
-
let entityId = "entity-" + ctx.nextId++;
|
|
483
|
-
if (meshIds && meshIds.length > 0) {
|
|
484
|
-
ctx.sceneModel.createEntity({
|
|
485
|
-
id: entityId,
|
|
486
|
-
meshIds,
|
|
487
|
-
isObject: true
|
|
488
|
-
});
|
|
489
|
-
if (ctx.autoMetaModel) {
|
|
490
|
-
ctx.metaObjects.push({
|
|
491
|
-
id: entityId,
|
|
492
|
-
type: "Default",
|
|
493
|
-
name: entityId,
|
|
494
|
-
parent: ctx.sceneModel.id
|
|
495
|
-
});
|
|
417
|
+
// Create a SceneMesh for each mesh primitive, and a SceneModelEntity for the root node and each named node.
|
|
418
|
+
const meshIdsStack = [];
|
|
419
|
+
let meshIds = null;
|
|
420
|
+
(function createSceneMeshesAndEntities(nodes, depth, parentMatrix) {
|
|
421
|
+
nodes.forEach(node => {
|
|
422
|
+
const nodeName = node.name;
|
|
423
|
+
let entityId = (((nodeName !== undefined) && (nodeName !== null) && nodeName)
|
|
424
|
+
||
|
|
425
|
+
((depth === 0) && ("entity-" + ctx.nextId++)));
|
|
426
|
+
|
|
427
|
+
if (entityId) {
|
|
428
|
+
while (ctx.sceneModel.objects[entityId]) {
|
|
429
|
+
entityId = "entity-" + ctx.nextId++;
|
|
496
430
|
}
|
|
497
|
-
meshIds
|
|
431
|
+
meshIdsStack.push(meshIds);
|
|
432
|
+
meshIds = [];
|
|
498
433
|
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
})();
|
|
502
|
-
|
|
503
|
-
const parseNodesWithNames = (function () {
|
|
504
|
-
|
|
505
|
-
const objectIdStack = [];
|
|
506
|
-
const meshIdsStack = [];
|
|
507
|
-
let meshIds = [];
|
|
508
434
|
|
|
509
|
-
|
|
510
|
-
matrix = parseNodeMatrix(node, matrix);
|
|
511
|
-
if (meshIds && node.mesh) {
|
|
512
|
-
parseNodeMesh(node, ctx, matrix, meshIds);
|
|
513
|
-
}
|
|
435
|
+
const matrix = parseNodeMatrix(node, parentMatrix);
|
|
514
436
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
let entityId = node.name;
|
|
518
|
-
if (!!entityId && ctx.sceneModel.objects[entityId]) {
|
|
519
|
-
// ctx.log(`Warning: Two or more glTF nodes found with same 'name' attribute: '${entityId} - will randomly-generating an object ID in XKT`);
|
|
520
|
-
}
|
|
521
|
-
while (!entityId || ctx.sceneModel.objects[entityId]) {
|
|
522
|
-
entityId = "entity-" + ctx.nextId++;
|
|
437
|
+
if (node.mesh) {
|
|
438
|
+
parseNodeMesh(node, ctx, matrix, meshIds);
|
|
523
439
|
}
|
|
524
|
-
objectIdStack.push(entityId);
|
|
525
|
-
meshIdsStack.push(meshIds);
|
|
526
|
-
}
|
|
527
440
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
531
|
-
const childNode = children[i];
|
|
532
|
-
parseNodesWithNames(ctx, childNode, depth + 1, matrix);
|
|
441
|
+
if (node.children) {
|
|
442
|
+
createSceneMeshesAndEntities(node.children, depth + 1, matrix);
|
|
533
443
|
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// Post-order visit scene node
|
|
537
444
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
if (!entityId) { // For when there are no nodes with names
|
|
542
|
-
entityId = "entity-" + ctx.nextId++;
|
|
543
|
-
}
|
|
544
|
-
let entityMeshIds = meshIdsStack.pop();
|
|
545
|
-
if (meshIds && meshIds.length > 0) {
|
|
546
|
-
ctx.sceneModel.createEntity({
|
|
547
|
-
id: entityId,
|
|
548
|
-
meshIds: entityMeshIds,
|
|
549
|
-
isObject: true
|
|
550
|
-
});
|
|
551
|
-
if (ctx.autoMetaModel) {
|
|
552
|
-
ctx.metaObjects.push({
|
|
445
|
+
if (entityId) {
|
|
446
|
+
if (meshIds.length > 0) {
|
|
447
|
+
ctx.sceneModel.createEntity({
|
|
553
448
|
id: entityId,
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
parent: ctx.sceneModel.id
|
|
449
|
+
meshIds: meshIds,
|
|
450
|
+
isObject: true
|
|
557
451
|
});
|
|
452
|
+
if (ctx.autoMetaModel) {
|
|
453
|
+
ctx.metaObjects.push({
|
|
454
|
+
id: entityId,
|
|
455
|
+
type: "Default",
|
|
456
|
+
name: entityId,
|
|
457
|
+
parent: ctx.sceneModel.id
|
|
458
|
+
});
|
|
459
|
+
}
|
|
558
460
|
}
|
|
461
|
+
meshIds = meshIdsStack.pop();
|
|
559
462
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
})();
|
|
564
|
-
|
|
463
|
+
});
|
|
464
|
+
})(nodes, 0, null);
|
|
465
|
+
};
|
|
565
466
|
|
|
566
467
|
/**
|
|
567
468
|
* Parses transform at the given glTF node.
|