相关疑难解决方法(0)

如何在轴three.js上旋转3D对象?

我有一个很好的关于旋转的问题.我希望在我的一个游戏中旋转我的3D立方体.

//init
geometry = new THREE.CubeGeometry grid, grid, grid
material = new THREE.MeshLambertMaterial {color:0xFFFFFF * Math.random(), shading:THREE.FlatShading, overdraw:true, transparent: true, opacity:0.8}
for i in [1...@shape.length]
    othergeo = new THREE.Mesh new THREE.CubeGeometry(grid, grid, grid)
    othergeo.position.x = grid * @shape[i][0]
    othergeo.position.y = grid * @shape[i][1]
    THREE.GeometryUtils.merge geometry, othergeo
@mesh = new THREE.Mesh geometry, material

//rotate
@mesh.rotation.y += y * Math.PI / 180
@mesh.rotation.x += x * Math.PI / 180
@mesh.rotation.z += z * Math.PI / 180
Run Code Online (Sandbox Code Playgroud)

和(x,y,z)可以是(1,0,0)

然后立方体可以旋转,但问题是立方体在其自己的轴上旋转,因此在旋转后,它不能按预期旋转.

我找到页面如何围绕轴旋转Three.js Vector3?,但它只是让Vector3点围绕世界轴旋转? …

javascript coffeescript three.js

34
推荐指数
6
解决办法
11万
查看次数

标签 统计

coffeescript ×1

javascript ×1

three.js ×1