itowns 2.45.1-next.0 → 2.45.1-next.1

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 (185) hide show
  1. package/dist/455.js +2 -0
  2. package/dist/455.js.map +1 -0
  3. package/dist/debug.js +3 -0
  4. package/dist/debug.js.LICENSE.txt +13 -0
  5. package/dist/debug.js.map +1 -0
  6. package/dist/itowns.js +3 -0
  7. package/dist/itowns.js.LICENSE.txt +5 -0
  8. package/dist/itowns.js.map +1 -0
  9. package/dist/itowns_lasparser.js +2 -0
  10. package/dist/itowns_lasparser.js.map +1 -0
  11. package/dist/itowns_lasworker.js +2 -0
  12. package/dist/itowns_lasworker.js.map +1 -0
  13. package/dist/itowns_potree2worker.js +2 -0
  14. package/dist/itowns_potree2worker.js.map +1 -0
  15. package/dist/itowns_widgets.js +2 -0
  16. package/dist/itowns_widgets.js.map +1 -0
  17. package/lib/Controls/FirstPersonControls.js +308 -0
  18. package/lib/Controls/FlyControls.js +175 -0
  19. package/lib/Controls/GlobeControls.js +1178 -0
  20. package/lib/Controls/PlanarControls.js +1025 -0
  21. package/lib/Controls/StateControl.js +432 -0
  22. package/lib/Controls/StreetControls.js +392 -0
  23. package/lib/Converter/Feature2Mesh.js +612 -0
  24. package/lib/Converter/Feature2Texture.js +174 -0
  25. package/lib/Converter/convertToTile.js +70 -0
  26. package/lib/Converter/textureConverter.js +43 -0
  27. package/lib/Core/3DTiles/C3DTBatchTable.js +131 -0
  28. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +96 -0
  29. package/lib/Core/3DTiles/C3DTBoundingVolume.js +156 -0
  30. package/lib/Core/3DTiles/C3DTExtensions.js +97 -0
  31. package/lib/Core/3DTiles/C3DTFeature.js +110 -0
  32. package/lib/Core/3DTiles/C3DTilesEnums.js +20 -0
  33. package/lib/Core/3DTiles/C3DTileset.js +99 -0
  34. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +100 -0
  35. package/lib/Core/AnimationPlayer.js +142 -0
  36. package/lib/Core/CopcNode.js +174 -0
  37. package/lib/Core/Deprecated/Undeprecator.js +74 -0
  38. package/lib/Core/EntwinePointTileNode.js +126 -0
  39. package/lib/Core/Feature.js +488 -0
  40. package/lib/Core/Geographic/GeoidGrid.js +108 -0
  41. package/lib/Core/Label.js +222 -0
  42. package/lib/Core/MainLoop.js +209 -0
  43. package/lib/Core/Picking.js +255 -0
  44. package/lib/Core/PointCloudNode.js +42 -0
  45. package/lib/Core/Potree2Node.js +206 -0
  46. package/lib/Core/Potree2PointAttributes.js +139 -0
  47. package/lib/Core/PotreeNode.js +101 -0
  48. package/lib/Core/Prefab/Globe/Atmosphere.js +293 -0
  49. package/lib/Core/Prefab/Globe/GlobeLayer.js +152 -0
  50. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +110 -0
  51. package/lib/Core/Prefab/Globe/SkyShader.js +78 -0
  52. package/lib/Core/Prefab/GlobeView.js +155 -0
  53. package/lib/Core/Prefab/Planar/PlanarLayer.js +59 -0
  54. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +71 -0
  55. package/lib/Core/Prefab/PlanarView.js +62 -0
  56. package/lib/Core/Prefab/TileBuilder.js +82 -0
  57. package/lib/Core/Prefab/computeBufferTileGeometry.js +248 -0
  58. package/lib/Core/Scheduler/Cache.js +17 -0
  59. package/lib/Core/Scheduler/CancelledCommandException.js +15 -0
  60. package/lib/Core/Scheduler/Scheduler.js +294 -0
  61. package/lib/Core/Style.js +660 -0
  62. package/lib/Core/StyleOptions.js +486 -0
  63. package/lib/Core/System/Capabilities.js +63 -0
  64. package/lib/Core/Tile/Tile.js +205 -0
  65. package/lib/Core/Tile/TileGrid.js +49 -0
  66. package/lib/Core/TileGeometry.js +124 -0
  67. package/lib/Core/TileMesh.js +108 -0
  68. package/lib/Core/View.js +1115 -0
  69. package/lib/Layer/C3DTilesLayer.js +459 -0
  70. package/lib/Layer/ColorLayer.js +154 -0
  71. package/lib/Layer/CopcLayer.js +63 -0
  72. package/lib/Layer/ElevationLayer.js +139 -0
  73. package/lib/Layer/EntwinePointTileLayer.js +71 -0
  74. package/lib/Layer/FeatureGeometryLayer.js +77 -0
  75. package/lib/Layer/GeoidLayer.js +80 -0
  76. package/lib/Layer/GeometryLayer.js +233 -0
  77. package/lib/Layer/InfoLayer.js +64 -0
  78. package/lib/Layer/LabelLayer.js +469 -0
  79. package/lib/Layer/Layer.js +335 -0
  80. package/lib/Layer/LayerUpdateState.js +89 -0
  81. package/lib/Layer/LayerUpdateStrategy.js +80 -0
  82. package/lib/Layer/OGC3DTilesLayer.js +543 -0
  83. package/lib/Layer/OrientedImageLayer.js +227 -0
  84. package/lib/Layer/PointCloudLayer.js +405 -0
  85. package/lib/Layer/Potree2Layer.js +171 -0
  86. package/lib/Layer/PotreeLayer.js +72 -0
  87. package/lib/Layer/RasterLayer.js +37 -0
  88. package/lib/Layer/ReferencingLayerProperties.js +62 -0
  89. package/lib/Layer/TiledGeometryLayer.js +459 -0
  90. package/lib/Loader/LASLoader.js +193 -0
  91. package/lib/Loader/Potree2BrotliLoader.js +261 -0
  92. package/lib/Loader/Potree2Loader.js +207 -0
  93. package/lib/Main.js +113 -0
  94. package/lib/MainBundle.js +4 -0
  95. package/lib/Parser/B3dmParser.js +174 -0
  96. package/lib/Parser/CameraCalibrationParser.js +94 -0
  97. package/lib/Parser/GDFParser.js +72 -0
  98. package/lib/Parser/GTXParser.js +75 -0
  99. package/lib/Parser/GeoJsonParser.js +212 -0
  100. package/lib/Parser/GpxParser.js +25 -0
  101. package/lib/Parser/ISGParser.js +71 -0
  102. package/lib/Parser/KMLParser.js +25 -0
  103. package/lib/Parser/LASParser.js +137 -0
  104. package/lib/Parser/MapBoxUrlParser.js +83 -0
  105. package/lib/Parser/PntsParser.js +131 -0
  106. package/lib/Parser/Potree2BinParser.js +92 -0
  107. package/lib/Parser/PotreeBinParser.js +106 -0
  108. package/lib/Parser/PotreeCinParser.js +29 -0
  109. package/lib/Parser/ShapefileParser.js +78 -0
  110. package/lib/Parser/VectorTileParser.js +215 -0
  111. package/lib/Parser/XbilParser.js +120 -0
  112. package/lib/Parser/deprecated/LegacyGLTFLoader.js +1386 -0
  113. package/lib/Parser/iGLTFLoader.js +168 -0
  114. package/lib/Process/3dTilesProcessing.js +304 -0
  115. package/lib/Process/FeatureProcessing.js +76 -0
  116. package/lib/Process/LayeredMaterialNodeProcessing.js +229 -0
  117. package/lib/Process/ObjectRemovalHelper.js +97 -0
  118. package/lib/Process/handlerNodeError.js +23 -0
  119. package/lib/Provider/3dTilesProvider.js +149 -0
  120. package/lib/Provider/DataSourceProvider.js +24 -0
  121. package/lib/Provider/Fetcher.js +233 -0
  122. package/lib/Provider/PointCloudProvider.js +45 -0
  123. package/lib/Provider/TileProvider.js +16 -0
  124. package/lib/Provider/URLBuilder.js +116 -0
  125. package/lib/Renderer/Camera.js +281 -0
  126. package/lib/Renderer/Color.js +56 -0
  127. package/lib/Renderer/ColorLayersOrdering.js +115 -0
  128. package/lib/Renderer/CommonMaterial.js +31 -0
  129. package/lib/Renderer/Label2DRenderer.js +192 -0
  130. package/lib/Renderer/LayeredMaterial.js +243 -0
  131. package/lib/Renderer/OBB.js +150 -0
  132. package/lib/Renderer/OrientedImageCamera.js +118 -0
  133. package/lib/Renderer/OrientedImageMaterial.js +167 -0
  134. package/lib/Renderer/PointsMaterial.js +485 -0
  135. package/lib/Renderer/RasterTile.js +243 -0
  136. package/lib/Renderer/RenderMode.js +31 -0
  137. package/lib/Renderer/Shader/ShaderChunk.js +160 -0
  138. package/lib/Renderer/Shader/ShaderUtils.js +47 -0
  139. package/lib/Renderer/SphereHelper.js +17 -0
  140. package/lib/Renderer/WebXR.js +51 -0
  141. package/lib/Renderer/c3DEngine.js +214 -0
  142. package/lib/Source/C3DTilesGoogleSource.js +74 -0
  143. package/lib/Source/C3DTilesIonSource.js +54 -0
  144. package/lib/Source/C3DTilesSource.js +30 -0
  145. package/lib/Source/CopcSource.js +126 -0
  146. package/lib/Source/EntwinePointTileSource.js +72 -0
  147. package/lib/Source/FileSource.js +188 -0
  148. package/lib/Source/OGC3DTilesGoogleSource.js +29 -0
  149. package/lib/Source/OGC3DTilesIonSource.js +34 -0
  150. package/lib/Source/OGC3DTilesSource.js +21 -0
  151. package/lib/Source/OrientedImageSource.js +59 -0
  152. package/lib/Source/Potree2Source.js +167 -0
  153. package/lib/Source/PotreeSource.js +82 -0
  154. package/lib/Source/Source.js +202 -0
  155. package/lib/Source/TMSSource.js +144 -0
  156. package/lib/Source/VectorTilesSource.js +182 -0
  157. package/lib/Source/WFSSource.js +170 -0
  158. package/lib/Source/WMSSource.js +167 -0
  159. package/lib/Source/WMTSSource.js +92 -0
  160. package/lib/ThreeExtended/capabilities/WebGL.js +69 -0
  161. package/lib/ThreeExtended/libs/ktx-parse.module.js +506 -0
  162. package/lib/ThreeExtended/libs/zstddec.module.js +29 -0
  163. package/lib/ThreeExtended/loaders/DDSLoader.js +200 -0
  164. package/lib/ThreeExtended/loaders/DRACOLoader.js +400 -0
  165. package/lib/ThreeExtended/loaders/GLTFLoader.js +2879 -0
  166. package/lib/ThreeExtended/loaders/KTX2Loader.js +709 -0
  167. package/lib/ThreeExtended/math/ColorSpaces.js +59 -0
  168. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +846 -0
  169. package/lib/ThreeExtended/utils/WorkerPool.js +70 -0
  170. package/lib/Utils/CameraUtils.js +554 -0
  171. package/lib/Utils/DEMUtils.js +350 -0
  172. package/lib/Utils/FeaturesUtils.js +156 -0
  173. package/lib/Utils/Gradients.js +16 -0
  174. package/lib/Utils/ThreeUtils.js +115 -0
  175. package/lib/Utils/gui/C3DTilesStyle.js +218 -0
  176. package/lib/Utils/gui/Main.js +7 -0
  177. package/lib/Utils/gui/Minimap.js +152 -0
  178. package/lib/Utils/gui/Navigation.js +245 -0
  179. package/lib/Utils/gui/Scale.js +104 -0
  180. package/lib/Utils/gui/Searchbar.js +234 -0
  181. package/lib/Utils/gui/Widget.js +80 -0
  182. package/lib/Utils/placeObjectOnGround.js +136 -0
  183. package/lib/Worker/LASLoaderWorker.js +19 -0
  184. package/lib/Worker/Potree2Worker.js +21 -0
  185. package/package.json +2 -2
