-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table extra fields in js object #155
Comments
I've found a workaround, doing this: local material = new(THREE.ShaderMaterial)
material.uniforms= uniforms
material.vertexShader= document:getElementById('vertexShader').textContent
material.fragmentShader= document:getElementById('fragmentShader').textContent but I still want to know how to make the other way work. And now I am having another issue the animation is static, unlike the pure js example the line |
I have found a solution for both problems by creating a JS object explicitly: local object = function(t)
return js.new(function(o)
for k,v in pairs(t) do
o[k] = v
end
end)
end Then instead of using plain tables I use: uniforms = object{
time = object{ value = 1.0 }
}
local material = new(THREE.ShaderMaterial, object{
uniforms= uniforms,
vertexShader= document:getElementById('vertexShader').textContent,
fragmentShader= document:getElementById('fragmentShader').textContent
}) Took me a while to try this, I think a function for creating JS objects similar to this one could be implemented in |
I agree, we all have helpers like this (see mine), they could be in interop. |
Lua tables are not exposed as JS objects, but as |
I'm going to close this issue as a duplicate of fengari-lua/fengari-interop#44 |
I am trying to port this example of three.js to Fengari:
https://threejs.org/examples/?q=shader#webgl_shader
However I am getting these errors and the example does not work:
Looks like when I create a table the js objects will always
have these fields and make Three.js error. How do I fix this?
For reference my ported code of the example is this:
The text was updated successfully, but these errors were encountered: