-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |