mirror of
https://github.com/BlueMap-Minecraft/BlueMapWeb.git
synced 2025-01-07 15:47:35 +01:00
Fix z-fighting and lowres-layer interaction
This commit is contained in:
parent
a9d9cb991b
commit
050cde0a0c
@ -177,16 +177,14 @@ export class MapViewer {
|
||||
this.raycaster.setFromCamera(normalizedScreenPos, this.camera);
|
||||
|
||||
// check Object3D interactions
|
||||
/*
|
||||
const intersectScenes = [this.map.hiresTileManager.scene, this.markers];
|
||||
for (let i = 0; i < this.map.lowresTileManager.length; i++) {
|
||||
intersectScenes.push(this.map.lowresTileManager[i].scene);
|
||||
}
|
||||
*/
|
||||
|
||||
let intersects = this.raycaster.intersectObjects([this.map.hiresTileManager.scene, this.markers], true);
|
||||
let intersects = this.raycaster.intersectObjects(intersectScenes, true);
|
||||
let hit = null;
|
||||
let lowresHit = null;
|
||||
let lowresHits = [];
|
||||
let hiresHit = null;
|
||||
let covered = false;
|
||||
for (let i = 0; i < intersects.length; i++) {
|
||||
@ -208,11 +206,11 @@ export class MapViewer {
|
||||
let parentRoot = object;
|
||||
while(parentRoot.parent) parentRoot = parentRoot.parent;
|
||||
|
||||
/*
|
||||
if (parentRoot === this.map.lowresTileManager.scene) {
|
||||
if (!lowresHit) lowresHit = intersects[i];
|
||||
for (let l = 0; l < this.map.lowresTileManager.length; l++) {
|
||||
if (parentRoot === this.map.lowresTileManager[l].scene) {
|
||||
if (!lowresHits[l]) lowresHits[l] = intersects[i];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (parentRoot === this.map.hiresTileManager.scene) {
|
||||
if (!hiresHit) hiresHit = intersects[i];
|
||||
@ -225,9 +223,9 @@ export class MapViewer {
|
||||
})) return;
|
||||
}
|
||||
|
||||
//if (parentRoot !== this.map.lowresTileManager.scene) {
|
||||
if (parentRoot !== this.map.lowresTileManager[0].scene) {
|
||||
covered = true;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -237,7 +235,7 @@ export class MapViewer {
|
||||
data: data,
|
||||
hit: hit,
|
||||
hiresHit: hiresHit,
|
||||
lowresHit: lowresHit,
|
||||
lowresHits: lowresHits,
|
||||
intersections: intersects,
|
||||
ray: this.raycaster.ray
|
||||
});
|
||||
|
@ -53,7 +53,7 @@ void main() {
|
||||
vPosition = position;
|
||||
|
||||
vec4 meta = texture(textureImage, posToMetaUV(position.xz));
|
||||
vPosition.y += metaToHeight(meta);
|
||||
vPosition.y = metaToHeight(meta) + 1.0 - position.x * 0.0001 - position.z * 0.0002; //including small offset-tilt to prevent z-fighting
|
||||
|
||||
vec4 worldPos = modelMatrix * vec4(vPosition, 1);
|
||||
vec4 viewPos = viewMatrix * worldPos;
|
||||
|
Loading…
Reference in New Issue
Block a user