I'm trying to draw a rotating 3D coordinate system using Three.js. I want the axes to have some thickness, which so far I have accomplished using LineBasicMaterial's linewidth parameter.
The following code works for me since I am not on Windows:
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 triad = new THREE.Geometry();
triad.vertices.push( new THREE.Vector3( 0, 0, 0 ) );
triad.vertices.push( new THREE.Vector3( 10, 0, 0 ) );
triad.vertices.push( new THREE.Vector3( 0, 0, 0 ) );
triad.vertices.push( new THREE.Vector3( 0, 10, 0 ) );
triad.vertices.push( new THREE.Vector3( 0, 0, 0 ) );
triad.vertices.push( new THREE.Vector3( 0, 0, 10 ) );
var line_mat = new THREE.LineBasicMaterial({'linewidth': 3});
var frame = new THREE.Line(triad, line_mat, THREE.LinePieces);
scene.add( frame );
camera.position.z = 40;
function render() {
requestAnimationFrame(render);
frame.rotation.x += 0.1;
frame.rotation.y += 0.02;
renderer.render(scene, camera);
}
render();
Unfortunately, there is a limitation on linewidth on Windows due to the ANGLE library, see this question: Thickness of lines using THREE.LineBasicMaterial
What can I use as a workaround so that this displays correctly on Windows?
I got workaround for the width of the line. I created a new method and passed the coordinates where line is to be drawn. Then in your method , draw multiple lines around the coordinates. Here is the code :
Let me know if this doesnt work.
To run WebGL with native gl you have to install the OpenGL in your windows machine.
You have these options below:
--use-gl=desktop
command-line argument. As you can see in http://nuclear.mutantstargoat.com/webgl/about:config
and search for preferencewebgl.prefer-native-gl
and set totrue
. As you can see in "http://forums.mozillazine.org/viewtopic.php?f=23&t=2090351&start=15By using Angle the rendering is actually handled by DirectX. Switching to native gl can even lead to performance increase (depending on the OpenGL performance of your graphics card).
You can check the current "under the hood" WebGL settings of your browser using this website here . It also shows you if your browser is currently using angle for WebGL.
You can also check this website for detailed explanation of how to switch to native gl.