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">
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-panel{
91
				position: fixed;
92
				bottom: 20px;
93
				right: 20px;
94 95 96
			}

			.action-button {
97 98 99 100
				padding: 8px;
				color: #fff;
				background-color: #555;
				opacity: 0.7;
101 102
				float: left;
				margin-left: 1px;
103
			}
104 105
			
			.action-button:hover {
M
Mugen87 已提交
106 107 108 109
				cursor: pointer;
				opacity: 1;
			}

110 111 112 113 114 115 116
			#open-external-button{
				background-image: url(files/external.svg);
				background-size: 50%;
				background-position: 50% 50%;
				background-repeat: no-repeat;
			}

M
Mugen87 已提交
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 155 156 157 158 159 160 161 162 163 164
			.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;
			}
165

M
Mr.doob 已提交
166 167 168 169 170 171 172 173 174 175 176
			/* mobile */

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

M
Mugen87 已提交
177 178 179 180 181 182 183 184
			#expandButton span {
				height: 2px;
				background-color: #2194CE;
				width: 16px;
				position: absolute;
				left: 8px;
				top: 10px;
			}
M
Mr.doob 已提交
185

M
Mugen87 已提交
186 187 188
			#expandButton span:nth-child(1) {
				top: 16px;
			}
M
Mr.doob 已提交
189

M
Mugen87 已提交
190 191 192
			#expandButton span:nth-child(2) {
				top: 22px;
			}
M
Mr.doob 已提交
193 194

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

M
Mr.doob 已提交
235 236 237 238
		</style>
	</head>
	<body>

M
Mr.doob 已提交
239 240
		<div id="panel" class="collapsed">
			<h1><a href="http://threejs.org">three.js</a> / examples</h1>
M
Mr.doob 已提交
241
			<a id="expandButton" href="#">
M
Mr.doob 已提交
242 243 244 245
				<span></span>
				<span></span>
				<span></span>
			</a>
M
Mugen87 已提交
246 247 248 249
			<div class="filterBlock" >
				<input type="text" id="filterInput" placeholder="Type to filter"/>
				<a href="#" id="clearFilterButton" >x</a>
			</div>
M
Mr.doob 已提交
250
			<div id="content"></div>
M
Mr.doob 已提交
251
		</div>
J
Jaume Sanchez 已提交
252
		<iframe id="viewer" name="viewer" allowfullscreen onmousewheel=""></iframe>
M
Mr.doob 已提交
253

G
gero3 已提交
254
		<script src="files.js"></script>
M
Mr.doob 已提交
255 256
		<script>

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

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

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

		// iOS8 workaround

272 273 274 275 276 277 278 279 280 281 282
		if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {

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

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

			} );

		}

M
Mr.doob 已提交
283
		var container = document.createElement( 'div' );
M
Mr.doob 已提交
284
		content.appendChild( container );
M
Mr.doob 已提交
285

J
Jaume Sanchez 已提交
286 287 288
		var actionPanel = document.createElement( 'div' );
		actionPanel.className = 'action-panel';
		document.body.appendChild( actionPanel );
289

290
		var button = document.createElement( 'div' );
291
		button.className = 'action-button';
292
		button.id = 'button';
M
Mr.doob 已提交
293
		button.textContent = 'View source';
294 295
		button.addEventListener( 'click', function ( event ) {

296
			window.open( 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html' );
297 298 299

		}, false );
		button.style.display = 'none';
J
Jaume Sanchez 已提交
300
		actionPanel.appendChild( button );
301 302 303 304 305 306 307 308 309 310 311 312

		var button2 = document.createElement( 'a' );
		button2.className = 'action-button';
		button2.id = 'open-external-button';
		button2.innerHTML = '&nbsp;&nbsp;'
		button2.addEventListener( 'click', function ( event ) {

			window.open( selected + '.html' );
			event.preventDefault();

		}, false );
		button2.style.display = 'none';
J
Jaume Sanchez 已提交
313
		actionPanel.appendChild( button2 );
314

315
		var links = {};
316
		var selected = null;
M
Mr.doob 已提交
317

M
Mr.doob 已提交
318
		for ( var key in files ) {
M
Mr.doob 已提交
319

M
Mr.doob 已提交
320
			var section = files[ key ];
M
Mr.doob 已提交
321

M
Mugen87 已提交
322 323 324 325
			var header = document.createElement( 'h2' );
			header.textContent = key;
			header.setAttribute( 'data-category', key );
			container.appendChild( header );
M
Mr.doob 已提交
326

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

M
Mr.doob 已提交
329
				( function ( file ) {
M
Mr.doob 已提交
330

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

333 334 335
					var link = document.createElement( 'a' );
					link.className = 'link';
					link.textContent = name;
336
					link.href = file + '.html';
J
Jaume Sanchez 已提交
337
					link.setAttribute( 'target', 'viewer' );
M
Mr.doob 已提交
338
					link.addEventListener( 'click', function ( event ) {
339

M
Mr.doob 已提交
340
						if ( event.button === 0 ) {
341

J
Jaume Sanchez 已提交
342
							//event.preventDefault();
343 344

							panel.classList.toggle( 'collapsed' );
J
Jaume Sanchez 已提交
345
							//load( file );
M
Mr.doob 已提交
346

347
						}
M
Mr.doob 已提交
348 349

					} );
350
					container.appendChild( link );
M
Mr.doob 已提交
351

352
					links[ file ] = link;
M
Mr.doob 已提交
353 354 355 356

				} )( section[ i ] );

			}
M
Mr.doob 已提交
357 358 359 360 361

		}

		var load = function ( file ) {

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

364
			links[ file ].className = 'link selected';
M
Mr.doob 已提交
365 366 367

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

370
			button.style.display = '';
371
			button2.style.display = '';
372

M
Mr.doob 已提交
373 374
			selected = file;

375 376
			button2.href = selected + '.html'

M
Mr.doob 已提交
377
		};
M
Mr.doob 已提交
378

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

M
Mr.doob 已提交
381
			load( window.location.hash.substring( 1 ) );
M
Mr.doob 已提交
382 383 384

		}

M
Mugen87 已提交
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 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
		// 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 已提交
491 492 493
		</script>

	</body>
494
</html>