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

298
Vistas
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 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