mirror of
https://github.com/anatolykopyl/vue-three-d-mockup.git
synced 2026-03-26 12:55:08 +00:00
Changing animations
This commit is contained in:
38
src/MockupModel.js
Normal file
38
src/MockupModel.js
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user