Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: 通过HoverCameraController组件的setCamera方法设置相机视角,当视角接近地面部分(y接近0时),鼠标滚轮缩放异常 #460

Open
ZhengWeiming233 opened this issue Dec 30, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@ZhengWeiming233
Copy link

Bug描述

通过HoverCameraController组件的setCamera方法设置相机视角,当视角参数的y坐标明显大于0很多时如20(或者distance距离过远时如600),鼠标缩放到接近y为0的高度时,滑轮缩放比例异常,十分缓慢,无法缩放到模型地表。

Bug复现流程

通过以下步骤产生bug:

  1. 创建 一个模型,模型坐标为(0,0,0),同时添加相机组件如HoverCameraController,通过setCamera方法设置相机视角。 view: {
    x: -200.84649658203125,
    y: 0.11393391340970993,
    z: 38.04443359375,
    pitch: -67.58179999999754,
    roll: 181.29546000801645,
    distance: 670.7881136027783
    },
  2. 鼠标滑动至模型地表(接近0)的部分,鼠标滑轮缩放比例异常,始终无法靠近模型地面部分。

期待的结果

鼠标滑轮缩放正常,能正常缩放至地表。

报错截图

12.30.1.mp4

测试引擎版本:

本地运行出错的Orillusion引擎版本, "@orillusion/core": "^0.8.4"

本机系统 (请填写完整):

  • OS: [windows10]
  • Browser: [edge]
  • Version: [e.g. 版本 131.0.2903.112 (正式版本) (64 位)]

本机配置

  • CPU: CPU Hygon C86 3350 8-coreProcessor
  • Graphics Card: GTX 4000

代码示例

image

@ZhengWeiming233 ZhengWeiming233 added the bug Something isn't working label Dec 30, 2024
@ZhengWeiming233 ZhengWeiming233 changed the title [BUG]: 通过 [BUG]: 通过HoverCameraController组件的setCamera方法设置相机视角,当视角接近地面部分(y接近0时),鼠标滚轮缩放异常 Dec 30, 2024
@lslzl3000
Copy link
Collaborator

lslzl3000 commented Dec 30, 2024

HoverCameraController 的缩放距离受 minDistancemaxDistance 限制

private onMouseWheel(e: PointerEvent3D) {
        if (!this.enable) return;
        this._wheelStep = (this.wheelStep * Vector3Ex.distance(this._currentPos.transform.worldPosition, this.camera.transform.worldPosition)) / 10;
        this.distance -= Engine3D.inputSystem.wheelDelta * this._wheelStep;
        this.distance = clamp(this.distance, this.minDistance, this.maxDistance);
    }

minDistance 默认值是 0.1,如果场景尺寸非常小,可以适当调小这个值,或者推荐将整体场景进行适当放大

@ZhengWeiming233
Copy link
Author

HoverCameraController 的缩放距离受 minDistancemaxDistance 限制

private onMouseWheel(e: PointerEvent3D) {
        if (!this.enable) return;
        this._wheelStep = (this.wheelStep * Vector3Ex.distance(this._currentPos.transform.worldPosition, this.camera.transform.worldPosition)) / 10;
        this.distance -= Engine3D.inputSystem.wheelDelta * this._wheelStep;
        this.distance = clamp(this.distance, this.minDistance, this.maxDistance);
    }

minDistance 默认值是 0.1,如果场景尺寸非常小,可以适当调小这个值,或者推荐将整体场景进行适当放大

您好,我把该数值调整到了0.01,但在靠近地表的部分缩放仍然很吃力

@lslzl3000
Copy link
Collaborator

lslzl3000 commented Jan 1, 2025

目测应该还是尺寸太小的原因,0.01相对模型还是太大了,而且好像原点都不一定在地板上,可以把模型zip上传一下,我们看一下模型具体尺寸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants