itowns 2.44.3-next.40 → 2.44.3-next.42

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.
Files changed (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,486 +0,0 @@
1
- import { FEATURE_TYPES } from "./Feature.js";
2
- import * as maplibre from '@maplibre/maplibre-gl-style-spec';
3
-
4
- /**
5
- * An object that can contain any properties (zoom, fill, stroke, point,
6
- * text or/and icon) and sub properties of a Style.
7
- * Used for the instanciation of a {@link Style}.
8
- *
9
- * @typedef {Object} StyleOptions
10
- *
11
- * @property {Object} [zoom] - Level on which to display the feature
12
- * @property {Number} [zoom.max] - max level
13
- * @property {Number} [zoom.min] - min level
14
- *
15
- * @property {Object} [fill] - Fill style for polygons.
16
- * @property {String|Function|THREE.Color} [fill.color] - Defines the main fill color. Can be
17
- * any [valid color string](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
18
- * Default is no value, which means no fill.
19
- * If the `Layer` is a `GeometryLayer` you can use `THREE.Color`.
20
- * @property {Image|Canvas|String|Object|Function} [fill.pattern] - Defines a pattern to fill the
21
- * surface with. It can be an `Image` to use directly, an url to fetch the pattern or an object containing
22
- * the url of the image to fetch and the transformation to apply.
23
- * from. See [this example](http://www.itowns-project.org/itowns/examples/#source_file_geojson_raster)
24
- * for how to use.
25
- * @property {Image|String} [fill.pattern.source] - The image or the url to fetch the pattern image
26
- * @property {Object} [fill.pattern.cropValues] - The x, y, width and height (in pixel) of the sub image to use.
27
- * @property {THREE.Color} [fill.pattern.color] - Can be any
28
- * [valid color string](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
29
- * It will change the color of the white pixels of the source image.
30
- * @property {Number|Function} [fill.opacity] - The opacity of the color or of the
31
- * pattern. Can be between `0.0` and `1.0`. Default is `1.0`.
32
- * For a `GeometryLayer`, this opacity property isn't used.
33
- * @property {Number|Function} [fill.base_altitude] - `GeometryLayer` style option, defines altitude
34
- * for each coordinate.
35
- * If `base_altitude` is `undefined`, the original altitude is kept, and if it doesn't exist
36
- * then the altitude value is set to 0.
37
- * @property {Number|Function} [fill.extrusion_height] - `GeometryLayer` style option, if defined,
38
- * polygons will be extruded by the specified amount
39
- *
40
- * @property {Object} [stroke] - Lines and polygons edges.
41
- * @property {String|Function|THREE.Color} [stroke.color] The color of the line. Can be any [valid
42
- * color string](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
43
- * Default is no value, which means no stroke.
44
- * If the `Layer` is a `GeometryLayer` you can use `THREE.Color`.
45
- * @property {Number|Function} [stroke.opacity] - The opacity of the line. Can be between
46
- * `0.0` and `1.0`. Default is `1.0`.
47
- * For a `GeometryLayer`, this opacity property isn't used.
48
- * @property {Number|Function} [stroke.width] - The width of the line. Default is `1.0`.
49
- * @property {Number|Function} [stroke.base_altitude] - `GeometryLayer` style option, defines altitude
50
- * for each coordinate.
51
- * If `base_altitude` is `undefined`, the original altitude is kept, and if it doesn't exist
52
- * then the altitude value is set to 0.
53
- *
54
- * @property {Object} [point] - Point style.
55
- * @property {String|Function} [point.color] - The color of the point. Can be any [valid
56
- * color string](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
57
- * Default is no value, which means points won't be displayed.
58
- * @property {Number|Function} [point.radius] - The radius of the point, in pixel. Default
59
- * is `2.0`.
60
- * @property {String|Function} [point.line] - The color of the border of the point. Can be
61
- * any [valid color
62
- * string](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
63
- * Not supported for a `GeometryLayer`.
64
- * @property {Number|Function} [point.width] - The width of the border, in pixel. Default
65
- * is `0.0` (no border).
66
- * @property {Number|Function} [point.opacity] - The opacity of the point. Can be between
67
- * `0.0` and `1.0`. Default is `1.0`.
68
- * Not supported for `GeometryLayer`.
69
- * @property {Number|Function} [point.base_altitude] - `GeometryLayer` style option, defines altitude
70
- * for each coordinate.
71
- * If `base_altitude` is `undefined`, the original altitude is kept, and if it doesn't exist
72
- * then the altitude value is set to 0.
73
- * @property {Object} [point.model] - 3D model to instantiate at each point position.
74
- *
75
- * @property {Object} [text] - All things {@link Label} related. (Supported for Points features, not yet
76
- * for Lines and Polygons features.)
77
- * @property {String|Function} [text.field] - A string representing a property key of
78
- * a `FeatureGeometry` enclosed in brackets, that will be replaced by the value of the
79
- * property for each geometry. For example, if each geometry contains a `name` property,
80
- * `text.field` can be set to `{name}`. Default is no value, indicating that no
81
- * text will be displayed.
82
- *
83
- * It's also possible to create more complex expressions. For example, you can combine
84
- * text that will always be displayed (e.g. `foo`) and variable properties (e.g. `{bar}`)
85
- * like the following: `foo {bar}`. You can also use multiple variables in one field.
86
- * Let's say for instance that you have two properties latin name and local name of a
87
- * place, you can write something like `{name_latin} - {name_local}` which can result
88
- * in `Marrakesh - مراكش` for example.
89
- * @property {String|Function} [text.color] - The color of the text. Can be any [valid
90
- * color string](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
91
- * Default is `#000000`.
92
- * @property {String|Number[]|Function} [text.anchor] - The anchor of the text compared to its
93
- * position (see {@link Label} for the position). Can be one of the following values: `top`,
94
- * `left`, `bottom`, `right`, `center`, `top-left`, `top-right`, `bottom-left`
95
- * or `bottom-right`. Default is `center`.
96
- *
97
- * It can also be defined as an Array of two numbers. Each number defines an offset (in
98
- * fraction of the label width and height) between the label position and the top-left
99
- * corner of the text. The first value is the horizontal offset, and the second is the
100
- * vertical offset. For example, `[-0.5, -0.5]` will be equivalent to `center`.
101
- * @property {Array|Function} [text.offset] - The offset of the text, depending on its
102
- * anchor, in pixels. First value is from `left`, second is from `top`. Default
103
- * is `[0, 0]`.
104
- * @property {Number|Function} [text.padding] - The padding outside the text, in pixels.
105
- * Default is `2`.
106
- * @property {Number|Function} [text.size] - The size of the font, in pixels. Default is
107
- * `16`.
108
- * @property {Number|Function} [text.wrap] - The maximum width, in pixels, before the text
109
- * is wrapped, because the string is too long. Default is `10`.
110
- * @property {Number|Function} [text.spacing] - The spacing between the letters, in `em`.
111
- * Default is `0`.
112
- * @property {String|Function} [text.transform] - A value corresponding to the [CSS
113
- * property
114
- * `text-transform`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform).
115
- * Default is `none`.
116
- * @property {String|Function} [text.justify] - A value corresponding to the [CSS property
117
- * `text-align`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align).
118
- * Default is `center`.
119
- * @property {Number|Function} [text.opacity] - The opacity of the text. Can be between
120
- * `0.0` and `1.0`. Default is `1.0`.
121
- * @property {Array|Function} [text.font] - A list (as an array of string) of font family
122
- * names, prioritized in the order it is set. Default is `Open Sans Regular,
123
- * Arial Unicode MS Regular, sans-serif`.
124
- * @property {String|Function} [text.haloColor] - The color of the halo. Can be any [valid
125
- * color string](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
126
- * Default is `#000000`.
127
- * @property {Number|Function} [text.haloWidth] - The width of the halo, in pixels.
128
- * Default is `0`.
129
- * @property {Number|Function} [text.haloBlur] - The blur value of the halo, in pixels.
130
- * Default is `0`.
131
- *
132
- * @property {Object} [icon] - Defines the appearance of icons attached to label.
133
- * @property {String} [icon.source] - The url of the icons' image file.
134
- * @property {String} [icon.id] - The id of the icons' sub-image in a vector tile data set.
135
- * @property {String} [icon.cropValues] - the x, y, width and height (in pixel) of the sub image to use.
136
- * @property {String} [icon.anchor] - The anchor of the icon compared to the label position.
137
- * Can be `left`, `bottom`, `right`, `center`, `top-left`, `top-right`, `bottom-left`
138
- * or `bottom-right`. Default is `center`.
139
- * @property {Number} [icon.size] - If the icon's image is passed with `icon.source` and/or
140
- * `icon.id`, its size when displayed on screen is multiplied by `icon.size`. Default is `1`.
141
- * @property {String|Function} [icon.color] - The color of the icon. Can be any [valid
142
- * color string](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
143
- * It will change the color of the white pixels of the icon source image.
144
- * @property {Number|Function} [icon.opacity] - The opacity of the icon. Can be between
145
- * `0.0` and `1.0`. Default is `1.0`.
146
- */
147
-
148
- /**
149
- * generate a StyleOptions from (geojson-like) properties.
150
- * @param {Object} properties (geojson-like) properties.
151
- * @param {FeatureContext} featCtx the context of the feature
152
- *
153
- * @returns {StyleOptions} containing all properties for itowns.Style
154
- */
155
- function setFromProperties(properties, featCtx) {
156
- const type = featCtx.type;
157
- const style = {};
158
- if (type === FEATURE_TYPES.POINT) {
159
- const point = {
160
- ...(properties.fill !== undefined && {
161
- color: properties.fill
162
- }),
163
- ...(properties['fill-opacity'] !== undefined && {
164
- opacity: properties['fill-opacity']
165
- }),
166
- ...(properties.stroke !== undefined && {
167
- line: properties.stroke
168
- }),
169
- ...(properties.radius !== undefined && {
170
- radius: properties.radius
171
- })
172
- };
173
- if (Object.keys(point).length) {
174
- style.point = point;
175
- }
176
- const text = {
177
- ...(properties['label-color'] !== undefined && {
178
- color: properties['label-color']
179
- }),
180
- ...(properties['label-opacity'] !== undefined && {
181
- opacity: properties['label-opacity']
182
- }),
183
- ...(properties['label-size'] !== undefined && {
184
- size: properties['label-size']
185
- })
186
- };
187
- if (Object.keys(point).length) {
188
- style.text = text;
189
- }
190
- const icon = {
191
- ...(properties.icon !== undefined && {
192
- source: properties.icon
193
- }),
194
- ...(properties['icon-scale'] !== undefined && {
195
- size: properties['icon-scale']
196
- }),
197
- ...(properties['icon-opacity'] !== undefined && {
198
- opacity: properties['icon-opacity']
199
- }),
200
- ...(properties['icon-color'] !== undefined && {
201
- color: properties['icon-color']
202
- })
203
- };
204
- if (Object.keys(icon).length) {
205
- style.icon = icon;
206
- }
207
- } else {
208
- const stroke = {
209
- ...(properties.stroke !== undefined && {
210
- color: properties.stroke
211
- }),
212
- ...(properties['stroke-width'] !== undefined && {
213
- width: properties['stroke-width']
214
- }),
215
- ...(properties['stroke-opacity'] !== undefined && {
216
- opacity: properties['stroke-opacity']
217
- })
218
- };
219
- if (Object.keys(stroke).length) {
220
- style.stroke = stroke;
221
- }
222
- if (type !== FEATURE_TYPES.LINE) {
223
- const fill = {
224
- ...(properties.fill !== undefined && {
225
- color: properties.fill
226
- }),
227
- ...(properties['fill-opacity'] !== undefined && {
228
- opacity: properties['fill-opacity']
229
- })
230
- };
231
- if (Object.keys(fill).length) {
232
- style.fill = fill;
233
- }
234
- }
235
- }
236
- return style;
237
- }
238
- function readVectorProperty(property, options) {
239
- if (property != undefined) {
240
- if (maplibre.expression.isExpression(property)) {
241
- return maplibre.expression.createExpression(property, options).value;
242
- } else {
243
- return property;
244
- }
245
- }
246
- }
247
- const inv255 = 1 / 255;
248
- function rgba2rgb(orig) {
249
- if (!orig) {
250
- return {};
251
- } else if (orig.stops || orig.expression) {
252
- return {
253
- color: orig
254
- };
255
- } else if (typeof orig == 'string') {
256
- const result = orig.match(/(?:((hsl|rgb)a? *\(([\d.%]+(?:deg|g?rad|turn)?)[ ,]*([\d.%]+)[ ,]*([\d.%]+)[ ,/]*([\d.%]*)\))|(#((?:[\d\w]{3}){1,2})([\d\w]{1,2})?))/i);
257
- if (result === null) {
258
- return {
259
- color: orig,
260
- opacity: 1.0
261
- };
262
- } else if (result[7]) {
263
- let opacity = 1.0;
264
- if (result[9]) {
265
- opacity = parseInt(result[9].length == 1 ? `${result[9]}${result[9]}` : result[9], 16) * inv255;
266
- }
267
- return {
268
- color: `#${result[8]}`,
269
- opacity
270
- };
271
- } else if (result[1]) {
272
- return {
273
- color: `${result[2]}(${result[3]},${result[4]},${result[5]})`,
274
- opacity: result[6] ? Number(result[6]) : 1.0
275
- };
276
- }
277
- }
278
- }
279
-
280
- /**
281
- * generate a StyleOptions from vector tile layer properties.
282
- * @param {Object} layer vector tile layer.
283
- * @param {Object} sprites vector tile layer.
284
- * @param {Boolean} [symbolToCircle=false]
285
- *
286
- * @returns {StyleOptions} containing all properties for itowns.Style
287
- */
288
- function setFromVectorTileLayer(layer, sprites) {
289
- let symbolToCircle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
290
- const style = {
291
- fill: {},
292
- stroke: {},
293
- point: {},
294
- text: {},
295
- icon: {}
296
- };
297
- layer.layout = layer.layout || {};
298
- layer.paint = layer.paint || {};
299
- if (layer.type === 'fill') {
300
- const {
301
- color,
302
- opacity
303
- } = rgba2rgb(readVectorProperty(layer.paint['fill-color'] || layer.paint['fill-pattern'], {
304
- type: 'color'
305
- }));
306
- style.fill.color = color;
307
- style.fill.opacity = readVectorProperty(layer.paint['fill-opacity']) || opacity;
308
- if (layer.paint['fill-pattern']) {
309
- try {
310
- style.fill.pattern = {
311
- id: layer.paint['fill-pattern'],
312
- source: sprites.source,
313
- cropValues: sprites[layer.paint['fill-pattern']]
314
- };
315
- } catch (err) {
316
- err.message = `VTlayer '${layer.id}': argument sprites must not be null when using layer.paint['fill-pattern']`;
317
- throw err;
318
- }
319
- }
320
- if (layer.paint['fill-outline-color']) {
321
- const {
322
- color,
323
- opacity
324
- } = rgba2rgb(readVectorProperty(layer.paint['fill-outline-color'], {
325
- type: 'color'
326
- }));
327
- style.stroke.color = color;
328
- style.stroke.opacity = opacity;
329
- style.stroke.width = 1.0;
330
- } else {
331
- style.stroke.width = 0.0;
332
- }
333
- } else if (layer.type === 'line') {
334
- const prepare = readVectorProperty(layer.paint['line-color'], {
335
- type: 'color'
336
- });
337
- const {
338
- color,
339
- opacity
340
- } = rgba2rgb(prepare);
341
- style.stroke.dasharray = readVectorProperty(layer.paint['line-dasharray']);
342
- style.stroke.color = color;
343
- style.stroke.lineCap = layer.layout['line-cap'];
344
- style.stroke.width = readVectorProperty(layer.paint['line-width']);
345
- style.stroke.opacity = readVectorProperty(layer.paint['line-opacity']) || opacity;
346
- } else if (layer.type === 'circle' || symbolToCircle) {
347
- const {
348
- color,
349
- opacity
350
- } = rgba2rgb(readVectorProperty(layer.paint['circle-color'], {
351
- type: 'color'
352
- }));
353
- style.point.color = color;
354
- style.point.opacity = opacity;
355
- style.point.radius = readVectorProperty(layer.paint['circle-radius']);
356
- } else if (layer.type === 'symbol') {
357
- // if symbol we shouldn't draw stroke but defaut value is 1.
358
- style.stroke.width = 0.0;
359
- // overlapping order
360
- style.text.zOrder = readVectorProperty(layer.layout['symbol-z-order']);
361
- if (style.text.zOrder == 'auto') {
362
- style.text.zOrder = readVectorProperty(layer.layout['symbol-sort-key']) || 'Y';
363
- } else if (style.text.zOrder == 'viewport-y') {
364
- style.text.zOrder = 'Y';
365
- } else if (style.text.zOrder == 'source') {
366
- style.text.zOrder = 0;
367
- }
368
-
369
- // position
370
- style.text.anchor = readVectorProperty(layer.layout['text-anchor']);
371
- style.text.offset = readVectorProperty(layer.layout['text-offset']);
372
- style.text.padding = readVectorProperty(layer.layout['text-padding']);
373
- style.text.size = readVectorProperty(layer.layout['text-size']);
374
- style.text.placement = readVectorProperty(layer.layout['symbol-placement']);
375
- style.text.rotation = readVectorProperty(layer.layout['text-rotation-alignment']);
376
-
377
- // content
378
- style.text.field = readVectorProperty(layer.layout['text-field']);
379
- style.text.wrap = readVectorProperty(layer.layout['text-max-width']); // Units ems
380
- style.text.spacing = readVectorProperty(layer.layout['text-letter-spacing']);
381
- style.text.transform = readVectorProperty(layer.layout['text-transform']);
382
- style.text.justify = readVectorProperty(layer.layout['text-justify']);
383
-
384
- // appearance
385
- const {
386
- color,
387
- opacity
388
- } = rgba2rgb(readVectorProperty(layer.paint['text-color'], {
389
- type: 'color'
390
- }));
391
- style.text.color = color;
392
- style.text.opacity = readVectorProperty(layer.paint['text-opacity']) || opacity !== undefined && opacity;
393
- style.text.font = readVectorProperty(layer.layout['text-font']);
394
- const haloColor = readVectorProperty(layer.paint['text-halo-color'], {
395
- type: 'color'
396
- });
397
- if (haloColor) {
398
- style.text.haloColor = haloColor.color || haloColor;
399
- style.text.haloWidth = readVectorProperty(layer.paint['text-halo-width']);
400
- style.text.haloBlur = readVectorProperty(layer.paint['text-halo-blur']);
401
- }
402
-
403
- // additional icon
404
- const iconImg = readVectorProperty(layer.layout['icon-image']);
405
- if (iconImg) {
406
- const cropValueDefault = {
407
- x: 0,
408
- y: 0,
409
- width: 1,
410
- height: 1
411
- };
412
- try {
413
- style.icon.id = iconImg;
414
- if (iconImg.stops) {
415
- const iconCropValue = {
416
- ...(iconImg.base !== undefined && {
417
- base: iconImg.base
418
- }),
419
- stops: iconImg.stops.map(stop => {
420
- let cropValues = sprites[stop[1]];
421
- if (stop[1].includes('{')) {
422
- cropValues = function (p) {
423
- const id = stop[1].replace(/\{(.+?)\}/g, (a, b) => p[b] || '').trim();
424
- if (cropValues === undefined) {
425
- // const warning = `WARNING: "${id}" not found in sprite file`;
426
- sprites[id] = cropValueDefault; // or return cropValueDefault;
427
- }
428
- return sprites[id];
429
- };
430
- } else if (cropValues === undefined) {
431
- // const warning = `WARNING: "${stop[1]}" not found in sprite file`;
432
- cropValues = cropValueDefault;
433
- }
434
- return [stop[0], cropValues];
435
- })
436
- };
437
- style.icon.cropValues = iconCropValue;
438
- } else {
439
- style.icon.cropValues = sprites[iconImg];
440
- if (iconImg.includes('{')) {
441
- style.icon.cropValues = function (p) {
442
- const id = iconImg.replace(/\{(.+?)\}/g, (a, b) => p[b] || '').trim();
443
- if (sprites[id] === undefined) {
444
- // const warning = `WARNING: "${id}" not found in sprite file`;
445
- sprites[id] = cropValueDefault; // or return cropValueDefault;
446
- }
447
- return sprites[id];
448
- };
449
- } else if (sprites[iconImg] === undefined) {
450
- // const warning = `WARNING: "${iconImg}" not found in sprite file`;
451
- style.icon.cropValues = cropValueDefault;
452
- }
453
- }
454
- style.icon.source = sprites.source;
455
- style.icon.size = readVectorProperty(layer.layout['icon-size']) ?? 1;
456
- const {
457
- color,
458
- opacity
459
- } = rgba2rgb(readVectorProperty(layer.paint['icon-color'], {
460
- type: 'color'
461
- }));
462
- // https://docs.mapbox.com/style-spec/reference/layers/#paint-symbol-icon-color
463
- if (iconImg.sdf) {
464
- style.icon.color = color;
465
- }
466
- style.icon.opacity = readVectorProperty(layer.paint['icon-opacity']) ?? (opacity !== undefined && opacity);
467
- } catch (err) {
468
- err.message = `VTlayer '${layer.id}': argument sprites must not be null when using layer.layout['icon-image']`;
469
- throw err;
470
- }
471
- }
472
- }
473
- // VectorTileSet: by default minZoom = 0 and maxZoom = 24
474
- // https://docs.mapbox.com/style-spec/reference/layers/#maxzoom and #minzoom
475
- // Should be move to layer properties, when (if) one mapBox layer will be considered as several itowns layers.
476
- // issue https://github.com/iTowns/itowns/issues/2153 (last point)
477
- style.zoom = {
478
- min: layer.minzoom || 0,
479
- max: layer.maxzoom || 24
480
- };
481
- return style;
482
- }
483
- export default {
484
- setFromProperties,
485
- setFromVectorTileLayer
486
- };
@@ -1,63 +0,0 @@
1
- /* babel-plugin-inline-import '../../Renderer/Shader/SampleTestFS.glsl' */
2
- const SampleTestFS = "uniform sampler2D uni[SAMPLE];\nvoid main() {\n gl_FragColor += texture2D(uni[SAMPLE-1], vec2(0));\n}";
3
- /* babel-plugin-inline-import '../../Renderer/Shader/SampleTestVS.glsl' */
4
- const SampleTestVS = "void main() {\n gl_Position = vec4( 0.0, 0.0, 0.0, 1.0 );\n}"; // default values
5
- let logDepthBufferSupported = false;
6
- let maxTexturesUnits = 8;
7
- let maxTextureSize = 4096;
8
- function _WebGLShader(renderer, type, string) {
9
- const gl = renderer.getContext();
10
- const shader = gl.createShader(type);
11
- gl.shaderSource(shader, string);
12
- gl.compileShader(shader);
13
- return shader;
14
- }
15
- function isFirefox() {
16
- return navigator && navigator.userAgent && navigator.userAgent.toLowerCase().includes('firefox');
17
- }
18
- export default {
19
- isLogDepthBufferSupported() {
20
- return logDepthBufferSupported;
21
- },
22
- isFirefox,
23
- getMaxTextureUnitsCount() {
24
- return maxTexturesUnits;
25
- },
26
- getMaxTextureSize() {
27
- return maxTextureSize;
28
- },
29
- updateCapabilities(renderer) {
30
- const gl = renderer.getContext();
31
- maxTexturesUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
32
- maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
33
- const program = gl.createProgram();
34
- const glVertexShader = _WebGLShader(renderer, gl.VERTEX_SHADER, SampleTestVS);
35
- let fragmentShader = `#define SAMPLE ${maxTexturesUnits}\n`;
36
- fragmentShader += SampleTestFS;
37
- const glFragmentShader = _WebGLShader(renderer, gl.FRAGMENT_SHADER, fragmentShader);
38
- gl.attachShader(program, glVertexShader);
39
- gl.attachShader(program, glFragmentShader);
40
- gl.linkProgram(program);
41
- if (gl.getProgramParameter(program, gl.LINK_STATUS) === false) {
42
- if (maxTexturesUnits > 16) {
43
- const info = gl.getProgramInfoLog(program);
44
- // eslint-disable-next-line no-console
45
- console.warn(`${info}: using a maximum of 16 texture units instead of the reported value (${maxTexturesUnits})`);
46
- if (isFirefox()) {
47
- // eslint-disable-next-line no-console
48
- console.warn(`It can come from a Mesa/Firefox bug;
49
- the shader compiles to an error when using more than 16 sampler uniforms,
50
- see https://bugzilla.mozilla.org/show_bug.cgi?id=777028`);
51
- }
52
- maxTexturesUnits = 16;
53
- } else {
54
- throw new Error(`The GPU capabilities could not be determined accurately.
55
- Impossible to link a shader with the Maximum texture units ${maxTexturesUnits}`);
56
- }
57
- }
58
- gl.deleteProgram(program);
59
- gl.deleteShader(glVertexShader);
60
- gl.deleteShader(glFragmentShader);
61
- logDepthBufferSupported = renderer.capabilities.logarithmicDepthBuffer;
62
- }
63
- };