我有以下应该产生简单火焰效果的简单函数,我从这里构建代码的实际显示部分:
http://jeromeetienne.github.io/sparkseditor/
每当我运行该函数时,它似乎耗尽了池(最大粒子)然后死了,在屏幕上看不到它的痕迹。我正在使用 r53,而 sparks.js 的许多示例(如果不是全部)都使用 r47,不确定这是否相关。
您可以在此处找到产生错误的实际文件:
http://jeromeetienne.github.io/threex/docs/threex.sparks.html
下面是我的火焰代码:
var position = data.status.position;
var group = new Object3D();
scene.add(group);
var sparks = new THREEx.Sparks({
maxParticles : 10,
counter : new SPARKS.SteadyCounter(300)
});
var emitter = sparks.emitter();
var color = function() {
this.initialize = function(emitter, particle) {
particle.target.color().setHSV(0.4, 0.8, 0.4);
particle.target.size(100);
};
};
emitter.addInitializer(new color());
emitter.addInitializer(new SPARKS.Position(new SPARKS.PointZone(new THREE.Vector3(
position.x, position.y, position.z
))));
emitter.addInitializer(new SPARKS.Lifetime(0, 0.8));
emitter.addInitializer(new SPARKS.Velocity(new SPARKS.PointZone(new THREE.Vector3(
position.x, position.y-100, position.z
))));
emitter.addAction(new SPARKS.Age());
emitter.addAction(new SPARKS.Move());
emitter.addAction(new SPARKS.RandomDrift(1000,0,1000));
emitter.addAction(new SPARKS.Accelerate(0,-200,0));
emitter.addCallback('created', function(particle) {
group.add(particle);
});
emitter.addCallback('dead', function(particle) {
particle.target.visible = false;
group.remove(particle);
});
emitter.start();
在此先感谢,非常感谢您的帮助:)