简体   繁体   English

Three.js画布行示例调整

[英]Three.js Canvas Lines Example Tweak

This is most likely better posted in a forum, but the Three.js Google Group seems dead and I'm not aware of any others so apologies in advance. 这很可能最好在论坛上发布,但是Three.js Google网上论坛似乎已经死了,我不知道其他任何人在此道歉。 Feel free to let me know of a better place to post more generic questions. 随时让我知道发布更一般性问题的更好的地方。

I'm curious how one would make this example: http://threejs.org/examples/#canvas_lines fill a cube's space instead of a sphere? 我很好奇一个例子: http : //threejs.org/examples/#canvas_lines填充了一个立方体的空间而不是一个球体? Is there an easy way to go about this with this example or would it require a lot of changes? 是否有一个简单的方法可以解决此问题,或者需要进行很多更改?

Replace this code: 替换此代码:

particle.position.x = Math.random() * 2 - 1;
particle.position.y = Math.random() * 2 - 1;
particle.position.z = Math.random() * 2 - 1;
particle.position.normalize();
particle.position.multiplyScalar( Math.random() * 10 + 450 );

With this: 有了这个:

particle.position.x = Math.random() * 500 - 250;
particle.position.y = Math.random() * 500 - 250;
particle.position.z = Math.random() * 500 - 250;

This code places the points at the edges of the box: 此代码将点放置在框的边缘:

particle.position.x = Math.random() * 2 - 1;
particle.position.y = Math.random() * 2 - 1;
particle.position.z = Math.random() * 2 - 1;
particle.position.normalize();
particle.position.multiplyScalar( 500 );
particle.position.clamp(
    new THREE.Vector3( -250, -250, -250 ),
    new THREE.Vector3(  250,  250,  250 )
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM