Skip to content

Commit

Permalink
Merge pull request #1772 from xeokit/XCD-215
Browse files Browse the repository at this point in the history
[FIX] SceneModel robustness for invalid tri mesh edgeIndices
  • Loading branch information
xeolabs authored Jan 9, 2025
2 parents 3ee2a14 + 356091a commit 4986b14
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 43 deletions.
30 changes: 19 additions & 11 deletions dist/xeokit-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52178,15 +52178,15 @@ class VBORenderer {
}

if (this._instancing) {
if (this._edges) {
if (this._edges && state.edgeIndicesBuf) {
state.edgeIndicesBuf.bind();
} else {
if (state.indicesBuf) {
state.indicesBuf.bind();
}
}
} else {
if (this._edges) {
if (this._edges && state.edgeIndicesBuf) {
state.edgeIndicesBuf.bind();
} else {
if (state.indicesBuf) {
Expand Down Expand Up @@ -52453,7 +52453,9 @@ class TrianglesBatchingRenderer extends VBORenderer {
} = drawCfg;

if (this._edges) {
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
if (state.edgeIndicesBuf) {
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
}
} else {
const count = frameCtx.pickElementsCount || state.indicesBuf.numItems;
const offset = frameCtx.pickElementsOffset ? frameCtx.pickElementsOffset * state.indicesBuf.itemByteSize : 0;
Expand Down Expand Up @@ -55618,9 +55620,11 @@ class TrianglesSnapRenderer$1 extends VBORenderer{
//=============================================================

if (frameCtx.snapMode === "edge") {
state.edgeIndicesBuf.bind();
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
state.edgeIndicesBuf.unbind(); // needed?
if (state.edgeIndicesBuf) {
state.edgeIndicesBuf.bind();
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
state.edgeIndicesBuf.unbind(); // needed?
}
} else {
gl.drawArrays(gl.POINTS, 0, state.positionsBuf.numItems);
}
Expand Down Expand Up @@ -57789,7 +57793,9 @@ class TrianglesInstancingRenderer extends VBORenderer {
} = drawCfg;

if (this._edges) {
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
if (state.edgeIndicesBuf) {
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
}
} else {
gl.drawElementsInstanced(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);

Expand Down Expand Up @@ -61081,10 +61087,12 @@ class TrianglesSnapRenderer extends VBORenderer {
this._aFlags.bindArrayBuffer(state.flagsBuf);
gl.vertexAttribDivisor(this._aFlags.location, 1);

if (frameCtx.snapMode === "edge") {
state.edgeIndicesBuf.bind();
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
state.edgeIndicesBuf.unbind(); // needed?
if (frameCtx.snapMode === "edge" ) {
if (state.edgeIndicesBuf) {
state.edgeIndicesBuf.bind();
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
state.edgeIndicesBuf.unbind(); // needed?
}
} else {
gl.drawArraysInstanced(gl.POINTS, 0, state.positionsBuf.numItems, state.numInstances);
}
Expand Down
30 changes: 19 additions & 11 deletions dist/xeokit-sdk.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -52174,15 +52174,15 @@ class VBORenderer {
}

if (this._instancing) {
if (this._edges) {
if (this._edges && state.edgeIndicesBuf) {
state.edgeIndicesBuf.bind();
} else {
if (state.indicesBuf) {
state.indicesBuf.bind();
}
}
} else {
if (this._edges) {
if (this._edges && state.edgeIndicesBuf) {
state.edgeIndicesBuf.bind();
} else {
if (state.indicesBuf) {
Expand Down Expand Up @@ -52449,7 +52449,9 @@ class TrianglesBatchingRenderer extends VBORenderer {
} = drawCfg;

if (this._edges) {
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
if (state.edgeIndicesBuf) {
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
}
} else {
const count = frameCtx.pickElementsCount || state.indicesBuf.numItems;
const offset = frameCtx.pickElementsOffset ? frameCtx.pickElementsOffset * state.indicesBuf.itemByteSize : 0;
Expand Down Expand Up @@ -55614,9 +55616,11 @@ class TrianglesSnapRenderer$1 extends VBORenderer{
//=============================================================

if (frameCtx.snapMode === "edge") {
state.edgeIndicesBuf.bind();
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
state.edgeIndicesBuf.unbind(); // needed?
if (state.edgeIndicesBuf) {
state.edgeIndicesBuf.bind();
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
state.edgeIndicesBuf.unbind(); // needed?
}
} else {
gl.drawArrays(gl.POINTS, 0, state.positionsBuf.numItems);
}
Expand Down Expand Up @@ -57785,7 +57789,9 @@ class TrianglesInstancingRenderer extends VBORenderer {
} = drawCfg;

if (this._edges) {
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
if (state.edgeIndicesBuf) {
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
}
} else {
gl.drawElementsInstanced(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);

Expand Down Expand Up @@ -61077,10 +61083,12 @@ class TrianglesSnapRenderer extends VBORenderer {
this._aFlags.bindArrayBuffer(state.flagsBuf);
gl.vertexAttribDivisor(this._aFlags.location, 1);

if (frameCtx.snapMode === "edge") {
state.edgeIndicesBuf.bind();
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
state.edgeIndicesBuf.unbind(); // needed?
if (frameCtx.snapMode === "edge" ) {
if (state.edgeIndicesBuf) {
state.edgeIndicesBuf.bind();
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
state.edgeIndicesBuf.unbind(); // needed?
}
} else {
gl.drawArraysInstanced(gl.POINTS, 0, state.positionsBuf.numItems, state.numInstances);
}
Expand Down
Loading

0 comments on commit 4986b14

Please sign in to comment.