refactor: extend PhysicsBody with cached dims and add dirtyElements
This commit is contained in:
@@ -4,6 +4,10 @@ interface PhysicsBody {
|
||||
y: number;
|
||||
vx: number;
|
||||
vy: number;
|
||||
width: number;
|
||||
height: number;
|
||||
originX: number;
|
||||
originY: number;
|
||||
isDragging: boolean;
|
||||
startX: number;
|
||||
startY: number;
|
||||
@@ -11,6 +15,7 @@ interface PhysicsBody {
|
||||
|
||||
export class GravityEngine {
|
||||
private bodies: PhysicsBody[] = [];
|
||||
private dirtyElements: HTMLElement[] = [];
|
||||
private animationFrameId: number | null = null;
|
||||
private isRunning = false;
|
||||
|
||||
@@ -83,6 +88,10 @@ export class GravityEngine {
|
||||
y: rect.top,
|
||||
vx: (Math.random() - 0.5) * 8, // slight explosion outward
|
||||
vy: (Math.random() - 0.5) * 5, // slight pop upward
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
originX: rect.left,
|
||||
originY: rect.top,
|
||||
isDragging: false,
|
||||
startX: 0,
|
||||
startY: 0,
|
||||
|
||||
Reference in New Issue
Block a user