index.html 8.1 KB
Newer Older
M
Mr.doob 已提交
1 2 3
<!DOCTYPE html>
<html lang="en">
	<head>
M
Mr.doob 已提交
4
		<title>three.js / examples</title>
M
Mr.doob 已提交
5
		<meta charset="utf-8">
M
Mr.doob 已提交
6
		<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
Mugen87 已提交
62 63 64
			#panel #content {
				padding: 0px 20px 20px 20px;
			}
M
Mr.doob 已提交
65

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

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

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

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
			}

M
Mr.doob 已提交
90 91 92 93
			#button {
				position: fixed;
				bottom: 20px;
				right: 20px;
94 95 96 97 98
				padding: 8px;
				color: #fff;
				background-color: #555;
				opacity: 0.7;
			}
M
Mr.doob 已提交
99 100

			#button:hover {
M
Mugen87 已提交
101 102 103 104 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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
				cursor: pointer;
				opacity: 1;
			}

			.filterBlock{
				margin: 20px;
				position: relative;
			}

			.filterBlock p {
				margin: 0;
			}

			#filterInput {
				width: 100%;
				padding: 5px;
				font-family: inherit;
				font-size: 15px;
				outline: none;
				border: 1px solid #dedede;
			}

			#filterInput:focus{
				border: 1px solid #2194CE;
			}

			#clearFilterButton {
				position: absolute;
				right: 6px;
				top: 50%;
				margin-top: -8px;
				width: 16px;
				height: 16px;
				font-size: 14px;
				color: grey;
				text-align: center;
				line-height: 0;
				padding-top: 7px;
				opacity: .5;
			}

			#clearFilterButton:hover {
				opacity: 1;
			}

			.filtered {
				display: none !important;
			}

			#panel li b {
				font-weight: bold;
			}
153

M
Mr.doob 已提交
154 155 156 157 158 159 160 161 162 163 164
			/* mobile */

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

M
Mugen87 已提交
165 166 167 168 169 170 171 172
			#expandButton span {
				height: 2px;
				background-color: #2194CE;
				width: 16px;
				position: absolute;
				left: 8px;
				top: 10px;
			}
M
Mr.doob 已提交
173

M
Mugen87 已提交
174 175 176
			#expandButton span:nth-child(1) {
				top: 16px;
			}
M
Mr.doob 已提交
177

M
Mugen87 已提交
178 179 180
			#expandButton span:nth-child(2) {
				top: 22px;
			}
M
Mr.doob 已提交
181 182

			@media all and ( max-width: 640px ) {
M
Mr.doob 已提交
183 184 185 186
				h1{
					margin-top: 20px;
					margin-bottom: 20px;
				}
M
Mr.doob 已提交
187 188 189 190 191 192 193 194 195 196 197 198 199 200
				#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;
M
Mugen87 已提交
201
					top: 90px;
M
Mr.doob 已提交
202 203
					right: 0;
					bottom: 0;
M
Mr.doob 已提交
204 205 206
					font-size: 17px;
					line-height: 22px;
					overflow: auto;
M
Mr.doob 已提交
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
				}
				#viewer{
					position: absolute;
					left: 0;
					top: 56px;
					width: 100%;
					height: calc(100% - 56px);
				}
				#expandButton{
					display: block;
				}
				#panel.collapsed{
					height: 56px;
				}
			}

M
Mr.doob 已提交
223 224 225 226
		</style>
	</head>
	<body>

M
Mr.doob 已提交
227 228
		<div id="panel" class="collapsed">
			<h1><a href="http://threejs.org">three.js</a> / examples</h1>
M
Mr.doob 已提交
229
			<a id="expandButton" href="#">
M
Mr.doob 已提交
230 231 232 233
				<span></span>
				<span></span>
				<span></span>
			</a>
M
Mugen87 已提交
234 235 236 237
			<div class="filterBlock" >
				<input type="text" id="filterInput" placeholder="Type to filter"/>
				<a href="#" id="clearFilterButton" >x</a>
			</div>
M
Mr.doob 已提交
238
			<div id="content"></div>
M
Mr.doob 已提交
239
		</div>
J
Jaume Sanchez 已提交
240
		<iframe id="viewer" name="viewer" allowfullscreen onmousewheel=""></iframe>
M
Mr.doob 已提交
241

G
gero3 已提交
242
		<script src="files.js"></script>
M
Mr.doob 已提交
243 244
		<script>

M
Mr.doob 已提交
245
		var panel = document.getElementById( 'panel' );
M
Mr.doob 已提交
246
		var content = document.getElementById( 'content' );
M
Mr.doob 已提交
247
		var viewer = document.getElementById( 'viewer' );
M
Mr.doob 已提交
248

M
Mugen87 已提交
249 250 251
		var filterInput = document.getElementById( 'filterInput' );
		var clearFilterButton = document.getElementById( 'clearFilterButton' );

