File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
packages/three-coverage-heatmap/src
Material/VolumeRenderingMaterial Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ varying vec3 vRayOrigin;
14
14
15
15
${ calculateIntensity }
16
16
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
+
17
24
void main() {
18
25
vec3 aabbmin = vec3(-volumeSize.x / 2.0, 0.0, -volumeSize.z / 2.0);
19
26
vec3 aabbmax = vec3(volumeSize.x / 2.0, volumeSize.y, volumeSize.z / 2.0);
@@ -22,7 +29,11 @@ void main() {
22
29
if (intersection.x <= intersection.y) {
23
30
24
31
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
+ }
26
37
}
27
38
28
39
float nearestWall = 1e6;
Original file line number Diff line number Diff line change @@ -333,7 +333,11 @@ class App {
333
333
mesh . position . fromArray ( object . position ) ;
334
334
mesh . onBeforeRender = ( rendering , scene , camera ) => {
335
335
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
+ }
337
341
} ;
338
342
this . _billboardGroup . add ( mesh ) ;
339
343
} ) ;
You can’t perform that action at this time.
0 commit comments