misc_exporter_gltf.html 16.3 KB
Newer Older
F
Fernando Serrano 已提交
1 2 3
<!DOCTYPE html>
<html lang="en">
	<head>
M
Mr.doob 已提交
4
		<title>three.js webgl - exporter - gltf</title>
F
Fernando Serrano 已提交
5 6
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
M
Mr.doob 已提交
7
		<link type="text/css" rel="stylesheet" href="main.css">
F
Fernando Serrano 已提交
8 9
	</head>
	<body>
10
		<div id="info">
M
Mugen87 已提交
11
			<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> webgl - exporter - gltf<br/><br/>
12
			<button id="export_scene">Export Scene1</button>
M
Mr.doob 已提交
13
			<button id="export_scenes">Export Scene1 and THREE.Scene 2</button>
M
Mr.doob 已提交
14
			<button id="export_object">Export Sphere</button><br/>
15
			<button id="export_obj">Export WaltHead</button>
16 17
			<button id="export_objects">Export Sphere and Grid</button>
			<button id="export_scene_object">Export Scene1 and Sphere</button>
M
Mr.doob 已提交
18
			<br/><br/>
19 20
			<label><input id="option_trs" name="trs" type="checkbox"/>TRS</label>
			<label><input id="option_visible" name="visible" type="checkbox" checked="checked"/>Only Visible</label>
M
Mr.doob 已提交
21
			<label><input id="option_drawrange" name="visible" type="checkbox" checked="checked"/>Truncate drawRange</label><br/>
22
			<label><input id="option_binary" name="visible" type="checkbox">Binary (<code>.glb</code>)</label>
23
			<label><input id="option_forcepot" name="visible" type="checkbox">Force POT textures</label>
24
			<label><input id="option_maxsize" name="maxSize" type="number" value="4096" min="2" max="8192" step="1"> Max texture size</label>
25
		</div>
F
Fernando Serrano 已提交
26

M
Mugen87 已提交
27
		<script type="module">
28

M
Mr.doob 已提交
29
			import * as THREE from '../build/three.module.js';
M
Mugen87 已提交
30 31 32

			import { OBJLoader } from './jsm/loaders/OBJLoader.js';
			import { GLTFExporter } from './jsm/exporters/GLTFExporter.js';
F
Fernando Serrano 已提交
33

34
			function exportGLTF( input ) {
F
Fernando Serrano 已提交
35

M
Mugen87 已提交
36
				var gltfExporter = new GLTFExporter();
F
Fernando Serrano 已提交
37

38
				var options = {
L
Lewy Blue 已提交
39 40 41 42
					trs: document.getElementById( 'option_trs' ).checked,
					onlyVisible: document.getElementById( 'option_visible' ).checked,
					truncateDrawRange: document.getElementById( 'option_drawrange' ).checked,
					binary: document.getElementById( 'option_binary' ).checked,
43 44
					forcePowerOfTwoTextures: document.getElementById( 'option_forcepot' ).checked,
					maxTextureSize: Number( document.getElementById( 'option_maxsize' ).value ) || Infinity // To prevent NaN value
45
				};
L
Lewy Blue 已提交
46
				gltfExporter.parse( input, function ( result ) {
F
Fernando Serrano 已提交
47

48 49 50 51 52 53 54 55 56 57 58
					if ( result instanceof ArrayBuffer ) {

						saveArrayBuffer( result, 'scene.glb' );

					} else {

						var output = JSON.stringify( result, null, 2 );
						console.log( output );
						saveString( output, 'scene.gltf' );

					}
F
Fernando Serrano 已提交
59

60
				}, options );
F
Fernando Serrano 已提交
61

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
			}

			document.getElementById( 'export_scene' ).addEventListener( 'click', function () {

				exportGLTF( scene1 );

			} );

			document.getElementById( 'export_scenes' ).addEventListener( 'click', function () {

				exportGLTF( [ scene1, scene2 ] );

			} );

			document.getElementById( 'export_object' ).addEventListener( 'click', function () {

				exportGLTF( sphere );

			} );

