Skip to content

Commit

Permalink
Minimal Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Patitotective committed Aug 25, 2024
1 parent 3587f93 commit ac8a4ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ nimcache/
nimblecache/
htmldocs/
dist*
src/buildcss
app
13 changes: 7 additions & 6 deletions src/frontend/simulations/parabola.nim
Original file line number Diff line number Diff line change
Expand Up @@ -716,17 +716,18 @@ proc calcTrajectory(state: var ParabolaState) =
let prevLastPoint = state.trajectory.pinnedPoint != 0 and
state.trajectory.pinnedPoint in state.trajectory.points and
state.trajectory.points.high == state.trajectory.pinnedPoint
let totalTime = initialState.calcTotalTime()

var highest = (index: 0, y: 0.0)

state.trajectory.points.setLen(0)
for t in countthrough(0.0, initialState.calcTotalTime(), step = delta / 25):
for t in countthrough(0.0, totalTime / 2, totalTime, step = delta / 25):
var point: TrajectoryPoint
with point:
time = t.round(state.floatPrecision)
pos = initialState.calcPos(point.time)
vel = initialState.calcVel(point.time)
speed = point.vel.magnitude()
vel = initialState.calcVel(point.time)#.both proc(a: float): float = abs(a)
speed = point.vel.magnitude()

state.trajectory.points.add point

Expand Down Expand Up @@ -1039,7 +1040,7 @@ proc onAfterUpdate(state: var ParabolaState, event: JsObject) =
if not b.isSleeping.to(bool) and not b.isStatic.to(bool):
freeze = false

if b.speed.to(float) > 1000:
if b.speed.to(float) > 1500:
Matter.Body.setSpeed(b, 10)

#echo (f: freeze, a: not state.canon.base.dragging, b: not state.canon.dragging,
Expand Down Expand Up @@ -1822,8 +1823,8 @@ proc reload*(state: var ParabolaState) =
proc renderLeftDiv(state: var ParabolaState): VNode =
buildHtml tdiv(id = "sim", class = "column col-8", style = "height: 100%".toCss):
# tabindex makes it able to focus the canvas
canvas(id = "canvas", style = toCss "height: 100%; width: 100%; min-width: 500px;" &
"min-height: 300px; outline: none", tabindex = "0"):
canvas(id = "canvas", style = toCss "height: 100%; width: 100%; min-width: 230px;" &
"outline: none", tabindex = "0"):
text "Matter-js simulation"
proc onclick(e: Event, n: VNode) =
n.dom.focus()
Expand Down

0 comments on commit ac8a4ee

Please sign in to comment.