After successfully creating a rotating box, I attempted to change the material code to a wireframe material using linebasicmaterial in Three.js. Despite following examples and consulting the documentation, the rendered output remained plain white. I even adjusted the color hex value from the default white.
You can view the JS Fiddle example here.
// revolutions per second
var angularSpeed = 0.2;
var lastTime = 0;
// this function is executed on each animation frame
function animate(){
// update
var time = (new Date()).getTime();
var timeDiff = time - lastTime;
var angleChange = angularSpeed * timeDiff * 2 * Math.PI / 1000;
cube.rotation.y += angleChange;
lastTime = time;
// render
renderer.render(scene, camera);
// request new frame
requestAnimationFrame(function(){
animate();
});
}
// renderer
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// camera
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.z = 500;
// scene
var scene = new THREE.Scene();
// material
var mat = new THREE.LineaBasicMaterial({color: 0x00aeef});
// primary cube (little one)
var cube = new THREE.Mesh(new THREE.CubeGeometry(200, 200, 200), mat);
cube.overdraw = true;
cube.rotation.x = Math.PI * 0.1;
scene.add(cube);
// secondary cube (big one)
//var cube_big = new THREE.Mesh(new THREE.CubeGeometry(200,200,200), mat);
//cube_big.overdraw = true;
//cube_big.rotation.x = Math.PI * 0.1;
//scene.add(cube_big);
// add subtle ambient lighting
var ambientLight = new THREE.AmbientLight(0xbbbbbb);
scene.add(ambientLight);
// directional lighting
var directionalLight = new THREE.DirectionalLight(0xffffff);
directionalLight.position.set(1, 1, 1).normalize();
scene.add(directionalLight);
// start animation
animate();
While experimenting with JS Fiddle, I may have made an error when pasting the code. I simply copied it from my editor and omitted the HTML and head tags before pasting it into the script field. In my local setup, everything is combined in a single HTML file.