0

我从 github 中找到了参考代码以及关于 stackoverflow 上的对象旋转的其他问题。

var vector = new THREE.Vector3( 1, 0, 0 );
        var axis = new THREE.Vector3( 1, 0, 0 ).normalize();
        var angle = Math.PI / 2;                

        function rotateAroundWorldAxis(object, axis, angle) {                                               
            var matrix = new THREE.Matrix4().makeRotationAxis( axis, angle );
            matrix.multiplyVector3( vector );
            object.matrix = matrix;
            object.rotation.setEulerFromRotationMatrix(object.matrix);
        }

        function render() {                     
            rotateAroundWorldAxis(tubeMesh, axis, angle);
            renderer.render( scene, camera );
        }

我无法弄清楚错误“未捕获的类型错误:无法读取未定义的属性‘x’”的原因。在谷歌浏览器中它显示为

  • 未捕获的类型错误:无法在three.min.js:56 处读取未定义的属性“x”
  • THREE.Matrix4.makeRotationAxis at three.min.js:56
  • 在 my_model.htm:290 处旋转环绕世界轴
  • 在 my_model.htm:297 处渲染
  • 动画

错误在第 1three.min.js行。56. 我正在使用three.js 库的r51。

4

1 回答 1

0

In case we had the same problem (three.js trying to read into the uv-mapping array) you can solve it by:

adding UV-mapping (in blender) to your model.
it basically entails:

  1. marking a seam on the object.
  2. unwrapping the model.
  3. exporting the model with UVs enabled.

for steps 1 and 2 you can follow this nice walk-through.
(NB: in addition to the steps in the article, in my version (2.59), I had to create a material and texture first.)

于 2013-08-21T08:33:32.077 回答