mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2024-11-23 08:34:14 -05:00
Merge pull request #273 from CesiumGS/eslint-update
Upgrades to eslint-config-cesium/node v9.0.0
This commit is contained in:
commit
9b018ff696
@ -89,7 +89,7 @@ function cloc() {
|
||||
|
||||
//Run cloc on primary Source files only
|
||||
const source = new Promise(function (resolve, reject) {
|
||||
cmdLine = "perl " + clocPath + " --quiet --progress-rate=0" + " lib/ bin/";
|
||||
cmdLine = `perl ${clocPath} --quiet --progress-rate=0` + ` lib/ bin/`;
|
||||
|
||||
child_process.exec(cmdLine, function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
@ -105,8 +105,7 @@ function cloc() {
|
||||
//If running cloc on source succeeded, also run it on the tests.
|
||||
return source.then(function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
cmdLine =
|
||||
"perl " + clocPath + " --quiet --progress-rate=0" + " specs/lib/";
|
||||
cmdLine = `perl ${clocPath} --quiet --progress-rate=0` + ` specs/lib/`;
|
||||
child_process.exec(cmdLine, function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
console.log(stderr);
|
||||
|
@ -141,7 +141,7 @@ function addCombinedBufferView(gltf, buffers, accessors, byteStride, target) {
|
||||
byteLength += buffers[i].length;
|
||||
}
|
||||
gltf.bufferViews.push({
|
||||
name: "bufferView_" + bufferViewIndex,
|
||||
name: `bufferView_${bufferViewIndex}`,
|
||||
buffer: 0,
|
||||
byteLength: byteLength,
|
||||
byteOffset: byteOffset,
|
||||
@ -212,7 +212,7 @@ function addSeparateBufferView(
|
||||
const bufferViewIndex = gltf.bufferViews.length;
|
||||
|
||||
gltf.buffers.push({
|
||||
name: name + "_" + bufferIndex,
|
||||
name: `${name}_${bufferIndex}`,
|
||||
byteLength: buffer.length,
|
||||
extras: {
|
||||
_obj2gltf: {
|
||||
@ -451,7 +451,7 @@ function getSplitMaterialName(
|
||||
) {
|
||||
break;
|
||||
}
|
||||
splitMaterialName = originalMaterialName + "-" + suffix++;
|
||||
splitMaterialName = `${originalMaterialName}-${suffix++}`;
|
||||
}
|
||||
return splitMaterialName;
|
||||
}
|
||||
@ -591,7 +591,7 @@ function addPrimitive(
|
||||
gltf,
|
||||
primitive.positions,
|
||||
3,
|
||||
mesh.name + "_" + index + "_positions"
|
||||
`${mesh.name}_${index}_positions`
|
||||
);
|
||||
attributes.POSITION = accessorIndex;
|
||||
bufferState.positionBuffers.push(primitive.positions.toFloatBuffer());
|
||||
@ -602,7 +602,7 @@ function addPrimitive(
|
||||
gltf,
|
||||
primitive.normals,
|
||||
3,
|
||||
mesh.name + "_" + index + "_normals"
|
||||
`${mesh.name}_${index}_normals`
|
||||
);
|
||||
attributes.NORMAL = accessorIndex;
|
||||
bufferState.normalBuffers.push(primitive.normals.toFloatBuffer());
|
||||
@ -613,7 +613,7 @@ function addPrimitive(
|
||||
gltf,
|
||||
primitive.uvs,
|
||||
2,
|
||||
mesh.name + "_" + index + "_texcoords"
|
||||
`${mesh.name}_${index}_texcoords`
|
||||
);
|
||||
attributes.TEXCOORD_0 = accessorIndex;
|
||||
bufferState.uvBuffers.push(primitive.uvs.toFloatBuffer());
|
||||
@ -624,7 +624,7 @@ function addPrimitive(
|
||||
gltf,
|
||||
primitive.indices,
|
||||
uint32Indices,
|
||||
mesh.name + "_" + index + "_indices"
|
||||
`${mesh.name}_${index}_indices`
|
||||
);
|
||||
const indexBuffer = uint32Indices
|
||||
? primitive.indices.toUint32Buffer()
|
||||
|
@ -346,9 +346,7 @@ function loadMaterialTexture(
|
||||
) {
|
||||
options.logger(error.message);
|
||||
options.logger(
|
||||
"Could not read texture file at " +
|
||||
shallowPath +
|
||||
". This texture will be ignored"
|
||||
`Could not read texture file at ${shallowPath}. This texture will be ignored`
|
||||
);
|
||||
});
|
||||
} else {
|
||||
@ -357,18 +355,14 @@ function loadMaterialTexture(
|
||||
// Try looking for the texture in the same directory as the obj
|
||||
options.logger(error.message);
|
||||
options.logger(
|
||||
"Could not read texture file at " +
|
||||
texturePath +
|
||||
". Attempting to read the texture file from within the obj directory instead."
|
||||
`Could not read texture file at ${texturePath}. Attempting to read the texture file from within the obj directory instead.`
|
||||
);
|
||||
return loadTexture(shallowPath, textureOptions);
|
||||
})
|
||||
.catch(function (error) {
|
||||
options.logger(error.message);
|
||||
options.logger(
|
||||
"Could not read texture file at " +
|
||||
shallowPath +
|
||||
". This texture will be ignored."
|
||||
`Could not read texture file at ${shallowPath}. This texture will be ignored.`
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -493,17 +487,7 @@ function getMinimumDimensions(textures, options) {
|
||||
const texture = textures[i];
|
||||
if (texture.width !== width || texture.height !== height) {
|
||||
options.logger(
|
||||
"Texture " +
|
||||
texture.path +
|
||||
" will be scaled from " +
|
||||
texture.width +
|
||||
"x" +
|
||||
texture.height +
|
||||
" to " +
|
||||
width +
|
||||
"x" +
|
||||
height +
|
||||
"."
|
||||
`Texture ${texture.path} will be scaled from ${texture.width}x${texture.height} to ${width}x${height}.`
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -540,11 +524,7 @@ function createDiffuseAlphaTexture(diffuseTexture, alphaTexture, options) {
|
||||
|
||||
if (!defined(diffuseTexture.pixels) || !defined(alphaTexture.pixels)) {
|
||||
options.logger(
|
||||
"Could not get decoded texture data for " +
|
||||
diffuseTexture.path +
|
||||
" or " +
|
||||
alphaTexture.path +
|
||||
". The material will be created without an alpha texture."
|
||||
`Could not get decoded texture data for ${diffuseTexture.path} or ${alphaTexture.path}. The material will be created without an alpha texture.`
|
||||
);
|
||||
return diffuseTexture;
|
||||
}
|
||||
@ -633,27 +613,21 @@ function createMetallicRoughnessTexture(
|
||||
|
||||
if (packMetallic && !defined(metallicTexture.pixels)) {
|
||||
options.logger(
|
||||
"Could not get decoded texture data for " +
|
||||
metallicTexture.path +
|
||||
". The material will be created without a metallicRoughness texture."
|
||||
`Could not get decoded texture data for ${metallicTexture.path}. The material will be created without a metallicRoughness texture.`
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (packRoughness && !defined(roughnessTexture.pixels)) {
|
||||
options.logger(
|
||||
"Could not get decoded texture data for " +
|
||||
roughnessTexture.path +
|
||||
". The material will be created without a metallicRoughness texture."
|
||||
`Could not get decoded texture data for ${roughnessTexture.path}. The material will be created without a metallicRoughness texture.`
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (packOcclusion && !defined(occlusionTexture.pixels)) {
|
||||
options.logger(
|
||||
"Could not get decoded texture data for " +
|
||||
occlusionTexture.path +
|
||||
". The occlusion texture will not be packed in the metallicRoughness texture."
|
||||
`Could not get decoded texture data for ${occlusionTexture.path}. The occlusion texture will not be packed in the metallicRoughness texture.`
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
@ -744,18 +718,14 @@ function createSpecularGlossinessTexture(
|
||||
|
||||
if (packSpecular && !defined(specularTexture.pixels)) {
|
||||
options.logger(
|
||||
"Could not get decoded texture data for " +
|
||||
specularTexture.path +
|
||||
". The material will be created without a specularGlossiness texture."
|
||||
`Could not get decoded texture data for ${specularTexture.path}. The material will be created without a specularGlossiness texture.`
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (packGlossiness && !defined(glossinessTexture.pixels)) {
|
||||
options.logger(
|
||||
"Could not get decoded texture data for " +
|
||||
glossinessTexture.path +
|
||||
". The material will be created without a specularGlossiness texture."
|
||||
`Could not get decoded texture data for ${glossinessTexture.path}. The material will be created without a specularGlossiness texture.`
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
@ -204,12 +204,10 @@ function loadObj(objPath, options) {
|
||||
function correctVertices(vertices, positions, uvs, normals) {
|
||||
const length = vertices.length;
|
||||
for (let i = 0; i < length; ++i) {
|
||||
vertices[i] =
|
||||
defaultValue(positions[i], "") +
|
||||
"/" +
|
||||
defaultValue(uvs[i], "") +
|
||||
"/" +
|
||||
defaultValue(normals[i], "");
|
||||
vertices[i] = `${defaultValue(positions[i], "")}/${defaultValue(
|
||||
uvs[i],
|
||||
""
|
||||
)}/${defaultValue(normals[i], "")}`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -538,7 +536,7 @@ function getMtlPaths(mtllibLine) {
|
||||
function finishLoading(nodes, mtlPaths, objPath, usesMaterials, options) {
|
||||
nodes = cleanNodes(nodes);
|
||||
if (nodes.length === 0) {
|
||||
throw new RuntimeError(objPath + " does not have any geometry data");
|
||||
throw new RuntimeError(`${objPath} does not have any geometry data`);
|
||||
}
|
||||
const name = path.basename(objPath, path.extname(objPath));
|
||||
return loadMtls(mtlPaths, objPath, options).then(function (materials) {
|
||||
@ -585,9 +583,7 @@ function loadMtls(mtlPaths, objPath, options) {
|
||||
.catch(function (error) {
|
||||
options.logger(error.message);
|
||||
options.logger(
|
||||
"Could not read material file at " +
|
||||
shallowPath +
|
||||
". Using default material instead."
|
||||
`Could not read material file at ${shallowPath}. Using default material instead.`
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -597,9 +593,7 @@ function loadMtls(mtlPaths, objPath, options) {
|
||||
// Try looking for the .mtl in the same directory as the obj
|
||||
options.logger(error.message);
|
||||
options.logger(
|
||||
"Could not read material file at " +
|
||||
mtlPath +
|
||||
". Attempting to read the material file from within the obj directory instead."
|
||||
`Could not read material file at ${mtlPath}. Attempting to read the material file from within the obj directory instead.`
|
||||
);
|
||||
return loadMtl(shallowPath, options);
|
||||
})
|
||||
@ -609,9 +603,7 @@ function loadMtls(mtlPaths, objPath, options) {
|
||||
.catch(function (error) {
|
||||
options.logger(error.message);
|
||||
options.logger(
|
||||
"Could not read material file at " +
|
||||
shallowPath +
|
||||
". Using default material instead."
|
||||
`Could not read material file at ${shallowPath}. Using default material instead.`
|
||||
);
|
||||
});
|
||||
},
|
||||
@ -722,7 +714,7 @@ function setDefaultNames(items, defaultName, usedNames) {
|
||||
const occurrences = usedNames[name];
|
||||
if (defined(occurrences)) {
|
||||
usedNames[name]++;
|
||||
name = name + "_" + occurrences;
|
||||
name = `${name}_${occurrences}`;
|
||||
} else {
|
||||
usedNames[name] = 1;
|
||||
}
|
||||
@ -736,7 +728,7 @@ function setDefaults(nodes) {
|
||||
const nodesLength = nodes.length;
|
||||
for (let i = 0; i < nodesLength; ++i) {
|
||||
const node = nodes[i];
|
||||
setDefaultNames(node.meshes, node.name + "-Mesh", usedNames);
|
||||
setDefaultNames(node.meshes, `${node.name}-Mesh`, usedNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ function writeSeparateBuffers(gltf, options) {
|
||||
buffers,
|
||||
function (buffer) {
|
||||
const source = buffer.extras._obj2gltf.source;
|
||||
const bufferUri = buffer.name + ".bin";
|
||||
const bufferUri = `${buffer.name}.bin`;
|
||||
buffer.uri = bufferUri;
|
||||
return options.writer(bufferUri, source);
|
||||
},
|
||||
@ -169,8 +169,9 @@ function writeEmbeddedBuffer(gltf) {
|
||||
);
|
||||
}
|
||||
|
||||
buffer.uri =
|
||||
"data:application/octet-stream;base64," + source.toString("base64");
|
||||
buffer.uri = `data:application/octet-stream;base64,${source.toString(
|
||||
"base64"
|
||||
)}`;
|
||||
}
|
||||
|
||||
function writeEmbeddedTextures(gltf) {
|
||||
|
@ -38,8 +38,9 @@
|
||||
"cloc": "^2.8.0",
|
||||
"coveralls": "^3.1.1",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-config-cesium": "^8.0.1",
|
||||
"eslint-config-cesium": "^9.0.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"gulp": "^4.0.2",
|
||||
"husky": "^4.3.8",
|
||||
"jasmine": "^3.10.0",
|
||||
|
@ -692,7 +692,7 @@ describe("loadObj", () => {
|
||||
}
|
||||
expect(thrownError).toEqual(
|
||||
new RuntimeError(
|
||||
objInvalidContentsPath + " does not have any geometry data"
|
||||
`${objInvalidContentsPath} does not have any geometry data`
|
||||
)
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user