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
			}

90
			.action-button {
91 92 93 94
				padding: 8px;
				color: #fff;
				background-color: #555;
				opacity: 0.7;
95 96
				float: left;
				margin-left: 1px;
97 98 99
				position: fixed;
				bottom: 20px;
				right: 20px;
100
			}
101 102
			
			.action-button:hover {
M
Mugen87 已提交
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 153 154
				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;
			}
155

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

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

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

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

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

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

M
Mr.doob 已提交
225 226 227 228
		</style>
	</head>
	<body>

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

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

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

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

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

		// iOS8 workaround

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

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

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

			} );

		}

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

276
		var button = document.createElement( 'div' );
277
		button.className = 'action-button';
278
		button.id = 'button';
M
Mr.doob 已提交
279
		button.textContent = 'View source';
280 281
		button.addEventListener( 'click', function ( event ) {

282
			window.open( 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html' );
283 284 285

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

288
		var links = {};
289
		var selected = null;
M
Mr.doob 已提交
290

M
Mr.doob 已提交
291
		for ( var key in files ) {
M
Mr.doob 已提交
292

M
Mr.doob 已提交
293
			var section = files[ key ];
M
Mr.doob 已提交
294

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

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

M
Mr.doob 已提交
302
				( function ( file ) {
M
Mr.doob 已提交
303

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

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

M
Mr.doob 已提交
313
						if ( event.button === 0 ) {
314

315
							selectFile( file );
M
Mr.doob 已提交
316

317
						}
M
Mr.doob 已提交
318 319

					} );
320
					container.appendChild( link );
M
Mr.doob 已提交
321

322
					links[ file ] = link;
M
Mr.doob 已提交
323 324 325 326

				} )( section[ i ] );

			}
M
Mr.doob 已提交
327 328 329 330 331

		}

		var load = function ( file ) {

332 333 334 335 336 337 338
			selectFile( file );
			viewer.src = file + '.html';

		};

		var selectFile = function( file ) {

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

341
			links[ file ].className = 'link selected';
M
Mr.doob 已提交
342 343 344

			window.location.hash = file;

345
			button.style.display = '';
346 347
			panel.classList.toggle( 'collapsed' );
			
M
Mr.doob 已提交
348 349
			selected = file;

350
		}
M
Mr.doob 已提交
351

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

M
Mr.doob 已提交
354
			load( window.location.hash.substring( 1 ) );
M
Mr.doob 已提交
355 356 357

		}

M
Mugen87 已提交
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 462 463
		// 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 已提交
464 465 466
		</script>

	</body>
467
</html>