-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransparentBG.html
More file actions
59 lines (50 loc) · 1.54 KB
/
transparentBG.html
File metadata and controls
59 lines (50 loc) · 1.54 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Transparency Tes</title>
<style type="text/css">
html{
background-color: #87C1DE;
}
</style>
</head>
<body>
<script src="js/three.min.js"></script>
<script>
var scene, camera, renderer, sphere;
init();
animate();
function init(){
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(60, window.innerWidth/window.innerHeight, 1, 1000);
camera.position.z = 20;
//creating sphere
sphere = new THREE.Mesh(new THREE.SphereGeometry(5,5,5), new THREE.MeshLambertMaterial({color: 0xDEF1FA}));
scene.add(sphere);
var light = new THREE.DirectionalLight(0x00DB12);
scene.add(light);
//ambient lighting is the same as the color of the document's background-color
//because the shadows look very dark and out of place otherwise
//play around with the color values though
//see what happens!
// http://www.colorpicker.com/ <-- great place to get hex code
light = new THREE.AmbientLight(0x87C1DE);
scene.add(light);
//set alpha to true in order to make the background for the scene transparent
//as opposed to the default black
renderer = new THREE.WebGLRenderer({antialias: true, alpha: true});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
}
function render(){
renderer.render(scene, camera);
}
function animate(){
requestAnimationFrame(animate);
sphere.rotation.x += .03;
sphere.rotation.y += .01;
render();
}
</script>
</body>