소스 검색

Clean up code

Fernando Serrano 8 년 전
부모
커밋
e0c5cf5d28
3개의 변경된 파일223개의 추가작업 그리고 713개의 파일을 삭제
  1. 4 10
      editor/js/Menubar.File.js
  2. 16 16
      examples/gltf_exporter.html
  3. 203 687
      examples/js/exporters/GLTFExporter.js

+ 4 - 10
editor/js/Menubar.File.js

@@ -202,18 +202,12 @@ Menubar.File = function ( editor ) {
 	option.setTextContent( 'Export GLTF2' );
 	option.setTextContent( 'Export GLTF2' );
 	option.onClick( function () {
 	option.onClick( function () {
 
 
-		var object = editor.scene;
-
-		if ( object === null ) {
-
-			alert( 'No object selected.' );
-			return;
-
-		}
-
 		var exporter = new THREE.GLTFExporter();
 		var exporter = new THREE.GLTFExporter();
 
 
-		saveString( JSON.stringify(exporter.parse( object ),null, 2), 'scene.gltf' );
+		exporter.parse(editor.scene, function(result){
+			saveString( JSON.stringify(result,null, 2), 'scene.gltf' );
+		});
+
 
 
 	} );
 	} );
 	options.add( option );
 	options.add( option );

+ 16 - 16
examples/gltf_exporter.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <!DOCTYPE html>
 <html lang="en">
 <html lang="en">
 	<head>
 	<head>
-		<title>three.js webgl - geometries</title>
+		<title>three.js webgl - gltf exporter</title>
 		<meta charset="utf-8">
 		<meta charset="utf-8">
 		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
 		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
 		<style>
 		<style>
@@ -69,7 +69,7 @@
 
 
 				var light, object;
 				var light, object;
 
 
-				scene.add( new THREE.AmbientLight( 0x404040 ) );
+				scene.add( new THREE.AmbientLight( 0xffffff ) );
 
 
 				light = new THREE.DirectionalLight( 0xffffff );
 				light = new THREE.DirectionalLight( 0xffffff );
 				light.position.set( 0, 1, 0 );
 				light.position.set( 0, 1, 0 );
@@ -83,9 +83,6 @@
 
 
 				//
 				//
 /*
 /*
-				object = new THREE.Mesh( new THREE.SphereGeometry( 75, 20, 10 ), material );
-				object.position.set( -400, 0, 200 );
-				scene.add( object );
 
 
 				object = new THREE.Mesh( new THREE.IcosahedronGeometry( 75, 1 ), material );
 				object = new THREE.Mesh( new THREE.IcosahedronGeometry( 75, 1 ), material );
 				object.position.set( -200, 0, 200 );
 				object.position.set( -200, 0, 200 );
@@ -106,8 +103,10 @@
 				scene.add( object );
 				scene.add( object );
 */
 */
 
 
+				var map2 = new THREE.TextureLoader().load( 'textures/hardwood2_diffuse.jpg' );
+
 				var material = new THREE.MeshStandardMaterial( {
 				var material = new THREE.MeshStandardMaterial( {
-					color: 0xffff00,
+					map: map2,
 					metalness: 0.5,
 					metalness: 0.5,
 					roughness: 1.0
 					roughness: 1.0
 				} );
 				} );
@@ -116,31 +115,32 @@
 				object.position.set( 0, 0, 0 );
 				object.position.set( 0, 0, 0 );
 				object.name = "Sphere";
 				object.name = "Sphere";
 				scene.add(object);
 				scene.add(object);
-
+/*
 				var material = new THREE.MeshStandardMaterial( {
 				var material = new THREE.MeshStandardMaterial( {
 					color: 0xff0000,
 					color: 0xff0000,
 					metalness: 0.1,
 					metalness: 0.1,
 					roughness: 0.5
 					roughness: 0.5
 				} );
 				} );
+*/
 
 
-				object = new THREE.Mesh( new THREE.BoxBufferGeometry( 100, 100, 100 ), material );
-				object.position.set( -200, 0, 0 );
-				object.name = "Cube";
 
 
-				var material = new THREE.MeshStandardMaterial( {
-					color: 0xff00ff
-				} );
+				var material = new THREE.MeshStandardMaterial( { map: map, side: THREE.DoubleSide } );
 
 
+/*
 				object3 = new THREE.Mesh( new THREE.CylinderBufferGeometry( 100, 100, 100 ), material );
 				object3 = new THREE.Mesh( new THREE.CylinderBufferGeometry( 100, 100, 100 ), material );
 				object3.position.set( 200, 0, 0 );
 				object3.position.set( 200, 0, 0 );
 				object3.name = "Cube";
 				object3.name = "Cube";
 				scene.add(object3);
 				scene.add(object3);
+*/
 
 
+				object = new THREE.Mesh( new THREE.BoxBufferGeometry( 100, 100, 100 ), material );
+				object.position.set( -200, 0, 0 );
+				object.name = "Cube";
 
 
 				object2 = new THREE.Mesh( new THREE.BoxBufferGeometry( 40, 10, 80, 2, 2, 2 ), material );
 				object2 = new THREE.Mesh( new THREE.BoxBufferGeometry( 40, 10, 80, 2, 2, 2 ), material );
-				object2.position.set( 40, 40, 40 );
+				object2.position.set( 0, 0, 50 );
 				object2.name = "SubCube";
 				object2.name = "SubCube";
-				// object.add(object2);
+				object.add(object2);
 
 
 				scene.add( object );
 				scene.add( object );
 
 
@@ -233,7 +233,7 @@
 
 
 			function render() {
 			function render() {
 
 
-				var timer = Date.now() * 0.0001;
+				var timer = Date.now() * 0.001;
 
 
 				camera.position.x = Math.cos( timer ) * 800;
 				camera.position.x = Math.cos( timer ) * 800;
 				camera.position.z = Math.sin( timer ) * 800;
 				camera.position.z = Math.sin( timer ) * 800;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 203 - 687
examples/js/exporters/GLTFExporter.js


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.