three.js-网格组示例? (THREE.Object3D()高级) [英] three.js - mesh group example? (THREE.Object3D() advanced)

查看:818
本文介绍了three.js-网格组示例? (THREE.Object3D()高级)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解如何将子网格物体分组/链接到父网格物体.我希望能够:

I'm attempting to understand how to group / link child meshes to a parent. I want to be able to:

  • 拖动父项
  • 相对于父元素旋转子元素
  • 让父母轮换/翻译为孩子做正确的事

我唯一的背景是在《第二人生》中使用LSL操纵对象中的链接素数.我想我不想合并网格物体,因为我想保持对每个孩子的控制(悬停,纹理,旋转,缩放等).

My only background in this is using LSL in Second Life to manipulate linked prims in an object. I am thinking I dont want to merge meshes, because I want to maintain control (hover, texture, rotation, scaling, etc) over each child.

关于此的任何好的教程吗?这是通过THREE.Object3D()实现的,是吗?

Any good tutorials on this out there? This is achieved with THREE.Object3D(), yes?

谢谢,丹尼尔

推荐答案

拖动将更加棘手,因为您需要确定鼠标在屏幕上(屏幕空间)的x/y位置在哪里在3D世界中,则需要投射光线并检查其是否与要拖动的对象相交.我想这将是一个不同的问题.

The dragging will be a bit more tricky because you need to work out where would the x/y positions of the mouse on the screen (screen space) will be in the 3D world, then you will need to cast a ray and check if it intersects the object you want to drag. I presume this will be a different question.

设置对象层次结构非常简单. 正如您所暗示的,您将使用THREE.Object3D实例使用其 add()方法将对象嵌套到其中.这个想法是,您将对具有几何形状的对象和Object3D实例使用网格,只需在其中嵌套元素即可.我建议从 canvas_geometry_hierarchy 示例开始.

Setting object hierarchy is fairly simple. As you hinted, you will use a THREE.Object3D instance to nest objects into using it's add() method. The idea is that you will use a Mesh for objects that have geometry, and Object3D instances, where you simply need to nest elements. I suggest starting with the canvas_geometry_hierarchy sample.

有趣的是:

group = new THREE.Object3D();//create an empty container
group.add( mesh );//add a mesh with geometry to it
scene.add( group );//when done, add the group to the scene

这篇关于three.js-网格组示例? (THREE.Object3D()高级)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