You've already forked vtt-mapper
Optimize quadtree
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import * as Three from 'three';
|
||||
import { FRUSTUMSIZE } from '../consts';
|
||||
import { RESOLUTION_X, RESOLUTION_Y } from '../consts';
|
||||
import Stats from 'stats.js';
|
||||
import { Point } from '../physics/common';
|
||||
|
||||
@@ -65,17 +65,17 @@ export default class Renderer
|
||||
this.camera.position.y += y;
|
||||
}
|
||||
static screenSpaceToCameraSpace(x: number, y: number, omit: boolean = false): Point {
|
||||
return { x: ((x / window.innerWidth - 0.5) * FRUSTUMSIZE * this.aspect) / this.#zoom + (omit ? 0 : this.#pos.x), y: (- (y / window.innerHeight - 0.5) * FRUSTUMSIZE) / this.zoom + (omit ? 0 : this.#pos.y) };
|
||||
return { x: ((x / window.innerWidth - 0.5) * RESOLUTION_X * this.aspect) / this.#zoom + (omit ? 0 : this.#pos.x), y: (- (y / window.innerHeight - 0.5) * RESOLUTION_Y) / this.zoom + (omit ? 0 : this.#pos.y) };
|
||||
}
|
||||
static #resize(): void
|
||||
{
|
||||
const aspect = this.aspect = window.innerWidth / window.innerHeight;
|
||||
this.renderer.setSize( window.innerWidth, window.innerHeight );
|
||||
|
||||
this.camera.left = FRUSTUMSIZE * aspect / - 2 / this.#zoom;
|
||||
this.camera.right = FRUSTUMSIZE * aspect / 2 / this.#zoom;
|
||||
this.camera.top = FRUSTUMSIZE / 2 / this.#zoom;
|
||||
this.camera.bottom = FRUSTUMSIZE / - 2 / this.#zoom;
|
||||
this.camera.left = RESOLUTION_X * aspect / - 2 / this.#zoom;
|
||||
this.camera.right = RESOLUTION_X * aspect / 2 / this.#zoom;
|
||||
this.camera.top = RESOLUTION_Y / 2 / this.#zoom;
|
||||
this.camera.bottom = RESOLUTION_Y / - 2 / this.#zoom;
|
||||
|
||||
this.camera.updateProjectionMatrix();
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ export default class Selector
|
||||
return;
|
||||
}
|
||||
|
||||
Selector.#ghostMesh.box.setFromArray([asset.x1, asset.y1, 0, asset.x2, asset.y2, 0]);
|
||||
Selector.#ghostMesh.box.setFromArray([asset.aabb.x1, asset.aabb.y1, 0, asset.aabb.x2, asset.aabb.y2, 0]);
|
||||
Selector.#ghostMesh.updateMatrix();
|
||||
|
||||
Selector.#ghostMesh.visible = true;
|
||||
@@ -65,11 +65,11 @@ export default class Selector
|
||||
Selector.#selected = true;
|
||||
|
||||
Selector.#selectionMesh.box.setFromArray([
|
||||
assets.map(e => e.x1).reduce((p, v) => Math.min(p, v), Infinity),
|
||||
assets.map(e => e.y1).reduce((p, v) => Math.min(p, v), Infinity),
|
||||
assets.map(e => e.aabb.x1).reduce((p, v) => Math.min(p, v), Infinity),
|
||||
assets.map(e => e.aabb.y1).reduce((p, v) => Math.min(p, v), Infinity),
|
||||
0,
|
||||
assets.map(e => e.x2).reduce((p, v) => Math.max(p, v), -Infinity),
|
||||
assets.map(e => e.y2).reduce((p, v) => Math.max(p, v), -Infinity),
|
||||
assets.map(e => e.aabb.x2).reduce((p, v) => Math.max(p, v), -Infinity),
|
||||
assets.map(e => e.aabb.y2).reduce((p, v) => Math.max(p, v), -Infinity),
|
||||
0
|
||||
]);
|
||||
Selector.#selectionMesh.updateMatrix();
|
||||
|
||||
Reference in New Issue
Block a user