You can download this example custom block for testing and as a template for implementing a custom block in a stand-alone javascript file: squareBlock.js
It works the same as custom frames I believe: the custom block must be loaded from local file when it is first added and after that it is reloaded from local storage as needed.
The demo calls BABYLON.NodeEditor.Show from code (it’s the same files as https://nme.babylonjs.com/ uses except that the custom build of babylonjs.nodeEditor.js is used).
I’ve tested it locally, using the playground and that is working well also.
The BABYLON namespace is used only in the custom block’s JS file. TBH I hand’t considered that people would want to create their custom block using ES6 (without the BABYLON namespace?)…
EDIT: Hmm I think I see the ES6 concern better now, and IDK either how ES6 could be supported since the custom files are needing the BABYLON namespace…
Custom frames are only using known nodes. There is no need for additional code. In your case if I use your node material without loading the custom code it will fail.
Also even if I’m loading your code inside an es6 environment it will fail as the Babylon namespace will not exist and thus your custom code will not compile.
My view of the custom code was more around something that does not requires js at all. More a combination of json info about inputs and outputs and associated glsl code. That way we could save it inside a snippet
But please don’t get me wrong, I find what you did really interesting but I do not think we should add it in the framework because of the limitations I highlighted earlier
Aah, okay, I had thought the custom frame’s json file was creating the same sort of dependency/limitation, but it sounds like the material can be saved and shared without the custom frame by just saving the frame’s nodes, so it’s not really the same situation…
And TBH I don’t really use es6 environment so I didn’t even think of the namespace concern.
So I think I will chalk this up to a learning exercise and try to find something else to tinker with LOL.
Okay, I’ll see what I can come up with and start a new thread once I’ve got the first draft work out. It sounds like the user will be responsible for creating the json file and NodeEditor will be responsible for loading the json file, serializing and unserializing it when the material is saved and loaded - and all of that I’m thinking will be wrapped up in a new class called CustomBlock that extends the Block class to implement the json handling part.