itowns 2.45.2-next.1 → 2.45.2-next.3

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.
@@ -161,7 +161,7 @@
161
161
  const input_url = document.getElementById('url');
162
162
  if (!input_url) return;
163
163
 
164
- uri.searchParams.set('copc', url);
164
+ uri.searchParams.set('3dtiles', url);
165
165
  history.replaceState(null, null, `?${uri.searchParams.toString()}`);
166
166
 
167
167
  input_url.value = url;
@@ -220,6 +220,15 @@
220
220
  window.loadSete = loadSete;
221
221
  window.loadLille = loadLille;
222
222
 
223
+
224
+ function loadPassedModel() {
225
+ const passedUrl = uri.searchParams.get('3dtiles');
226
+ if (passedUrl) {
227
+ setUrl(passedUrl);
228
+ }
229
+ }
230
+ loadPassedModel();
231
+
223
232
  </script>
224
233
  </body>
225
234
  </html>
package/lib/Main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const conf = {
2
- version: '2.45.2-next.1'
2
+ version: '2.45.2-next.3'
3
3
  };
4
4
  export const REVISION = conf.version;
5
5
 
@@ -44,8 +44,10 @@ interface LayeredMaterialRawUniforms {
44
44
  opacity: number;
45
45
  lightingEnabled: boolean;
46
46
  lightPosition: THREE.Vector3;
47
- fogDistance: number;
47
+ fogNear: number;
48
+ fogFar: number;
48
49
  fogColor: THREE.Color;
50
+ fogDensity: number;
49
51
  overlayAlpha: number;
50
52
  overlayColor: THREE.Color;
51
53
  objectId: number;
@@ -75,7 +77,6 @@ type RenderModeDefines = DefineMapping<'MODE', typeof RenderMode.MODES>;
75
77
  type LayeredMaterialDefines = {
76
78
  NUM_VS_TEXTURES: number;
77
79
  NUM_FS_TEXTURES: number;
78
- USE_FOG: number;
79
80
  NUM_CRS: number;
80
81
  DEBUG: number;
81
82
  MODE: number;
@@ -2,7 +2,7 @@ import * as THREE from 'three';
2
2
  /* babel-plugin-inline-import './Shader/TileVS.glsl' */
3
3
  const TileVS = "#include <itowns/precision_qualifier>\n#include <common>\n#include <itowns/elevation_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#if NUM_CRS > 1\nattribute float uv_1;\n#endif\n\nuniform bool lightingEnabled;\nvarying vec2 vHighPrecisionZW;\n\n#if MODE == MODE_FINAL\n#include <fog_pars_vertex>\nvarying vec3 vUv;\nvarying vec3 vNormal;\n#endif\nvoid main() {\n #include <begin_vertex>\n #include <itowns/elevation_vertex>\n #include <itowns/geoid_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n vHighPrecisionZW = gl_Position.zw;\n#if MODE == MODE_FINAL\n #include <fog_vertex>\n #if NUM_CRS > 1\n vUv = vec3(uv, (uv_1 > 0.) ? uv_1 : uv.y); // set uv_1 = uv if uv_1 is undefined\n #else\n vUv = vec3(uv, 0.0);\n #endif\n vNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );\n#endif\n}\n";
4
4
  /* babel-plugin-inline-import './Shader/TileFS.glsl' */
5
- const TileFS = "#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#include <itowns/pitUV>\n#include <itowns/color_layers_pars_fragment>\n#if MODE == MODE_FINAL\n#include <itowns/fog_pars_fragment>\n#include <itowns/overlay_pars_fragment>\n#include <itowns/lighting_pars_fragment>\n#endif\n#include <itowns/mode_pars_fragment>\n\nuniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vUv; // uv.x/uv_1.x, uv.y, uv_1.y\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n #include <logdepthbuf_fragment>\n\n#if MODE == MODE_ID\n\n #include <itowns/mode_id_fragment>\n\n#elif MODE == MODE_DEPTH\n\n #include <itowns/mode_depth_fragment>\n\n#else\n\n gl_FragColor = vec4(diffuse, opacity);\n\n uvs[0] = vec3(vUv.xy, 0.);\n\n#if NUM_CRS > 1\n uvs[1] = vec3(vUv.x, fract(vUv.z), floor(vUv.z));\n#endif\n\n vec4 color;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_FS_TEXTURES; i ++ ) {\n color = getLayerColor( i , colorTextures[ i ], colorOffsetScales[ i ], colorLayers[ i ]);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n }\n\n #if DEBUG == 1\n if (showOutline) {\n #pragma unroll_loop\n for ( int i = 0; i < NUM_CRS; i ++) {\n color = getOutlineColor( outlineColors[ i ], uvs[ i ].xy);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n }\n }\n #endif\n\n #include <itowns/fog_fragment>\n #include <itowns/lighting_fragment>\n #include <itowns/overlay_fragment>\n\n#endif\n}\n";
5
+ const TileFS = "#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#include <itowns/pitUV>\n#include <itowns/color_layers_pars_fragment>\n#if MODE == MODE_FINAL\n#include <fog_pars_fragment>\n#include <itowns/overlay_pars_fragment>\n#include <itowns/lighting_pars_fragment>\n#endif\n#include <itowns/mode_pars_fragment>\n\nuniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vUv; // uv.x/uv_1.x, uv.y, uv_1.y\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n #include <logdepthbuf_fragment>\n\n#if MODE == MODE_ID\n\n #include <itowns/mode_id_fragment>\n\n#elif MODE == MODE_DEPTH\n\n #include <itowns/mode_depth_fragment>\n\n#else\n\n gl_FragColor = vec4(diffuse, opacity);\n\n uvs[0] = vec3(vUv.xy, 0.);\n\n#if NUM_CRS > 1\n uvs[1] = vec3(vUv.x, fract(vUv.z), floor(vUv.z));\n#endif\n\n vec4 color;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_FS_TEXTURES; i ++ ) {\n color = getLayerColor( i , colorTextures[ i ], colorOffsetScales[ i ], colorLayers[ i ]);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n }\n\n #if DEBUG == 1\n if (showOutline) {\n #pragma unroll_loop\n for ( int i = 0; i < NUM_CRS; i ++) {\n color = getOutlineColor( outlineColors[ i ], uvs[ i ].xy);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n }\n }\n #endif\n\n #include <fog_fragment>\n #include <itowns/lighting_fragment>\n #include <itowns/overlay_fragment>\n\n#endif\n}\n";
6
6
  import ShaderUtils from "./Shader/ShaderUtils.js";
7
7
  import Capabilities from "../Core/System/Capabilities.js";
8
8
  import RenderMode from "./RenderMode.js";
@@ -123,14 +123,13 @@ export class LayeredMaterial extends THREE.ShaderMaterial {
123
123
  const defines = {};
124
124
  fillInProp(defines, 'NUM_VS_TEXTURES', nbSamplers[0]);
125
125
  fillInProp(defines, 'NUM_FS_TEXTURES', nbSamplers[1]);
126
- // TODO: We do not use the fog from the scene, is this a desired
127
- // behavior?
128
- fillInProp(defines, 'USE_FOG', 1);
129
126
  fillInProp(defines, 'NUM_CRS', crsCount);
130
127
  initModeDefines(defines);
131
128
  fillInProp(defines, 'MODE', RenderMode.MODES.FINAL);
132
129
  fillInProp(defines, 'DEBUG', +false);
133
130
  this.defines = defines;
131
+ this.fog = true; // receive the fog defined on the scene, if any
132
+
134
133
  this.vertexShader = TileVS;
135
134
  // three loop unrolling of ShaderMaterial only supports integer bounds,
136
135
  // see https://github.com/mrdoob/three.js/issues/28020
@@ -144,8 +143,10 @@ export class LayeredMaterial extends THREE.ShaderMaterial {
144
143
  lightingEnabled: false,
145
144
  lightPosition: new THREE.Vector3(-0.5, 0.0, 1.0),
146
145
  // Misc properties
147
- fogDistance: 1000000000.0,
146
+ fogNear: 1,
147
+ fogFar: 1000,
148
148
  fogColor: new THREE.Color(0.76, 0.85, 1.0),
149
+ fogDensity: 0.00025,
149
150
  overlayAlpha: 0,
150
151
  overlayColor: new THREE.Color(1.0, 0.3, 0.0),
151
152
  objectId: 0,
@@ -7,10 +7,6 @@ const elevation_pars_vertex = "#if NUM_VS_TEXTURES > 0\n struct Layer {\n
7
7
  const elevation_vertex = "#if NUM_VS_TEXTURES > 0\n if(elevationTextureCount > 0) {\n float elevation = getElevation(uv, elevationTextures[0], elevationOffsetScales[0], elevationLayers[0]);\n transformed += elevation * normal;\n }\n#endif\n";
8
8
  /* babel-plugin-inline-import './Chunk/geoid_vertex.glsl' */
9
9
  const geoid_vertex = "transformed += geoidHeight * normal;\n";
10
- /* babel-plugin-inline-import './Chunk/fog_fragment.glsl' */
11
- const fog_fragment = "#if defined(USE_FOG)\n float fogFactor = 1. - min( exp(-vFogDepth / fogDistance), 1.);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor);\n#endif\n";
12
- /* babel-plugin-inline-import './Chunk/fog_pars_fragment.glsl' */
13
- const fog_pars_fragment = "#if defined(USE_FOG)\nuniform vec3 fogColor;\nuniform float fogDistance;\nvarying float vFogDepth;\n#endif\n";
14
10
  /* babel-plugin-inline-import './Chunk/lighting_fragment.glsl' */
15
11
  const lighting_fragment = "if (lightingEnabled) {\n float light = min(2. * dot(vNormal, lightPosition), 1.);\n gl_FragColor.rgb *= light;\n}\n";
16
12
  /* babel-plugin-inline-import './Chunk/lighting_pars_fragment.glsl' */
@@ -44,8 +40,6 @@ const itownsShaderChunk = {
44
40
  elevation_pars_vertex,
45
41
  elevation_vertex,
46
42
  geoid_vertex,
47
- fog_fragment,
48
- fog_pars_fragment,
49
43
  lighting_fragment,
50
44
  lighting_pars_fragment,
51
45
  mode_depth_fragment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.45.2-next.1",
3
+ "version": "2.45.2-next.3",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",
@@ -51,7 +51,7 @@
51
51
  "url": "https://github.com/iTowns/itowns/issues"
52
52
  },
53
53
  "dependencies": {
54
- "@itowns/geographic": "^2.45.2-next.1",
54
+ "@itowns/geographic": "^2.45.2-next.3",
55
55
  "@mapbox/vector-tile": "^2.0.3",
56
56
  "@maplibre/maplibre-gl-style-spec": "^23.1.0",
57
57
  "@tmcw/togeojson": "^7.0.0",