Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Aug 26, 2024
1 parent d595fab commit 2ae2ef5
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 381 deletions.
223 changes: 65 additions & 158 deletions dist/xeokit-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,21 +682,27 @@ class ContextMenu {
if (itemSubMenu) {

html.push(
'<li id="' + item.id + '" class="xeokit-context-menu-item" style="' +
((groupIdx === groupLen - 1) || ((j < lenj - 1)) ? 'border-bottom: 0' : 'border-bottom: 1px solid black') +
'">' +
'<li id="' + item.id + '" class="xeokit-context-menu-item">' +
actionTitle +
' [MORE]' +
'</li>');
if (!((groupIdx === groupLen - 1) || (j < lenj - 1))) {
html.push(
'<li id="' + item.id + '" class="xeokit-context-menu-item-seperator"></li>'
);
}

} else {

html.push(
'<li id="' + item.id + '" class="xeokit-context-menu-item" style="' +
((groupIdx === groupLen - 1) || ((j < lenj - 1)) ? 'border-bottom: 0' : 'border-bottom: 1px solid black') +
'">' +
'<li id="' + item.id + '" class="xeokit-context-menu-item">' +
actionTitle +
'</li>');
if (!((groupIdx === groupLen - 1) || (j < lenj - 1))) {
html.push(
'<li id="' + item.id + '" class="xeokit-context-menu-item-seperator"></li>'
);
}
}
}
}
Expand Down Expand Up @@ -894,14 +900,13 @@ class ContextMenu {
const shown = getShown(this._context);
item.shown = shown;
if (!shown) {
itemElement.style.visibility = "hidden";
itemElement.style.height = "0";
itemElement.style.padding = "0";
itemElement.classList.remove("xeokit-context-menu-item-visible");
itemElement.classList.add("xeokit-context-menu-item-hidden");
continue;
} else {
itemElement.style.visibility = "visible";
itemElement.style.height = "auto";
itemElement.style.padding = null;
itemElement.classList.remove("ceokit-context-menu-item-hidden");
itemElement.classList.add("xeokit-context-menu-item-visible");

}
const enabled = getEnabled(this._context);
item.enabled = enabled;
Expand Down Expand Up @@ -118140,172 +118145,74 @@ function loadDefaultScene(ctx) {
error(ctx, "glTF has no default scene");
return;
}
loadScene(ctx, scene);
}

function loadScene(ctx, scene) {
const nodes = scene.nodes;
if (!nodes) {
return;
}
for (let i = 0, len = nodes.length; i < len; i++) {
const node = nodes[i];
countMeshUsage(ctx, node);
}
for (let i = 0, len = nodes.length; i < len && !ctx.nodesHaveNames; i++) {
const node = nodes[i];
if (testIfNodesHaveNames(node)) {
ctx.nodesHaveNames = true;
}
}
if (!ctx.nodesHaveNames) {
for (let i = 0, len = nodes.length; i < len; i++) {
const node = nodes[i];
parseNodesWithoutNames(ctx, node, 0, null);
}
} else {
for (let i = 0, len = nodes.length; i < len; i++) {
const node = nodes[i];
parseNodesWithNames(ctx, node, 0, null);
}
}
}

