I forked a lib designed to draw vectors on webgl in order to allow it to be suitable for animated draw by not recreating a buffer at every draw call. I tried it on a simple next app and it worked. Code is available here: https://github.com/Th0rgal/svgdemo/blob/main/pages/index.js And this draws:
Unfortunately when I tried to do the same thing in my existing app, I ran into an error and I don't understand what could be the issue.
The error says: TypeError: Cannot read properties of undefined (reading 'VERTEX_SHADER')
and seems to be caused by this line:
this.loaded.load({
webgl,
shaders: {
vertex: vertexShader,
fragment: fragmentShader,
},
loc: {
width: 400,
height: 400,
},
needTrim: false,
});
This is the exact same code than from the svgdemo and I use the same shader (it is not empty, I console.logged it). I have no mention of VERTEX_SHADER in my entire code nor in the lib code. The bugged project is available here: https://github.com/age-of-eykar/eykar.org/tree/472405a43a01629c187b593b90660e4450a31bd0
Entire error:
"TypeError: Cannot read properties of undefined (reading 'VERTEX_SHADER')
at on (webpack-internal:///./node_modules/svg-webgl-loader-opti/dist/js/index.umd.js:6:12232)
at eval (webpack-internal:///./node_modules/svg-webgl-loader-opti/dist/js/index.umd.js:6:22344)
at Object.n.load (webpack-internal:///./node_modules/svg-webgl-loader-opti/dist/js/index.umd.js:6:22376)
at _callee$ (webpack-internal:///./utils/map/assets.js:250:46)
at tryCatch (webpack-internal:///./node_modules/next/dist/compiled/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (webpack-internal:///./node_modules/next/dist/compiled/regenerator-runtime/runtime.js:274:22)
at Generator.prototype.<computed> [as next] (webpack-internal:///./node_modules/next/dist/compiled/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (webpack-internal:///./utils/map/assets.js:21:28)
at _next (webpack-internal:///./utils/map/assets.js:39:17)"
The only difference I see is that I use webgl to draw with another shader, but the code that takes care of it is not called when the error happens (it's really at the initialization of the object).
Via Active questions tagged javascript - Stack Overflow https://ift.tt/sDfgRLU
Comments
Post a Comment