mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2024-11-27 10:30:16 -05:00
Updates
This commit is contained in:
parent
56c4fde4f7
commit
dea55fec0f
24
lib/obj.js
24
lib/obj.js
@ -113,8 +113,8 @@ function loadObj(objPath) {
|
||||
var primitives = mesh.primitives;
|
||||
var primitivesLength = primitives.length;
|
||||
for (var i = 0; i < primitivesLength; ++i) {
|
||||
primitive = primitives[i]; // Sets the active primitive in case of returning early
|
||||
if (primitive.material === material) {
|
||||
if (primitives[i].material === material) {
|
||||
primitive = primitives[i];
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -331,25 +331,25 @@ function loadImages(imagePaths) {
|
||||
}
|
||||
|
||||
function getImagePaths(materials) {
|
||||
var imagePaths = [];
|
||||
var imagePaths = {};
|
||||
for (var name in materials) {
|
||||
if (materials.hasOwnProperty(name)) {
|
||||
var material = materials[name];
|
||||
if (defined(material.ambientColorMap) && imagePaths.indexOf(material.ambientColorMap) === -1) {
|
||||
imagePaths.push(material.ambientColorMap);
|
||||
if (defined(material.ambientColorMap)) {
|
||||
imagePaths[material.ambientColorMap] = true;
|
||||
}
|
||||
if (defined(material.diffuseColorMap) && imagePaths.indexOf(material.diffuseColorMap) === -1) {
|
||||
imagePaths.push(material.diffuseColorMap);
|
||||
if (defined(material.diffuseColorMap)) {
|
||||
imagePaths[material.diffuseColorMap] = true;
|
||||
}
|
||||
if (defined(material.emissionColorMap) && imagePaths.indexOf(material.emissionColorMap) === -1) {
|
||||
imagePaths.push(material.emissionColorMap);
|
||||
if (defined(material.emissionColorMap)) {
|
||||
imagePaths[material.emissionColorMap] = true;
|
||||
}
|
||||
if (defined(material.specularColorMap) && imagePaths.indexOf(material.specularColorMap) === -1) {
|
||||
imagePaths.push(material.specularColorMap);
|
||||
if (defined(material.specularColorMap)) {
|
||||
imagePaths[material.specularColorMap] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return imagePaths;
|
||||
return Object.keys(imagePaths);
|
||||
}
|
||||
|
||||
function removeEmptyPrimitives(primitives) {
|
||||
|
@ -128,16 +128,6 @@ describe('obj', function() {
|
||||
}), done).toResolve();
|
||||
});
|
||||
|
||||
it('loads obj with triangle faces', function(done) {
|
||||
expect(loadObj(objTrianglesUrl)
|
||||
.then(function(data) {
|
||||
var mesh = getMeshes(data)[0];
|
||||
var primitive = getPrimitives(data)[0];
|
||||
expect(mesh.positions.length / 3).toBe(24);
|
||||
expect(primitive.indices.length).toBe(36);
|
||||
}), done).toResolve();
|
||||
});
|
||||
|
||||
it('loads obj with objects', function(done) {
|
||||
expect(loadObj(objObjectsUrl)
|
||||
.then(function(data) {
|
||||
|
Loading…
Reference in New Issue
Block a user