Abstract Mesh example

Could someone please create an example of using an abstract mesh to define shared properties across two meshes that are created using MeshBuilder?

I can’t get my head around how to structure / code this.

Hi geoidesic,

Just replied to the other thread you created on this same general topic, but maybe I’m not understanding what you’re looking for. Can you create a Playground that shows the scenario you’re trying to achieve, then point out what part of the code you’re trying to replace with something shared?

Well for this thread I’m really just trying to understand AbstractMesh. There’s zero documentation on it so for me at this point it’s extremely abstract :slight_smile:

So I’m just looking for an understanding of how I would use AbstractMesh here and I wouldn’t be able to create a Playground example because I have nothing to base it on. I’m hoping someone else will create one and say something like “this is how I use AbstractMesh in my app”.

I was making an assumption about what I thought it was for in my description of the requested example… but really I’m just interested in knowing how to work with it (on this thread).

My first idea was that the abstract mesh is a base mesh from which all children are derived.

Googled a bit and found this old discussion:

1 Like

Okay, I understand better now; thanks!

Niceps is 100% right: the primary purpose of the AbstractMesh (in my understanding) is an API surface for when you’re dealing with meshes, but you don’t really care what kind of meshes (for example, InstancedMesh versus ordinary Mesh). As a base class, AbstractMesh is conceptually somewhere in the vicinity of an interface, but it’s a little more explicit and solid because you can actually make one.

In many cases, some of the best examples for how to use Babylon APIs can be found inside the implementation of Babylon itself. In the case of AbstractMesh, it’s used heavily by the motion controller part of the implementation for Babylon’s WebXR support. For this usage, AbstractMesh is used to represent the 3D models of various WebXR motion controller in a generic way, which is necessary because we may have to load in completely different motion controller meshes depending on what XR device you’re using. Thus, we need to interact with the meshes, but we don’t know much about what they actually are from the shared code. That’s where AbstractMesh comes in.

Hope this helps, and best of luck!

I think secretly none of y’all know how to use AbstractMesh… thus the lack of examples! (Hoping someone will take the bait).

1 Like

I think the TransfromNode is what you need.

The thing is AbstractMesh on its own is not usefull outside the framework, this is only the base of our Mesh classes e,g, Mesh InstancedMesh and such…

If you are not planning on implementing your own custom type of mesh, you probably do not need it.

1 Like

I cannot let such a statement stand freely in space … it is dangerous for my mental balance. :o)

I accept the challenge and search for YOU in the examples and here we are: I came back with a bunch of examples using the AbstractMesh:

I didn’t dig deeper into the attributes of this class. I supose that it has no geometric informations but position and rotation. Useful to hing a particlesystem to a position like in this example: https://playground.babylonjs.com/#03L15L#4

1 Like

Here is an example where the prototype of an AbstractMesh is used to put custom data in or common functions for all derived meshes:

1 Like