add TS types defs
This commit is contained in:
parent
b5fc9389f8
commit
82d72c82ec
|
|
@ -4,6 +4,21 @@
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/three": {
|
||||||
|
"version": "0.89.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.89.6.tgz",
|
||||||
|
"integrity": "sha512-fPaCCrr1pxuyoZVSXmRO1VRF02nshe9Y3BMwm5tJBd9o0Mp5Lma9JUQfK/4oacJXSMkykcQrjmsyCsabB3uqsA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/webvr-api": "0.0.31"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/webvr-api": {
|
||||||
|
"version": "0.0.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/webvr-api/-/webvr-api-0.0.31.tgz",
|
||||||
|
"integrity": "sha1-9gYf6IoDXTSotqDFX4dYkB7IoI4=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"acorn": {
|
"acorn": {
|
||||||
"version": "5.4.1",
|
"version": "5.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
"description": "Three.js powered Minecraft skin viewer",
|
"description": "Three.js powered Minecraft skin viewer",
|
||||||
"module": "build/skinview3d.module.js",
|
"module": "build/skinview3d.module.js",
|
||||||
"main": "build/skinview3d.js",
|
"main": "build/skinview3d.js",
|
||||||
|
"typings": "types/skinview3d.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c tools/rollup.module.js && rollup -c tools/rollup.browser.js && rollup -c tools/rollup.browser.min.js",
|
"build": "rollup -c tools/rollup.module.js && rollup -c tools/rollup.browser.js && rollup -c tools/rollup.browser.min.js",
|
||||||
"prepare": "npm test && rm -rf build && npm run build",
|
"prepare": "npm test && rm -rf build && npm run build",
|
||||||
|
|
@ -23,6 +24,7 @@
|
||||||
"three": "^0.89.0"
|
"three": "^0.89.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/three": "^0.89.6",
|
||||||
"babel-cli": "^6.26.0",
|
"babel-cli": "^6.26.0",
|
||||||
"babel-plugin-external-helpers": "^6.22.0",
|
"babel-plugin-external-helpers": "^6.22.0",
|
||||||
"babel-preset-env": "^1.6.1",
|
"babel-preset-env": "^1.6.1",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { PlayerObject } from './model'
|
||||||
|
|
||||||
|
declare function invokeAnimation(
|
||||||
|
animation: CompositeAnimation,
|
||||||
|
player: PlayerObject,
|
||||||
|
time: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
declare function invokeAnimation(
|
||||||
|
animation: typeof WalkAnimation,
|
||||||
|
player: PlayerObject,
|
||||||
|
time: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
declare class AnimationHandle {
|
||||||
|
animation: typeof WalkAnimation
|
||||||
|
paused: boolean
|
||||||
|
speed: number
|
||||||
|
|
||||||
|
constructor(animation: typeof WalkAnimation)
|
||||||
|
|
||||||
|
play(player: PlayerObject, time: number): void
|
||||||
|
|
||||||
|
reset(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CompositeAnimation {
|
||||||
|
handles: Set<AnimationHandle>
|
||||||
|
|
||||||
|
constructor()
|
||||||
|
|
||||||
|
add(animation: typeof WalkAnimation): AnimationHandle
|
||||||
|
|
||||||
|
play(player: PlayerObject, time: number): void
|
||||||
|
}
|
||||||
|
|
||||||
|
export function WalkAnimation(player: PlayerObject, time: number): void
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
isSlim: boolean,
|
||||||
|
layer1Material: Material,
|
||||||
|
layer2Material: Material
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CapeObject extends THREE.Group {
|
||||||
|
cape: THREE.Mesh
|
||||||
|
|
||||||
|
constructor(capeMaterial: Material)
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PlayerObject extends THREE.Group {
|
||||||
|
slim: boolean
|
||||||
|
skin: SkinObject
|
||||||
|
cape: CapeObject
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
isSlim: boolean,
|
||||||
|
layer1Material: Material,
|
||||||
|
layer2Material: Material,
|
||||||
|
capeMaterial: Material
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
export { CompositeAnimation, WalkAnimation } from './animation'
|
||||||
|
export { SkinViewer, SkinControl } from './viewer'
|
||||||
|
export { SkinObject, CapeObject, PlayerObject } from './model'
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { CompositeAnimation, WalkAnimation } from './animation';
|
||||||
|
|
||||||
|
interface SkinViewerOptions {
|
||||||
|
domElement: Element
|
||||||
|
animation?: CompositeAnimation | typeof WalkAnimation
|
||||||
|
slim?: boolean
|
||||||
|
skinUrl?: string
|
||||||
|
capeUrl?: string
|
||||||
|
width?: number
|
||||||
|
height?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SkinViewer {
|
||||||
|
skinUrl: string
|
||||||
|
capeUrl: string
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
|
||||||
|
constructor(options: SkinViewerOptions)
|
||||||
|
|
||||||
|
setSize(width: number, height: number): void
|
||||||
|
|
||||||
|
dispose(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SkinControl {
|
||||||
|
constructor(skinViewer: SkinViewer)
|
||||||
|
|
||||||
|
dispose(): void
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue