@threlte/gltf 0.0.5 → 1.0.0-next.0
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/package.json +1 -1
- package/readme.md +11 -11
- package/src/utils/parser.js +7 -7
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -58,20 +58,20 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb
|
|
|
58
58
|
-->
|
|
59
59
|
<script>
|
|
60
60
|
import { Group } from 'three'
|
|
61
|
-
import { T
|
|
61
|
+
import { T } from '@threlte/core'
|
|
62
62
|
import { useGltf, useGltfAnimations } from '@threlte/extras'
|
|
63
63
|
|
|
64
64
|
export const ref = new Group()
|
|
65
65
|
|
|
66
|
-
const
|
|
66
|
+
const gltf = useGltf('/stacy.glb')
|
|
67
67
|
export const { actions, mixer } = useGltfAnimations(gltf, ref)
|
|
68
68
|
</script>
|
|
69
69
|
|
|
70
70
|
{#if $gltf}
|
|
71
|
-
<
|
|
71
|
+
<T is={ref} {...$$restProps}>
|
|
72
72
|
<T.Group name="Scene">
|
|
73
73
|
<T.Group name="Stacy" rotation={[Math.PI / 2, 0, 0]} scale={0.01}>
|
|
74
|
-
<
|
|
74
|
+
<T is={$gltf.nodes.mixamorigHips} />
|
|
75
75
|
<T.SkinnedMesh
|
|
76
76
|
name="stacy"
|
|
77
77
|
geometry={$gltf.nodes.stacy.geometry}
|
|
@@ -84,7 +84,7 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb
|
|
|
84
84
|
</T.Group>
|
|
85
85
|
|
|
86
86
|
<slot {ref} />
|
|
87
|
-
</
|
|
87
|
+
</T>
|
|
88
88
|
{/if}
|
|
89
89
|
```
|
|
90
90
|
|
|
@@ -161,7 +161,7 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb -t
|
|
|
161
161
|
<script lang="ts">
|
|
162
162
|
import type * as THREE from 'three'
|
|
163
163
|
import { Group } from 'three'
|
|
164
|
-
import { T,
|
|
164
|
+
import { T, type Props, type Events, type Slots } from '@threlte/core'
|
|
165
165
|
import { useGltf, useGltfAnimations } from '@threlte/extras'
|
|
166
166
|
|
|
167
167
|
type $$Props = Props<THREE.Group>
|
|
@@ -179,15 +179,15 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb -t
|
|
|
179
179
|
materials: {}
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
const
|
|
182
|
+
const gltf = useGltf<GLTFResult>('/stacy.glb')
|
|
183
183
|
export const { actions, mixer } = useGltfAnimations<ActionName>(gltf, ref)
|
|
184
184
|
</script>
|
|
185
185
|
|
|
186
186
|
{#if $gltf}
|
|
187
|
-
<
|
|
187
|
+
<T is={ref} {...$$restProps}>
|
|
188
188
|
<T.Group name="Scene">
|
|
189
189
|
<T.Group name="Stacy" rotation={[Math.PI / 2, 0, 0]} scale={0.01}>
|
|
190
|
-
<
|
|
190
|
+
<T is={$gltf.nodes.mixamorigHips} />
|
|
191
191
|
<T.SkinnedMesh
|
|
192
192
|
name="stacy"
|
|
193
193
|
geometry={$gltf.nodes.stacy.geometry}
|
|
@@ -200,7 +200,7 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb -t
|
|
|
200
200
|
</T.Group>
|
|
201
201
|
|
|
202
202
|
<slot {ref} />
|
|
203
|
-
</
|
|
203
|
+
</T>
|
|
204
204
|
{/if}
|
|
205
205
|
```
|
|
206
206
|
|
|
@@ -209,7 +209,7 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb -t
|
|
|
209
209
|
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:
|
|
210
210
|
|
|
211
211
|
```svelte
|
|
212
|
-
const
|
|
212
|
+
const gltf = useGltf('/stacy.glb')
|
|
213
213
|
export const { actions, mixer } = useGltfAnimations(gltf, ref)
|
|
214
214
|
```
|
|
215
215
|
|
package/src/utils/parser.js
CHANGED
|
@@ -374,7 +374,7 @@ function parse(fileName, gltf, options = {}) {
|
|
|
374
374
|
|
|
375
375
|
// Bail out on lights and bones
|
|
376
376
|
if (type === 'bone') {
|
|
377
|
-
return `<
|
|
377
|
+
return `<T is={$gltf.${node}} />\n`
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
// Collect children
|
|
@@ -482,7 +482,7 @@ ${parseExtras(gltf.parser.json.asset && gltf.parser.json.asset.extras)}-->
|
|
|
482
482
|
|
|
483
483
|
${options.types ? `\nimport type * as THREE from 'three'` : ''}
|
|
484
484
|
import { Group } from 'three'
|
|
485
|
-
import { ${['T',
|
|
485
|
+
import { ${['T', options.types ? 'type Props, type Events, type Slots' : ''].join(
|
|
486
486
|
', '
|
|
487
487
|
)} } from '@threlte/core'
|
|
488
488
|
import { ${['useGltf', hasAnimations ? 'useGltfAnimations' : ''].join(
|
|
@@ -497,7 +497,7 @@ ${parseExtras(gltf.parser.json.asset && gltf.parser.json.asset.extras)}-->
|
|
|
497
497
|
|
|
498
498
|
${options.types ? printThrelteTypes(objects, animations) : ''}
|
|
499
499
|
|
|
500
|
-
const
|
|
500
|
+
const gltf = useGltf${options.types ? '<GLTFResult>' : ''}('${url}'${
|
|
501
501
|
useGltfOptions ? `, ${JSON.stringify(useGltfOptions)}` : ''
|
|
502
502
|
})
|
|
503
503
|
${
|
|
@@ -511,13 +511,13 @@ ${parseExtras(gltf.parser.json.asset && gltf.parser.json.asset.extras)}-->
|
|
|
511
511
|
</script>
|
|
512
512
|
|
|
513
513
|
{#if $gltf}
|
|
514
|
-
|
|
514
|
+
<T is={ref} {...$$restProps}>
|
|
515
515
|
${scene}
|
|
516
516
|
|
|
517
517
|
<slot {ref} />
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
518
|
+
</T>
|
|
519
|
+
{/if}
|
|
520
|
+
`
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
export default parse
|