Art Vandelay Posted November 29, 2017 Share Posted November 29, 2017 Hi everyone, What's the difference between Mesh and AbstractMesh? I understand the Mesh extends AbstractMesh but I am trying to understand when I should use one and when I should use the other. An example would be great as well. Thanks! Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 29, 2017 Share Posted November 29, 2017 basically you should not use abstractMesh on your own as this is the common parts between Mesh and InstancedMesh. Since a couple of weeks ago you can create a TransformNode if you need to group Meshes under a transform a bit like in unity. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted November 29, 2017 Share Posted November 29, 2017 I have never used it directly, but often need to declare it in TypeScript in function parameters for Typing, ie: for PickingInfo.pickedMesh:https://github.com/BabylonJS/Babylon.js/blob/01a11b0a4dcd1a195e9ca0b179852006f978ad9a/src/Collisions/babylon.pickingInfo.ts#L14 Here is an example of current state of VR Experience Helper (may change before 3.1 final) for setting a predicate for selection: let experienceHelper = new BABYLON.VRExperienceHelper(scene); experienceHelper.onNewMeshSelected.add((mesh: BABYLON.AbstractMesh, eventState: BABYLON.EventState) : void => { console.log('selected', mesh.name, mesh.isPickable) }) If I was in JavaScript would not be using AbstractMesh, though. If you don't know the difference - TypeScript transpiles down to JavaScript and all the typing information is lost anyway. Also, would say that having "Abstract" in the name of the class is a good indication that you would not create your own instances (ie: abstract classes cannot be instantiated). Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 29, 2017 Share Posted November 29, 2017 AbstractMesh is selected here because all Meshes derive from it. We already had an internal discussion about the name, which all of us kind'a agree - It is not the most fortunate name. Having said that - it will not be changed. You can always cast to Mesh (if you feel like it will look better in code). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.