Tuve exactamente el mismo problema. Estaba tratando de crear un HUD (pantalla Head-up) sin DOM y terminé creando esta solución:
- Creé una escena separada con una cámara ortográfica.
- Creé un elemento de lienzo y utilicé primitivas de dibujo 2D para representar mis gráficos.
- Luego creé un plano que se adapta a toda la pantalla y utilicé un elemento de lienzo 2D como textura.
- I emitió esa escena secundaria en la parte superior de la escena original
Así es como se ve el código HUD como:
// We will use 2D canvas element to render our HUD.
var hudCanvas = document.createElement('canvas');
// Again, set dimensions to fit the screen.
hudCanvas.width = width;
hudCanvas.height = height;
// Get 2D context and draw something supercool.
var hudBitmap = hudCanvas.getContext('2d');
hudBitmap.font = "Normal 40px Arial";
hudBitmap.textAlign = 'center';
hudBitmap.fillStyle = "rgba(245,245,245,0.75)";
hudBitmap.fillText('Initializing...', width/2, height/2);
// Create the camera and set the viewport to match the screen dimensions.
var cameraHUD = new THREE.OrthographicCamera(-width/2, width/2, height/2, -height/2, 0, 30);
// Create also a custom scene for HUD.
sceneHUD = new THREE.Scene();
// Create texture from rendered graphics.
var hudTexture = new THREE.Texture(hudCanvas)
hudTexture.needsUpdate = true;
// Create HUD material.
var material = new THREE.MeshBasicMaterial({map: hudTexture});
material.transparent = true;
// Create plane to render the HUD. This plane fill the whole screen.
var planeGeometry = new THREE.PlaneGeometry(width, height);
var plane = new THREE.Mesh(planeGeometry, material);
sceneHUD.add(plane);
Y eso es lo que he añadido a mi bucle de render:
// Render HUD on top of the scene.
renderer.render(sceneHUD, cameraHUD);
Puede jugar con el código fuente completo aquí: http://codepen.io/jaamo/pen/MaOGZV
y leer más acerca de la aplicación en mi blog: http://www.evermade.fi/pure-three-js-hud/
Brandon Jones tiene una buena demostración de elementos de HUD hechos de divs: http://media.tojicode.com/webgl-samples/hud-test.html – Anton
También eche un vistazo a este hilo: https://github.com/mrdoob/three.js/issues/1959 – WestLangley
gracias chicos, estos son realmente útiles – Dev