82 83 84 85 86 87
			document.getElementById( 'export_obj' ).addEventListener( 'click', function () {

				exportGLTF( waltHead );

			} );

88 89 90 91
			document.getElementById( 'export_objects' ).addEventListener( 'click', function () {

				exportGLTF( [ sphere, gridHelper ] );

92
			} );
F
Fernando Serrano 已提交
93

94 95 96 97 98 99 100
			document.getElementById( 'export_scene_object' ).addEventListener( 'click', function () {

				exportGLTF( [ scene1, gridHelper ] );

			} );


101 102 103
			var link = document.createElement( 'a' );
			link.style.display = 'none';
			document.body.appendChild( link ); // Firefox workaround, see #6594
F
Fernando Serrano 已提交
104

105
			function save( blob, filename ) {
F
Fernando Serrano 已提交
106

107
				link.href = URL.createObjectURL( blob );
108
				link.download = filename;
109
				link.click();
F
Fernando Serrano 已提交
110

111
				// URL.revokeObjectURL( url ); breaks Firefox...
F
Fernando Serrano 已提交
112

113 114 115
			}

			function saveString( text, filename ) {
F
Fernando Serrano 已提交
116

117
				save( new Blob( [ text ], { type: 'text/plain' } ), filename );
118 119 120 121 122 123 124

			}


			function saveArrayBuffer( buffer, filename ) {

				save( new Blob( [ buffer ], { type: 'application/octet-stream' } ), filename );
F
Fernando Serrano 已提交
125

126
			}
F
Fernando Serrano 已提交
127

128
			var container;
F
Fernando Serrano 已提交
129

130
			var camera, object, scene1, scene2, renderer;
131
			var gridHelper, sphere, waltHead;
