Default options parameter for Create functions

Heya, I was wondering if the options parameter could default to an empty object for CreateBox and the other Create functions?

Currently for example, calling CreateBox without any parameters throws an error because CreateBox attempts to access properties of the undefined options parameter.

But after defaulting the options parameter to {} like below, then the box mesh is created without error with default options.

export function CreateBox(name: string, options: { size?: number, width?: number, height?: number, depth?: number, faceUV?: Vector4[], faceColors?: Color4[], sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean, topBaseAt?: number, bottomBaseAt?: number, updatable?: boolean } = {}, scene: Nullable<Scene> = null): Mesh {

If sounds good, I’m happy to make a PR for the Create functions. :slightly_smiling_face:

3 Likes

sounds good to me

3 Likes

I always forget the options parameter so this sounds wonderful to me. :joy:

1 Like

Here’s the patch: I updated and tested all of the Create functions listed under the Methods section of the Mesh documentation that don’t have any required options and didn’t have a default options object already. :slight_smile: :beers:

CreateBox
CreateCylinder
CreateDisc
CreateGround
CreateGroundFromHeightMap
CreateHemisphere
CreateIcoSphere
CreatePlane
CreatePolyhedron
CreateSphere
CreateTorus
CreateTorusKnot
2 Likes