Skip to content

Commit 4299b89

Browse files
committed
feat: update cli
1 parent 7b8d93e commit 4299b89

File tree

8 files changed

+2502
-2461
lines changed

8 files changed

+2502
-2461
lines changed

cli.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const cli = meow(
2121
--name, -n Name of the component
2222
--keepnames, -k Keep original names
2323
--keepgroups, -K Keep (empty) groups, disable pruning
24+
--bones, -b Layout bones declaratively (default: false)
2425
--meta, -m Include metadata (as userData)
2526
--shadows, -s Let meshes cast and receive shadows
2627
--printwidth, -w Prettier printWidth (default: 120)
@@ -29,11 +30,14 @@ const cli = meow(
2930
--preload -P Add preload method to module script
3031
--root, -r Sets directory from which .gltf file is served
3132
--transform, -T Transform the asset for the web (draco, prune, resize)
32-
--resolution, -R Transform resolution for texture resizing (default: 1024)
33-
--simplify, -S Transform simplification (default: false) (experimental!)
34-
--weld Weld tolerance (default: 0.0001)
35-
--ratio Simplifier ratio (default: 0.75)
36-
--error Simplifier error threshold (default: 0.001)
33+
--resolution, -R Resolution for texture resizing (default: 1024)
34+
--keepmeshes, -j Do not join compatible meshes
35+
--keepmaterials, -M Do not palette join materials
36+
--format, -f Texture format (default: "webp")
37+
--simplify, -S Mesh simplification (default: false)
38+
--ratio Simplifier ratio (default: 0)
39+
--error Simplifier error threshold (default: 0.0001)
40+
--console, -c Log component to console, won't produce a file
3741
--debug, -D Debug output
3842
`,
3943
{
@@ -42,24 +46,31 @@ const cli = meow(
4246
output: { type: "string", shortFlag: "o" },
4347
selector: { type: "string" },
4448
name: { type: "string" },
45-
types: { type: "boolean", shortFlag: "t" },
4649
keepnames: { type: "boolean", shortFlag: "k" },
4750
keepgroups: { type: "boolean", shortFlag: "K" },
51+
bones: { type: "boolean", shortFlag: "b", default: false },
4852
shadows: { type: "boolean", shortFlag: "s" },
4953
printwidth: { type: "number", shortFlag: "p", default: 120 },
5054
meta: { type: "boolean", shortFlag: "m" },
51-
precision: { type: "number", shortFlag: "p", default: 2 },
52-
isolated: { type: "boolean", shortFlag: "i", default: false },
55+
precision: { type: "number", shortFlag: "p", default: 3 },
5356
preload: { type: "boolean", shortFlag: "P", default: false },
5457
draco: { type: "string", shortFlag: "d" },
5558
root: { type: "string", shortFlag: "r" },
5659
transform: { type: "boolean", shortFlag: "T" },
5760
resolution: { type: "number", shortFlag: "R", default: 1024 },
61+
degrade: { type: "string", shortFlag: "q", default: "" },
62+
degraderesolution: { type: "number", shortFlag: "Q", default: 512 },
5863
simplify: { type: "boolean", shortFlag: "S", default: false },
59-
weld: { type: "number", default: 0.0001 },
64+
keepmeshes: { type: "boolean", shortFlag: "j", default: false },
65+
keepmaterials: { type: "boolean", shortFlag: "M", default: false },
6066
ratio: { type: "number", default: 0.75 },
6167
error: { type: "number", default: 0.001 },
6268
debug: { type: "boolean", shortFlag: "D" },
69+
format: { type: "string", shortFlag: "f", default: "webp" },
70+
console: { type: "boolean", shortFlag: "c" },
71+
72+
// instance: { type: "boolean", shortFlag: "i" },
73+
// instanceall: { type: "boolean", shortFlag: "I" },
6374
},
6475
},
6576
);
@@ -70,7 +81,8 @@ if (cli.input.length === 0) {
7081
console.log(cli.help);
7182
} else {
7283
const file = cli.input[0];
73-
let nameExt = file.match(/[-_\w]+[.]\w+$/i)[0];
84+
85+
let nameExt = file.match(/[-_\w\d\s]+[.][\w]+$/i)[0];
7486
let name = nameExt.split(".").slice(0, -1).join(".");
7587
let output = name + ".ts";
7688

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-three-gltf",
3-
"version": "1.0.17",
3+
"version": "1.1.0",
44
"description": "GLTF to Angular Three converter",
55
"scripts": {
66
"cleanup": "rimraf node_modules"
@@ -34,26 +34,27 @@
3434
"node": ">=18"
3535
},
3636
"dependencies": {
37-
"@gltf-transform/core": "^4.0.9",
38-
"@gltf-transform/extensions": "^4.0.9",
39-
"@gltf-transform/functions": "^4.0.9",
37+
"@gltf-transform/core": "^4.1.1",
38+
"@gltf-transform/extensions": "^4.1.1",
39+
"@gltf-transform/functions": "^4.1.1",
4040
"@node-loader/babel": "^2.1.0",
41-
"chalk": "^5.3.0",
41+
"chalk": "^5.4.1",
4242
"draco3dgltf": "^1.5.7",
43-
"fast-glob": "^3.3.2",
43+
"fast-glob": "^3.3.3",
4444
"fs-extra": "^11.2.0",
4545
"jsdom": "^25.0.1",
4646
"jsdom-global": "^3.0.2",
47+
"keyframe-resample": "^0.1.0",
4748
"meow": "^13.2.0",
48-
"meshoptimizer": "^0.21.0",
49-
"prettier": "^3.3.3",
49+
"meshoptimizer": "^0.22.0",
50+
"prettier": "^3.4.2",
5051
"read-pkg-up": "^11.0.0",
5152
"sharp": "^0.33.5",
5253
"three": "0.122.0",
53-
"three-stdlib": "^2.21.8"
54+
"three-stdlib": "^2.35.2"
5455
},
5556
"devDependencies": {
56-
"lint-staged": "^15.2.10",
57+
"lint-staged": "^15.3.0",
5758
"prettier-plugin-organize-imports": "^4.1.0",
5859
"rimraf": "^6.0.1",
5960
"simple-git-hooks": "^2.11.1"

src/bin/DRACOLoader.js

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
'use strict'
2-
import THREE from 'three'
1+
import * as THREE from 'three'
32
import draco from 'draco3dgltf'
3+
44
const decoder = draco.createDecoderModule()
5-
const DRACOLoader = (THREE.DRACOLoader = function (t) {
5+
const DRACOLoader = function (t) {
66
;(this.timeLoaded = 0),
77
(this.manager = t || THREE.DefaultLoadingManager),
88
(this.materials = null),
99
(this.verbosity = 0),
1010
(this.attributeOptions = {}),
1111
(this.drawMode = THREE.TrianglesDrawMode),
12-
(this.nativeAttributeMap = {
13-
position: 'POSITION',
14-
normal: 'NORMAL',
15-
color: 'COLOR',
16-
uv: 'TEX_COORD'
17-
})
18-
})
19-
20-
export default DRACOLoader
12+
(this.nativeAttributeMap = { position: 'POSITION', normal: 'NORMAL', color: 'COLOR', uv: 'TEX_COORD' })
13+
}
2114

22-
THREE.DRACOLoader.prototype = {
23-
constructor: THREE.DRACOLoader,
15+
DRACOLoader.prototype = {
16+
constructor: DRACOLoader,
2417
load: function (t, e, r, o) {
2518
var i = this,
2619
n = new THREE.FileLoader(i.manager)
@@ -128,8 +121,7 @@ THREE.DRACOLoader.prototype = {
128121
convertDracoGeometryTo3JS: function (t, e, r, o, i, n) {
129122
var a, s, u
130123
if (
131-
(!0 === this.getAttributeOptions('position').skipDequantization &&
132-
e.SkipAttributeTransform(t.POSITION),
124+
(!0 === this.getAttributeOptions('position').skipDequantization && e.SkipAttributeTransform(t.POSITION),
133125
r === t.TRIANGULAR_MESH
134126
? ((a = new t.Mesh()), (s = e.DecodeBufferToMesh(o, a)))
135127
: ((a = new t.PointCloud()), (s = e.DecodeBufferToPointCloud(o, a))),
@@ -141,8 +133,7 @@ THREE.DRACOLoader.prototype = {
141133
}
142134
t.destroy(o),
143135
r == t.TRIANGULAR_MESH
144-
? ((u = a.num_faces()),
145-
this.verbosity > 0 && console.log('Number of faces loaded: ' + u.toString()))
136+
? ((u = a.num_faces()), this.verbosity > 0 && console.log('Number of faces loaded: ' + u.toString()))
146137
: (u = 0)
147138
var A = a.num_points(),
148139
c = a.num_attributes()
@@ -187,18 +178,14 @@ THREE.DRACOLoader.prototype = {
187178
for (I = 0; I < u; ++I) {
188179
e.GetFaceFromMesh(a, I, D)
189180
var m = 3 * I
190-
;(f.indices[m] = D.GetValue(0)),
191-
(f.indices[m + 1] = D.GetValue(1)),
192-
(f.indices[m + 2] = D.GetValue(2))
181+
;(f.indices[m] = D.GetValue(0)), (f.indices[m + 1] = D.GetValue(1)), (f.indices[m + 2] = D.GetValue(2))
193182
}
194183
t.destroy(D)
195184
}
196185
;(y.drawMode = this.drawMode),
197186
r == t.TRIANGULAR_MESH &&
198187
y.setIndex(
199-
new (f.indices.length > 65535
200-
? THREE.Uint32BufferAttribute
201-
: THREE.Uint16BufferAttribute)(f.indices, 1)
188+
new (f.indices.length > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute)(f.indices, 1)
202189
)
203190
var G = new t.AttributeQuantizationTransform()
204191
if (G.InitFromAttribute(b)) {
@@ -214,9 +201,8 @@ THREE.DRACOLoader.prototype = {
214201
e(decoder.isVersionSupported(t))
215202
},
216203
getAttributeOptions: function (t) {
217-
return (
218-
void 0 === this.attributeOptions[t] && (this.attributeOptions[t] = {}),
219-
this.attributeOptions[t]
220-
)
221-
}
204+
return void 0 === this.attributeOptions[t] && (this.attributeOptions[t] = {}), this.attributeOptions[t]
205+
},
222206
}
207+
208+
export { DRACOLoader }

0 commit comments

Comments
 (0)