2
0
Эх сурвалжийг харах

Merge pull request #14180 from takahirox/MMDExamplesCleanup

MMDLoader examples clean up
Mr.doob 7 жил өмнө
parent
commit
06cef39c95

+ 12 - 8
examples/webgl_loader_mmd.html

@@ -82,14 +82,14 @@
 				scene.background = new THREE.Color( 0xffffff );
 				scene.background = new THREE.Color( 0xffffff );
 
 
 				var gridHelper = new THREE.PolarGridHelper( 30, 10 );
 				var gridHelper = new THREE.PolarGridHelper( 30, 10 );
-				gridHelper.position.y = -10;
+				gridHelper.position.y = - 10;
 				scene.add( gridHelper );
 				scene.add( gridHelper );
 
 
 				var ambient = new THREE.AmbientLight( 0x666666 );
 				var ambient = new THREE.AmbientLight( 0x666666 );
 				scene.add( ambient );
 				scene.add( ambient );
 
 
 				var directionalLight = new THREE.DirectionalLight( 0x887766 );
 				var directionalLight = new THREE.DirectionalLight( 0x887766 );
-				directionalLight.position.set( -1, 1, 1 ).normalize();
+				directionalLight.position.set( - 1, 1, 1 ).normalize();
 				scene.add( directionalLight );
 				scene.add( directionalLight );
 
 
 				//
 				//
@@ -108,14 +108,18 @@
 
 
 				// model
 				// model
 
 
-				var onProgress = function ( xhr ) {
+				function onProgress( xhr ) {
+
 					if ( xhr.lengthComputable ) {
 					if ( xhr.lengthComputable ) {
+
 						var percentComplete = xhr.loaded / xhr.total * 100;
 						var percentComplete = xhr.loaded / xhr.total * 100;
-						console.log( Math.round(percentComplete, 2) + '% downloaded' );
+						console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
+
 					}
 					}
+
 				};
 				};
 
 
-				var onError = function ( xhr ) {
+				function onError( xhr ) {
 				};
 				};
 
 
 				var modelFile = 'models/mmd/miku/miku_v2.pmd';
 				var modelFile = 'models/mmd/miku/miku_v2.pmd';
