2

我有一个代码,在控制台的 three.js 中它说:

已弃用:Matrix4 的 .multiplyVector3() 已被删除。请改用 vector.applyMatrix4( matrix ) 或 vector.applyProjection( matrix )。

但我不知道该怎么做。

这是我的代码:

 var rotation_matrixc = new THREE.Matrix4();
 rotation_matrixc.extractRotation(CHROMEboyPC.matrix);
 var cam_vectorc = new THREE.Vector3(    100 ,  30 ,  5);
 var   final_cam_vectorc = rotation_matrixc.multiplyVector3(cam_vectorc);
 camera.position.copy(CHROMEboy.position ).add(final_cam_vectorc   );
 camera.lookAt(CHROMEboy.position);

如何使用建议的方法编写等效代码。

4

2 回答 2

6

您使用相反的符号:

使用向量 .applyMatrix3 或 .applyMatrix4 函数旋转向量

var final_cam_vectorc = cam_vectorc.applyMatrix4( rotation_matrixc );
于 2013-05-25T15:19:12.490 回答
0

要替换multiplyVector3,请简化follow 方法并稍微澄清前面的答案:

cameraOffset 是一个 Vector,包含相机相对于跟随的位置。

“玩家”是被跟踪的对象。您可能需要增加偏移量。

        var cameraOffset = new THREE.Vector3(0, 1, 2.5);

        // modify it relative to the followed object
        var new_cam_position = cameraOffset.applyMatrix4( player.matrix );

        // copy the new position vector to the camera
        camera.position.copy(new_cam_position);

        // look at
        camera.lookAt(player.position);
于 2018-12-17T22:07:36.233 回答