Transparent objects in Threejs

Both your spheres are transparent, and are remaining so. What is happening is that the smaller sphere is not being rendered at all. Transparency in WebGL is tricky. You can google the issue to find out more about it. But you have stumbled upon an issue related to how three.js in particular handles transparency. The … Read more

Three.js – Width of view

You have to be precise here. You can calculate the visible rectangular region given the camera’s field-of-view, camera.fov, and a given distance, dist, from the camera. Since the object presumably has depth, you have to pick one plane through the mesh, and do the calculation at that distance. Here is how to calculate the visible … Read more

Three.js camera tilt up or down and keep horizon level

In three.js, an object’s orientation can be specified by its Euler rotation vector object.rotation. The three components of the rotation vector represent the rotation in radians around the object’s internal x-axis, y-axis, and z-axis respectively. The order in which the rotations are performed is specified by object.rotation.order. The default order is “XYZ” — rotation around … Read more

Three.js – Orthographic camera

The pattern for instantiating an orthographic camera in three.js is: var camera = new THREE.OrthographicCamera( width / – 2, width / 2, height / 2, height / – 2, near, far ); where width and height are the width and height of the camera’s cuboid-shaped frustum measured in world-space units. near and far are the … Read more

How to Fit Camera to Object

I am assuming you are using a perspective camera. You can set the camera’s position, field-of-view, or both. The following calculation is exact for an object that is a cube, so think in terms of the object’s bounding box, aligned to face the camera. If the camera is centered and viewing the cube head-on, define … Read more

How can I render an ‘atmosphere’ over a rendering of the Earth in Three.js?

Well an old and already answered question but I wanted to add my solution for beginner consideration out there. Have playing along Atmospheric scattering and GLSL for a long time and developed this VEEERRRYYY Simplified version of Atmospheric scattering (if animation stops refresh page or view the GIF in something more decend): [ planet is … Read more