适合OrthographicCamera到立方体

时间:2017-09-11 14:15:51

标签: javascript three.js orthographic

我有一个带有长方体和OrthographicCamera的three.js场景:

var scene = new THREE.Scene();

var aspect = canvas.width/canvas.height;
var size = 1000;

var camera = new THREE.OrthographicCamera(size * aspect / - 2, size * aspect / 2, size / 2, size / - 2, 1, 2000);

camera.position.x = -400;
camera.position.y = 200;
camera.position.z = 400;

camera.lookAt(new THREE.Vector3(0, 0, 0));

var box = new THREE.Mesh(
  new THREE.BoxGeometry(someWidth, someHeight, someDepth), 
  new THREE.MeshLambertMaterial({ color: 0xffffff })
);

scene.add(box);

长方体的大小和比例各不相同。如何从长方体中获取相机属性,使其整齐地放在相机视图的中心(所有边上都有一个小边距)?

0 个答案:

没有答案