在three.js中,什么时候需要启用PointCloud.sortParticles? [英] In three.js, when we need PointCloud.sortParticles enabled?

查看:20
本文介绍了在three.js中,什么时候需要启用PointCloud.sortParticles?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现一些示例启用了此属性,但没有足够的注释让我理解它的重要性.你能告诉我这个属性的最佳实践是什么吗?

I found some of the examples enable this property, but there're not enough comments to make me understand what it matters. Could you please tell me what's the best practice of this property?

推荐答案

PointCloud 现在是 Points.sortParticles 属性已被删除.这意味着这些点按照它们在缓冲区中存在的顺序进行渲染.下面的答案已经过时了.三.js r.73

PointCloud is now Points, and the .sortParticles property has been removed. That means the points are rendererd in the order they exist in the buffer. The answer below is outdated. three.js r.73

这是一个完美的例子,说明如果您使用 Three.js,那么至少了解 webGL 的基本概念很重要.(参见这篇SO帖子.)

This is a perfect example of why it is important to understand at least the basic concepts of webGL if you are using three.js. (See this SO post.)

如果渲染顺序很重要,您需要设置 PointCloud.sortParticles = true.

You need to set PointCloud.sortParticles = true if the rendering order matters.

以下是渲染顺序很重要的示例:

Here is an example where the rendering order matters:

var material = new THREE.PointCloudMaterial( {
    map: texture, // has transparent areas
    transparent: true
} );

var pointCloud = new THREE.PointCloud( geometry, material );
pointCloud.sortParticles = true; // the default is false

在这种情况下,渲染器将按深度对点进行排序,因此首先渲染离相机较远的点,并通过较近点的透明区域显示.

In this case, the renderer will sort the points by depth, so points further from the camera are rendered first, and show through the transparent areas of the closer ones.

这是一个渲染顺序无关的例子:

Here is an example where rendering order does not matter:

var material = new THREE.PointCloudMaterial( {
    map: texture,
    blending: THREE.AdditiveBlending,
    depthTest: false,
    transparent: true
} );

// point cloud
var pointCloud = new THREE.PointCloud( geometry, material );

由于排序发生在 CPU 端,因此最好明智地选择您的材料设置,这样您就可以避免开销——尤其是对于大型系统.

Since sorting occurs on the CPU-side, it is best to choose your material settings wisely, so you can avoid the overhead -- especially for large systems.

我建议您建立一个测试平台并进行实验.有很多很多可能的情况需要考虑.

I suggest you build a testbed and experiment. There are many, many possible cases to consider.

three.js r.69

three.js r.69

这篇关于在three.js中,什么时候需要启用PointCloud.sortParticles?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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