植物补光
This commit is contained in:
@@ -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() {
|
||||
@@ -339,6 +344,16 @@ export class OceanScene {
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user