@needle-tools/gltf-progressive 3.1.0 → 3.1.1

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
@@ -4,6 +4,10 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.1.1] - 2025-08-07
8
+ - Fix: Issue where compressed texture did loose LOD information ([issue](https://linear.app/needle/issue/NE-6669))
9
+ - Chore: Warn once if multi-mesh primitive is detected but compressed asset doesnt have densities per primitive, meaning an older compression pipeline version was used in processing this asset that would require an update for correct LOD updates
10
+
7
11
  ## [3.1.0] - 2025-08-06
8
12
  - Add: Queue to limit max concurrent LOD requests
9
13
  - Fix: Spread the skinned mesh bounds calculation over the available frames (defined by `skinnedMeshAutoUpdateBoundsInterval`)
package/README.md CHANGED
@@ -1,19 +1,21 @@
1
1
  # glTF progressive
2
2
 
3
- LODs on steroids for glTF, GLB or VRM files with density based loading for meshes or texture for any three.js based project.
3
+ Blazingly fast loading with lazy LODs for glTF, GLB or VRM files + smart density based LOD selection for meshes or texture for any three.js based project.
4
4
 
5
5
  ## Features
6
- - One line integration in any three.js based engine/project
7
- - Mesh LOD support
8
- - Texture LOD support
9
- - LOD levels are loaded on demand based on mesh screen density
10
- - Low poly LOD meshes can easily be used for raycasting for smooth interactions with high-poly meshes
11
- - Cloud generation and loading support via [cloud.needle.tools](https://cloud.needle.tools) for glTF, GLB & VRM assets
6
+ - [**Single line integration**](#usage) for any three.js project
7
+ - Mesh & Texture LOD support
8
+ - LOD levels are loaded lazily on demand based on **mesh screen density** instead of pure distance ensuring consistent and predictable quality
9
+ - Mobile [data-saving](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/saveData) support
10
+ - Automatically handles KTX2, WebP, Draco, Meshopt... for you
11
+ - Asset generation and loading support via [Needle Cloud](https://cloud.needle.tools) for glTF, GLB & VRM assets
12
+ - Faster raycasting thanks to low poly LOD meshes: smooth interactions with high-poly meshes
12
13
 
13
14
  ## Examples
14
15
 
15
16
  Examples are in the `/examples` directory. Live versions can be found in the links below.
16
17
 
18
+ - [Loading comparisons](https://stackblitz.com/edit/gltf-progressive-comparison?file=package.json,index.html)
17
19
  - [Vanilla three.js](https://engine.needle.tools/demos/gltf-progressive/threejs/) - multiple models and animations
18
20
  - [React Three Fiber](https://engine.needle.tools/demos/gltf-progressive/r3f/)
19
21
  - \<model-viewer\>
@@ -27,32 +29,33 @@ Examples are in the `/examples` directory. Live versions can be found in the lin
27
29
  - [Codesandbox](https://codesandbox.io/dashboard/sandboxes/gltf-progressive)
28
30
 
29
31
 
32
+ ## Videos
33
+ <a href="https://youtu.be/7EjL0BRfIp8" target="_blank">![Progressive glTF — comparison with traditional three.js optimization
34
+ ](https://engine.needle.tools/demos/gltf-progressive/video-comparison-throttled-thumbnail-1.webp)</a>
35
+ *Progressive glTF — comparison with traditional three.js optimization*
36
+
30
37
  <br/>
31
- <video width="320" controls autoplay src="https://engine.needle.tools/demos/gltf-progressive/video.mp4">
32
- <source src="https://engine.needle.tools/demos/gltf-progressive/video.mp4" type="video/mp4">
33
- </video>
34
38
 
39
+ # Usage
35
40
 
36
- ## Usage
41
+ ## three.js
37
42
 
38
- ### react three fiber
43
+ **gltf-progressive** works with any three.js project and should also work with any three.js version.
39
44
 
40
- Full example in `examples/react-three-fiber`
45
+ Full three.js example at: `examples/threejs`
41
46
 
42
47
  ```ts
43
- function MyModel() {
44
- const { gl } = useThree()
45
- const url = 'https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file'
46
- const { scene } = useGLTF(url, false, false, (loader) => {
47
- useNeedleProgressive(url, gl, loader as any)
48
- })
49
- return <primitive object={scene} />
50
- }
51
- ```
48
+ const gltfLoader = new GLTFLoader();
49
+ const url = "https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file";
52
50
 
53
- ### threejs (CDN, no bundler)
51
+ // register the progressive loader plugin
52
+ useNeedleProgressive(url, renderer, gltfLoader)
54
53
 
55
- The full example can be found at `examples/threejs`
54
+ // just call the load method as usual
55
+ gltfLoader.load(url, gltf => {
56
+ scene.add(gltf.scene)
57
+ })
58
+ ```
56
59
 
57
60
  ```html
58
61
  <head>
@@ -70,25 +73,25 @@ The full example can be found at `examples/threejs`
70
73
  </head>
71
74
  ```
72
75
 
73
- In your script:
74
- ```ts
75
- const gltfLoader = new GLTFLoader();
76
76
 
77
- const url = "https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file";
77
+ ## react three fiber
78
78
 
79
- // register the progressive loader plugin
80
- useNeedleProgressive(url, renderer, gltfLoader)
79
+ Full react-three-fiber example at: `examples/react-three-fiber`
81
80
 
82
- // just call the load method as usual
83
- gltfLoader.load(url, gltf => {
84
- scene.add(gltf.scene)
85
- })
81
+ ```ts
82
+ function MyModel() {
83
+ const { gl } = useThree()
84
+ const url = 'https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file'
85
+ const { scene } = useGLTF(url, false, false, (loader) => {
86
+ useNeedleProgressive(url, gl, loader as any)
87
+ })
88
+ return <primitive object={scene} />
89
+ }
86
90
  ```
87
91
 
92
+ ## google \<model-viewer\>
88
93
 
89
- ### \<model-viewer\>
90
-
91
- The example can be found in `examples/modelviewer.html`
94
+ Full model-viewer example at: `examples/modelviewer.html`
92
95
 
93
96
  ```html
94
97
  <head>
@@ -113,13 +116,39 @@ The example can be found in `examples/modelviewer.html`
113
116
  </body>
114
117
  ```
115
118
 
116
- ### Needle Engine
119
+ ## Needle Engine
117
120
 
118
121
  [Needle Engine](https://needle.tools) natively supports progressive loading of these glTF files! See [docs.needle.tools](https://docs.needle.tools) for more information.
119
122
 
120
123
 
121
- Use [cloud.needle.tools](https://cloud.needle.tools) to generate LODs for your assets now.
124
+ # Advanced
125
+
126
+ ### Add a LOD Manager plugin to receive callbacks per object
127
+ Create a new class extending `NEEDLE_progressive_plugin` and add your plugin by calling the static `LODSManager.addPlugin(<your_plugin_instance>)`
128
+
129
+ ### Wait for LODs being loaded
130
+ Call `lodsManager.awaitLoading(<opts?>)` to receive a promise that will resolve when all object LODs that start loading during the next frame have finished to update. Use the optional options parameter to e.g. wait for more frames.
131
+
132
+ ### Global LOD level override
133
+ Set the static `LODsManager.overrideGlobalLodLevel = <level>` to any number between 0 and 6. To disable the override again set it to `undefined`.
134
+
135
+ ### LOD Manager settings
136
+ These settings are available on the LOD manager instance:
137
+ - `targetTriangleDensity` - The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
138
+ - `skinnedMeshAutoUpdateBoundsInterval` - The interval in frames to automatically update the bounds of skinned meshes.
139
+ - `updateInterval` - The update interval in frames. If set to 0, the LODs will be updated every frame. If set to 2, the LODs will be updated every second frame, etc.
140
+ - `pause` - If set to true, the LODsManager will not update the LODs.
141
+ - `manual` - When set to true the LODsManager will not update the LODs. This can be used to manually update the LODs using the `update` method. Otherwise the LODs will be updated automatically when the renderer renders the scene.
142
+
143
+ ### Automatically use low-poly meshes for raycasting
144
+ Simply call `useRaycastMeshes(true)` to enable faster raycasting when using the the THREE.Raycaster. This can again be disabled by calling `useRaycastMeshes(false)`. Calling this method is only necessary once to enable it.
145
+
146
+ ### Get LOW poly meshes for physics simulation
147
+ Call `getRaycastMesh(<your_mesh_object>)`
148
+
122
149
 
150
+ # How can I generate assets for progressive loading
151
+ Use [Needle Cloud](https://cloud.needle.tools) to generate LODs for your assets (includes hosting, global CDN, password protection, versioning, CLI support...) or use one of the Needle integrations for Unity or Blender.
123
152
 
124
153
  # Contact ✒️
125
154
  <b>[🌵 needle — tools for creators](https://needle.tools)</b> •