@needle-tools/gltf-progressive 3.1.0 → 3.1.1-next.26e0b81

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,32 @@
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 for glTF, GLB or VRM files** + smart density based LOD selection for meshes or texture for any three.js based project.
4
+
5
+ ## Installation
6
+ `npm i @needle-tools/gltf-progressive`
7
+
8
+ ```ts
9
+ import { useNeedleProgressive } from "@needle-tools/gltf-progressive";
10
+
11
+ // Before loading with GLTFLoader
12
+ // call 'useNeedleProgressive' once to register the loader plugin
13
+ useNeedleProgressive("<asset_url>", webgl_renderer, gltf_loader)
14
+ ```
4
15
 
5
16
  ## 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
17
+ - [**Single line integration**](#usage) for any three.js project
18
+ - Mesh & Texture LOD support
19
+ - LOD levels are loaded lazily on demand based on **mesh screen density** instead of pure distance ensuring consistent and predictable quality
20
+ - Mobile [data-saving](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/saveData) support
21
+ - Automatically handles KTX2, WebP, Draco, Meshopt... for you
22
+ - Asset generation and loading support via [Needle Cloud](https://cloud.needle.tools) for glTF, GLB & VRM assets
23
+ - Faster raycasting thanks to low poly LOD meshes: smooth interactions with high-poly meshes
12
24
 
13
25
  ## Examples
14
26
 
15
27
  Examples are in the `/examples` directory. Live versions can be found in the links below.
16
28
 
29
+ - [Loading comparisons](https://stackblitz.com/edit/gltf-progressive-comparison?file=package.json,index.html)
17
30
  - [Vanilla three.js](https://engine.needle.tools/demos/gltf-progressive/threejs/) - multiple models and animations
18
31
  - [React Three Fiber](https://engine.needle.tools/demos/gltf-progressive/r3f/)
19
32
  - \<model-viewer\>
@@ -27,32 +40,33 @@ Examples are in the `/examples` directory. Live versions can be found in the lin
27
40
  - [Codesandbox](https://codesandbox.io/dashboard/sandboxes/gltf-progressive)
28
41
 
29
42
 
43
+ ## Videos
44
+ <a href="https://youtu.be/7EjL0BRfIp8" target="_blank">![Progressive glTF — comparison with traditional three.js optimization
45
+ ](https://engine.needle.tools/demos/gltf-progressive/video-comparison-throttled-thumbnail-1.webp)</a>
46
+ *Progressive glTF — comparison with traditional three.js optimization*
47
+
30
48
  <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
49
 
50
+ # Usage
35
51
 
36
- ## Usage
52
+ ## three.js
37
53
 
38
- ### react three fiber
54
+ **gltf-progressive** works with any three.js project and should also work with any three.js version.
39
55
 
40
- Full example in `examples/react-three-fiber`
56
+ Full three.js example at: `examples/threejs`
41
57
 
42
58
  ```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
- ```
59
+ const gltfLoader = new GLTFLoader();
60
+ const url = "https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file";
52
61
 
53
- ### threejs (CDN, no bundler)
62
+ // register the progressive loader plugin
63
+ useNeedleProgressive(url, renderer, gltfLoader)
54
64
 
55
- The full example can be found at `examples/threejs`
65
+ // just call the load method as usual
66
+ gltfLoader.load(url, gltf => {
67
+ scene.add(gltf.scene)
68
+ })
69
+ ```
56
70
 
57
71
  ```html
58
72
  <head>
@@ -70,25 +84,25 @@ The full example can be found at `examples/threejs`
70
84
  </head>
71
85
  ```
72
86
 
73
- In your script:
74
- ```ts
75
- const gltfLoader = new GLTFLoader();
76
87
 
77
- const url = "https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file";
88
+ ## react three fiber
78
89
 
79
- // register the progressive loader plugin
80
- useNeedleProgressive(url, renderer, gltfLoader)
90
+ Full react-three-fiber example at: `examples/react-three-fiber`
81
91
 
82
- // just call the load method as usual
83
- gltfLoader.load(url, gltf => {
84
- scene.add(gltf.scene)
85
- })
92
+ ```ts
93
+ function MyModel() {
94
+ const { gl } = useThree()
95
+ const url = 'https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file'
96
+ const { scene } = useGLTF(url, false, false, (loader) => {
97
+ useNeedleProgressive(url, gl, loader as any)
98
+ })
99
+ return <primitive object={scene} />
100
+ }
86
101
  ```
87
102
 
103
+ ## google \<model-viewer\>
88
104
 
89
- ### \<model-viewer\>
90
-
91
- The example can be found in `examples/modelviewer.html`
105
+ Full model-viewer example at: `examples/modelviewer.html`
92
106
 
93
107
  ```html
94
108
  <head>
@@ -113,13 +127,39 @@ The example can be found in `examples/modelviewer.html`
113
127
  </body>
114
128
  ```
115
129
 
116
- ### Needle Engine
130
+ ## Needle Engine
117
131
 
118
132
  [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
133
 
120
134
 
121
- Use [cloud.needle.tools](https://cloud.needle.tools) to generate LODs for your assets now.
135
+ # Advanced
136
+
137
+ ### Add a LOD Manager plugin to receive callbacks per object
138
+ Create a new class extending `NEEDLE_progressive_plugin` and add your plugin by calling the static `LODSManager.addPlugin(<your_plugin_instance>)`
139
+
140
+ ### Wait for LODs being loaded
141
+ 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.
142
+
143
+ ### Global LOD level override
144
+ Set the static `LODsManager.overrideGlobalLodLevel = <level>` to any number between 0 and 6. To disable the override again set it to `undefined`.
145
+
146
+ ### LOD Manager settings
147
+ These settings are available on the LOD manager instance:
148
+ - `targetTriangleDensity` - The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
149
+ - `skinnedMeshAutoUpdateBoundsInterval` - The interval in frames to automatically update the bounds of skinned meshes.
150
+ - `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.
151
+ - `pause` - If set to true, the LODsManager will not update the LODs.
152
+ - `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.
153
+
154
+ ### Automatically use low-poly meshes for raycasting
155
+ 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.
156
+
157
+ ### Get LOW poly meshes for physics simulation
158
+ Call `getRaycastMesh(<your_mesh_object>)`
159
+
122
160
 
161
+ # How can I generate assets for progressive loading
162
+ 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
163
 
124
164
  # Contact ✒️
125
165
  <b>[🌵 needle — tools for creators](https://needle.tools)</b> •