0

我正在尝试在我的常规相机顶部设置一个正交相机以用作平视显示器。我似乎无法显示任何文本,这是我的代码:

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;
...
4

1 回答 1

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);

当我没有改变它的位置时,正交相机对我来说效果最好,也许尝试不同的位置和旋转。您还可以使用轨道控制,这样您就可以使用这些值。

于 2014-05-28T12:37:11.090 回答