3D animation is a realm filled with numerous terms and concepts that are unfamiliar to me. I am particularly confused about the significance of "UV" in 3D rendering and the tools used for mapping pixels onto a mesh.
I have an image captured by a 360-degree camera, which I intend to use as the texture for a sphere. However, I want the center of this image to represent the top of the sphere, with the circular radius translating into an arc along the surface from top to bottom.
Starting with code snippets borrowed directly from Three.JS documentation:
var video = document.getElementById( "texture-video" );
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var texture = new THREE.VideoTexture( video );
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.format = THREE.RGBFormat;
var material = new THREE.MeshBasicMaterial( { map: texture } );
var geometry = new THREE.SphereGeometry(0.5, 100, 100);
var mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
camera.position.z = 1
function animate()
{
mesh.rotation.y += 0.01;
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
animate();
The output result exhibits some issues:
The texture orientation needs correction (rotated 90 degrees)The ground seems distorted, potentially linked to the rotation issue?- Update: Further examination reveals that the image aligns properly with the sphere when considering its top and bottom poles; however, the edges create a distorted effect resembling sideways ground textures
- The current setup places the image on the outside of the sphere, but my goal is to project it onto the inside while positioning the camera within the sphere
Placing the camera inside results in a solid black display. As per Three.JS guidelines, lighting should not be required with a MeshBasicMaterial
. The likely problem could stem from outward-facing normals on the sphere's faces, suggesting a need for reversal akin to skybox implementations that I'm unsure how to execute.
Research indicates that adjusting the "UV"s may solve this issue, although the method and implication remain unclear...