This commit is contained in:
yushijinhun 2020-01-27 19:11:19 +08:00
parent 8378e72b34
commit b8bbde4e7b
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4
13 changed files with 6 additions and 2863 deletions

View File

@ -128,7 +128,7 @@
</div> </div>
</div> </div>
<script type="text/javascript" src="https://unpkg.com/three@0.112.1/build/three.min.js"></script> <script type="text/javascript" src="https://unpkg.com/three@0.112.1/build/three.min.js"></script>
<script type="text/javascript" src="js/dist/skinview3d.js"></script> <script type="text/javascript" src="js/dist/skinview3d.min.js"></script>
<script type="text/javascript" src="js/example.js"></script> <script type="text/javascript" src="js/example.js"></script>
<script> <script>
initSkinViewer(); initSkinViewer();

View File

@ -1,37 +0,0 @@
import { Clock } from "three";
import { PlayerObject } from "./model";
export interface IAnimation {
play(player: PlayerObject, time: number): void;
}
export declare type AnimationFn = (player: PlayerObject, time: number) => void;
export declare type Animation = AnimationFn | IAnimation;
export declare function invokeAnimation(animation: Animation, player: PlayerObject, time: number): void;
export interface AnimationHandle {
speed: number;
paused: boolean;
progress: number;
readonly animation: Animation;
reset(): void;
}
export interface SubAnimationHandle extends AnimationHandle {
remove(): void;
resetAndRemove(): void;
}
export declare class CompositeAnimation implements IAnimation {
readonly handles: Set<AnimationHandle & IAnimation>;
add(animation: Animation): AnimationHandle;
play(player: PlayerObject, time: number): void;
}
export declare class RootAnimation extends CompositeAnimation implements AnimationHandle {
speed: number;
progress: number;
readonly clock: Clock;
get animation(): this;
get paused(): boolean;
set paused(value: boolean);
runAnimationLoop(player: PlayerObject): void;
reset(): void;
}
export declare const WalkingAnimation: Animation;
export declare const RunningAnimation: Animation;
export declare const RotatingAnimation: Animation;

34
js/dist/model.d.ts vendored
View File

@ -1,34 +0,0 @@
import { Group, Mesh, MeshBasicMaterial, Object3D } from "three";
/**
* Notice that innerLayer and outerLayer may NOT be the direct children of the Group.
*/
export declare class BodyPart extends Group {
readonly innerLayer: Object3D;
readonly outerLayer: Object3D;
constructor(innerLayer: Object3D, outerLayer: Object3D);
}
export declare class SkinObject extends Group {
readonly head: BodyPart;
readonly body: BodyPart;
readonly rightArm: BodyPart;
readonly leftArm: BodyPart;
readonly rightLeg: BodyPart;
readonly leftLeg: BodyPart;
private modelListeners;
private _slim;
constructor(layer1Material: MeshBasicMaterial, layer2Material: MeshBasicMaterial);
get slim(): boolean;
set slim(value: boolean);
private getBodyParts;
setInnerLayerVisible(value: boolean): void;
setOuterLayerVisible(value: boolean): void;
}
export declare class CapeObject extends Group {
readonly cape: Mesh;
constructor(capeMaterial: MeshBasicMaterial);
}
export declare class PlayerObject extends Group {
readonly skin: SkinObject;
readonly cape: CapeObject;
constructor(layer1Material: MeshBasicMaterial, layer2Material: MeshBasicMaterial, capeMaterial: MeshBasicMaterial);
}

View File

