Small UI fixes and finetuned quadtree settings
This commit is contained in:
parent
209a070464
commit
8f0100c466
23
src/main.ts
23
src/main.ts
|
|
@ -37,25 +37,32 @@ Renderer.scene.add(Asset.instance);
|
|||
Renderer.startRendering();
|
||||
|
||||
Input.onDragStart((_, button) => { if(button & 1) Selector.hide(); });
|
||||
Input.onDragEnd((start, end, button) => {
|
||||
Input.onDragEnd((s, e, button) => {
|
||||
if(button & 1)
|
||||
{
|
||||
const s = performance.now();
|
||||
const selection = quad.query({x1: Math.min(start.x, end.x), x2: Math.max(start.x, end.x), y1: Math.min(start.y, end.y), y2: Math.max(start.y, end.y)}).map(e => Asset.assets[e]);
|
||||
console.log("Fetching %s out of %s elements in %sms", selection.length, Asset.assets.length, performance.now() - s);
|
||||
const n = performance.now();
|
||||
const selection = quad.query({x1: Math.min(s.x, e.x), x2: Math.max(s.x, e.x), y1: Math.min(s.y, e.y), y2: Math.max(s.y, e.y)}).map(e => Asset.assets[e]);
|
||||
console.log("Fetching %s out of %s elements in %sms", selection.length, Asset.assets.length, performance.now() - n);
|
||||
|
||||
if(Input.keys['Shift']) Selector.toggle(selection);
|
||||
else Selector.select(selection);
|
||||
}
|
||||
});
|
||||
Input.onDrag((delta, start, end, button) => { if(button & 1) Selector.preview(start, end); else Renderer.move(-delta.x, -delta.y); });
|
||||
Input.onClick((point, button) => {
|
||||
Input.onClick((p, button) => {
|
||||
if(button & 1)
|
||||
{
|
||||
const selection = quad.fetch(point.x, point.y).map(e => Asset.assets[e]);
|
||||
const selection = quad.fetch(p.x, p.y)[0];
|
||||
|
||||
if(Input.keys['Shift']) Selector.toggle(selection);
|
||||
else Selector.select(selection);
|
||||
if (selection === undefined)
|
||||
{
|
||||
if (!Input.keys['Shift'])
|
||||
Selector.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Input.keys['Shift']) Selector.toggle([Asset.assets[selection]]);
|
||||
else Selector.select([Asset.assets[selection]]);
|
||||
}
|
||||
});
|
||||
Input.onWheel(delta => Renderer.zoom = clamp(Renderer.zoom * 1 + (delta * -0.001), 0.9, 5));
|
||||
|
|
|
|||
|
|
@ -115,15 +115,15 @@ export default class Input
|
|||
{
|
||||
e.preventDefault();
|
||||
|
||||
if(Input.#dragging && !Input.#dragStarted)
|
||||
const cursor = Renderer.screenSpaceToCameraSpace(e.clientX, e.clientY);
|
||||
const cursorOmitted = Renderer.screenSpaceToCameraSpace(e.clientX, e.clientY, true);
|
||||
|
||||
if(Input.#dragging && !Input.#dragStarted && cursor.x !== this.#dragInitPos.x && cursor.y !== this.#dragInitPos.y)
|
||||
{
|
||||
Input.#dragStartCb && Input.#dragStartCb(Input.#dragInitPos, e.buttons);
|
||||
Input.#dragStarted = true;
|
||||
}
|
||||
|
||||
const cursor = Renderer.screenSpaceToCameraSpace(e.clientX, e.clientY);
|
||||
const cursorOmitted = Renderer.screenSpaceToCameraSpace(e.clientX, e.clientY, true);
|
||||
|
||||
Input.#cursor = cursor;
|
||||
|
||||
if(Input.dragging)
|
||||
|
|
|
|||
Loading…
Reference in New Issue