Skip to content

Commit

Permalink
Monthly Maintenance
Browse files Browse the repository at this point in the history
* Upgrade prettier to 3.0.3 and format files.
* Upgrade `eslint-config-cesium` and `eslint-config-prettier`.
* Switch from the defunct `eslint-plugin-node` to `eslint-plugin-n`
Since that is what `eslint-config-cesium` now uses.
* Switch from pretty-quick to lint-staged
  • Loading branch information
mramato committed Oct 3, 2023
1 parent a26858a commit b87c761
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 188 deletions.
12 changes: 7 additions & 5 deletions bin/obj2gltf.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,21 @@ const argv = yargs

if (argv.metallicRoughness + argv.specularGlossiness > 1) {
console.error(
"Only one material type may be set from [--metallicRoughness, --specularGlossiness]."
"Only one material type may be set from [--metallicRoughness, --specularGlossiness].",
);
process.exit(1);
process.exitCode = 1;
return;
}

if (
defined(argv.metallicRoughnessOcclusionTexture) &&
defined(argv.specularGlossinessTexture)
) {
console.error(
"--metallicRoughnessOcclusionTexture and --specularGlossinessTexture cannot both be set."
"--metallicRoughnessOcclusionTexture and --specularGlossinessTexture cannot both be set.",
);
process.exit(1);
process.exitCode = 1;
return;
}

const objPath = argv.input;
Expand Down Expand Up @@ -242,5 +244,5 @@ obj2gltf(objPath, options)
})
.catch(function (error) {
console.log(error.message);
process.exit(1);
process.exitCode = 1;
});
8 changes: 4 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function test() {
new JasmineSpecReporter({
displaySuccessfulSpec:
!defined(argv.suppressPassed) || !argv.suppressPassed,
})
}),
);
const results = await jasmine.execute();
if (argv.failTaskOnError && results.overallStatus === "failed") {
Expand Down Expand Up @@ -78,7 +78,7 @@ async function coverage() {
" JASMINE_CONFIG_PATH=specs/jasmine.json",
{
stdio: [process.stdin, process.stdout, process.stderr],
}
},
);
}

