Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

238
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda