Skip to content

Tilde grabbing: bug fixes#3714

Closed
patriboz wants to merge 3 commits intomasterfrom
patriboz/tilde-grabbing
Closed

Tilde grabbing: bug fixes#3714
patriboz wants to merge 3 commits intomasterfrom
patriboz/tilde-grabbing

Conversation

@patriboz
Copy link
Contributor

@patriboz patriboz commented Sep 16, 2022

This PR fixes the following issues when editing scenes:

- Grabbed object transform out of sync
object.updateMatrixWorld was called before the transform, which caused jitters.

- Collisions
Querying only forward collision resulted in the object going into the ground when the distance from localPlayer to collision point was bigger than the grab offset. I added downCollision to prevent that. By raycasting from object perpendicularly down returns the collision point with the ground. object.position.y will then be clamped to be >= point.y.

- Pivot point
Before, the grabbed object was moved around camera.position as pivot point. When 3rd person mode was entered, the object would move backwards with the camera. To prevent that I set the pivot point at localPlayer.position.

Videos
Before:
https://user-images.githubusercontent.com/49231818/190644219-ac9d3d79-9afb-4f5a-8b63-4cdb7ca29c0a.mp4

After:
https://user-images.githubusercontent.com/49231818/190644313-43e0136b-d9ec-4176-ab56-8b49381b403e.mp4

@patriboz patriboz mentioned this pull request Sep 16, 2022
@patriboz patriboz requested a review from jakezira September 16, 2022 10:28
this.addAction(grabAction);

physicsScene.disableAppPhysics(app)
if(this instanceof LocalPlayer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need spacing.
Why is this check needed?

Copy link
Contributor Author

@patriboz patriboz Sep 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

position = h.position;
quaternion = h.quaternion;
} else {
position = this.position;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was wrong with previous implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before, the grabbed object was moved around camera.position as pivot point. When 3rd person mode was entered, the object would move backwards with the camera. To prevent that I set the pivot point at localPlayer.position.

game.js Outdated
// .add(localVector2.set(0, 0.01, 0));
const collision =
collisionEnabled && physicsScene.raycast(localVector, localQuaternion);
localQuaternion2.setFromAxisAngle(localVector2.set(1, 0, 0), -Math.PI * 0.5);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct indentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@lalalune
Copy link
Contributor

@patriboz please review #3717

@patriboz patriboz closed this Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants