itowns 2.42.1-next.2 → 2.42.1-next.20
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 +8 -19
- 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 -37
- 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 -20
- package/lib/Core/Prefab/TileBuilder.js +11 -20
- package/lib/Core/Prefab/computeBufferTileGeometry.js +11 -15
- 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 -9
- package/lib/Core/TileGeometry.js +11 -14
- package/lib/Core/TileMesh.js +6 -15
- package/lib/Core/View.js +43 -53
- 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 +37 -13
- 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 +27 -41
- package/lib/Renderer/OBB.js +12 -21
- package/lib/Renderer/OrientedImageCamera.js +2 -11
- package/lib/Renderer/OrientedImageMaterial.js +7 -17
- package/lib/Renderer/PointsMaterial.js +223 -84
- package/lib/Renderer/RasterTile.js +18 -30
- package/lib/Renderer/RenderMode.js +2 -9
- package/lib/Renderer/Shader/ShaderChunk.js +2 -11
- 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 +18 -28
- 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,19 +1,10 @@
|
|
|
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
4
|
const textureVS = "#include <itowns/WebGL2_pars_vertex>\n#include <itowns/precision_qualifier>\n#include <itowns/project_pars_vertex>\n#include <itowns/projective_texturing_pars_vertex>\n#include <common>\n#include <logdepthbuf_pars_vertex>\n\nvarying vec3 vNormal;\nattribute vec3 normal;\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
6
|
const textureFS = "#include <itowns/WebGL2_pars_fragment>\n#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;
|
|
@@ -76,7 +67,7 @@ class OrientedImageMaterial extends THREE.RawShaderMaterial {
|
|
|
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,12 +107,12 @@ 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 (
|
|
110
|
+
if (Capabilities.isLogDepthBufferSupported()) {
|
|
120
111
|
this.defines.USE_LOGDEPTHBUF = 1;
|
|
121
112
|
this.defines.USE_LOGDEPTHBUF_EXT = 1;
|
|
122
113
|
}
|
|
123
114
|
this.vertexShader = textureVS;
|
|
124
|
-
this.fragmentShader =
|
|
115
|
+
this.fragmentShader = ShaderUtils.unrollLoops(textureFS, this.defines);
|
|
125
116
|
}
|
|
126
117
|
onBeforeCompile(shader, renderer) {
|
|
127
118
|
if (renderer.capabilities.isWebGL2) {
|
|
@@ -182,5 +173,4 @@ class OrientedImageMaterial extends THREE.RawShaderMaterial {
|
|
|
182
173
|
}
|
|
183
174
|
}
|
|
184
175
|
}
|
|
185
|
-
|
|
186
|
-
exports.default = _default;
|
|
176
|
+
export default OrientedImageMaterial;
|
|
@@ -1,37 +1,32 @@
|
|
|
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/WebGL2_pars_vertex>\n#include <itowns/precision_qualifier>\n#include <itowns/project_pars_vertex>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_vertex>\n#endif\n#include <common>\n#include <logdepthbuf_pars_vertex>\n\nuniform float size;\nuniform float scale;\n\nuniform bool picking;\nuniform int mode;\nuniform float opacity;\nuniform vec4 overlayColor;\nuniform vec2 intensityRange;\nuniform bool applyOpacityClassication;\nattribute vec3 color;\nattribute vec4 unique_id;\nattribute float intensity;\nattribute float classification;\
|
|
3
|
+
const PointsVS = "#include <itowns/WebGL2_pars_vertex>\n#include <itowns/precision_qualifier>\n#include <itowns/project_pars_vertex>\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#else\nattribute vec3 normal;\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
5
|
const PointsFS = "#include <itowns/WebGL2_pars_fragment>\n#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";
|
|
18
|
-
|
|
6
|
+
import Capabilities from "../Core/System/Capabilities.js";
|
|
7
|
+
import ShaderUtils from "./Shader/ShaderUtils.js";
|
|
8
|
+
import CommonMaterial from "./CommonMaterial.js";
|
|
9
|
+
import Gradients from "../Utils/Gradients.js";
|
|
10
|
+
export const PNTS_MODE = {
|
|
19
11
|
COLOR: 0,
|
|
20
12
|
INTENSITY: 1,
|
|
21
13
|
CLASSIFICATION: 2,
|
|
22
|
-
|
|
14
|
+
ELEVATION: 3,
|
|
15
|
+
RETURN_NUMBER: 4,
|
|
16
|
+
RETURN_TYPE: 5,
|
|
17
|
+
RETURN_COUNT: 6,
|
|
18
|
+
POINT_SOURCE_ID: 7,
|
|
19
|
+
SCAN_ANGLE: 8,
|
|
20
|
+
NORMAL: 9
|
|
23
21
|
};
|
|
24
|
-
|
|
25
|
-
const PNTS_SHAPE = {
|
|
22
|
+
export const PNTS_SHAPE = {
|
|
26
23
|
CIRCLE: 0,
|
|
27
24
|
SQUARE: 1
|
|
28
25
|
};
|
|
29
|
-
|
|
30
|
-
const PNTS_SIZE_MODE = {
|
|
26
|
+
export const PNTS_SIZE_MODE = {
|
|
31
27
|
VALUE: 0,
|
|
32
28
|
ATTENUATED: 1
|
|
33
29
|
};
|
|
34
|
-
exports.PNTS_SIZE_MODE = PNTS_SIZE_MODE;
|
|
35
30
|
const white = new THREE.Color(1.0, 1.0, 1.0);
|
|
36
31
|
|
|
37
32
|
/**
|
|
@@ -49,7 +44,7 @@ const white = new THREE.Color(1.0, 1.0, 1.0);
|
|
|
49
44
|
*/
|
|
50
45
|
// eslint-disable-next-line
|
|
51
46
|
class /* istanbul ignore next */Classification {}
|
|
52
|
-
const ClassificationScheme = {
|
|
47
|
+
export const ClassificationScheme = {
|
|
53
48
|
DEFAULT: {
|
|
54
49
|
0: {
|
|
55
50
|
visible: true,
|
|
@@ -137,7 +132,128 @@ const ClassificationScheme = {
|
|
|
137
132
|
}
|
|
138
133
|
}
|
|
139
134
|
};
|
|
140
|
-
|
|
135
|
+
const DiscreteScheme = {
|
|
136
|
+
DEFAULT: {
|
|
137
|
+
0: {
|
|
138
|
+
visible: true,
|
|
139
|
+
name: '0',
|
|
140
|
+
color: new THREE.Color('rgb(67, 99, 216)'),
|
|
141
|
+
opacity: 1.0
|
|
142
|
+
},
|
|
143
|
+
1: {
|
|
144
|
+
visible: true,
|
|
145
|
+
name: '1',
|
|
146
|
+
color: new THREE.Color('rgb(60, 180, 75);'),
|
|
147
|
+
opacity: 1.0
|
|
148
|
+
},
|
|
149
|
+
2: {
|
|
150
|
+
visible: true,
|
|
151
|
+
name: '2',
|
|
152
|
+
color: new THREE.Color('rgb(255, 255, 25)'),
|
|
153
|
+
opacity: 1.0
|
|
154
|
+
},
|
|
155
|
+
3: {
|
|
156
|
+
visible: true,
|
|
157
|
+
name: '3',
|
|
158
|
+
color: new THREE.Color('rgb(145, 30, 180)'),
|
|
159
|
+
opacity: 1.0
|
|
160
|
+
},
|
|
161
|
+
4: {
|
|
162
|
+
visible: true,
|
|
163
|
+
name: '4',
|
|
164
|
+
color: new THREE.Color('rgb(245, 130, 49)'),
|
|
165
|
+
opacity: 1.0
|
|
166
|
+
},
|
|
167
|
+
5: {
|
|
168
|
+
visible: true,
|
|
169
|
+
name: '5',
|
|
170
|
+
color: new THREE.Color('rgb(230, 25, 75)'),
|
|
171
|
+
opacity: 1.0
|
|
172
|
+
},
|
|
173
|
+
6: {
|
|
174
|
+
visible: true,
|
|
175
|
+
name: '6',
|
|
176
|
+
color: new THREE.Color('rgb(66, 212, 244)'),
|
|
177
|
+
opacity: 1.0
|
|
178
|
+
},
|
|
179
|
+
7: {
|
|
180
|
+
visible: true,
|
|
181
|
+
name: '7',
|
|
182
|
+
color: new THREE.Color('rgb(240, 50, 230)'),
|
|
183
|
+
opacity: 1.0
|
|
184
|
+
},
|
|
185
|
+
DEFAULT: {
|
|
186
|
+
visible: true,
|
|
187
|
+
name: 'default',
|
|
188
|
+
color: white,
|
|
189
|
+
opacity: 0.5
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// Taken from Potree. Copyright (c) 2011-2020, Markus Schütz All rights reserved.
|
|
195
|
+
// https://github.com/potree/potree/blob/develop/src/materials/PointCloudMaterial.js
|
|
196
|
+
function generateGradientTexture(gradient) {
|
|
197
|
+
const size = 64;
|
|
198
|
+
|
|
199
|
+
// create canvas
|
|
200
|
+
const canvas = document.createElement('canvas');
|
|
201
|
+
canvas.width = size;
|
|
202
|
+
canvas.height = size;
|
|
203
|
+
|
|
204
|
+
// get context
|
|
205
|
+
const context = canvas.getContext('2d');
|
|
206
|
+
|
|
207
|
+
// draw gradient
|
|
208
|
+
context.rect(0, 0, size, size);
|
|
209
|
+
const ctxGradient = context.createLinearGradient(0, 0, size, size);
|
|
210
|
+
for (let i = 0; i < gradient.length; i++) {
|
|
211
|
+
const step = gradient[i];
|
|
212
|
+
ctxGradient.addColorStop(step[0], `#${step[1].getHexString()}`);
|
|
213
|
+
}
|
|
214
|
+
context.fillStyle = ctxGradient;
|
|
215
|
+
context.fill();
|
|
216
|
+
const texture = new THREE.CanvasTexture(canvas);
|
|
217
|
+
texture.needsUpdate = true;
|
|
218
|
+
texture.minFilter = THREE.LinearFilter;
|
|
219
|
+
texture.wrap = THREE.RepeatWrapping;
|
|
220
|
+
texture.repeat = 2;
|
|
221
|
+
return texture;
|
|
222
|
+
}
|
|
223
|
+
function recomputeTexture(scheme, texture, nbClass) {
|
|
224
|
+
const data = texture.image.data;
|
|
225
|
+
const width = texture.image.width;
|
|
226
|
+
if (!nbClass) {
|
|
227
|
+
nbClass = Object.keys(scheme).length;
|
|
228
|
+
}
|
|
229
|
+
for (let i = 0; i < width; i++) {
|
|
230
|
+
let color;
|
|
231
|
+
let opacity;
|
|
232
|
+
let visible = true;
|
|
233
|
+
if (scheme[i]) {
|
|
234
|
+
color = scheme[i].color;
|
|
235
|
+
visible = scheme[i].visible;
|
|
236
|
+
opacity = scheme[i].opacity;
|
|
237
|
+
} else if (scheme[i % nbClass]) {
|
|
238
|
+
color = scheme[i % nbClass].color;
|
|
239
|
+
visible = scheme[i % nbClass].visible;
|
|
240
|
+
opacity = scheme[i % nbClass].opacity;
|
|
241
|
+
} else if (scheme.DEFAULT) {
|
|
242
|
+
color = scheme.DEFAULT.color;
|
|
243
|
+
visible = scheme.DEFAULT.visible;
|
|
244
|
+
opacity = scheme.DEFAULT.opacity;
|
|
245
|
+
} else {
|
|
246
|
+
color = white;
|
|
247
|
+
opacity = 1.0;
|
|
248
|
+
}
|
|
249
|
+
const j = 4 * i;
|
|
250
|
+
data[j + 0] = parseInt(255 * color.r, 10);
|
|
251
|
+
data[j + 1] = parseInt(255 * color.g, 10);
|
|
252
|
+
data[j + 2] = parseInt(255 * color.b, 10);
|
|
253
|
+
data[j + 3] = visible ? parseInt(255 * opacity, 10) : 0;
|
|
254
|
+
}
|
|
255
|
+
texture.needsUpdate = true;
|
|
256
|
+
}
|
|
141
257
|
class PointsMaterial extends THREE.RawShaderMaterial {
|
|
142
258
|
/**
|
|
143
259
|
* @class PointsMaterial
|
|
@@ -146,13 +262,23 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
146
262
|
* @param {number} [options.mode=PNTS_MODE.COLOR] display mode.
|
|
147
263
|
* @param {number} [options.mode=PNTS_SHAPE.CIRCLE] rendered points shape.
|
|
148
264
|
* @param {THREE.Vector4} [options.overlayColor=new THREE.Vector4(0, 0, 0, 0)] overlay color.
|
|
149
|
-
* @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(
|
|
265
|
+
* @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range.
|
|
266
|
+
* @param {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range.
|
|
267
|
+
* @param {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range.
|
|
150
268
|
* @param {boolean} [options.applyOpacityClassication=false] apply opacity classification on all display mode.
|
|
151
|
-
* @param {
|
|
269
|
+
* @param {Scheme} [options.classification] LUT for point classification colorization.
|
|
270
|
+
* @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
|
|
271
|
+
* @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
|
|
272
|
+
* (Default value will be the 'SPECTRAL' gradient from Utils/Gradients)
|
|
152
273
|
* @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
274
|
* @param {number} [options.minAttenuatedSize=3] minimum scale used by 'ATTENUATED' size mode
|
|
154
275
|
* @param {number} [options.maxAttenuatedSize=10] maximum scale used by 'ATTENUATED' size mode
|
|
155
|
-
*
|
|
276
|
+
*
|
|
277
|
+
* @property {Scheme} classificationScheme - Color scheme for point classification values.
|
|
278
|
+
* @property {Scheme} discreteScheme - Color scheme for all other discrete values.
|
|
279
|
+
* @property {object} gradients - Descriptions of all available gradients.
|
|
280
|
+
* @property {object} gradient - Description of the gradient to use for display.
|
|
281
|
+
* @property {THREE.CanvasTexture} gradientTexture - The texture generate from the choosen gradient.
|
|
156
282
|
*
|
|
157
283
|
* @example
|
|
158
284
|
* // change color category classification
|
|
@@ -162,9 +288,12 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
162
288
|
*/
|
|
163
289
|
constructor() {
|
|
164
290
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
165
|
-
const intensityRange = options.intensityRange || new THREE.Vector2(
|
|
291
|
+
const intensityRange = options.intensityRange || new THREE.Vector2(1, 65536);
|
|
292
|
+
const elevationRange = options.elevationRange || new THREE.Vector2(0, 1000);
|
|
293
|
+
const angleRange = options.angleRange || new THREE.Vector2(-90, 90);
|
|
166
294
|
const oiMaterial = options.orientedImageMaterial;
|
|
167
|
-
const
|
|
295
|
+
const classificationScheme = options.classification || ClassificationScheme.DEFAULT;
|
|
296
|
+
const discreteScheme = options.discreteScheme || DiscreteScheme.DEFAULT;
|
|
168
297
|
const applyOpacityClassication = options.applyOpacityClassication == undefined ? false : options.applyOpacityClassication;
|
|
169
298
|
const size = options.size || 0;
|
|
170
299
|
const mode = options.mode || PNTS_MODE.COLOR;
|
|
@@ -172,9 +301,19 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
172
301
|
const sizeMode = size === 0 ? PNTS_SIZE_MODE.ATTENUATED : options.sizeMode || PNTS_SIZE_MODE.VALUE;
|
|
173
302
|
const minAttenuatedSize = options.minAttenuatedSize || 3;
|
|
174
303
|
const maxAttenuatedSize = options.maxAttenuatedSize || 10;
|
|
175
|
-
|
|
304
|
+
let gradients = Gradients;
|
|
305
|
+
if (options.gradient) {
|
|
306
|
+
gradients = {
|
|
307
|
+
...options.gradient,
|
|
308
|
+
...Gradients
|
|
309
|
+
};
|
|
310
|
+
}
|
|
176
311
|
delete options.intensityRange;
|
|
177
|
-
delete options.
|
|
312
|
+
delete options.elevationRange;
|
|
313
|
+
delete options.angleRange;
|
|
314
|
+
delete options.orientedImageMaterial;
|
|
315
|
+
delete options.classificationScheme;
|
|
316
|
+
delete options.discreteScheme;
|
|
178
317
|
delete options.applyOpacityClassication;
|
|
179
318
|
delete options.size;
|
|
180
319
|
delete options.mode;
|
|
@@ -182,38 +321,56 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
182
321
|
delete options.sizeMode;
|
|
183
322
|
delete options.minAttenuatedSize;
|
|
184
323
|
delete options.maxAttenuatedSize;
|
|
324
|
+
delete options.gradient;
|
|
185
325
|
super(options);
|
|
326
|
+
this.gradients = gradients;
|
|
327
|
+
this.gradientTexture = new THREE.CanvasTexture();
|
|
186
328
|
this.vertexShader = PointsVS;
|
|
187
329
|
const scale = options.scale || 0.05 * 0.5 / Math.tan(1.0 / 2.0); // autosizing scale
|
|
188
330
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
331
|
+
CommonMaterial.setDefineMapping(this, 'PNTS_MODE', PNTS_MODE);
|
|
332
|
+
CommonMaterial.setDefineMapping(this, 'PNTS_SHAPE', PNTS_SHAPE);
|
|
333
|
+
CommonMaterial.setDefineMapping(this, 'PNTS_SIZE_MODE', PNTS_SIZE_MODE);
|
|
334
|
+
CommonMaterial.setUniformProperty(this, 'size', size);
|
|
335
|
+
CommonMaterial.setUniformProperty(this, 'mode', mode);
|
|
336
|
+
CommonMaterial.setUniformProperty(this, 'shape', shape);
|
|
337
|
+
CommonMaterial.setUniformProperty(this, 'picking', false);
|
|
338
|
+
CommonMaterial.setUniformProperty(this, 'opacity', this.opacity);
|
|
339
|
+
CommonMaterial.setUniformProperty(this, 'overlayColor', options.overlayColor || new THREE.Vector4(0, 0, 0, 0));
|
|
340
|
+
CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange);
|
|
341
|
+
CommonMaterial.setUniformProperty(this, 'elevationRange', elevationRange);
|
|
342
|
+
CommonMaterial.setUniformProperty(this, 'angleRange', angleRange);
|
|
343
|
+
CommonMaterial.setUniformProperty(this, 'applyOpacityClassication', applyOpacityClassication);
|
|
344
|
+
CommonMaterial.setUniformProperty(this, 'sizeMode', sizeMode);
|
|
345
|
+
CommonMaterial.setUniformProperty(this, 'scale', scale);
|
|
346
|
+
CommonMaterial.setUniformProperty(this, 'minAttenuatedSize', minAttenuatedSize);
|
|
347
|
+
CommonMaterial.setUniformProperty(this, 'maxAttenuatedSize', maxAttenuatedSize);
|
|
204
348
|
|
|
205
349
|
// add classification texture to apply classification lut.
|
|
206
350
|
const data = new Uint8Array(256 * 4);
|
|
207
351
|
const texture = new THREE.DataTexture(data, 256, 1, THREE.RGBAFormat);
|
|
208
352
|
texture.needsUpdate = true;
|
|
209
353
|
texture.magFilter = THREE.NearestFilter;
|
|
210
|
-
|
|
354
|
+
CommonMaterial.setUniformProperty(this, 'classificationTexture', texture);
|
|
211
355
|
|
|
212
|
-
//
|
|
213
|
-
|
|
356
|
+
// add texture to applying the discrete lut.
|
|
357
|
+
const dataLUT = new Uint8Array(256 * 4);
|
|
358
|
+
const textureLUT = new THREE.DataTexture(dataLUT, 256, 1, THREE.RGBAFormat);
|
|
359
|
+
textureLUT.needsUpdate = true;
|
|
360
|
+
textureLUT.magFilter = THREE.NearestFilter;
|
|
361
|
+
CommonMaterial.setUniformProperty(this, 'discreteTexture', textureLUT);
|
|
214
362
|
|
|
215
|
-
//
|
|
363
|
+
// Classification and other discrete values scheme
|
|
364
|
+
this.classificationScheme = classificationScheme;
|
|
365
|
+
this.discreteScheme = discreteScheme;
|
|
366
|
+
|
|
367
|
+
// Update classification and discrete Texture
|
|
216
368
|
this.recomputeClassification();
|
|
369
|
+
this.recomputeDiscreteTexture();
|
|
370
|
+
|
|
371
|
+
// Gradient texture for continuous values
|
|
372
|
+
this.gradient = Object.values(gradients)[0];
|
|
373
|
+
CommonMaterial.setUniformProperty(this, 'gradientTexture', this.gradientTexture);
|
|
217
374
|
if (oiMaterial) {
|
|
218
375
|
this.uniforms.projectiveTextureAlphaBorder = oiMaterial.uniforms.projectiveTextureAlphaBorder;
|
|
219
376
|
this.uniforms.projectiveTextureDistortion = oiMaterial.uniforms.projectiveTextureDistortion;
|
|
@@ -226,49 +383,27 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
226
383
|
this.defines.DEBUG_ALPHA_BORDER = oiMaterial.defines.DEBUG_ALPHA_BORDER;
|
|
227
384
|
this.defines.USE_TEXTURES_PROJECTIVE = true;
|
|
228
385
|
this.defines.USE_BASE_MATERIAL = true;
|
|
229
|
-
this.fragmentShader =
|
|
386
|
+
this.fragmentShader = ShaderUtils.unrollLoops(PointsFS, this.defines);
|
|
230
387
|
} else {
|
|
231
388
|
this.fragmentShader = PointsFS;
|
|
232
389
|
}
|
|
233
|
-
if (
|
|
390
|
+
if (Capabilities.isLogDepthBufferSupported()) {
|
|
234
391
|
this.defines.USE_LOGDEPTHBUF = 1;
|
|
235
392
|
this.defines.USE_LOGDEPTHBUF_EXT = 1;
|
|
236
393
|
}
|
|
237
394
|
}
|
|
238
395
|
recomputeClassification() {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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;
|
|
396
|
+
recomputeTexture(this.classificationScheme, this.classificationTexture, 32);
|
|
397
|
+
this.dispatchEvent({
|
|
398
|
+
type: 'material_property_changed',
|
|
399
|
+
target: this.uniforms
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
recomputeDiscreteTexture() {
|
|
403
|
+
recomputeTexture(this.discreteScheme, this.discreteTexture);
|
|
269
404
|
this.dispatchEvent({
|
|
270
405
|
type: 'material_property_changed',
|
|
271
|
-
target: this
|
|
406
|
+
target: this.uniforms
|
|
272
407
|
});
|
|
273
408
|
}
|
|
274
409
|
onBeforeCompile(shader, renderer) {
|
|
@@ -309,9 +444,13 @@ class PointsMaterial extends THREE.RawShaderMaterial {
|
|
|
309
444
|
this.scale = source.scale;
|
|
310
445
|
this.overlayColor.copy(source.overlayColor);
|
|
311
446
|
this.intensityRange.copy(source.intensityRange);
|
|
447
|
+
this.elevationRange.copy(source.elevationRange);
|
|
448
|
+
this.angleRange.copy(source.angleRange);
|
|
312
449
|
Object.assign(this.defines, source.defines);
|
|
313
450
|
return this;
|
|
314
451
|
}
|
|
452
|
+
set gradient(value) {
|
|
453
|
+
this.gradientTexture = generateGradientTexture(value);
|
|
454
|
+
}
|
|
315
455
|
}
|
|
316
|
-
|
|
317
|
-
exports.default = _default;
|
|
456
|
+
export default PointsMaterial;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.RasterElevationTile = exports.RasterColorTile = exports.EMPTY_TEXTURE_ZOOM = void 0;
|
|
8
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
9
|
-
var _LayeredMaterial = require("./LayeredMaterial");
|
|
10
|
-
var _XbilParser = require("../Parser/XbilParser");
|
|
11
|
-
var _Crs = _interopRequireDefault(require("../Core/Geographic/Crs"));
|
|
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; }
|
|
14
|
-
const EMPTY_TEXTURE_ZOOM = -1;
|
|
15
|
-
exports.EMPTY_TEXTURE_ZOOM = EMPTY_TEXTURE_ZOOM;
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { ELEVATION_MODES } from "./LayeredMaterial.js";
|
|
3
|
+
import { checkNodeElevationTextureValidity, insertSignificantValuesFromParent, computeMinMaxElevation } from "../Parser/XbilParser.js";
|
|
4
|
+
import CRS from "../Core/Geographic/Crs.js";
|
|
5
|
+
export const EMPTY_TEXTURE_ZOOM = -1;
|
|
16
6
|
const pitch = new THREE.Vector4();
|
|
17
7
|
function getIndiceWithPitch(i, pitch, w) {
|
|
18
8
|
// Return corresponding indice in parent tile using pitch
|
|
@@ -39,7 +29,7 @@ class RasterTile extends THREE.EventDispatcher {
|
|
|
39
29
|
constructor(material, layer) {
|
|
40
30
|
super();
|
|
41
31
|
this.layer = layer;
|
|
42
|
-
this.crs = layer.parent.tileMatrixSets.indexOf(
|
|
32
|
+
this.crs = layer.parent.tileMatrixSets.indexOf(CRS.formatToTms(layer.crs));
|
|
43
33
|
if (this.crs == -1) {
|
|
44
34
|
console.error('Unknown crs:', layer.crs);
|
|
45
35
|
}
|
|
@@ -75,7 +65,8 @@ class RasterTile extends THREE.EventDispatcher {
|
|
|
75
65
|
}
|
|
76
66
|
}
|
|
77
67
|
}
|
|
78
|
-
dispose(
|
|
68
|
+
dispose() {
|
|
69
|
+
let removeEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
79
70
|
if (removeEvent) {
|
|
80
71
|
this.layer.removeEventListener('visible-property-changed', this._handlerCBEvent);
|
|
81
72
|
this.layer.removeEventListener('opacity-property-changed', this._handlerCBEvent);
|
|
@@ -94,7 +85,7 @@ class RasterTile extends THREE.EventDispatcher {
|
|
|
94
85
|
this.material.layersNeedUpdate = true;
|
|
95
86
|
}
|
|
96
87
|
setTexture(index, texture, offsetScale) {
|
|
97
|
-
this.level = texture && index == 0 ? texture.extent.zoom : this.level;
|
|
88
|
+
this.level = texture && texture.extent && index == 0 ? texture.extent.zoom : this.level;
|
|
98
89
|
this.textures[index] = texture || null;
|
|
99
90
|
this.offsetScales[index] = offsetScale;
|
|
100
91
|
this.material.layersNeedUpdate = true;
|
|
@@ -106,9 +97,8 @@ class RasterTile extends THREE.EventDispatcher {
|
|
|
106
97
|
}
|
|
107
98
|
}
|
|
108
99
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
class RasterColorTile extends RasterTile {
|
|
100
|
+
export default RasterTile;
|
|
101
|
+
export class RasterColorTile extends RasterTile {
|
|
112
102
|
get effect_type() {
|
|
113
103
|
return this.layer.effect_type;
|
|
114
104
|
}
|
|
@@ -119,13 +109,12 @@ class RasterColorTile extends RasterTile {
|
|
|
119
109
|
return this.layer.transparent;
|
|
120
110
|
}
|
|
121
111
|
}
|
|
122
|
-
|
|
123
|
-
class RasterElevationTile extends RasterTile {
|
|
112
|
+
export class RasterElevationTile extends RasterTile {
|
|
124
113
|
constructor(material, layer) {
|
|
125
114
|
super(material, layer);
|
|
126
115
|
const defaultEle = {
|
|
127
116
|
bias: 0,
|
|
128
|
-
mode:
|
|
117
|
+
mode: ELEVATION_MODES.DATA,
|
|
129
118
|
zmin: -Infinity,
|
|
130
119
|
zmax: Infinity
|
|
131
120
|
};
|
|
@@ -133,12 +122,12 @@ class RasterElevationTile extends RasterTile {
|
|
|
133
122
|
|
|
134
123
|
// Define elevation properties
|
|
135
124
|
if (layer.useRgbaTextureElevation) {
|
|
136
|
-
defaultEle.mode =
|
|
125
|
+
defaultEle.mode = ELEVATION_MODES.RGBA;
|
|
137
126
|
defaultEle.zmax = 5000;
|
|
138
127
|
throw new Error('Restore this feature');
|
|
139
128
|
} else if (layer.useColorTextureElevation) {
|
|
140
129
|
this.scaleFactor = layer.colorTextureElevationMaxZ - layer.colorTextureElevationMinZ;
|
|
141
|
-
defaultEle.mode =
|
|
130
|
+
defaultEle.mode = ELEVATION_MODES.COLOR;
|
|
142
131
|
defaultEle.bias = layer.colorTextureElevationMinZ;
|
|
143
132
|
this.min = this.layer.colorTextureElevationMinZ;
|
|
144
133
|
this.max = this.layer.colorTextureElevationMaxZ;
|
|
@@ -189,7 +178,7 @@ class RasterElevationTile extends RasterTile {
|
|
|
189
178
|
const {
|
|
190
179
|
min,
|
|
191
180
|
max
|
|
192
|
-
} =
|
|
181
|
+
} = computeMinMaxElevation(this.textures[0], this.offsetScales[0], {
|
|
193
182
|
noDataValue: this.layer.noDataValue,
|
|
194
183
|
zmin: this.layer.zmin,
|
|
195
184
|
zmax: this.layer.zmax
|
|
@@ -209,12 +198,11 @@ class RasterElevationTile extends RasterTile {
|
|
|
209
198
|
const parentTexture = this.textures[0];
|
|
210
199
|
const parentDataElevation = parentTexture && parentTexture.image && parentTexture.image.data;
|
|
211
200
|
const dataElevation = texture.image && texture.image.data;
|
|
212
|
-
if (dataElevation && !
|
|
213
|
-
|
|
201
|
+
if (dataElevation && !checkNodeElevationTextureValidity(dataElevation, nodatavalue)) {
|
|
202
|
+
insertSignificantValuesFromParent(dataElevation, parentDataElevation && dataParent(texture, parentTexture, parentDataElevation, pitch), nodatavalue);
|
|
214
203
|
}
|
|
215
204
|
}
|
|
216
205
|
}
|
|
217
|
-
exports.RasterElevationTile = RasterElevationTile;
|
|
218
206
|
function dataParent(texture, parentTexture, parentDataElevation, pitch) {
|
|
219
207
|
texture.extent.offsetToParent(parentTexture.extent, pitch);
|
|
220
208
|
return i => parentDataElevation[getIndiceWithPitch(i, pitch, 256)];
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
1
|
const MODES = {
|
|
8
2
|
FINAL: 0,
|
|
9
3
|
// final color
|
|
@@ -32,8 +26,7 @@ function push(object3d, mode) {
|
|
|
32
26
|
// Rendering mode
|
|
33
27
|
// According to the rendering mode, the material's object switches
|
|
34
28
|
// the mode property of the materials
|
|
35
|
-
|
|
29
|
+
export default {
|
|
36
30
|
MODES,
|
|
37
31
|
push
|
|
38
|
-
};
|
|
39
|
-
exports.default = _default;
|
|
32
|
+
};
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
8
|
-
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); }
|
|
9
|
-
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';
|
|
10
2
|
/* babel-plugin-inline-import './Chunk/color_layers_pars_fragment.glsl' */
|
|
11
3
|
const color_layers_pars_fragment = "struct Layer {\n int textureOffset;\n int crs;\n int effect_type;\n float effect_parameter;\n float opacity;\n bool transparent;\n};\n\n#include <itowns/custom_header_colorLayer>\n\nuniform sampler2D colorTextures[NUM_FS_TEXTURES];\nuniform vec4 colorOffsetScales[NUM_FS_TEXTURES];\nuniform Layer colorLayers[NUM_FS_TEXTURES];\nuniform int colorTextureCount;\n\nvec3 uvs[NUM_CRS];\n\nfloat getBorderDistance(vec2 uv) {\n vec2 p2 = min(uv, 1. -uv);\n return min(p2.x, p2.y);\n}\n\nfloat tolerance = 0.99;\n\nvec4 applyWhiteToInvisibleEffect(vec4 color) {\n float a = dot(color.rgb, vec3(0.333333333));\n if (a >= tolerance) {\n color.a = 0.0;\n }\n return color;\n}\n\nvec4 applyLightColorToInvisibleEffect(vec4 color, float intensity) {\n float a = max(0.05,1. - length(color.xyz - 1.));\n color.a *= 1.0 - pow(abs(a), intensity);\n color.rgb *= color.rgb * color.rgb;\n return color;\n}\n\n#if defined(DEBUG)\nuniform bool showOutline;\nuniform vec3 outlineColors[NUM_CRS];\nuniform float outlineWidth;\n\nvec4 getOutlineColor(vec3 outlineColor, vec2 uv) {\n float alpha = 1. - clamp(getBorderDistance(uv) / outlineWidth, 0., 1.);\n return vec4(outlineColor, alpha);\n}\n#endif\n\nuniform float minBorderDistance;\nvec4 getLayerColor(int textureOffset, sampler2D tex, vec4 offsetScale, Layer layer) {\n if ( textureOffset >= colorTextureCount ) return vec4(0);\n\n vec3 uv;\n // #pragma unroll_loop\n for ( int i = 0; i < NUM_CRS; i ++ ) {\n if ( i == layer.crs ) uv = uvs[ i ];\n }\n\n float borderDistance = getBorderDistance(uv.xy);\n if (textureOffset != layer.textureOffset + int(uv.z) || borderDistance < minBorderDistance ) return vec4(0);\n vec4 color = texture2D(tex, pitUV(uv.xy, offsetScale));\n if (layer.effect_type == 3) {\n #include <itowns/custom_body_colorLayer>\n } else {\n if (layer.transparent && color.a != 0.0) {\n color.rgb /= color.a;\n }\n\n if (layer.effect_type == 1) {\n color = applyLightColorToInvisibleEffect(color, layer.effect_parameter);\n } else if (layer.effect_type == 2) {\n color = applyWhiteToInvisibleEffect(color);\n }\n }\n color.a *= layer.opacity;\n return color;\n}\n";
|
|
12
4
|
/* babel-plugin-inline-import './Chunk/elevation_pars_vertex.glsl' */
|
|
@@ -174,5 +166,4 @@ class ShaderChunkManager {
|
|
|
174
166
|
}
|
|
175
167
|
}
|
|
176
168
|
const ShaderChunk = new ShaderChunkManager(THREE.ShaderChunk, 'itowns/');
|
|
177
|
-
|
|
178
|
-
exports.default = _default;
|
|
169
|
+
export default ShaderChunk;
|