danchitnis/webgl-plot

noob question : how to import correctly

journeytosilius opened this issue · 1 comments

I'm following this fiddle : https://jsfiddle.net/danchitnis/mfcw73z2/

so I import the bundle file from the CDN endpoint : <script src="https://cdn.jsdelivr.net/gh/danchitnis/webgl-plot@master/dist/webglplot.umd.min.js"></script>

I use express for the webserver, and have my code at a JS file, when I run the class instantiation I get this :

webglplot.umd.js:635 Uncaught TypeError: t.getContext is not a function

I'm pretty sure there is something I don't understand about how to import it, if you can clarify I'd much appreciate it

EDIT :

So I import the bundle in my html, then I add my JS file as a module like this : <script type="module" src="your-code.js"></script>

and then I add this on my JS file :

import {
  WebglPlot,
  WebglLine,
  ColorRGBA,
} from "https://cdn.jsdelivr.net/gh/danchitnis/webgl-plot@master/dist/webglplot.esm.min.js";

sorry I was passing div instead of a canvas