Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jes committed Apr 28, 2024
1 parent 0c3de90 commit 72b8cd4
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions 20240428.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 2024-04-28

## Deadbeat escapement simulator

I've been reading more Goodrich, and his explanation of laying out a deadbeat escapement is quite clear.
I am once again motivated to try to make an escapement simulator. But I'd rather not fight Matter.js
again, so I'm going to use one of the JavaScript Box2D ports, which Luke Wallin suggested to me.

[Which Box2D JavaScript library should I use?](https://stackoverflow.com/a/7968954)

https://github.com/piqnt/planck.js has the most github stars so let's start there.

Plan is maybe:

1. make a pendulum
2. make the rest of the escapement?

If I can get a pendulum working tonight I shall be pleased.

I'm following the "script tag" instructions on https://piqnt.com/planck.js/docs/install to try
to get `planck-with-testbed.min.js`. It works if I literally copy and paste the example, but
if I download `planck-with-testbed.min.js` from jsDelivr and try to load it locally it doesn't work,
either from a `file:///` URL ot with `SimpleHTTPServer`. Does it need to be loaded over https? Nope,
if I host it under `https://incoherency.co.uk/` it still doesn't work.

The error I'm getting is `Uncaught TypeError: t is null` at `planck-with-testbed.min.js:38`. So
what is it about jsDelivr that is making it work?

Oh! It's actually not jsDelivr. It's that if I write

<script src="..."></script>

then it doesn't work, but if I write:

<script src="..." />

then it does. Wtf?

Is it actually working? Maybe it doesn't work anyway but the ` />` form hides the error message?

I think the latter. If I put a `console.log` in my code it doesn't even execute that.

I've reported an issue on github: https://github.com/piqnt/planck.js/issues/276

OK, figured it, it's because it assumes the existence of some HTML elements that it hasn't created.

Woo, got a working pendulum: https://img.incoherency.co.uk/5418

0 comments on commit 72b8cd4

Please sign in to comment.