F
Fernando Serrano 已提交
132 133 134 135 136 137 138 139 140

			init();
			animate();

			function init() {

				container = document.createElement( 'div' );
				document.body.appendChild( container );

M
Mr.doob 已提交
141
				scene1 = new THREE.Scene();
142
				scene1.name = 'Scene1';
F
Fernando Serrano 已提交
143

144 145 146
				// ---------------------------------------------------------------------
				// Perspective Camera
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
147
				camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
L
Lewy Blue 已提交
148
				camera.position.set( 600, 400, 0 );
149 150 151

				camera.name = "PerspectiveCamera";
				scene1.add( camera );
F
Fernando Serrano 已提交
152

153 154 155
				// ---------------------------------------------------------------------
				// Ambient light
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
156
				var light = new THREE.AmbientLight( 0xffffff, 0.2 );
157 158
				light.name = 'AmbientLight';
				scene1.add( light );
F
Fernando Serrano 已提交
159

160 161 162
				// ---------------------------------------------------------------------
				// DirectLight
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
163
				light = new THREE.DirectionalLight( 0xffffff, 1 );
M
Mugen87 已提交
164
				light.target.position.set( 0, 0, - 1 );
165
				light.add( light.target );
M
Mugen87 已提交
166
				light.lookAt( - 1, - 1, 0 );
167
				light.name = 'DirectionalLight';
F
Fernando Serrano 已提交
168
				scene1.add( light );
F
Fernando Serrano 已提交
169

170 171 172
				// ---------------------------------------------------------------------
				// Grid
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
173
				gridHelper = new THREE.GridHelper( 2000, 20 );
L
Lewy Blue 已提交
174
				gridHelper.position.y = - 50;
175 176
				gridHelper.name = "Grid";
				scene1.add( gridHelper );
F
Fernando Serrano 已提交
177

178
				// ---------------------------------------------------------------------
W
WestLangley 已提交
179
				// Axes
180
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
181
				var axes = new THREE.AxesHelper( 500 );
W
WestLangley 已提交
182 183
				axes.name = "AxesHelper";
				scene1.add( axes );
F
Fernando Serrano 已提交
184 185 186 187 188

				// ---------------------------------------------------------------------
				// Simple geometry with basic material
				// ---------------------------------------------------------------------
				// Icosahedron
189
				var mapGrid = new THREE.TextureLoader().load( 'textures/uv_grid_opengl.jpg' );
M
Mr.doob 已提交
190 191
				mapGrid.wrapS = mapGrid.wrapT = THREE.RepeatWrapping;
				var material = new THREE.MeshBasicMaterial( {
192 193
					color: 0xffffff,
					map: mapGrid
194
				} );
F
Fernando Serrano 已提交
195

M
Mr.doob 已提交
196
				object = new THREE.Mesh( new THREE.IcosahedronBufferGeometry( 75, 0 ), material );
L
Lewy Blue 已提交
197
				object.position.set( - 200, 0, 200 );
198 199
				object.name = 'Icosahedron';
				scene1.add( object );
F
Fernando Serrano 已提交
200

F
Fernando Serrano 已提交
201
				// Octahedron
M
Mr.doob 已提交
202
				material = new THREE.MeshBasicMaterial( {
F
Fernando Serrano 已提交
203 204 205
					color: 0x0000ff,
					wireframe: true
				} );
M
Mr.doob 已提交
206
				object = new THREE.Mesh( new THREE.OctahedronBufferGeometry( 75, 1 ), material );
F
Fernando Serrano 已提交
207
				object.position.set( 0, 0, 200 );
208 209
				object.name = 'Octahedron';
				scene1.add( object );
F
Fernando Serrano 已提交
210

F
Fernando Serrano 已提交
211
				// Tetrahedron
M
Mr.doob 已提交
212
				material = new THREE.MeshBasicMaterial( {
213 214 215
					color: 0xff0000,
					transparent: true,
					opacity: 0.5
F
Fernando Serrano 已提交
216 217
				} );

M
Mr.doob 已提交
218
				object = new THREE.Mesh( new THREE.TetrahedronBufferGeometry( 75, 0 ), material );
F
Fernando Serrano 已提交
219
				object.position.set( 200, 0, 200 );
220 221
				object.name = 'Tetrahedron';
				scene1.add( object );
F
Fernando Serrano 已提交
222

F
Fernando Serrano 已提交
223 224 225
				// ---------------------------------------------------------------------
				// Buffered geometry primitives
				// ---------------------------------------------------------------------
F
Fernando Serrano 已提交
226
				// Sphere
M
Mr.doob 已提交
227
				material = new THREE.MeshStandardMaterial( {
F
Fernando Serrano 已提交
228
					color: 0xffff00,
F
Fernando Serrano 已提交
229
					metalness: 0.5,
F
Fernando Serrano 已提交
230 231
					roughness: 1.0,
					flatShading: true
F
Fernando Serrano 已提交
232
				} );
M
Mr.doob 已提交
233
				sphere = new THREE.Mesh( new THREE.SphereBufferGeometry( 70, 10, 10 ), material );
234 235 236
				sphere.position.set( 0, 0, 0 );
				sphere.name = "Sphere";
				scene1.add( sphere );
237

F
Fernando Serrano 已提交
238
				// Cylinder
M
Mr.doob 已提交
239
				material = new THREE.MeshStandardMaterial( {
F
Fernando Serrano 已提交
240 241 242
					color: 0xff00ff,
					flatShading: true
				} );
M
Mr.doob 已提交
243
				object = new THREE.Mesh( new THREE.CylinderBufferGeometry( 10, 80, 100 ), material );
F
Fernando Serrano 已提交
244 245
				object.position.set( 200, 0, 0 );
				object.name = "Cylinder";
246
				scene1.add( object );
F
Fernando Serrano 已提交
247

F
Fernando Serrano 已提交
248
				// TorusKnot
M
Mr.doob 已提交
249
				material = new THREE.MeshStandardMaterial( {
250 251
					color: 0xff0000,
					roughness: 1
F
Fernando Serrano 已提交
252
				} );
M
Mr.doob 已提交
253
				object = new THREE.Mesh( new THREE.TorusKnotBufferGeometry( 50, 15, 40, 10 ), material );
L
Lewy Blue 已提交
254
				object.position.set( - 200, 0, 0 );
F
Fernando Serrano 已提交
255
				object.name = "Cylinder";
256
				scene1.add( object );
F
Fernando Serrano 已提交
257

F
Fernando Serrano 已提交
258

F
Fernando Serrano 已提交
259 260 261
				// ---------------------------------------------------------------------
				// Hierarchy
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
262 263
				var mapWood = new THREE.TextureLoader().load( 'textures/hardwood2_diffuse.jpg' );
				material = new THREE.MeshStandardMaterial( { map: mapWood, side: THREE.DoubleSide } );
F
Fernando Serrano 已提交
264

M
Mr.doob 已提交
265
				object = new THREE.Mesh( new THREE.BoxBufferGeometry( 40, 100, 100 ), material );
L
Lewy Blue 已提交
266
				object.position.set( - 200, 0, 400 );
F
Fernando Serrano 已提交
267
				object.name = "Cube";
268
				scene1.add( object );
F
Fernando Serrano 已提交
269

M
Mr.doob 已提交
270
				var object2 = new THREE.Mesh( new THREE.BoxBufferGeometry( 40, 40, 40, 2, 2, 2 ), material );
F
Fernando Serrano 已提交
271
				object2.position.set( 0, 0, 50 );
F
Fernando Serrano 已提交
272
				object2.rotation.set( 0, 45, 0 );
F
Fernando Serrano 已提交
273
				object2.name = "SubCube";
F
Fernando Serrano 已提交
274
				object.add( object2 );
275

F
Fernando Serrano 已提交
276 277 278 279

				// ---------------------------------------------------------------------
				// Groups
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
280
				var group1 = new THREE.Group();
F
Fernando Serrano 已提交
281
				group1.name = "Group";
282
				scene1.add( group1 );
F
Fernando Serrano 已提交
283

M
Mr.doob 已提交
284
				var group2 = new THREE.Group();
F
Fernando Serrano 已提交
285
				group2.name = "subGroup";
L
Lewy Blue 已提交
286
				group2.position.set( 0, 50, 0 );
F
Fernando Serrano 已提交
287
				group1.add( group2 );
288

M
Mr.doob 已提交
289
				object2 = new THREE.Mesh( new THREE.BoxBufferGeometry( 30, 30, 30 ), material );
290
				object2.name = "Cube in group";
F
Fernando Serrano 已提交
291
				object2.position.set( 0, 0, 400 );
292 293
				group2.add( object2 );

F
Fernando Serrano 已提交
294
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
295
				// THREE.Line Strip
F
Fernando Serrano 已提交
296
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
297
				var geometry = new THREE.BufferGeometry();
298 299 300
				var numPoints = 100;
				var positions = new Float32Array( numPoints * 3 );

L
Lewy Blue 已提交
301 302
				for ( var i = 0; i < numPoints; i ++ ) {

303 304 305
					positions[ i * 3 ] = i;
					positions[ i * 3 + 1 ] = Math.sin( i / 2 ) * 20;
					positions[ i * 3 + 2 ] = 0;
L
Lewy Blue 已提交
306

307 308
				}

309
				geometry.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
M
Mr.doob 已提交
310
				object = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ) );
L
Lewy Blue 已提交
311
				object.position.set( - 50, 0, - 200 );
F
Fernando Serrano 已提交
312
				scene1.add( object );
313 314


F
Fernando Serrano 已提交
315
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
316
				// THREE.Line Loop
F
Fernando Serrano 已提交
317
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
318
				var geometry = new THREE.BufferGeometry();
319
				var numPoints = 5;
F
Fernando Serrano 已提交
320
				var radius = 70;
321 322
				var positions = new Float32Array( numPoints * 3 );

L
Lewy Blue 已提交
323 324
				for ( var i = 0; i < numPoints; i ++ ) {

325
					var s = i * Math.PI * 2 / numPoints;
L
Lewy Blue 已提交
326 327
					positions[ i * 3 ] = radius * Math.sin( s );
					positions[ i * 3 + 1 ] = radius * Math.cos( s );
328
					positions[ i * 3 + 2 ] = 0;
L
Lewy Blue 已提交
329

330 331
				}

332
				geometry.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
M
Mr.doob 已提交
333
				object = new THREE.LineLoop( geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ) );
L
Lewy Blue 已提交
334
				object.position.set( 0, 0, - 200 );
335

F
Fernando Serrano 已提交
336
				scene1.add( object );
337

338 339 340
				// ---------------------------------------------------------------------
				// Buffer geometry truncated (DrawRange)
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
341
				var geometry = new THREE.BufferGeometry();
