Load remote model

Is there any detail documentation on Load remote external models? I can’t find it on the website or forum

Hi Saad Baig,

For loading remote external models in Needle Engine, you can refer to the XRControllerModel class, which provides methods for loading models dynamically. Here’s a summarized explanation:

  1. Custom Model Loading: You can assign a model or model URL by using customLeftHand and customRightHand properties.

  2. Dynamic Loading Method: The core method for loading a model is loadModel(controller: NeedleXRController, url: string). This function fetches the model via the provided URL and adds it to the scene.

  3. GLTF Support: The GLTFLoader is utilized to support GLTF models, which are fetched from external URLs. Multiple loaders such as Draco and KTX2 can be registered for compression.

  4. Integration: You can instantiate models and attach them to the scene by asynchronously fetching the GLTF data.

If you need a code reference or more details, you may want to also check the samples for model loading available in the documentation and GitHub repository.

For example, here is a simple implementation to load an external model:

import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';

async function loadExternalModel(url: string) {
    const loader = new GLTFLoader();
    return new Promise((resolve, reject) => {
        loader.load(
            url,
            (gltf) => {
                // Process the loaded model (gltf.scene) here
                resolve(gltf.scene);
            },
            undefined,
            (error) => {
                console.error("Error loading model:", error);
                reject(error);
            }
        );
    });
}

For more resources, you could check Needle Engine Samples and the Needle Engine Documentation.

Please let me know if you have further questions or need additional clarifications!

3 replies left
thread_54F08cDpCGEQsceEsaYxyqJy
Reply to this message to continue the conversation

Hi Saad

See the sample External Content | Needle Engine - sample code

It’s basically:

const assetReference = AssetReference.getOrCreateFromUrl(<url>);
const instance = await assetReference.instantiate(); 

Here are also a few examples: Scripting Examples | Needle Engine Documentation

Also: Needle Engine - Load glb - StackBlitz

This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.