From f1d3ad6a6dff13c585faf91617d9809684a37d4f Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 22 Sep 2024 02:32:34 -0500 Subject: [PATCH] perf: entity --- app/react/components/pixi/entity.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/react/components/pixi/entity.js b/app/react/components/pixi/entity.js index 7925b70..7d520c0 100644 --- a/app/react/components/pixi/entity.js +++ b/app/react/components/pixi/entity.js @@ -54,6 +54,8 @@ export default class Entity { this.debug.removeChild(this.interactionAabb); } this.interactionAabb = undefined; + this.diffuse.rotation = 0; + this.normals.rotation = 0; } setDebug(isDebugging) { if (isDebugging) { @@ -141,7 +143,9 @@ export default class Entity { this.entity.Sprite.animation, this.entity.Sprite.frame, ); - diffuse.texture = texture; + if (diffuse.texture !== texture) { + diffuse.texture = texture; + } if (asset.data.meta.normals) { const {pathname} = new URL( Sprite.source @@ -157,17 +161,14 @@ export default class Entity { this.entity.Sprite.animation, this.entity.Sprite.frame, ); - normals.texture = texture; + if (normals.texture !== texture) { + normals.texture = texture; + } }); } }); } } - if (!this.attached) { - const {diffuse, normals} = this; - diffuse.rotation = 0; - normals.rotation = 0; - } if (Direction) { const {diffuse, normals} = this; if (!this.attached || 'direction' in Direction) {