pixijs / particle-emitter

A particle system for PixiJS
http://pixijs.io/particle-emitter/docs
MIT License
793 stars 125 forks source link

pixi 4.6.2, getting transform error #73

Closed endel closed 6 years ago

endel commented 6 years ago

Hi there,

I'm not sure what might be causing this problem. When adding particles to the stage I'm having this error:

screen shot 2017-12-07 at 18 01 59

pixi.js version "4.6.2" pixi-particles version "2.1.9"

endel commented 6 years ago

Oops! My bad. I've monkey-patched DisplayObject.prototype.updateTransform to call update methods automatically, and it turns out Particle has an update method, and it was causing an infinite loop.

// 
// Call 'update' at every render step, if defined.
// 
const DisplayObject_updateTransform = PIXI.DisplayObject.prototype.updateTransform;
PIXI.DisplayObject.prototype.updateTransform = function () {
    if (this.update) { this.update(PIXI.ticker.shared.deltaTime); }
    DisplayObject_updateTransform.apply(this, arguments);
}

const Container_updateTransform = PIXI.Container.prototype.updateTransform;
PIXI.Container.prototype.updateTransform = function () {
    if (this.update) { this.update(PIXI.ticker.shared.deltaTime); }
    Container_updateTransform.apply(this, arguments);
}

For now, I'm just checking if it's not a particle, like this:

// 
// Call 'update' at every render step, if defined.
// 
const DisplayObject_updateTransform = PIXI.DisplayObject.prototype.updateTransform;
PIXI.DisplayObject.prototype.updateTransform = function () {
    if (this.update && !this.Particle_update) { this.update(PIXI.ticker.shared.deltaTime); }
    DisplayObject_updateTransform.apply(this, arguments);
}

const Container_updateTransform = PIXI.Container.prototype.updateTransform;
PIXI.Container.prototype.updateTransform = function () {
    if (this.update && !this.Particle_update) { this.update(PIXI.ticker.shared.deltaTime); }
    Container_updateTransform.apply(this, arguments);
}

Cheers, and sorry to bother!