diff --git a/src/Layer/PointCloudLayer.js b/src/Layer/PointCloudLayer.js index 5043a0be26..51713cb92d 100644 --- a/src/Layer/PointCloudLayer.js +++ b/src/Layer/PointCloudLayer.js @@ -239,14 +239,12 @@ class PointCloudLayer extends GeometryLayer { if (this.material) { this.material.visible = this.visible; this.material.opacity = this.opacity; - this.material.transparent = this.material.userData.needTransparency[this.material.mode] || this.opacity < 1 || this.material.userData.needTransparency.classTransparency; - this.material.depthWrite = !this.material.userData.needTransparency.classTransparency; + this.material.depthWrite = false; this.material.size = this.pointSize; this.material.scale = context.camera.preSSE; if (this.material.updateUniforms) { this.material.updateUniforms(); } - this.material.needsUpdate = true; } // lookup lowest common ancestor of changeSources diff --git a/src/Renderer/PointsMaterial.js b/src/Renderer/PointsMaterial.js index ac9782bcc9..f926fca6fa 100644 --- a/src/Renderer/PointsMaterial.js +++ b/src/Renderer/PointsMaterial.js @@ -113,7 +113,6 @@ function generateGradientTexture(gradient) { } function recomputeTexture(scheme, texture, nbClass) { - let needTransparency; const data = texture.image.data; const width = texture.image.width; if (!nbClass) { nbClass = Object.keys(scheme).length; } @@ -141,11 +140,8 @@ function recomputeTexture(scheme, texture, nbClass) { data[j + 1] = parseInt(255 * color.g, 10); data[j + 2] = parseInt(255 * color.b, 10); data[j + 3] = parseInt(255 * opacity, 10); - - needTransparency = needTransparency || opacity < 1; } texture.needsUpdate = true; - return needTransparency; } class PointsMaterial extends THREE.ShaderMaterial { @@ -206,6 +202,7 @@ class PointsMaterial extends THREE.ShaderMaterial { super({ ...materialOptions, fog: true, + transparent: true, precision: 'highp', vertexColors: true, }); @@ -217,7 +214,6 @@ class PointsMaterial extends THREE.ShaderMaterial { this.vertexShader = PointsVS; this.fragmentShader = PointsFS; - this.userData.needTransparency = {}; this.gradients = gradients; this.gradientTexture = new THREE.CanvasTexture(); @@ -285,11 +281,6 @@ class PointsMaterial extends THREE.ShaderMaterial { * @returns {this} */ copy(source) { - // Manually copy this needTransparency if source doesn't have one. Prevents losing it when copying a three - // PointsMaterial into this PointsMaterial - const needTransparency = source.userData.needTransparency !== undefined ? source.userData.needTransparency - : this.userData.needTransparency; - if (source.isShaderMaterial) { super.copy(source); } else { @@ -304,8 +295,6 @@ class PointsMaterial extends THREE.ShaderMaterial { this.sizeAttenuation = source.sizeAttenuation; this.fog = source.fog; - this.userData.needTransparency = needTransparency; - return this; } @@ -376,8 +365,7 @@ class PointsMaterial extends THREE.ShaderMaterial { } recomputeClassification() { - const needTransparency = recomputeTexture(this.classificationScheme, this.classificationTexture, 256); - this.userData.needTransparency[PNTS_MODE.CLASSIFICATION] = needTransparency; + recomputeTexture(this.classificationScheme, this.classificationTexture, 256); this.dispatchEvent({ type: 'material_property_changed', target: this.uniforms, @@ -385,11 +373,7 @@ class PointsMaterial extends THREE.ShaderMaterial { } recomputeDiscreteTexture() { - const needTransparency = recomputeTexture(this.discreteScheme, this.discreteTexture); - this.userData.needTransparency[PNTS_MODE.RETURN_NUMBER] = needTransparency; - this.userData.needTransparency[PNTS_MODE.RETURN_TYPE] = needTransparency; - this.userData.needTransparency[PNTS_MODE.RETURN_COUNT] = needTransparency; - this.userData.needTransparency[PNTS_MODE.POINT_SOURCE_ID] = needTransparency; + recomputeTexture(this.discreteScheme, this.discreteTexture); this.dispatchEvent({ type: 'material_property_changed', target: this.uniforms, @@ -397,7 +381,6 @@ class PointsMaterial extends THREE.ShaderMaterial { } recomputeVisibleTexture() { - let needTransparency; const texture = this.visiTexture; const scheme = this.classificationScheme; @@ -416,12 +399,9 @@ class PointsMaterial extends THREE.ShaderMaterial { } data[i] = visible ? 255 : 0; - needTransparency = needTransparency || visible === false; } texture.needsUpdate = true; - this.userData.needTransparency.classTransparency = needTransparency; - this.dispatchEvent({ type: 'material_property_changed', target: this.uniforms,