Changing animations

This commit is contained in:
2022-01-29 16:49:45 +03:00
parent a85a7eda4a
commit ce6fc1a0eb
3 changed files with 69 additions and 11 deletions

38
src/MockupModel.js Normal file
View File

@@ -0,0 +1,38 @@
import { Group } from 'three';
export default class MockupModel extends Group {
constructor() {
super();
this.speed = {
x: 0,
y: 0,
z: 0,
};
this.acceleration = {
x: 0,
y: 0,
z: 0,
};
}
floatAnim() {
const maxSpeed = 0.5;
if (this.position.y < -2) {
this.acceleration.y = 0.02;
}
if (this.position.y > 2) {
this.acceleration.y = -0.02;
}
this.speed.y = Math.min(this.speed.y + this.acceleration.y, maxSpeed);
this.position.y += this.speed.y;
}
rotateAnim() {
this.rotation.y += 0.02;
}
}