bruce-cesium 7.3.6 → 7.3.7
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/bruce-cesium.es5.js +307 -5
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +305 -3
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/displaced-surface-primitive.js +270 -1
- package/dist/lib/rendering/displaced-surface-primitive.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine-polygon.js +27 -0
- package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -1
- package/dist/lib/utils/cesium-entity-styler.js +6 -0
- package/dist/lib/utils/cesium-entity-styler.js.map +1 -1
- package/dist/lib/utils/drawing-utils.js +1 -1
- package/dist/lib/utils/drawing-utils.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/displaced-surface-primitive.d.ts +29 -0
- package/dist/types/rendering/entity-render-engine-polygon.d.ts +6 -0
- package/dist/types/utils/cesium-entity-styler.d.ts +3 -0
- package/package.json +2 -2
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -400,7 +400,7 @@
|
|
|
400
400
|
function EnsurePosHeight(params) {
|
|
401
401
|
let { pos3d, viewer, desiredHeightRef, heightRef } = params;
|
|
402
402
|
const carto = BModels.Cartes.ValidateCartes3(pos3d) ? Cesium.Cartographic.fromCartesian(pos3d) : null;
|
|
403
|
-
if (!
|
|
403
|
+
if (!carto) {
|
|
404
404
|
return pos3d;
|
|
405
405
|
}
|
|
406
406
|
if (heightRef == null) {
|
|
@@ -3339,6 +3339,12 @@
|
|
|
3339
3339
|
}
|
|
3340
3340
|
}
|
|
3341
3341
|
CesiumEntityStyler.Refresh = Refresh;
|
|
3342
|
+
// Read the unselected colour even while a selection animation is running.
|
|
3343
|
+
function GetDefaultColor(viewer, graphic) {
|
|
3344
|
+
var _a;
|
|
3345
|
+
return (_a = getColor$1(viewer, "default", graphic)) === null || _a === void 0 ? void 0 : _a.clone();
|
|
3346
|
+
}
|
|
3347
|
+
CesiumEntityStyler.GetDefaultColor = GetDefaultColor;
|
|
3342
3348
|
function BakeDefaultColor(params) {
|
|
3343
3349
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3344
3350
|
let { viewer, entity, override, colors, refresh } = params;
|
|
@@ -43466,6 +43472,44 @@
|
|
|
43466
43472
|
const MASK_TEXTURE_MAX_SIDE = 1024;
|
|
43467
43473
|
// Stands in for "no floor" and "no clearance", far below anything the sheet can reach.
|
|
43468
43474
|
const NO_LIMIT_METRES = -1e6;
|
|
43475
|
+
// Ripple layers to cycle across the field's own repeat.
|
|
43476
|
+
const WATER_WAVES = [
|
|
43477
|
+
{ x: 2, y: 1, amplitude: 6.4 },
|
|
43478
|
+
{ x: 1, y: 4, amplitude: 3.9 },
|
|
43479
|
+
{ x: -6, y: 4, amplitude: 2.5 },
|
|
43480
|
+
{ x: 9, y: -9, amplitude: 1.6 },
|
|
43481
|
+
{ x: -14, y: 18, amplitude: 1.0 },
|
|
43482
|
+
{ x: 38, y: 15, amplitude: 0.63 },
|
|
43483
|
+
{ x: -30, y: 68, amplitude: 0.39 },
|
|
43484
|
+
{ x: 120, y: 57, amplitude: 0.245 }
|
|
43485
|
+
];
|
|
43486
|
+
const waveCycles = (wave) => Math.hypot(wave.x, wave.y);
|
|
43487
|
+
// Which layer the wavelength setting names. The ladder runs either side of it.
|
|
43488
|
+
const WATER_BASE_WAVE = 4;
|
|
43489
|
+
// How many metres the field repeats over, as a multiple of the settings' own wavelength.
|
|
43490
|
+
const WATER_PERIOD_IN_WAVELENGTHS = waveCycles(WATER_WAVES[WATER_BASE_WAVE]);
|
|
43491
|
+
/*
|
|
43492
|
+
* How much of the surface's total slope each layer carries, which is its amplitude against its
|
|
43493
|
+
* wave number rather than its amplitude alone.
|
|
43494
|
+
*/
|
|
43495
|
+
const WATER_WAVE_SLOPES = (() => {
|
|
43496
|
+
const raw = WATER_WAVES.map((wave) => wave.amplitude * waveCycles(wave));
|
|
43497
|
+
const total = raw.reduce((sum, value) => sum + value, 0);
|
|
43498
|
+
return raw.map((value) => value / total);
|
|
43499
|
+
})();
|
|
43500
|
+
// Screen pixels a ripple layer needs to span before it counts at all, and before it counts in
|
|
43501
|
+
// full. Below the first it is finer than the pixel grid and turns into moire that crawls as the
|
|
43502
|
+
// camera moves; the gap between the two is there so a layer leaves gradually rather than
|
|
43503
|
+
// stepping out and leaving a visible change in the surface.
|
|
43504
|
+
const WATER_MIN_PIXELS_PER_WAVE = 6;
|
|
43505
|
+
const WATER_FULL_PIXELS_PER_WAVE = 16;
|
|
43506
|
+
const DEFAULT_WATER_WAVELENGTH_METRES = 26;
|
|
43507
|
+
const DEFAULT_WATER_AMPLITUDE_METRES = 0.11;
|
|
43508
|
+
const DEFAULT_WATER_SPEED_METRES_PER_SECOND = 0.6;
|
|
43509
|
+
const DEFAULT_WATER_REFLECTIVITY = 0.72;
|
|
43510
|
+
const DEFAULT_WATER_GLOSSINESS = 140;
|
|
43511
|
+
const DEFAULT_WATER_SUN_INTENSITY = 1;
|
|
43512
|
+
const DEFAULT_WATER_SKY_COLOR = { red: 150, green: 186, blue: 214, alpha: 1 };
|
|
43469
43513
|
const GROUND_MIN_METRES = -1000;
|
|
43470
43514
|
const GROUND_MAX_METRES = 9000;
|
|
43471
43515
|
const DEFAULT_LOW_COLOR = { red: 255, green: 255, blue: 255, alpha: 0.12 };
|
|
@@ -43501,10 +43545,17 @@ uniform vec2 u_maskGroundSize;
|
|
|
43501
43545
|
uniform vec4 u_extentDegrees;
|
|
43502
43546
|
uniform vec4 u_maskGroundDegrees;
|
|
43503
43547
|
uniform float u_coverageCutoffVertex;
|
|
43548
|
+
uniform vec2 u_extentMetres;
|
|
43549
|
+
uniform vec2 u_waveOrigin;
|
|
43504
43550
|
|
|
43505
43551
|
out vec2 v_st;
|
|
43506
43552
|
out float v_value;
|
|
43507
43553
|
out float v_coverage;
|
|
43554
|
+
out vec3 v_positionEC;
|
|
43555
|
+
out vec3 v_eastEC;
|
|
43556
|
+
out vec3 v_northEC;
|
|
43557
|
+
out vec3 v_upEC;
|
|
43558
|
+
out vec2 v_waveMetres;
|
|
43508
43559
|
|
|
43509
43560
|
float decodeGround(vec2 uv) {
|
|
43510
43561
|
// Channels arrive normalised to 0..1, so they go back to bytes before being reassembled.
|
|
@@ -43623,6 +43674,25 @@ void main() {
|
|
|
43623
43674
|
// Added to the LOW half of the encoded position: a metre-scale offset added to the high half
|
|
43624
43675
|
// would be lost to float32 rounding at an earth radius.
|
|
43625
43676
|
vec4 p = czm_translateRelativeToEye(position3DHigh, position3DLow + normal * displacement);
|
|
43677
|
+
|
|
43678
|
+
// The local frame at this vertex so a shading normal built in east/north/up meters can be turned into something usable.
|
|
43679
|
+
v_upEC = czm_normal * normal;
|
|
43680
|
+
vec3 east = normalize(cross(vec3(0.0, 0.0, 1.0), normal));
|
|
43681
|
+
v_eastEC = czm_normal * east;
|
|
43682
|
+
v_northEC = czm_normal * cross(normal, east);
|
|
43683
|
+
v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
|
|
43684
|
+
|
|
43685
|
+
/*
|
|
43686
|
+
* Where this vertex sits in the ripple field, in metres from an origin that follows the camera.
|
|
43687
|
+
*
|
|
43688
|
+
* Subtracted here rather than in the fragment shader because the position it is subtracted from
|
|
43689
|
+
* spans the whole archive, which over a sound is tens of kilometres. A wave number times that
|
|
43690
|
+
* is thousands of radians, and no fragment shader that may only have mediump can step through a
|
|
43691
|
+
* cosine at that magnitude: the ripples come out as a flat surface, which is what a first cut of
|
|
43692
|
+
* this did. What crosses into the fragment shader is a small number the camera is standing in.
|
|
43693
|
+
*/
|
|
43694
|
+
v_waveMetres = st * u_extentMetres - u_waveOrigin;
|
|
43695
|
+
|
|
43626
43696
|
gl_Position = czm_modelViewProjectionRelativeToEye * p;
|
|
43627
43697
|
}
|
|
43628
43698
|
`;
|
|
@@ -43635,10 +43705,27 @@ uniform float u_valuePacked;
|
|
|
43635
43705
|
uniform float u_valueRange;
|
|
43636
43706
|
uniform float u_exaggeration;
|
|
43637
43707
|
uniform float u_metresPerTexel;
|
|
43708
|
+
uniform float u_waterOn;
|
|
43709
|
+
uniform float u_waterWavelength;
|
|
43710
|
+
uniform float u_waterAmplitude;
|
|
43711
|
+
uniform float u_waterReflectivity;
|
|
43712
|
+
uniform float u_waterGloss;
|
|
43713
|
+
uniform float u_waterSun;
|
|
43714
|
+
uniform vec3 u_waterSky;
|
|
43715
|
+
// One scrolled phase per ripple layer, wrapped into a turn on the CPU.
|
|
43716
|
+
uniform vec4 u_wavePhase;
|
|
43717
|
+
uniform vec4 u_wavePhaseB;
|
|
43718
|
+
// Metres the whole ripple field repeats over.
|
|
43719
|
+
uniform float u_wavePeriod;
|
|
43638
43720
|
|
|
43639
43721
|
in vec2 v_st;
|
|
43640
43722
|
in float v_value;
|
|
43641
43723
|
in float v_coverage;
|
|
43724
|
+
in vec3 v_positionEC;
|
|
43725
|
+
in vec3 v_eastEC;
|
|
43726
|
+
in vec3 v_northEC;
|
|
43727
|
+
in vec3 v_upEC;
|
|
43728
|
+
in vec2 v_waveMetres;
|
|
43642
43729
|
|
|
43643
43730
|
/*
|
|
43644
43731
|
* Scaled per channel for the same reason the vertex shader's decode is: reassembling the pair reaches
|
|
@@ -43650,6 +43737,82 @@ float valueAt(vec2 uv) {
|
|
|
43650
43737
|
return mix(texel.r, packed16, u_valuePacked);
|
|
43651
43738
|
}
|
|
43652
43739
|
|
|
43740
|
+
/*
|
|
43741
|
+
* Slope of the ripple field at a point, in metres of rise per metre travelled.
|
|
43742
|
+
*/
|
|
43743
|
+
vec2 rippleSlope(vec2 metres, float metresPerPixel, out float detail) {
|
|
43744
|
+
vec2 slope = vec2(0.0);
|
|
43745
|
+
detail = 0.0;
|
|
43746
|
+
float amplitude = u_waterAmplitude * 0.5;
|
|
43747
|
+
${WATER_WAVES.map((wave, index) => {
|
|
43748
|
+
const cycles = waveCycles(wave);
|
|
43749
|
+
return `
|
|
43750
|
+
{
|
|
43751
|
+
vec2 lattice = vec2(${wave.x.toFixed(1)}, ${wave.y.toFixed(1)});
|
|
43752
|
+
float k = 6.2831853 * ${cycles.toFixed(4)} / u_wavePeriod;
|
|
43753
|
+
float pixels = u_wavePeriod / ${cycles.toFixed(4)} / max(metresPerPixel, 1e-6);
|
|
43754
|
+
float weight = smoothstep(${WATER_MIN_PIXELS_PER_WAVE.toFixed(1)},
|
|
43755
|
+
${WATER_FULL_PIXELS_PER_WAVE.toFixed(1)}, pixels);
|
|
43756
|
+
vec2 direction = lattice / ${cycles.toFixed(4)};
|
|
43757
|
+
float phase = 6.2831853 * dot(lattice, metres) / u_wavePeriod
|
|
43758
|
+
+ ${index < 4 ? `u_wavePhase[${index}]` : `u_wavePhaseB[${index - 4}]`};
|
|
43759
|
+
slope += direction * (amplitude * ${wave.amplitude.toFixed(4)} * k * cos(phase) * weight);
|
|
43760
|
+
detail += ${WATER_WAVE_SLOPES[index].toFixed(5)} * weight;
|
|
43761
|
+
}`;
|
|
43762
|
+
}).join("")}
|
|
43763
|
+
return slope;
|
|
43764
|
+
}
|
|
43765
|
+
|
|
43766
|
+
/*
|
|
43767
|
+
* The sheet shaded as a water surface: a flat body colour seen through a sun glint and a grazing
|
|
43768
|
+
* sky reflection, with the ripple field standing in for a geometry it is far too fine to carry.
|
|
43769
|
+
*/
|
|
43770
|
+
vec4 water(vec3 relief, vec4 color) {
|
|
43771
|
+
float metresPerPixel = czm_metersPerPixel(vec4(v_positionEC, 1.0));
|
|
43772
|
+
float detail;
|
|
43773
|
+
vec2 slope = rippleSlope(v_waveMetres, metresPerPixel, detail);
|
|
43774
|
+
|
|
43775
|
+
// relief arrives normalised, so its horizontal part over its vertical part is the slope it means.
|
|
43776
|
+
vec2 reliefSlope = relief.xy / max(relief.z, 1e-3);
|
|
43777
|
+
vec3 local = normalize(vec3(-(slope + reliefSlope), 1.0));
|
|
43778
|
+
vec3 normalEC = normalize(local.x * v_eastEC + local.y * v_northEC + local.z * v_upEC);
|
|
43779
|
+
|
|
43780
|
+
vec3 view = normalize(-v_positionEC);
|
|
43781
|
+
// Drawn with culling off, so the underside of the sheet arrives with its normal pointing away.
|
|
43782
|
+
normalEC = dot(normalEC, view) < 0.0 ? -normalEC : normalEC;
|
|
43783
|
+
vec3 sun = normalize(czm_sunDirectionEC);
|
|
43784
|
+
|
|
43785
|
+
// Water at a grazing angle is almost a mirror and water looked straight down is almost clear.
|
|
43786
|
+
// That split is the single strongest cue that a blue surface is wet, more than any ripple is.
|
|
43787
|
+
float fresnel = u_waterReflectivity
|
|
43788
|
+
* (0.02 + 0.98 * pow(1.0 - clamp(dot(normalEC, view), 0.0, 1.0), 5.0));
|
|
43789
|
+
|
|
43790
|
+
// Softened by the roughness the shading has had to give up.
|
|
43791
|
+
fresnel *= mix(0.55, 1.0, detail);
|
|
43792
|
+
|
|
43793
|
+
// Where the ripples have faded out the surface is not smooth, it is rough below one pixel, so
|
|
43794
|
+
// the glint has to widen to cover what the normal no longer says.
|
|
43795
|
+
float gloss = mix(u_waterGloss * 0.12, u_waterGloss, detail);
|
|
43796
|
+
vec3 halfway = normalize(sun + view);
|
|
43797
|
+
// Weighted by the same reflectance as the sky, because a glint is a reflection too.
|
|
43798
|
+
float glint = pow(max(dot(normalEC, halfway), 0.0), gloss) * u_waterSun * fresnel;
|
|
43799
|
+
float lambert = clamp(dot(normalEC, sun), 0.0, 1.0);
|
|
43800
|
+
|
|
43801
|
+
vec3 body = color.rgb * (0.55 + 0.6 * lambert);
|
|
43802
|
+
vec3 lit = min(mix(body, u_waterSky, fresnel) + vec3(glint), vec3(1.0));
|
|
43803
|
+
|
|
43804
|
+
/*
|
|
43805
|
+
* The same fog the globe under it is already drawing with.
|
|
43806
|
+
*/
|
|
43807
|
+
lit = czm_fog(length(v_positionEC), lit, u_waterSky);
|
|
43808
|
+
|
|
43809
|
+
// A reflection seen through a half-transparent sheet is not a reflection, so the surface is
|
|
43810
|
+
// allowed to close up exactly where it is being reflective.
|
|
43811
|
+
float alpha = color.a * v_coverage;
|
|
43812
|
+
alpha = clamp(alpha + (1.0 - alpha) * (fresnel * 0.55 + glint), 0.0, 1.0);
|
|
43813
|
+
return vec4(lit, alpha);
|
|
43814
|
+
}
|
|
43815
|
+
|
|
43653
43816
|
void main() {
|
|
43654
43817
|
if (v_coverage < u_coverageCutoff) {
|
|
43655
43818
|
discard;
|
|
@@ -43670,6 +43833,12 @@ void main() {
|
|
|
43670
43833
|
float up = valueAt(v_st + vec2(0.0, u_texelSize.y));
|
|
43671
43834
|
float scale = u_valueRange * u_exaggeration;
|
|
43672
43835
|
vec3 n = normalize(vec3((left - right) * scale, (down - up) * scale, 2.0 * u_metresPerTexel));
|
|
43836
|
+
|
|
43837
|
+
if (u_waterOn > 0.5) {
|
|
43838
|
+
out_FragColor = water(n, color);
|
|
43839
|
+
return;
|
|
43840
|
+
}
|
|
43841
|
+
|
|
43673
43842
|
float lambert = clamp(dot(n, normalize(vec3(-0.5, -0.6, 0.62))), 0.0, 1.0);
|
|
43674
43843
|
color.rgb *= 0.45 + 0.9 * lambert;
|
|
43675
43844
|
|
|
@@ -44020,6 +44189,9 @@ void main() {
|
|
|
44020
44189
|
this.maskGroundBox = null;
|
|
44021
44190
|
this.maskGroundRequested = false;
|
|
44022
44191
|
this.maskGroundLevel = 0;
|
|
44192
|
+
this.water = null;
|
|
44193
|
+
this.waterStartMs = now();
|
|
44194
|
+
this.waveOrigin = new Cesium.Cartesian2(0, 0);
|
|
44023
44195
|
this.followGround = Boolean(options.followGround);
|
|
44024
44196
|
this.terrainProvider = options.terrainProvider || null;
|
|
44025
44197
|
this.extent = options.extent;
|
|
@@ -44035,6 +44207,23 @@ void main() {
|
|
|
44035
44207
|
this.maskFillValue = firstOpaqueStop(this.rampPixels);
|
|
44036
44208
|
this.tiles = buildTiles(hasCoverage);
|
|
44037
44209
|
this.SetGroundClearance(options.groundClearance || null);
|
|
44210
|
+
this.SetWater(options.water || null);
|
|
44211
|
+
}
|
|
44212
|
+
GetWater() {
|
|
44213
|
+
return this.water;
|
|
44214
|
+
}
|
|
44215
|
+
/**
|
|
44216
|
+
* Shades the sheet as water, or stops. Null goes back to the relief shading.
|
|
44217
|
+
*
|
|
44218
|
+
* Nothing is rebuilt: no mesh, no texture and no shader, since the water path is a branch in
|
|
44219
|
+
* the fragment shader the whole scene already carries. So this is cheap enough to drive from
|
|
44220
|
+
* a control the user is dragging.
|
|
44221
|
+
*/
|
|
44222
|
+
SetWater(water) {
|
|
44223
|
+
if (water && !this.water) {
|
|
44224
|
+
this.waterStartMs = now();
|
|
44225
|
+
}
|
|
44226
|
+
this.water = water;
|
|
44038
44227
|
}
|
|
44039
44228
|
GetFollowsGround() {
|
|
44040
44229
|
return this.followGround;
|
|
@@ -44205,6 +44394,12 @@ void main() {
|
|
|
44205
44394
|
const mesh = this.ensureMesh(context, tile, tile.tier);
|
|
44206
44395
|
frameState.commandList.push(this.commandFor(context, tile, mesh));
|
|
44207
44396
|
}
|
|
44397
|
+
if (this.water) {
|
|
44398
|
+
this.updateWaveOrigin(frameState);
|
|
44399
|
+
if (frameState.afterRender) {
|
|
44400
|
+
frameState.afterRender.push(() => true);
|
|
44401
|
+
}
|
|
44402
|
+
}
|
|
44208
44403
|
}
|
|
44209
44404
|
isDestroyed() {
|
|
44210
44405
|
return this.destroyed;
|
|
@@ -44416,6 +44611,60 @@ void main() {
|
|
|
44416
44611
|
})
|
|
44417
44612
|
});
|
|
44418
44613
|
}
|
|
44614
|
+
/*
|
|
44615
|
+
* Metres the extent spans west to east and north to south, which is what turns the shader's
|
|
44616
|
+
* 0..1 surface coordinate into the real distance the ripple wavelength is measured in.
|
|
44617
|
+
*/
|
|
44618
|
+
extentMetres() {
|
|
44619
|
+
const southWest = Cesium.Cartesian3.fromDegrees(this.extent.West, this.extent.South, 0);
|
|
44620
|
+
const southEast = Cesium.Cartesian3.fromDegrees(this.extent.East, this.extent.South, 0);
|
|
44621
|
+
const northWest = Cesium.Cartesian3.fromDegrees(this.extent.West, this.extent.North, 0);
|
|
44622
|
+
return new Cesium.Cartesian2(Math.max(1, Cesium.Cartesian3.distance(southWest, southEast)), Math.max(1, Cesium.Cartesian3.distance(southWest, northWest)));
|
|
44623
|
+
}
|
|
44624
|
+
/*
|
|
44625
|
+
* Where each ripple layer has scrolled to, wrapped into one turn.
|
|
44626
|
+
*/
|
|
44627
|
+
wavePhase(from) {
|
|
44628
|
+
var _a;
|
|
44629
|
+
const water = this.water;
|
|
44630
|
+
if (!water) {
|
|
44631
|
+
return new Cesium.Cartesian4(0, 0, 0, 0);
|
|
44632
|
+
}
|
|
44633
|
+
const speed = (_a = water.speed) !== null && _a !== void 0 ? _a : DEFAULT_WATER_SPEED_METRES_PER_SECOND;
|
|
44634
|
+
const period = this.wavePeriod();
|
|
44635
|
+
const seconds = (now() - this.waterStartMs) / 1000;
|
|
44636
|
+
const base = waveCycles(WATER_WAVES[WATER_BASE_WAVE]);
|
|
44637
|
+
const phases = WATER_WAVES.slice(from, from + 4).map((wave) => {
|
|
44638
|
+
const cycles = waveCycles(wave);
|
|
44639
|
+
const waveNumber = 2 * Math.PI * cycles / period;
|
|
44640
|
+
const travels = Math.sqrt(base / cycles);
|
|
44641
|
+
const travelled = seconds * speed * travels * waveNumber;
|
|
44642
|
+
return travelled % (2 * Math.PI);
|
|
44643
|
+
});
|
|
44644
|
+
return new Cesium.Cartesian4(phases[0] || 0, phases[1] || 0, phases[2] || 0, phases[3] || 0);
|
|
44645
|
+
}
|
|
44646
|
+
wavePeriod() {
|
|
44647
|
+
const wavelength = (this.water && this.water.wavelength) || DEFAULT_WATER_WAVELENGTH_METRES;
|
|
44648
|
+
return wavelength * WATER_PERIOD_IN_WAVELENGTHS;
|
|
44649
|
+
}
|
|
44650
|
+
/*
|
|
44651
|
+
* The point the ripple phase is measured from, kept near the camera and snapped to a whole
|
|
44652
|
+
* number of periods in each direction.
|
|
44653
|
+
*/
|
|
44654
|
+
updateWaveOrigin(frameState) {
|
|
44655
|
+
const period = this.wavePeriod();
|
|
44656
|
+
const carto = Cesium.Cartographic.fromCartesian(frameState.camera.positionWC);
|
|
44657
|
+
if (!carto) {
|
|
44658
|
+
return;
|
|
44659
|
+
}
|
|
44660
|
+
const metres = this.extentMetres();
|
|
44661
|
+
const longitude = Cesium.Math.toDegrees(carto.longitude);
|
|
44662
|
+
const latitude = Cesium.Math.toDegrees(carto.latitude);
|
|
44663
|
+
const u = (longitude - this.extent.West) / (this.extent.East - this.extent.West);
|
|
44664
|
+
// North is v zero, the way the vertex shader places the surface.
|
|
44665
|
+
const v = (this.extent.North - latitude) / (this.extent.North - this.extent.South);
|
|
44666
|
+
this.waveOrigin = new Cesium.Cartesian2(Math.floor(u * metres.x / period) * period, Math.floor(v * metres.y / period) * period);
|
|
44667
|
+
}
|
|
44419
44668
|
/*
|
|
44420
44669
|
* Ground distance between neighbouring texels, so the shading normal is built from a real
|
|
44421
44670
|
* slope rather than a made up one.
|
|
@@ -44642,7 +44891,33 @@ void main() {
|
|
|
44642
44891
|
: 0,
|
|
44643
44892
|
u_coverageCutoff: () => COVERAGE_CUTOFF,
|
|
44644
44893
|
u_rampTexture: () => self.rampTexture,
|
|
44645
|
-
u_texelSize: () => new Cesium.Cartesian2(1 / self.source.width, 1 / self.source.height)
|
|
44894
|
+
u_texelSize: () => new Cesium.Cartesian2(1 / self.source.width, 1 / self.source.height),
|
|
44895
|
+
u_waterOn: () => (self.water ? 1 : 0),
|
|
44896
|
+
u_waterWavelength: () => (self.water && self.water.wavelength)
|
|
44897
|
+
|| DEFAULT_WATER_WAVELENGTH_METRES,
|
|
44898
|
+
u_waterAmplitude: () => {
|
|
44899
|
+
var _a;
|
|
44900
|
+
return (_a = (self.water && self.water.amplitude)) !== null && _a !== void 0 ? _a : DEFAULT_WATER_AMPLITUDE_METRES;
|
|
44901
|
+
},
|
|
44902
|
+
u_waterReflectivity: () => {
|
|
44903
|
+
var _a;
|
|
44904
|
+
return (_a = (self.water && self.water.reflectivity)) !== null && _a !== void 0 ? _a : DEFAULT_WATER_REFLECTIVITY;
|
|
44905
|
+
},
|
|
44906
|
+
u_waterGloss: () => (self.water && self.water.glossiness)
|
|
44907
|
+
|| DEFAULT_WATER_GLOSSINESS,
|
|
44908
|
+
u_waterSun: () => {
|
|
44909
|
+
var _a;
|
|
44910
|
+
return (_a = (self.water && self.water.sunIntensity)) !== null && _a !== void 0 ? _a : DEFAULT_WATER_SUN_INTENSITY;
|
|
44911
|
+
},
|
|
44912
|
+
u_waterSky: () => {
|
|
44913
|
+
const sky = (self.water && self.water.skyColor) || DEFAULT_WATER_SKY_COLOR;
|
|
44914
|
+
return new Cesium.Cartesian3(sky.red / 255, sky.green / 255, sky.blue / 255);
|
|
44915
|
+
},
|
|
44916
|
+
u_wavePhase: () => self.wavePhase(0),
|
|
44917
|
+
u_wavePhaseB: () => self.wavePhase(4),
|
|
44918
|
+
u_wavePeriod: () => self.wavePeriod(),
|
|
44919
|
+
u_waveOrigin: () => self.waveOrigin,
|
|
44920
|
+
u_extentMetres: () => self.extentMetres()
|
|
44646
44921
|
}
|
|
44647
44922
|
});
|
|
44648
44923
|
}
|
|
@@ -45295,6 +45570,23 @@ void main() {
|
|
|
45295
45570
|
return touched;
|
|
45296
45571
|
}
|
|
45297
45572
|
EntityRenderEnginePolygon.SetGroundClearance = SetGroundClearance;
|
|
45573
|
+
/**
|
|
45574
|
+
* Shades every rendered polygon in a set as water rather than as a coloured surface.
|
|
45575
|
+
* @param cEntities
|
|
45576
|
+
* @param water Pass null to go back to the relief shading.
|
|
45577
|
+
*/
|
|
45578
|
+
function SetWater(cEntities, water) {
|
|
45579
|
+
let touched = 0;
|
|
45580
|
+
for (const cEntity of cEntities || []) {
|
|
45581
|
+
const surface = GetDisplacedSurface(cEntity);
|
|
45582
|
+
if (surface) {
|
|
45583
|
+
surface.SetWater(water);
|
|
45584
|
+
touched++;
|
|
45585
|
+
}
|
|
45586
|
+
}
|
|
45587
|
+
return touched;
|
|
45588
|
+
}
|
|
45589
|
+
EntityRenderEnginePolygon.SetWater = SetWater;
|
|
45298
45590
|
/**
|
|
45299
45591
|
* Disposes a cEntity's TextureFrameSeriesAnimator.Animator (if any).
|
|
45300
45592
|
*/
|
|
@@ -45452,6 +45744,7 @@ void main() {
|
|
|
45452
45744
|
if (reusable && existingSurface.GetFollowsGround() === placement.followGround) {
|
|
45453
45745
|
existingSurface.SetBaseHeight(placement.baseHeight);
|
|
45454
45746
|
existingSurface.SetExaggeration(exaggerationFor(style));
|
|
45747
|
+
existingSurface.SetWater(waterFor(style));
|
|
45455
45748
|
return;
|
|
45456
45749
|
}
|
|
45457
45750
|
disposeDisplacedSurface(cEntity, viewer);
|
|
@@ -45491,6 +45784,7 @@ void main() {
|
|
|
45491
45784
|
valueMax: extrusionArchive.metadata.ValueMax,
|
|
45492
45785
|
packedValue: exports.TextureFrameSeriesAnimator.IsPackedValue(extrusionArchive.metadata),
|
|
45493
45786
|
exaggeration: exaggerationFor(style),
|
|
45787
|
+
water: waterFor(style),
|
|
45494
45788
|
lowColor: mask ? BModels.Color.ColorFromStr(mask.minColor) : null,
|
|
45495
45789
|
highColor: mask ? BModels.Color.ColorFromStr(mask.maxColor) : null,
|
|
45496
45790
|
// Normalised the same way the animator normalises them, so the surface and the flat drape
|
|
@@ -45536,6 +45830,14 @@ void main() {
|
|
|
45536
45830
|
}
|
|
45537
45831
|
return 1;
|
|
45538
45832
|
}
|
|
45833
|
+
const WATER_EFFECT = "WATER";
|
|
45834
|
+
/*
|
|
45835
|
+
* The water settings a style asks a displaced surface for, or null for the plain relief shading.
|
|
45836
|
+
*/
|
|
45837
|
+
function waterFor(style) {
|
|
45838
|
+
var _a;
|
|
45839
|
+
return ((_a = style.effect) === null || _a === void 0 ? void 0 : _a.type) === WATER_EFFECT ? {} : null;
|
|
45840
|
+
}
|
|
45539
45841
|
/*
|
|
45540
45842
|
* The lon/lat bounding rectangle of a ring, which is the frame Cesium drapes an image material in.
|
|
45541
45843
|
*/
|
|
@@ -47393,7 +47695,7 @@ void main() {
|
|
|
47393
47695
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
47394
47696
|
})(exports.StyleUtils || (exports.StyleUtils = {}));
|
|
47395
47697
|
|
|
47396
|
-
const VERSION = "7.3.
|
|
47698
|
+
const VERSION = "7.3.7";
|
|
47397
47699
|
/**
|
|
47398
47700
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
47399
47701
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|