Rectangle Gui around viewport mini camera

Hi, you have method fait make rect arround mini camera viewport ?

line 388
click in corner right :smiley:

I am not sure what you are trying to achieve ???

cc @carolhmj

You can get there with a bit of math :slight_smile: GUI Viewport Outline | Babylon.js Playground (babylonjs.com)

2 Likes

LoL. Whenever I read ‘Maths’ it makes me nervous :grin:
You should have said “you can get there with just very little effort to make it responsive and match your needs”. And then, not as if you didn’t already do most of the job, so it’s now as close as can be to a copy/paste :smile:

@carolhmj, thanks a lot I completely misunderstood the request…

Thanks for your help, SOLVED thanks to you to all of you :DDD

var rect3 = new BABYLON.GUI.Rectangle();
rect3.color = "red";
rect3.thickness = 4;

rect3.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
rect3.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_BOTTOM;

rect3.width = minicamera.viewport.width;
rect3.height = minicamera.viewport.height;
rect3.left = minicamera.viewport.x * 100 + "%";
rect3.top = minicamera.viewport.y * 100 + "%";

console.log("viewport : " + "width = " + minicamera.viewport.width + "; height = " + minicamera.viewport.height + "; x = " + minicamera.viewport.x + "; y = " + minicamera.viewport.y);

advancedTexture.addControl(rect3);
1 Like