namespacing JavaScript + MicroScript
MicroScript code can use JavaScript code - I'm very impressed with this.
While testing (transferring to MicroScript) the sample code, I noticed a problem with the combination of JavaScript and MicroScript.
Here's a description of how MicroStudio was screaming for 24 hours and I couldn't understand what was happening.
In PIXI3D, the library exports classes and variables. It turns out that there is a variable that has the same name as the class.
PIXI3D.LightingEnvironment.main
which contains before the critical call
object
renderer = [object]
lights = [list]
imageBasedLighting = 0
end
The variable is used in the library and its absence or incorrect content causes errors in the graphics display.
There is also a class called PIXI3D.LightingEnvironment()
I can refer to a variable and a class from MicroScript - everything works fine.
However, the authors of the library did something that MicroScript cannot do - overwrite the value of PIXI3D.LightingEnvironment.main
with a new object.
Call:
app.renderer,
new PIXI3D.ImageBasedLighting(
resources["diffuse.cubemap"].cubemap,
resources["specular.cubemap"].cubemap
)
)
Causes the PIXI3D.LightingEnvironment
class to disappear.
Attempting to write to PIXI3D.LightingEnvironment.main
generates an error that such a variable does not exist.
It took me 24 hours to understand this and I suspected it was a library error or a server error (no graphics).
Due to this error, the entire graphic is black - you can check it by turning off the light (comment the lines PIXI3D.LightingEnvironment.main.lights.push(l)
)