@3driseai/3drise-viewer 0.1.7 → 0.1.8
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/components/Clouds.d.ts.map +1 -1
- package/dist/components/Clouds.js +0 -1
- package/dist/components/CloudsGenerator.d.ts +32 -0
- package/dist/components/CloudsGenerator.d.ts.map +1 -0
- package/dist/components/CloudsGenerator.js +58 -0
- package/dist/components/EnvironmentManager.d.ts +47 -5
- package/dist/components/EnvironmentManager.d.ts.map +1 -1
- package/dist/components/EnvironmentManager.js +35 -66
- package/dist/components/HdrEnvironment.d.ts +20 -0
- package/dist/components/HdrEnvironment.d.ts.map +1 -0
- package/dist/components/HdrEnvironment.js +44 -0
- package/dist/components/LandscapeBuilder.d.ts +23 -0
- package/dist/components/LandscapeBuilder.d.ts.map +1 -0
- package/dist/components/LandscapeBuilder.js +25 -0
- package/dist/components/LandscapeObject.d.ts +24 -0
- package/dist/components/LandscapeObject.d.ts.map +1 -0
- package/dist/components/LandscapeObject.js +27 -0
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +10 -0
- package/dist/components/OceanBuilder.d.ts +35 -0
- package/dist/components/OceanBuilder.d.ts.map +1 -0
- package/dist/components/OceanBuilder.js +53 -0
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SkySystem.d.ts +27 -6
- package/dist/components/SkySystem.d.ts.map +1 -1
- package/dist/components/SkySystem.js +6 -5
- package/dist/components/SunLight.d.ts.map +1 -1
- package/dist/components/SunLight.js +4 -1
- package/dist/components/TerrainBuilder.d.ts +30 -0
- package/dist/components/TerrainBuilder.d.ts.map +1 -0
- package/dist/components/TerrainBuilder.js +44 -0
- package/dist/components/index.d.ts +17 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +10 -0
- package/dist/components/landscape/LandscapeMesh.d.ts +18 -0
- package/dist/components/landscape/LandscapeMesh.d.ts.map +1 -0
- package/dist/components/landscape/LandscapeMesh.js +278 -0
- package/dist/components/landscape/index.d.ts +3 -0
- package/dist/components/landscape/index.d.ts.map +1 -0
- package/dist/components/landscape/index.js +1 -0
- package/dist/components/landscape/types.d.ts +13 -0
- package/dist/components/landscape/types.d.ts.map +1 -0
- package/dist/components/landscape/types.js +1 -0
- package/dist/components/terrain/Canyon.d.ts +23 -0
- package/dist/components/terrain/Canyon.d.ts.map +1 -0
- package/dist/components/terrain/Canyon.js +29 -0
- package/dist/components/terrain/Dunes.d.ts +22 -0
- package/dist/components/terrain/Dunes.d.ts.map +1 -0
- package/dist/components/terrain/Dunes.js +25 -0
- package/dist/components/terrain/Hills.d.ts +17 -0
- package/dist/components/terrain/Hills.d.ts.map +1 -0
- package/dist/components/terrain/Hills.js +20 -0
- package/dist/components/terrain/Mountains.d.ts +19 -0
- package/dist/components/terrain/Mountains.d.ts.map +1 -0
- package/dist/components/terrain/Mountains.js +22 -0
- package/dist/components/terrain/TerrainSurface.d.ts +22 -0
- package/dist/components/terrain/TerrainSurface.d.ts.map +1 -0
- package/dist/components/terrain/TerrainSurface.js +94 -0
- package/dist/components/terrain/index.d.ts +7 -0
- package/dist/components/terrain/index.d.ts.map +1 -0
- package/dist/components/terrain/index.js +7 -0
- package/dist/components/terrain/types.d.ts +17 -0
- package/dist/components/terrain/types.d.ts.map +1 -0
- package/dist/components/terrain/types.js +1 -0
- package/dist/components/volumetricClouds/Cirrus.d.ts +14 -0
- package/dist/components/volumetricClouds/Cirrus.d.ts.map +1 -0
- package/dist/components/volumetricClouds/Cirrus.js +13 -0
- package/dist/components/volumetricClouds/Cumulonimbus.d.ts +17 -0
- package/dist/components/volumetricClouds/Cumulonimbus.d.ts.map +1 -0
- package/dist/components/volumetricClouds/Cumulonimbus.js +20 -0
- package/dist/components/volumetricClouds/Cumulus.d.ts +14 -0
- package/dist/components/volumetricClouds/Cumulus.d.ts.map +1 -0
- package/dist/components/volumetricClouds/Cumulus.js +17 -0
- package/dist/components/volumetricClouds/Stratocumulus.d.ts +12 -0
- package/dist/components/volumetricClouds/Stratocumulus.d.ts.map +1 -0
- package/dist/components/volumetricClouds/Stratocumulus.js +16 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts +42 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.js +298 -0
- package/dist/components/volumetricClouds/index.d.ts +8 -0
- package/dist/components/volumetricClouds/index.d.ts.map +1 -0
- package/dist/components/volumetricClouds/index.js +7 -0
- package/dist/components/volumetricClouds/types.d.ts +17 -0
- package/dist/components/volumetricClouds/types.d.ts.map +1 -0
- package/dist/components/volumetricClouds/types.js +1 -0
- package/dist/components/water/Host.d.ts +12 -0
- package/dist/components/water/Host.d.ts.map +1 -0
- package/dist/components/water/Host.js +12 -0
- package/dist/components/water/Lake.d.ts +18 -0
- package/dist/components/water/Lake.d.ts.map +1 -0
- package/dist/components/water/Lake.js +21 -0
- package/dist/components/water/OceanSurface.d.ts +27 -0
- package/dist/components/water/OceanSurface.d.ts.map +1 -0
- package/dist/components/water/OceanSurface.js +60 -0
- package/dist/components/water/Sea.d.ts +18 -0
- package/dist/components/water/Sea.d.ts.map +1 -0
- package/dist/components/water/Sea.js +17 -0
- package/dist/components/water/Shore.d.ts +16 -0
- package/dist/components/water/Shore.d.ts.map +1 -0
- package/dist/components/water/Shore.js +15 -0
- package/dist/components/water/Storm.d.ts +14 -0
- package/dist/components/water/Storm.d.ts.map +1 -0
- package/dist/components/water/Storm.js +13 -0
- package/dist/components/water/WaterBody.d.ts +31 -0
- package/dist/components/water/WaterBody.d.ts.map +1 -0
- package/dist/components/water/WaterBody.js +76 -0
- package/dist/components/water/index.d.ts +9 -0
- package/dist/components/water/index.d.ts.map +1 -0
- package/dist/components/water/index.js +11 -0
- package/dist/components/water/types.d.ts +20 -0
- package/dist/components/water/types.d.ts.map +1 -0
- package/dist/components/water/types.js +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +9 -0
- package/dist/hooks/index.d.ts +24 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +12 -0
- package/dist/hooks/useClipmap.d.ts +71 -0
- package/dist/hooks/useClipmap.d.ts.map +1 -0
- package/dist/hooks/useClipmap.js +81 -0
- package/dist/hooks/useCloudLive.d.ts +29 -0
- package/dist/hooks/useCloudLive.d.ts.map +1 -0
- package/dist/hooks/useCloudLive.js +43 -0
- package/dist/hooks/useCloudNoise.d.ts +28 -0
- package/dist/hooks/useCloudNoise.d.ts.map +1 -0
- package/dist/hooks/useCloudNoise.js +128 -0
- package/dist/hooks/useCloudSun.d.ts +49 -0
- package/dist/hooks/useCloudSun.d.ts.map +1 -0
- package/dist/hooks/useCloudSun.js +84 -0
- package/dist/hooks/useCubeCamera.d.ts +27 -9
- package/dist/hooks/useCubeCamera.d.ts.map +1 -1
- package/dist/hooks/useCubeCamera.js +28 -70
- package/dist/hooks/useEnvironmentProbe.d.ts +32 -0
- package/dist/hooks/useEnvironmentProbe.d.ts.map +1 -0
- package/dist/hooks/useEnvironmentProbe.js +35 -0
- package/dist/hooks/useFrameRenderer.d.ts +15 -0
- package/dist/hooks/useFrameRenderer.d.ts.map +1 -0
- package/dist/hooks/useFrameRenderer.js +23 -0
- package/dist/hooks/useLandscapeLive.d.ts +29 -0
- package/dist/hooks/useLandscapeLive.d.ts.map +1 -0
- package/dist/hooks/useLandscapeLive.js +41 -0
- package/dist/hooks/useLandscapeMaps.d.ts +32 -0
- package/dist/hooks/useLandscapeMaps.d.ts.map +1 -0
- package/dist/hooks/useLandscapeMaps.js +138 -0
- package/dist/hooks/useOceanLive.d.ts +29 -0
- package/dist/hooks/useOceanLive.d.ts.map +1 -0
- package/dist/hooks/useOceanLive.js +38 -0
- package/dist/hooks/useOceanMaterial.d.ts +39 -0
- package/dist/hooks/useOceanMaterial.d.ts.map +1 -0
- package/dist/hooks/useOceanMaterial.js +65 -0
- package/dist/hooks/useTerrainClipmap.d.ts +12 -0
- package/dist/hooks/useTerrainClipmap.d.ts.map +1 -0
- package/dist/hooks/useTerrainClipmap.js +10 -0
- package/dist/hooks/useTerrainLive.d.ts +34 -0
- package/dist/hooks/useTerrainLive.d.ts.map +1 -0
- package/dist/hooks/useTerrainLive.js +45 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/presets/landscapePresets.d.ts +60 -0
- package/dist/presets/landscapePresets.d.ts.map +1 -0
- package/dist/presets/landscapePresets.js +194 -0
- package/dist/presets/landscapeTypes.d.ts +195 -0
- package/dist/presets/landscapeTypes.d.ts.map +1 -0
- package/dist/presets/landscapeTypes.js +315 -0
- package/dist/presets/oceanSurfacePresets.d.ts +33 -0
- package/dist/presets/oceanSurfacePresets.d.ts.map +1 -0
- package/dist/presets/oceanSurfacePresets.js +245 -0
- package/dist/presets/terrainPresets.d.ts +28 -0
- package/dist/presets/terrainPresets.d.ts.map +1 -0
- package/dist/presets/terrainPresets.js +293 -0
- package/dist/presets/volumetricCloudPresets.d.ts +38 -0
- package/dist/presets/volumetricCloudPresets.d.ts.map +1 -0
- package/dist/presets/volumetricCloudPresets.js +480 -0
- package/dist/shaders/clouds/CirrusMaterial.d.ts +84 -0
- package/dist/shaders/clouds/CirrusMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/CirrusMaterial.js +167 -0
- package/dist/shaders/clouds/CloudCompositeMaterial.d.ts +20 -0
- package/dist/shaders/clouds/CloudCompositeMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/CloudCompositeMaterial.js +82 -0
- package/dist/shaders/clouds/CloudResolveMaterial.d.ts +22 -0
- package/dist/shaders/clouds/CloudResolveMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/CloudResolveMaterial.js +77 -0
- package/dist/shaders/clouds/CloudVolumeMaterial.d.ts +143 -0
- package/dist/shaders/clouds/CloudVolumeMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/CloudVolumeMaterial.js +249 -0
- package/dist/shaders/clouds/SkyBackgroundMaterial.d.ts +21 -0
- package/dist/shaders/clouds/SkyBackgroundMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/SkyBackgroundMaterial.js +42 -0
- package/dist/shaders/glsl/cloudCore.glsl.d.ts +24 -0
- package/dist/shaders/glsl/cloudCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/cloudCore.glsl.js +348 -0
- package/dist/shaders/glsl/landscapeCore.glsl.d.ts +49 -0
- package/dist/shaders/glsl/landscapeCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/landscapeCore.glsl.js +518 -0
- package/dist/shaders/glsl/noiseBake.glsl.d.ts +30 -0
- package/dist/shaders/glsl/noiseBake.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/noiseBake.glsl.js +164 -0
- package/dist/shaders/glsl/oceanCore.glsl.d.ts +52 -0
- package/dist/shaders/glsl/oceanCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/oceanCore.glsl.js +421 -0
- package/dist/shaders/glsl/terrainCore.glsl.d.ts +78 -0
- package/dist/shaders/glsl/terrainCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/terrainCore.glsl.js +625 -0
- package/dist/shaders/landscape/LandscapeMaterial.d.ts +73 -0
- package/dist/shaders/landscape/LandscapeMaterial.d.ts.map +1 -0
- package/dist/shaders/landscape/LandscapeMaterial.js +136 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts +57 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts.map +1 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.js +268 -0
- package/dist/shaders/terrain/TerrainMaterial.d.ts +80 -0
- package/dist/shaders/terrain/TerrainMaterial.d.ts.map +1 -0
- package/dist/shaders/terrain/TerrainMaterial.js +291 -0
- package/dist/types/cloudConfigs.d.ts +244 -0
- package/dist/types/cloudConfigs.d.ts.map +1 -0
- package/dist/types/cloudConfigs.js +282 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +4 -1
- package/dist/types/landscapeConfigs.d.ts +218 -0
- package/dist/types/landscapeConfigs.d.ts.map +1 -0
- package/dist/types/landscapeConfigs.js +256 -0
- package/dist/types/oceanConfigs.d.ts +290 -0
- package/dist/types/oceanConfigs.d.ts.map +1 -0
- package/dist/types/oceanConfigs.js +380 -0
- package/dist/types/terrainConfigs.d.ts +251 -0
- package/dist/types/terrainConfigs.d.ts.map +1 -0
- package/dist/types/terrainConfigs.js +292 -0
- package/dist/utils/cloudUniforms.d.ts +14 -0
- package/dist/utils/cloudUniforms.d.ts.map +1 -0
- package/dist/utils/cloudUniforms.js +122 -0
- package/dist/utils/frameRenderer.d.ts +33 -0
- package/dist/utils/frameRenderer.d.ts.map +1 -0
- package/dist/utils/frameRenderer.js +24 -0
- package/dist/utils/handleCloudsAnimations.d.ts +16 -0
- package/dist/utils/handleCloudsAnimations.d.ts.map +1 -0
- package/dist/utils/handleCloudsAnimations.js +64 -0
- package/dist/utils/landscapeGeometry.d.ts +61 -0
- package/dist/utils/landscapeGeometry.d.ts.map +1 -0
- package/dist/utils/landscapeGeometry.js +126 -0
- package/dist/utils/landscapeHeight.d.ts +44 -0
- package/dist/utils/landscapeHeight.d.ts.map +1 -0
- package/dist/utils/landscapeHeight.js +65 -0
- package/dist/utils/landscapeTextures.d.ts +94 -0
- package/dist/utils/landscapeTextures.d.ts.map +1 -0
- package/dist/utils/landscapeTextures.js +290 -0
- package/dist/utils/landscapeUniforms.d.ts +20 -0
- package/dist/utils/landscapeUniforms.d.ts.map +1 -0
- package/dist/utils/landscapeUniforms.js +61 -0
- package/dist/utils/oceanUniforms.d.ts +47 -0
- package/dist/utils/oceanUniforms.d.ts.map +1 -0
- package/dist/utils/oceanUniforms.js +216 -0
- package/dist/utils/rtin.d.ts +63 -0
- package/dist/utils/rtin.d.ts.map +1 -0
- package/dist/utils/rtin.js +202 -0
- package/dist/utils/terrainUniforms.d.ts +14 -0
- package/dist/utils/terrainUniforms.d.ts.map +1 -0
- package/dist/utils/terrainUniforms.js +196 -0
- package/package.json +2 -2
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { extend } from '@react-three/fiber';
|
|
3
|
+
import { skyLib } from '../glsl/cloudCore.glsl.js';
|
|
4
|
+
import { terrainFull } from '../glsl/terrainCore.glsl.js';
|
|
5
|
+
/**
|
|
6
|
+
* The terrain surface material. Used by all four landforms — they are one height
|
|
7
|
+
* field with different shaping operators, not four shaders.
|
|
8
|
+
*
|
|
9
|
+
* ## Why this is not drei's `shaderMaterial`
|
|
10
|
+
*
|
|
11
|
+
* Every other material in this package is built with `shaderMaterial()` from
|
|
12
|
+
* drei, and that is still the house convention. This one cannot be, and the
|
|
13
|
+
* reason is the requirement: terrain has to RECEIVE the scene's shadows, so an
|
|
14
|
+
* object standing on it casts onto it. That needs `lights: true`, which is what
|
|
15
|
+
* makes the renderer populate `directionalShadowMap`, `directionalShadowMatrix`
|
|
16
|
+
* and `directionalLightShadows`, and it needs those uniform blocks merged in from
|
|
17
|
+
* `UniformsLib`. drei's helper builds neither. Everything else about the
|
|
18
|
+
* convention is kept: `u_`-prefixed uniforms, a typed Uniforms interface, a
|
|
19
|
+
* defaults export, `/* glsl *\/` template strings, `extend()` and the
|
|
20
|
+
* `ThreeElements` augmentation, so it is consumed as a JSX element like the rest.
|
|
21
|
+
*
|
|
22
|
+
* ## Two shadow systems, deliberately
|
|
23
|
+
*
|
|
24
|
+
* - **Terrain on terrain** is an analytic march down the sun vector, in
|
|
25
|
+
* `terrainSunShadow`. A 2048 shadow map stretched across 25 km is 12 m per
|
|
26
|
+
* texel, so a ridge shadow would be a staircase; the march has no resolution to
|
|
27
|
+
* run out of and costs a fixed handful of coarse height samples.
|
|
28
|
+
* - **Objects on terrain** is three's ordinary shadow map, through
|
|
29
|
+
* `getShadowMask()`. That one is sized for objects and is correct for them.
|
|
30
|
+
*
|
|
31
|
+
* The terrain does not cast INTO that map. The sun's shadow camera is framed
|
|
32
|
+
* around the scene's objects, and pushing a 25 km surface through it would waste
|
|
33
|
+
* the whole map to produce a mountain shadow one texel wide. See the terrain doc
|
|
34
|
+
* for what that would take.
|
|
35
|
+
*/
|
|
36
|
+
const vertex = /* glsl */ `
|
|
37
|
+
#include <common>
|
|
38
|
+
#include <shadowmap_pars_vertex>
|
|
39
|
+
#include <fog_pars_vertex>
|
|
40
|
+
|
|
41
|
+
// three's <common> already supplies PI and saturate. cloudCommon must NOT be
|
|
42
|
+
// included beside it: redefining PI with a different literal is a compile error,
|
|
43
|
+
// which is why the sky helpers are pulled in without it.
|
|
44
|
+
${skyLib}
|
|
45
|
+
${terrainFull}
|
|
46
|
+
|
|
47
|
+
/** World size of this vertex's cell. Per-vertex rather than per-mesh so one
|
|
48
|
+
* material serves every clipmap ring. */
|
|
49
|
+
attribute float aCell;
|
|
50
|
+
/** 0 in the body of a ring, ramping to 1 across its outer band. */
|
|
51
|
+
attribute float aMorph;
|
|
52
|
+
/** Offset from this vertex to its parent-grid neighbour. Zero on even indices. */
|
|
53
|
+
attribute vec2 aCoarse;
|
|
54
|
+
|
|
55
|
+
varying vec3 vWorld;
|
|
56
|
+
varying float vCell;
|
|
57
|
+
varying float vDist;
|
|
58
|
+
varying float vShadow;
|
|
59
|
+
|
|
60
|
+
void main(){
|
|
61
|
+
// Geomorph. Across the outer band of each ring, odd vertices slide onto their
|
|
62
|
+
// even neighbours, so by the ring boundary the edge polyline is EXACTLY the
|
|
63
|
+
// coarser ring's edge polyline. That is what removes the T-junction cracks
|
|
64
|
+
// between levels, and it removes the pop at the same time: the transition is
|
|
65
|
+
// continuous rather than a swap.
|
|
66
|
+
vec2 local = position.xz + aCoarse * aMorph;
|
|
67
|
+
|
|
68
|
+
// The mesh carries translation only - the clipmap follows the camera and has no
|
|
69
|
+
// orientation of its own - so a local Y offset is a world Y offset, and the
|
|
70
|
+
// height field can be sampled directly in world XZ.
|
|
71
|
+
vec3 flatPos = vec3(local.x, 0.0, local.y);
|
|
72
|
+
vec2 wxz = (modelMatrix * vec4(flatPos, 1.0)).xz;
|
|
73
|
+
|
|
74
|
+
// The LOD cell morphs with the vertex. Level l's outer edge ends up sampling at
|
|
75
|
+
// 2 x its own cell, which is exactly level l+1's cell at its inner edge - so the
|
|
76
|
+
// two rings agree on the height at the seam. Without this the geomorph closes the
|
|
77
|
+
// T-junction and the octave cut-off reopens it as a one-pixel crack.
|
|
78
|
+
float cellLod = aCell * (1.0 + aMorph);
|
|
79
|
+
|
|
80
|
+
vec2 grad;
|
|
81
|
+
float h = terrainSample(wxz, cellLod, grad);
|
|
82
|
+
|
|
83
|
+
// The cast shadow, marched HERE rather than per fragment.
|
|
84
|
+
//
|
|
85
|
+
// This was the single most expensive thing in the renderer: up to twenty height
|
|
86
|
+
// evaluations on every shaded pixel. Per vertex it is two orders of magnitude
|
|
87
|
+
// cheaper and looks all but identical, because what it produces is a soft
|
|
88
|
+
// occlusion factor that interpolates cleanly - and because the terminator does
|
|
89
|
+
// not come from here. terrainLight takes N.L from the fragment's own analytic
|
|
90
|
+
// normal, so the lit/unlit edge stays per-pixel and only the cast shadow is
|
|
91
|
+
// interpolated. Coarse rings march at their own cell size, so distant rings run
|
|
92
|
+
// fewer octaves per step as well as fewer vertices.
|
|
93
|
+
vec3 wp = vec3(wxz.x, h, wxz.y);
|
|
94
|
+
float camDist = distance(wp, cameraPosition);
|
|
95
|
+
vShadow = terrainShadowAt(wp, terrainNormal(grad), cellLod, camDist);
|
|
96
|
+
|
|
97
|
+
// Planetary curvature, applied here and ONLY here. It is a view-relative bend,
|
|
98
|
+
// so folding it into the height field would make the ground move when the
|
|
99
|
+
// camera does - and the shadow march samples that same field.
|
|
100
|
+
vec2 fromCam = wxz - cameraPosition.xz;
|
|
101
|
+
float drop = u_curvature * dot(fromCam, fromCam);
|
|
102
|
+
|
|
103
|
+
vec3 transformed = vec3(local.x, h - drop, local.y);
|
|
104
|
+
|
|
105
|
+
// Up is close enough for the shadow-map normal bias; the real normal is
|
|
106
|
+
// computed per fragment, and this only nudges the depth lookup.
|
|
107
|
+
vec3 objectNormal = vec3(0.0, 1.0, 0.0);
|
|
108
|
+
vec3 transformedNormal = normalMatrix * objectNormal;
|
|
109
|
+
|
|
110
|
+
vWorld = vec3(wxz.x, h, wxz.y);
|
|
111
|
+
vCell = cellLod;
|
|
112
|
+
vDist = length(vec3(wxz.x, h - drop, wxz.y) - cameraPosition);
|
|
113
|
+
|
|
114
|
+
vec4 mvPosition = modelViewMatrix * vec4(transformed, 1.0);
|
|
115
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
116
|
+
|
|
117
|
+
#include <worldpos_vertex>
|
|
118
|
+
#include <shadowmap_vertex>
|
|
119
|
+
#include <fog_vertex>
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
const fragment = /* glsl */ `
|
|
123
|
+
#include <common>
|
|
124
|
+
#include <packing>
|
|
125
|
+
#include <fog_pars_fragment>
|
|
126
|
+
// lights_pars_begin is what declares the bool uniform receiveShadow, which
|
|
127
|
+
// shadowmask_pars_fragment reads. Include the shadow chunks without it and the
|
|
128
|
+
// fragment shader fails with 'undeclared identifier: receiveShadow' - the
|
|
129
|
+
// material then renders black with nothing but a console error to say why.
|
|
130
|
+
#include <lights_pars_begin>
|
|
131
|
+
#include <shadowmap_pars_fragment>
|
|
132
|
+
#include <shadowmask_pars_fragment>
|
|
133
|
+
|
|
134
|
+
${skyLib}
|
|
135
|
+
${terrainFull}
|
|
136
|
+
|
|
137
|
+
uniform float u_receiveShadows;
|
|
138
|
+
|
|
139
|
+
varying vec3 vWorld;
|
|
140
|
+
varying float vCell;
|
|
141
|
+
varying float vDist;
|
|
142
|
+
varying float vShadow;
|
|
143
|
+
|
|
144
|
+
void main(){
|
|
145
|
+
vec3 viewDir = normalize(vWorld - cameraPosition);
|
|
146
|
+
|
|
147
|
+
// The shading footprint. Finer than the mesh cell, because a ridge 5 km out
|
|
148
|
+
// lands on a 256 m clipmap cell but still covers only a few pixels - clamping
|
|
149
|
+
// to vCell is what makes distant terrain read as a smooth dome however many
|
|
150
|
+
// octaves are configured. But not arbitrarily finer either: a pixel lands on
|
|
151
|
+
// the flat triangle, so the world XZ it reports is a point on that
|
|
152
|
+
// approximation rather than on the true surface, and shading a field far finer
|
|
153
|
+
// than the mesh turns that parallax error into chevrons along every triangle
|
|
154
|
+
// edge. A quarter of the mesh cell keeps most of the detail and stays inside
|
|
155
|
+
// the error the mesh already has.
|
|
156
|
+
float lod = max(max(u_cellSize, vCell * 0.25), vDist * 0.0015);
|
|
157
|
+
|
|
158
|
+
// ONE height evaluation. The gradient comes back with it, so the normal is free
|
|
159
|
+
// - a central difference would need four more, and this shader used to pay for
|
|
160
|
+
// them on every pixel.
|
|
161
|
+
vec2 grad;
|
|
162
|
+
float shadeHeight = terrainSample(vWorld.xz, lod, grad);
|
|
163
|
+
vec3 n = terrainNormal(grad);
|
|
164
|
+
n = terrainDetailNormal(n, vWorld, vDist);
|
|
165
|
+
|
|
166
|
+
// Shade against the analytically evaluated surface, not the interpolated mesh
|
|
167
|
+
// vertex. The mesh is a coarse approximation of this field and its height is
|
|
168
|
+
// piecewise linear, so splatting off it draws every threshold along triangle
|
|
169
|
+
// edges.
|
|
170
|
+
vec3 surface = vec3(vWorld.x, shadeHeight, vWorld.z);
|
|
171
|
+
|
|
172
|
+
// Slope as a fraction of vertical, not as 1 - n.y. The naive form is badly
|
|
173
|
+
// compressed at the angles that matter - a 30 degree hillside reads 0.13 and a
|
|
174
|
+
// 45 degree one 0.29 - so every slope threshold ends up crowded into the top of
|
|
175
|
+
// its range and rock never appears where it should. This way 0.5 IS 45 degrees.
|
|
176
|
+
float slope = acos(clamp(n.y, -1.0, 1.0)) * 0.6366197724;
|
|
177
|
+
float h01 = saturate((shadeHeight - u_seaLevel) / max(u_elevation, 1e-3));
|
|
178
|
+
|
|
179
|
+
vec3 albedo = terrainAlbedo(surface, h01, slope);
|
|
180
|
+
|
|
181
|
+
float selfShadow = mix(1.0, saturate(vShadow), saturate(u_sunShadow));
|
|
182
|
+
|
|
183
|
+
float sceneShadow = 1.0;
|
|
184
|
+
#ifdef USE_SHADOWMAP
|
|
185
|
+
sceneShadow = mix(1.0, getShadowMask(), u_receiveShadows);
|
|
186
|
+
#endif
|
|
187
|
+
|
|
188
|
+
vec3 col = terrainLight(albedo, n, viewDir, selfShadow, sceneShadow);
|
|
189
|
+
col = terrainAerial(col, viewDir, vDist, shadeHeight);
|
|
190
|
+
col *= u_exposure;
|
|
191
|
+
|
|
192
|
+
gl_FragColor = vec4(col, 1.0);
|
|
193
|
+
|
|
194
|
+
#include <tonemapping_fragment>
|
|
195
|
+
#include <colorspace_fragment>
|
|
196
|
+
#include <fog_fragment>
|
|
197
|
+
}
|
|
198
|
+
`;
|
|
199
|
+
/** Uniform-space defaults. Config units are converted by `applyTerrainUniforms`;
|
|
200
|
+
* these are only what the material holds before anything is applied. */
|
|
201
|
+
export const terrainMaterialDefaults = {
|
|
202
|
+
u_terrainType: 2,
|
|
203
|
+
u_elevation: 180,
|
|
204
|
+
u_seaLevel: 0,
|
|
205
|
+
u_baseScale: 1 / 2600,
|
|
206
|
+
u_octaves: 8,
|
|
207
|
+
u_lacunarity: 2.06,
|
|
208
|
+
u_gain: 0.46,
|
|
209
|
+
u_ridge: 0.05,
|
|
210
|
+
u_warpStrength: 0.35,
|
|
211
|
+
u_warpScale: 0.6,
|
|
212
|
+
u_erosion: 0.45,
|
|
213
|
+
u_terraces: 0,
|
|
214
|
+
u_terraceSharp: 0.6,
|
|
215
|
+
u_bearingDir: new THREE.Vector2(0.978, 0.208),
|
|
216
|
+
u_duneFreq: (2 * Math.PI) / 340,
|
|
217
|
+
u_duneAsym: 0.62,
|
|
218
|
+
u_plateau: 0,
|
|
219
|
+
u_valleyDepth: 0,
|
|
220
|
+
u_valleyWidth: 0.25,
|
|
221
|
+
u_cellSize: 2,
|
|
222
|
+
u_curvature: 1 / (2 * 6371000),
|
|
223
|
+
u_lowColor: new THREE.Color('#3f5326'),
|
|
224
|
+
u_midColor: new THREE.Color('#55663a'),
|
|
225
|
+
u_rockColor: new THREE.Color('#7a7266'),
|
|
226
|
+
u_peakColor: new THREE.Color('#8d9a6a'),
|
|
227
|
+
u_slopeRockStart: 0.5,
|
|
228
|
+
u_slopeRockEnd: 0.78,
|
|
229
|
+
u_peakLevel: 0.78,
|
|
230
|
+
u_peakBlend: 0.2,
|
|
231
|
+
u_peakSlopeFalloff: 1.4,
|
|
232
|
+
u_macroVariation: 0.3,
|
|
233
|
+
u_macroScale: 1 / 1400,
|
|
234
|
+
u_detailStrength: 0.5,
|
|
235
|
+
u_detailScale: 1 / 6,
|
|
236
|
+
u_detailFade: 1 / 900,
|
|
237
|
+
u_roughness: 0.9,
|
|
238
|
+
u_specular: 0.03,
|
|
239
|
+
u_ambient: 1,
|
|
240
|
+
u_bounce: 0.35,
|
|
241
|
+
u_sunShadow: 1,
|
|
242
|
+
u_shadowSoftness: 12,
|
|
243
|
+
u_shadowDistance: 5000,
|
|
244
|
+
u_fogDensity: 0.000028,
|
|
245
|
+
u_exposure: 1,
|
|
246
|
+
u_shadowSteps: 20,
|
|
247
|
+
u_receiveShadows: 1,
|
|
248
|
+
// Shared with the cloud materials, and set by the same applySunUniforms().
|
|
249
|
+
u_sunDir: new THREE.Vector3(0.35, 0.42, 0.84).normalize(),
|
|
250
|
+
u_sunColor: new THREE.Color(1, 1, 1),
|
|
251
|
+
// Set by applySunUniforms from useCloudSun, same as the clouds. Constant per
|
|
252
|
+
// frame, so the shader reads them instead of calling skyRadiance per pixel.
|
|
253
|
+
u_skyAmbient: new THREE.Color(0.6, 0.9, 1.6),
|
|
254
|
+
u_groundAmbient: new THREE.Color(0.45, 0.42, 0.37),
|
|
255
|
+
u_sunIntensity: 1,
|
|
256
|
+
u_turbidity: 2,
|
|
257
|
+
u_rayleigh: 1,
|
|
258
|
+
u_mieCoefficient: 0.005,
|
|
259
|
+
u_mieG: 0.76,
|
|
260
|
+
};
|
|
261
|
+
function buildUniforms() {
|
|
262
|
+
const own = {};
|
|
263
|
+
for (const [key, value] of Object.entries(terrainMaterialDefaults)) {
|
|
264
|
+
own[key] = { value };
|
|
265
|
+
}
|
|
266
|
+
return THREE.UniformsUtils.merge([
|
|
267
|
+
THREE.UniformsLib.lights,
|
|
268
|
+
THREE.UniformsLib.fog,
|
|
269
|
+
own,
|
|
270
|
+
]);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* `UniformsUtils.merge` clones by `Uniform.clone()`, which deep-copies Colors and
|
|
274
|
+
* Vectors but turns a plain object into a shallow copy — fine here, since every
|
|
275
|
+
* own uniform is a number, Color or Vector. The lights block must come first so
|
|
276
|
+
* a name collision would resolve to ours; there are none, because everything of
|
|
277
|
+
* ours is `u_`-prefixed.
|
|
278
|
+
*/
|
|
279
|
+
export class TerrainMaterial extends THREE.ShaderMaterial {
|
|
280
|
+
constructor() {
|
|
281
|
+
super({
|
|
282
|
+
uniforms: buildUniforms(),
|
|
283
|
+
vertexShader: vertex,
|
|
284
|
+
fragmentShader: fragment,
|
|
285
|
+
lights: true,
|
|
286
|
+
fog: true,
|
|
287
|
+
});
|
|
288
|
+
this.side = THREE.FrontSide;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
extend({ TerrainMaterial });
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config shapes for the volumetric cloud system that lives in this package.
|
|
3
|
+
*
|
|
4
|
+
* Declared locally rather than in `@3driseai/3drise-core`, alongside
|
|
5
|
+
* `gridConfigs.ts`, because the materials and the renderer are here and nothing
|
|
6
|
+
* outside the viewer needs to construct these by hand.
|
|
7
|
+
*
|
|
8
|
+
* A sky is a deck PLUS an optional ice layer, not one of four things — cirrus
|
|
9
|
+
* coexists with every other type in nature and in the renderer. So a cloud
|
|
10
|
+
* settings object carries two independent layer blocks.
|
|
11
|
+
*/
|
|
12
|
+
/** The three types the volumetric marcher renders. Cirrus has its own model. */
|
|
13
|
+
export type CloudDeckType = 'cumulus' | 'stratocumulus' | 'cumulonimbus';
|
|
14
|
+
/** Fields every deck shares, whatever its vertical profile. */
|
|
15
|
+
export interface CloudDeckSurfaceConfig {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
/** Fraction of sky the deck occupies. The threshold window slides and narrows,
|
|
18
|
+
* so 1.0 really is overcast rather than the ~0.5 a naive remap tops out at. */
|
|
19
|
+
coverage: number;
|
|
20
|
+
/** Multiplies the density field. Aim for optical depth 4-6 through a core;
|
|
21
|
+
* past ~10 the multi-scatter octaves stop lifting the interior and it muddies. */
|
|
22
|
+
density: number;
|
|
23
|
+
/** Blends the three archetypal vertical profiles: 0 stratus, 0.5 cumulus,
|
|
24
|
+
* 1 cumulonimbus. The weather map biases it +/-0.15 per cell, so one sky
|
|
25
|
+
* holds a spread of shapes rather than one repeated silhouette. */
|
|
26
|
+
profile: number;
|
|
27
|
+
/** Cloud base, in world units. */
|
|
28
|
+
baseAltitude: number;
|
|
29
|
+
/** Cloud top. Also sets the march's fine step, which is derived from depth
|
|
30
|
+
* rather than from ray length — halving the depth roughly halves the cost. */
|
|
31
|
+
topAltitude: number;
|
|
32
|
+
/** Size of the primary cauliflower lobes, in world units. */
|
|
33
|
+
featureSize: number;
|
|
34
|
+
/** Size of the erosion detail that breaks up edges. Below ~2x the march step
|
|
35
|
+
* this beats against the sampling and the far field speckles. */
|
|
36
|
+
detailSize: number;
|
|
37
|
+
/** How deeply the detail volume eats into the base shape. */
|
|
38
|
+
detailStrength: number;
|
|
39
|
+
/** Divergence-free warp on the erosion, strongest at the base where a cloud
|
|
40
|
+
* shears out into wisps. */
|
|
41
|
+
curlStrength: number;
|
|
42
|
+
/** Size of the coverage cells that decide where clouds are at all. Too large
|
|
43
|
+
* and a whole viewport sits inside one cell. */
|
|
44
|
+
weatherCellSize: number;
|
|
45
|
+
/** Downwind displacement per unit height — tilts the column so the top leads
|
|
46
|
+
* the base, as it does under real shear. */
|
|
47
|
+
shear: number;
|
|
48
|
+
/** Lateral coverage growth above 70% height. Gated on profile, so a
|
|
49
|
+
* fair-weather cumulus can never grow an anvil. */
|
|
50
|
+
anvil: number;
|
|
51
|
+
/** Drops scattering albedo toward the base. Large rain drops absorb far more
|
|
52
|
+
* than small droplets, which is why a storm base is charcoal while its top
|
|
53
|
+
* is white — extinction alone will not do it. */
|
|
54
|
+
precipitation: number;
|
|
55
|
+
/** Wind bearing in degrees. Drives advection, shear and the cirrus streak axis. */
|
|
56
|
+
windBearing: number;
|
|
57
|
+
windSpeed: number;
|
|
58
|
+
/** Vertical motion of the shape volume. Decoupling it from wind is what makes
|
|
59
|
+
* clouds boil rather than slide. */
|
|
60
|
+
rise: number;
|
|
61
|
+
/** Independent vertical motion of the erosion layer — the third timescale. */
|
|
62
|
+
churn: number;
|
|
63
|
+
/** Slow oscillation of the coverage threshold. Cells genuinely appear and
|
|
64
|
+
* dissipate rather than only drifting past. */
|
|
65
|
+
evolution: number;
|
|
66
|
+
/** Extinction coefficient, per world unit. Physically ~0.045 for cloud, but a
|
|
67
|
+
* 3-octave scattering approximation cannot carry that optical depth, so it is
|
|
68
|
+
* tuned down and density scaled up to match. */
|
|
69
|
+
extinction: number;
|
|
70
|
+
/** Anisotropy of the forward Henyey-Greenstein lobe. This is the silver lining. */
|
|
71
|
+
forwardLobe: number;
|
|
72
|
+
/** Anisotropy of the small backward lobe. The glow when the sun is behind you. */
|
|
73
|
+
backLobe: number;
|
|
74
|
+
/** Per-octave extinction / energy / anisotropy scale in the multiple-scattering
|
|
75
|
+
* approximation. Drop `msEnergy` to 0.15 and the cloud collapses to the flat
|
|
76
|
+
* black of a single-scatter implementation. */
|
|
77
|
+
msExtinction: number;
|
|
78
|
+
msEnergy: number;
|
|
79
|
+
msPhase: number;
|
|
80
|
+
/** Dark-edge term. Applied only when looking away from the sun, or it
|
|
81
|
+
* double-darkens the backlit rims that should be brightest. */
|
|
82
|
+
powder: number;
|
|
83
|
+
/** Extra forward-scatter boost near the sun disc, on top of the phase function. */
|
|
84
|
+
silverLining: number;
|
|
85
|
+
/** Weight of sky-above and ground-bounce fill. Too high and the cloud goes
|
|
86
|
+
* flat; too low and shadowed sides crush to black. */
|
|
87
|
+
ambient: number;
|
|
88
|
+
/** Rate at which distant cloud fades into the sky it is seen through. The main
|
|
89
|
+
* cue for how large the sky reads. */
|
|
90
|
+
aerialPerspective: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The deck, as the animation system sees it.
|
|
94
|
+
*
|
|
95
|
+
* `type` is 'clouds' — the OBJECT type — because that is the discriminant
|
|
96
|
+
* getAnimatableProperties() and detectAnimatableDomain() route on, exactly like
|
|
97
|
+
* light and rain configs. The meteorological model is `deckType`, which is what
|
|
98
|
+
* CloudsGenerator switches on. Collapsing the two onto one field would make the
|
|
99
|
+
* deck invisible to the keyframe and mouse-move panels.
|
|
100
|
+
*/
|
|
101
|
+
export type CloudDeckConfig = CloudDeckSurfaceConfig & {
|
|
102
|
+
type: 'clouds';
|
|
103
|
+
deckType: CloudDeckType;
|
|
104
|
+
/** Name of the preset the numbers came from, or '' once any of them is edited.
|
|
105
|
+
* Purely a UI bookmark — the renderer never reads it. */
|
|
106
|
+
preset?: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* High ice cloud. Not a volume: three samples through a thin slab, stretched hard
|
|
110
|
+
* along the shear vector, lit by a near-pure forward lobe.
|
|
111
|
+
*/
|
|
112
|
+
export interface CirrusLayerConfig {
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
altitude: number;
|
|
115
|
+
thickness: number;
|
|
116
|
+
coverage: number;
|
|
117
|
+
/** Calibrated so 1.0 gives vertical optical depth around 0.5 — cirrus you can
|
|
118
|
+
* see the sun through, which is the point. */
|
|
119
|
+
opticalDepth: number;
|
|
120
|
+
featureSize: number;
|
|
121
|
+
/** Compression along the wind axis. 1.0 gives round blobs; 0.1 gives the
|
|
122
|
+
* drawn-out fibratus streaks cirrus is recognised by. */
|
|
123
|
+
anisotropy: number;
|
|
124
|
+
windBearing: number;
|
|
125
|
+
windSpeed: number;
|
|
126
|
+
/** Refraction minimum of a 60-degree hexagonal ice prism, visible within a few
|
|
127
|
+
* degrees of 22 from the sun. The strongest single cue that this is ice. */
|
|
128
|
+
halo: number;
|
|
129
|
+
forwardLobe: number;
|
|
130
|
+
secondaryLobe: number;
|
|
131
|
+
ambient: number;
|
|
132
|
+
aerialPerspective: number;
|
|
133
|
+
/** Name of the preset the numbers came from, or '' once any of them is edited. */
|
|
134
|
+
preset?: string;
|
|
135
|
+
}
|
|
136
|
+
/** Cost knobs. Shared by both layers, since they share the pipeline. */
|
|
137
|
+
export interface CloudsQualityConfig {
|
|
138
|
+
/** Fraction of full resolution the march runs at. 0.5 is the sweet spot. */
|
|
139
|
+
resolutionScale: number;
|
|
140
|
+
/** History weight when the camera is still. Higher converges further, ghosts more. */
|
|
141
|
+
temporalBlend: number;
|
|
142
|
+
/** Sets the fine step as depth/steps*2. Empty space is skipped 2.8x coarser
|
|
143
|
+
* regardless, so this costs less than the number suggests. */
|
|
144
|
+
steps: number;
|
|
145
|
+
/** Samples toward the sun per shaded point, spread inside a cone so
|
|
146
|
+
* self-shadowing is soft rather than banded. */
|
|
147
|
+
lightSteps: number;
|
|
148
|
+
/** First shadow step as a fraction of cloud depth, growing 1.62x each sample.
|
|
149
|
+
* A fraction, not world units, so one value works for a shallow deck and a
|
|
150
|
+
* 9 km tower alike. */
|
|
151
|
+
lightStep: number;
|
|
152
|
+
/** Step size as a fraction of distance — the actual meaning of "constant
|
|
153
|
+
* screen-space error". A near-horizontal ray can span a hundred kilometres
|
|
154
|
+
* inside the deck; a fixed step exhausts the budget and the deck stops along a
|
|
155
|
+
* straight line short of the horizon. */
|
|
156
|
+
stepGrowth: number;
|
|
157
|
+
/** Hard cap on how far one ray marches. Aerial perspective should hide the
|
|
158
|
+
* cut-off before it is reached. */
|
|
159
|
+
maxSpan: number;
|
|
160
|
+
/** Distance over which high-frequency erosion fades out. Removes far-field
|
|
161
|
+
* speckle and buys back most of its own cost. */
|
|
162
|
+
detailFadeDistance: number;
|
|
163
|
+
/** 1/(2R). Bends the ray so the deck meets a real horizon instead of running to
|
|
164
|
+
* infinity as a flat slab would. Zero gives a flat deck. */
|
|
165
|
+
curvature: number;
|
|
166
|
+
exposure: number;
|
|
167
|
+
/** Set false when something downstream will tonemap instead. */
|
|
168
|
+
tonemap: boolean;
|
|
169
|
+
}
|
|
170
|
+
export declare const defaultCumulusConfig: CloudDeckConfig;
|
|
171
|
+
export declare const defaultStratocumulusConfig: CloudDeckConfig;
|
|
172
|
+
export declare const defaultCumulonimbusConfig: CloudDeckConfig;
|
|
173
|
+
export declare const defaultCirrusConfig: CirrusLayerConfig;
|
|
174
|
+
export declare const defaultCloudsQuality: CloudsQualityConfig;
|
|
175
|
+
/** Per-type deck defaults, for the controller's type switcher. */
|
|
176
|
+
export declare const CLOUD_DECK_DEFAULTS: Record<CloudDeckType, CloudDeckConfig>;
|
|
177
|
+
export type CloudPropertyGroup = 'shape' | 'animation' | 'scattering' | 'lighting' | 'quality';
|
|
178
|
+
/**
|
|
179
|
+
* Everything the controller needs to build a row and everything the AI context
|
|
180
|
+
* builder needs to know what a knob does and where it is safe. The runtime never
|
|
181
|
+
* reads this — defaults live in the config objects above.
|
|
182
|
+
*/
|
|
183
|
+
export interface CloudPropertySchema {
|
|
184
|
+
key: string;
|
|
185
|
+
label: string;
|
|
186
|
+
group: CloudPropertyGroup;
|
|
187
|
+
min?: number;
|
|
188
|
+
max?: number;
|
|
189
|
+
step?: number;
|
|
190
|
+
unit?: string;
|
|
191
|
+
description: string;
|
|
192
|
+
advanced?: boolean;
|
|
193
|
+
/** Only show for these deck types. Absent means all. */
|
|
194
|
+
types?: CloudDeckType[];
|
|
195
|
+
}
|
|
196
|
+
export declare const CLOUD_DECK_SCHEMA: CloudPropertySchema[];
|
|
197
|
+
export declare const CIRRUS_SCHEMA: CloudPropertySchema[];
|
|
198
|
+
export declare const CLOUD_QUALITY_SCHEMA: CloudPropertySchema[];
|
|
199
|
+
import type { ObjectAnimations, MouseMoveInteractions } from '@3driseai/3drise-core';
|
|
200
|
+
/**
|
|
201
|
+
* A sky, as stored. Two independent layers, because that is what a sky is:
|
|
202
|
+
* a deck, and an ice layer that coexists with any deck.
|
|
203
|
+
*
|
|
204
|
+
* There is deliberately no `meshSettings` and no `materialSettings`. A layer has
|
|
205
|
+
* no transform — altitude and thickness are config, not position — and its
|
|
206
|
+
* material is not swappable, so the Transform and Material tabs do not apply.
|
|
207
|
+
* `animations` and `mouseMove` reuse the existing `clouds` domain, so
|
|
208
|
+
* AminationsPanel and MouseMoveManagerPanel work unchanged.
|
|
209
|
+
*/
|
|
210
|
+
export interface VolumetricCloudsSettings {
|
|
211
|
+
id: string;
|
|
212
|
+
type: 'clouds';
|
|
213
|
+
/** The convective / stratiform deck. Named `config` because that is where the
|
|
214
|
+
* animation and mouse-move systems look for an object's animatable domain. */
|
|
215
|
+
config: CloudDeckConfig;
|
|
216
|
+
/** High ice layer. Independent — it sits above whatever the deck is doing. */
|
|
217
|
+
cirrus: CirrusLayerConfig;
|
|
218
|
+
quality: CloudsQualityConfig;
|
|
219
|
+
/** Per-domain keyframe animations; the `clouds` domain drives deck properties. */
|
|
220
|
+
animations?: ObjectAnimations;
|
|
221
|
+
/** Per-domain mouse-move interactions; same `clouds` domain. */
|
|
222
|
+
mouseMove?: MouseMoveInteractions;
|
|
223
|
+
}
|
|
224
|
+
export declare const defaultVolumetricCloudsSettings: VolumetricCloudsSettings;
|
|
225
|
+
/**
|
|
226
|
+
* Deck properties the `clouds` animation and mouse-move domains may target.
|
|
227
|
+
* Everything here is a scalar that can be interpolated per frame without
|
|
228
|
+
* rebuilding anything — altitudes and feature sizes are deliberately excluded,
|
|
229
|
+
* since changing them mid-animation restretches the whole density field.
|
|
230
|
+
*/
|
|
231
|
+
export declare const CLOUD_ANIMATABLE_PROPERTIES: readonly ["coverage", "density", "profile", "detailStrength", "curlStrength", "shear", "anvil", "precipitation", "windBearing", "windSpeed", "rise", "churn", "evolution", "extinction", "powder", "silverLining", "ambient"];
|
|
232
|
+
export type CloudAnimatableProperty = (typeof CLOUD_ANIMATABLE_PROPERTIES)[number];
|
|
233
|
+
/** Deck block merged over its type's defaults. Returns null when there is no deck
|
|
234
|
+
* to render — including the retired flat CloudsSettings shape, which has no
|
|
235
|
+
* `config` and should draw nothing rather than half a sky. */
|
|
236
|
+
export declare function normalizeCloudDeck(raw: unknown): CloudDeckConfig | null;
|
|
237
|
+
/** Cirrus block merged over its defaults, or null when the scene has no cirrus
|
|
238
|
+
* block at all. Null rather than the defaults, because `defaultCirrusConfig` is
|
|
239
|
+
* enabled: a project saved before this layer existed must not gain an ice sheet
|
|
240
|
+
* it was never authored with. A block that exists but omits `enabled` is a
|
|
241
|
+
* deliberate one and takes the default. */
|
|
242
|
+
export declare function normalizeCirrus(raw: unknown): CirrusLayerConfig | null;
|
|
243
|
+
export declare function normalizeCloudQuality(raw: unknown): CloudsQualityConfig;
|
|
244
|
+
//# sourceMappingURL=cloudConfigs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudConfigs.d.ts","sourceRoot":"","sources":["../../src/types/cloudConfigs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,gFAAgF;AAChF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,cAAc,CAAC;AAEzE,+DAA+D;AAC/D,MAAM,WAAW,sBAAsB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB;oFACgF;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB;uFACmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB;;wEAEoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB;mFAC+E;IAC/E,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IAC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