forked from ppfun/pixelplanet
rewrite VoxelPainterControls as proper class
(3d canvas still broken)
This commit is contained in:
parent
0254f7d820
commit
d7c60a9df2
|
@ -24,6 +24,33 @@ import {
|
||||||
} from '../core/utils';
|
} from '../core/utils';
|
||||||
|
|
||||||
class PixelPainterControls {
|
class PixelPainterControls {
|
||||||
|
store;
|
||||||
|
renderer;
|
||||||
|
viewport;
|
||||||
|
//
|
||||||
|
clickTapStartView = [0, 0];
|
||||||
|
clickTapStartTime = 0;
|
||||||
|
clickTapStartCoords = [0, 0];
|
||||||
|
tapStartDist = 50;
|
||||||
|
//
|
||||||
|
// on mouse: true as long as left mouse button is pressed
|
||||||
|
// on touch: set to true when one finger touches the screen
|
||||||
|
// set to false when second finger touches or touch ends
|
||||||
|
isClicking = false;
|
||||||
|
// on touch: true if more than one finger on screen
|
||||||
|
isMultiTab = false;
|
||||||
|
// on touch: timeout to detect long-press
|
||||||
|
tapTimeout = null;
|
||||||
|
/*
|
||||||
|
* if we are shift-hold-painting
|
||||||
|
* 0: no
|
||||||
|
* 1: left shift
|
||||||
|
* 2: right shift
|
||||||
|
*/
|
||||||
|
holdPainting = 0;
|
||||||
|
// if we are waiting before placing pixel via holdPainting again
|
||||||
|
coolDownDelta = false;
|
||||||
|
|
||||||
constructor(renderer, viewport, store) {
|
constructor(renderer, viewport, store) {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
|
@ -41,29 +68,6 @@ class PixelPainterControls {
|
||||||
this.onTouchEnd = this.onTouchEnd.bind(this);
|
this.onTouchEnd = this.onTouchEnd.bind(this);
|
||||||
this.onTouchMove = this.onTouchMove.bind(this);
|
this.onTouchMove = this.onTouchMove.bind(this);
|
||||||
|
|
||||||
this.clickTapStartView = [0, 0];
|
|
||||||
this.clickTapStartTime = 0;
|
|
||||||
this.clickTapStartCoords = [0, 0];
|
|
||||||
this.tapStartDist = 50;
|
|
||||||
this.tapStartScale = this.store.getState().scale;
|
|
||||||
// on mouse: true as long as left mouse button is pressed
|
|
||||||
// on touch: set to true when one finger touches the screen
|
|
||||||
// set to false when second finger touches or touch ends
|
|
||||||
this.isClicking = false;
|
|
||||||
// on touch: true if more than one finger on screen
|
|
||||||
this.isMultiTab = false;
|
|
||||||
// on touch: timeout to detect long-press
|
|
||||||
this.tapTimeout = null;
|
|
||||||
/*
|
|
||||||
* if we are shift-hold-painting
|
|
||||||
* 0: no
|
|
||||||
* 1: left shift
|
|
||||||
* 2: right shift
|
|
||||||
*/
|
|
||||||
this.holdPainting = 0;
|
|
||||||
// if we are waiting before placing pixel via holdPainting again
|
|
||||||
this.coolDownDelta = false;
|
|
||||||
|
|
||||||
document.addEventListener('keydown', this.onKeyDown, false);
|
document.addEventListener('keydown', this.onKeyDown, false);
|
||||||
document.addEventListener('keyup', this.onKeyUp, false);
|
document.addEventListener('keyup', this.onKeyUp, false);
|
||||||
viewport.addEventListener('auxclick', this.onAuxClick, false);
|
viewport.addEventListener('auxclick', this.onAuxClick, false);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,7 +11,7 @@ import { updateView } from '../store/actions';
|
||||||
class Renderer {
|
class Renderer {
|
||||||
store;
|
store;
|
||||||
// object for user controls
|
// object for user controls
|
||||||
constrols = {
|
controls = {
|
||||||
update() {},
|
update() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class Renderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
this.controls?.update();
|
return this.controls.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPixel() {}
|
renderPixel() {}
|
||||||
|
|
|
@ -35,7 +35,6 @@ class Renderer3D extends Renderer {
|
||||||
oobGeometry;
|
oobGeometry;
|
||||||
oobMaterial;
|
oobMaterial;
|
||||||
//--
|
//--
|
||||||
controls;
|
|
||||||
threeRenderer;
|
threeRenderer;
|
||||||
// temp variables for mouse events
|
// temp variables for mouse events
|
||||||
mouse;
|
mouse;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user