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

297
Visualizações
Parts of large ring do not render in three.js

I want to create a sun surrounded with a large ring or orbit in three.js. Here is my source code (using require.js modules):

require(['js/interactive.js', 'js/OrbitControls.js', 'js/three.min.js'], function (InteractionManager, OrbitControls, THREE) {
    const ZOOM = 300;

    const scene = new THREE.Scene();
    const camera = new THREE.OrthographicCamera(window.innerWidth / -ZOOM, window.innerWidth / ZOOM, window.innerHeight / ZOOM, window.innerHeight / - ZOOM, 1, 1000);

    const renderer = new THREE.WebGLRenderer({ preserveDrawingBuffer: true });
    renderer.setSize(window.innerWidth, window.innerHeight);
    // renderer.setClearColorHex( 0x555555, 1 );
    document.body.appendChild(renderer.domElement);


    // new a interaction, then you can add interaction-event with your free style
    const interaction = new InteractionManager(renderer, camera, renderer.domElement);
    const loader = new THREE.TextureLoader();
    const controls = new OrbitControls(camera, renderer.domElement);

    const light = new THREE.AmbientLight(0xffffff); // soft white light
    scene.add(light);

    // const light2 = new THREE.PointLight(0xffffff); // soft white light
    // light2.position.set(10, 0, 0);
    // scene.add(light2);

    const geometry = new THREE.SphereGeometry(1, 32, 32);
    const material = new THREE.MeshPhongMaterial({
        map: loader.load('./resources/2k_sun.jpeg'),
        specular: 0x555555,
        shininess: 50
    });

    const sun = new THREE.Mesh(geometry, material);
    scene.add(sun);
    interaction.add(sun);

    sun.addEventListener('click', function(ev) {
        var bb = new THREE.Box3()
        bb.setFromObject(sun);
        bb.getCenter(controls.target);

        camera.zoom = 1;
        camera.updateProjectionMatrix();
    });

    const ringGeometry = new THREE.RingGeometry(50, 51, 32);
    const ringMaterial = new THREE.MeshBasicMaterial( { color: 0x808080, side: THREE.DoubleSide } );
    const ring = new THREE.Mesh( ringGeometry, ringMaterial );
    scene.add( ring );

    camera.position.set(0, 0, 5);
    controls.update();

    const animate = function () {
        requestAnimationFrame(animate);

        sun.rotation.x += 0.01;
        sun.rotation.y += 0.01;

        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.render(scene, camera);
    };

    animate();
})

interactive.js is an interaction library I downloaded from here. I used it to zoom in on the sun when it's clicked.

However, when I run this code, parts of the ring will not render at certain angles. This is only fixed if I make the ring much smaller. Below is a screenshot of this behavior: parts of the ring will not render at certain angles

My question: How can I make this ring fully visible at any angle and maintain the large size?

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