function countMeshUsage(ctx, node) {
const mesh = node.mesh;
if (mesh) {
mesh.instances = mesh.instances ? mesh.instances + 1 : 1;
}
if (node.children) {
const children = node.children;
for (let i = 0, len = children.length; i < len; i++) {
const childNode = children[i];
if (!childNode) {
error(ctx, "Node not found: " + i);
continue;
(function accumulateMeshInstantes(nodes) {
nodes.forEach(node => {
const mesh = node.mesh;
if (mesh) {
mesh.instances ||= 0;
mesh.instances += 1;
}
countMeshUsage(ctx, childNode);
}
}
}

function testIfNodesHaveNames(node) {
if (node.name) {
return true;
}
if (node.children) {
const children = node.children;
for (let i = 0, len = children.length; i < len; i++) {
const childNode = children[i];
if (testIfNodesHaveNames(childNode)) {
return true;
if (node.children) {
accumulateMeshInstantes(node.children);
}
}
}
return false;
}
});
})(nodes);

/**
* Parses a glTF node hierarchy that is known to NOT contain "name" attributes on the nodes.
* Create a SceneMesh for each mesh primitive, and a single SceneObject.
*/
const parseNodesWithoutNames = (function () {
const meshIds = [];
return function (ctx, node, depth, matrix, parentNode) {
matrix = parseNodeMatrix(node, matrix);
if (node.mesh) {
parseNodeMesh(node, ctx, matrix, meshIds);
}
if (node.children) {
const children = node.children;
for (let i = 0, len = children.length; i < len; i++) {
const childNode = children[i];
parseNodesWithoutNames(ctx, childNode, depth + 1, matrix, node);
}
}
if (depth === 0) {
let entityId = "entity-" + ctx.nextId++;
if (meshIds && meshIds.length > 0) {
ctx.sceneModel.createEntity({
id: entityId,
meshIds,
isObject: true
});
if (ctx.autoMetaModel) {
ctx.metaObjects.push({
id: entityId,
type: "Default",
name: entityId,
parent: ctx.sceneModel.id
});
// Create a SceneMesh for each mesh primitive, and a SceneModelEntity for the root node and each named node.
const meshIdsStack = [];
let meshIds = null;
(function createSceneMeshesAndEntities(nodes, depth, parentMatrix) {
nodes.forEach(node => {
const nodeName = node.name;
let entityId = (((nodeName !== undefined) && (nodeName !== null) && nodeName)
||
((depth === 0) && ("entity-" + ctx.nextId++)));

if (entityId) {
while (ctx.sceneModel.objects[entityId]) {
entityId = "entity-" + ctx.nextId++;
}
meshIds.length = 0;
meshIdsStack.push(meshIds);
meshIds = [];
}
}
}
})();

const parseNodesWithNames = (function () {

const objectIdStack = [];
const meshIdsStack = [];
let meshIds = [];

return function (ctx, node, depth, matrix) {
matrix = parseNodeMatrix(node, matrix);
if (meshIds && node.mesh) {
parseNodeMesh(node, ctx, matrix, meshIds);
}
const matrix = parseNodeMatrix(node, parentMatrix);

if (node.name) {
meshIds = [];
let entityId = node.name;
if (!!entityId && ctx.sceneModel.objects[entityId]) ;
while (!entityId || ctx.sceneModel.objects[entityId]) {
entityId = "entity-" + ctx.nextId++;
if (node.mesh) {
parseNodeMesh(node, ctx, matrix, meshIds);
}
objectIdStack.push(entityId);
meshIdsStack.push(meshIds);
}

if (node.children) {
const children = node.children;
for (let i = 0, len = children.length; i < len; i++) {
const childNode = children[i];
parseNodesWithNames(ctx, childNode, depth + 1, matrix);
if (node.children) {
createSceneMeshesAndEntities(node.children, depth + 1, matrix);
}
}

// Post-order visit scene node

const nodeName = node.name;
if ((nodeName !== undefined && nodeName !== null) || depth === 0) {
let entityId = objectIdStack.pop();
if (!entityId) { // For when there are no nodes with names
entityId = "entity-" + ctx.nextId++;
}
let entityMeshIds = meshIdsStack.pop();
if (meshIds && meshIds.length > 0) {
ctx.sceneModel.createEntity({
id: entityId,
meshIds: entityMeshIds,
isObject: true
});
if (ctx.autoMetaModel) {
ctx.metaObjects.push({
if (entityId) {
if (meshIds.length > 0) {
ctx.sceneModel.createEntity({
id: entityId,
type: "Default",
name: entityId,
parent: ctx.sceneModel.id
meshIds: meshIds,
isObject: true
});
if (ctx.autoMetaModel) {
ctx.metaObjects.push({
id: entityId,
type: "Default",
name: entityId,
parent: ctx.sceneModel.id
});
}
}
meshIds = meshIdsStack.pop();
}
meshIds = meshIdsStack.length > 0 ? meshIdsStack[meshIdsStack.length - 1] : null;
}
};
})();


});
})(nodes, 0, null);
}
/**
* Parses transform at the given glTF node.
*
Expand Down Expand Up @@ -140075,7 +139982,7 @@ class DotBIMLoaderPlugin extends Plugin {
id: `${dbMeshId}-${faceColor}`,
primitive: "triangles",
positions: trianglesCoordinates,
indices: [...Array(trianglesCoordinates.length).keys()]
indices: [...Array(trianglesCoordinates.length / 3).keys()]
});
const meshId = `${objectId}-mesh-${faceColor}`;
const faceColorArray = faceColor.split(',').map(Number);
Expand Down
Loading

0 comments on commit 2ae2ef5

Please sign in to comment.