itowns 2.43.2-next.17 → 2.43.2-next.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Core/Style.js CHANGED
@@ -15,29 +15,30 @@ function baseAltitudeDefault(properties, ctx) {
15
15
  return ctx?.coordinates?.z || 0;
16
16
  }
17
17
  export function readExpression(property, ctx) {
18
- if (property != undefined) {
19
- if (property.expression) {
20
- return property.expression.evaluate(ctx);
21
- } else if (property.stops) {
22
- for (let i = property.stops.length - 1; i >= 0; i--) {
23
- const stop = property.stops[i];
24
- if (ctx.zoom >= stop[0]) {
25
- return stop[1];
26
- }
18
+ if (property.expression) {
19
+ return property.expression.evaluate(ctx);
20
+ }
21
+ if (property.stops) {
22
+ const stops = property.stops;
23
+ property = property.stops[0][1];
24
+ for (let i = stops.length - 1; i >= 0; i--) {
25
+ const stop = stops[i];
26
+ if (ctx.zoom >= stop[0]) {
27
+ property = stop[1];
28
+ break;
27
29
  }
28
- return property.stops[0][1];
29
- }
30
- if (typeof property === 'string' || property instanceof String) {
31
- property = property.replace(/\{(.+?)\}/g, (a, b) => ctx.properties[b] || '').trim();
32
30
  }
33
- if (property instanceof Function) {
34
- // TOBREAK: Pass the current `context` as a unique parameter.
35
- // In this proposal, metadata will be accessed in the callee by the
36
- // `context.properties` property.
37
- return property(ctx.properties, ctx);
38
- }
39
- return property;
40
31
  }
32
+ if (typeof property === 'string' || property instanceof String) {
33
+ return property.replace(/\{(.+?)\}/g, (a, b) => ctx.properties[b] || '').trim();
34
+ }
35
+ if (property instanceof Function) {
36
+ // TOBREAK: Pass the current `context` as a unique parameter.
37
+ // In this proposal, metadata will be accessed in the callee by the
38
+ // `context.properties` property.
39
+ return property(ctx.properties, ctx);
40
+ }
41
+ return property;
41
42
  }
42
43
  function rgba2rgb(orig) {
43
44
  if (!orig) {
@@ -48,7 +49,7 @@ function rgba2rgb(orig) {
48
49
  };
49
50
  } else if (typeof orig == 'string') {
50
51
  const result = orig.match(/(?:((hsl|rgb)a? *\(([\d.%]+(?:deg|g?rad|turn)?)[ ,]*([\d.%]+)[ ,]*([\d.%]+)[ ,/]*([\d.%]*)\))|(#((?:[\d\w]{3}){1,2})([\d\w]{1,2})?))/i);
51
- if (!result) {
52
+ if (result === null) {
52
53
  return {
53
54
  color: orig,
54
55
  opacity: 1.0
@@ -62,10 +63,10 @@ function rgba2rgb(orig) {
62
63
  color: `#${result[8]}`,
63
64
  opacity
64
65
  };
65
- } else if (result[0]) {
66
+ } else if (result[1]) {
66
67
  return {
67
68
  color: `${result[2]}(${result[3]},${result[4]},${result[5]})`,
68
- opacity: Number(result[6]) || 1.0
69
+ opacity: result[6] ? Number(result[6]) : 1.0
69
70
  };
70
71
  }
71
72
  }
@@ -692,31 +693,6 @@ class Style {
692
693
  defineStyleProperty(this, 'icon', 'color', params.icon.color);
693
694
  defineStyleProperty(this, 'icon', 'opacity', params.icon.opacity, 1.0);
694
695
  }
695
-
696
- /**
697
- * Copies the content of the target style into this style.
698
- * @param {Style} style - The style to copy.
699
- *
700
- * @return {Style} This style.
701
- */
702
- copy(style) {
703
- Object.assign(this.fill, style.fill);
704
- Object.assign(this.stroke, style.stroke);
705
- Object.assign(this.point, style.point);
706
- Object.assign(this.text, style.text);
707
- Object.assign(this.icon, style.icon);
708
- return this;
709
- }
710
-
711
- /**
712
- * Clones this style.
713
- *
714
- * @return {Style} The new style, cloned from this one.
715
- */
716
- clone() {
717
- const clone = new Style();
718
- return clone.copy(this);
719
- }
720
696
  setContext(ctx) {
721
697
  this.context = ctx;
722
698
  }
@@ -940,8 +916,35 @@ class Style {
940
916
  if (iconImg) {
941
917
  try {
942
918
  style.icon.id = iconImg;
919
+ if (iconImg.stops) {
920
+ const iconCropValue = {
921
+ ...(iconImg.base !== undefined && {
922
+ base: iconImg.base
923
+ }),
924
+ stops: iconImg.stops.map(stop => {
925
+ let cropValues = sprites[stop[1]];
926
+ if (stop[1].includes('{')) {
927
+ cropValues = function (p) {
928
+ const id = stop[1].replace(/\{(.+?)\}/g, (a, b) => p[b] || '').trim();
929
+ cropValues = sprites[id];
930
+ return sprites[id];
931
+ };
932
+ }
933
+ return [stop[0], cropValues];
934
+ })
935
+ };
936
+ style.icon.cropValues = iconCropValue;
937
+ } else {
938
+ style.icon.cropValues = sprites[iconImg];
939
+ if (iconImg[0].includes('{')) {
940
+ style.icon.cropValues = function (p) {
941
+ const id = iconImg.replace(/\{(.+?)\}/g, (a, b) => p[b] || '').trim();
942
+ style.icon.cropValues = sprites[id];
943
+ return sprites[id];
944
+ };
945
+ }
946
+ }
943
947
  style.icon.source = sprites.source;
944
- style.icon.cropValues = sprites[iconImg];
945
948
  style.icon.size = readVectorProperty(layer.layout['icon-size']) || 1;
946
949
  const {
947
950
  color,
@@ -38,7 +38,7 @@ function pntsParse(data, layer) {
38
38
  size: 1,
39
39
  mode: layer.pntsMode,
40
40
  shape: layer.pntsShape,
41
- classification: layer.classification,
41
+ classificationScheme: layer.classification,
42
42
  sizeMode: layer.pntsSizeMode,
43
43
  minAttenuatedSize: layer.pntsMinAttenuatedSize,
44
44
  maxAttenuatedSize: layer.pntsMaxAttenuatedSize
@@ -1,9 +1,8 @@
1
1
  import * as THREE from 'three';
2
2
  /* babel-plugin-inline-import './Shader/PointsVS.glsl' */
3
- const PointsVS = "#include <itowns/precision_qualifier>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_vertex>\n#endif\n#include <common>\n#include <logdepthbuf_pars_vertex>\n\n#define NB_CLASS 8.\n\nuniform float size;\nuniform float scale;\n\nuniform bool picking;\nuniform int mode;\nuniform float opacity;\nuniform vec4 overlayColor;\n\nuniform vec2 elevationRange;\nuniform vec2 intensityRange;\nuniform vec2 angleRange;\n\nuniform sampler2D classificationTexture;\nuniform sampler2D discreteTexture;\nuniform sampler2D gradientTexture;\nuniform int sizeMode;\nuniform float minAttenuatedSize;\nuniform float maxAttenuatedSize;\n\nattribute vec3 color;\nattribute vec2 range;\nattribute vec4 unique_id;\nattribute float intensity;\nattribute float classification;\nattribute float pointSourceID;\n\nattribute float returnNumber;\nattribute float numberOfReturns;\nattribute float scanAngle;\n\n#if defined(NORMAL_OCT16)\nattribute vec2 oct16Normal;\n#elif defined(NORMAL_SPHEREMAPPED)\nattribute vec2 sphereMappedNormal;\n#endif\n\nvarying vec4 vColor;\n\n// see https://web.archive.org/web/20150303053317/http://lgdv.cs.fau.de/get/1602\n// and implementation in PotreeConverter (BINPointReader.cpp) and potree (BinaryDecoderWorker.js)\n#if defined(NORMAL_OCT16)\nvec3 decodeOct16Normal(vec2 encodedNormal) {\n vec2 nNorm = 2. * (encodedNormal / 255.) - 1.;\n vec3 n;\n n.z = 1. - abs(nNorm.x) - abs(nNorm.y);\n if (n.z >= 0.) {\n n.x = nNorm.x;\n n.y = nNorm.y;\n } else {\n n.x = sign(nNorm.x) - sign(nNorm.x) * sign(nNorm.y) * nNorm.y;\n n.y = sign(nNorm.y) - sign(nNorm.y) * sign(nNorm.x) * nNorm.x;\n }\n return normalize(n);\n}\n#elif defined(NORMAL_SPHEREMAPPED)\n// see http://aras-p.info/texts/CompactNormalStorage.html method #4\n// or see potree's implementation in BINPointReader.cpp\nvec3 decodeSphereMappedNormal(vec2 encodedNormal) {\n vec2 fenc = 2. * encodedNormal / 255. - 1.;\n float f = dot(fenc,fenc);\n float g = 2. * sqrt(1. - f);\n vec3 n;\n n.xy = fenc * g;\n n.z = 1. - 2. * f;\n return n;\n}\n#endif\n\nvoid main() {\n\n#if defined(NORMAL_OCT16)\n vec3 normal = decodeOct16Normal(oct16Normal);\n#elif defined(NORMAL_SPHEREMAPPED)\n vec3 normal = decodeSphereMappedNormal(sphereMappedNormal);\n#elif defined(NORMAL)\n // nothing to do\n#else\n // default to color\n vec3 normal = color;\n#endif\n\n if (picking) {\n vColor = unique_id;\n } else {\n vColor.a = 1.0;\n if (mode == PNTS_MODE_CLASSIFICATION) {\n vec2 uv = vec2(classification/255., 0.5);\n vColor = texture2D(classificationTexture, uv);\n } else if (mode == PNTS_MODE_NORMAL) {\n vColor.rgb = abs(normal);\n } else if (mode == PNTS_MODE_COLOR) {\n // default to color mode\n vColor.rgb = mix(color, overlayColor.rgb, overlayColor.a);\n } else if (mode == PNTS_MODE_RETURN_NUMBER) {\n vec2 uv = vec2(returnNumber/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_TYPE) {\n float returnType;\n if (returnNumber > numberOfReturns) {\n returnType = 4.;\n } else if (returnNumber == 1.) {\n if (numberOfReturns == 1.) {\n // single\n returnType = 0.;\n } else {\n // first\n returnType = 1.;\n }\n } else {\n if (returnNumber == numberOfReturns) {\n // last\n returnType = 3.;\n } else {\n // intermediate\n returnType = 2.;\n }\n }\n vec2 uv = vec2(returnType/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_COUNT) {\n vec2 uv = vec2(numberOfReturns/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_POINT_SOURCE_ID) {\n vec2 uv = vec2(mod(pointSourceID, NB_CLASS)/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_SCAN_ANGLE) {\n float i = (scanAngle - angleRange.x) / (angleRange.y - angleRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_INTENSITY) {\n float i = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_ELEVATION) {\n float z = (modelMatrix * vec4(position, 1.0)).z;\n float i = (z - elevationRange.x) / (elevationRange.y - elevationRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n }\n\n vColor.a *= opacity;\n }\n\n #include <begin_vertex>\n #include <project_vertex>\n\n gl_PointSize = size;\n\n if (sizeMode == PNTS_SIZE_MODE_ATTENUATED) {\n bool isPerspective = isPerspectiveMatrix(projectionMatrix);\n\n if (isPerspective) {\n gl_PointSize *= scale / -mvPosition.z;\n gl_PointSize = clamp(gl_PointSize, minAttenuatedSize, maxAttenuatedSize);\n }\n }\n\n#if defined(USE_TEXTURES_PROJECTIVE)\n #include <itowns/projective_texturing_vertex>\n#endif\n #include <logdepthbuf_vertex>\n}\n";
3
+ const PointsVS = "#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec4 vColor; // color_pars_vertex\n\n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\n\n#define NB_CLASS 8.\n\nuniform float size;\nuniform float scale;\n\nuniform bool picking;\nuniform int mode;\n\nuniform vec2 elevationRange;\nuniform vec2 intensityRange;\nuniform vec2 angleRange;\n\nuniform sampler2D classificationTexture;\nuniform sampler2D discreteTexture;\nuniform sampler2D gradientTexture;\nuniform int sizeMode;\nuniform float minAttenuatedSize;\nuniform float maxAttenuatedSize;\n\nattribute vec4 unique_id;\nattribute float intensity;\nattribute float classification;\nattribute float pointSourceID;\n\nattribute float returnNumber;\nattribute float numberOfReturns;\nattribute float scanAngle;\n\nvoid main() {\n vColor = vec4(1.0);\n if (picking) {\n vColor = unique_id;\n } else {\n if (mode == PNTS_MODE_CLASSIFICATION) {\n vec2 uv = vec2(classification/255., 0.5);\n vColor = texture2D(classificationTexture, uv);\n } else if (mode == PNTS_MODE_NORMAL) {\n vColor.rgb = abs(normal);\n } else if (mode == PNTS_MODE_COLOR) {\n#if defined(USE_COLOR)\n vColor.rgb = color.rgb;\n#elif defined(USE_COLOR_ALPHA)\n vColor = color;\n#endif\n } else if (mode == PNTS_MODE_RETURN_NUMBER) {\n vec2 uv = vec2(returnNumber/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_TYPE) {\n float returnType;\n if (returnNumber > numberOfReturns) {\n returnType = 4.;\n } else if (returnNumber == 1.) {\n if (numberOfReturns == 1.) {\n // single\n returnType = 0.;\n } else {\n // first\n returnType = 1.;\n }\n } else {\n if (returnNumber == numberOfReturns) {\n // last\n returnType = 3.;\n } else {\n // intermediate\n returnType = 2.;\n }\n }\n vec2 uv = vec2(returnType/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_COUNT) {\n vec2 uv = vec2(numberOfReturns/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_POINT_SOURCE_ID) {\n vec2 uv = vec2(mod(pointSourceID, NB_CLASS)/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_SCAN_ANGLE) {\n float i = (scanAngle - angleRange.x) / (angleRange.y - angleRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_INTENSITY) {\n float i = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_ELEVATION) {\n float z = (modelMatrix * vec4(position, 1.0)).z;\n float i = (z - elevationRange.x) / (elevationRange.y - elevationRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n }\n }\n\n#define USE_COLOR_ALPHA\n#include <morphcolor_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <project_vertex>\n\n gl_PointSize = size;\n\n if (sizeMode == PNTS_SIZE_MODE_ATTENUATED) {\n bool isPerspective = isPerspectiveMatrix(projectionMatrix);\n\n if (isPerspective) {\n gl_PointSize *= scale / -mvPosition.z;\n gl_PointSize = clamp(gl_PointSize, minAttenuatedSize, maxAttenuatedSize);\n }\n }\n\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <fog_vertex>\n}\n";
4
4
  /* babel-plugin-inline-import './Shader/PointsFS.glsl' */
5
- const PointsFS = "#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_fragment>\n#endif\n\nvarying vec4 vColor;\nuniform bool picking;\nuniform int shape;\n\nvoid main() {\n #include <logdepthbuf_fragment>\n //square shape does not require any change.\n if (shape == PNTS_SHAPE_CIRCLE) {\n //circular rendering in glsl\n if ((length(gl_PointCoord - 0.5) > 0.5) || (vColor.a == 0.0)) {\n discard;\n }\n }\n\n#if defined(USE_TEXTURES_PROJECTIVE)\n vec4 color = vColor;\n if (!picking) {\n #pragma unroll_loop\n for (int i = 0; i < ORIENTED_IMAGES_COUNT; i++) {\n 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);\n }\n gl_FragColor = vec4(color.rgb, color.a * opacity);\n } else {\n gl_FragColor = color;\n }\n#else\n gl_FragColor = vColor;\n#endif\n}\n";
6
- import ShaderUtils from "./Shader/ShaderUtils.js";
5
+ const PointsFS = "#define USE_COLOR_ALPHA\n\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nuniform bool picking;\nuniform int shape;\n\nvoid main() {\n\n// Early discard (clipping planes and shape)\n#include <clipping_planes_pars_fragment>\n if (shape == PNTS_SHAPE_CIRCLE) {\n //circular rendering in glsl\n if ((length(gl_PointCoord - 0.5) > 0.5) || (vColor.a == 0.0)) {\n discard;\n }\n }\n\n#include <logdepthbuf_fragment>\n\n vec4 diffuseColor = vec4(diffuse, opacity);\n#include <map_particle_fragment>\n#include <color_fragment>\n\n#include <alphatest_fragment>\n#include <alphahash_fragment>\n\n vec3 outgoingLight = diffuseColor.rgb;\n#include <opaque_fragment> // gl_FragColor\n#include <tonemapping_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n\n}\n";
7
6
  import CommonMaterial from "./CommonMaterial.js";
8
7
  import Gradients from "../Utils/Gradients.js";
9
8
  export const PNTS_MODE = {
@@ -267,7 +266,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
267
266
  * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range.
268
267
  * @param {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range.
269
268
  * @param {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range.
270
- * @param {Scheme} [options.classification] LUT for point classification colorization.
269
+ * @param {Scheme} [options.classificationScheme] LUT for point classification colorization.
271
270
  * @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
272
271
  * @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
273
272
  * (Default value will be the 'SPECTRAL' gradient from Utils/Gradients)
@@ -289,54 +288,49 @@ class PointsMaterial extends THREE.ShaderMaterial {
289
288
  */
290
289
  constructor() {
291
290
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
292
- const intensityRange = options.intensityRange || new THREE.Vector2(1, 65536);
293
- const elevationRange = options.elevationRange || new THREE.Vector2(0, 1000);
294
- const angleRange = options.angleRange || new THREE.Vector2(-90, 90);
295
- const oiMaterial = options.orientedImageMaterial;
296
- const classificationScheme = options.classification || ClassificationScheme.DEFAULT;
297
- const discreteScheme = options.discreteScheme || DiscreteScheme.DEFAULT;
298
- const size = options.size || 0;
299
- const mode = options.mode || PNTS_MODE.COLOR;
300
- const shape = options.shape || PNTS_SHAPE.CIRCLE;
301
- const sizeMode = size === 0 ? PNTS_SIZE_MODE.ATTENUATED : options.sizeMode || PNTS_SIZE_MODE.VALUE;
302
- const minAttenuatedSize = options.minAttenuatedSize || 3;
303
- const maxAttenuatedSize = options.maxAttenuatedSize || 10;
304
- let gradients = Gradients;
305
- if (options.gradient) {
306
- gradients = {
307
- ...options.gradient,
308
- ...Gradients
309
- };
310
- }
311
- delete options.intensityRange;
312
- delete options.elevationRange;
313
- delete options.angleRange;
314
- delete options.orientedImageMaterial;
315
- delete options.classification;
316
- delete options.discreteScheme;
317
- delete options.size;
318
- delete options.mode;
319
- delete options.shape;
320
- delete options.sizeMode;
321
- delete options.minAttenuatedSize;
322
- delete options.maxAttenuatedSize;
323
- delete options.gradient;
324
- super(options);
291
+ const gradients = {
292
+ ...options.gradient,
293
+ ...Gradients
294
+ };
295
+ options.gradient = Object.values(gradients)[0];
296
+ const {
297
+ intensityRange = new THREE.Vector2(1, 65536),
298
+ elevationRange = new THREE.Vector2(0, 1000),
299
+ angleRange = new THREE.Vector2(-90, 90),
300
+ classificationScheme = ClassificationScheme.DEFAULT,
301
+ discreteScheme = DiscreteScheme.DEFAULT,
302
+ size = 1,
303
+ mode = PNTS_MODE.COLOR,
304
+ shape = PNTS_SHAPE.CIRCLE,
305
+ sizeMode = PNTS_SIZE_MODE.ATTENUATED,
306
+ minAttenuatedSize = 3,
307
+ maxAttenuatedSize = 10,
308
+ gradient,
309
+ scale = 0.05 * 0.5 / Math.tan(1.0 / 2.0),
310
+ ...materialOptions
311
+ } = options;
312
+ super({
313
+ ...materialOptions,
314
+ fog: true,
315
+ precision: 'highp',
316
+ vertexColors: true
317
+ });
318
+ this.uniforms = THREE.UniformsUtils.merge([
319
+ // THREE.PointsMaterial uniforms
320
+ THREE.UniformsLib.points, THREE.UniformsLib.fog]);
321
+ this.vertexShader = PointsVS;
322
+ this.fragmentShader = PointsFS;
325
323
  this.userData.needTransparency = {};
326
324
  this.gradients = gradients;
327
325
  this.gradientTexture = new THREE.CanvasTexture();
328
- this.vertexShader = PointsVS;
329
- const scale = options.scale || 0.05 * 0.5 / Math.tan(1.0 / 2.0); // autosizing scale
330
-
331
326
  CommonMaterial.setDefineMapping(this, 'PNTS_MODE', PNTS_MODE);
332
327
  CommonMaterial.setDefineMapping(this, 'PNTS_SHAPE', PNTS_SHAPE);
333
328
  CommonMaterial.setDefineMapping(this, 'PNTS_SIZE_MODE', PNTS_SIZE_MODE);
334
- CommonMaterial.setUniformProperty(this, 'size', size);
329
+ this.size = size;
335
330
  CommonMaterial.setUniformProperty(this, 'mode', mode);
336
331
  CommonMaterial.setUniformProperty(this, 'shape', shape);
337
332
  CommonMaterial.setUniformProperty(this, 'picking', false);
338
333
  CommonMaterial.setUniformProperty(this, 'opacity', this.opacity);
339
- CommonMaterial.setUniformProperty(this, 'overlayColor', options.overlayColor || new THREE.Vector4(0, 0, 0, 0));
340
334
  CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange);
341
335
  CommonMaterial.setUniformProperty(this, 'elevationRange', elevationRange);
342
336
  CommonMaterial.setUniformProperty(this, 'angleRange', angleRange);
@@ -368,26 +362,95 @@ class PointsMaterial extends THREE.ShaderMaterial {
368
362
  this.recomputeDiscreteTexture();
369
363
 
370
364
  // Gradient texture for continuous values
371
- this.gradient = Object.values(gradients)[0];
365
+ this.gradient = gradient;
372
366
  CommonMaterial.setUniformProperty(this, 'gradientTexture', this.gradientTexture);
373
- if (oiMaterial) {
374
- this.uniforms.projectiveTextureAlphaBorder = oiMaterial.uniforms.projectiveTextureAlphaBorder;
375
- this.uniforms.projectiveTextureDistortion = oiMaterial.uniforms.projectiveTextureDistortion;
376
- this.uniforms.projectiveTextureMatrix = oiMaterial.uniforms.projectiveTextureMatrix;
377
- this.uniforms.projectiveTexture = oiMaterial.uniforms.projectiveTexture;
378
- this.uniforms.mask = oiMaterial.uniforms.mask;
379
- this.uniforms.boostLight = oiMaterial.uniforms.boostLight;
380
- this.defines.ORIENTED_IMAGES_COUNT = oiMaterial.defines.ORIENTED_IMAGES_COUNT;
381
- this.defines.USE_DISTORTION = oiMaterial.defines.USE_DISTORTION;
382
- this.defines.DEBUG_ALPHA_BORDER = oiMaterial.defines.DEBUG_ALPHA_BORDER;
383
- this.defines.USE_TEXTURES_PROJECTIVE = true;
384
- this.defines.USE_BASE_MATERIAL = true;
385
- // three loop unrolling of ShaderMaterial only supports integer
386
- // bounds, see https://github.com/mrdoob/three.js/issues/28020
387
- this.fragmentShader = ShaderUtils.unrollLoops(PointsFS, this.defines);
367
+ }
368
+
369
+ /**
370
+ * Copy the parameters from the passed material into this material.
371
+ * @override
372
+ * @param {THREE.PointsMaterial} source
373
+ * @returns {this}
374
+ */
375
+ copy(source) {
376
+ if (source.isShaderMaterial) {
377
+ super.copy(source);
388
378
  } else {
389
- this.fragmentShader = PointsFS;
379
+ THREE.Material.prototype.copy.call(this, source);
380
+ }
381
+
382
+ // Parameters of THREE.PointsMaterial
383
+ this.color.copy(source.color);
384
+ this.map = source.map;
385
+ this.alphaMap = source.alphaMap;
386
+ this.size = source.size;
387
+ this.sizeAttenuation = source.sizeAttenuation;
388
+ this.fog = source.fog;
389
+ return this;
390
+ }
391
+
392
+ /** @returns {THREE.Color} */
393
+ get color() {
394
+ return this.uniforms.diffuse.value;
395
+ }
396
+
397
+ /** @param {THREE.Color} color */
398
+ set color(color) {
399
+ this.uniforms.diffuse.value.copy(color);
400
+ }
401
+
402
+ /** @returns {THREE.Texture | null} */
403
+ get map() {
404
+ return this.uniforms.map.value;
405
+ }
406
+
407
+ /** @param {THREE.Texture | null} map */
408
+ set map(map) {
409
+ this.uniforms.map.value = map;
410
+ if (!map) {
411
+ return;
390
412
  }
413
+ if (map.matrixAutoUpdate) {
414
+ map.updateMatrix();
415
+ }
416
+ this.uniforms.uvTransform.value.copy(map.matrix);
417
+ }
418
+
419
+ /** @returns {THREE.Texture | null} */
420
+ get alphaMap() {
421
+ return this.uniforms.alphaMap.value;
422
+ }
423
+
424
+ /** @param {THREE.Texture | null} map */
425
+ set alphaMap(map) {
426
+ this.uniforms.alphaMap.value = map;
427
+ if (!map) {
428
+ return;
429
+ }
430
+ if (map.matrixAutoUpdate) {
431
+ map.updateMatrix();
432
+ }
433
+ this.uniforms.alphaMapTransform.value.copy(map.matrix);
434
+ }
435
+
436
+ /** @returns {number} */
437
+ get size() {
438
+ return this.uniforms.size.value;
439
+ }
440
+
441
+ /** @param {number} size */
442
+ set size(size) {
443
+ this.uniforms.size.value = size;
444
+ }
445
+
446
+ /** @returns {boolean} */
447
+ get sizeAttenuation() {
448
+ return this.sizeMode !== PNTS_SIZE_MODE.VALUE;
449
+ }
450
+
451
+ /** @param {boolean} value */
452
+ set sizeAttenuation(value) {
453
+ this.sizeMode = value ? PNTS_SIZE_MODE.ATTENUATED : PNTS_SIZE_MODE.VALUE;
391
454
  }
392
455
  recomputeClassification() {
393
456
  const needTransparency = recomputeTexture(this.classificationScheme, this.classificationTexture, 256);
@@ -408,43 +471,10 @@ class PointsMaterial extends THREE.ShaderMaterial {
408
471
  target: this.uniforms
409
472
  });
410
473
  }
411
- copy(source) {
412
- super.copy(source);
413
- if (source.uniforms.projectiveTextureAlphaBorder) {
414
- // Don't copy oriented image because, it's a link to oriented image material.
415
- // It needs a reference to oriented image material.
416
- this.uniforms.projectiveTextureAlphaBorder = source.uniforms.projectiveTextureAlphaBorder;
417
- this.uniforms.projectiveTextureDistortion = source.uniforms.projectiveTextureDistortion;
418
- this.uniforms.projectiveTextureMatrix = source.uniforms.projectiveTextureMatrix;
419
- this.uniforms.projectiveTexture = source.uniforms.projectiveTexture;
420
- this.uniforms.mask = source.uniforms.mask;
421
- this.uniforms.boostLight = source.uniforms.boostLight;
422
- }
423
- return this;
424
- }
425
474
  enablePicking(picking) {
426
475
  this.picking = picking;
427
476
  this.blending = picking ? THREE.NoBlending : THREE.NormalBlending;
428
477
  }
429
- update(source) {
430
- this.visible = source.visible;
431
- this.opacity = source.opacity;
432
- this.transparent = source.transparent;
433
- this.size = source.size;
434
- this.mode = source.mode;
435
- this.shape = source.shape;
436
- this.sizeMode = source.sizeMode;
437
- this.minAttenuatedSize = source.minAttenuatedSize;
438
- this.maxAttenuatedSize = source.maxAttenuatedSize;
439
- this.picking = source.picking;
440
- this.scale = source.scale;
441
- this.overlayColor.copy(source.overlayColor);
442
- this.intensityRange.copy(source.intensityRange);
443
- this.elevationRange.copy(source.elevationRange);
444
- this.angleRange.copy(source.angleRange);
445
- Object.assign(this.defines, source.defines);
446
- return this;
447
- }
448
478
  set gradient(value) {
449
479
  this.gradientTexture = generateGradientTexture(value);
450
480
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.43.2-next.17",
3
+ "version": "2.43.2-next.19",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",