format code

This commit is contained in:
yushijinhun 2018-02-09 12:29:42 +08:00
parent 000f29aec8
commit 42959b63d7
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4
5 changed files with 95 additions and 83 deletions

View File

@ -1,9 +1,21 @@
{ {
"defaultSeverity": "error", "defaultSeverity": "error",
"extends": [ "extends": [
"tslint:recommended" "tslint:latest"
], ],
"jsRules": {}, "jsRules": {},
"rules": {}, "rules": {
"indent": [
true,
"tabs"
],
"eofline": true,
"linebreak-style": [
true,
"LF"
],
"max-classes-per-file": false,
"interface-name": false
},
"rulesDirectory": [] "rulesDirectory": []
} }

34
types/animation.d.ts vendored
View File

@ -1,37 +1,37 @@
import { PlayerObject } from './model' import { PlayerObject } from "./model";
type AnimationFn = (player: PlayerObject, time: number) => void type AnimationFn = (player: PlayerObject, time: number) => void;
interface IAnimation { interface IAnimation {
play(player: PlayerObject, time: number): void play(player: PlayerObject, time: number): void;
} }
export type Animation = AnimationFn | IAnimation export type Animation = AnimationFn | IAnimation;
declare function invokeAnimation( declare function invokeAnimation(
animation: Animation, animation: Animation,
player: PlayerObject, player: PlayerObject,
time: number time: number,
): void ): void;
declare class AnimationHandle implements IAnimation { declare class AnimationHandle implements IAnimation {
readonly animation: Animation readonly animation: Animation;
paused: boolean paused: boolean;
speed: number speed: number;
constructor(animation: Animation) constructor(animation: Animation);
play(player: PlayerObject, time: number): void play(player: PlayerObject, time: number): void;
reset(): void reset(): void;
} }
export class CompositeAnimation implements IAnimation { export class CompositeAnimation implements IAnimation {
private handles: Set<AnimationHandle> private handles: Set<AnimationHandle>;
constructor() constructor();
add(animation: Animation): AnimationHandle add(animation: Animation): AnimationHandle;
play(player: PlayerObject, time: number): void play(player: PlayerObject, time: number): void;
} }
export const WalkAnimation: AnimationFn export const WalkAnimation: AnimationFn;

54
types/model.d.ts vendored
View File

@ -1,35 +1,35 @@
import * as THREE from 'three' import * as THREE from "three";
export class SkinObject extends THREE.Group { export class SkinObject extends THREE.Group {
readonly head: THREE.Group readonly head: THREE.Group;
readonly body: THREE.Group readonly body: THREE.Group;
readonly rightArm: THREE.Group readonly rightArm: THREE.Group;
readonly leftArm: THREE.Group readonly leftArm: THREE.Group;
readonly rightLeg: THREE.Group readonly rightLeg: THREE.Group;
readonly leftLeg: THREE.Group readonly leftLeg: THREE.Group;
constructor(
isSlim: boolean,
layer1Material: THREE.Material,
layer2Material: THREE.Material
)
}
export class CapeObject extends THREE.Group {
readonly cape: THREE.Mesh
constructor(capeMaterial: THREE.Material)
}
export class PlayerObject extends THREE.Group {
readonly slim: boolean
readonly skin: SkinObject
readonly cape: CapeObject
constructor( constructor(
isSlim: boolean, isSlim: boolean,
layer1Material: THREE.Material, layer1Material: THREE.Material,
layer2Material: THREE.Material, layer2Material: THREE.Material,
capeMaterial: THREE.Material );
) }
export class CapeObject extends THREE.Group {
readonly cape: THREE.Mesh;
constructor(capeMaterial: THREE.Material);
}
export class PlayerObject extends THREE.Group {
readonly slim: boolean;
readonly skin: SkinObject;
readonly cape: CapeObject;
constructor(
isSlim: boolean,
layer1Material: THREE.Material,
layer2Material: THREE.Material,
capeMaterial: THREE.Material,
);
} }

View File

@ -3,9 +3,9 @@ export {
WalkAnimation, WalkAnimation,
Animation, Animation,
AnimationFn, AnimationFn,
IAnimation IAnimation,
} from './animation' } from "./animation";
export { SkinViewer, SkinControl } from './viewer' export { SkinViewer, SkinControl } from "./viewer";
export { SkinObject, CapeObject, PlayerObject } from './model' export { SkinObject, CapeObject, PlayerObject } from "./model";

62
types/viewer.d.ts vendored
View File

@ -1,45 +1,45 @@
import * as THREE from 'three' import * as THREE from "three";
import { CompositeAnimation, WalkAnimation } from './animation' import { CompositeAnimation, WalkAnimation } from "./animation";
import { Animation } from './animation' import { Animation } from "./animation";
import { PlayerObject } from './model' import { PlayerObject } from "./model";
interface SkinViewerOptions { interface SkinViewerOptions {
domElement: Element domElement: Element;
animation?: Animation animation?: Animation;
slim?: boolean slim?: boolean;
skinUrl?: string skinUrl?: string;
capeUrl?: string capeUrl?: string;
width?: number width?: number;
height?: number height?: number;
} }
export class SkinViewer { export class SkinViewer {
skinUrl: string skinUrl: string;
capeUrl: string capeUrl: string;
width: number width: number;
height: number height: number;
readonly domElement: Element readonly domElement: Element;
animation: Animation animation: Animation;
animationPaused: boolean animationPaused: boolean;
animationTime: number animationTime: number;
readonly playerObject: PlayerObject readonly playerObject: PlayerObject;
readonly disposed: boolean readonly disposed: boolean;
readonly camera: THREE.Camera readonly camera: THREE.Camera;
readonly renderer: THREE.Renderer readonly renderer: THREE.Renderer;
readonly scene: THREE.Scene readonly scene: THREE.Scene;
constructor(options: SkinViewerOptions) constructor(options: SkinViewerOptions);
setSize(width: number, height: number): void setSize(width: number, height: number): void;
dispose(): void dispose(): void;
} }
export class SkinControl { export class SkinControl {
enableAnimationControl: boolean enableAnimationControl: boolean;
readonly skinViewer: SkinViewer readonly skinViewer: SkinViewer;
constructor(skinViewer: SkinViewer) constructor(skinViewer: SkinViewer);
dispose(): void dispose(): void;
} }