342 343 344 345 346 347
				var numElements = 6;
				var outOfRange = 3;

				var positions = new Float32Array( ( numElements + outOfRange ) * 3 );
				var colors = new Float32Array( ( numElements + outOfRange ) * 3 );

L
Lewy Blue 已提交
348
				positions.set( [
349 350 351 352 353 354
					0, 0, 0,
					0, 80, 0,
					80, 0, 0,
					80, 0, 0,
					0, 80, 0,
					80, 80, 0
L
Lewy Blue 已提交
355
				] );
356

L
Lewy Blue 已提交
357
				colors.set( [
358 359 360 361 362 363
					1, 0, 0,
					1, 0, 0,
					1, 1, 0,
					1, 1, 0,
					0, 0, 1,
					0, 0, 1,
L
Lewy Blue 已提交
364
				] );
365

366 367
				geometry.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
				geometry.setAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) );
368 369
				geometry.setDrawRange( 0, numElements );

370
				object = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { side: THREE.DoubleSide, vertexColors: true } ) );
371
				object.name = 'Custom buffered truncated';
M
Mugen87 已提交
372
				object.position.set( 140, - 40, - 200 );
373 374 375

				scene1.add( object );

F
Fernando Serrano 已提交
376
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
377
				// THREE.Points
F
Fernando Serrano 已提交
378
				// ---------------------------------------------------------------------
379 380
				var numPoints = 100;
				var pointsArray = new Float32Array( numPoints * 3 );
L
Lewy Blue 已提交
381 382 383
				for ( var i = 0; i < numPoints; i ++ ) {

					pointsArray[ 3 * i ] = - 50 + Math.random() * 100;
F
Fernando Serrano 已提交
384
					pointsArray[ 3 * i + 1 ] = Math.random() * 100;
L
Lewy Blue 已提交
385 386
					pointsArray[ 3 * i + 2 ] = - 50 + Math.random() * 100;

F
Fernando Serrano 已提交
387 388
				}

M
Mr.doob 已提交
389
				var pointsGeo = new THREE.BufferGeometry();
390
				pointsGeo.setAttribute( 'position', new THREE.BufferAttribute( pointsArray, 3 ) );
F
Fernando Serrano 已提交
391

M
Mr.doob 已提交
392 393
				var pointsMaterial = new THREE.PointsMaterial( { color: 0xffff00, size: 5 } );
				var points = new THREE.Points( pointsGeo, pointsMaterial );
F
Fernando Serrano 已提交
394
				points.name = "Points";
L
Lewy Blue 已提交
395
				points.position.set( - 200, 0, - 200 );
396
				scene1.add( points );
F
Fernando Serrano 已提交
397

398 399 400
				// ---------------------------------------------------------------------
				// Ortho camera
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
401
				var cameraOrtho = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, 0.1, 10 );
402
				scene1.add( cameraOrtho );
F
Fernando Serrano 已提交
403
				cameraOrtho.name = 'OrthographicCamera';
F
Fernando Serrano 已提交
404

M
Mr.doob 已提交
405
				material = new THREE.MeshLambertMaterial( {
406
					color: 0xffff00,
M
Mr.doob 已提交
407
					side: THREE.DoubleSide
408 409
				} );

M
Mr.doob 已提交
410
				object = new THREE.Mesh( new THREE.CircleBufferGeometry( 50, 20, 0, Math.PI * 2 ), material );
L
Lewy Blue 已提交
411
				object.position.set( 200, 0, - 400 );
412
				scene1.add( object );
F
Fernando Serrano 已提交
413

