Skip to content

Commit

Permalink
fix prettier, use jpg for normals
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed Jul 11, 2023
1 parent 6636adf commit 0064dc3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 24 deletions.
6 changes: 2 additions & 4 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ const cli = meow(
--instanceall, -I Instance every geometry (for cheaper re-use)
--transform, -T Transform the asset for the web (draco, prune, resize)
--resolution, -R Resolution for texture resizing (default: 1024)
--keepmeshes, -j Do not join compatible meshes
--keepnormals, -n Do not compress normal maps with loss
--keepmeshes, -j Do not join compatible meshes
--keepmaterials, -M Do not palette join materials
--format, -f Texture format (default: "webp")
--simplify, -S Mesh simplification (default: false)
Expand Down Expand Up @@ -61,8 +60,7 @@ const cli = meow(
degraderesolution: { type: 'number', shortFlag: 'Q', default: 512 },
simplify: { type: 'boolean', shortFlag: 'S', default: false },
keepmeshes: { type: 'boolean', shortFlag: 'j', default: false },
keepmaterials: { type: 'boolean', shortFlag: 'M', default: false },
keepnormals: { type: 'boolean', shortFlag: 'n', default: false },
keepmaterials: { type: 'boolean', shortFlag: 'M', default: false },
format: { type: 'string', shortFlag: 'f', default: 'webp' },
weld: { type: 'number', default: 0.0001 },
ratio: { type: 'number', default: 0.75 },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"keyframe-resample": "^0.0.14",
"meow": "^12.0.1",
"meshoptimizer": "^0.19.0",
"prettier": "^2.8.8",
"prettier": "2.8.7",
"three": "0.152.2",
"three-stdlib": "^2.22.4"
},
Expand Down
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Options
--transform, -T Transform the asset for the web (draco, prune, resize)
--resolution, -R Resolution for texture resizing (default: 1024)
--keepmeshes, -j Do not join compatible meshes
--keepnormals, -n Do not compress normal maps with loss
--keepmaterials, -M Do not palette join materials
--format, -f Texture format (default: "webp")
--simplify, -S Mesh simplification (default: false)
Expand Down
18 changes: 4 additions & 14 deletions src/utils/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ async function transform(file, output, config = {}) {

const document = await io.read(file)
const resolution = config.resolution ?? 1024
const normalResolution = Math.max(resolution, 2048)
const degradeResolution = config.degraderesolution ?? 512

const functions = []

if (!config.keepmaterials) functions.push(palette())
Expand Down Expand Up @@ -75,7 +75,7 @@ async function transform(file, output, config = {}) {
resize: [resolution, resolution],
})
)
} else if (config.keepnormals) {
} else {
// Keep normal maps near lossless
functions.push(
textureCompress({
Expand All @@ -86,19 +86,9 @@ async function transform(file, output, config = {}) {
}),
textureCompress({
slots: /^(?=normalTexture).*$/, // include normal maps
nearLossless: true,
encoder: sharp,
targetFormat: config.format,
resize: [resolution, resolution],
})
)
} else {
// Just treat everything the same
functions.push(
textureCompress({
encoder: sharp,
targetFormat: config.format,
resize: [resolution, resolution],
targetFormat: 'jpeg',
resize: [normalResolution, normalResolution],
})
)
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1520,10 +1520,10 @@ prebuild-install@^7.1.1:
tar-fs "^2.0.0"
tunnel-agent "^0.6.0"

prettier@^2.8.8:
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
[email protected].7:
version "2.8.7"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.7.tgz#bb79fc8729308549d28fe3a98fce73d2c0656450"
integrity sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==

property-graph@^1.2.0:
version "1.2.0"
Expand Down

0 comments on commit 0064dc3

Please sign in to comment.