-
Notifications
You must be signed in to change notification settings - Fork 10
/
interactive.html
104 lines (77 loc) · 2.62 KB
/
interactive.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, shrink-to-fit=0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title></title>
<style>
head, body{
width:100%;
height:100%;
overflow: hidden;
top:0;
left:0;
margin:0;
padding:0;
}
</style>
</head>
<body>
<script src="vendor/three.min.js"></script>
<!--
<script src="vendor/postprocessing/EffectComposer.js"></script>
<script src="vendor/postprocessing/RenderPass.js"></script>
<script src="vendor/postprocessing/ShaderPass.js"></script>
<script src="vendor/postprocessing/MaskPass.js"></script>
<script src="vendor/shaders/CopyShader.js"></script>
<script src="vendor/shaders/FXAAShader.js"></script>
/-->
<!--<script src="MouseControls.js"></script>-->
<script src="vendor/controls/OrbitControls.js"></script>
<script src="raymarcher.js"></script>
<script src="composer.js"></script>
<script>
var rm;
var composer;
function init() {
rm = new RayMarcher();
rm.loadFragmentShader("glsl/interactive.glsl", onFragmentLoaded );
new THREE.OrbitControls( rm.camera );
rm.camera.position.z = 8;
// composer = new Composer( rm );
document.body.appendChild( rm.domElement );
window.addEventListener( "resize", onResize, false );
onResize();
}
function onFragmentLoaded( scope )
{
scope.setUniform( "color0", "v3", new THREE.Vector3(0.9, 0.9, 0.0) ); //yellow
scope.setUniform( "light0", "v3", new THREE.Vector3(-0.5, 0.75, -0.5) );
scope.setUniform( "color1", "v3", new THREE.Vector3(0.0, 0.2, 0.9) ); //blue
scope.setUniform( "light1", "v3", new THREE.Vector3( 0.5, -0.75, 0.5) );
}
function onResize(e)
{
rm.setSize( window.innerWidth, window.innerHeight );
if( composer !=null )composer.setSize( window.innerWidth, window.innerHeight );
}
function animate() {
requestAnimationFrame( animate );
if( rm.loaded ){
// rm.target.y = 2 * ( Math.sin( Date.now() * 0.001 ) * .5 );
var l1 = rm.getUniform( "light1" );
if( l1 != null )
{
rm.getUniform( "light1" ).value.x = 20 * ( Math.cos( Date.now() * 0.001 ) );
rm.getUniform( "light1" ).value.z = 20 * ( Math.sin( Date.now() * 0.001 ) );
}
}
rm.update();
rm.render();
if(rm.loaded && composer !=null ) composer.render();
}
init();
animate();
</script>
</body>
</html>