M
Mr.doob 已提交
252 253 254 255 256 257 258 259
		var expandButton = document.getElementById( 'expandButton' );
		expandButton.addEventListener( 'click', function ( event ) {
			panel.classList.toggle( 'collapsed' );
			event.preventDefault();
		} );

		// iOS8 workaround

260 261 262 263 264 265 266 267 268 269 270
		if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {

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

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

			} );

		}

M
Mr.doob 已提交
271
		var container = document.createElement( 'div' );
M
Mr.doob 已提交
272
		content.appendChild( container );
M
Mr.doob 已提交
273

274 275
		var button = document.createElement( 'div' );
		button.id = 'button';
M
Mr.doob 已提交
276
		button.textContent = 'View source';
277 278
		button.addEventListener( 'click', function ( event ) {

279
			window.open( 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html' );
280 281 282

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

285
		var links = {};
286
		var selected = null;
M
Mr.doob 已提交
287

M
Mr.doob 已提交
288
		for ( var key in files ) {
M
Mr.doob 已提交
289

M
Mr.doob 已提交
290
			var section = files[ key ];
M
Mr.doob 已提交
291

M
Mugen87 已提交
292 293 294 295
			var header = document.createElement( 'h2' );
			header.textContent = key;
			header.setAttribute( 'data-category', key );
			container.appendChild( header );
M
Mr.doob 已提交
296

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

M
Mr.doob 已提交
299
				( function ( file ) {
M
Mr.doob 已提交
300

M
Mugen87 已提交
301
					var name = getName( file );
M
Mr.doob 已提交
302

303 304 305
					var link = document.createElement( 'a' );
					link.className = 'link';
					link.textContent = name;
306
					link.href = file + '.html';
J
Jaume Sanchez 已提交
307
					link.setAttribute( 'target', 'viewer' );
M
Mr.doob 已提交
308
					link.addEventListener( 'click', function ( event ) {
309

M
Mr.doob 已提交
310
						if ( event.button === 0 ) {
311

312
							selectFile( file );
M
Mr.doob 已提交
313

314
						}
M
Mr.doob 已提交
315 316

					} );
317
					container.appendChild( link );
M
Mr.doob 已提交
318

319
					links[ file ] = link;
M
Mr.doob 已提交
320 321 322 323

				} )( section[ i ] );

			}
M
Mr.doob 已提交
324 325 326

		}

M
Mr.doob 已提交
327
		function loadFile( file ) {
M
Mr.doob 已提交
328

329 330 331
			selectFile( file );
			viewer.src = file + '.html';

M
Mr.doob 已提交
332
		}
333

M
Mr.doob 已提交
334
		function selectFile( file ) {
335

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

338
			links[ file ].className = 'link selected';
M
Mr.doob 已提交
339 340

			window.location.hash = file;
J
Jaume Sanchez 已提交
341
			viewer.focus();
M
Mr.doob 已提交
342

343
			button.style.display = '';
344
			panel.classList.toggle( 'collapsed' );
M
Mr.doob 已提交
345

M
Mr.doob 已提交
346 347
			selected = file;

348
		}
M
Mr.doob 已提交
349

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

M
Mr.doob 已提交
352
			loadFile( window.location.hash.substring( 1 ) );
M
Mr.doob 已提交
353 354 355

		}

M
Mugen87 已提交
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
		// filter

		filterInput.addEventListener( 'input', function( e ) {

			updateFilter();

		} );

		clearFilterButton.addEventListener( 'click', function( e ) {

			filterInput.value = '';
			updateFilter();
			e.preventDefault();

		} );

		function updateFilter() {

			var exp = new RegExp( filterInput.value, 'gi' );

			for ( var key in files ) {

				var section = files[ key ];

				for ( var i = 0; i < section.length; i ++ ) {

					filterExample( section[ i ], exp );

				}

			}

			layoutList();

		}

		function filterExample( file, exp ){

			var link = links[ file ];
			var name = getName( file );
			var res = file.match( exp );
			var text;

			if ( res && res.length > 0 ) {

				link.classList.remove( 'filtered' );

				for( var i = 0; i < res.length; i++ ) {
					text = name.replace( res[ i ], '<b>' + res[ i ] + '</b>' );
				}

				link.innerHTML = text;

			} else {

				link.classList.add( 'filtered' );
				link.innerHTML = name;

			}
		}

		function getName( file ) {

			var name = file.split( '_' );
			name.shift();
			return name.join( ' / ' );

		}

		function layoutList() {

			for ( var key in files ) {

				var collapsed = true;

				var section = files[ key ];

				for ( var i = 0; i < section.length; i ++ ) {

					var file = section[ i ];

					if( !links[ file ].classList.contains( 'filtered' ) ){

						collapsed = false;
						break;

					}

				}

				var element = document.querySelector( 'h2[data-category="' + key + '"]' );

				if( collapsed ){

					element.classList.add( 'filtered' );

				} else {

					element.classList.remove( 'filtered' );

				}

			}

		}

M
Mr.doob 已提交
462 463 464
		</script>

	</body>
465
</html>