@xeokit/xeokit-sdk 2.6.36 → 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.
@@ -682,21 +682,27 @@ class ContextMenu {
682
682
  if (itemSubMenu) {
683
683
 
684
684
  html.push(
685
- '<li id="' + item.id + '" class="xeokit-context-menu-item" style="' +
686
- ((groupIdx === groupLen - 1) || ((j < lenj - 1)) ? 'border-bottom: 0' : 'border-bottom: 1px solid black') +
687
- '">' +
685
+ '<li id="' + item.id + '" class="xeokit-context-menu-item">' +
688
686
  actionTitle +
689
687
  ' [MORE]' +
690
688
  '</li>');
689
+ if (!((groupIdx === groupLen - 1) || (j < lenj - 1))) {
690
+ html.push(
691
+ '<li id="' + item.id + '" class="xeokit-context-menu-item-seperator"></li>'
692
+ );
693
+ }
691
694
 
692
695
  } else {
693
696
 
694
697
  html.push(
695
- '<li id="' + item.id + '" class="xeokit-context-menu-item" style="' +
696
- ((groupIdx === groupLen - 1) || ((j < lenj - 1)) ? 'border-bottom: 0' : 'border-bottom: 1px solid black') +
697
- '">' +
698
+ '<li id="' + item.id + '" class="xeokit-context-menu-item">' +
698
699
  actionTitle +
699
700
  '</li>');
701
+ if (!((groupIdx === groupLen - 1) || (j < lenj - 1))) {
702
+ html.push(
703
+ '<li id="' + item.id + '" class="xeokit-context-menu-item-seperator"></li>'
704
+ );
705
+ }
700
706
  }
701
707
  }
702
708
  }
@@ -894,14 +900,13 @@ class ContextMenu {
894
900
  const shown = getShown(this._context);
895
901
  item.shown = shown;
896
902
  if (!shown) {
897
- itemElement.style.visibility = "hidden";
898
- itemElement.style.height = "0";
899
- itemElement.style.padding = "0";
903
+ itemElement.classList.remove("xeokit-context-menu-item-visible");
904
+ itemElement.classList.add("xeokit-context-menu-item-hidden");
900
905
  continue;
901
906
  } else {
902
- itemElement.style.visibility = "visible";
903
- itemElement.style.height = "auto";
904
- itemElement.style.padding = null;
907
+ itemElement.classList.remove("ceokit-context-menu-item-hidden");
908
+ itemElement.classList.add("xeokit-context-menu-item-visible");
909
+
905
910
  }
906
911
  const enabled = getEnabled(this._context);
907
912
  item.enabled = enabled;
@@ -118140,172 +118145,74 @@ function loadDefaultScene(ctx) {
118140
118145
  error(ctx, "glTF has no default scene");
118141
118146
  return;
118142
118147
  }
118143
- loadScene(ctx, scene);
118144
- }
118145
118148
 
118146
- function loadScene(ctx, scene) {
118147
118149
  const nodes = scene.nodes;
118148
118150
  if (!nodes) {
118149
118151
  return;
118150
118152
  }
118151
- for (let i = 0, len = nodes.length; i < len; i++) {
118152
- const node = nodes[i];
118153
- countMeshUsage(ctx, node);
118154
- }
118155
- for (let i = 0, len = nodes.length; i < len && !ctx.nodesHaveNames; i++) {
118156
- const node = nodes[i];
118157
- if (testIfNodesHaveNames(node)) {
118158
- ctx.nodesHaveNames = true;
118159
- }
118160
- }
118161
- if (!ctx.nodesHaveNames) {
118162
- for (let i = 0, len = nodes.length; i < len; i++) {
118163
- const node = nodes[i];
118164
- parseNodesWithoutNames(ctx, node, 0, null);
118165
- }
118166
- } else {
118167
- for (let i = 0, len = nodes.length; i < len; i++) {
118168
- const node = nodes[i];
118169
- parseNodesWithNames(ctx, node, 0, null);
118170
- }
118171
- }
118172
- }
118173
118153
 
