diff --git a/src/OceanScene.js b/src/OceanScene.js index 4e54a91..ab50182 100644 --- a/src/OceanScene.js +++ b/src/OceanScene.js @@ -877,13 +877,14 @@ export class OceanScene { waterNormals: waterNormals, sunDirection: new THREE.Vector3(), sunColor: 0xffffff, - waterColor: 0x001e0f, + waterColor: this.params.waterColor, distortionScale: 3.7, fog: true }); this.water.rotation.x = -Math.PI / 2; this.water.position.y = -0.15; + this.setWaterColor(this.params.waterColor); this.scene.add(this.water); } @@ -1101,6 +1102,13 @@ export class OceanScene { } } + setWaterColor(value) { + this.params.waterColor = value; + if (this.water?.material?.uniforms?.waterColor?.value) { + this.water.material.uniforms.waterColor.value.set(value); + } + } + setCloudCoverage(value) { this.params.cloudCoverage = value; this.updateClouds(); @@ -1303,6 +1311,7 @@ export class OceanScene { this.setRayleigh(mergedParams.rayleigh); this.setBloomStrength(mergedParams.bloomStrength); this.setBloomRadius(mergedParams.bloomRadius); + this.setWaterColor(mergedParams.waterColor); this.setCloudCoverage(mergedParams.cloudCoverage); this.setCloudDensity(mergedParams.cloudDensity); this.setCloudElevation(mergedParams.cloudElevation); diff --git a/src/main.js b/src/main.js index 227118d..6cf6a4c 100644 --- a/src/main.js +++ b/src/main.js @@ -51,6 +51,7 @@ function setupControls(oceanScene) { 'rayleigh', 'bloomStrength', 'bloomRadius', + 'waterColor', 'cloudCoverage', 'cloudDensity', 'cloudElevation', @@ -78,6 +79,7 @@ function setupControls(oceanScene) { rayleigh: '瑞利散射强度', bloomStrength: '泛光强度', bloomRadius: '泛光扩散范围', + waterColor: '海水颜色', cloudCoverage: '云层覆盖度', cloudDensity: '云层密度', cloudElevation: '云层高度', @@ -162,6 +164,9 @@ function setupControls(oceanScene) { bindController(bloomFolder.add(params, 'bloomStrength', 0, 1, 0.01).name('强度'), (value) => oceanScene.setBloomStrength(value)); bindController(bloomFolder.add(params, 'bloomRadius', 0, 3, 0.01).name('扩散'), (value) => oceanScene.setBloomRadius(value)); + const waterFolder = gui.addFolder('海水'); + bindController(waterFolder.addColor(params, 'waterColor').name('颜色'), (value) => oceanScene.setWaterColor(value)); + const cloudFolder = gui.addFolder('云层'); bindController(cloudFolder.add(params, 'cloudCoverage', 0, 1, 0.01).name('覆盖度'), (value) => oceanScene.setCloudCoverage(value)); bindController(cloudFolder.add(params, 'cloudDensity', 0, 1, 0.01).name('密度'), (value) => oceanScene.setCloudDensity(value)); diff --git a/src/weatherPresets.js b/src/weatherPresets.js index aad451f..956f734 100644 --- a/src/weatherPresets.js +++ b/src/weatherPresets.js @@ -7,7 +7,8 @@ export const DEFAULT_SCENE_PARAMS = { bloomStrength: 0.1, bloomRadius: 0, bloomThreshold: 0, - cloudCoverage: 0.4, + waterColor: '#001e0f', + cloudCoverage: 0.1, cloudDensity: 0.5, cloudElevation: 0.5, fogDensity: 0.42, @@ -47,6 +48,7 @@ export const WEATHER_PRESETS = { "rayleigh": 3.21, "bloomStrength": 0.24, "bloomRadius": 0.42, + "waterColor": "#0b3f36", "cloudCoverage": 0.4, "cloudDensity": 0.18, "cloudElevation": 0.98, @@ -75,6 +77,7 @@ export const WEATHER_PRESETS = { exposure: 0.08, bloomStrength: 0.16, bloomRadius: 0.24, + waterColor: '#0a2a24', cloudCoverage: 0.78, cloudDensity: 0.82, cloudElevation: 0.42, @@ -94,28 +97,35 @@ export const WEATHER_PRESETS = { } }, storm: { - label: '暴雨雷暴', + label: '正午', params: { ...DEFAULT_SCENE_PARAMS, - exposure: 0.065, - bloomStrength: 0.22, - bloomRadius: 0.35, - cloudCoverage: 0.92, - cloudDensity: 0.94, - cloudElevation: 0.36, - fogDensity: 0.7, - fogHeight: 0.42, - fogRange: 0.82, - rainEnabled: true, - rainScreenIntensity: 0.72, - rainVeilIntensity: 1.35, - rainDropSize: 1.14, - rainSpeed: 1.34, - rainAudioEnabled: true, - rainAudioVolume: 0.42, - lightningEnabled: true, - lightningIntensity: 1.0, - snowEnabled: false + "elevation": 90, + "azimuth": 180, + "exposure": 0.24, + "turbidity": 18.6, + "rayleigh": 4, + "bloomStrength": 0.18, + "bloomRadius": 0, + "waterColor": "#3378a3", + "cloudCoverage": 0.4, + "cloudDensity": 0.5, + "cloudElevation": 0.5, + "fogDensity": 0.41, + "fogHeight": 0.4, + "fogRange": 0.31, + "rainEnabled": false, + "rainScreenIntensity": 0.41, + "rainVeilIntensity": 1.15, + "rainDropSize": 1, + "rainSpeed": 1, + "rainAudioEnabled": true, + "rainAudioVolume": 0.35, + "snowEnabled": false, + "snowIntensity": 0.65, + "snowSpeed": 0.85, + "lightningEnabled": true, + "lightningIntensity": 0.75 } }, snow: { @@ -124,6 +134,7 @@ export const WEATHER_PRESETS = { ...DEFAULT_SCENE_PARAMS, exposure: 0.11, bloomStrength: 0.08, + waterColor: '#17343e', cloudCoverage: 0.72, cloudDensity: 0.7, fogDensity: 0.52,