Move 'export' to where the variable is defined

This commit is contained in:
yushijinhun 2018-08-16 19:07:46 +08:00
parent d3a2fe473f
commit 11d0b93723
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4
4 changed files with 12 additions and 26 deletions

View File

@ -1,6 +1,6 @@
import { PlayerObject } from "./model";
function invokeAnimation(animation: Animation, player: PlayerObject, time: number) {
export function invokeAnimation(animation: Animation, player: PlayerObject, time: number) {
if (animation instanceof CompositeAnimation) {
animation.play(player, time);
} else if (animation instanceof Function) {
@ -60,7 +60,7 @@ export class AnimationHandle implements IAnimation {
}
}
class CompositeAnimation {
export class CompositeAnimation {
handles: Set<AnimationHandle>;
@ -78,7 +78,7 @@ class CompositeAnimation {
}
}
const WalkingAnimation: Animation = (player: PlayerObject, time: number) => {
export const WalkingAnimation: Animation = (player: PlayerObject, time: number) => {
const skin = player.skin;
// Multiply by animation's natural speed
@ -104,7 +104,7 @@ const WalkingAnimation: Animation = (player: PlayerObject, time: number) => {
player.cape.rotation.x = Math.sin(time / 1.5) * 0.06 + basicCapeRotationX;
};
const RunningAnimation: Animation = (player: PlayerObject, time: number) => {
export const RunningAnimation: Animation = (player: PlayerObject, time: number) => {
const skin = player.skin;
time *= 15;
@ -137,14 +137,6 @@ const RunningAnimation: Animation = (player: PlayerObject, time: number) => {
// You shouldn't glance right and left when running dude :P
};
const RotatingAnimation: Animation = (player: PlayerObject, time: number) => {
export const RotatingAnimation: Animation = (player: PlayerObject, time: number) => {
player.rotation.y = time;
};
export {
CompositeAnimation,
invokeAnimation,
WalkingAnimation,
RunningAnimation,
RotatingAnimation
};

View File

@ -41,7 +41,7 @@ function setVertices(box: THREE.BoxGeometry, top: Array<THREE.Vector2>, bottom:
// why is this a global constant?
const esp = 0.002;
class SkinObject extends THREE.Group {
export class SkinObject extends THREE.Group {
// body parts
head: THREE.Group;
@ -348,7 +348,7 @@ class SkinObject extends THREE.Group {
}
}
class CapeObject extends THREE.Group {
export class CapeObject extends THREE.Group {
cape: THREE.Mesh;
@ -373,7 +373,7 @@ class CapeObject extends THREE.Group {
}
}
class PlayerObject extends THREE.Group {
export class PlayerObject extends THREE.Group {
skin: SkinObject;
cape: CapeObject;
@ -393,5 +393,3 @@ class PlayerObject extends THREE.Group {
this.add(this.cape);
}
}
export { SkinObject, CapeObject, PlayerObject };

View File

@ -82,7 +82,7 @@ function convertSkinTo1_8(context, width) {
copySkin(52, 20, 4, 12, 44, 52, true); // Back Arm
}
function loadSkinToCanvas(canvas, image) {
export function loadSkinToCanvas(canvas, image) {
let isOldFormat = false;
if (image.width !== image.height) {
if (image.width === 2 * image.height) {
@ -108,7 +108,7 @@ function loadSkinToCanvas(canvas, image) {
}
}
function loadCapeToCanvas(canvas, image) {
export function loadCapeToCanvas(canvas, image) {
let isOldFormat = false;
if (image.width !== 2 * image.height) {
if (image.width * 17 === image.height * 22) {
@ -132,7 +132,7 @@ function loadCapeToCanvas(canvas, image) {
context.drawImage(image, 0, 0, image.width, image.height);
}
function isSlimSkin(canvasOrImage) {
export function isSlimSkin(canvasOrImage) {
// Detects whether the skin is default or slim.
//
// The right arm area of *default* skins:
@ -192,5 +192,3 @@ function isSlimSkin(canvasOrImage) {
throw new Error(`Illegal argument: ${canvasOrImage}`);
}
}
export { isSlimSkin, loadSkinToCanvas, loadCapeToCanvas };

View File

@ -3,7 +3,7 @@ import { PlayerObject } from "./model";
import { invokeAnimation } from "./animation";
import { loadSkinToCanvas, loadCapeToCanvas, isSlimSkin } from "./utils";
class SkinViewer {
export class SkinViewer {
public domElement: HTMLElement;
public animation: Animation;
@ -165,5 +165,3 @@ class SkinViewer {
this.setSize(this.width, newHeight);
}
}
export { SkinViewer };