-
Notifications
You must be signed in to change notification settings - Fork 210
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
Character controller #1856
Character controller #1856
Conversation
app-manager.js
Outdated
@@ -543,9 +543,16 @@ class AppManager extends EventTarget { | |||
physicsObject.position.copy(app.position); | |||
physicsObject.quaternion.copy(app.quaternion); | |||
physicsObject.scale.copy(app.scale); | |||
|
|||
if(app.appType === "vrm") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
App manager should not be aware of app type. This code belongs in the loader.
character-physics.js
Outdated
class CharacterPhysics { | ||
constructor(player) { | ||
this.player = player; | ||
this.rb = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is rb
?
character-physics.js
Outdated
|
||
const collision = this.collideCapsule(localVector, localQuaternion2.set(0, 0, 0, 1)); | ||
const capsuleOffset = new THREE.Vector3(0, this.player.avatar.height/2, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not allocate here, since I think it is part of the render loop.
character-physics.js
Outdated
const collision = this.collideCapsule(localVector, localQuaternion2.set(0, 0, 0, 1)); | ||
const capsuleOffset = new THREE.Vector3(0, this.player.avatar.height/2, 0); | ||
localVector.add(capsuleOffset); | ||
const collision = this.collideCapsule(localVector, localQuaternion2.set(0, 0, 0, 1)); // TODO: Replace with physicsManager.isGrounded restitution check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not collide physics here. This should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't think isGrounded
is something you can ask after the simulation.
Grounded state must come from the simulation itself, not after. After the simulation returns, we don't know if we are truly grounded since the state has already been restituted and that knowledge has been lost.
character-physics.js
Outdated
@@ -156,6 +176,8 @@ class CharacterPhysics { | |||
localVector.y += 1; | |||
localQuaternion.premultiply(localQuaternion2.setFromAxisAngle(localVector3.set(0, 1, 0), Math.PI)); | |||
} | |||
const feetOffset = new THREE.Vector3(0, 0.05, 0); // Or feet will be in ground, only cosmetical, works for all avatars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More allocation.
character-physics.js
Outdated
} | ||
updateTransform() { | ||
if(this.rb) { | ||
const physicsObjects2 = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allocation in the render loop?
character-physics.js
Outdated
updateVelocity() { | ||
if(this.player.avatar) { | ||
if(this.rb) { | ||
physicsManager.setVelocity(this.rb, this.velocity.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allocation from .clone()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More code issues to fix.
I suspect they will affect functionality (for the better) once fixed.
The CCD works fine within its domain. The issues that appear in it are purely fps based depending on each scene. I have attached few examples how fps affect the performance of avatar. 1-On 60 or more fps, everything works perfectly fine without any kind of issues/jitter. Just as fps drop, The issues such as jitter while walking/running appear. -On 60 fps(no jitter issues.) WhatsApp.Video.2021-11-29.at.8.35.42.PM.mp4-FPS drop in the same scene causing jitter WhatsApp.Video.2021-11-29.at.8.35.42.PM.1.mp4-No issue in scenes like prototype, grid where fps remain stable at above 60. WhatsApp.Video.2021-11-29.at.8.35.42.PM.2.mp4-Jitter drop in high requirement scenes causes issues. WhatsApp.Video.2021-11-29.at.8.44.11.PM.1.mp4IMO the issues related to this PR are resolved, The FPS related issues should be fixed separately. The CCD can be pushed to production. |
FPS has improved for me.. |
@avaer The CCD related issue are fixed. What is left is FPS related issues. Kindly review it for final verdict. |
|
small code changes
No description provided.