@threlte/gltf 3.0.5 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @threlte/gltf
2
2
 
3
+ ## 3.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 766701b: Fixed -p flag collision between --printwidth and --precision
8
+ - 766701b: Fixed --printwidth flag being ignored
9
+ - 766701b: Fixed ReferenceError crash when using --degrade flag
10
+
3
11
  ## 3.0.5
4
12
 
5
13
  ### Patch Changes
package/cli.js CHANGED
@@ -47,7 +47,7 @@ const cli = meow(
47
47
  keepnames: { type: 'boolean', shortFlag: 'k' },
48
48
  keepgroups: { type: 'boolean', shortFlag: 'K' },
49
49
  shadows: { type: 'boolean', shortFlag: 's' },
50
- printwidth: { type: 'number', shortFlag: 'p', default: 120 },
50
+ printwidth: { type: 'number', shortFlag: 'w', default: 120 },
51
51
  meta: { type: 'boolean', shortFlag: 'm' },
52
52
  precision: { type: 'number', shortFlag: 'p', default: 2 },
53
53
  isolated: { type: 'boolean', shortFlag: 'i', default: false },
@@ -62,6 +62,7 @@ const cli = meow(
62
62
  simplify: { type: 'boolean', shortFlag: 'S', default: false },
63
63
  keepmeshes: { type: 'boolean', shortFlag: 'j', default: false },
64
64
  keepmaterials: { type: 'boolean', shortFlag: 'M', default: false },
65
+ format: { type: 'string', shortFlag: 'f', default: 'webp' },
65
66
  ratio: { type: 'number', default: 0.75 },
66
67
  error: { type: 'number', default: 0.001 },
67
68
  debug: { type: 'boolean', shortFlag: 'D' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threlte/gltf",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "GLTF to Threlte converter",
5
5
  "type": "module",
6
6
  "keywords": [
package/src/index.js CHANGED
@@ -39,7 +39,7 @@ export default async function (file, output, options) {
39
39
  singleQuote: true,
40
40
  trailingComma: 'es5',
41
41
  semi: false,
42
- printWidth: 100,
42
+ printWidth: options.printwidth ?? 100,
43
43
  parser: 'svelte',
44
44
  plugins: [prettierPluginSvelte],
45
45
  overrides: [
@@ -19,4 +19,14 @@ export type Options = {
19
19
  ratio?: number
20
20
  error?: number
21
21
  debug?: boolean
22
+ keepmeshes?: boolean
23
+ keepmaterials?: boolean
24
+ format?: string
25
+ degrade?: string
26
+ degraderesolution?: number
27
+ console?: boolean
28
+ header?: string
29
+ showLog?: (log: string) => void
30
+ timeout?: number
31
+ delay?: number
22
32
  }
@@ -53,7 +53,7 @@ export function parse(fileName, gltf, options = {}) {
53
53
  }
54
54
 
55
55
  if (child.geometry) {
56
- const key = child.geometry.uuid + child.material?.name ?? ''
56
+ const key = child.geometry.uuid + (child.material?.name ?? '')
57
57
  if (!duplicates.geometries[key]) {
58
58
  let name = (child.name || 'Part').replace(/[^a-zA-Z]/g, '')
59
59
  name = name.charAt(0).toUpperCase() + name.slice(1)
@@ -77,7 +77,7 @@ export function parse(fileName, gltf, options = {}) {
77
77
  }
78
78
 
79
79
  function sanitizeName(name) {
80
- return isVarName(name) ? `.${name}` : `['${name}']`
80
+ return isVarName(name) ? `.${name}` : `['${name.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}']`
81
81
  }
82
82
 
83
83
  const rNbr = (number) => {
@@ -528,7 +528,7 @@ ${parseExtras(gltf.parser.json.asset && gltf.parser.json.asset.extras)}-->
528
528
  ${
529
529
  options.preload
530
530
  ? `
531
- <script context="module"${options.types ? ' lang="ts"' : ''}>
531
+ <script module${options.types ? ' lang="ts"' : ''}>
532
532
  ${imports}
533
533
 
534
534
  ${options.types ? printThrelteTypes(objects, animations) : ''}
@@ -83,7 +83,7 @@ export async function transform(file, output, config = {}) {
83
83
  encoder: sharp,
84
84
  pattern: new RegExp(`^(?=${config.degrade}).*$`),
85
85
  targetFormat: config.format,
86
- resize: [degradeResolution, degradeResolution]
86
+ resize: [config.degraderesolution ?? 512, config.degraderesolution ?? 512]
87
87
  }),
88
88
  textureCompress({
89
89
  encoder: sharp,