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]: FlyCameraController在初始化后setCamera不生效 #362

Open
OriIIusion opened this issue Jan 26, 2024 · 2 comments
Open

[BUG]: FlyCameraController在初始化后setCamera不生效 #362

OriIIusion opened this issue Jan 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@OriIIusion
Copy link
Contributor

Bug描述

想通过dat.gui按钮来设置一下FlyCameraController.setCamera(),发现不起作用。
刚创建相机时 调用FlyCameraController.setCamera()可以生效,使用dat.gui按钮就不生效了。
但是HoverCameraController却可以在dat.gui中setCamera。

Bug复现流程

通过以下步骤产生bug:

  1. 打开我创建的案例 https://codepen.io/OriIIusion/pen/MWxOeVJ
  2. 默认使用的是fly相机,点击flyCamera列表下的五个按钮,画面无反应
  3. 点击ChangeCamera列表下的hoverCamera,可以切换到hover相机
  4. 点击hoverCamera列表下的五个按钮,可跳转镜头。

期待的结果

希望fly相机可以和hover相机一样跳转镜头

代码示例

https://codepen.io/OriIIusion/pen/MWxOeVJ

其他信息

fly相机点击5个按钮后,可以在控制台看到FlyCameraController.targetPos和FlyCameraController.lookAtPos已经改变,但是相机本身的position和rotation却不改变

@OriIIusion OriIIusion added the bug Something isn't working label Jan 26, 2024
@ID-Emmett
Copy link

我看了下源码,在FlyCameraController组件中,通过setCamera设置的targetPoslookAtPos在初始化时通过lookAt指定了相机位置和朝向,在此后,可以通过按键F手动更新。

但朝向设置可能有点问题,因为朝向更新是根据鼠标指针设置相机欧拉角旋转,通过按键F手动更新相机位置和朝向时,如果在这之前鼠标指针修改了欧拉角旋转,那么相机的欧拉角旋转会与lookAt设置的四元数旋转产生冲突,在这里的优先级为欧拉角,所以手动更新后,相机的朝向可能不会改变。

@OriIIusion
Copy link
Contributor Author

感谢大佬解释!

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