is it possible to do something like class MyMeshType extends Mesh { .. }
and when you do const pickResult = Scene.pick.. and then do something like if (pickResult.pickedMesh instanceof MyMeshType) {...}?
My current attempt is very much like the above, just with a testMessage: string in MyMeshType.
Currently I’m putting all the ‘extra data’ in the metadata-property, but on some types I want to be able to add custom code when the position changes, something like
class MyTestMesh extends Mesh {
get position(): Vector3
{
console.log('get position');
return super.position;
}
set position(newPosition: Vector3)
{
console.log('set position');
super.position = newPosition;
}
}
Wait, here you are using a TS cast so the property customName is not available. You are just telling the type system that you know it is a TestMesh, which is not the case cause in the function createSphere we are creating a Mesh not a TestMesh.
Got a somewhat OK prototype working with the position update now, thanks for the input.
Any tips on where to look for creating custom meshes? I’m mostly drawing lines, boxes and spheres in a “2D view” using orthographic camera. Had some troubles with sprites as they looked really bad when zoomed in or out - maybe I should have used some kind of LOD?