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

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