itowns 2.42.1-next.2 → 2.42.1-next.21
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/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_widgets.js +1 -1
- package/dist/itowns_widgets.js.map +1 -1
- package/examples/{.eslintrc.js → .eslintrc.cjs} +1 -1
- package/examples/effects_stereo.html +2 -2
- package/examples/entwine_simple_loader.html +24 -8
- package/examples/misc_collada.html +2 -2
- package/examples/misc_instancing.html +1 -1
- package/examples/source_file_gpx_3d.html +2 -2
- package/examples/source_stream_wfs_25d.html +11 -11
- package/examples/source_stream_wfs_3d.html +1 -1
- package/examples/vector_tile_3d_mesh.html +2 -2
- package/examples/vector_tile_raster_2d.html +1 -1
- package/examples/vector_tile_raster_3d.html +1 -1
- package/examples/view_25d_map.html +2 -2
- package/examples/view_3d_map.html +3 -3
- package/examples/view_3d_map_webxr.html +1 -1
- package/examples/view_3d_mns_map.html +3 -3
- package/examples/view_immersive.html +1 -1
- package/examples/view_multi_25d.html +2 -2
- package/examples/widgets_minimap.html +1 -1
- package/examples/widgets_searchbar.html +2 -2
- package/lib/Controls/FirstPersonControls.js +5 -12
- package/lib/Controls/FlyControls.js +4 -13
- package/lib/Controls/GlobeControls.js +33 -43
- package/lib/Controls/PlanarControls.js +9 -20
- package/lib/Controls/StateControl.js +2 -11
- package/lib/Controls/StreetControls.js +14 -24
- package/lib/Converter/Feature2Mesh.js +77 -70
- package/lib/Converter/Feature2Texture.js +15 -25
- package/lib/Converter/convertToTile.js +16 -26
- package/lib/Converter/textureConverter.js +9 -19
- package/lib/Core/3DTiles/C3DTBatchTable.js +5 -13
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +1 -8
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +17 -27
- package/lib/Core/3DTiles/C3DTExtensions.js +1 -8
- package/lib/Core/3DTiles/C3DTFeature.js +3 -10
- package/lib/Core/3DTiles/C3DTilesEnums.js +3 -11
- package/lib/Core/3DTiles/C3DTileset.js +7 -16
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +5 -11
- package/lib/Core/AnimationPlayer.js +2 -11
- package/lib/Core/Deprecated/Undeprecator.js +9 -20
- package/lib/Core/EntwinePointTileNode.js +6 -16
- package/lib/Core/Feature.js +16 -30
- package/lib/Core/Geographic/CoordStars.js +3 -12
- package/lib/Core/Geographic/Coordinates.js +12 -22
- package/lib/Core/Geographic/Crs.js +7 -15
- package/lib/Core/Geographic/Extent.js +36 -47
- package/lib/Core/Geographic/GeoidGrid.js +6 -16
- package/lib/Core/Label.js +7 -17
- package/lib/Core/MainLoop.js +7 -16
- package/lib/Core/Math/Ellipsoid.js +6 -17
- package/lib/Core/Picking.js +10 -20
- package/lib/Core/PointCloudNode.js +2 -11
- package/lib/Core/PotreeNode.js +4 -13
- package/lib/Core/Prefab/Globe/Atmosphere.js +17 -26
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +6 -16
- package/lib/Core/Prefab/Globe/GlobeLayer.js +19 -28
- package/lib/Core/Prefab/Globe/SkyShader.js +2 -11
- package/lib/Core/Prefab/GlobeView.js +27 -45
- package/lib/Core/Prefab/Planar/PlanarLayer.js +11 -20
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +6 -16
- package/lib/Core/Prefab/PlanarView.js +10 -25
- package/lib/Core/Prefab/TileBuilder.js +13 -22
- package/lib/Core/Prefab/computeBufferTileGeometry.js +12 -16
- package/lib/Core/Scheduler/Cache.js +2 -10
- package/lib/Core/Scheduler/CancelledCommandException.js +1 -8
- package/lib/Core/Scheduler/Scheduler.js +15 -23
- package/lib/Core/Style.js +26 -40
- package/lib/Core/System/Capabilities.js +2 -13
- package/lib/Core/TileGeometry.js +13 -15
- package/lib/Core/TileMesh.js +6 -15
- package/lib/Core/View.js +43 -58
- package/lib/Layer/C3DTilesLayer.js +29 -41
- package/lib/Layer/ColorLayer.js +10 -16
- package/lib/Layer/ElevationLayer.js +7 -14
- package/lib/Layer/EntwinePointTileLayer.js +11 -18
- package/lib/Layer/FeatureGeometryLayer.js +9 -16
- package/lib/Layer/GeoidLayer.js +6 -15
- package/lib/Layer/GeometryLayer.js +11 -17
- package/lib/Layer/InfoLayer.js +5 -14
- package/lib/Layer/LabelLayer.js +22 -32
- package/lib/Layer/Layer.js +16 -26
- package/lib/Layer/LayerUpdateState.js +1 -8
- package/lib/Layer/LayerUpdateStrategy.js +7 -18
- package/lib/Layer/OrientedImageLayer.js +15 -25
- package/lib/Layer/PointCloudLayer.js +27 -24
- package/lib/Layer/PotreeLayer.js +8 -18
- package/lib/Layer/RasterLayer.js +9 -17
- package/lib/Layer/ReferencingLayerProperties.js +1 -8
- package/lib/Layer/TiledGeometryLayer.js +37 -33
- package/lib/Main.js +86 -707
- package/lib/MainBundle.js +4 -34
- package/lib/Parser/B3dmParser.js +80 -131
- package/lib/Parser/CameraCalibrationParser.js +5 -14
- package/lib/Parser/GDFParser.js +11 -22
- package/lib/Parser/GLTFParser.js +88 -0
- package/lib/Parser/GTXParser.js +9 -21
- package/lib/Parser/GeoJsonParser.js +14 -22
- package/lib/Parser/GpxParser.js +7 -14
- package/lib/Parser/ISGParser.js +19 -28
- package/lib/Parser/KMLParser.js +7 -14
- package/lib/Parser/LASLoader.js +31 -21
- package/lib/Parser/LASParser.js +10 -17
- package/lib/Parser/MapBoxUrlParser.js +2 -9
- package/lib/Parser/PntsParser.js +4 -14
- package/lib/Parser/PotreeBinParser.js +8 -16
- package/lib/Parser/PotreeCinParser.js +3 -12
- package/lib/Parser/ShapefileParser.js +11 -18
- package/lib/Parser/VectorTileParser.js +23 -31
- package/lib/Parser/XbilParser.js +5 -13
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +2 -12
- package/lib/Process/3dTilesProcessing.js +14 -27
- package/lib/Process/FeatureProcessing.js +14 -22
- package/lib/Process/LayeredMaterialNodeProcessing.js +19 -28
- package/lib/Process/ObjectRemovalHelper.js +2 -9
- package/lib/Process/handlerNodeError.js +1 -7
- package/lib/Provider/3dTilesProvider.js +32 -29
- package/lib/Provider/DataSourceProvider.js +2 -9
- package/lib/Provider/Fetcher.js +40 -22
- package/lib/Provider/PointCloudProvider.js +7 -19
- package/lib/Provider/TileProvider.js +4 -12
- package/lib/Provider/URLBuilder.js +4 -12
- package/lib/Renderer/Camera.js +7 -17
- package/lib/Renderer/Color.js +3 -11
- package/lib/Renderer/ColorLayersOrdering.js +14 -22
- package/lib/Renderer/CommonMaterial.js +3 -12
- package/lib/Renderer/Label2DRenderer.js +5 -16
- package/lib/Renderer/LayeredMaterial.js +33 -53
- package/lib/Renderer/OBB.js +12 -21
- package/lib/Renderer/OrientedImageCamera.js +2 -11
- package/lib/Renderer/OrientedImageMaterial.js +17 -35
- package/lib/Renderer/PointsMaterial.js +224 -94
- package/lib/Renderer/RasterTile.js +18 -30
- package/lib/Renderer/RenderMode.js +2 -9
- package/lib/Renderer/Shader/ShaderChunk.js +5 -23
- package/lib/Renderer/Shader/ShaderUtils.js +2 -9
- package/lib/Renderer/SphereHelper.js +2 -11
- package/lib/Renderer/WebXR.js +2 -11
- package/lib/Renderer/c3DEngine.js +20 -53
- package/lib/Source/C3DTilesGoogleSource.js +76 -0
- package/lib/Source/C3DTilesIonSource.js +6 -13
- package/lib/Source/C3DTilesSource.js +5 -12
- package/lib/Source/EntwinePointTileSource.js +12 -19
- package/lib/Source/FileSource.js +7 -14
- package/lib/Source/OrientedImageSource.js +6 -14
- package/lib/Source/PotreeSource.js +9 -16
- package/lib/Source/Source.js +26 -39
- package/lib/Source/TMSSource.js +11 -22
- package/lib/Source/VectorTilesSource.js +75 -34
- package/lib/Source/WFSSource.js +7 -14
- package/lib/Source/WMSSource.js +5 -12
- package/lib/Source/WMTSSource.js +3 -10
- package/lib/ThreeExtended/capabilities/WebGL.js +1 -8
- package/lib/ThreeExtended/libs/ktx-parse.module.js +2 -256
- package/lib/ThreeExtended/libs/zstddec.module.js +2 -8
- package/lib/ThreeExtended/loaders/DDSLoader.js +10 -16
- package/lib/ThreeExtended/loaders/DRACOLoader.js +14 -19
- package/lib/ThreeExtended/loaders/GLTFLoader.js +124 -129
- package/lib/ThreeExtended/loaders/KTX2Loader.js +73 -78
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +40 -59
- package/lib/ThreeExtended/utils/WorkerPool.js +2 -9
- package/lib/Utils/CameraUtils.js +32 -44
- package/lib/Utils/DEMUtils.js +8 -19
- package/lib/Utils/FeaturesUtils.js +8 -16
- package/lib/Utils/Gradients.js +16 -0
- package/lib/Utils/OrientationUtils.js +8 -18
- package/lib/Utils/ThreeUtils.js +2 -9
- package/lib/Utils/gui/C3DTilesStyle.js +7 -15
- package/lib/Utils/gui/Main.js +7 -48
- package/lib/Utils/gui/Minimap.js +12 -20
- package/lib/Utils/gui/Navigation.js +6 -14
- package/lib/Utils/gui/Scale.js +11 -19
- package/lib/Utils/gui/Searchbar.js +5 -13
- package/lib/Utils/gui/Widget.js +1 -8
- package/lib/Utils/placeObjectOnGround.js +13 -23
- package/package.json +13 -8
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
9
|
-
var _Capabilities = _interopRequireDefault(require("../Core/System/Capabilities"));
|
|
10
|
-
var _ShaderUtils = _interopRequireDefault(require("./Shader/ShaderUtils"));
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import Capabilities from "../Core/System/Capabilities.js";
|
|
13
3
|
/* babel-plugin-inline-import './Shader/ProjectiveTextureVS.glsl' */
|
|
14
|
-
const textureVS = "#include <itowns/
|
|
4
|
+
const textureVS = "#include <itowns/precision_qualifier>\n#include <itowns/projective_texturing_pars_vertex>\n#include <common>\n#include <logdepthbuf_pars_vertex>\n\nvarying vec3 vNormal;\n\nvoid main() {\n #include <begin_vertex>\n #include <project_vertex>\n vNormal = normal;\n #include <itowns/projective_texturing_vertex>\n #include <logdepthbuf_vertex>\n}\n";
|
|
15
5
|
/* babel-plugin-inline-import './Shader/ProjectiveTextureFS.glsl' */
|
|
16
|
-
const textureFS = "#include <itowns/
|
|
6
|
+
const textureFS = "#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#include <itowns/projective_texturing_pars_fragment>\nvarying vec3 vNormal;\n\n#ifdef USE_BASE_MATERIAL\nstruct noPT {\n vec3 lightDirection;\n vec3 ambient;\n float opacity;\n};\n\nuniform noPT noProjectiveMaterial;\n#endif\n\nvoid main(void)\n{\n #include <logdepthbuf_fragment>\n #ifdef USE_BASE_MATERIAL\n float nDotVP = (max(0.1, dot(vNormal, normalize(noProjectiveMaterial.lightDirection))));\n vec4 color = vec4(noProjectiveMaterial.ambient + nDotVP, 0.0);\n #else\n vec4 color = vec4(0.0);\n #endif\n\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\n #ifdef USE_BASE_MATERIAL\n color.a = color.a < 1.0 ? max(noProjectiveMaterial.opacity, color.a) : 1.0 ;\n gl_FragColor = vec4(color.rgb, color.a * opacity);\n #else\n gl_FragColor = vec4(color.rgb / color.a, opacity);\n #endif\n\n}\n";
|
|
7
|
+
import ShaderUtils from "./Shader/ShaderUtils.js";
|
|
17
8
|
const ndcToTextureMatrix = new THREE.Matrix4(1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 2);
|
|
18
9
|
const noMask = new THREE.DataTexture(new Uint8Array([255, 255, 255, 255]), 1, 1, THREE.RGBAFormat, THREE.UnsignedByteType);
|
|
19
10
|
noMask.needsUpdate = true;
|
|
20
11
|
const noTexture = new THREE.Texture();
|
|
21
|
-
const
|
|
12
|
+
const shaderMaterial = new THREE.ShaderMaterial();
|
|
22
13
|
/**
|
|
23
14
|
* @classdesc OrientedImageMaterial is a custom shader material used to do projective texture mapping.<br/>
|
|
24
15
|
*
|
|
@@ -37,7 +28,7 @@ const rawShaderMaterial = new THREE.RawShaderMaterial();
|
|
|
37
28
|
* <br/>
|
|
38
29
|
* To get a more comprehensive support of camera Micmac models, you can consider using [three-photogrammetric-camera]{@link https://github.com/mbredif/three-photogrammetric-camera} instead.
|
|
39
30
|
*/
|
|
40
|
-
class OrientedImageMaterial extends THREE.
|
|
31
|
+
class OrientedImageMaterial extends THREE.ShaderMaterial {
|
|
41
32
|
/**
|
|
42
33
|
* @constructor
|
|
43
34
|
* @param { OrientedImageCamera[]} cameras - Array of {@link OrientedImageCamera}. Each camera will project a texture.
|
|
@@ -62,21 +53,21 @@ class OrientedImageMaterial extends THREE.RawShaderMaterial {
|
|
|
62
53
|
options.transparent = options.transparent ?? true;
|
|
63
54
|
options.opacity = options.opacity ?? 1;
|
|
64
55
|
|
|
65
|
-
// Filter
|
|
66
|
-
const
|
|
56
|
+
// Filter out non-ShaderMaterial options
|
|
57
|
+
const shaderMaterialOptions = {};
|
|
67
58
|
for (const key in options) {
|
|
68
59
|
if (Object.prototype.hasOwnProperty.call(options, key)) {
|
|
69
|
-
const currentValue =
|
|
60
|
+
const currentValue = shaderMaterial[key];
|
|
70
61
|
if (currentValue !== undefined) {
|
|
71
|
-
|
|
62
|
+
shaderMaterialOptions[key] = options[key];
|
|
72
63
|
}
|
|
73
64
|
}
|
|
74
65
|
}
|
|
75
|
-
super(
|
|
66
|
+
super(shaderMaterialOptions);
|
|
76
67
|
this.defines.ORIENTED_IMAGES_COUNT = options.OrientedImagesCount ?? cameras.length;
|
|
77
68
|
|
|
78
69
|
// verify that number of textures doesn't exceed GPU capabilities
|
|
79
|
-
const maxTexturesUnits =
|
|
70
|
+
const maxTexturesUnits = Capabilities.getMaxTextureUnitsCount();
|
|
80
71
|
if (this.defines.ORIENTED_IMAGES_COUNT > maxTexturesUnits) {
|
|
81
72
|
console.warn(`OrientedImageMaterial: Can't project ${cameras.length} textures, because it's more than GPU capabilities maximum texture units (${maxTexturesUnits})`);
|
|
82
73
|
|
|
@@ -116,18 +107,10 @@ class OrientedImageMaterial extends THREE.RawShaderMaterial {
|
|
|
116
107
|
ambient: new THREE.Color(0.1, 0.1, 0.1),
|
|
117
108
|
opacity: 0.75
|
|
118
109
|
});
|
|
119
|
-
if (_Capabilities.default.isLogDepthBufferSupported()) {
|
|
120
|
-
this.defines.USE_LOGDEPTHBUF = 1;
|
|
121
|
-
this.defines.USE_LOGDEPTHBUF_EXT = 1;
|
|
122
|
-
}
|
|
123
110
|
this.vertexShader = textureVS;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (renderer.capabilities.isWebGL2) {
|
|
128
|
-
this.defines.WEBGL2 = true;
|
|
129
|
-
shader.glslVersion = '300 es';
|
|
130
|
-
}
|
|
111
|
+
// three loop unrolling of ShaderMaterial only supports integer bounds,
|
|
112
|
+
// see https://github.com/mrdoob/three.js/issues/28020
|
|
113
|
+
this.fragmentShader = ShaderUtils.unrollLoops(textureFS, this.defines);
|
|
131
114
|
}
|
|
132
115
|
|
|
133
116
|
/**
|
|
@@ -182,5 +165,4 @@ class OrientedImageMaterial extends THREE.RawShaderMaterial {
|
|
|
182
165
|
}
|
|
183
166
|
}
|
|
184
167
|
}
|
|
185
|
-
|
|
186
|
-
exports.default = _default;
|
|
168
|
+
export default OrientedImageMaterial;
|
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.PNTS_SIZE_MODE = exports.PNTS_SHAPE = exports.PNTS_MODE = exports.ClassificationScheme = void 0;
|
|
8
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
9
|
-
var _Capabilities = _interopRequireDefault(require("../Core/System/Capabilities"));
|
|
10
|
-
var _ShaderUtils = _interopRequireDefault(require("./Shader/ShaderUtils"));
|
|
11
|
-
var _CommonMaterial = _interopRequireDefault(require("./CommonMaterial"));
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1
|
+
import * as THREE from 'three';
|
|
14
2
|
/* babel-plugin-inline-import './Shader/PointsVS.glsl' */
|
|
15
|
-
const PointsVS = "#include <itowns/
|
|
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 bool applyOpacityClassication;\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 = opacity;\n if (applyOpacityClassication || mode == PNTS_MODE_CLASSIFICATION) {\n vec2 uv = vec2(classification/255., 0.5);\n vColor = texture2D(classificationTexture, uv);\n vColor.a *= opacity;\n }\n\n 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 i = (position.z - elevationRange.x) / (elevationRange.y - elevationRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n }\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";
|
|
16
4
|
/* babel-plugin-inline-import './Shader/PointsFS.glsl' */
|
|
17
|
-
const PointsFS = "#include <itowns/
|
|
18
|
-
|
|
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";
|
|
7
|
+
import CommonMaterial from "./CommonMaterial.js";
|
|
8
|
+
import Gradients from "../Utils/Gradients.js";
|
|
9
|
+
export const PNTS_MODE = {
|
|
19
10
|
COLOR: 0,
|
|
20
11
|
INTENSITY: 1,
|
|
21
12
|
CLASSIFICATION: 2,
|
|
22
|
-
|
|
13
|
+
ELEVATION: 3,
|
|
14
|
+
RETURN_NUMBER: 4,
|
|
15
|
+
RETURN_TYPE: 5,
|
|
16
|
+
RETURN_COUNT: 6,
|
|
17
|
+
POINT_SOURCE_ID: 7,
|
|
18
|
+
SCAN_ANGLE: 8,
|
|
19
|
+
NORMAL: 9
|
|
23
20
|
};
|
|
24
|
-
|
|
25
|
-
const PNTS_SHAPE = {
|
|
21
|
+
export const PNTS_SHAPE = {
|
|
26
22
|
CIRCLE: 0,
|
|
27
23
|
SQUARE: 1
|
|
28
24
|
};
|
|
29
|
-
|
|
30
|
-
const PNTS_SIZE_MODE = {
|
|
25
|
+
export const PNTS_SIZE_MODE = {
|
|
31
26
|
VALUE: 0,
|
|
32
27
|
ATTENUATED: 1
|
|
33
28
|
};
|
|
34
|
-
exports.PNTS_SIZE_MODE = PNTS_SIZE_MODE;
|
|
35
29
|
const white = new THREE.Color(1.0, 1.0, 1.0);
|
|
36
30
|
|
|
37
31
|
/**
|
|
@@ -49,7 +43,7 @@ const white = new THREE.Color(1.0, 1.0, 1.0);
|
|
|
49
43
|
*/
|
|
50
44
|
// eslint-disable-next-line
|
|
51
45
|
class /* istanbul ignore next */Classification {}
|
|
52
|
-
const ClassificationScheme = {
|
|
46
|
+
export const ClassificationScheme = {
|
|
53
47
|
DEFAULT: {
|
|
54
48
|
0: {
|
|
55
49
|
visible: true,
|
|
@@ -137,8 +131,129 @@ const ClassificationScheme = {
|
|
|
137
131
|
}
|
|
138
132
|
}
|
|
139
133
|
};
|
|
140
|
-
|
|
141
|
-
|
|
134
|
+
const DiscreteScheme = {
|
|
135
|
+
DEFAULT: {
|
|
136
|
+
0: {
|
|
137
|
+
visible: true,
|
|
138
|
+
name: '0',
|
|
139
|
+
color: new THREE.Color('rgb(67, 99, 216)'),
|
|
140
|
+
opacity: 1.0
|
|
141
|
+
},
|
|
142
|
+
1: {
|
|
143
|
+
visible: true,
|
|
144
|
+
name: '1',
|
|
145
|
+
color: new THREE.Color('rgb(60, 180, 75);'),
|
|
146
|
+
opacity: 1.0
|
|
147
|
+
},
|
|
148
|
+
2: {
|
|
149
|
+
visible: true,
|
|
150
|
+
name: '2',
|
|
151
|
+
color: new THREE.Color('rgb(255, 255, 25)'),
|
|
152
|
+
opacity: 1.0
|
|
153
|
+
},
|
|
154
|
+
3: {
|
|
155
|
+
visible: true,
|
|
156
|
+
name: '3',
|
|
157
|
+
color: new THREE.Color('rgb(145, 30, 180)'),
|
|
158
|
+
opacity: 1.0
|
|
159
|
+
},
|
|
160
|
+
4: {
|
|
161
|
+
visible: true,
|
|
162
|
+
name: '4',
|
|
163
|
+
color: new THREE.Color('rgb(245, 130, 49)'),
|
|
164
|
+
opacity: 1.0
|
|
165
|
+
},
|
|
166
|
+
5: {
|
|
167
|
+
visible: true,
|
|
168
|
+
name: '5',
|
|
169
|
+
color: new THREE.Color('rgb(230, 25, 75)'),
|
|
170
|
+
opacity: 1.0
|
|
171
|
+
},
|
|
172
|
+
6: {
|
|
173
|
+
visible: true,
|
|
174
|
+
name: '6',
|
|
175
|
+
color: new THREE.Color('rgb(66, 212, 244)'),
|
|
176
|
+
opacity: 1.0
|
|
177
|
+
},
|
|
178
|
+
7: {
|
|
179
|
+
visible: true,
|
|
180
|
+
name: '7',
|
|
181
|
+
color: new THREE.Color('rgb(240, 50, 230)'),
|
|
182
|
+
opacity: 1.0
|
|
183
|
+
},
|
|
184
|
+
DEFAULT: {
|
|
185
|
+
visible: true,
|
|
186
|
+
name: 'default',
|
|
187
|
+
color: white,
|
|
188
|
+
opacity: 0.5
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// Taken from Potree. Copyright (c) 2011-2020, Markus Schütz All rights reserved.
|
|
194
|
+
// https://github.com/potree/potree/blob/develop/src/materials/PointCloudMaterial.js
|
|
195
|
+
function generateGradientTexture(gradient) {
|
|
196
|
+
const size = 64;
|
|
197
|
+
|
|
198
|
+
// create canvas
|
|
199
|
+
const canvas = document.createElement('canvas');
|
|
200
|
+
canvas.width = size;
|
|
201
|
+
canvas.height = size;
|
|
202
|
+
|
|
203
|
+
// get context
|
|
204
|
+
const context = canvas.getContext('2d');
|
|
205
|
+
|
|
206
|
+
// draw gradient
|
|
207
|
+
context.rect(0, 0, size, size);
|
|
208
|
+
const ctxGradient = context.createLinearGradient(0, 0, size, size);
|
|
209
|
+
for (let i = 0; i < gradient.length; i++) {
|
|
210
|
+
const step = gradient[i];
|
|
211
|
+
ctxGradient.addColorStop(step[0], `#${step[1].getHexString()}`);
|
|
212
|
+
}
|
|
213
|
+
context.fillStyle = ctxGradient;
|
|
214
|
+
context.fill();
|
|
215
|
+
const texture = new THREE.CanvasTexture(canvas);
|
|
216
|
+
texture.needsUpdate = true;
|
|
217
|
+
texture.minFilter = THREE.LinearFilter;
|
|
218
|
+
texture.wrap = THREE.RepeatWrapping;
|
|
219
|
+
texture.repeat = 2;
|
|
220
|
+
return texture;
|
|
221
|
+
}
|
|
222
|
+
function recomputeTexture(scheme, texture, nbClass) {
|
|
223
|
+
const data = texture.image.data;
|
|
224
|
+
const width = texture.image.width;
|
|
225
|
+
if (!nbClass) {
|
|
226
|
+
nbClass = Object.keys(scheme).length;
|
|
227
|
+
}
|
|
228
|
+
for (let i = 0; i < width; i++) {
|
|
229
|
+
let color;
|
|
230
|
+
let opacity;
|
|
231
|
+
let visible = true;
|
|
232
|
+
if (scheme[i]) {
|
|
233
|
+
color = scheme[i].color;
|
|
234
|
+
visible = scheme[i].visible;
|
|
235
|
+
opacity = scheme[i].opacity;
|
|
236
|
+
} else if (scheme[i % nbClass]) {
|
|
237
|
+
color = scheme[i % nbClass].color;
|
|
238
|
+
visible = scheme[i % nbClass].visible;
|
|
239
|
+
opacity = scheme[i % nbClass].opacity;
|
|
240
|
+
} else if (scheme.DEFAULT) {
|
|
241
|
+
color = scheme.DEFAULT.color;
|
|
242
|
+
visible = scheme.DEFAULT.visible;
|
|
243
|
+
opacity = scheme.DEFAULT.opacity;
|
|
244
|
+
} else {
|
|
245
|
+
color = white;
|
|
246
|
+
opacity = 1.0;
|
|
247
|
+
}
|
|
248
|
+
const j = 4 * i;
|
|
249
|
+
data[j + 0] = parseInt(255 * color.r, 10);
|
|
250
|
+
data[j + 1] = parseInt(255 * color.g, 10);
|
|
251
|
+
data[j + 2] = parseInt(255 * color.b, 10);
|
|
252
|
+
data[j + 3] = visible ? parseInt(255 * opacity, 10) : 0;
|
|
253
|
+
}
|
|
254
|
+
texture.needsUpdate = true;
|
|
255
|
+
}
|
|
256
|
+
class PointsMaterial extends THREE.ShaderMaterial {
|
|
142
257
|
/**
|
|
143
258
|
* @class PointsMaterial
|
|
144
259
|
* @param {object} [options={}] The options
|
|
@@ -146,13 +261,23 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
146
261
|
* @param {number} [options.mode=PNTS_MODE.COLOR] display mode.
|
|
147
262
|
* @param {number} [options.mode=PNTS_SHAPE.CIRCLE] rendered points shape.
|
|
148
263
|
* @param {THREE.Vector4} [options.overlayColor=new THREE.Vector4(0, 0, 0, 0)] overlay color.
|
|
149
|
-
* @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(
|
|
264
|
+
* @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range.
|
|
265
|
+
* @param {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range.
|
|
266
|
+
* @param {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range.
|
|
150
267
|
* @param {boolean} [options.applyOpacityClassication=false] apply opacity classification on all display mode.
|
|
151
|
-
* @param {
|
|
268
|
+
* @param {Scheme} [options.classification] LUT for point classification colorization.
|
|
269
|
+
* @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
|
|
270
|
+
* @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
|
|
271
|
+
* (Default value will be the 'SPECTRAL' gradient from Utils/Gradients)
|
|
152
272
|
* @param {number} [options.sizeMode=PNTS_SIZE_MODE.VALUE] point cloud size mode. Only 'VALUE' or 'ATTENUATED' are possible. VALUE use constant size, ATTENUATED compute size depending on distance from point to camera.
|
|
153
273
|
* @param {number} [options.minAttenuatedSize=3] minimum scale used by 'ATTENUATED' size mode
|
|
154
274
|
* @param {number} [options.maxAttenuatedSize=10] maximum scale used by 'ATTENUATED' size mode
|
|
155
|
-
*
|
|
275
|
+
*
|
|
276
|
+
* @property {Scheme} classificationScheme - Color scheme for point classification values.
|
|
277
|
+
* @property {Scheme} discreteScheme - Color scheme for all other discrete values.
|
|
278
|
+
* @property {object} gradients - Descriptions of all available gradients.
|
|
279
|
+
* @property {object} gradient - Description of the gradient to use for display.
|
|
280
|
+
* @property {THREE.CanvasTexture} gradientTexture - The texture generate from the choosen gradient.
|
|
156
281
|
*
|
|
157
282
|
* @example
|
|
158
283
|
* // change color category classification
|
|
@@ -162,9 +287,12 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
162
287
|
*/
|
|
163
288
|
constructor() {
|
|
164
289
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
165
|
-
const intensityRange = options.intensityRange || new THREE.Vector2(
|
|
290
|
+
const intensityRange = options.intensityRange || new THREE.Vector2(1, 65536);
|
|
291
|
+
const elevationRange = options.elevationRange || new THREE.Vector2(0, 1000);
|
|
292
|
+
const angleRange = options.angleRange || new THREE.Vector2(-90, 90);
|
|
166
293
|
const oiMaterial = options.orientedImageMaterial;
|
|
167
|
-
const
|
|
294
|
+
const classificationScheme = options.classification || ClassificationScheme.DEFAULT;
|
|
295
|
+
const discreteScheme = options.discreteScheme || DiscreteScheme.DEFAULT;
|
|
168
296
|
const applyOpacityClassication = options.applyOpacityClassication == undefined ? false : options.applyOpacityClassication;
|
|
169
297
|
const size = options.size || 0;
|
|
170
298
|
const mode = options.mode || PNTS_MODE.COLOR;
|
|
@@ -172,9 +300,19 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
172
300
|
const sizeMode = size === 0 ? PNTS_SIZE_MODE.ATTENUATED : options.sizeMode || PNTS_SIZE_MODE.VALUE;
|
|
173
301
|
const minAttenuatedSize = options.minAttenuatedSize || 3;
|
|
174
302
|
const maxAttenuatedSize = options.maxAttenuatedSize || 10;
|
|
175
|
-
|
|
303
|
+
let gradients = Gradients;
|
|
304
|
+
if (options.gradient) {
|
|
305
|
+
gradients = {
|
|
306
|
+
...options.gradient,
|
|
307
|
+
...Gradients
|
|
308
|
+
};
|
|
309
|
+
}
|
|
176
310
|
delete options.intensityRange;
|
|
177
|
-
delete options.
|
|
311
|
+
delete options.elevationRange;
|
|
312
|
+
delete options.angleRange;
|
|
313
|
+
delete options.orientedImageMaterial;
|
|
314
|
+
delete options.classificationScheme;
|
|
315
|
+
delete options.discreteScheme;
|
|
178
316
|
delete options.applyOpacityClassication;
|
|
179
317
|
delete options.size;
|
|
180
318
|
delete options.mode;
|
|
@@ -182,38 +320,56 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
182
320
|
delete options.sizeMode;
|
|
183
321
|
delete options.minAttenuatedSize;
|
|
184
322
|
delete options.maxAttenuatedSize;
|
|
323
|
+
delete options.gradient;
|
|
185
324
|
super(options);
|
|
325
|
+
this.gradients = gradients;
|
|
326
|
+
this.gradientTexture = new THREE.CanvasTexture();
|
|
186
327
|
this.vertexShader = PointsVS;
|
|
187
328
|
const scale = options.scale || 0.05 * 0.5 / Math.tan(1.0 / 2.0); // autosizing scale
|
|
188
329
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
330
|
+
CommonMaterial.setDefineMapping(this, 'PNTS_MODE', PNTS_MODE);
|
|
331
|
+
CommonMaterial.setDefineMapping(this, 'PNTS_SHAPE', PNTS_SHAPE);
|
|
332
|
+
CommonMaterial.setDefineMapping(this, 'PNTS_SIZE_MODE', PNTS_SIZE_MODE);
|
|
333
|
+
CommonMaterial.setUniformProperty(this, 'size', size);
|
|
334
|
+
CommonMaterial.setUniformProperty(this, 'mode', mode);
|
|
335
|
+
CommonMaterial.setUniformProperty(this, 'shape', shape);
|
|
336
|
+
CommonMaterial.setUniformProperty(this, 'picking', false);
|
|
337
|
+
CommonMaterial.setUniformProperty(this, 'opacity', this.opacity);
|
|
338
|
+
CommonMaterial.setUniformProperty(this, 'overlayColor', options.overlayColor || new THREE.Vector4(0, 0, 0, 0));
|
|
339
|
+
CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange);
|
|
340
|
+
CommonMaterial.setUniformProperty(this, 'elevationRange', elevationRange);
|
|
341
|
+
CommonMaterial.setUniformProperty(this, 'angleRange', angleRange);
|
|
342
|
+
CommonMaterial.setUniformProperty(this, 'applyOpacityClassication', applyOpacityClassication);
|
|
343
|
+
CommonMaterial.setUniformProperty(this, 'sizeMode', sizeMode);
|
|
344
|
+
CommonMaterial.setUniformProperty(this, 'scale', scale);
|
|
345
|
+
CommonMaterial.setUniformProperty(this, 'minAttenuatedSize', minAttenuatedSize);
|
|
346
|
+
CommonMaterial.setUniformProperty(this, 'maxAttenuatedSize', maxAttenuatedSize);
|
|
204
347
|
|
|
205
348
|
// add classification texture to apply classification lut.
|
|
206
349
|
const data = new Uint8Array(256 * 4);
|
|
207
350
|
const texture = new THREE.DataTexture(data, 256, 1, THREE.RGBAFormat);
|
|
208
351
|
texture.needsUpdate = true;
|
|
209
352
|
texture.magFilter = THREE.NearestFilter;
|
|
210
|
-
|
|
353
|
+
CommonMaterial.setUniformProperty(this, 'classificationTexture', texture);
|
|
354
|
+
|
|
355
|
+
// add texture to applying the discrete lut.
|
|
356
|
+
const dataLUT = new Uint8Array(256 * 4);
|
|
357
|
+
const textureLUT = new THREE.DataTexture(dataLUT, 256, 1, THREE.RGBAFormat);
|
|
358
|
+
textureLUT.needsUpdate = true;
|
|
359
|
+
textureLUT.magFilter = THREE.NearestFilter;
|
|
360
|
+
CommonMaterial.setUniformProperty(this, 'discreteTexture', textureLUT);
|
|
211
361
|
|
|
212
|
-
// Classification scheme
|
|
213
|
-
this.
|
|
362
|
+
// Classification and other discrete values scheme
|
|
363
|
+
this.classificationScheme = classificationScheme;
|
|
364
|
+
this.discreteScheme = discreteScheme;
|
|
214
365
|
|
|
215
|
-
// Update classification
|
|
366
|
+
// Update classification and discrete Texture
|
|
216
367
|
this.recomputeClassification();
|
|
368
|
+
this.recomputeDiscreteTexture();
|
|
369
|
+
|
|
370
|
+
// Gradient texture for continuous values
|
|
371
|
+
this.gradient = Object.values(gradients)[0];
|
|
372
|
+
CommonMaterial.setUniformProperty(this, 'gradientTexture', this.gradientTexture);
|
|
217
373
|
if (oiMaterial) {
|
|
218
374
|
this.uniforms.projectiveTextureAlphaBorder = oiMaterial.uniforms.projectiveTextureAlphaBorder;
|
|
219
375
|
this.uniforms.projectiveTextureDistortion = oiMaterial.uniforms.projectiveTextureDistortion;
|
|
@@ -226,56 +382,26 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
226
382
|
this.defines.DEBUG_ALPHA_BORDER = oiMaterial.defines.DEBUG_ALPHA_BORDER;
|
|
227
383
|
this.defines.USE_TEXTURES_PROJECTIVE = true;
|
|
228
384
|
this.defines.USE_BASE_MATERIAL = true;
|
|
229
|
-
|
|
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);
|
|
230
388
|
} else {
|
|
231
389
|
this.fragmentShader = PointsFS;
|
|
232
390
|
}
|
|
233
|
-
if (_Capabilities.default.isLogDepthBufferSupported()) {
|
|
234
|
-
this.defines.USE_LOGDEPTHBUF = 1;
|
|
235
|
-
this.defines.USE_LOGDEPTHBUF_EXT = 1;
|
|
236
|
-
}
|
|
237
391
|
}
|
|
238
392
|
recomputeClassification() {
|
|
239
|
-
|
|
240
|
-
const data = this.classificationLUT.image.data;
|
|
241
|
-
const width = this.classificationLUT.image.width;
|
|
242
|
-
for (let i = 0; i < width; i++) {
|
|
243
|
-
let color;
|
|
244
|
-
let opacity;
|
|
245
|
-
let visible = true;
|
|
246
|
-
if (classification[i]) {
|
|
247
|
-
color = classification[i].color;
|
|
248
|
-
visible = classification[i].visible;
|
|
249
|
-
opacity = classification[i].opacity;
|
|
250
|
-
} else if (classification[i % 32]) {
|
|
251
|
-
color = classification[i % 32].color;
|
|
252
|
-
visible = classification[i % 32].visible;
|
|
253
|
-
opacity = classification[i % 32].opacity;
|
|
254
|
-
} else if (classification.DEFAULT) {
|
|
255
|
-
color = classification.DEFAULT.color;
|
|
256
|
-
visible = classification.DEFAULT.visible;
|
|
257
|
-
opacity = classification.DEFAULT.opacity;
|
|
258
|
-
} else {
|
|
259
|
-
color = white;
|
|
260
|
-
opacity = 1.0;
|
|
261
|
-
}
|
|
262
|
-
const j = 4 * i;
|
|
263
|
-
data[j + 0] = parseInt(255 * color.r, 10);
|
|
264
|
-
data[j + 1] = parseInt(255 * color.g, 10);
|
|
265
|
-
data[j + 2] = parseInt(255 * color.b, 10);
|
|
266
|
-
data[j + 3] = visible ? parseInt(255 * opacity, 10) : 0;
|
|
267
|
-
}
|
|
268
|
-
this.classificationLUT.needsUpdate = true;
|
|
393
|
+
recomputeTexture(this.classificationScheme, this.classificationTexture, 32);
|
|
269
394
|
this.dispatchEvent({
|
|
270
395
|
type: 'material_property_changed',
|
|
271
|
-
target: this
|
|
396
|
+
target: this.uniforms
|
|
272
397
|
});
|
|
273
398
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
399
|
+
recomputeDiscreteTexture() {
|
|
400
|
+
recomputeTexture(this.discreteScheme, this.discreteTexture);
|
|
401
|
+
this.dispatchEvent({
|
|
402
|
+
type: 'material_property_changed',
|
|
403
|
+
target: this.uniforms
|
|
404
|
+
});
|
|
279
405
|
}
|
|
280
406
|
copy(source) {
|
|
281
407
|
super.copy(source);
|
|
@@ -309,9 +435,13 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
309
435
|
this.scale = source.scale;
|
|
310
436
|
this.overlayColor.copy(source.overlayColor);
|
|
311
437
|
this.intensityRange.copy(source.intensityRange);
|
|
438
|
+
this.elevationRange.copy(source.elevationRange);
|
|
439
|
+
this.angleRange.copy(source.angleRange);
|
|
312
440
|
Object.assign(this.defines, source.defines);
|
|
313
441
|
return this;
|
|
314
442
|
}
|
|
443
|
+
set gradient(value) {
|
|
444
|
+
this.gradientTexture = generateGradientTexture(value);
|
|
445
|
+
}
|
|
315
446
|
}
|
|
316
|
-
|
|
317
|
-
exports.default = _default;
|
|
447
|
+
export default PointsMaterial;
|