【发布时间】:2012-11-08 03:27:54
【问题描述】:
我正在模拟围绕太阳系运行的小行星。你可以看到一个初始实现here。
我将整个轨道对象集转换为单个 ParticleSystem,我可以在我的家用机器上以 60fps 的速度运行 10,000 个轨道(在我的笔记本电脑上大约为 30fps)。 15-20k 让我的机器降到 30fps。
我正在运行一个网络工作者来计算一个新的位置列表,然后我在主线程中更新每个对象的位置,如下所示:
for (var j=0; j < positions.length; j++) {
myobjects[j].MoveParticleToPosition(positions[j]);
}
particle_geometry.__dirtyVertices = true;
MoveParticleToPosition:
var vertex_particle = this.particle_geometry.vertices[this.vertex_pos];
vertex_particle.x = pos[0];
vertex_particle.y = pos[1];
vertex_particle.z = pos[2];
我的问题是:如何从这里提高性能?
例如,有没有更快的方法来更新几何顶点?是否有可以应用于 ParticleSystem 的优化?是否可以从 Web Worker 中更新顶点?
【问题讨论】:
-
__dirty 标志不再受支持。您不妨更新到当前版本的 three.js 并查看 wiki:github.com/mrdoob/three.js/wiki/Updates。
标签: three.js