refactor: oppt

This commit is contained in:
cha0s 2021-07-06 19:11:25 -05:00
parent 779ade1058
commit 41c2c0950e

View File

@ -7,6 +7,8 @@ export default () => class Primitive extends Trait {
#primitives;
#scheduledDraw = true;
static defaultParams() {
return {
primitives: [],
@ -68,22 +70,29 @@ export default () => class Primitive extends Trait {
return {
blueChanged: () => {
this.drawPrimitives();
this.#scheduledDraw = true;
},
greenChanged: () => {
this.drawPrimitives();
this.#scheduledDraw = true;
},
redChanged: () => {
this.drawPrimitives();
this.#scheduledDraw = true;
},
traitAdded: () => {
this.drawPrimitives();
this.#scheduledDraw = true;
},
};
}
renderTick() {
if (this.#scheduledDraw) {
this.#scheduledDraw = false;
this.drawPrimitives();
}
}
};