index.html 5.4 KB
Newer Older
M
Mr.doob 已提交
1 2 3
<!DOCTYPE html>
<html lang="en">
	<head>
4
		<meta charset="utf-8">
M
Mr.doob 已提交
5 6
		<title>three.js / examples</title>
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
M
Mr.doob 已提交
7 8 9 10 11 12 13 14 15
		<style>

			@font-face {
				font-family: 'inconsolata';
				src: url('files/inconsolata.woff') format('woff');
				font-weight: normal;
				font-style: normal;
			}

M
Mr.doob 已提交
16
			* {
M
Mr.doob 已提交
17 18 19
				box-sizing: border-box;
			}

M
Mr.doob 已提交
20 21 22 23
			html {
				height: 100%;
			}

M
Mr.doob 已提交
24 25 26
			body {
				background-color: #ffffff;
				margin: 0px;
M
Mr.doob 已提交
27 28
				height: 100%;
				color: #555;
M
Mr.doob 已提交
29 30
				font-family: 'inconsolata';
				font-size: 15px;
M
Mr.doob 已提交
31
				line-height: 18px;
M
Mr.doob 已提交
32
				overflow: hidden;
33
			}
M
Mr.doob 已提交
34

M
Mr.doob 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47
			h1 {
				margin-top: 30px;
				margin-bottom: 40px;
				margin-left: 20px;
				font-size: 25px;
				font-weight: normal;
			}

			h2 {
				font-size: 20px;
				font-weight: normal;
			}

48 49 50
			a {
				color: #2194CE;
				text-decoration: none;
M
Mr.doob 已提交
51 52 53
			}

			#panel {
M
Mr.doob 已提交
54 55
				position: fixed;
				left: 0px;
M
Mr.doob 已提交
56
				width: 310px;
M
Mr.doob 已提交
57
				height: 100%;
M
Mr.doob 已提交
58
				overflow: auto;
M
Mr.doob 已提交
59
				background: #fafafa;
M
Mr.doob 已提交
60 61
			}

M
Mr.doob 已提交
62
				#panel #content {
M
Mr.doob 已提交
63
					padding: 0px 20px 20px 20px;
M
Mr.doob 已提交
64 65
				}

M
Mr.doob 已提交
66
				#panel #content .link {
M
Mr.doob 已提交
67 68 69
					color: #2194CE;
					text-decoration: none;
					cursor: pointer;
70
					display: block;
M
Mr.doob 已提交
71 72
				}

M
Mr.doob 已提交
73
				#panel #content .selected {
M
Mr.doob 已提交
74 75 76
					color: #ff0000;
				}

M
Mr.doob 已提交
77
					#panel #content .link:hover {
M
Mr.doob 已提交
78 79 80
						text-decoration: underline;
					}

M
Mr.doob 已提交
81 82
			#viewer {
				position: absolute;
M
Mr.doob 已提交
83
				border: 0px;
M
Mr.doob 已提交
84 85
				left: 310px;
				width: calc(100% - 310px);
M
Mr.doob 已提交
86
				height: 100%;
M
Mr.doob 已提交
87
				overflow: auto;
M
Mr.doob 已提交
88 89
			}

90 91
			#button {
				position: fixed;
92
				bottom: 20px;
93 94 95 96 97 98 99 100 101 102 103 104
				right: 20px;
				padding: 8px;
				color: #fff;
				background-color: #555;
				opacity: 0.7;
			}

				#button:hover {
					cursor: pointer;
					opacity: 1;
				}

M
Mr.doob 已提交
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
			/* mobile */

			#expandButton {
				display: none;
				position: absolute;
				right: 20px;
				top: 12px;
				width: 32px;
				height: 32px;
			}

				#expandButton span {
					height: 2px;
					background-color: #2194CE;
					width: 16px;
					position: absolute;
					left: 8px;
					top: 10px;
				}

				#expandButton span:nth-child(1) {
					top: 16px;
				}

				#expandButton span:nth-child(2) {
					top: 22px;
				}

			@media all and ( max-width: 640px ) {
M
Mr.doob 已提交
134 135 136 137
				h1{
					margin-top: 20px;
					margin-bottom: 20px;
				}
M
Mr.doob 已提交
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
				#panel{
					position: absolute;
					left: 0;
					top: 0;
					height: 480px;
					width: 100%;
					right: 0;
					z-index: 100;
					overflow: hidden;
					border-bottom: 1px solid #dedede;
				}
				#content{
					position: absolute;
					left: 0;
					top: 60px;
					right: 0;
					bottom: 0;
M
Mr.doob 已提交
155 156 157
					font-size: 17px;
					line-height: 22px;
					overflow: auto;
M
Mr.doob 已提交
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
				}
				#viewer{
					position: absolute;
					left: 0;
					top: 56px;
					width: 100%;
					height: calc(100% - 56px);
				}
				#expandButton{
					display: block;
				}
				#panel.collapsed{
					height: 56px;
				}
			}

