reduce edges recalculation when enabled

This commit is contained in:
Stewart Allen 2026-01-05 15:33:29 -05:00
commit 9e816dd14b
2 changed files with 19 additions and 12 deletions

View file

@ -130,10 +130,16 @@ class Widget extends WidgetCore {
} }
} }
/**
* Set edge rendering
*/
setEdges(set) { setEdges(set) {
clearTimeout(this._setimer);
if (set === true && this.outline) {
this._setimer = setTimeout(() => this._setEdges(set), 10);
} else {
this._setEdges(set);
}
}
_setEdges(set) {
if (!(this.api && this.api.conf)) { if (!(this.api && this.api.conf)) {
// missing api features in engine mode // missing api features in engine mode
return; return;
@ -145,7 +151,6 @@ class Widget extends WidgetCore {
if (this.outline) { if (this.outline) {
mesh.remove(this.outline); mesh.remove(this.outline);
this.outline = null; this.outline = null;
} }
if (set) { if (set) {
let dark = this.api.space.is_dark(); let dark = this.api.space.is_dark();

View file

@ -442,12 +442,10 @@ class Widget {
} }
_updateMeshPosition() { _updateMeshPosition() {
let mesh = this.mesh, let { cache, mesh, track } = this,
track = this.track, { top, tzoff } = track,
tzoff = track.tzoff, { x, y, z } = track.pos,
top = track.top, tz = -tzoff;
tz = -tzoff,
{ x, y, z } = track.pos;
if (track.indexed) { if (track.indexed) {
this.mesh.rotation.x = -track.indexRad; this.mesh.rotation.x = -track.indexRad;
z = top; z = top;
@ -455,8 +453,12 @@ class Widget {
this.mesh.rotation.x = 0; this.mesh.rotation.x = 0;
z += tz; z += tz;
} }
mesh.position.set(x, y, z); let { pos } = cache;
this._updateEdges(); if (!pos || pos.x !== x || pos.y !==y || pos.z !== z) {
mesh.position.set(x, y, z);
this._updateEdges();
cache.pos = { x, y, z };
}
} }
_updateEdges() { _updateEdges() {