🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@needle-tools/gltf-progressive

Package Overview
Dependencies
Maintainers
2
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@needle-tools/gltf-progressive

three.js support for loading glTF or GLB files that contain progressive loading data

latest
stable
Source
npmnpm
Version
3.3.5
Version published
Weekly downloads
274
-19.88%
Maintainers
2
Weekly downloads
 
Created
Source

glTF progressive

Blazingly fast loading for glTF, GLB or VRM files + smart density based LOD selection for meshes or texture for any three.js based project.

Installation

npm i @needle-tools/gltf-progressive

import { useNeedleProgressive } from "@needle-tools/gltf-progressive";

// Before loading with GLTFLoader   
// call 'useNeedleProgressive' once to register the loader plugin
useNeedleProgressive(gltf_loader, webgl_renderer)

Features

  • Single line integration for any three.js project
  • Mesh & Texture LOD support
    • LOD levels are loaded lazily on demand based on mesh screen density instead of pure distance ensuring consistent and predictable quality
  • Mobile data-saving support
  • Automatically handles KTX2, WebP, Draco, Meshopt... for you
  • Asset generation and loading support via Needle Cloud for glTF, GLB & VRM assets
  • Faster raycasting thanks to low poly LOD meshes: smooth interactions with high-poly meshes

Examples

Examples are in the /examples directory. Live versions can be found in the links below.

Interactive Examples:

Usage

three.js

gltf-progressive works with any three.js project and should also work with any three.js version.

Full three.js example at: examples/threejs

const gltfLoader = new GLTFLoader();
const url = "https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file";

// register the progressive loader plugin
useNeedleProgressive(gltfLoader, renderer)

// just call the load method as usual
gltfLoader.load(url, gltf => {
    scene.add(gltf.scene)
})
<head>
    <!-- Add the threejs import map to your HTML head section -->
    <script type="importmap">
    {
        "imports": {
            "three": "https://cdn.jsdelivr.net/npm/three@latest/build/three.module.js",
            "three/addons/": "https://cdn.jsdelivr.net/npm/three@latest/examples/jsm/",
            "three/examples/": "https://cdn.jsdelivr.net/npm/three@latest/examples/",
            "@needle-tools/gltf-progressive": "https://cdn.jsdelivr.net/npm/@needle-tools/gltf-progressive/gltf-progressive.min.js"
        }
    }
    </script>
</head>

react three fiber

Full react-three-fiber example at: examples/react-three-fiber

function MyModel() {
  const { gl } = useThree()
  const url = 'https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file'
  const { scene } = useGLTF(url, false, false, (loader) => {
    useNeedleProgressive(loader as any, gl as any)
  })
  return <primitive object={scene} />
}

google <model-viewer>

Full model-viewer example at: examples/modelviewer.html

<head>
    <!-- Include threejs import map -->
    <script type="importmap">
        {
            "imports": {
                "three": "https://unpkg.com/three/build/three.module.js",
                "three/": "https://unpkg.com/three/"
            }
        }
    </script>
    <!-- Include gltf-progressive -->
    <script type="module" src="https://cdn.jsdelivr.net/npm/@needle-tools/gltf-progressive/gltf-progressive.min.js"></script>
    <!-- Include model-viewer -->
    <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.4.0/model-viewer.min.js"></script>
</head>
<body>

    <model-viewer src="https://cloud.needle.tools/-/assets/Z23hmXBZN45qJ-ZN45qJ-world/file" camera-controls auto-rotate></model-viewer>
    
</body>

Needle Engine

Needle Engine natively supports progressive loading of these glTF files! See docs.needle.tools for more information.

How can I generate assets for progressive loading

Use Needle Cloud 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.

Advanced

Add a LOD Manager plugin to receive callbacks per object

Create a new class extending NEEDLE_progressive_plugin and add your plugin by calling the static LODSManager.addPlugin(<your_plugin_instance>)

Wait for LODs being loaded

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.

Global LOD level override

LOD Manager settings

These settings are available on the LOD manager instance:

  • targetTriangleDensity - The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
  • skinnedMeshAutoUpdateBoundsInterval - The interval in frames to automatically update the bounds of skinned meshes.
  • 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.
  • pause - If set to true, the LODsManager will not update the LODs.
  • 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.
  • overrideLodLevel - Can be set to any number between 0 and 6 to override the lod level to be loaded. To disable the override again set it to undefined.

Automatically use low-poly meshes for raycasting

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.

Get LOW poly meshes for physics simulation

Call getRaycastMesh(<your_mesh_object>)

Extension

Read more about the NEEDLE_progressive extension

Contact ✒️

🌵 needle — tools for creators • Twitter • Discord • Forum

Keywords

three.js

FAQs

Package last updated on 08 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts