Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
Export gltf model with Instancedmesh

I tried to export a cube of spheres create with the following code using instancedmesh as gltf model but upon importing it in blender it only shows one sphere (the original sphere). is there any way to export the instances as well and import the whole scene in blender as it is in threejs?

let scene, camera, renderer;
let wrapper, canvas;
function createWorld() {
    renderer.setClearColor(0x808080);
    scene = new THREE.Scene();
    camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 10000);
    camera.position.z = 30;
    let light = new THREE.DirectionalLight(0xffffff, 0.8);
    light.position.set(0, 0, 1);
    camera.add(light);
    scene.add(camera);
    scene.add(new THREE.AmbientLight(0x303030));
    const material = new THREE.MeshLambertMaterial();
    const geometry = new THREE.SphereGeometry(0.45, 32, 16);
    const count = 11 * 11 * 11;
    let object = new THREE.InstancedMesh(geometry, material, count);
    let matrix = new THREE.Matrix4();
    let color = new THREE.Color();
    let i = 0;
    for (let z = -5; z <= 5; z++)
        for (let y = -5; y <= 5; y++)
            for (let x = -5; x <= 5; x++) {
                color.r = (x + 5) / 10;
                color.g = (y + 5) / 10;
                color.b = 1 - (z + 5) / 10;
                object.setColorAt(i, color);
                matrix.makeTranslation(x, y, z);
                object.setMatrixAt(i++, matrix);
            }
    scene.add(object);
}

function render() {
    renderer.render(scene, camera);
}

function init() {
    try {
        renderer = new THREE.WebGLRenderer({
            canvas,
            antialias: true,
        });
        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.setPixelRatio(window.devicePixelRatio);
        renderer.toneMapping = THREE.ACESFilmicToneMapping;
        renderer.toneMappingExposure = 1;
        renderer.outputEncoding = THREE.sRGBEncoding;
    } catch (e) {
        wrapper.innerHTML = '<h3><b>Sorry, WebGL2 is required but is not available.</b><h3>';
        return;
    }

    createWorld();

    let controls = new OrbitControls(camera, renderer.domElement);
    controls.enablePan = false;
    controls.enableZoom = false;
    controls.addEventListener('change', render);

    render();
}

init();
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!