Hugo M

  • Content Count

  • Joined

  • Last visited

  1. @Wingnut Thanks! I'm already registered in the new forum and I will ask there. @aWeirdo that looks useful, thanks!
  2. I have this code: var tiledGround = new BABYLON.Mesh.CreateTiledGround("Tiled Ground", xmin, zmin, xmax, zmax, subdivisions, precision, scene); tiledGround.actionManager = new BABYLON.ActionManager(scene); tiledGround.actionManager.registerAction( new BABYLON.ExecuteCodeAction( BABYLON.ActionManager.OnPickTrigger, e => { // TODO: I need to know which submesh was clicked console.log(e); }, null )); var whiteMaterial = new BABYLON.StandardMaterial("White", scene); whiteMaterial.diffuseColor = new BABYLON.Color3(1, 1, 1); var blackMaterial = new BABYLON.StandardMaterial("Black", scene); blackMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0); var multimat = new BABYLON.MultiMaterial("multi", scene); multimat.subMaterials.push(whiteMaterial); multimat.subMaterials.push(blackMaterial); tiledGround.material = multimat; var verticesCount = tiledGround.getTotalVertices(); var tileIndicesLength = tiledGround.getIndices().length / (subdivisions.w * subdivisions.h); tiledGround.subMeshes = []; var base = 0; for (var row = 0; row < subdivisions.h; row++) { for (var col = 0; col < subdivisions.w; col++) { tiledGround.subMeshes.push(new BABYLON.SubMesh(row%2 ^ col%2, 0, verticesCount, base, tileIndicesLength, tiledGround)); base += tileIndicesLength; } } So basically I'm not sure how to know which submesh was clicked. The result for the event gives me some X and Y coordinates but they don't seem related at all with my mesh size. Ej the tiledGround size is 10x10 (I'm not sure which units are used by Babylon) but the pointer gives me something like x: 800, y: 200. Obviously they are not the same magnitudes. My point is that I'd be able to calculate to which tile correspond the click if the pointers were related to the actual position on the plane, but they don't seem to.