Hello! I’m currently learning to use the babylon editor. In the editor, you can add a mesh to the scene and then attach a script to it. This script can then alter the position/rotation/etc of that mesh by referencing this.position
, this.rotation
, etc.
However, I would like to set the mesh programmatically and can’t find how that would be done. I could add my own variable to my class such as this.myMesh = MeshBuilder()
and reference that for all my translations but I would miss out on a lot of the nifty tools built into the editor classes. Does anyone know the best way to do this? Thanks!
Edit: After doing some more research, it seems my question is more along the lines of: How can I set an instance of the Mesh class to use a box or sphere?
Edit: This seems to work. It’s added as a child which I’m good with. Is this the best way then? There still seems to be some quirks doing it this way
export default class MyScript extends Mesh {
public onStart(): void {
const box = MeshBuilder.CreateBox('testbox');
this.addChild(box);
}