@@ -130,7 +134,7 @@
 				loader.loadWithAnimation( modelFile, vmdFiles, function ( mmd ) {
 				loader.loadWithAnimation( modelFile, vmdFiles, function ( mmd ) {
 
 
 					mesh = mmd.mesh;
 					mesh = mmd.mesh;
-					mesh.position.y = -10;
+					mesh.position.y = - 10;
 					scene.add( mesh );
 					scene.add( mesh );
 
 
 					helper.add( mesh, {
 					helper.add( mesh, {
@@ -157,7 +161,7 @@
 				var phongMaterials;
 				var phongMaterials;
 				var originalMaterials;
 				var originalMaterials;
 
 
-				function makePhongMaterials ( materials ) {
+				function makePhongMaterials( materials ) {
 
 
 					var array = [];
 					var array = [];
 
 
@@ -175,7 +179,7 @@
 
 
 				}
 				}
 
 
-				function initGui () {
+				function initGui() {
 
 
 					var api = {
 					var api = {
 						'animation': true,
 						'animation': true,

+ 8 - 4
examples/webgl_loader_mmd_audio.html

@@ -87,7 +87,7 @@
 				scene.add( ambient );
 				scene.add( ambient );
 
 
 				var directionalLight = new THREE.DirectionalLight( 0x887766 );
 				var directionalLight = new THREE.DirectionalLight( 0x887766 );
-				directionalLight.position.set( -1, 1, 1 ).normalize();
+				directionalLight.position.set( - 1, 1, 1 ).normalize();
 				scene.add( directionalLight );
 				scene.add( directionalLight );
 
 
 				//
 				//
@@ -101,14 +101,18 @@
 
 
 				// model
 				// model
 
 
-				var onProgress = function ( xhr ) {
+				function onProgress( xhr ) {
+
 					if ( xhr.lengthComputable ) {
 					if ( xhr.lengthComputable ) {
+
 						var percentComplete = xhr.loaded / xhr.total * 100;
 						var percentComplete = xhr.loaded / xhr.total * 100;
-						console.log( Math.round(percentComplete, 2) + '% downloaded' );
+						console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
+
 					}
 					}
+
 				};
 				};
 
 
-				var onError = function ( xhr ) {
+				function onError( xhr ) {
 				};
 				};
 
 
 				var modelFile = 'models/mmd/miku/miku_v2.pmd';
 				var modelFile = 'models/mmd/miku/miku_v2.pmd';

+ 23 - 18
examples/webgl_loader_mmd_pose.html

@@ -80,7 +80,7 @@
 				scene.add( ambient );
 				scene.add( ambient );
 
 
 				var directionalLight = new THREE.DirectionalLight( 0x887766 );
 				var directionalLight = new THREE.DirectionalLight( 0x887766 );
-				directionalLight.position.set( -1, 1, 1 ).normalize();
+				directionalLight.position.set( - 1, 1, 1 ).normalize();
 				scene.add( directionalLight );
 				scene.add( directionalLight );
 
 
 				//
 				//
@@ -94,14 +94,18 @@
 
 
 				// model
 				// model
 
 
-				var onProgress = function ( xhr ) {
+				function onProgress( xhr ) {
+
 					if ( xhr.lengthComputable ) {
 					if ( xhr.lengthComputable ) {
+
 						var percentComplete = xhr.loaded / xhr.total * 100;
 						var percentComplete = xhr.loaded / xhr.total * 100;
-						console.log( Math.round(percentComplete, 2) + '% downloaded' );
+						console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
+
 					}
 					}
+
 				};
 				};
 
 
-				var onError = function ( xhr ) {
+				function onError( xhr ) {
 				};
 				};
 
 
 				var modelFile = 'models/mmd/miku/miku_v2.pmd';
 				var modelFile = 'models/mmd/miku/miku_v2.pmd';
@@ -126,13 +130,13 @@
 				loader.load( modelFile, function ( object ) {
 				loader.load( modelFile, function ( object ) {
 
 
 					mesh = object;
 					mesh = object;
-					mesh.position.y = -10;
+					mesh.position.y = - 10;
 
 
 					scene.add( mesh );
 					scene.add( mesh );
 
 
 					var vpdIndex = 0;
 					var vpdIndex = 0;
 
 
-					function loadVpd () {
+					function loadVpd() {
 
 
 						var vpdFile = vpdFiles[ vpdIndex ];
 						var vpdFile = vpdFiles[ vpdIndex ];
 
 
@@ -140,7 +144,7 @@
 
 
 							vpds.push( vpd );
 							vpds.push( vpd );
 
 
-							vpdIndex++;
+							vpdIndex ++;
 
 
 							if ( vpdIndex < vpdFiles.length ) {
 							if ( vpdIndex < vpdFiles.length ) {
 
 
@@ -155,6 +159,7 @@
 						}, onProgress, onError );
 						}, onProgress, onError );
 
 
 					}
 					}
+
 					loadVpd();
 					loadVpd();
 
 
 				}, onProgress, onError );
 				}, onProgress, onError );
@@ -163,7 +168,7 @@
 
 
 				window.addEventListener( 'resize', onWindowResize, false );
 				window.addEventListener( 'resize', onWindowResize, false );
 
 
-				function initGui () {
+				function initGui() {
 
 
 					var gui = new dat.GUI();
 					var gui = new dat.GUI();
 
 
@@ -175,13 +180,13 @@
 					var poses = gui.addFolder( 'Poses' );
 					var poses = gui.addFolder( 'Poses' );
 					var morphs = gui.addFolder( 'Morphs' );
 					var morphs = gui.addFolder( 'Morphs' );
 
 
-					function getBaseName ( s ) {
+					function getBaseName( s ) {
 
 
 						return s.slice( s.lastIndexOf( '/' ) + 1 );
 						return s.slice( s.lastIndexOf( '/' ) + 1 );
 
 
 					}
 					}
 
 
-					function initControls () {
+					function initControls() {
 
 
 						for ( var key in dictionary ) {
 						for ( var key in dictionary ) {
 
 
@@ -189,7 +194,7 @@
 
 
 						}
 						}
 
 
-						controls.pose = -1;
+						controls.pose = - 1;
 
 
 						for ( var i = 0; i < vpdFiles.length; i++ ) {
 						for ( var i = 0; i < vpdFiles.length; i++ ) {
 
 
@@ -199,7 +204,7 @@
 
 
 					}
 					}
 
 
-					function initKeys () {
+					function initKeys() {
 
 
 						for ( var key in dictionary ) {
 						for ( var key in dictionary ) {
 
 
@@ -209,9 +214,9 @@
 
 
 					}
 					}
 
 
-					function initPoses () {
+					function initPoses() {
 
 
-						var files = { default: -1 };
+						var files = { default: - 1 };
 
 
 						for ( var i = 0; i < vpdFiles.length; i++ ) {
 						for ( var i = 0; i < vpdFiles.length; i++ ) {
 
 
@@ -223,7 +228,7 @@
 
 
 					}
 					}
 
 
-					function initMorphs () {
+					function initMorphs() {
 
 
 						for ( var key in dictionary ) {
 						for ( var key in dictionary ) {
 
 
@@ -233,7 +238,7 @@
 
 
 					}
 					}
 
 
-					function onChangeMorph () {
+					function onChangeMorph() {
 
 
 						for ( var i = 0; i < keys.length; i++ ) {
 						for ( var i = 0; i < keys.length; i++ ) {
 
 
@@ -245,11 +250,11 @@
 
 
 					}
 					}
 
 
-					function onChangePose () {
+					function onChangePose() {
 
 
 						var index = parseInt( controls.pose );
 						var index = parseInt( controls.pose );
 
 
-						if ( index === -1 ) {
+						if ( index === - 1 ) {
 
 
 							mesh.pose();
 							mesh.pose();