index.html 8.9 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">
S
sunag 已提交
7
		<link rel="shortcut icon" href="../favicon.ico" />
M
Mr.doob 已提交
8 9 10 11 12 13 14 15 16
		<style>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

101
			#viewSrcButton:hover {
M
Mugen87 已提交
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 153
				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;
			}
154

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

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

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

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

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

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

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

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

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

M
Mr.doob 已提交
245 246
		<script>

247
		function extractQuery() {
248
			var p = window.location.search.indexOf( '?q=' );
249 250
			if( p !== -1 ) {
				return window.location.search.substr( 3 );
M
Mr.doob 已提交
251
			}
252 253 254
			return ''
		}

M
Mr.doob 已提交
255
		var panel = document.getElementById( 'panel' );
M
Mr.doob 已提交
256
		var content = document.getElementById( 'content' );
M
Mr.doob 已提交
257
		var viewer = document.getElementById( 'viewer' );
M
Mr.doob 已提交
258

M
Mugen87 已提交
259 260 261
		var filterInput = document.getElementById( 'filterInput' );
		var clearFilterButton = document.getElementById( 'clearFilterButton' );

M
Mr.doob 已提交
262 263 264
		var expandButton = document.getElementById( 'expandButton' );
		expandButton.addEventListener( 'click', function ( event ) {
			event.preventDefault();
M
Mr.doob 已提交
265
			panel.classList.toggle( 'collapsed' );
M
Mr.doob 已提交
266 267
		} );

268
		// iOS iframe auto-resize workaround
M
Mr.doob 已提交
269

270 271
		if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {

272 273
			viewer.style.width = getComputedStyle( viewer ).width;
			viewer.style.height = getComputedStyle( viewer ).height;
274
			viewer.setAttribute( 'scrolling', 'no' );
275 276 277

		}

M
Mr.doob 已提交
278
		var container = document.createElement( 'div' );
M
Mr.doob 已提交
279
		content.appendChild( container );
M
Mr.doob 已提交
280

281 282 283 284 285 286
		var viewSrcButton = document.createElement( 'a' );
		viewSrcButton.id = 'viewSrcButton';
		viewSrcButton.target = '_blank';
		viewSrcButton.textContent = 'View source';
		viewSrcButton.style.display = 'none';
		document.body.appendChild( viewSrcButton );
287

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

M
Mr.doob 已提交
291 292 293 294 295 296 297 298 299
		function createLink( file ) {

			var link = document.createElement( 'a' );
			link.className = 'link';
			link.href = file + '.html';
			link.textContent = getName( file );
			link.setAttribute( 'target', 'viewer' );
			link.addEventListener( 'click', function ( event ) {

M
Mr.doob 已提交
300
				if ( event.button !== 0 || event.ctrlKey || event.altKey || event.metaKey ) return;
M
Mr.doob 已提交
301

M
Mr.doob 已提交
302
				selectFile( file );
M
Mr.doob 已提交
303 304 305 306 307 308 309

			} );

			return link;

		}

M
Mr.doob 已提交
310
		for ( var key in files ) {
M
Mr.doob 已提交
311

M
Mr.doob 已提交
312
			var section = files[ key ];
M
Mr.doob 已提交
313

M
Mugen87 已提交
314 315 316 317
			var header = document.createElement( 'h2' );
			header.textContent = key;
			header.setAttribute( 'data-category', key );
			container.appendChild( header );
M
Mr.doob 已提交
318

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

M
Mr.doob 已提交
321
				var file = section[ i ];
M
Mr.doob 已提交
322

M
Mr.doob 已提交
323 324
				var link = createLink( file );
				container.appendChild( link );
M
Mr.doob 已提交
325

M
Mr.doob 已提交
326
				links[ file ] = link;
M
Mr.doob 已提交
327 328

			}
M
Mr.doob 已提交
329 330 331

		}

M
Mr.doob 已提交
332
		function loadFile( file ) {
M
Mr.doob 已提交
333

334 335 336
			selectFile( file );
			viewer.src = file + '.html';

M
Mr.doob 已提交
337
		}
338

M
Mr.doob 已提交
339
		function selectFile( file ) {
340

341
			if ( selected !== null ) links[ selected ].classList.remove( 'selected' );
M
Mr.doob 已提交
342

343
			links[ file ].classList.add( 'selected' );
M
Mr.doob 已提交
344 345

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

348
			panel.classList.add( 'collapsed' );
M
Mr.doob 已提交
349

M
Mr.doob 已提交
350 351
			selected = file;

352 353 354 355 356
			// Reveal "View source" button and set attributes to this example
			viewSrcButton.style.display = '';
			viewSrcButton.href = 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html';
			viewSrcButton.title = 'View source code for ' + getName(selected) + ' on GitHub';

357
		}
M
Mr.doob 已提交
358

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

M
Mr.doob 已提交
361
			loadFile( window.location.hash.substring( 1 ) );
M
Mr.doob 已提交
362 363 364

		}

M
Mugen87 已提交
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
		// filter

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

			updateFilter();

		} );

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

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

		} );

		function updateFilter() {

383 384
			var v = filterInput.value;
			if( v !== '' ) {
385
				window.history.replaceState( {} , '', '?q=' + v + window.location.hash );
386
			} else {
387
				window.history.replaceState( {} , '', window.location.pathname + window.location.hash );
388 389 390
			}

			var exp = new RegExp( v, 'gi' );
M
Mugen87 已提交
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 464 465 466 467 468 469 470 471 472 473 474 475 476 477

			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' );

				}

			}

		}

478
		filterInput.value = extractQuery();
M
Mr.doob 已提交
479
		updateFilter();
480

M
Mr.doob 已提交
481 482 483
		</script>

	</body>
484
</html>