You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove need to use eval in base library, and use and special magic to have functions in scope.
No scope collisions or magic, external data can easily be brought in a predictable way. Multiple shapes could coexist without their namespaces/scopes interfering
API proposal:
//////////// SP library ////////////// Returns library functions in a dictionary rather than using eval to dump them into global scopefunctioncreateShape(){return{baseShape: {bindToCanvas: (canvas)=>console.log('attaching to canvas...'),getGLSL: ()=>console.log('vec3 p ... '),draw: ()=>console.log('rendering ...')},sphere: (rad)=>console.log(`drawing sphere radius ${rad}`),box: ()=>console.log('drawing box'),mix: ()=>console.log('setting mode mix')}}///////////// USER CODE ////////////////import{createShape}fromshaderparkimportexternalObjectfrom'./otherfile.js'// Equivalent to importing functions that are bound to a particular object,// could have multiple shapes in the same file which don't interfere with each otherconst{baseShape, sphere, mix}=createShape()// Can use any javascript variable like you'd expect!sphere(externalObject.raduis)baseShape.bindToCanvas('dummmy canvas')baseShape.draw()// object-oriented approach binds all functions to their data so you can do things like just ask a shape for its glsl)constglslSource=baseShape.getGLSL()
The text was updated successfully, but these errors were encountered:
Remove need to use eval in base library, and use and special magic to have functions in scope.
No scope collisions or magic, external data can easily be brought in a predictable way. Multiple shapes could coexist without their namespaces/scopes interfering
API proposal:
The text was updated successfully, but these errors were encountered: