wip faster texture loading

This commit is contained in:
David Allemang
2026-07-04 12:16:34 -04:00
parent a00d8c52d7
commit 57660397aa
5 changed files with 94 additions and 52 deletions

View File

@@ -24,6 +24,24 @@ export class Camera {
this.attachEvents();
}
saveState() {
this.checkpoint = {
target: [...this.target],
radius: this.radius,
theta: this.theta,
phi: this.phi,
}
}
loadState() {
if (!this.checkpoint) return;
this.target = [...this.checkpoint.target];
this.radius = this.checkpoint.radius;
this.theta = this.checkpoint.theta;
this.phi = this.checkpoint.phi;
this.onChange();
}
// --- INTERACTION MATH ---
orbit(dx, dy) {
@@ -115,7 +133,7 @@ export class Camera {
};
this.lastPinchDist = Math.hypot(t1.clientX - t2.clientX, t1.clientY - t2.clientY);
}
}, { passive: false });
}, {passive: false});
this.element.addEventListener('touchmove', (e) => {
if (!this.isDragging) return;
@@ -128,8 +146,7 @@ export class Camera {
this.orbit(dx, dy);
this.onChange();
}
else if (this.touchMode === 'pan-zoom' && e.touches.length >= 2) {
} else if (this.touchMode === 'pan-zoom' && e.touches.length >= 2) {
const t1 = e.touches[0], t2 = e.touches[1];
const cx = (t1.clientX + t2.clientX) / 2;
const cy = (t1.clientY + t2.clientY) / 2;
@@ -146,7 +163,7 @@ export class Camera {
this.zoom(-dDist); // Pinching out zooms in
this.onChange();
}
}, { passive: false });
}, {passive: false});
const onTouchEnd = (e) => {
if (e.touches.length === 0) {