M
Mr.doob 已提交
414
				object = new THREE.Mesh( new THREE.RingBufferGeometry( 10, 50, 20, 5, 0, Math.PI * 2 ), material );
L
Lewy Blue 已提交
415
				object.position.set( 0, 0, - 400 );
416
				scene1.add( object );
F
Fernando Serrano 已提交
417

M
Mr.doob 已提交
418
				object = new THREE.Mesh( new THREE.CylinderBufferGeometry( 25, 75, 100, 40, 5 ), material );
L
Lewy Blue 已提交
419
				object.position.set( - 200, 0, - 400 );
420
				scene1.add( object );
421

F
Fernando Serrano 已提交
422 423 424 425 426
				//
				var points = [];

				for ( var i = 0; i < 50; i ++ ) {

M
Mr.doob 已提交
427
					points.push( new THREE.Vector2( Math.sin( i * 0.2 ) * Math.sin( i * 0.1 ) * 15 + 50, ( i - 5 ) * 2 ) );
F
Fernando Serrano 已提交
428 429 430

				}

M
Mr.doob 已提交
431
				object = new THREE.Mesh( new THREE.LatheBufferGeometry( points, 20 ), material );
432
				object.position.set( 200, 0, 400 );
433
				scene1.add( object );
F
Fernando Serrano 已提交
434

435 436 437
				// ---------------------------------------------------------------------
				// Big red box hidden just for testing `onlyVisible` option
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
438
				material = new THREE.MeshBasicMaterial( {
439 440
					color: 0xff0000
				} );
M
Mr.doob 已提交
441
				object = new THREE.Mesh( new THREE.BoxBufferGeometry( 200, 200, 200 ), material );
442 443 444 445
				object.position.set( 0, 0, 0 );
				object.name = "CubeHidden";
				object.visible = false;
				scene1.add( object );
F
Fernando Serrano 已提交
446

447 448 449
				// ---------------------------------------------------------------------
				//
				//
M
Mugen87 已提交
450
				var loader = new OBJLoader();
451 452 453 454
				loader.load( 'models/obj/walt/WaltHead.obj', function ( obj ) {

					waltHead = obj;
					waltHead.scale.multiplyScalar( 1.5 );
L
Lewy Blue 已提交
455
					waltHead.position.set( 400, 0, 0 );
456 457 458
					scene1.add( waltHead );

				} );
M
Mugen87 已提交
459 460


F
Fernando Serrano 已提交
461
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
462
				// 2nd THREE.Scene
F
Fernando Serrano 已提交
463
				// ---------------------------------------------------------------------
M
Mr.doob 已提交
464 465
				scene2 = new THREE.Scene();
				object = new THREE.Mesh( new THREE.BoxBufferGeometry( 100, 100, 100 ), material );
466 467 468
				object.position.set( 0, 0, 0 );
				object.name = "Cube2ndScene";
				scene2.name = 'Scene2';
L
Lewy Blue 已提交
469
				scene2.add( object );
470

F
Fernando Serrano 已提交
471 472
				//

M
Mr.doob 已提交
473
				renderer = new THREE.WebGLRenderer( { antialias: true } );
F
Fernando Serrano 已提交
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );

				container.appendChild( renderer.domElement );

				//

				window.addEventListener( 'resize', onWindowResize, false );

			}

			function onWindowResize() {

				camera.aspect = window.innerWidth / window.innerHeight;
				camera.updateProjectionMatrix();

				renderer.setSize( window.innerWidth, window.innerHeight );

			}

			//

			function animate() {

				requestAnimationFrame( animate );

				render();

			}

			function render() {

F
Fernando Serrano 已提交
506
				var timer = Date.now() * 0.0001;
F
Fernando Serrano 已提交
507

F
Fernando Serrano 已提交
508 509
				camera.position.x = Math.cos( timer ) * 800;
				camera.position.z = Math.sin( timer ) * 800;
F
Fernando Serrano 已提交
510

511 512
				camera.lookAt( scene1.position );
				renderer.render( scene1, camera );
F
Fernando Serrano 已提交
513 514 515 516 517 518 519

			}

		</script>

	</body>
</html>