@ -1,123 +0,0 @@
import { Camera, EventDispatcher, MOUSE, Vector3 } from "three";
import { SkinViewer } from "./viewer";
export declare class OrbitControls extends EventDispatcher {
/**
* @preserve
* The code was originally from https://github.com/mrdoob/three.js/blob/d45a042cf962e9b1aa9441810ba118647b48aacb/examples/js/controls/OrbitControls.js
*/
/**
* @license
* Copyright (C) 2010-2017 three.js authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
* @author qiao / https://github.com/qiao
* @author mrdoob / http://mrdoob.com
* @author alteredq / http://alteredqualia.com/
* @author WestLangley / http://github.com/WestLangley
* @author erich666 / http://erichaines.com
*/
object: Camera;
domElement: HTMLElement | HTMLDocument;
window: Window;
enabled: boolean;
target: Vector3;
enableZoom: boolean;
zoomSpeed: number;
minDistance: number;
maxDistance: number;
enableRotate: boolean;
rotateSpeed: number;
enablePan: boolean;
keyPanSpeed: number;
autoRotate: boolean;
autoRotateSpeed: number;
minZoom: number;
maxZoom: number;
minPolarAngle: number;
maxPolarAngle: number;
minAzimuthAngle: number;
maxAzimuthAngle: number;
enableKeys: boolean;
keys: {
LEFT: number;
UP: number;
RIGHT: number;
BOTTOM: number;
};
mouseButtons: {
ORBIT: MOUSE;
ZOOM: MOUSE;
PAN: MOUSE;
};
enableDamping: boolean;
dampingFactor: number;
private spherical;
private sphericalDelta;
private scale;
private target0;
private position0;
private zoom0;
private state;
private panOffset;
private zoomChanged;
private rotateStart;
private rotateEnd;
private rotateDelta;
private panStart;
private panEnd;
private panDelta;
private dollyStart;
private dollyEnd;
private dollyDelta;
private updateLastPosition;
private updateOffset;
private updateQuat;
private updateLastQuaternion;
private updateQuatInverse;
private panLeftV;
private panUpV;
private panInternalOffset;
private onContextMenu;
private onMouseUp;
private onMouseDown;
private onMouseMove;
private onMouseWheel;
private onTouchStart;
private onTouchEnd;
private onTouchMove;
private onKeyDown;
constructor(object: Camera, domElement?: HTMLElement, domWindow?: Window);
update(): boolean;
panLeft(distance: number, objectMatrix: any): void;
panUp(distance: number, objectMatrix: any): void;
pan(deltaX: number, deltaY: number): void;
dollyIn(dollyScale: any): void;
dollyOut(dollyScale: any): void;
getAutoRotationAngle(): number;
getZoomScale(): number;
rotateLeft(angle: number): void;
rotateUp(angle: number): void;
getPolarAngle(): number;
getAzimuthalAngle(): number;
dispose(): void;
reset(): void;
}
export declare function createOrbitControls(skinViewer: SkinViewer): OrbitControls;

2
js/dist/revision vendored
View File

@ -1 +1 @@
add0c04c7345524e6a950f6707ee991f00b6d15c 0cddbd51a893ec8b937dd431e0cdb14428e6375a

View File

@ -1,5 +0,0 @@
export { SkinObject, BodyPart, CapeObject, PlayerObject } from "./model";
export { SkinViewer, SkinViewerOptions } from "./viewer";
export { OrbitControls, createOrbitControls } from "./orbit_controls";
export { IAnimation, AnimationFn, Animation, invokeAnimation, SubAnimationHandle, AnimationHandle, CompositeAnimation, RootAnimation, WalkingAnimation, RunningAnimation, RotatingAnimation } from "./animation";
export { isSlimSkin } from "./utils";

1306
js/dist/skinview3d.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

1
js/dist/skinview3d.min.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

3
js/dist/utils.d.ts vendored
View File

@ -1,3 +0,0 @@
export declare function loadSkinToCanvas(canvas: HTMLCanvasElement, image: HTMLImageElement): void;
export declare function loadCapeToCanvas(canvas: HTMLCanvasElement, image: HTMLImageElement): void;
export declare function isSlimSkin(canvasOrImage: HTMLCanvasElement | HTMLImageElement): boolean;

46
js/dist/viewer.d.ts vendored
View File

@ -1,46 +0,0 @@
import { MeshBasicMaterial, PerspectiveCamera, Scene, Texture, WebGLRenderer } from "three";
import { RootAnimation } from "./animation";
import { PlayerObject } from "./model";
export interface SkinViewerOptions {
domElement: Node;
animation?: Animation;
skinUrl?: string;
capeUrl?: string;
width?: number;
height?: number;
detectModel?: boolean;
}
export declare class SkinViewer {
readonly domElement: Node;
readonly animations: RootAnimation;
detectModel: boolean;
disposed: boolean;
readonly skinImg: HTMLImageElement;
readonly skinCanvas: HTMLCanvasElement;
readonly skinTexture: Texture;
readonly capeImg: HTMLImageElement;
readonly capeCanvas: HTMLCanvasElement;
readonly capeTexture: Texture;
readonly layer1Material: MeshBasicMaterial;
readonly layer2Material: MeshBasicMaterial;
readonly capeMaterial: MeshBasicMaterial;
readonly scene: Scene;
readonly camera: PerspectiveCamera;
readonly renderer: WebGLRenderer;
readonly playerObject: PlayerObject;
private _renderPaused;
constructor(options: SkinViewerOptions);
private draw;
setSize(width: number, height: number): void;
dispose(): void;
get renderPaused(): boolean;
set renderPaused(value: boolean);
get skinUrl(): string;
set skinUrl(url: string);
get capeUrl(): string;
set capeUrl(url: string);
get width(): number;
set width(newWidth: number);
get height(): number;
set height(newHeight: number);
}

View File

@ -15,7 +15,7 @@ if [ -f "$revision_file" ];then
fi fi
original_dir=$(pwd) original_dir=$(pwd)
master_revision=$(git show-ref --hash -- refs/heads/master) master_revision=$(git show-ref --hash -- refs/remotes/origin/master)
echo "> Checking out $master_revision" echo "> Checking out $master_revision"
echo "> Commit summary:" echo "> Commit summary:"