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'
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(
animation: Animation,
@ -8,8 +18,8 @@ declare function invokeAnimation(
time: number
): void
declare class AnimationHandle {
animation: Animation
declare class AnimationHandle implements IAnimation {
readonly animation: Animation
paused: boolean
speed: number
@ -20,8 +30,8 @@ declare class AnimationHandle {
reset(): void
}
export class CompositeAnimation {
handles: Set<AnimationHandle>
export class CompositeAnimation implements IAnimation {
readonly handles: Set<AnimationHandle>
constructor()
@ -30,4 +40,4 @@ export class CompositeAnimation {
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'
type Material = THREE.Material | THREE.Material[]
export class SkinObject extends THREE.Group {
head: THREE.Group
body: THREE.Group
rightArm: THREE.Group
leftArm: THREE.Group
rightLeg: THREE.Group
leftLeg: THREE.Group
readonly head: THREE.Group
readonly body: THREE.Group
readonly rightArm: THREE.Group
readonly leftArm: THREE.Group
readonly rightLeg: THREE.Group
readonly leftLeg: THREE.Group
constructor(
isSlim: boolean,
layer1Material: Material,
layer2Material: Material
layer1Material: THREE.Material,
layer2Material: THREE.Material
)
}
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 {
slim: boolean
skin: SkinObject
cape: CapeObject
readonly slim: boolean
readonly skin: SkinObject
readonly cape: CapeObject
constructor(
isSlim: boolean,
layer1Material: Material,
layer2Material: Material,
capeMaterial: Material
layer1Material: THREE.Material,
layer2Material: THREE.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 { SkinObject, CapeObject, PlayerObject } from './model'