@@ -123,19 +123,15 @@ function recomputeTexture(scheme, texture, nbClass) {
123
123
for ( let i = 0 ; i < width ; i ++ ) {
124
124
let color ;
125
125
let opacity ;
126
- let visible = true ;
127
126
128
127
if ( scheme [ i ] ) {
129
128
color = scheme [ i ] . color ;
130
- visible = scheme [ i ] . visible ;
131
129
opacity = scheme [ i ] . opacity ;
132
130
} else if ( scheme [ i % nbClass ] ) {
133
131
color = scheme [ i % nbClass ] . color ;
134
- visible = scheme [ i % nbClass ] . visible ;
135
132
opacity = scheme [ i % nbClass ] . opacity ;
136
133
} else if ( scheme . DEFAULT ) {
137
134
color = scheme . DEFAULT . color ;
138
- visible = scheme . DEFAULT . visible ;
139
135
opacity = scheme . DEFAULT . opacity ;
140
136
} else {
141
137
color = white ;
@@ -146,9 +142,9 @@ function recomputeTexture(scheme, texture, nbClass) {
146
142
data [ j + 0 ] = parseInt ( 255 * color . r , 10 ) ;
147
143
data [ j + 1 ] = parseInt ( 255 * color . g , 10 ) ;
148
144
data [ j + 2 ] = parseInt ( 255 * color . b , 10 ) ;
149
- data [ j + 3 ] = visible ? parseInt ( 255 * opacity , 10 ) : 0 ;
145
+ data [ j + 3 ] = parseInt ( 255 * opacity , 10 ) ;
150
146
151
- needTransparency = needTransparency || opacity < 1 || ! visible ;
147
+ needTransparency = needTransparency || opacity < 1 ;
152
148
}
153
149
texture . needsUpdate = true ;
154
150
return needTransparency ;
@@ -258,13 +254,22 @@ class PointsMaterial extends THREE.ShaderMaterial {
258
254
textureLUT . magFilter = THREE . NearestFilter ;
259
255
CommonMaterial . setUniformProperty ( this , 'discreteTexture' , textureLUT ) ;
260
256
257
+ // add texture to apply visibility.
258
+ const dataVisi = new Uint8Array ( 256 * 1 ) ;
259
+ const textureVisi = new THREE . DataTexture ( dataVisi , 256 , 1 , THREE . RedFormat ) ;
260
+
261
+ textureVisi . needsUpdate = true ;
262
+ textureVisi . magFilter = THREE . NearestFilter ;
263
+ CommonMaterial . setUniformProperty ( this , 'visiTexture' , textureVisi ) ;
264
+
261
265
// Classification and other discrete values scheme
262
266
this . classificationScheme = classificationScheme ;
263
267
this . discreteScheme = discreteScheme ;
264
268
265
269
// Update classification and discrete Texture
266
270
this . recomputeClassification ( ) ;
267
271
this . recomputeDiscreteTexture ( ) ;
272
+ this . recomputeVisibleTexture ( ) ;
268
273
269
274
// Gradient texture for continuous values
270
275
this . gradient = gradient ;
@@ -386,6 +391,35 @@ class PointsMaterial extends THREE.ShaderMaterial {
386
391
} ) ;
387
392
}
388
393
394
+ recomputeVisibleTexture ( ) {
395
+ const texture = this . visiTexture ;
396
+ const scheme = this . classificationScheme ;
397
+
398
+ const data = texture . image . data ;
399
+ const width = texture . image . width ;
400
+
401
+ for ( let i = 0 ; i < width ; i ++ ) {
402
+ let visible ;
403
+
404
+ if ( scheme [ i ] ) {
405
+ visible = scheme [ i ] . visible ;
406
+ } else if ( scheme . DEFAULT ) {
407
+ visible = scheme . DEFAULT . visible ;
408
+ } else {
409
+ visible = true ;
410
+ }
411
+
412
+ data [ i ] = visible ? 255 : 0 ;
413
+ }
414
+ texture . needsUpdate = true ;
415
+
416
+
417
+ this . dispatchEvent ( {
418
+ type : 'material_property_changed' ,
419
+ target : this . uniforms ,
420
+ } ) ;
421
+ }
422
+
389
423
enablePicking ( picking ) {
390
424
this . picking = picking ;
391
425
this . blending = picking ? THREE . NoBlending : THREE . NormalBlending ;
0 commit comments