-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (49 loc) · 2.04 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html>
<head>
<meta charset=UTF-8 />
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<script src="three.min.js"></script>
<script src="OrbitControls.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.9/dat.gui.min.js" integrity="sha512-WoO4Ih0CDOSLYafy22wZD/mcJ7k0ESLqtQsFa6zFKnEUrbtuGU+GkLtVhgt93xa2qewG5gKEC6CWlN8OaCTSVg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
const gui = new dat.GUI();
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(60, window.innerWidth/window.innerHeight,1,5000);
camera.position.set(0,0,400);
scene.add(camera);
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth,window.innerHeight);
document.body.appendChild(renderer.domElement);
let light = new THREE.PointLight(0xffffff,1.2);
light.position.set(0,0,400);
scene.add(light);
let map = new THREE.TextureLoader().load("rock.jpg");
let bmap = new THREE.TextureLoader().load("rock-bump.jpg");
let dmap = new THREE.TextureLoader().load("rock-displacement.jpg");
let material = new THREE.MeshPhongMaterial({
bumpMap: bmap,
bumpScale: 1.3,
displacementMap: dmap,
displacementScale: 5,
map: map
});
gui.add(material,"displacementScale",-500,500,0.1).name("displacement")
//let geometry = new THREE.PlaneGeometry(400,450,50,50);
const geometry = new THREE.SphereGeometry( 100, 100, 100 );
let brickWall = new THREE.Mesh(geometry,material);
scene.add(brickWall);
let controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
function render() {
renderer.render(scene,camera);
brickWall.rotation.y += 0.001;
controls.update();
requestAnimationFrame(render);
}
render();
</script>
</body>
</html>