2
我正嘗試在簡單的three.js場景中手動設置相機的矩陣。我已經嘗試將matrix.set方法與matrixAutoUpdate = false結合使用,但是儘管場景最初呈現的不會像我期望的那樣隨時間而改變。我也嘗試用camera.matrix =設置矩陣,結果相同。讓我覺得我錯過了一些關於如何讓對象'接受'手動設置的值。我也嘗試了applyMatrix,但似乎完全是做了其他事情。在ThreeJS中手動設置相機矩陣
任何意見非常感謝 - 謝謝!
下面的代碼在行動筆:
http://codepen.io/heyscam/pen/phflL
而這裏僅僅是JS:
var WIDTH = 640;
var HEIGHT = 360;
var VIEW_ANGLE = 31.417;
var ASPECT = WIDTH/HEIGHT;
var NEAR = 0.1;
var FAR = 10000;
var $container = $('#container');
console.log($container);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(WIDTH, HEIGHT);
$container.append(renderer.domElement);
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
VIEW_ANGLE,
ASPECT,
NEAR,
FAR
);
scene.add(camera);
var cube = new THREE.Mesh(
new THREE.CubeGeometry(200, 200, 200)
);
scene.add(cube);
var frame = 0;
animate();
function animate() {
camera.matrixAutoUpdate = false;
camera.matrix.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 500 + (frame * 10), 0, 0, 0, 1);
render();
frame++;
requestAnimationFrame(animate);
}
function render() {
renderer.render(scene, camera);
}