@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @threlte/gltf
2
2
 
3
+ ## 3.0.0-next.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 7a3281c: Split out gltf-related loaders into hooks for better tree shaking
8
+
3
9
  ## 3.0.0-next.5
4
10
 
5
11
  ### Patch Changes
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
- ```svelte
290
- const gltf = useGltf('/stacy.glb') export const {(actions, mixer)} = useGltfAnimations(gltf, ref)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threlte/gltf",
3
- "version": "3.0.0-next.5",
3
+ "version": "3.0.0-next.6",
4
4
  "description": "GLTF to Threlte converter",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -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 ? `, ${JSON.stringify(useGltfOptions)}` : ''})${
491
+ }('${url}'${useGltfOptions.draco ? `, { dracoLoader: useDraco(${typeof useGltfOptions.draco === 'string' ? `'${useGltfOptions.draco}'` : ''}) }` : ''})${
498
492
  options.suspense ? ')' : ''
499
493
  }`
500
494