如何在 Three.js 中单独访问每个元素

发布于 2025-01-01 20:41:17 字数 128 浏览 2 评论 0原文

我已经使用 Three.js 创建了网格并渲染了“10”个 3D 对象?

如何访问每个对象以执行缩放、旋转和缩放所有的东西,所以有一个 需要单独获取div对象吗?

帮我解决这个问题吗?

谢谢 !

I have created mesh and rendered " 10 " 3d objects using three.js?

how to access each object to perform scaling , rotation & all stuffs so there is a
need to get the div object individually?

help me to solve this issue ?

thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

和影子一齐双人舞 2025-01-08 20:41:17

你似乎没有问一个真正的问题。而是要求某人教你一些东西。在“启动代码”中,SphereGeometry 对象与 MeshBasicMaterial 对象组合,以创建 Mesh 对象,该对象是您的 3D 对象,然后您可以使用它来访问/设置对象位置、旋转等。以下是代码行我指的是:

var geometry = new THREE.SphereGeometry( 75, 20, 10 );
var material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
var mesh = new THREE.Mesh( geometry, material );

创建网格对象后,您需要通过调用 scene.add(mesh) 将它们添加到场景中。此时您可以设置或获取旋转或位置

mesh.position.x = 50;
mesh.rotation.z = Math.PI / 2 // rotations are in radians

You do not seem to be asking a real question. But rather asking for someone to teach you something. In the 'startup code' a SphereGeometry object is combined with a MeshBasicMaterial object in order to create the Mesh object which is your 3d object that you can then use to access/set the objects position, rotation, etc. Here are the lines of code I am referring to:

var geometry = new THREE.SphereGeometry( 75, 20, 10 );
var material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
var mesh = new THREE.Mesh( geometry, material );

Once you create mesh objects you need to add them to the scene with a call to scene.add(mesh). At this point you can set or get the rotation or position as such

mesh.position.x = 50;
mesh.rotation.z = Math.PI / 2 // rotations are in radians
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文