jwagner / simplex-noise.js

A fast simplex noise implementation in Javascript / Typescript.
MIT License
1.61k stars 130 forks source link

MIME type ('application/octet-stream') is not executable #45

Closed olgageletina closed 2 years ago

olgageletina commented 2 years ago

Hi there,

Thanks for putting this awesome resource out there. I was hoping to use the 3.0.1 version in codepen but getting a MIME type ('application/octet-stream'). Here's the link. Version 2.4.0 seems to work fine, given a nearly identical implementation.

jwagner commented 2 years ago

Hey @olgageletina , Thanks for sharing this issue. The first link does not work for me 'This debug view expired.'. Can you update it? Should be able to have a look at this later today. :)

olgageletina commented 2 years ago

Thank you @jwagner!! Apologies, here's the link and the full error I'm getting.

jwagner commented 2 years ago

No worries @olgageletina . The issue doesn't seem to be with simplex-noise.js itself but rather with the config in cdnjs. Specifically this file here: https://github.com/cdnjs/packages/blob/master/packages/s/simplex-noise.json

Since simplex-noise 3 is now a module the best way to use it is to import it. I've updated the example pen to reflect this: https://codepen.io/jwagner/pen/BNmpdm

Looking at it now it would probably be a good idea to add a few more nicer demos than this simple plasma effect as well. :)

Would be awesome if you can confirm that using the import is working for you.

olgageletina commented 2 years ago

Sweet, thank you @jwagner! For some reason when I import the simplex module it prevents P5 from loading. There are no errors in the console. In fact unless I remove the import statement completely (commenting it out doesn't work) P5 doesn't render. When I try to import P5 it throws an error.

I filed an issue with codepen to see if it's on their side. The pen is for a class where most of the students are new to JS. So I was hoping to avoid the canvas scripting API for now.

jwagner commented 2 years ago

@olgageletina with the import statement your script runs in a module. This results in the setup function not being globally visible. A simple window.setup = setup; at the end of your script should resolve your issue. :)

olgageletina commented 2 years ago

Got it — appreciate your help!