again on my journey toward babylon, I am stuck on a point where I need to hide meshes from second camera, I am using layer mask like this:
var firstCamera = new BABYLON.ArcRotateCamera('firstCamera', 0, 2.3, 32, BABYLON.Vector3.Zero(), scene);
firstCamera.layerMask = 0x10000000;
var secondCamera = new BABYLON.ArcRotateCamera('secondCamera', 0, 2.3, 32, BABYLON.Vector3.Zero(), scene);
secondCamera.layerMask = 0x20000000;
and to show a a unique mesh on each camera, I am assigning layerMask like this firstMesh.layerMask = 0x10000000; secondMesh.layerMask = 0x20000000;
I want to show first Mesh also on second camera, something like maybe layerMask takes an array? : firstMesh.layerMask = [0x10000000 , 0x20000000 ]; secondMesh.layerMask = 0x20000000;
how could I achieve that?
p.s, second question: how can I capture if my mouse is hovering over firstCamera or secondCamera? , for secondCamera I am using viewport secondCamera.viewport = new BABYLON.Viewport(0, 0, (2) / (canvas.width / 100) / 1.2,(2) / (canvas.height / 100) / 1.2);
any idea how can I capture mouseEnter/Leave events
what I want to accomplish is, when I hover on second camera it should set scene.cameraToUseForPointers = secondCamera; and when mouse Leave secondCamera it should set scene.cameraToUseForPointers = camera;
@sebavan I think you are suggesting it to add on move?
scene.onPointerMove = function (evt, pickResult) {
// do something with scene.pointerX here ?
};
isn’t scene.pointerY/X values different on each screen? and, also will that work on touch event? could you please example in PG https://playground.babylonjs.com/#1RI2YK#4 , Thanks
So the screen will be different but if you use a viewport of 0.5 for the width you know that if pointerX > engine.getRenderingWidth() / 2 you would be into it. you could apply the same on y.
Thanks @sebavan, I was getting undefined error with engine.getRenderingWidth so I used canvas.widthand later found its engine.getRenderWidth, but seems my mind is stuck on this simple math calculation. I have setup a viewport like this
let viewSizeX = (2 / (canvas.width / 100) / 1.2);
let viewSizeY = (2 / (canvas.height / 100) / 1.2);
secondCamera.viewport = new BABYLON.Viewport(0, 0, viewSizeX ,viewSizeY);
scene.onPointerMove = function (evt, pickResult) {
let whatX = ?
let whatY = ?
if(scene.pointerX << whatX && scene.pointerY << whatY){
}
};
The issue I am facing is, scene.pointerX/Y coordinates start from top left corner of screen, while viewport’s start from bottom left corner, so trying to figure out how to calculate this.