rewrite VoxelPainterControls as proper class

(3d canvas still broken)
This commit is contained in:
HF 2024-01-20 03:08:00 +01:00
parent 0254f7d820
commit d7c60a9df2
4 changed files with 999 additions and 1014 deletions

View File

@ -24,6 +24,33 @@ import {
} from '../core/utils';
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) {
this.store = store;
this.renderer = renderer;
@ -41,29 +68,6 @@ class PixelPainterControls {
this.onTouchEnd = this.onTouchEnd.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('keyup', this.onKeyUp, false);
viewport.addEventListener('auxclick', this.onAuxClick, false);

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@ import { updateView } from '../store/actions';
class Renderer {
store;
// object for user controls
constrols = {
controls = {
update() {},
};
@ -77,7 +77,7 @@ class Renderer {
}
render() {
this.controls?.update();
return this.controls.update();
}
renderPixel() {}

View File

@ -35,7 +35,6 @@ class Renderer3D extends Renderer {
oobGeometry;
oobMaterial;
//--
controls;
threeRenderer;
// temp variables for mouse events
mouse;