How to change the distance of camera?

I want to change the far or near of the camera without changing its position. Which parameter in the camera should I change.As shown in the following figure:

Hello @619944680,

It’s unclear from your post what you would like to do. The title of your post is “how to change the distance of camera” but then you mention “without changing its position.” Also, the Camera class does not have a far plane member variable. It is only possible to change the near limit.

Perhaps you are referring to the width and height of the aspect ratio? More specifically, are you trying to do a zoom operation but you would like the camera position to remain the same and thus only change the width and height attributes of the camera?

Thanks,
Tino

Yes,perhaps my expression was not very accurate.But you’re right.I’m trying to do a zoom operation but I would like the camera position to remain the same.I have tried multiplying the width and height attributes of the camera by a fixed value before.


But sometimes the model seems to be cut, so I want to know what properties can be changed to make the distance farther or closer when scaling?

Based on the image you provided, it looks like the near plane of the camera is clipping the model. By default, the near limit is set to 0.01 in the Web Viewer. Depending on the model in question, you may have to increase or decrease this value.

1 Like

But I still have this issue with increase or decrease the value of nearlimit.Is there any other way to zoom, but the camera position to remain unchanged?

Hello @619944680,

Well, if you would like to just do a simple operation of zooming the camera, you can modify the width and height attributes of the camera directly and leave the position unchanged:

var cam = hwv.view.getCamera();
cam.setHeight(cam.getHeight()*.5);
cam.setWidth(cam.getWidth()*.5);
hwv.view.setCamera(cam);

Worth noting is that the zoom operator in Communicator, by default, changes the position of the camera to maintain a specific ratio relative to the field width. For example, a ratio of 2.5 means that the distance to the target of the camera is 2.5 times the width. Sometimes the ratio is 1. Without moving the camera appropriately, setting the width of the camera to very large values can lead to rendering issues.

Thanks,
Tino