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);
|
this.raycaster.setFromCamera(normalizedScreenPos, this.camera);
|
||||||
|
|
||||||
// check Object3D interactions
|
// check Object3D interactions
|
||||||
/*
|
|
||||||
const intersectScenes = [this.map.hiresTileManager.scene, this.markers];
|
const intersectScenes = [this.map.hiresTileManager.scene, this.markers];
|
||||||
for (let i = 0; i < this.map.lowresTileManager.length; i++) {
|
for (let i = 0; i < this.map.lowresTileManager.length; i++) {
|
||||||
intersectScenes.push(this.map.lowresTileManager[i].scene);
|
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 hit = null;
|
||||||
let lowresHit = null;
|
let lowresHits = [];
|
||||||
let hiresHit = null;
|
let hiresHit = null;
|
||||||
let covered = false;
|
let covered = false;
|
||||||
for (let i = 0; i < intersects.length; i++) {
|
for (let i = 0; i < intersects.length; i++) {
|
||||||
|
@ -208,11 +206,11 @@ export class MapViewer {
|
||||||
let parentRoot = object;
|
let parentRoot = object;
|
||||||
while(parentRoot.parent) parentRoot = parentRoot.parent;
|
while(parentRoot.parent) parentRoot = parentRoot.parent;
|
||||||
|
|
||||||
/*
|
for (let l = 0; l < this.map.lowresTileManager.length; l++) {
|
||||||
if (parentRoot === this.map.lowresTileManager.scene) {
|
if (parentRoot === this.map.lowresTileManager[l].scene) {
|
||||||
if (!lowresHit) lowresHit = intersects[i];
|
if (!lowresHits[l]) lowresHits[l] = intersects[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if (parentRoot === this.map.hiresTileManager.scene) {
|
if (parentRoot === this.map.hiresTileManager.scene) {
|
||||||
if (!hiresHit) hiresHit = intersects[i];
|
if (!hiresHit) hiresHit = intersects[i];
|
||||||
|
@ -225,9 +223,9 @@ export class MapViewer {
|
||||||
})) return;
|
})) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (parentRoot !== this.map.lowresTileManager.scene) {
|
if (parentRoot !== this.map.lowresTileManager[0].scene) {
|
||||||
covered = true;
|
covered = true;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +235,7 @@ export class MapViewer {
|
||||||
data: data,
|
data: data,
|
||||||
hit: hit,
|
hit: hit,
|
||||||
hiresHit: hiresHit,
|
hiresHit: hiresHit,
|
||||||
lowresHit: lowresHit,
|
lowresHits: lowresHits,
|
||||||
intersections: intersects,
|
intersections: intersects,
|
||||||
ray: this.raycaster.ray
|
ray: this.raycaster.ray
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,7 +53,7 @@ void main() {
|
||||||
vPosition = position;
|
vPosition = position;
|
||||||
|
|
||||||
vec4 meta = texture(textureImage, posToMetaUV(position.xz));
|
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 worldPos = modelMatrix * vec4(vPosition, 1);
|
||||||
vec4 viewPos = viewMatrix * worldPos;
|
vec4 viewPos = viewMatrix * worldPos;
|
||||||
|
|
Loading…
Reference in New Issue