我试图在普通相机上设置正交相机,用作抬头显示器。我似乎无法显示任何文字,这是我的代码:
function createHUD()
{
var width = window.innerWidth;
var height = window.innerHeight;
cameraOrtho = new THREE.OrthographicCamera(-width/2, width/2, height/2, -height/2, -10, 10);
cameraOrtho.position.z = 10;
sceneHUD = new THREE.Scene();
var textGeometry = new THREE.TextGeometry("hello world", {size: 20});
var textMaterial = new THREE.MeshBasicMaterial({color: 0xff0000});
var textMesh = new THREE.Mesh(textGeometry, textMaterial);
sceneHUD.add(textMesh);
}
function render()
{
renderer.render(scene, camera);
renderer.render(sceneHUD, cameraOrtho);
}
function init()
{
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x0088FF, 1);
renderer.autoClear = false;
document.body.appendChild(renderer.domElement);
createHUD();
camera.position.z += 5;
camera.position.y += 1;
...
答案 0 :(得分:2)
尝试使用lookAt功能将文本旋转90°到相机:
var textMesh = new THREE.Mesh(textGeometry, textMaterial);
textMesh.lookAt(cameraOrtho.position); // Rotate the mesh so the face is fully visible by the camera
sceneHUD.add(textMesh);
当我没有改变它的位置时,ortographic相机最适合我,也许尝试不同的位置和旋转。您也可以使用轨道控制,这样您就可以使用值。