Expand Down Expand Up @@ -178,7 +178,7 @@ async function generateThirdParty() {
for (const packageName in dependencies) {
if (dependencies.hasOwnProperty(packageName)) {
const override = thirdPartyExtraJson.find(
(entry) => entry.name === packageName
(entry) => entry.name === packageName,
);
thirdPartyJson.push(getLicenseDataFromPackage(packageName, override));
}
Expand All @@ -198,6 +198,6 @@ async function generateThirdParty() {

fsExtra.writeFileSync(
"ThirdParty.json",
JSON.stringify(thirdPartyJson, null, 2)
JSON.stringify(thirdPartyJson, null, 2),
);
}
2 changes: 1 addition & 1 deletion lib/ArrayStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function ArrayStorage(componentDatatype) {
function resize(storage, length) {
const typedArray = ComponentDatatype.createTypedArray(
storage.componentDatatype,
length
length,
);
typedArray.set(storage.typedArray);
storage.typedArray = typedArray;
Expand Down
58 changes: 29 additions & 29 deletions lib/createGltf.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function createGltf(objData, options) {
bufferState,
uint32Indices,
meshes[0],
options
options,
);
addNode(gltf, node.name, meshIndex, undefined);
} else {
Expand All @@ -96,7 +96,7 @@ function createGltf(objData, options) {
bufferState,
uint32Indices,
mesh,
options
options,
);
addNode(gltf, mesh.name, meshIndex, parentIndex);
}
Expand Down Expand Up @@ -158,36 +158,36 @@ function addCombinedBuffers(gltf, bufferState, name) {
bufferState.positionBuffers,
bufferState.positionAccessors,
12,
WebGLConstants.ARRAY_BUFFER
WebGLConstants.ARRAY_BUFFER,
);
addCombinedBufferView(
gltf,
bufferState.normalBuffers,
bufferState.normalAccessors,
12,
WebGLConstants.ARRAY_BUFFER
WebGLConstants.ARRAY_BUFFER,
);
addCombinedBufferView(
gltf,
bufferState.uvBuffers,
bufferState.uvAccessors,
8,
WebGLConstants.ARRAY_BUFFER
WebGLConstants.ARRAY_BUFFER,
);
addCombinedBufferView(
gltf,
bufferState.indexBuffers,
bufferState.indexAccessors,
undefined,
WebGLConstants.ELEMENT_ARRAY_BUFFER
WebGLConstants.ELEMENT_ARRAY_BUFFER,
);

let buffers = [];
buffers = buffers.concat(
bufferState.positionBuffers,
bufferState.normalBuffers,
bufferState.uvBuffers,
bufferState.indexBuffers
bufferState.indexBuffers,
);
const buffer = getBufferPadded(Buffer.concat(buffers));

Expand All @@ -208,7 +208,7 @@ function addSeparateBufferView(
accessor,
byteStride,
target,
name
name,
) {
const bufferIndex = gltf.buffers.length;
const bufferViewIndex = gltf.bufferViews.length;
Expand Down Expand Up @@ -241,7 +241,7 @@ function addSeparateBufferViews(
accessors,
byteStride,
target,
name
name,
) {
const length = buffers.length;
for (let i = 0; i < length; ++i) {
Expand All @@ -251,7 +251,7 @@ function addSeparateBufferViews(
accessors[i],
byteStride,
target,
name
name,
);
}
}
Expand All @@ -263,39 +263,39 @@ function addSeparateBuffers(gltf, bufferState, name) {
bufferState.positionAccessors,
12,
WebGLConstants.ARRAY_BUFFER,
name
name,
);
addSeparateBufferViews(
gltf,
bufferState.normalBuffers,
bufferState.normalAccessors,
12,
WebGLConstants.ARRAY_BUFFER,
name
name,
);
addSeparateBufferViews(
gltf,
bufferState.uvBuffers,
bufferState.uvAccessors,
8,
WebGLConstants.ARRAY_BUFFER,
name
name,
);
addSeparateBufferViews(
gltf,
bufferState.indexBuffers,
bufferState.indexAccessors,
undefined,
WebGLConstants.ELEMENT_ARRAY_BUFFER,
name
name,
);
}

function addBuffers(gltf, bufferState, name, separate) {
const buffers = bufferState.positionBuffers.concat(
bufferState.normalBuffers,
bufferState.uvBuffers,
bufferState.indexBuffers
bufferState.indexBuffers,
);
const buffersLength = buffers.length;
let buffersByteLength = 0;
Expand Down Expand Up @@ -440,15 +440,15 @@ function primitiveInfoMatch(a, b) {
function getSplitMaterialName(
originalMaterialName,
primitiveInfo,
primitiveInfoByMaterial
primitiveInfoByMaterial,
) {
let splitMaterialName = originalMaterialName;
let suffix = 2;
while (defined(primitiveInfoByMaterial[splitMaterialName])) {
if (
primitiveInfoMatch(
primitiveInfo,
primitiveInfoByMaterial[splitMaterialName]
primitiveInfoByMaterial[splitMaterialName],
)
) {
break;
Expand Down Expand Up @@ -478,27 +478,27 @@ function splitIncompatibleMaterials(nodes, materials, options) {
};
const originalMaterialName = defaultValue(
primitive.material,
"default"
"default",
);
const splitMaterialName = getSplitMaterialName(
originalMaterialName,
primitiveInfo,
primitiveInfoByMaterial
primitiveInfoByMaterial,
);
primitive.material = splitMaterialName;
primitiveInfoByMaterial[splitMaterialName] = primitiveInfo;

let splitMaterial = getMaterialByName(
splitMaterials,
splitMaterialName
splitMaterialName,
);
if (defined(splitMaterial)) {
continue;
}

const originalMaterial = getMaterialByName(
materials,
originalMaterialName
originalMaterialName,
);
if (defined(originalMaterial)) {
splitMaterial = cloneMaterial(originalMaterial, !hasUvs);
Expand Down Expand Up @@ -581,7 +581,7 @@ function addPrimitive(
mesh,
primitive,
index,
options
options,
) {
const hasPositions = primitive.positions.length > 0;
const hasNormals = primitive.normals.length > 0;
Expand All @@ -593,7 +593,7 @@ function addPrimitive(
gltf,
primitive.positions,
3,
`${mesh.name}_${index}_positions`
`${mesh.name}_${index}_positions`,
);
attributes.POSITION = accessorIndex;
bufferState.positionBuffers.push(primitive.positions.toFloatBuffer());
Expand All @@ -604,7 +604,7 @@ function addPrimitive(
gltf,
primitive.normals,
3,
`${mesh.name}_${index}_normals`
`${mesh.name}_${index}_normals`,
);
attributes.NORMAL = accessorIndex;
bufferState.normalBuffers.push(primitive.normals.toFloatBuffer());
Expand All @@ -615,7 +615,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());
Expand All @@ -626,7 +626,7 @@ function addPrimitive(
gltf,
primitive.indices,
uint32Indices,
`${mesh.name}_${index}_indices`
`${mesh.name}_${index}_indices`,
);
const indexBuffer = uint32Indices
? primitive.indices.toUint32Buffer()
Expand All @@ -644,7 +644,7 @@ function addPrimitive(
gltf,
materials,
primitive.material,
options
options,
);

return {
Expand All @@ -669,8 +669,8 @@ function addMesh(gltf, materials, bufferState, uint32Indices, mesh, options) {
mesh,
primitives[i],
i,
options
)
options,
),
);
}

Expand Down
Loading

0 comments on commit b87c761

Please sign in to comment.