Skip to content

Commit 0ab308c

Browse files
committed
fix: remove back-size aabb intersection and lable.
1 parent 594c0e7 commit 0ab308c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/three-coverage-heatmap/src/Material/VolumeRenderingMaterial/fragmentShader.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ varying vec3 vRayOrigin;
1414
1515
${calculateIntensity}
1616
17+
bool isRayOriginInAABB(vec3 vRayOrigin, vec3 aabbmin, vec3 aabbmax) {
18+
bool insideX = (vRayOrigin.x >= aabbmin.x) && (vRayOrigin.x <= aabbmax.x);
19+
bool insideY = (vRayOrigin.y >= aabbmin.y) && (vRayOrigin.y <= aabbmax.y);
20+
bool insideZ = (vRayOrigin.z >= aabbmin.z) && (vRayOrigin.z <= aabbmax.z);
21+
return insideX && insideY && insideZ;
22+
}
23+
1724
void main() {
1825
vec3 aabbmin = vec3(-volumeSize.x / 2.0, 0.0, -volumeSize.z / 2.0);
1926
vec3 aabbmax = vec3(volumeSize.x / 2.0, volumeSize.y, volumeSize.z / 2.0);
@@ -22,7 +29,11 @@ void main() {
2229
if (intersection.x <= intersection.y) {
2330
2431
if (intersection.x < 0.0) {
25-
intersection.x = 1e-3;
32+
if (isRayOriginInAABB(vRayOrigin, aabbmin, aabbmax)) {
33+
intersection.x = 1e-3;
34+
} else {
35+
discard;
36+
}
2637
}
2738
2839
float nearestWall = 1e6;

packages/three-coverage-heatmap/src/app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,11 @@ class App {
333333
mesh.position.fromArray(object.position);
334334
mesh.onBeforeRender = (rendering, scene, camera) => {
335335
const coord = mesh.position.clone().project(camera);
336-
object.onViewportChange(coord.x / 2 + 0.5, -coord.y / 2 + 0.5);
336+
if (coord.z > 1) {
337+
object.onViewportChange(-1, -1);
338+
} else {
339+
object.onViewportChange(coord.x / 2 + 0.5, -coord.y / 2 + 0.5);
340+
}
337341
};
338342
this._billboardGroup.add(mesh);
339343
});

0 commit comments

Comments
 (0)