This code is a part of my Booth class to create some board mesh with registered action.
First of all, OnPointerOver and Down works well, but only PickTrigger doesn’t work on board mesh.
To figure out the problem, i tried below solutions , but it didn’t work
- board.isPickable = true
- attachControl to my camera
But it seems that ‘PickTrigger’ event just don’t work for every meshes.
public CreateBoardMesh() {
for (let i = 0; i < 3; i++) {
const board = MeshBuilder.CreateBox(
`board-${i}-image`,
{
width: 2,
height: 3.8,
depth: 0.1,
},
this.scene
);
board.isPickable = true;
board.parent = this.rootMesh;
board.rotation.y = Math.PI / 2;
board.position.set(3.6, 3, 0.715 + i * -2.5);
board.edgesColor = new Color4(1, 1, 0, 0.7);
board.edgesWidth = 5;
const mat = new StandardMaterial("board-mat", this.scene);
mat.diffuseColor = new Color3(1, 1, 1);
mat.roughness = 0.5;
mat.diffuseTexture = this.dummyTextures[Math.floor(Math.random() * 8)];
board.material = mat;
board.actionManager = new ActionManager(this.scene);
board.actionManager.registerAction(
new ExecuteCodeAction(ActionManager.OnPickUpTrigger, () => {
alert("player clicked");
})
);
board.actionManager.registerAction(
new ExecuteCodeAction(ActionManager.OnPointerOverTrigger, () => {
board.enableEdgesRendering();
})
);
board.actionManager.registerAction(
new ExecuteCodeAction(ActionManager.OnPointerOutTrigger, () => {
board.disableEdgesRendering();
})
);
}
}