Three js 3D rotation

wuahi

I have 2 mesh objects. Anchor and Rod. The Anchor rotates around z-axis, as illustrated by the image. The rod is supposed to move only backward and forwards. Here is the image: http://imageshack.us/photo/my-images/841/7a83.png/.

But i am stuck with trying to figure out the matrix calculation. For example if the anchor rotates 45degrees, so its facing the x-axis, how can i make the rod still move backwards and forwards?

Troopers

For the rotation around z axis :

var rotation = new THREE.Matrix4().makeRotationZ(Math.PI/2);

For the translation, where z is your delta :

var translation = new THREE.Matrix4().makeTranslation(0, 0, z);

You can combine the two transformations in beginning with the translation :

var transformation = new THREE.Matrix4().makeTranslation(0, 0, z).makeRotationZ(Math.PI/2);

var transformation = rotation.multiply(translation);

Then apply transformation to your geometry :

geometry.applyMatrix(transformation);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Three.js - Rotation not respecting local orientation

来自分类Dev

three.js 3d模型作为超链接

来自分类Dev

Three.js中的多种3D声音

来自分类Dev

Three.js 3D文字弯曲

来自分类Dev

在THREE.js中绘制3d边界框

来自分类Dev

three.js以相同的视角显示3d对象

来自分类Dev

在Three.js中链接3d对象

来自分类Dev

从jsartoolkit和three.js创建3D环境

来自分类Dev

How to find rotation matrix between two vectors in THREE.js

来自分类Dev

如何使用three.js将3d框放置在另一个3d框内?

来自分类Dev

Three.js 3D球面看起来像2D

来自分类Dev

Three.js使用正交相机将2D映射到3D

来自分类Dev

使用three.js从2D旋转到3D

来自分类Dev

如何在three.js中从BufferGeometry绘制2D/3D网格

来自分类Dev

具有Three.js的Web音频可定位3D声音

来自分类Dev

在three.js中概述一个3d对象

来自分类Dev

Three.js-如何计算两个3D位置之间的距离?

来自分类Dev

初始加载时,在Three.JS Canvas中适合3D对象(Collada文件)

来自分类Dev

Three.js-创建不受缩放和平移影响的3D文本

来自分类Dev

无法使用three.js更改3D模型的颜色

来自分类Dev

如何使用three.js绘制自定义3d曲面?

来自分类Dev

使用THREE.js通过坐标自定义3D对象

来自分类Dev

如何在three.js中确定相机视场的3D边界

来自分类Dev

使用Three.js无法在Mapbox上加载3D模型

来自分类Dev

为什么three.js投射阴影无法在3D模型上运行

来自分类Dev

将SVG组转换为3D形状| 用Three.js增加厚度

来自分类Dev

如何在three.js中的3D对象上放置透明的颜色蒙版?

来自分类Dev

逐步“显示” Three.js中的3d对象-我这样做对吗?

来自分类Dev

3d法线贴图在Three.js中无法正常工作

Related 相关文章

热门标签

归档