Replace animationPaused with animationSpeed
This commit is contained in:
parent
0c8a8b627a
commit
5992d3e68d
|
@ -58,7 +58,7 @@ Three.js powered Minecraft skin viewer.
|
||||||
// Pause single animation
|
// Pause single animation
|
||||||
run.paused = true;
|
run.paused = true;
|
||||||
// Pause all animations!
|
// Pause all animations!
|
||||||
skinViewer.animationPaused = true;
|
skinViewer.animationSpeed = 0;
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,8 @@
|
||||||
// skinViewer.playerObject.skin.slim = true;
|
// skinViewer.playerObject.skin.slim = true;
|
||||||
|
|
||||||
let control = new skinview3d.createOrbitControls(skinViewer);
|
let control = new skinview3d.createOrbitControls(skinViewer);
|
||||||
skinViewer.animation = new skinview3d.CompositeAnimation();
|
skinViewer.animation = skinview3d.WalkingAnimation;
|
||||||
|
skinViewer.animationSpeed = 1.5;
|
||||||
let walk = skinViewer.animation.add(skinview3d.WalkingAnimation);
|
|
||||||
walk.speed = 1.5;
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ export class SkinViewer {
|
||||||
public readonly domElement: Node;
|
public readonly domElement: Node;
|
||||||
public animation: Animation | null;
|
public animation: Animation | null;
|
||||||
public detectModel: boolean = true;
|
public detectModel: boolean = true;
|
||||||
public animationPaused: boolean = false;
|
public animationSpeed: number = 1;
|
||||||
public animationTime: number = 0;
|
public animationTime: number = 0;
|
||||||
public disposed: boolean = false;
|
public disposed: boolean = false;
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ export class SkinViewer {
|
||||||
|
|
||||||
public readonly playerObject: PlayerObject;
|
public readonly playerObject: PlayerObject;
|
||||||
|
|
||||||
|
private readonly clock: THREE.Clock;
|
||||||
|
|
||||||
constructor(options: SkinViewerOptions) {
|
constructor(options: SkinViewerOptions) {
|
||||||
this.domElement = options.domElement;
|
this.domElement = options.domElement;
|
||||||
this.animation = options.animation || null;
|
this.animation = options.animation || null;
|
||||||
|
@ -114,14 +116,13 @@ export class SkinViewer {
|
||||||
if (options.width) this.width = options.width;
|
if (options.width) this.width = options.width;
|
||||||
if (options.height) this.height = options.height;
|
if (options.height) this.height = options.height;
|
||||||
|
|
||||||
|
this.clock = new THREE.Clock(true);
|
||||||
const draw = () => {
|
const draw = () => {
|
||||||
if (this.disposed) return;
|
if (this.disposed) return;
|
||||||
window.requestAnimationFrame(draw);
|
window.requestAnimationFrame(draw);
|
||||||
if (!this.animationPaused) {
|
this.animationTime += this.clock.getDelta() * this.animationSpeed;
|
||||||
this.animationTime++;
|
if (this.animation) {
|
||||||
if (this.animation) {
|
invokeAnimation(this.animation, this.playerObject, this.animationTime);
|
||||||
invokeAnimation(this.animation, this.playerObject, this.animationTime / 100.0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.renderer.render(this.scene, this.camera);
|
this.renderer.render(this.scene, this.camera);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue