@texture-transform/cli
Advanced tools
Comparing version 1.0.4 to 1.0.5
import caporal from '@caporal/core'; | ||
import { resolveTextureLocation, remapTextureLocation, checkFilesDoNotExist, readTexture, specGlossToMetalRough, writeTexture } from '@texture-transform/core'; | ||
import { resolveTextureLocation, remapTextureLocation, checkFilesDoNotExist, readTexture, extractTextureChannel, specGlossToMetalRough, writeTexture } from '@texture-transform/core'; | ||
import fsPromises from 'fs/promises'; | ||
var name = "@texture-transform/cli"; | ||
var version = "1.0.4"; | ||
var version = "1.0.5"; | ||
var type = "module"; | ||
@@ -43,3 +44,3 @@ var description = "A set of tools for converting between different 3D shader material textures"; | ||
"@caporal/core": "^2.0.2", | ||
"@texture-transform/core": "1.0.3", | ||
"@texture-transform/core": "1.0.5", | ||
"@types/node": "^18.16.1" | ||
@@ -110,2 +111,10 @@ }; | ||
logger.info(`Saving textures`); | ||
try { | ||
await fsPromises.access(outputDirectory); | ||
} catch { | ||
logger.info(`Creating output directory as it didn't exists.`); | ||
await fsPromises.mkdir(outputDirectory, { | ||
recursive: true | ||
}); | ||
} | ||
if (!opts.overwrite) { | ||
@@ -122,2 +131,3 @@ // check if files exist | ||
const [diffuseTexture, specularTexture, glossinessTexture] = await Promise.all([readTexture(diffuseLocation.path), readTexture(specularLocation.path), readTexture(glossinessLocation.path)]); | ||
const singleChannelGlossinessTexture = glossinessTexture.channels === 1 ? glossinessTexture : extractTextureChannel(glossinessTexture, 0); | ||
logger.info(`Converting textures`); | ||
@@ -128,3 +138,3 @@ const { | ||
roughnessTexture | ||
} = specGlossToMetalRough(diffuseTexture, specularTexture, glossinessTexture); | ||
} = specGlossToMetalRough(diffuseTexture, specularTexture, singleChannelGlossinessTexture); | ||
await Promise.all([writeTexture(baseTexture, baseLocation.path, quality), writeTexture(metallicTexture, metallicLocation.path, quality), writeTexture(roughnessTexture, roughnessLocation.path, quality)]); | ||
@@ -131,0 +141,0 @@ }); |
{ | ||
"name": "@texture-transform/cli", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"type": "module", | ||
@@ -41,5 +41,5 @@ "description": "A set of tools for converting between different 3D shader material textures", | ||
"@caporal/core": "^2.0.2", | ||
"@texture-transform/core": "1.0.3", | ||
"@texture-transform/core": "1.0.5", | ||
"@types/node": "^18.16.1" | ||
} | ||
} |
import caporal from '@caporal/core'; | ||
import { | ||
checkFilesDoNotExist, | ||
extractTextureChannel, | ||
readTexture, | ||
@@ -12,2 +13,3 @@ remapTextureLocation, | ||
} from '@texture-transform/core'; | ||
import fsPromises from 'fs/promises'; | ||
@@ -112,2 +114,9 @@ import rawPackageJson from '../package.json'; | ||
try { | ||
await fsPromises.access(outputDirectory); | ||
} catch { | ||
logger.info(`Creating output directory as it didn't exists.`); | ||
await fsPromises.mkdir(outputDirectory, { recursive: true }); | ||
} | ||
if (!opts.overwrite) { | ||
@@ -135,5 +144,14 @@ // check if files exist | ||
const singleChannelGlossinessTexture = | ||
glossinessTexture.channels === 1 | ||
? glossinessTexture | ||
: extractTextureChannel(glossinessTexture, 0); | ||
logger.info(`Converting textures`); | ||
const { baseTexture, metallicTexture, roughnessTexture } = | ||
specGlossToMetalRough(diffuseTexture, specularTexture, glossinessTexture); | ||
specGlossToMetalRough( | ||
diffuseTexture, | ||
specularTexture, | ||
singleChannelGlossinessTexture | ||
); | ||
@@ -140,0 +158,0 @@ await Promise.all([ |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
22469
307
2
+ Added@texture-transform/core@1.0.5(transitive)
- Removed@texture-transform/core@1.0.3(transitive)