Skip to content

Commit

Permalink
refactor(points): Uniformize naming with three's points shader
Browse files Browse the repository at this point in the history
  • Loading branch information
Desplandis committed Dec 20, 2023
1 parent e6e1d80 commit d46cd44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Layer/PointCloudLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class PointCloudLayer extends GeometryLayer {
this.material.opacity = this.opacity;
this.material.transparent = this.opacity < 1;
this.material.size = this.pointSize;
this.material.preSSE = context.camera.preSSE;
this.material.scale = context.camera.preSSE;
if (this.material.updateUniforms) {
this.material.updateUniforms();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Renderer/PointsMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class PointsMaterial extends THREE.RawShaderMaterial {

this.vertexShader = PointsVS;

this.scale = options.scale || 0.05 * 0.5 / Math.tan(1.0 / 2.0); // autosizing scale
const scale = options.scale || 0.05 * 0.5 / Math.tan(1.0 / 2.0); // autosizing scale

CommonMaterial.setDefineMapping(this, 'PNTS_MODE', PNTS_MODE);
CommonMaterial.setDefineMapping(this, 'PNTS_SHAPE', PNTS_SHAPE);
Expand All @@ -123,7 +123,7 @@ class PointsMaterial extends THREE.RawShaderMaterial {
CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange);
CommonMaterial.setUniformProperty(this, 'applyOpacityClassication', applyOpacityClassication);
CommonMaterial.setUniformProperty(this, 'sizeMode', sizeMode);
CommonMaterial.setUniformProperty(this, 'preSSE', 1.0);
CommonMaterial.setUniformProperty(this, 'scale', scale);
CommonMaterial.setUniformProperty(this, 'minAttenuatedSize', minAttenuatedSize);
CommonMaterial.setUniformProperty(this, 'maxAttenuatedSize', maxAttenuatedSize);

Expand Down
4 changes: 2 additions & 2 deletions src/Renderer/Shader/PointsVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <logdepthbuf_pars_vertex>

uniform float size;
uniform float preSSE;
uniform float scale;

uniform bool picking;
uniform int mode;
Expand Down Expand Up @@ -109,7 +109,7 @@ void main() {
bool isPerspective = isPerspectiveMatrix(projectionMatrix);

if (isPerspective) {
gl_PointSize *= preSSE / -mvPosition.z;
gl_PointSize *= scale / -mvPosition.z;
gl_PointSize = clamp(gl_PointSize, minAttenuatedSize, maxAttenuatedSize);
}
}
Expand Down

0 comments on commit d46cd44

Please sign in to comment.