Move 'export' to where the variable is defined
This commit is contained in:
parent
d3a2fe473f
commit
11d0b93723
|
|
@ -1,6 +1,6 @@
|
||||||
import { PlayerObject } from "./model";
|
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) {
|
if (animation instanceof CompositeAnimation) {
|
||||||
animation.play(player, time);
|
animation.play(player, time);
|
||||||
} else if (animation instanceof Function) {
|
} else if (animation instanceof Function) {
|
||||||
|
|
@ -60,7 +60,7 @@ export class AnimationHandle implements IAnimation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CompositeAnimation {
|
export class CompositeAnimation {
|
||||||
|
|
||||||
handles: Set<AnimationHandle>;
|
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;
|
const skin = player.skin;
|
||||||
|
|
||||||
// Multiply by animation's natural speed
|
// 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;
|
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;
|
const skin = player.skin;
|
||||||
|
|
||||||
time *= 15;
|
time *= 15;
|
||||||
|
|
@ -137,14 +137,6 @@ const RunningAnimation: Animation = (player: PlayerObject, time: number) => {
|
||||||
// You shouldn't glance right and left when running dude :P
|
// 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;
|
player.rotation.y = time;
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
|
||||||
CompositeAnimation,
|
|
||||||
invokeAnimation,
|
|
||||||
WalkingAnimation,
|
|
||||||
RunningAnimation,
|
|
||||||
RotatingAnimation
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ function setVertices(box: THREE.BoxGeometry, top: Array<THREE.Vector2>, bottom:
|
||||||
// why is this a global constant?
|
// why is this a global constant?
|
||||||
const esp = 0.002;
|
const esp = 0.002;
|
||||||
|
|
||||||
class SkinObject extends THREE.Group {
|
export class SkinObject extends THREE.Group {
|
||||||
|
|
||||||
// body parts
|
// body parts
|
||||||
head: THREE.Group;
|
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;
|
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;
|
skin: SkinObject;
|
||||||
cape: CapeObject;
|
cape: CapeObject;
|
||||||
|
|
@ -393,5 +393,3 @@ class PlayerObject extends THREE.Group {
|
||||||
this.add(this.cape);
|
this.add(this.cape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { SkinObject, CapeObject, PlayerObject };
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ function convertSkinTo1_8(context, width) {
|
||||||
copySkin(52, 20, 4, 12, 44, 52, true); // Back Arm
|
copySkin(52, 20, 4, 12, 44, 52, true); // Back Arm
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSkinToCanvas(canvas, image) {
|
export function loadSkinToCanvas(canvas, image) {
|
||||||
let isOldFormat = false;
|
let isOldFormat = false;
|
||||||
if (image.width !== image.height) {
|
if (image.width !== image.height) {
|
||||||
if (image.width === 2 * 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;
|
let isOldFormat = false;
|
||||||
if (image.width !== 2 * image.height) {
|
if (image.width !== 2 * image.height) {
|
||||||
if (image.width * 17 === image.height * 22) {
|
if (image.width * 17 === image.height * 22) {
|
||||||
|
|
@ -132,7 +132,7 @@ function loadCapeToCanvas(canvas, image) {
|
||||||
context.drawImage(image, 0, 0, image.width, image.height);
|
context.drawImage(image, 0, 0, image.width, image.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSlimSkin(canvasOrImage) {
|
export function isSlimSkin(canvasOrImage) {
|
||||||
// Detects whether the skin is default or slim.
|
// Detects whether the skin is default or slim.
|
||||||
//
|
//
|
||||||
// The right arm area of *default* skins:
|
// The right arm area of *default* skins:
|
||||||
|
|
@ -192,5 +192,3 @@ function isSlimSkin(canvasOrImage) {
|
||||||
throw new Error(`Illegal argument: ${canvasOrImage}`);
|
throw new Error(`Illegal argument: ${canvasOrImage}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { isSlimSkin, loadSkinToCanvas, loadCapeToCanvas };
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { PlayerObject } from "./model";
|
||||||
import { invokeAnimation } from "./animation";
|
import { invokeAnimation } from "./animation";
|
||||||
import { loadSkinToCanvas, loadCapeToCanvas, isSlimSkin } from "./utils";
|
import { loadSkinToCanvas, loadCapeToCanvas, isSlimSkin } from "./utils";
|
||||||
|
|
||||||
class SkinViewer {
|
export class SkinViewer {
|
||||||
|
|
||||||
public domElement: HTMLElement;
|
public domElement: HTMLElement;
|
||||||
public animation: Animation;
|
public animation: Animation;
|
||||||
|
|
@ -165,5 +165,3 @@ class SkinViewer {
|
||||||
this.setSize(this.width, newHeight);
|
this.setSize(this.width, newHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { SkinViewer };
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue