Errors when using pointer observable inside of a Mesh subclass

I am trying to create a class that extends AbstractMesh and wraps a plane mesh. Basically I want to create a container for a depth mask mesh as part of an effort to try to get some better encapsulation for CSS3DObject. When I do this, I found that I need to mask the getWorldMatrix with a method that delegates to the underlying mesh’s getWorldMatrix. I add a pointer observable when I create the mesh to determine if the mesh has been selected or deselected (so I can trigger a resize gizmo on and off). When I click on the mesh, I get an error in getWorldMatrix that mesh is undefined. However, I have a custom renderer that is able to call the getWorldMatrix successfully. It is only in the context of the pick event, that it fails. I doubt this is a Babylon problem, but I’m hoping somebody can shed some light on what is happening here. You can observe this in the PG by looking at the console and then click on the plane and you will see the error. You may need to pause execution as the logging of the matrix will happen every frame.

Hey there, I wasn’t able to reproduce the error, but I recommend that instead of creating wrapper’s for the mesh properties and functions, to instead extend from Mesh and create and apply the plane vertex data in your constructor like below. That way the code is much more concise and easier IMO, w/out all the wrappers. :slight_smile:

Thanks. I was looking for a way to do that and I think the createPlaneVertexData is exactly what I need.

1 Like