@threlte/gltf 3.0.0-next.1 → 3.0.0-next.2

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/.prettierrc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "useTabs": false,
3
+ "singleQuote": true,
4
+ "trailingComma": "none",
5
+ "semi": false,
6
+ "printWidth": 100,
7
+ "plugins": ["prettier-plugin-svelte"],
8
+ "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
9
+ "singleAttributePerLine": true
10
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @threlte/gltf
2
2
 
3
+ ## 3.0.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 958c375: Fix T.Group parser error
8
+
3
9
  ## 3.0.0-next.1
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -116,9 +116,16 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb
116
116
  </script>
117
117
 
118
118
  {#if $gltf}
119
- <T is={ref} {...$$restProps}>
119
+ <T
120
+ is={ref}
121
+ {...$$restProps}
122
+ >
120
123
  <T.Group name="Scene">
121
- <T.Group name="Stacy" rotation={[Math.PI / 2, 0, 0]} scale={0.01}>
124
+ <T.Group
125
+ name="Stacy"
126
+ rotation={[Math.PI / 2, 0, 0]}
127
+ scale={0.01}
128
+ >
122
129
  <T is={$gltf.nodes.mixamorigHips} />
123
130
  <T.SkinnedMesh
124
131
  name="stacy"
@@ -166,7 +173,11 @@ You can re-use it, it will re-use geometries and materials out of the box:
166
173
  Or make the model dynamic. Change its colors for example:
167
174
 
168
175
  ```svelte
169
- <T.Mesh geometry={$gltf.nodes.robot.geometry} material={$gltf.materials.metal} material.color="green" />
176
+ <T.Mesh
177
+ geometry={$gltf.nodes.robot.geometry}
178
+ material={$gltf.materials.metal}
179
+ material.color="green"
180
+ />
170
181
  ```
171
182
 
172
183
  Or exchange materials:
@@ -181,7 +192,10 @@ Make contents conditional:
181
192
 
182
193
  ```svelte
183
194
  {#if condition}
184
- <T.Mesh geometry={$gltf.nodes.robot.geometry} material={$gltf.materials.metal} />}
195
+ <T.Mesh
196
+ geometry={$gltf.nodes.robot.geometry}
197
+ material={$gltf.materials.metal}
198
+ />}
185
199
  {/if}
186
200
  ```
187
201
 
@@ -193,7 +207,7 @@ You don't need to do anything if your models are draco compressed, since `useGlt
193
207
 
194
208
  #### ⚡️ Auto-transform (compression, resize)
195
209
 
196
- With the `--transform` flag it creates a binary-packed, draco-compressed, texture-resized (1024x1024), webp compressed, deduped, instanced and pruned *.glb ready to be consumed on a web site. It uses [glTF-Transform](https://github.com/donmccurdy/glTF-Transform). This can reduce the size of an asset by 70%-90%.
210
+ With the `--transform` flag it creates a binary-packed, draco-compressed, texture-resized (1024x1024), webp compressed, deduped, instanced and pruned \*.glb ready to be consumed on a web site. It uses [glTF-Transform](https://github.com/donmccurdy/glTF-Transform). This can reduce the size of an asset by 70%-90%.
197
211
 
198
212
  It will not alter the original but create a copy and append `[modelname]-transformed.glb`.
199
213
 
@@ -218,7 +232,16 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb -t
218
232
 
219
233
  export const ref = new Group()
220
234
 
221
- type ActionName = 'pockets' | 'rope' | 'swingdance' | 'jump' | 'react' | 'shrug' | 'wave' | 'golf' | 'idle'
235
+ type ActionName =
236
+ | 'pockets'
237
+ | 'rope'
238
+ | 'swingdance'
239
+ | 'jump'
240
+ | 'react'
241
+ | 'shrug'
242
+ | 'wave'
243
+ | 'golf'
244
+ | 'idle'
222
245
  type GLTFResult = {
223
246
  nodes: {
224
247
  stacy: THREE.SkinnedMesh
@@ -232,9 +255,16 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb -t
232
255
  </script>
233
256
 
234
257
  {#if $gltf}
235
- <T is={ref} {...$$restProps}>
258
+ <T
259
+ is={ref}
260
+ {...$$restProps}
261
+ >
236
262
  <T.Group name="Scene">
237
- <T.Group name="Stacy" rotation={[Math.PI / 2, 0, 0]} scale={0.01}>
263
+ <T.Group
264
+ name="Stacy"
265
+ rotation={[Math.PI / 2, 0, 0]}
266
+ scale={0.01}
267
+ >
238
268
  <T is={$gltf.nodes.mixamorigHips} />
239
269
  <T.SkinnedMesh
240
270
  name="stacy"
@@ -257,8 +287,7 @@ Command: npx gltfjsx@0.0.1 ./stacy.glb -t
257
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:
258
288
 
259
289
  ```svelte
260
- const gltf = useGltf('/stacy.glb')
261
- export const { actions, mixer } = useGltfAnimations(gltf, ref)
290
+ const gltf = useGltf('/stacy.glb') export const {(actions, mixer)} = useGltfAnimations(gltf, ref)
262
291
  ```
263
292
 
264
293
  If you want to play an animation you can do so at any time:
@@ -285,7 +314,6 @@ gltfLoader.load(url, (gltf) => {
285
314
  })
286
315
  ```
287
316
 
288
-
289
317
  ## Contributing
290
318
 
291
319
  Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threlte/gltf",
3
- "version": "3.0.0-next.1",
3
+ "version": "3.0.0-next.2",
4
4
  "description": "GLTF to Threlte converter",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -66,6 +66,8 @@
66
66
  ]
67
67
  },
68
68
  "scripts": {
69
- "cleanup": "rimraf node_modules"
69
+ "cleanup": "rimraf node_modules",
70
+ "lint": "prettier --check .",
71
+ "format": "prettier --write ."
70
72
  }
71
73
  }
@@ -1,4 +1,4 @@
1
1
  const THREE = (global.THREE = require('three'))
2
2
  require('../bin/GLTFLoader')
3
3
 
4
- module.exports = THREE.GLTFLoader
4
+ module.exports = THREE.GLTFLoader
@@ -474,10 +474,7 @@ function parse(fileName, gltf, options = {}) {
474
474
  const imports = `
475
475
  ${options.types ? `\nimport type * as THREE from 'three'` : ''}
476
476
  ${options.stype && !options.isolated ? `import type { Snippet } from 'svelte'` : ''}
477
- import { ${[
478
- 'T',
479
- options.types && !options.isolated ? 'type Props' : ''
480
- ]
477
+ import { ${['T', options.types && !options.isolated ? 'type Props' : '']
481
478
  .filter(Boolean)
482
479
  .join(', ')} } from '@threlte/core'
483
480
  import { ${[
@@ -536,12 +533,16 @@ ${
536
533
  error,
537
534
  children,
538
535
  ...props
539
- }${options.types && !options.isolated ? `: Props<THREE.Group> & {
536
+ }${
537
+ options.types && !options.isolated
538
+ ? `: Props<THREE.Group> & {
540
539
  ref?: THREE.Group
541
540
  children?: Snippet<[{ ref: THREE.Group }]>
542
541
  fallback?: Snippet
543
542
  error?: Snippet<[{ error: Error }]>
544
- }` : ''} = $props()
543
+ }`
544
+ : ''
545
+ } = $props()
545
546
 
546
547
  ${!options.preload && options.suspense ? 'const suspend = useSuspense()' : ''}
547
548
 
@@ -567,7 +568,7 @@ ${
567
568
  {/await}
568
569
 
569
570
  {@render children?.({ ref })}
570
- </T>
571
+ </T.Group>
571
572
  `
572
573
  }
573
574
 
@@ -1,5 +1,13 @@
1
1
  import { NodeIO } from '@gltf-transform/core'
2
- import { simplify, weld, dedup, resample, prune, textureCompress, draco } from '@gltf-transform/functions'
2
+ import {
3
+ simplify,
4
+ weld,
5
+ dedup,
6
+ resample,
7
+ prune,
8
+ textureCompress,
9
+ draco
10
+ } from '@gltf-transform/functions'
3
11
  import { ALL_EXTENSIONS } from '@gltf-transform/extensions'
4
12
  import { MeshoptDecoder, MeshoptEncoder, MeshoptSimplifier } from 'meshoptimizer'
5
13
  import draco3d from 'draco3dgltf'
@@ -12,7 +20,7 @@ async function transform(file, output, config = {}) {
12
20
  'draco3d.decoder': await draco3d.createDecoderModule(),
13
21
  'draco3d.encoder': await draco3d.createEncoderModule(),
14
22
  'meshopt.decoder': MeshoptDecoder,
15
- 'meshopt.encoder': MeshoptEncoder,
23
+ 'meshopt.encoder': MeshoptEncoder
16
24
  })
17
25
 
18
26
  const document = await io.read(file)
@@ -28,7 +36,7 @@ async function transform(file, output, config = {}) {
28
36
  // Resize and convert textures (using webp and sharp)
29
37
  textureCompress({ targetFormat: 'webp', encoder: sharp, resize: [resolution, resolution] }),
30
38
  // Add Draco compression.
31
- draco(),
39
+ draco()
32
40
  ]
33
41
 
34
42
  if (config.simplify) {
@@ -36,7 +44,11 @@ async function transform(file, output, config = {}) {
36
44
  // Weld vertices
37
45
  weld({ tolerance: config.weld ?? 0.0001 }),
38
46
  // Simplify meshes
39
- simplify({ simplifier: MeshoptSimplifier, ratio: config.ratio ?? 0.75, error: config.error ?? 0.001 })
47
+ simplify({
48
+ simplifier: MeshoptSimplifier,
49
+ ratio: config.ratio ?? 0.75,
50
+ error: config.error ?? 0.001
51
+ })
40
52
  )
41
53
  }
42
54