Open jackwh opened 1 year ago
Good work here! I copied the modified p5.easycam.js file from this PR and tested a dozen or more of my EasyCam sketches on OpenProcessing and editor.p5js.org. They all worked perfectly, both global and multi-instance sketches. I'll look into the TypeScript definitions tomorrow when I find time. Were you able to import this modified version successfully into your Yarn/TypeScript project?
Further to the discussion in #26, this PR does two things:
p5
context to be set dynamically. The code previously expectedp5
to be available globally, which won't always be the case ifp5
is aliased or bundled.Example code demonstrating these changes:
The traditional
<script src="..." />
approach still works as before. I've checked all the examples, and everything seems to be backwards-compatible.The only bit I'm unsure about is whether the TypeScript definitions need changing, now the code's wrapped in a module. I understand the types are a work-in-progress so perhaps someone can advise on that.