-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
103 lines (93 loc) · 4.47 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
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
<!doctype html>
<html>
<head>
<title>Marching Cubes Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="libs/sylvester.js" type="text/javascript"></script>
<script src="libs/glUtils.js" type="text/javascript"></script>
<script src="libs/perlin.js" type="text/javascript"></script>
<script src="MarchingCubesConst.js" type="text/javascript"></script>
<script src="RenderableObject.js" type="text/javascript"></script>
<script src="Chunk.js" type="text/javascript"></script>
<script src="Cube.js" type="text/javascript"></script>
<script src="engine.js" type="text/javascript"></script>
<!-- Fragment shader program -->
<script id="shader-fs" type="x-shader/x-fragment">
varying highp vec3 vLighting;
void main(void) {
gl_FragColor = gl_FragColor = vec4(0.8 * vLighting.r, 0.8 * vLighting.b, 0.8 * vLighting.b, 1.0);
}
</script>
<!-- Vertex shader program -->
<script id="shader-vs" type="x-shader/x-vertex">
attribute highp vec3 aVertexNormal;
attribute highp vec3 aVertexPosition;
attribute highp vec2 aTextureCoord;
uniform highp mat4 uNormalMatrix;
uniform highp mat4 uMVMatrix;
uniform highp mat4 uPMatrix;
varying highp vec2 vTextureCoord;
varying highp vec3 vLighting;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
vTextureCoord = aTextureCoord;
highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);
highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);
highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);
highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);
highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);
vLighting = ambientLight + (directionalLightColor * directional);
}
</script>
</head>
<body onload="start()">
<div id="menu">
<div id="fps">FPS: 0</div>
<div id="renderable-points">Renderable Objects: 0</div>
<div id="vertices">Vertices: 0</div>
<div id="triangles">Triangles: 0</div>
<br>
<form name="chunkform">
<span>Generation Options</span>
<br>
<label for="threshold">Threshold</label> - <span id="threshold_value"></span>
<input class="slider" type="range" id="threshold" value="100" oninput="onThresholdChange(this.value)">
<br>
<label for="resolution">Resolution</label> - <span id="resolution_value"></span>
<input class="slider" type="range" id="resolution" value="50" oninput="onResolutionChange(this.value)">
<br>
<label for="noise-scale">Noise Scale</label> - <span id="noise-scale_value"></span>
<input class="slider" type="range" id="noise-scale" value="25" oninput="onNoiseScaleChange(this.value)">
<br>
<label for="chunk-scale">Chunk Scale</label> - <span id="chunk-scale_value"></span>
<input class="slider" type="range" id="chunk-scale" value="25" oninput="onChunkScaleChange(this.value)">
<br>
<label for="isovalue">Isolevel</label> - <span id="isolevel_value"></span>
<input class="slider" type="range" id="isovalue" value="100" oninput="onIsolevelChange(this.value)">
<br>
<label for="pointvalue">Points scalar value</label> - <span id="pointlevel_value"></span>
<input class="slider" type="range" id="pointvalue" value="100" oninput="onPointValueChange(this.value)">
<br>
<label for="seed">Seed</label>
<input type="text" id="seed" onchange="onSeedChange(this.value)">
<label for="render-points">Debug vertices?</label>
<input type="checkbox" id="render-points" onchange="onDebugVerticesChange()">
<br>
<label for="hot-reload">Hot reload?</label>
<input type="checkbox" id="hot-reload" onchange="onHotReloadChange()">
<br>
<label for="noise-method">Noise Algorithm</label>
<select id="noise-method" onchange="onNoiseAlgorithmChange(this.value)">
<option value="perlin">Perlin</option>
<option value="simplex">Simplex</option>
</select>
<input type="submit" value="Generate">
</form>
</div>
<canvas id="glcanvas" width="1280" height="960">
Your browser doesn't appear to support the <code><canvas></code> element.
</canvas>
<script src="ChunkGenerator.js" type="text/javascript"></script>
</body>
</html>