@threlte/gltf 3.0.0-next.5 → 3.0.0-next.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 +6 -0
- package/README.md +4 -2
- package/package.json +1 -1
- package/src/utils/parser.js +6 -12
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -286,8 +286,10 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb -t
|
|
|
286
286
|
|
|
287
287
|
If your GLTF contains animations it will add [@threlte/extras's `useGltfAnimations`](https://threlte.xyz/extras/use-gltf-animations) hook, which extracts all clips and prepares them as actions:
|
|
288
288
|
|
|
289
|
-
```
|
|
290
|
-
const gltf = useGltf('/stacy.glb')
|
|
289
|
+
```ts
|
|
290
|
+
const gltf = useGltf('/stacy.glb')
|
|
291
|
+
|
|
292
|
+
export const {(actions, mixer)} = useGltfAnimations(gltf, ref)
|
|
291
293
|
```
|
|
292
294
|
|
|
293
295
|
If you want to play an animation you can do so at any time:
|
package/package.json
CHANGED
package/src/utils/parser.js
CHANGED
|
@@ -466,16 +466,9 @@ function parse(fileName, gltf, options = {}) {
|
|
|
466
466
|
// 2nd pass to eliminate hard to swat left-overs
|
|
467
467
|
const scene = printThrelte(gltf.scene)
|
|
468
468
|
|
|
469
|
-
const useGltfOptions =
|
|
470
|
-
options.transform && options.draco
|
|
471
|
-
|
|
472
|
-
useDraco: options.draco
|
|
473
|
-
}
|
|
474
|
-
: options.transform
|
|
475
|
-
? {
|
|
476
|
-
useDraco: true
|
|
477
|
-
}
|
|
478
|
-
: undefined
|
|
469
|
+
const useGltfOptions = {
|
|
470
|
+
draco: options.transform && options.draco ? (options.draco ? options.transform : true) : false
|
|
471
|
+
}
|
|
479
472
|
|
|
480
473
|
const imports = `
|
|
481
474
|
${options.types ? `\nimport type * as THREE from 'three'` : ''}
|
|
@@ -486,7 +479,8 @@ function parse(fileName, gltf, options = {}) {
|
|
|
486
479
|
import { ${[
|
|
487
480
|
'useGltf',
|
|
488
481
|
hasAnimations ? 'useGltfAnimations' : '',
|
|
489
|
-
options.suspense ? 'useSuspense' : ''
|
|
482
|
+
options.suspense ? 'useSuspense' : '',
|
|
483
|
+
useGltfOptions.draco ? 'useDraco' : ''
|
|
490
484
|
]
|
|
491
485
|
.filter(Boolean)
|
|
492
486
|
.join(', ')} } from '@threlte/extras'
|
|
@@ -494,7 +488,7 @@ function parse(fileName, gltf, options = {}) {
|
|
|
494
488
|
|
|
495
489
|
const useGltf = `${options.suspense ? 'suspend(' : ''}useGltf${
|
|
496
490
|
options.types ? '<GLTFResult>' : ''
|
|
497
|
-
}('${url}'${useGltfOptions ? `, ${
|
|
491
|
+
}('${url}'${useGltfOptions.draco ? `, { dracoLoader: useDraco(${typeof useGltfOptions.draco === 'string' ? `'${useGltfOptions.draco}'` : ''}) }` : ''})${
|
|
498
492
|
options.suspense ? ')' : ''
|
|
499
493
|
}`
|
|
500
494
|
|