From df6d78236da8b5ea1d1c4782b9d1c1d0b997d192 Mon Sep 17 00:00:00 2001 From: como Date: Thu, 26 Mar 2026 10:38:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A4=8D=E7=89=A9=E8=A1=A5=E5=85=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/OceanScene.js | 15 +++++++++++++++ src/VegetationSystem.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/OceanScene.js b/src/OceanScene.js index c331f9f..4888d22 100644 --- a/src/OceanScene.js +++ b/src/OceanScene.js @@ -24,6 +24,7 @@ export class OceanScene { this.pmremGenerator = null; this.renderTarget = null; this.sunLight = null; + this.vegetationFillLight = null; this.composer = null; this.bloomPass = null; this.cloudGroup = null; @@ -122,6 +123,10 @@ export class OceanScene { this.sunLight.shadow.camera.top = 100; this.sunLight.shadow.camera.bottom = -100; this.scene.add(this.sunLight); + + this.vegetationFillLight = new THREE.DirectionalLight(0xffb06a, 0.95); + this.vegetationFillLight.castShadow = false; + this.scene.add(this.vegetationFillLight); } initPostProcessing() { @@ -338,6 +343,16 @@ export class OceanScene { this.sun.z * sunDistance ); } + + if (this.vegetationFillLight) { + const fillDistance = 90; + this.vegetationFillLight.position.set( + -this.sun.x * fillDistance * 0.45 + 35, + Math.max(18, this.sun.y * fillDistance * 0.28 + 24), + -this.sun.z * fillDistance * 0.35 + 28 + ); + this.vegetationFillLight.intensity = THREE.MathUtils.lerp(0.7, 1.15, THREE.MathUtils.clamp((this.sun.y + 0.2) / 0.9, 0, 1)); + } if (this.renderTarget) { this.renderTarget.dispose(); diff --git a/src/VegetationSystem.js b/src/VegetationSystem.js index 738667c..7fe13be 100644 --- a/src/VegetationSystem.js +++ b/src/VegetationSystem.js @@ -169,9 +169,40 @@ export class VegetationSystem { plant.options.bark.tint = this.jitterColor(plant.options.bark.tint, tintJitter * 0.04); plant.options.leaves.tint = this.jitterColor(plant.options.leaves.tint, tintJitter * 0.08); plant.generate(); + this.tunePlantMaterials(plant); return plant; } + tunePlantMaterials(plant) { + plant.traverse((child) => { + if (!child.isMesh || !child.material) return; + + const materials = Array.isArray(child.material) ? child.material : [child.material]; + + materials.forEach((material) => { + if (material.name === 'branches') { + material.color.multiplyScalar(1.6); + material.emissive = new THREE.Color(0x6a4a34); + material.emissiveIntensity = 0.38; + material.shininess = 26; + } + + if (material.name === 'leaves') { + material.color.multiplyScalar(1.2); + material.emissive = new THREE.Color(0x355326); + material.emissiveIntensity = 0.18; + material.alphaTest = 0.42; + } + + material.needsUpdate = true; + }); + + if (child.material?.name === 'branches') { + child.receiveShadow = false; + } + }); + } + createGrassBladeGeometry(rotationY) { const width = 0.24; const height = 1.4;