Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda