Want to show plane

I want to render an object having a large size in a small area of canvas how can I achieve that?
Currently facing issue to render the object in a small area if I enlarge the Canvas size its showing perfectly as in attached image.

But If I am reducing the size of the canvas it’s not showing the proper view of object
as in the attached image.

Have you added this into your code?

// Watch for browser/canvas resize events
window.addEventListener("resize", function () {
        engine.resize();
});
1 Like

No I haven’t try this

Not working with this solution it is not fit in the window properly

Object with less size is looking so far
image

Object with bigger size is looking perfect
image

But in my case, both should look perfect even if the size of the objects is smaller or bigger

It is not clear what you are trying to achieve.

This is to be expected in 3D. In the following playground the sphere in the middle and the one on the right (sphere2) are the same size, sphere 2 is further away. The sphere on the left (sphere3) is smaller than the other two spheres but is the around the same distance from the camera as the middle sphere and higher than it.

When you are viewing the playground change the size of the browser, the scene looks the same as you alter the size of the browser. Is this what you are trying to achieve?

If so then this is achieved using

// Watch for browser/canvas resize events
window.addEventListener("resize", function () {
        engine.resize();
});

To see where to use it see

If it is not working in 3D Stack View there maybe a property of 3D Stack View that overrides it.

But what about camera position its looking so far just because of setPosition of camera

That is true, the further away the camera the smaller the mesh will appear.

Sorry but I really do not understand what you are trying to achieve. Hopefully someone else will.

I have two objects of different sizes Object A is smaller and Object B is bigger if my camera position is the same for both A and B objects then they should visible at the same position, so what will be the position of the camera in which both objects looks fitted to screen

I believe you are mixing camera position, camera target and camera zoom. You have to mind the 3D environment. If you want a smaller object to fit in the camera view the same size as a larger object, you only have two choice:

  1. Make both object the same size (by changing the scaling of one or the other)
  2. Change the camera zoom on the target (and/or eventually position) depending on the object size.

Changing the size of the canvas or resizing the window won’t do anything. A smaller object will always look smaller than the bigger one, except for using one of the two methods above.

Unfortunately your intention is still not clear to me.

Do you mean

Given two (or more) meshes how do I position the camera so that all meshes are visible and as large as possible.

For example

If this is what you need then I do not know how to do this automatically. Someone else might.

Okay, thank you!

Please say whether this describes your needs accurately so that other know if this is your problem or not

Hello @Bhavna just checking in, was your question answered?