mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2025-02-20 09:33:50 -05:00
Clear vertex cache too
This commit is contained in:
parent
a87087b0dd
commit
ce1591c860
@ -96,6 +96,11 @@ function loadObj(objPath, options) {
|
|||||||
|
|
||||||
var vertexIndices = [];
|
var vertexIndices = [];
|
||||||
|
|
||||||
|
function clearVertexCache() {
|
||||||
|
vertexCache = {};
|
||||||
|
vertexCacheCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
function getName(name) {
|
function getName(name) {
|
||||||
return (name === '' ? undefined : name);
|
return (name === '' ? undefined : name);
|
||||||
}
|
}
|
||||||
@ -120,8 +125,7 @@ function loadObj(objPath, options) {
|
|||||||
mesh.primitives.push(primitive);
|
mesh.primitives.push(primitive);
|
||||||
|
|
||||||
// Clear the vertex cache for each new primitive
|
// Clear the vertex cache for each new primitive
|
||||||
vertexCache = {};
|
clearVertexCache();
|
||||||
vertexCacheCount = 0;
|
|
||||||
vertexCount = 0;
|
vertexCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +139,7 @@ function loadObj(objPath, options) {
|
|||||||
for (var i = 0; i < primitivesLength; ++i) {
|
for (var i = 0; i < primitivesLength; ++i) {
|
||||||
if (primitives[i].material === material) {
|
if (primitives[i].material === material) {
|
||||||
primitive = primitives[i];
|
primitive = primitives[i];
|
||||||
|
clearVertexCache();
|
||||||
vertexCount = primitive.positions.length / 3;
|
vertexCount = primitive.positions.length / 3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -196,8 +201,7 @@ function loadObj(objPath, options) {
|
|||||||
// may be some duplicate vertices.
|
// may be some duplicate vertices.
|
||||||
vertexCacheCount++;
|
vertexCacheCount++;
|
||||||
if (vertexCacheCount > vertexCacheLimit) {
|
if (vertexCacheCount > vertexCacheLimit) {
|
||||||
vertexCacheCount = 0;
|
clearVertexCache();
|
||||||
vertexCache = {};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user