M
Mr.doob 已提交
174 175 176 177
		</style>
	</head>
	<body>

M
Mr.doob 已提交
178 179
		<div id="panel" class="collapsed">
			<h1><a href="http://threejs.org">three.js</a> / examples</h1>
M
Mr.doob 已提交
180
			<a id="expandButton" href="#">
M
Mr.doob 已提交
181 182 183 184 185
				<span></span>
				<span></span>
				<span></span>
			</a>
			<div id="content"></div>
M
Mr.doob 已提交
186
		</div>
187
		<iframe id="viewer" allowfullscreen onmousewheel=""></iframe>
M
Mr.doob 已提交
188

G
gero3 已提交
189
		<script src="files.js"></script>
M
Mr.doob 已提交
190 191
		<script>

M
Mr.doob 已提交
192
		var panel = document.getElementById( 'panel' );
M
Mr.doob 已提交
193
		var content = document.getElementById( 'content' );
M
Mr.doob 已提交
194
		var viewer = document.getElementById( 'viewer' );
M
Mr.doob 已提交
195

M
Mr.doob 已提交
196 197 198 199 200 201 202 203
		var expandButton = document.getElementById( 'expandButton' );
		expandButton.addEventListener( 'click', function ( event ) {
			panel.classList.toggle( 'collapsed' );
			event.preventDefault();
		} );

		// iOS8 workaround

204 205 206 207 208 209 210 211 212 213 214
		if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {

			viewer.addEventListener( 'load', function ( event ) {

				viewer.contentWindow.innerWidth -= 10;
				viewer.contentWindow.innerHeight -= 2;

			} );

		}

M
Mr.doob 已提交
215
		var container = document.createElement( 'div' );
M
Mr.doob 已提交
216
		content.appendChild( container );
M
Mr.doob 已提交
217

218 219
		var button = document.createElement( 'div' );
		button.id = 'button';
M
Mr.doob 已提交
220
		button.textContent = 'View source';
221 222 223 224 225
		button.addEventListener( 'click', function ( event ) {

			var array = location.href.split( '/' );
			array.pop();

M
Mr.doob 已提交
226
			window.open( 'view-source:' + array.join( '/' ) + '/' + selected + '.html' );
227 228 229 230 231

		}, false );
		button.style.display = 'none';
		document.body.appendChild( button );

232
		var links = {};
233
		var selected = null;
M
Mr.doob 已提交
234

M
Mr.doob 已提交
235
		for ( var key in files ) {
M
Mr.doob 已提交
236

M
Mr.doob 已提交
237
			var section = files[ key ];
M
Mr.doob 已提交
238

M
Mr.doob 已提交
239 240 241
			var div = document.createElement( 'h2' );
			div.textContent = key;
			container.appendChild( div );
M
Mr.doob 已提交
242

M
Mr.doob 已提交
243
			for ( var i = 0; i < section.length; i ++ ) {
M
Mr.doob 已提交
244

M
Mr.doob 已提交
245
				( function ( file ) {
M
Mr.doob 已提交
246

M
Mr.doob 已提交
247 248 249
					var name = file.split( '_' );
					name.shift();
					name = name.join( ' / ' );
M
Mr.doob 已提交
250

251 252 253
					var link = document.createElement( 'a' );
					link.className = 'link';
					link.textContent = name;
254
					link.href = "#" + file;
M
Mr.doob 已提交
255
					link.addEventListener( 'click', function ( event ) {
256

M
Mr.doob 已提交
257
						if ( event.button === 0 ) {
258

M
Mr.doob 已提交
259
							event.preventDefault();
260 261 262

							panel.classList.toggle( 'collapsed' );
							load( file );
M
Mr.doob 已提交
263

264
						}
M
Mr.doob 已提交
265 266

					} );
267
					container.appendChild( link );
M
Mr.doob 已提交
268

269
					links[ file ] = link;
M
Mr.doob 已提交
270 271 272 273

				} )( section[ i ] );

			}
M
Mr.doob 已提交
274 275 276 277 278

		}

		var load = function ( file ) {

279
			if ( selected !== null ) links[ selected ].className = 'link';
M
Mr.doob 已提交
280

281
			links[ file ].className = 'link selected';
M
Mr.doob 已提交
282 283 284

			window.location.hash = file;
			viewer.src = file + '.html';
M
Mr.doob 已提交
285
			viewer.focus();
M
Mr.doob 已提交
286

287 288
			button.style.display = '';

M
Mr.doob 已提交
289 290
			selected = file;

M
Mr.doob 已提交
291
		};
M
Mr.doob 已提交
292

M
Mr.doob 已提交
293
		if ( window.location.hash !== '' ) {
M
Mr.doob 已提交
294

M
Mr.doob 已提交
295
			load( window.location.hash.substring( 1 ) );
M
Mr.doob 已提交
296 297 298 299 300 301

		}

		</script>

	</body>
302
</html>