Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@needle-tools/gltf-progressive

Package Overview
Dependencies
Maintainers
0
Versions
62
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

  • 1.2.15
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
358
decreased by-26.49%
Maintainers
0
Weekly downloads
 
Created
Source

glTF progressive

LODs on steroids for glTF, GLB or VRM files with density based loading for meshes or texture for any three.js based project.

Features

  • One line integration in any three.js based engine/project
  • Mesh LOD support
  • Texture LOD support
  • LOD levels are loaded on demand based on mesh screen density
  • Low poly LOD meshes can easily be used for raycasting for smooth interactions with high-poly meshes
  • Cloud generation and loading support via cloud.needle.tools for glTF, GLB & VRM assets

Examples

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

Interactive Examples:


Usage

react three fiber

Full example in examples/react-three-fiber

function ChurchModel() {
  const { gl } = useThree()
  const url = 'https://engine.needle.tools/demos/gltf-progressive/assets/church/model.glb'
  const { scene } = useGLTF(url, false, false, (loader) => {
    useNeedleProgressive(url, gl, loader as any)
  })
  return <primitive object={scene} />
}

threejs (CDN, no bundler)

The full example can be found at examples/threejs

<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-engine/gltf-progressive": "https://www.unpkg.com/@needle-tools/gltf-progressive@latest"
        }
    }
    </script>
</head>

In your script:

const gltfLoader = new GLTFLoader();

const url = "https://engine.needle.tools/demos/gltf-progressive/assets/church/model.glb";

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

// just call the load method as usual
gltfLoader.load(url, gltf => {
    console.log(gltf)
    scene.add(gltf.scene)
    gltf.scene.position.y += .95;
})

<model-viewer>

The example can be found in 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://www.unpkg.com/@needle-tools/gltf-progressive@latest"></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://engine.needle.tools/demos/gltf-progressive/assets/church/model.glb" 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.

Use cloud.needle.tools to generate LODs for your assets now.

Contact ✒️

🌵 needle — tools for creatorsTwitterDiscordForum

Keywords

FAQs

Package last updated on 21 Oct 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc