Giter Site home page Giter Site logo

Comments (5)

Samstiles avatar Samstiles commented on May 27, 2024

Here is the slow movement follow issue

...The very slow transition makes the game feel very slow and disconnected from the character:

gif

from camera-controls.

Samstiles avatar Samstiles commented on May 27, 2024

Here is the "over rotating and lerping in the opposite direction of the mouse movement" issue:

gif

And my camera rotation logic:

        // in my camera  constructor
        document.addEventListener("mousemove", (event: MouseEvent) => {
            if (VulpineMiscUtils.IsUndefinedOrNull(this._tagCamera)) return;

            if (GameClient.PointerLock.PointerIsLocked() === true) {
                const { movementX: horizontalMovement, movementY: verticalMovement } = event;

                this._characterFollowLateralAngle += horizontalMovement * Config.Camera.MouseSensitivity;
                this._characterFollowVerticalAngle += verticalMovement * Config.Camera.MouseSensitivity;

                this._characterFollowVerticalAngle = VulpineMathUtils.Clamp(
                    this._characterFollowVerticalAngle,
                    VulpineMathUtils.DegToRads(Config.Camera.CameraPitchDegreesMin),
                    VulpineMathUtils.DegToRads(Config.Camera.CameraPitchDegreesMax)
                );
        });
                // in my update loop

                this._nextCameraLookDirection.x =
                    Math.cos(this._characterFollowLateralAngle - Math.PI / 2) * Math.cos(this._characterFollowVerticalAngle);
                this._nextCameraLookDirection.y = Math.sin(this._characterFollowVerticalAngle);
                this._nextCameraLookDirection.z =
                    Math.sin(this._characterFollowLateralAngle - Math.PI / 2) * Math.cos(this._characterFollowVerticalAngle);

                this._nextCameraPosition.x =
                    this._followTargetObject!.position.x + this._nextCameraLookDirection.x * this._characterFollowDistance;
                this._nextCameraPosition.y =
                    this._followTargetObject!.position.y + this._nextCameraLookDirection.y * this._characterFollowDistance;
                this._nextCameraPosition.z =
                    this._followTargetObject!.position.z + this._nextCameraLookDirection.z * this._characterFollowDistance;

                this._cameraControls.lerpLookAt(
                    this._currentCameraPosition.x,
                    this._currentCameraPosition.y,
                    this._currentCameraPosition.z,
                    this._lastKnownTargetPosition.x,
                    this._lastKnownTargetPosition.y,
                    this._lastKnownTargetPosition.z,
                    this._nextCameraPosition.x,
                    this._nextCameraPosition.y,
                    this._nextCameraPosition.z,
                    this._followTargetObject!.position.x,
                    this._followTargetObject!.position.y + this.cameraLookAtVerticalOffset,
                    this._followTargetObject!.position.z,
                    10,
                    true
                );
                
                

                this._currentCameraLookDirection.copy(this._nextCameraLookDirection);
                this._currentCameraPosition.copy(this._nextCameraPosition);
                this._lastKnownTargetPosition.copy(this._followTargetObject!.position);

                this._cameraControls.update(deltaTimeS);

from camera-controls.

yomotsu avatar yomotsu commented on May 27, 2024

Thanks for using camera-controls.
To solve that delay, you can set 0 to the smoothness value

cameraControlsInstance.smoothTime = 0;
cameraControlsInstance.draggingSmoothTime = 0;

Also, check the third-person demo in the example section and the docs for further information.

from camera-controls.

Samstiles avatar Samstiles commented on May 27, 2024

Thank you @yomotsu ! Your library is wonderful and I'm enjoying using it.

I have sped up the lerp speed using the parameters you describe above.

I solved my other problem - the over-rotation - by capping how much the camera is allowed to rotate each frame :)

5月にあなたの美しい国に旅行します! 長野と山梨の地域でハイキングする予定です。 あなたの文化と景色を体験することを楽しみにしています。

camera-controls に再び感謝します!

from camera-controls.

yomotsu avatar yomotsu commented on May 27, 2024

It's good to hear that.

May is one of the best months to visit! Altho, temperatures have been on the rise in recent years.
(My parents in law live in 山梨 btw...)
いい旅を。

let me close the issue then.

from camera-controls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.