@@ -0,0 +1,171 @@
1
+ /*
2
+ ============
3
+ == POTREE ==
4
+ ============
5
+
6
+ http://potree.org
7
+
8
+ Copyright (c) 2011-2020, Markus Schütz
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this
15
+ list of conditions and the following disclaimer.
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
24
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ The views and conclusions contained in the software and documentation are those
32
+ of the authors and should not be interpreted as representing official policies,
33
+ either expressed or implied, of the FreeBSD Project.
34
+ */
35
+
36
+ import * as THREE from 'three';
37
+ import PointCloudLayer from "./PointCloudLayer.js";
38
+ import Potree2Node from "../Core/Potree2Node.js";
39
+ import { Extent } from '@itowns/geographic';
40
+ import { PointAttribute, Potree2PointAttributes, PointAttributeTypes } from "../Core/Potree2PointAttributes.js";
41
+ const bboxMesh = new THREE.Mesh();
42
+ const box3 = new THREE.Box3();
43
+ bboxMesh.geometry.boundingBox = box3;
44
+ const typeNameAttributeMap = {
45
+ double: PointAttributeTypes.DATA_TYPE_DOUBLE,
46
+ float: PointAttributeTypes.DATA_TYPE_FLOAT,
47
+ int8: PointAttributeTypes.DATA_TYPE_INT8,
48
+ uint8: PointAttributeTypes.DATA_TYPE_UINT8,
49
+ int16: PointAttributeTypes.DATA_TYPE_INT16,
50
+ uint16: PointAttributeTypes.DATA_TYPE_UINT16,
51
+ int32: PointAttributeTypes.DATA_TYPE_INT32,
52
+ uint32: PointAttributeTypes.DATA_TYPE_UINT32,
53
+ int64: PointAttributeTypes.DATA_TYPE_INT64,
54
+ uint64: PointAttributeTypes.DATA_TYPE_UINT64
55
+ };
56
+ function parseAttributes(jsonAttributes) {
57
+ const attributes = new Potree2PointAttributes();
58
+ const replacements = {
59
+ rgb: 'rgba'
60
+ };
61
+ for (const jsonAttribute of jsonAttributes) {
62
+ const {
63
+ name,
64
+ numElements,
65
+ min,
66
+ max
67
+ } = jsonAttribute;
68
+ const type = typeNameAttributeMap[jsonAttribute.type];
69
+ const potreeAttributeName = replacements[name] ? replacements[name] : name;
70
+ const attribute = new PointAttribute(potreeAttributeName, type, numElements);
71
+ if (numElements === 1) {
72
+ attribute.range = [min[0], max[0]];
73
+ } else {
74
+ attribute.range = [min, max];
75
+ }
76
+ if (name === 'gps-time') {
77
+ // HACK: Guard against bad gpsTime range in metadata, see potree/potree#909
78
+ if (attribute.range[0] === attribute.range[1]) {
79
+ attribute.range[1] += 1;
80
+ }
81
+ }
82
+ attribute.initialRange = attribute.range;
83
+ attributes.add(attribute);
84
+ }
85
+ {
86
+ // check if it has normals
87
+ const hasNormals = attributes.attributes.find(a => a.name === 'NormalX') !== undefined && attributes.attributes.find(a => a.name === 'NormalY') !== undefined && attributes.attributes.find(a => a.name === 'NormalZ') !== undefined;
88
+ if (hasNormals) {
89
+ attributes.addVector({
90
+ name: 'NORMAL',
91
+ attributes: ['NormalX', 'NormalY', 'NormalZ']
92
+ });
93
+ }
94
+ }
95
+ return attributes;
96
+ }
97
+
98
+ /**
99
+ * @property {boolean} isPotreeLayer - Used to checkout whether this layer
100
+ * is a Potree2Layer. Default is `true`. You should not change this, as it is
101
+ * used internally for optimisation.
102
+ *
103
+ * @extends PointCloudLayer
104
+ */
105
+ class Potree2Layer extends PointCloudLayer {
106
+ /**
107
+ * Constructs a new instance of Potree2 layer.
108
+ *
109
+ * @example
110
+ * // Create a new point cloud layer
111
+ * const points = new Potree2Layer('points',
112
+ * {
113
+ * source: new Potree2Source({
114
+ * url: 'https://pointsClouds/',
115
+ * file: 'metadata.json',
116
+ * }
117
+ * });
118
+ *
119
+ * View.prototype.addLayer.call(view, points);
120
+ *
121
+ * @param {string} id - The id of the layer, that should be unique. It is
122
+ * not mandatory, but an error will be emitted if this layer is added a
123
+ * {@link View} that already has a layer going by that id.
124
+ * @param {Object} config - Configuration, all elements in it
125
+ * will be merged as is in the layer. For example, if the configuration
126
+ * contains three elements `name, protocol, extent`, these elements will be
127
+ * available using `layer.name` or something else depending on the property
128
+ * name. See the list of properties to know which one can be specified.
129
+ * @param {string} [config.crs=ESPG:4326] - The CRS of the {@link View} this
130
+ * layer will be attached to. This is used to determine the extent of this
131
+ * layer. Default to `EPSG:4326`.
132
+ */
133
+ constructor(id, config) {
134
+ super(id, config);
135
+
136
+ /**
137
+ * @type {boolean}
138
+ * @readonly
139
+ */
140
+ this.isPotreeLayer = true;
141
+ const resolve = this.addInitializationStep();
142
+ this.source.whenReady.then(metadata => {
143
+ this.scale = new THREE.Vector3(1, 1, 1);
144
+ this.metadata = metadata;
145
+ this.pointAttributes = parseAttributes(metadata.attributes);
146
+ this.spacing = metadata.spacing;
147
+ const normal = Array.isArray(this.pointAttributes.attributes) && this.pointAttributes.attributes.find(elem => elem.name.startsWith('NORMAL'));
148
+ if (normal) {
149
+ this.material.defines[normal.name] = 1;
150
+ }
151
+ const min = new THREE.Vector3(...metadata.boundingBox.min);
152
+ const max = new THREE.Vector3(...metadata.boundingBox.max);
153
+ const boundingBox = new THREE.Box3(min, max);
154
+ const root = new Potree2Node(0, 0, this);
155
+ root.bbox = boundingBox;
156
+ root.boundingSphere = boundingBox.getBoundingSphere(new THREE.Sphere());
157
+ this.minElevationRange = this.minElevationRange ?? metadata.boundingBox.min[2];
158
+ this.maxElevationRange = this.maxElevationRange ?? metadata.boundingBox.max[2];
159
+ root.id = 'r';
160
+ root.depth = 0;
161
+ root.nodeType = 2;
162
+ root.hierarchyByteOffset = 0n;
163
+ root.hierarchyByteSize = BigInt(metadata.hierarchy.firstChunkSize);
164
+ root.byteOffset = 0;
165
+ this.root = root;
166
+ this.extent = Extent.fromBox3(this.source.crs || 'EPSG:4326', boundingBox);
167
+ return this.root.loadOctree().then(resolve);
168
+ });
169
+ }
170
+ }
171
+ export default Potree2Layer;
@@ -0,0 +1,72 @@
1
+ import * as THREE from 'three';
2
+ import PointCloudLayer from "./PointCloudLayer.js";
3
+ import PotreeNode from "../Core/PotreeNode.js";
4
+ import { Extent } from '@itowns/geographic';
5
+ const bboxMesh = new THREE.Mesh();
6
+ const box3 = new THREE.Box3();
7
+ bboxMesh.geometry.boundingBox = box3;
8
+
9
+ /**
10
+ * @property {boolean} isPotreeLayer - Used to checkout whether this layer
11
+ * is a PotreeLayer. Default is `true`. You should not change this, as it is
12
+ * used internally for optimisation.
13
+ *
14
+ * @extends PointCloudLayer
15
+ */
16
+ class PotreeLayer extends PointCloudLayer {
17
+ /**
18
+ * Constructs a new instance of Potree layer.
19
+ *
20
+ * @example
21
+ * // Create a new point cloud layer
22
+ * const points = new PotreeLayer('points',
23
+ * {
24
+ * source: new PotreeLayer({
25
+ * url: 'https://pointsClouds/',
26
+ * file: 'points.js',
27
+ * }
28
+ * });
29
+ *
30
+ * View.prototype.addLayer.call(view, points);
31
+ *
32
+ * @param {string} id - The id of the layer, that should be unique. It is
33
+ * not mandatory, but an error will be emitted if this layer is added a
34
+ * {@link View} that already has a layer going by that id.
35
+ * @param {Object} config - Configuration, all elements in it
36
+ * will be merged as is in the layer. For example, if the configuration
37
+ * contains three elements `name, protocol, extent`, these elements will be
38
+ * available using `layer.name` or something else depending on the property
39
+ * name. See the list of properties to know which one can be specified.
40
+ * @param {string} [config.crs='ESPG:4326'] - The CRS of the {@link View} this
41
+ * layer will be attached to. This is used to determine the extent of this
42
+ * layer. Default to `EPSG:4326`.
43
+ */
44
+ constructor(id, config) {
45
+ super(id, config);
46
+
47
+ /**
48
+ * @type {boolean}
49
+ * @readonly
50
+ */
51
+ this.isPotreeLayer = true;
52
+ const resolve = this.addInitializationStep();
53
+ this.source.whenReady.then(cloud => {
54
+ this.scale = new THREE.Vector3().addScalar(cloud.scale);
55
+ this.spacing = cloud.spacing;
56
+ this.hierarchyStepSize = cloud.hierarchyStepSize;
57
+ const normal = Array.isArray(cloud.pointAttributes) && cloud.pointAttributes.find(elem => elem.startsWith('NORMAL'));
58
+ if (normal) {
59
+ this.material.defines[normal] = 1;
60
+ }
61
+ this.supportsProgressiveDisplay = this.source.extension === 'cin';
62
+ this.root = new PotreeNode(0, 0, this);
63
+ this.root.bbox.min.set(cloud.boundingBox.lx, cloud.boundingBox.ly, cloud.boundingBox.lz);
64
+ this.root.bbox.max.set(cloud.boundingBox.ux, cloud.boundingBox.uy, cloud.boundingBox.uz);
65
+ this.minElevationRange = this.minElevationRange ?? cloud.boundingBox.lz;
66
+ this.maxElevationRange = this.maxElevationRange ?? cloud.boundingBox.uz;
67
+ this.extent = Extent.fromBox3(this.source.crs || 'EPSG:4326', this.root.bbox);
68
+ return this.root.loadOctree().then(resolve);
69
+ });
70
+ }
71
+ }
72
+ export default PotreeLayer;
@@ -0,0 +1,37 @@
1
+ import Layer from "./Layer.js";
2
+ import { removeLayeredMaterialNodeLayer } from "../Process/LayeredMaterialNodeProcessing.js";
3
+ import textureConverter from "../Converter/textureConverter.js";
4
+ import { CACHE_POLICIES } from "../Core/Scheduler/Cache.js";
5
+ class RasterLayer extends Layer {
6
+ constructor(id, config) {
7
+ const {
8
+ cacheLifeTime = CACHE_POLICIES.TEXTURE,
9
+ minFilter,
10
+ magFilter,
11
+ ...layerConfig
12
+ } = config;
13
+ super(id, {
14
+ ...layerConfig,
15
+ cacheLifeTime
16
+ });
17
+ this.minFilter = minFilter;
18
+ this.magFilter = magFilter;
19
+ }
20
+ convert(data, extentDestination) {
21
+ return textureConverter.convert(data, extentDestination, this);
22
+ }
23
+
24
+ /**
25
+ * All layer's textures are removed from scene and disposed from video device.
26
+ * @param {boolean} [clearCache=false] Whether to clear the layer cache or not
27
+ */
28
+ delete(clearCache) {
29
+ if (clearCache) {
30
+ this.cache.clear();
31
+ }
32
+ for (const root of this.parent.level0Nodes) {
33
+ root.traverse(removeLayeredMaterialNodeLayer(this.id));
34
+ }
35
+ }
36
+ }
37
+ export default RasterLayer;
@@ -0,0 +1,62 @@
1
+ // next step is move these properties to Style class
2
+ // and hide transparent mechanism
3
+ function ReferLayerProperties(material, layer) {
4
+ if (layer && layer.isGeometryLayer) {
5
+ let transparent = material.transparent;
6
+ material.layer = layer;
7
+ if (material.uniforms && material.uniforms.opacity != undefined) {
8
+ Object.defineProperty(material.uniforms.opacity, 'value', {
9
+ get: () => material.layer.opacity
10
+ });
11
+ } else if (material.opacity != undefined) {
12
+ Object.defineProperty(material, 'opacity', {
13
+ get: () => material.layer.opacity
14
+ });
15
+ }
16
+ if (material.uniforms && material.uniforms.mode != undefined) {
17
+ Object.defineProperty(material.uniforms.mode, 'value', {
18
+ get: () => material.layer.pntsMode
19
+ });
20
+ }
21
+ if (material.uniforms && material.uniforms.shape != undefined) {
22
+ Object.defineProperty(material.uniforms.shape, 'value', {
23
+ get: () => material.layer.pntsShape
24
+ });
25
+ }
26
+ if (material.uniforms && material.uniforms.sizeMode != undefined) {
27
+ Object.defineProperty(material.uniforms.sizeMode, 'value', {
28
+ get: () => material.layer.pntsSizeMode
29
+ });
30
+ }
31
+ if (material.uniforms && material.uniforms.minAttenuatedSize != undefined) {
32
+ Object.defineProperty(material.uniforms.minAttenuatedSize, 'value', {
33
+ get: () => material.layer.pntsMinAttenuatedSize
34
+ });
35
+ }
36
+ if (material.uniforms && material.uniforms.maxAttenuatedSize != undefined) {
37
+ Object.defineProperty(material.uniforms.maxAttenuatedSize, 'value', {
38
+ get: () => material.layer.pntsMaxAttenuatedSize
39
+ });
40
+ }
41
+ if (material.uniforms && material.uniforms.scale != undefined) {
42
+ Object.defineProperty(material.uniforms.scale, 'value', {
43
+ get: () => material.layer.scale
44
+ });
45
+ }
46
+ Object.defineProperty(material, 'wireframe', {
47
+ get: () => material.layer.wireframe
48
+ });
49
+ Object.defineProperty(material, 'transparent', {
50
+ get: () => {
51
+ const needTransparency = material.userData.needTransparency?.[material.mode] || material.layer.opacity < 1.0;
52
+ if (transparent != needTransparency) {
53
+ material.needsUpdate = true;
54
+ transparent = needTransparency;
55
+ }
56
+ return transparent;
57
+ }
58
+ });
59
+ }
60
+ return material;
61
+ }
62
+ export default ReferLayerProperties;