Merge pull request #1 from yushijinhun/pr-12-mod
Remove MouseControl and use OrbitControls instead
This commit is contained in:
commit
0db8457441
|
|
@ -37,10 +37,10 @@ Three.js powered Minecraft skin viewer.
|
||||||
skinViewer.height = 400;
|
skinViewer.height = 400;
|
||||||
|
|
||||||
// Control objects with your mouse!
|
// Control objects with your mouse!
|
||||||
let control = new skinview3d.SkinControl(skinViewer);
|
let control = skinview3d.createOrbitControls(skinViewer);
|
||||||
control.rotation = true;
|
control.enableRotate = true;
|
||||||
control.zoom = false;
|
control.enableZoom = false;
|
||||||
control.pan = false;
|
control.enablePan = false;
|
||||||
|
|
||||||
skinViewer.animation = new skinview3d.CompositeAnimation();
|
skinViewer.animation = new skinview3d.CompositeAnimation();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -593,4 +593,17 @@ class OrbitControls extends THREE.EventDispatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { OrbitControls };
|
function createOrbitControls(skinViewer) {
|
||||||
|
let control = new OrbitControls(skinViewer.camera, skinViewer.renderer.domElement);
|
||||||
|
|
||||||
|
// default configuration
|
||||||
|
control.enablePan = false;
|
||||||
|
control.target = new THREE.Vector3(0, -12, 0);
|
||||||
|
control.minDistance = 10;
|
||||||
|
control.maxDistance = 256;
|
||||||
|
control.update();
|
||||||
|
|
||||||
|
return control;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { OrbitControls, createOrbitControls };
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
export { SkinObject, CapeObject, PlayerObject } from "./model";
|
export { SkinObject, CapeObject, PlayerObject } from "./model";
|
||||||
export { SkinViewer, MouseControl } from "./viewer";
|
export { SkinViewer } from "./viewer";
|
||||||
|
export { OrbitControls, createOrbitControls } from "./orbit_controls";
|
||||||
export {
|
export {
|
||||||
invokeAnimation,
|
invokeAnimation,
|
||||||
CompositeAnimation,
|
CompositeAnimation,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { PlayerObject } from "./model";
|
import { PlayerObject } from "./model";
|
||||||
import { OrbitControls } from "./orbit_controls";
|
|
||||||
import { invokeAnimation } from "./animation";
|
import { invokeAnimation } from "./animation";
|
||||||
|
|
||||||
function copyImage(context, sX, sY, w, h, dX, dY, flipHorizontal) {
|
function copyImage(context, sX, sY, w, h, dX, dY, flipHorizontal) {
|
||||||
|
|
@ -228,45 +227,4 @@ class SkinViewer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MouseControl {
|
export { SkinViewer };
|
||||||
constructor(skinViewer) {
|
|
||||||
this.skinViewer = skinViewer;
|
|
||||||
|
|
||||||
this.orbitControls = new OrbitControls(skinViewer.camera, skinViewer.renderer.domElement);
|
|
||||||
this.orbitControls.enablePan = false;
|
|
||||||
this.orbitControls.target = new THREE.Vector3(0, -12, 0);
|
|
||||||
this.orbitControls.minDistance = 10;
|
|
||||||
this.orbitControls.maxDistance = 256;
|
|
||||||
this.orbitControls.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
get rotation() {
|
|
||||||
return this.orbitControls.enableRotate;
|
|
||||||
}
|
|
||||||
|
|
||||||
set rotation(value) {
|
|
||||||
this.orbitControls.enableRotate = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
get zoom() {
|
|
||||||
return this.orbitControls.enableZoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
set zoom(value) {
|
|
||||||
this.orbitControls.enableZoom = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
get pan() {
|
|
||||||
return this.orbitControls.enablePan;
|
|
||||||
}
|
|
||||||
|
|
||||||
set pan(value) {
|
|
||||||
this.orbitControls.enablePan = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose() {
|
|
||||||
this.orbitControls.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { SkinViewer, MouseControl };
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
import * as THREE from "three";
|
||||||
|
import { SkinViewer } from "./viewer";
|
||||||
|
|
||||||
|
export class OrbitControls {
|
||||||
|
|
||||||
|
public readonly object: THREE.Camera;
|
||||||
|
public readonly domElement: HTMLElement | HTMLDocument;
|
||||||
|
|
||||||
|
public enabled: boolean;
|
||||||
|
public target: THREE.Vector3;
|
||||||
|
|
||||||
|
public minDistance: number;
|
||||||
|
public maxDistance: number;
|
||||||
|
|
||||||
|
public minZoom: number;
|
||||||
|
public maxZoom: number;
|
||||||
|
|
||||||
|
public minPolarAngle: number;
|
||||||
|
public maxPolarAngle: number;
|
||||||
|
|
||||||
|
public minAzimuthAngle: number;
|
||||||
|
public maxAzimuthAngle: number;
|
||||||
|
|
||||||
|
public enableDamping: boolean;
|
||||||
|
public dampingFactor: number;
|
||||||
|
|
||||||
|
public enableZoom: boolean;
|
||||||
|
public zoomSpeed: number;
|
||||||
|
|
||||||
|
public enableRotate: boolean;
|
||||||
|
public rotateSpeed: number;
|
||||||
|
|
||||||
|
public enablePan: boolean;
|
||||||
|
public keyPanSpeed: number;
|
||||||
|
|
||||||
|
public autoRotate: boolean;
|
||||||
|
public autoRotateSpeed: number;
|
||||||
|
|
||||||
|
public enableKeys: boolean;
|
||||||
|
public keys: { LEFT: number, UP: number, RIGHT: number, BOTTOM: number };
|
||||||
|
|
||||||
|
public mouseButtons: { ORBIT: THREE.MOUSE, ZOOM: THREE.MOUSE, PAN: THREE.MOUSE };
|
||||||
|
|
||||||
|
constructor(object: THREE.Camera, domElement?: HTMLElement);
|
||||||
|
|
||||||
|
public getPolarAngle(): number;
|
||||||
|
public getAzimuthalAngle(): number;
|
||||||
|
|
||||||
|
public saveState(): void;
|
||||||
|
public reset(): void;
|
||||||
|
|
||||||
|
public update(): boolean;
|
||||||
|
|
||||||
|
public dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createOrbitControls(skinViewer: SkinViewer): OrbitControls;
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
export * from "./model";
|
export * from "./model";
|
||||||
export * from "./animation";
|
export * from "./animation";
|
||||||
export * from "./viewer";
|
export * from "./viewer";
|
||||||
|
export * from "./orbit_controls";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue