further refinement to scroll and zoom

This commit is contained in:
Lentil Hoffman 2025-12-26 19:12:04 -06:00
parent c53a4e9393
commit 4bb91d664d
Signed by: lentil
GPG Key ID: 0F5B99F3F4D0C087
3 changed files with 9 additions and 5 deletions

View File

@ -2,6 +2,7 @@ export const DISPLAY_OBJECTS_INFO = false;
export const DISPLAY_CURSOR_INFO = false;
export const DISPLAY_CANVAS_SIZE = false;
export const DISPLAY_CURRENT_SCALE = true;
export const DISPLAY_CURRENT_MODE = false;
export const DISPLAY_VELOCITY_VECTORS = true;
export const MASS_CREATION_RATE = 0.001;

View File

@ -179,13 +179,13 @@ export class Pointer {
if (this.panning) {
const {pointerStart, pointerCurrent, viewOriginStart, velocity} = this.sim.pointer.panning;
// Convert pointer velocity to sim internal scale
velocity.x /= this.sim.display.scale;
velocity.y /= this.sim.display.scale;
const vx = velocity.x / this.sim.display.scale;
const vy = velocity.y / this.sim.display.scale;
this.panning.viewOriginStart = this.sim.display.viewOrigin;
this.panning.pointerStart = pointerCurrent;
// const speed = Math.sqrt(velocity.x ** 2 + velocity.y ** 2);
this.sim.display.viewOrigin.x -= velocity.x * elapsedTime * PAN_VELOCITY_SCALE_FACTOR;
this.sim.display.viewOrigin.y -= velocity.y * elapsedTime * PAN_VELOCITY_SCALE_FACTOR;
this.sim.display.viewOrigin.x -= vx * elapsedTime * PAN_VELOCITY_SCALE_FACTOR;
this.sim.display.viewOrigin.y -= vy * elapsedTime * PAN_VELOCITY_SCALE_FACTOR;
}
}
}

View File

@ -10,6 +10,7 @@ import {
SCALE_POWER_MAX,
SCALE_POWER_MIN,
DISPLAY_CURRENT_SCALE,
DISPLAY_CURRENT_MODE,
} from './config.js';
export class Sim {
@ -89,7 +90,9 @@ export class Sim {
const elapsedTime = currentTime - this.time;
this.time = currentTime;
this.info['Mode'] = this.getCurrentMode();
if (DISPLAY_CURRENT_MODE) {
this.info['Mode'] = this.getCurrentMode();
}
if (this.nextZoom) {
this.zoom(this.nextZoom);