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

Fix wrong physical speed and animations jitter in low fps issues ( Make them "frame rate independent" ). ( 2nd try ) #3648

Closed
wants to merge 24 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dev
gonnavis committed Aug 16, 2022
commit 3224a17409693455c365b74266859d4db79bd655
3 changes: 3 additions & 0 deletions avatar-spriter.js
Original file line number Diff line number Diff line change
@@ -549,6 +549,7 @@ class SpriteMegaAvatarMesh extends THREE.Mesh {

// select the texture
const spriteSpecName = (() => {
debugger
const playerSide = _getPlayerSide();
const currentSpeed = localVector.set(avatar.velocity.x * velocityScaleFactor, 0, avatar.velocity.z * velocityScaleFactor)
.length();
@@ -636,6 +637,7 @@ class SpriteMegaAvatarMesh extends THREE.Mesh {
}
})();
this.setTexture(spriteSpecName);
console.log(spriteSpecName)

if (spriteSpecName !== this.lastSpriteSpecName) {
this.lastSpriteSpecName = spriteSpecName;
@@ -805,6 +807,7 @@ const getSpriteSpecs = () => {
return {
reset() {},
update(timestamp, timeDiffMs) {
// debugger
positionOffset -= walkSpeed/1000 * timeDiffMs;

const euler = new THREE.Euler(0, angle, 0, 'YXZ');
11 changes: 8 additions & 3 deletions avatars/avatars.js
Original file line number Diff line number Diff line change
@@ -1516,8 +1516,8 @@ class Avatar {
this.testVelocity.y *= -1;
if (!isBoundPlayer) {
this.velocity.copy(this.testVelocity);
this.velocity.x *= 1 / 3; // walk speed 2.5
this.velocity.z *= 1 / 3; // walk speed 2.5
// this.velocity.x *= 1 / 3; // walk speed 2.5 // wrong, don't need modify.SS
// this.velocity.z *= 1 / 3; // walk speed 2.5 // wrong, don't need modify.SS
}
// this.velocity.applyEuler(localEuler);
this.direction.copy(positionDiff).normalize();
@@ -1527,6 +1527,7 @@ class Avatar {
this.lastMoveTime = timestamp;
}
// if (this.velocity.x > 100) debugger
// if (this.velocity.x === 2.5) debugger
}

update(timestamp, timeDiff, isBoundPlayer = true) {
@@ -1552,7 +1553,10 @@ class Avatar {

this.idleWalkFactor = Math.min(Math.max((currentSpeed - idleSpeed) / (walkSpeed - idleSpeed), 0), 1);
this.walkRunFactor = Math.min(Math.max((currentSpeed - walkSpeed) / (runSpeed - walkSpeed), 0), 1);
if (this.idleWalkFactor >= 0.9 && this.walkRunFactor < 1 && this.velocity.x > 0.1) console.log( this.velocity.x)
// if (this.idleWalkFactor >= 0.9 && this.walkRunFactor < 1 && this.velocity.x > 0.1) {
// console.log( this.velocity.x)
// debugger
// }
// console.log(this.walkRunFactor)
// console.log(this.idleWalkFactor, this.walkRunFactor)
this.crouchFactor = Math.min(Math.max(1 - (this.crouchTime / crouchMaxTime), 0), 1);
@@ -1889,6 +1893,7 @@ class Avatar {

const _updateSubAvatars = () => {
if (this.spriteMegaAvatarMesh) {
// debugger
this.spriteMegaAvatarMesh.update(timestamp, timeDiff, {
playerAvatar: this,
camera,