Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed Mar 28, 2024
1 parent 1c394cb commit f6ae63b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ const refill = () => {
/>
<input type="number" v-model="worldConfig.BOUNCE_FORCE_MULTIPLIER" step="0.1" />
</div>
<div>
<input-header
name="Bounds Force Multiplier"
tooltip="Parameter by which the force of repulsion from the boundaries of space is multiplied."
/>
<input type="number" v-model="worldConfig.BOUNDS_FORCE_MULTIPLIER" step="0.01" />
</div>
<div>
<input-header
name="Inertial Multiplier"
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function createBaseWorldConfig(): WorldConfig {
GRAVITY_FORCE_MULTIPLIER: 1,
LINK_FORCE_MULTIPLIER: 0.015,
BOUNCE_FORCE_MULTIPLIER: 2,
BOUNDS_FORCE_MULTIPLIER: 0.01,
INERTIAL_MULTIPLIER: 0.96,
SPEED: 25,
PLAYBACK_SPEED: 1,
Expand Down
8 changes: 6 additions & 2 deletions src/lib/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ export class InteractionManager implements InteractionManagerInterface {
private handleBounds(atom: AtomInterface): void {
for (let i = 0; i < atom.position.length; ++i) {
if (atom.position[i] < this.WORLD_CONFIG.MIN_POSITION[i]) {
atom.speed[i] += this.physicModel.getBoundsForce(this.WORLD_CONFIG.MIN_POSITION[i] - atom.position[i]);
atom.speed[i] += this.normalizeForce(
this.physicModel.getBoundsForce(this.WORLD_CONFIG.MIN_POSITION[i] - atom.position[i])
);
} else if (atom.position[i] > this.WORLD_CONFIG.MAX_POSITION[i]) {
atom.speed[i] -= this.physicModel.getBoundsForce(atom.position[i] - this.WORLD_CONFIG.MAX_POSITION[i]);
atom.speed[i] -= this.normalizeForce(
this.physicModel.getBoundsForce(atom.position[i] - this.WORLD_CONFIG.MAX_POSITION[i])
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/physics/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class PhysicModelV1 implements PhysicModelInterface {
return this.WORLD_CONFIG.LINK_FORCE_MULTIPLIER;
}

getBoundsForce(): number {
return 1;
getBoundsForce(dist: number): number {
return this.WORLD_CONFIG.BOUNDS_FORCE_MULTIPLIER * dist;
}
}
4 changes: 2 additions & 2 deletions src/lib/physics/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class PhysicModelV2 implements PhysicModelInterface {
return this.WORLD_CONFIG.LINK_FORCE_MULTIPLIER;
}

getBoundsForce(): number {
return 1;
getBoundsForce(dist: number): number {
return this.WORLD_CONFIG.BOUNDS_FORCE_MULTIPLIER * dist;
}
}
1 change: 1 addition & 0 deletions src/lib/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type WorldConfig = {
GRAVITY_FORCE_MULTIPLIER: number;
LINK_FORCE_MULTIPLIER: number;
BOUNCE_FORCE_MULTIPLIER: number;
BOUNDS_FORCE_MULTIPLIER: number;
INERTIAL_MULTIPLIER: number;
PLAYBACK_SPEED: number;
SIMPLIFIED_VIEW_MODE: boolean;
Expand Down

0 comments on commit f6ae63b

Please sign in to comment.