Compare commits
3 Commits
960103b162
...
6c9fed62b0
Author | SHA1 | Date | |
---|---|---|---|
6c9fed62b0 | |||
51ac2cf0f0 | |||
6b5760ac3f |
28
main.js
28
main.js
@ -16,11 +16,11 @@ const mazeWidth = 23
|
|||||||
|
|
||||||
const parameters = {
|
const parameters = {
|
||||||
elevation: 48,
|
elevation: 48,
|
||||||
azimuth: 53,
|
azimuth : 53,
|
||||||
};
|
};
|
||||||
|
|
||||||
const waves = {
|
const waves = {
|
||||||
A: { direction: 0, steepness: 0.05, wavelength: 3 },
|
A: { direction: 0, steepness: 0.05, wavelength: 3 },
|
||||||
B: { direction: 30, steepness: 0.10, wavelength: 6 },
|
B: { direction: 30, steepness: 0.10, wavelength: 6 },
|
||||||
C: { direction: 60, steepness: 0.05, wavelength: 1.5 },
|
C: { direction: 60, steepness: 0.05, wavelength: 1.5 },
|
||||||
};
|
};
|
||||||
@ -82,6 +82,8 @@ scene.background = new THREE.CubeTextureLoader()
|
|||||||
'lf.jpg',
|
'lf.jpg',
|
||||||
] );
|
] );
|
||||||
|
|
||||||
|
window.scene = scene
|
||||||
|
|
||||||
const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000);
|
const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||||
camera.rotation.order = 'YXZ';
|
camera.rotation.order = 'YXZ';
|
||||||
|
|
||||||
@ -186,7 +188,7 @@ const ground = new THREE.Mesh(
|
|||||||
groundMaterial,
|
groundMaterial,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
ground.rotation.x = - Math.PI / 2;
|
ground.rotation.x = -Math.PI / 2;
|
||||||
ground.position.y = -0.5
|
ground.position.y = -0.5
|
||||||
ground.receiveShadow = true;
|
ground.receiveShadow = true;
|
||||||
ground.matrixAutoUpdate = false
|
ground.matrixAutoUpdate = false
|
||||||
@ -199,20 +201,20 @@ collisionner.add(ground)
|
|||||||
const waterGeometry = new THREE.PlaneGeometry(2048, 2048, 512, 512);
|
const waterGeometry = new THREE.PlaneGeometry(2048, 2048, 512, 512);
|
||||||
|
|
||||||
const ocean = new Water(waterGeometry, {
|
const ocean = new Water(waterGeometry, {
|
||||||
textureWidth: 512,
|
textureWidth : 512,
|
||||||
textureHeight: 512,
|
textureHeight: 512,
|
||||||
waterNormals: loader.load(
|
waterNormals : loader.load(
|
||||||
'textures/waternormals.jpg',
|
'textures/waternormals.jpg',
|
||||||
function (texture) {
|
function (texture) {
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
sunDirection: new THREE.Vector3(),
|
sunDirection : new THREE.Vector3(),
|
||||||
sunColor: 0xffffff,
|
sunColor : 0xffffff,
|
||||||
waterColor: 0x001e0f,
|
waterColor : 0x001e0f,
|
||||||
distortionScale: 3.7,
|
distortionScale: 3.7,
|
||||||
fog: scene.fog !== undefined,
|
fog : scene.fog !== undefined,
|
||||||
alpha: 0.9
|
alpha : 0.9
|
||||||
});
|
});
|
||||||
ocean.rotation.x = - Math.PI / 2;
|
ocean.rotation.x = - Math.PI / 2;
|
||||||
ocean.position.y = -0.2;
|
ocean.position.y = -0.2;
|
||||||
@ -259,10 +261,10 @@ const sun = new THREE.Vector3();
|
|||||||
|
|
||||||
// Lights
|
// Lights
|
||||||
|
|
||||||
const ambientLight = new THREE.AmbientLight(0x404040, 9);
|
const ambientLight = new THREE.AmbientLight(0x404040, 7);
|
||||||
scene.add(ambientLight);
|
scene.add(ambientLight);
|
||||||
|
|
||||||
const sunLight = new THREE.DirectionalLight(0xfffae8, 0.7);
|
const sunLight = new THREE.DirectionalLight(0xfffae8, 0.5);
|
||||||
sunLight.castShadow = true;
|
sunLight.castShadow = true;
|
||||||
sunLight.shadow.camera.near = 0.1;
|
sunLight.shadow.camera.near = 0.1;
|
||||||
sunLight.shadow.camera.far = 1.4 * mazeWidth;
|
sunLight.shadow.camera.far = 1.4 * mazeWidth;
|
||||||
@ -338,10 +340,10 @@ const raft = new THREE.Mesh(raftGeometry, [
|
|||||||
raft.position.set( .2, ocean.position.y, -mazeWidth/2 - 1 );
|
raft.position.set( .2, ocean.position.y, -mazeWidth/2 - 1 );
|
||||||
raft.rotation.y = 1.4
|
raft.rotation.y = 1.4
|
||||||
raft.castShadow = true;
|
raft.castShadow = true;
|
||||||
|
|
||||||
collisionner.add(raft);
|
collisionner.add(raft);
|
||||||
const raftOctree = new Octree();
|
const raftOctree = new Octree();
|
||||||
raftOctree.fromGraphNode(raft)
|
raftOctree.fromGraphNode(raft)
|
||||||
scene.add(raft)
|
|
||||||
|
|
||||||
scene.add(collisionner);
|
scene.add(collisionner);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user