fix some types defs

This commit is contained in:
Pig Fang 2018-02-05 09:14:43 +08:00
parent 07e8cd58c6
commit c483ae33ee
3 changed files with 33 additions and 25 deletions

22
types/animation.d.ts vendored
View File

@ -1,6 +1,16 @@
import { PlayerObject } from './model' import { PlayerObject } from './model'
export type Animation = CompositeAnimation | typeof WalkAnimation type AnimationFn = (player: PlayerObject, time: number) => void
interface IAnimation {
play(player: PlayerObject, time: number): void
}
export type Animation =
| AnimationFn
| IAnimation
| {
play(player: PlayerObject, time: number): void
[x: string]: any
}
declare function invokeAnimation( declare function invokeAnimation(
animation: Animation, animation: Animation,
@ -8,8 +18,8 @@ declare function invokeAnimation(
time: number time: number
): void ): void
declare class AnimationHandle { declare class AnimationHandle implements IAnimation {
animation: Animation readonly animation: Animation
paused: boolean paused: boolean
speed: number speed: number
@ -20,8 +30,8 @@ declare class AnimationHandle {
reset(): void reset(): void
} }
export class CompositeAnimation { export class CompositeAnimation implements IAnimation {
handles: Set<AnimationHandle> readonly handles: Set<AnimationHandle>
constructor() constructor()
@ -30,4 +40,4 @@ export class CompositeAnimation {
play(player: PlayerObject, time: number): void play(player: PlayerObject, time: number): void
} }
export function WalkAnimation(player: PlayerObject, time: number): void export const WalkAnimation: AnimationFn

34
types/model.d.ts vendored
View File

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

View File

@ -1,3 +1,3 @@
export { CompositeAnimation, WalkAnimation } from './animation' export { CompositeAnimation, WalkAnimation, 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'