Skip to content

Commit

Permalink
refacto(points): remove support of oriented images
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
* Remove non-tested and non-documented orientedImageMaterial property
  • Loading branch information
Desplandis committed Jul 9, 2024
1 parent 24b3641 commit c93a2cd
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 93 deletions.
32 changes: 1 addition & 31 deletions src/Renderer/PointsMaterial.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as THREE from 'three';
import PointsVS from 'Renderer/Shader/PointsVS.glsl';
import PointsFS from 'Renderer/Shader/PointsFS.glsl';
import ShaderUtils from 'Renderer/Shader/ShaderUtils';
import CommonMaterial from 'Renderer/CommonMaterial';
import Gradients from 'Utils/Gradients';

Expand Down Expand Up @@ -190,7 +189,6 @@ class PointsMaterial extends THREE.ShaderMaterial {
const intensityRange = options.intensityRange || new THREE.Vector2(1, 65536);
const elevationRange = options.elevationRange || new THREE.Vector2(0, 1000);
const angleRange = options.angleRange || new THREE.Vector2(-90, 90);
const oiMaterial = options.orientedImageMaterial;
const classificationScheme = options.classification || ClassificationScheme.DEFAULT;
const discreteScheme = options.discreteScheme || DiscreteScheme.DEFAULT;
const size = options.size || 0;
Expand All @@ -210,7 +208,6 @@ class PointsMaterial extends THREE.ShaderMaterial {
delete options.intensityRange;
delete options.elevationRange;
delete options.angleRange;
delete options.orientedImageMaterial;
delete options.classification;
delete options.discreteScheme;
delete options.size;
Expand Down Expand Up @@ -274,24 +271,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
this.gradient = Object.values(gradients)[0];
CommonMaterial.setUniformProperty(this, 'gradientTexture', this.gradientTexture);

if (oiMaterial) {
this.uniforms.projectiveTextureAlphaBorder = oiMaterial.uniforms.projectiveTextureAlphaBorder;
this.uniforms.projectiveTextureDistortion = oiMaterial.uniforms.projectiveTextureDistortion;
this.uniforms.projectiveTextureMatrix = oiMaterial.uniforms.projectiveTextureMatrix;
this.uniforms.projectiveTexture = oiMaterial.uniforms.projectiveTexture;
this.uniforms.mask = oiMaterial.uniforms.mask;
this.uniforms.boostLight = oiMaterial.uniforms.boostLight;
this.defines.ORIENTED_IMAGES_COUNT = oiMaterial.defines.ORIENTED_IMAGES_COUNT;
this.defines.USE_DISTORTION = oiMaterial.defines.USE_DISTORTION;
this.defines.DEBUG_ALPHA_BORDER = oiMaterial.defines.DEBUG_ALPHA_BORDER;
this.defines.USE_TEXTURES_PROJECTIVE = true;
this.defines.USE_BASE_MATERIAL = true;
// three loop unrolling of ShaderMaterial only supports integer
// bounds, see https://github.com/mrdoob/three.js/issues/28020
this.fragmentShader = ShaderUtils.unrollLoops(PointsFS, this.defines);
} else {
this.fragmentShader = PointsFS;
}
this.fragmentShader = PointsFS;

if (__DEBUG__) {
this.defines.DEBUG = 1;
Expand Down Expand Up @@ -321,16 +301,6 @@ class PointsMaterial extends THREE.ShaderMaterial {

copy(source) {
super.copy(source);
if (source.uniforms.projectiveTextureAlphaBorder) {
// Don't copy oriented image because, it's a link to oriented image material.
// It needs a reference to oriented image material.
this.uniforms.projectiveTextureAlphaBorder = source.uniforms.projectiveTextureAlphaBorder;
this.uniforms.projectiveTextureDistortion = source.uniforms.projectiveTextureDistortion;
this.uniforms.projectiveTextureMatrix = source.uniforms.projectiveTextureMatrix;
this.uniforms.projectiveTexture = source.uniforms.projectiveTexture;
this.uniforms.mask = source.uniforms.mask;
this.uniforms.boostLight = source.uniforms.boostLight;
}
return this;
}

Expand Down
16 changes: 0 additions & 16 deletions src/Renderer/Shader/PointsFS.glsl
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include <itowns/precision_qualifier>
#include <logdepthbuf_pars_fragment>
#if defined(USE_TEXTURES_PROJECTIVE)
#include <itowns/projective_texturing_pars_fragment>
#endif

varying vec4 vColor;
uniform bool picking;
Expand All @@ -18,18 +15,5 @@ void main() {
}
}

#if defined(USE_TEXTURES_PROJECTIVE)
vec4 color = vColor;
if (!picking) {
#pragma unroll_loop
for (int i = 0; i < ORIENTED_IMAGES_COUNT; i++) {
color = projectiveTextureColor(projectiveTextureCoords[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTextureDistortion[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTexture[ ORIENTED_IMAGES_COUNT - 1 - i ], mask[ORIENTED_IMAGES_COUNT - 1 - i], color);
}
gl_FragColor = vec4(color.rgb, color.a * opacity);
} else {
gl_FragColor = color;
}
#else
gl_FragColor = vColor;
#endif
}
6 changes: 0 additions & 6 deletions src/Renderer/Shader/PointsVS.glsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include <itowns/precision_qualifier>
#if defined(USE_TEXTURES_PROJECTIVE)
#include <itowns/projective_texturing_pars_vertex>
#endif
#include <common>
#include <logdepthbuf_pars_vertex>

Expand Down Expand Up @@ -117,8 +114,5 @@ void main() {
}
}

#if defined(USE_TEXTURES_PROJECTIVE)
#include <itowns/projective_texturing_vertex>
#endif
#include <logdepthbuf_vertex>
}
20 changes: 0 additions & 20 deletions test/unit/potree.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import View from 'Core/View';
import GlobeView from 'Core/Prefab/GlobeView';
import Coordinates from 'Core/Geographic/Coordinates';
import PotreeNode from 'Core/PotreeNode';
import PointsMaterial from 'Renderer/PointsMaterial';
import OrientedImageMaterial from 'Renderer/OrientedImageMaterial';
import sinon from 'sinon';
import Fetcher from 'Provider/Fetcher';
import Renderer from './bootstrap';
Expand Down Expand Up @@ -147,23 +145,5 @@ describe('Potree', function () {
).catch(done);
});
});

