mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Fix ParticleSystem customs not working issue (#3000)
This commit is contained in:
@@ -921,16 +921,17 @@ var ParticleSystem = cc.Class({
|
||||
}
|
||||
|
||||
self._plistFile = file.nativeUrl;
|
||||
if (self._custom) {
|
||||
self._initTextureWithDictionary(content);
|
||||
if (!self.spriteFrame) {
|
||||
if (file.texture) {
|
||||
self.spriteFrame = new cc.SpriteFrame(file.texture);
|
||||
}
|
||||
else {
|
||||
self._initTextureWithDictionary(content);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!self._custom) {
|
||||
self._initWithDictionary(content);
|
||||
}
|
||||
|
||||
if (file.texture) {
|
||||
self.spriteFrame = new cc.SpriteFrame(file.texture);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -1094,10 +1095,7 @@ var ParticleSystem = cc.Class({
|
||||
|
||||
_onTextureLoaded: function (event) {
|
||||
this._texture = this._spriteFrame.getTexture();
|
||||
// Mark render data dirty
|
||||
if (this._renderData) {
|
||||
this._renderData.uvDirty = true;
|
||||
}
|
||||
this._simulator.updateUVs(true);
|
||||
// Reactivate material
|
||||
this._activateMaterial();
|
||||
},
|
||||
|
||||
@@ -191,13 +191,15 @@ Simulator.prototype.emitParticle = function (pos) {
|
||||
}
|
||||
};
|
||||
|
||||
Simulator.prototype.updateUVs = function (particleCount) {
|
||||
Simulator.prototype.updateUVs = function (force) {
|
||||
let particleCount = this.particles.length;
|
||||
if (this.sys._buffer && this.sys._spriteFrame) {
|
||||
const FLOAT_PER_PARTICLE = 4 * this.sys._vertexFormat._bytes / 4;
|
||||
let vbuf = this.sys._buffer._vData;
|
||||
let uv = this.sys._spriteFrame.uv;
|
||||
|
||||
for (let i = this._uvFilled; i < particleCount; i++) {
|
||||
let start = force ? 0 : this._uvFilled;
|
||||
for (let i = start; i < particleCount; i++) {
|
||||
let offset = i * FLOAT_PER_PARTICLE;
|
||||
vbuf[offset+2] = uv[0];
|
||||
vbuf[offset+3] = uv[1];
|
||||
@@ -303,7 +305,7 @@ Simulator.prototype.step = function (dt) {
|
||||
|
||||
// Fill up uvs
|
||||
if (particleCount > this._uvFilled) {
|
||||
this.updateUVs(particleCount);
|
||||
this.updateUVs();
|
||||
}
|
||||
|
||||
// Used to reduce memory allocation / creation within the loop
|
||||
|
||||
Reference in New Issue
Block a user