diff --git a/index.html b/index.html
index 2e99ac5eea8285aef2fb2704d79b21dc57db493d..56e9396068795548bab2afb6153d536f30ddeb78 100644
--- a/index.html
+++ b/index.html
@@ -48,23 +48,23 @@
-
池塘夜降彩色雨 2022
-
@陈卓勋 @张丁夕 @林孟颖
+
@张丁夕 @林孟颖 @陈卓勋
diff --git a/js/rainAndWave.js b/js/rainAndWave.js
index de4e16a511d2b191609dae6c35ce5c4fe183a8fe..676d4aa29ad36d30ea011e25e8fce709924cef6e 100644
--- a/js/rainAndWave.js
+++ b/js/rainAndWave.js
@@ -20,13 +20,13 @@ const World = {
cloudNum : 200,
lightColor : 0x556666,
lookAtMe : null,
- fieldOfView : 50,
+ fieldOfView : null,
}
const lighteningPara = {
//在从上一次闪电结束,间隔lighteningGap开始的一段长为lighteningDuration的时间内会有闪电
// 闪电时间会随每次闪电结束随机调整
- lighteningGap : 2000, //ms
+ lighteningGap : 5000, //ms
lighteningDuration : 200, //ms
lastlighteningTime : 0, // 上一次闪电时间
lmMax : 200, //最大亮度
@@ -63,6 +63,7 @@ AnimPara.refreshTimeGap = document.getElementById("refresh");
windPara.direction = document.getElementById("windDir");
windPara.windSpeed = document.getElementById("windStr");
World.lookAtMe = document.getElementById("cameraVw");
+World.fieldOfView = document.getElementById("cameraFOV");
// Refresh function
function refresh(){
@@ -75,7 +76,7 @@ function refresh(){
/* refreshfieldview */
// TODO: 调整视野参数
-
+ refreshFOV();
}
@@ -160,14 +161,24 @@ class WaveMesh extends THREE.Mesh {
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(50,window.innerWidth / window.innerHeight,0.1,1000);
const renderer = new THREE.WebGLRenderer();
-camera.position.set(World.MAX_X,World.MAX_Y/2,World.MAX_Z);
+camera.position.set(World.MAX_X*0.9,World.MAX_Y/2,World.MAX_Z*0.9);
camera.lookAt(0,World.MAX_Y/4,0);
renderer.setSize(window.innerWidth,window.innerHeight);
document.body.appendChild(renderer.domElement);
+// var refreshFOV = (function () {
+// var lastFOV = 50;
+// if(World.fieldOfView != lastFOV) {
+// lastFOV = World.fieldOfView;
+// }
+// })();
+
function refreshFOV() {
- camera.fov = World.fieldOfView;
+ camera.fov = Number(World.fieldOfView.value);
+ camera.updateProjectionMatrix();
+ // console.log(camera.fov);
+ // console.log(World.fieldOfView);
}
@@ -185,12 +196,19 @@ treePic.wrapS = THREE.RepeatWrapping;
treePic.repeat.set(1,1);
var treeMeshXY = new THREE.Mesh(treeGeo,new THREE.MeshBasicMaterial({side:THREE.DoubleSide,map:treePic}));
-treeMeshXY.position.set(World.MAX_X/2,World.MAX_Y/2);
+treeMeshXY.position.set(World.MAX_X/2,World.MAX_Y/2,0);
var treeMeshYZ = new THREE.Mesh(treeGeo,new THREE.MeshBasicMaterial({side:THREE.DoubleSide,map:treePic}));
treeMeshYZ.position.set(0,World.MAX_Y/2,World.MAX_Z/2);
treeMeshYZ.rotateY(Math.PI/2);
scene.add(treeMeshXY);
scene.add(treeMeshYZ);
+treeMeshXY = new THREE.Mesh(treeGeo,new THREE.MeshBasicMaterial({side:THREE.DoubleSide,map:treePic}));
+treeMeshXY.position.set(World.MAX_X/2,World.MAX_Y/2,World.MAX_Z);
+treeMeshYZ = new THREE.Mesh(treeGeo,new THREE.MeshBasicMaterial({side:THREE.DoubleSide,map:treePic}));
+treeMeshYZ.position.set(World.MAX_X,World.MAX_Y/2,World.MAX_Z/2);
+treeMeshYZ.rotateY(Math.PI/2);
+scene.add(treeMeshXY);
+scene.add(treeMeshYZ);
//water
var waterGeo = new THREE.PlaneGeometry(World.MAX_X,World.MAX_Y);
@@ -294,7 +312,7 @@ function draw() {
renderer.render(scene,camera);
allFallsDown();
refresh();
- console.log(camera.fov);
+ // console.log(camera.fov);
requestAnimationFrame(draw);
}
@@ -335,7 +353,6 @@ function allFallsDown() {
let nposition = new THREE.Vector3(amesh.position.x,0,amesh.position.z);
mesh = new RainMesh(nposition,speed,amesh.mySize/2,amesh.myColor,0);
rainGroup.add(mesh);
- console.log("new bal");
}
}
else if(amesh.fromSky)
@@ -381,6 +398,7 @@ function allFallsDown() {
}
if(deltaTime > longestBound) {
lighteningPara.lighteningGap = lighteningPara.lighteningGap * (0.5+Math.random());
+
lightening.power = lighteningPara.lmMin;
lighteningPara.lastlighteningTime = nowTime;
// setInterval(() => {