describe('Point Material and oriented images', () => {
const orientedImageMaterial = new OrientedImageMaterial([]);
const pMaterial = new PointsMaterial({ orientedImageMaterial });
const pMaterial2 = new PointsMaterial();
it('instance', () => {
assert.ok(pMaterial);
});
it('copy', () => {
pMaterial2.copy(pMaterial);
assert.equal(pMaterial2.uniforms.projectiveTextureAlphaBorder.value, 20);
});
it('update', () => {
pMaterial.visible = false;
pMaterial2.update(pMaterial);
assert.equal(pMaterial2.visible, false);
});
});
});
});
20 changes: 0 additions & 20 deletions test/unit/potree2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import Potree2BinParser from 'Parser/Potree2BinParser';
import View from 'Core/View';
import { HttpsProxyAgent } from 'https-proxy-agent';
import Potree2Node from 'Core/Potree2Node';
import PointsMaterial from 'Renderer/PointsMaterial';
import OrientedImageMaterial from 'Renderer/OrientedImageMaterial';
import { Vector3 } from 'three';
import Renderer from './bootstrap';

Expand Down Expand Up @@ -110,24 +108,6 @@ describe('Potree2', function () {
});
});

describe('Point Material and oriented images', () => {
const orientedImageMaterial = new OrientedImageMaterial([]);
const pMaterial = new PointsMaterial({ orientedImageMaterial });
const pMaterial2 = new PointsMaterial();
it('instance', () => {
assert.ok(pMaterial);
});
it('copy', () => {
pMaterial2.copy(pMaterial);
assert.equal(pMaterial2.uniforms.projectiveTextureAlphaBorder.value, 20);
});
it('update', () => {
pMaterial.visible = false;
pMaterial2.update(pMaterial);
assert.equal(pMaterial2.visible, false);
});
});

after(async function () {
await Potree2BinParser.terminate();
});
Expand Down

0 comments on commit c93a2cd

Please sign in to comment.