I set the layermask property in sprites and defined a second camera, but it has no effect.
You are going to need to put up a PG for something complicated like that. You will also need to adjust the layermask of the cameras & possibly lights as well. Also what is the effect wanted in the first place?
sorry, This is PG
var secondCamera = new BABYLON.FreeCamera(“GunSightCamera”, new BABYLON.Vector3(0, 0, -50), scene);
secondCamera.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA;
secondCamera.layerMask = 0x20000000;
var spriteManagerPlayer = new BABYLON.SpriteManager(“playerManager”, “textures/player.png”, 2, 64, scene);
var player = new BABYLON.Sprite(“player”, spriteManagerPlayer);
player.playAnimation(0, 40, true, 100);
player.position.y = -2.3;
player.size = 2;
player.isPickable = true;
player.layerMask = 0x20000000;
It look like no effect.
Yep, now that I can see some example, I checked into it. Anybody can write ‘I mixed A with B and did not get C.’ Nobody looks until there is something behind it.
The source for Sprite shows the class is not a subclass of something else & does not even get a search hit for
layerMask, so that is not going to do anything. I also saw the gunsight. That was one of the few doc pages I wrote & it did not move with the scene camera, so it was also being applied correctly.
Looking in other classes of the sprite sub-dir, the file spriteManager.ts does have
layermask in the interface
I changed the layermask of the manager, and I definitely get an effect, https://www.babylonjs-playground.com/index.html#2GXKNW#87. The effect is to disappear, but then that happens to the ground as well. Probably some tweaking to either camera or sprite position needed.
(Wow, I spelled tweaking wrong in firefox, and first in the correction list was twerking).
Did not read the api carefully, this is my mistake.