Jump to content

CSG toMesh material required


brianzinn
 Share

Recommended Posts

@Deltakosh Thanks - whole game builds with strictNullChecks compile option enabled!

One gotcha is that there are a lot of Nullable<T> (Nullable<T> = T | null), while they can often be undefined.  ie: mesh.physicsImpostor.  Not sure if it makes sense to default some to null - or at least new Nullable<T> properties that are added in the future.

ie: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L357

Could be

public physicsImpostor: Nullable<PhysicsImpostor> = null;

So, right now I need to check if (mesh.physicsImpostor) {...}, whereas I thought I could do if (mesh.physicsImpostor !== null) {..}.  I have a feeling that would break a lot of existing code, so I would guess it is just something we have to deal with knowing how it is implemented :) 

Link to comment
Share on other sites

Those 2 fields are really the tip of the iceberg.  Before even if I checked "if (mesh.physicsImpostor !== undefined)", I would get a potential Null warning in compiler in my if block, while checking for not null did not work and failed at runtime (default was undefined).  I think it's hard to say a (T | null) can either be a T or null only, which is what we expect from a typed language and not so much from JavaScript, but it does add some consistency and match the .d.ts file to help people in their editors and compile/lint errors.  Cheers.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...