Hey!
I’m using Raanan great kickstart repo to convert my project to Typescript.
I’m trying to add:
new StandardMaterial(`myMat`);
It generates the following error:
TS2554: Expected 2 arguments, but got 1. standardMaterial.d.ts(461, 31): An argument for 'scene' was not provided.
I can see that the signature of StandardMaterial is:
constructor(name: string, scene: Scene);
I think this is wrong.
IMO scene
should be optional:
-
it is already the current behaviour
I have been creating some objects without attaching them directly at the scene and it works fine -
leaving
scene
optional, and leaving the behaviour of adding to the scene at a later point, is very advantageous in terms of modulating the code and trying to be a minimal functional
I have a function for creating the material, one for the mesh, etc… and I can easily reuse them across components -
there is no harm for people that want to attach an object to the scene directly
What do you guys think?
TL DR
scene
being optional is just syntactic sugar
If not added explicitly, is being added by:
this._scene = scene || EngineStore.LastCreatedScene;
If a scene hasn’t been defined previously, the code will fail later at:
if (this._scene.useRightHandedSystem) {
....
}