commit
c88b02d0a2
|
|
@ -4,6 +4,21 @@
|
|||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"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": {
|
||||
"version": "5.4.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
"description": "Three.js powered Minecraft skin viewer",
|
||||
"module": "build/skinview3d.module.js",
|
||||
"main": "build/skinview3d.js",
|
||||
"typings": "types/skinview3d.d.ts",
|
||||
"scripts": {
|
||||
"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",
|
||||
|
|
@ -23,6 +24,7 @@
|
|||
"three": "^0.89.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/three": "^0.89.6",
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-plugin-external-helpers": "^6.22.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
import { PlayerObject } from './model'
|
||||
|
||||
type AnimationFn = (player: PlayerObject, time: number) => void
|
||||
interface IAnimation {
|
||||
play(player: PlayerObject, time: number): void
|
||||
}
|
||||
export type Animation = AnimationFn | IAnimation
|
||||
|
||||
declare function invokeAnimation(
|
||||
animation: Animation,
|
||||
player: PlayerObject,
|
||||
time: number
|
||||
): void
|
||||
|
||||
declare class AnimationHandle implements IAnimation {
|
||||
readonly animation: Animation
|
||||
paused: boolean
|
||||
speed: number
|
||||
|
||||
constructor(animation: Animation)
|
||||
|
||||
play(player: PlayerObject, time: number): void
|
||||
|
||||
reset(): void
|
||||
}
|
||||
|
||||
export class CompositeAnimation implements IAnimation {
|
||||
private handles: Set<AnimationHandle>
|
||||
|
||||
constructor()
|
||||
|
||||
add(animation: Animation): AnimationHandle
|
||||
|
||||
play(player: PlayerObject, time: number): void
|
||||
}
|
||||
|
||||
export const WalkAnimation: AnimationFn
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
import * as THREE from 'three'
|
||||
|
||||
export class SkinObject extends 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: 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(
|
||||
isSlim: boolean,
|
||||
layer1Material: THREE.Material,
|
||||
layer2Material: THREE.Material,
|
||||
capeMaterial: THREE.Material
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
export {
|
||||
CompositeAnimation,
|
||||
WalkAnimation,
|
||||
Animation,
|
||||
AnimationFn,
|
||||
IAnimation
|
||||
} from './animation'
|
||||
|
||||
export { SkinViewer, SkinControl } from './viewer'
|
||||
|
||||
export { SkinObject, CapeObject, PlayerObject } from './model'
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
import * as THREE from 'three'
|
||||
import { CompositeAnimation, WalkAnimation } from './animation'
|
||||
import { Animation } from './animation'
|
||||
import { PlayerObject } from './model'
|
||||
|
||||
interface SkinViewerOptions {
|
||||
domElement: Element
|
||||
animation?: Animation
|
||||
slim?: boolean
|
||||
skinUrl?: string
|
||||
capeUrl?: string
|
||||
width?: number
|
||||
height?: number
|
||||
}
|
||||
|
||||
export class SkinViewer {
|
||||
skinUrl: string
|
||||
capeUrl: string
|
||||
width: number
|
||||
height: number
|
||||
readonly domElement: Element
|
||||
animation: Animation
|
||||
animationPaused: boolean
|
||||
animationTime: number
|
||||
readonly playerObject: PlayerObject
|
||||
readonly disposed: boolean
|
||||
readonly camera: THREE.Camera
|
||||
readonly renderer: THREE.Renderer
|
||||
readonly scene: THREE.Scene
|
||||
|
||||
constructor(options: SkinViewerOptions)
|
||||
|
||||
setSize(width: number, height: number): void
|
||||
|
||||
dispose(): void
|
||||
}
|
||||
|
||||
export class SkinControl {
|
||||
enableAnimationControl: boolean
|
||||
readonly skinViewer: SkinViewer
|
||||
|
||||
constructor(skinViewer: SkinViewer)
|
||||
|
||||
dispose(): void
|
||||
}
|
||||
Loading…
Reference in New Issue