118174
- function countMeshUsage(ctx, node) {
118175
- const mesh = node.mesh;
118176
- if (mesh) {
118177
- mesh.instances = mesh.instances ? mesh.instances + 1 : 1;
118178
- }
118179
- if (node.children) {
118180
- const children = node.children;
118181
- for (let i = 0, len = children.length; i < len; i++) {
118182
- const childNode = children[i];
118183
- if (!childNode) {
118184
- error(ctx, "Node not found: " + i);
118185
- continue;
118154
+ (function accumulateMeshInstantes(nodes) {
118155
+ nodes.forEach(node => {
118156
+ const mesh = node.mesh;
118157
+ if (mesh) {
118158
+ mesh.instances ||= 0;
118159
+ mesh.instances += 1;
118186
118160
  }
118187
- countMeshUsage(ctx, childNode);
118188
- }
118189
- }
118190
- }
118191
-
118192
- function testIfNodesHaveNames(node) {
118193
- if (node.name) {
118194
- return true;
118195
- }
118196
- if (node.children) {
118197
- const children = node.children;
118198
- for (let i = 0, len = children.length; i < len; i++) {
118199
- const childNode = children[i];
118200
- if (testIfNodesHaveNames(childNode)) {
118201
- return true;
118161
+ if (node.children) {
118162
+ accumulateMeshInstantes(node.children);
118202
118163
  }
118203
- }
118204
- }
118205
- return false;
118206
- }
118164
+ });
118165
+ })(nodes);
118207
118166
 
118208
- /**
118209
- * Parses a glTF node hierarchy that is known to NOT contain "name" attributes on the nodes.
118210
- * Create a SceneMesh for each mesh primitive, and a single SceneObject.
118211
- */
118212
- const parseNodesWithoutNames = (function () {
118213
- const meshIds = [];
118214
- return function (ctx, node, depth, matrix, parentNode) {
118215
- matrix = parseNodeMatrix(node, matrix);
118216
- if (node.mesh) {
118217
- parseNodeMesh(node, ctx, matrix, meshIds);
118218
- }
118219
- if (node.children) {
118220
- const children = node.children;
118221
- for (let i = 0, len = children.length; i < len; i++) {
118222
- const childNode = children[i];
118223
- parseNodesWithoutNames(ctx, childNode, depth + 1, matrix, node);
118224
- }
118225
- }
118226
- if (depth === 0) {
118227
- let entityId = "entity-" + ctx.nextId++;
118228
- if (meshIds && meshIds.length > 0) {
118229
- ctx.sceneModel.createEntity({
118230
- id: entityId,
118231
- meshIds,
118232
- isObject: true
118233
- });
118234
- if (ctx.autoMetaModel) {
118235
- ctx.metaObjects.push({
118236
- id: entityId,
118237
- type: "Default",
118238
- name: entityId,
118239
- parent: ctx.sceneModel.id
118240
- });
118167
+ // Create a SceneMesh for each mesh primitive, and a SceneModelEntity for the root node and each named node.
118168
+ const meshIdsStack = [];
118169
+ let meshIds = null;
118170
+ (function createSceneMeshesAndEntities(nodes, depth, parentMatrix) {
118171
+ nodes.forEach(node => {
118172
+ const nodeName = node.name;
118173
+ let entityId = (((nodeName !== undefined) && (nodeName !== null) && nodeName)
118174
+ ||
118175
+ ((depth === 0) && ("entity-" + ctx.nextId++)));
118176
+
118177
+ if (entityId) {
118178
+ while (ctx.sceneModel.objects[entityId]) {
118179
+ entityId = "entity-" + ctx.nextId++;
118241
118180
  }
118242
- meshIds.length = 0;
118181
+ meshIdsStack.push(meshIds);
118182
+ meshIds = [];
118243
118183
  }
118244
- }
118245
- }
118246
- })();
118247
-
118248
- const parseNodesWithNames = (function () {
118249
-
118250
- const objectIdStack = [];
118251
- const meshIdsStack = [];
118252
- let meshIds = [];
118253
118184
 
118254
- return function (ctx, node, depth, matrix) {
118255
- matrix = parseNodeMatrix(node, matrix);
118256
- if (meshIds && node.mesh) {
118257
- parseNodeMesh(node, ctx, matrix, meshIds);
118258
- }
118185
+ const matrix = parseNodeMatrix(node, parentMatrix);
118259
118186
 
118260
- if (node.name) {
118261
- meshIds = [];
118262
- let entityId = node.name;
118263
- if (!!entityId && ctx.sceneModel.objects[entityId]) ;
118264
- while (!entityId || ctx.sceneModel.objects[entityId]) {
118265
- entityId = "entity-" + ctx.nextId++;
118187
+ if (node.mesh) {
118188
+ parseNodeMesh(node, ctx, matrix, meshIds);
118266
118189
  }
118267
- objectIdStack.push(entityId);
118268
- meshIdsStack.push(meshIds);
118269
- }
118270
118190
 
118271
- if (node.children) {
118272
- const children = node.children;
118273
- for (let i = 0, len = children.length; i < len; i++) {
118274
- const childNode = children[i];
118275
- parseNodesWithNames(ctx, childNode, depth + 1, matrix);
118191
+ if (node.children) {
118192
+ createSceneMeshesAndEntities(node.children, depth + 1, matrix);
118276
118193
  }
118277
- }
118278
-
118279
- // Post-order visit scene node
118280
118194
 
118281
- const nodeName = node.name;
118282
- if ((nodeName !== undefined && nodeName !== null) || depth === 0) {
118283
- let entityId = objectIdStack.pop();
118284
- if (!entityId) { // For when there are no nodes with names
118285
- entityId = "entity-" + ctx.nextId++;
118286
- }
118287
- let entityMeshIds = meshIdsStack.pop();
118288
- if (meshIds && meshIds.length > 0) {
118289
- ctx.sceneModel.createEntity({
118290
- id: entityId,
118291
- meshIds: entityMeshIds,
118292
- isObject: true
118293
- });
118294
- if (ctx.autoMetaModel) {
118295
- ctx.metaObjects.push({
118195
+ if (entityId) {
118196
+ if (meshIds.length > 0) {
118197
+ ctx.sceneModel.createEntity({
118296
118198
  id: entityId,
118297
- type: "Default",
118298
- name: entityId,
118299
- parent: ctx.sceneModel.id
118199
+ meshIds: meshIds,
118200
+ isObject: true
118300
118201
  });
118202
+ if (ctx.autoMetaModel) {
118203
+ ctx.metaObjects.push({
118204
+ id: entityId,
118205
+ type: "Default",
118206
+ name: entityId,
118207
+ parent: ctx.sceneModel.id
118208
+ });
118209
+ }
118301
118210
  }
118211
+ meshIds = meshIdsStack.pop();
118302
118212
  }
118303
- meshIds = meshIdsStack.length > 0 ? meshIdsStack[meshIdsStack.length - 1] : null;
118304
- }
118305
- };
118306
- })();
118307
-
118308
-
118213
+ });
118214
+ })(nodes, 0, null);
118215
+ }
118309
118216
  /**
118310
118217
  * Parses transform at the given glTF node.
118311
118218
  *
@@ -140075,7 +139982,7 @@ class DotBIMLoaderPlugin extends Plugin {
140075
139982
  id: `${dbMeshId}-${faceColor}`,
140076
139983
  primitive: "triangles",
140077
139984
  positions: trianglesCoordinates,
140078
- indices: [...Array(trianglesCoordinates.length).keys()]
139985
+ indices: [...Array(trianglesCoordinates.length / 3).keys()]
140079
139986
  });
140080
139987
  const meshId = `${objectId}-mesh-${faceColor}`;
140081
139988
  const faceColorArray = faceColor.split(',').map(Number);
@@ -678,21 +678,27 @@ class ContextMenu {
678
678
  if (itemSubMenu) {
679
679
 
680
680
  html.push(
681
- '<li id="' + item.id + '" class="xeokit-context-menu-item" style="' +
682
- ((groupIdx === groupLen - 1) || ((j < lenj - 1)) ? 'border-bottom: 0' : 'border-bottom: 1px solid black') +
683
- '">' +
681
+ '<li id="' + item.id + '" class="xeokit-context-menu-item">' +
684
682
  actionTitle +
685
683
  ' [MORE]' +
686
684
  '</li>');
685
+ if (!((groupIdx === groupLen - 1) || (j < lenj - 1))) {
686
+ html.push(
687
+ '<li id="' + item.id + '" class="xeokit-context-menu-item-seperator"></li>'
688
+ );
689
+ }
687
690
 
688
691
  } else {
689
692
 
690
693
  html.push(
691
- '<li id="' + item.id + '" class="xeokit-context-menu-item" style="' +
692
- ((groupIdx === groupLen - 1) || ((j < lenj - 1)) ? 'border-bottom: 0' : 'border-bottom: 1px solid black') +
693
- '">' +
694
+ '<li id="' + item.id + '" class="xeokit-context-menu-item">' +
694
695
  actionTitle +
695
696
  '</li>');
697
+ if (!((groupIdx === groupLen - 1) || (j < lenj - 1))) {
698
+ html.push(
699
+ '<li id="' + item.id + '" class="xeokit-context-menu-item-seperator"></li>'
700
+ );
701
+ }
696
702
  }
697
703
  }
698
704
  }
@@ -890,14 +896,13 @@ class ContextMenu {
890
896
  const shown = getShown(this._context);
891
897
  item.shown = shown;
892
898
  if (!shown) {
893
- itemElement.style.visibility = "hidden";
894
- itemElement.style.height = "0";
895
- itemElement.style.padding = "0";
899
+ itemElement.classList.remove("xeokit-context-menu-item-visible");
900
+ itemElement.classList.add("xeokit-context-menu-item-hidden");
896
901
  continue;
897
902
  } else {
898
- itemElement.style.visibility = "visible";
899
- itemElement.style.height = "auto";
900
- itemElement.style.padding = null;
903
+ itemElement.classList.remove("ceokit-context-menu-item-hidden");
904
+ itemElement.classList.add("xeokit-context-menu-item-visible");
905
+
901
906
  }
902
907
  const enabled = getEnabled(this._context);
903
908
  item.enabled = enabled;
@@ -118136,172 +118141,74 @@ function loadDefaultScene(ctx) {
118136
118141
  error(ctx, "glTF has no default scene");
118137
118142
  return;
118138
118143
  }
118139
- loadScene(ctx, scene);
118140
- }
118141
118144
 
118142
- function loadScene(ctx, scene) {
118143
118145
  const nodes = scene.nodes;
118144
118146
  if (!nodes) {
118145
118147
  return;
118146
118148
  }
118147
- for (let i = 0, len = nodes.length; i < len; i++) {
118148
- const node = nodes[i];
118149
- countMeshUsage(ctx, node);
118150
- }
118151
- for (let i = 0, len = nodes.length; i < len && !ctx.nodesHaveNames; i++) {
118152
- const node = nodes[i];
118153
- if (testIfNodesHaveNames(node)) {
118154
- ctx.nodesHaveNames = true;
118155
- }
118156
- }
118157
- if (!ctx.nodesHaveNames) {
118158
- for (let i = 0, len = nodes.length; i < len; i++) {
118159
- const node = nodes[i];
118160
- parseNodesWithoutNames(ctx, node, 0, null);
118161
- }
118162
- } else {
118163
- for (let i = 0, len = nodes.length; i < len; i++) {
118164
- const node = nodes[i];
118165
- parseNodesWithNames(ctx, node, 0, null);
118166
- }
118167
- }
118168
- }
118169
118149
 
118170
- function countMeshUsage(ctx, node) {
118171
- const mesh = node.mesh;
118172
- if (mesh) {
118173
- mesh.instances = mesh.instances ? mesh.instances + 1 : 1;
118174
- }
118175
- if (node.children) {
118176
- const children = node.children;
118177
- for (let i = 0, len = children.length; i < len; i++) {
118178
- const childNode = children[i];
118179
- if (!childNode) {
118180
- error(ctx, "Node not found: " + i);
118181
- continue;
118150
+ (function accumulateMeshInstantes(nodes) {
118151
+ nodes.forEach(node => {
118152
+ const mesh = node.mesh;
118153
+ if (mesh) {
118154
+ mesh.instances ||= 0;
118155
+ mesh.instances += 1;
118182
118156
  }
118183
- countMeshUsage(ctx, childNode);
118184
- }
118185
- }
118186
- }
118187
-
118188
- function testIfNodesHaveNames(node) {
118189
- if (node.name) {
118190
- return true;
118191
- }
118192
- if (node.children) {
118193
- const children = node.children;
118194
- for (let i = 0, len = children.length; i < len; i++) {
118195
- const childNode = children[i];
118196
- if (testIfNodesHaveNames(childNode)) {
118197
- return true;
118157
+ if (node.children) {
118158
+ accumulateMeshInstantes(node.children);
118198
118159
  }
118199
- }
118200
- }
118201
- return false;
118202
- }
118160
+ });
118161
+ })(nodes);
118203
118162
 
118204
- /**
118205
- * Parses a glTF node hierarchy that is known to NOT contain "name" attributes on the nodes.
118206
- * Create a SceneMesh for each mesh primitive, and a single SceneObject.
118207
- */
118208
- const parseNodesWithoutNames = (function () {
118209
- const meshIds = [];
118210
- return function (ctx, node, depth, matrix, parentNode) {
118211
- matrix = parseNodeMatrix(node, matrix);
118212
- if (node.mesh) {
118213
- parseNodeMesh(node, ctx, matrix, meshIds);
118214
- }
118215
- if (node.children) {
118216
- const children = node.children;
118217
- for (let i = 0, len = children.length; i < len; i++) {
118218
- const childNode = children[i];
118219
- parseNodesWithoutNames(ctx, childNode, depth + 1, matrix, node);
118220
- }
118221
- }
118222
- if (depth === 0) {
118223
- let entityId = "entity-" + ctx.nextId++;
118224
- if (meshIds && meshIds.length > 0) {
118225
- ctx.sceneModel.createEntity({
118226
- id: entityId,
118227
- meshIds,
118228
- isObject: true
118229
- });
118230
- if (ctx.autoMetaModel) {
118231
- ctx.metaObjects.push({
118232
- id: entityId,
118233
- type: "Default",
118234
- name: entityId,
118235
- parent: ctx.sceneModel.id
118236
- });
118163
+ // Create a SceneMesh for each mesh primitive, and a SceneModelEntity for the root node and each named node.
118164
+ const meshIdsStack = [];
118165
+ let meshIds = null;
118166
+ (function createSceneMeshesAndEntities(nodes, depth, parentMatrix) {
118167
+ nodes.forEach(node => {
118168
+ const nodeName = node.name;
118169
+ let entityId = (((nodeName !== undefined) && (nodeName !== null) && nodeName)
118170
+ ||
118171
+ ((depth === 0) && ("entity-" + ctx.nextId++)));
118172
+
118173
+ if (entityId) {
118174
+ while (ctx.sceneModel.objects[entityId]) {
118175
+ entityId = "entity-" + ctx.nextId++;
118237
118176
  }
118238
- meshIds.length = 0;
118177
+ meshIdsStack.push(meshIds);
118178
+ meshIds = [];
118239
118179
  }
118240
- }
118241
- }
118242
- })();
118243
-
118244
- const parseNodesWithNames = (function () {
118245
-
118246
- const objectIdStack = [];
118247
- const meshIdsStack = [];
118248
- let meshIds = [];
118249
118180
 
118250
- return function (ctx, node, depth, matrix) {
118251
- matrix = parseNodeMatrix(node, matrix);
118252
- if (meshIds && node.mesh) {
118253
- parseNodeMesh(node, ctx, matrix, meshIds);
118254
- }
118181
+ const matrix = parseNodeMatrix(node, parentMatrix);
118255
118182
 
118256
- if (node.name) {
118257
- meshIds = [];
118258
- let entityId = node.name;
118259
- if (!!entityId && ctx.sceneModel.objects[entityId]) ;
118260
- while (!entityId || ctx.sceneModel.objects[entityId]) {
118261
- entityId = "entity-" + ctx.nextId++;
118183
+ if (node.mesh) {
118184
+ parseNodeMesh(node, ctx, matrix, meshIds);
118262
118185
  }
118263
- objectIdStack.push(entityId);
118264
- meshIdsStack.push(meshIds);
118265
- }
118266
118186
 
118267
- if (node.children) {
118268
- const children = node.children;
118269
- for (let i = 0, len = children.length; i < len; i++) {
118270
- const childNode = children[i];
118271
- parseNodesWithNames(ctx, childNode, depth + 1, matrix);
118187
+ if (node.children) {
118188
+ createSceneMeshesAndEntities(node.children, depth + 1, matrix);
118272
118189
  }
118273
- }
118274
-
118275
- // Post-order visit scene node
118276
118190
 
118277
- const nodeName = node.name;
118278
- if ((nodeName !== undefined && nodeName !== null) || depth === 0) {
118279
- let entityId = objectIdStack.pop();
118280
- if (!entityId) { // For when there are no nodes with names
118281
- entityId = "entity-" + ctx.nextId++;
118282
- }
118283
- let entityMeshIds = meshIdsStack.pop();
118284
- if (meshIds && meshIds.length > 0) {
118285
- ctx.sceneModel.createEntity({
118286
- id: entityId,
118287
- meshIds: entityMeshIds,
118288
- isObject: true
118289
- });
118290
- if (ctx.autoMetaModel) {
118291
- ctx.metaObjects.push({
118191
+ if (entityId) {
118192
+ if (meshIds.length > 0) {
118193
+ ctx.sceneModel.createEntity({
118292
118194
  id: entityId,
118293
- type: "Default",
118294
- name: entityId,
118295
- parent: ctx.sceneModel.id
118195
+ meshIds: meshIds,
118196
+ isObject: true
118296
118197
  });
118198
+ if (ctx.autoMetaModel) {
118199
+ ctx.metaObjects.push({
118200
+ id: entityId,
118201
+ type: "Default",
118202
+ name: entityId,
118203
+ parent: ctx.sceneModel.id
118204
+ });
118205
+ }
118297
118206
  }
118207
+ meshIds = meshIdsStack.pop();
118298
118208
  }
118299
- meshIds = meshIdsStack.length > 0 ? meshIdsStack[meshIdsStack.length - 1] : null;
118300
- }
118301
- };
118302
- })();
118303
-
118304
-
118209
+ });
118210
+ })(nodes, 0, null);
118211
+ }
118305
118212
  /**
118306
118213
  * Parses transform at the given glTF node.
118307
118214
  *
@@ -140071,7 +139978,7 @@ class DotBIMLoaderPlugin extends Plugin {
140071
139978
  id: `${dbMeshId}-${faceColor}`,
140072
139979
  primitive: "triangles",
140073
139980
  positions: trianglesCoordinates,
140074
- indices: [...Array(trianglesCoordinates.length).keys()]
139981
+ indices: [...Array(trianglesCoordinates.length / 3).keys()]
140075
139982
  });
140076
139983
  const meshId = `${objectId}-mesh-${faceColor}`;
140077
139984
  const faceColorArray = faceColor.split(',').map(Number);