Ver Fonte

Added support for SkinnedMeshes to SceneLoader.

alteredq há 12 anos atrás
pai
commit
d2a0d37974

+ 5 - 1
build/three.js

@@ -9146,7 +9146,11 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
 
 						}
 
-						if ( o.morph ) {
+						if ( o.skin ) {
+
+							object = new THREE.SkinnedMesh( geometry, material );
+
+						} else if ( o.morph ) {
 
 							object = new THREE.MorphAnimMesh( geometry, material );
 

Diff do ficheiro suprimidas por serem muito extensas
+ 155 - 155
build/three.min.js


+ 20 - 0
examples/scenes/test_scene.js

@@ -204,6 +204,16 @@
 			"mirroredLoop" : true
 		},
 
+		"knight" : {
+			"geometry" : "knight",
+			"materials": [ "phong_skin" ],
+			"position" : [ 70, -10, 10 ],
+			"rotation" : [ 0, 0, 0 ],
+			"scale"	   : [ 2.5, 2.5, 2.5 ],
+			"visible"  : true,
+			"skin"	   : true
+		},
+
 		"quad_bg" : {
 			"geometry" : "quad",
 			"materials": [ "textured_bg" ],
@@ -398,6 +408,11 @@
 			"url" : "models/animated/sittingBox.js"
 		},
 
+		"knight": {
+			"type": "ascii",
+			"url" : "models/skinned/knight.js"
+		},
+
 		"ben": {
 			"type": "ctm",
 			"url" : "models/ctm/ben.ctm",
@@ -501,6 +516,11 @@
 			"parameters": { "color": 0, "ambient": 0, "specular": 16777215, "shininess": 50, "envMap": "cube_reflection", "reflectivity": 0.125, "combine": "MixOperation", "shading": "flat", "side": "double", "morphTargets": true, "morphNormals" : true }
 		},
 
+		"phong_skin": {
+			"type": "MeshPhongMaterial",
+			"parameters": { "color": 0, "ambient": 0, "specular": 16777215, "shininess": 50, "envMap": "cube_reflection", "reflectivity": 0.5, "combine": "MixOperation", "skinning": true, "morphTargets": true }
+		},
+
 		"phong_compressed_cube": {
 			"type": "MeshPhongMaterial",
 			"parameters": { "color": 16777215, "envMap": "cube_compressed", "bumpMap": "texture_bump_repeat_2", "bumpScale": -0.1 }

+ 19 - 1
examples/webgl_loader_scene.html

@@ -324,6 +324,20 @@
 
 						}
 
+						if ( object instanceof THREE.SkinnedMesh ) {
+
+							THREE.AnimationHandler.add( object.geometry.animation );
+
+							var animation = new THREE.Animation( object, object.geometry.animation.name );
+							animation.JITCompile = false;
+							animation.interpolationType = THREE.AnimationHandler.LINEAR;
+
+							animation.play();
+
+							console.log( object );
+
+						}
+
 					} );
 
 				}
@@ -379,7 +393,7 @@
 
 			}
 
-			function onDocumentMouseMove(event) {
+			function onDocumentMouseMove( event ) {
 
 				mouseX = ( event.clientX - windowHalfX );
 				mouseY = ( event.clientY - windowHalfY );
@@ -455,6 +469,10 @@
 
 				camera.lookAt( scene.position );
 
+				// update skinning
+
+				THREE.AnimationHandler.update( delta * 0.75 );
+
 				for ( var i = 0; i < rotatingObjects.length; i ++ ) {
 
 					var object = rotatingObjects[ i ];

+ 5 - 1
src/loaders/SceneLoader.js

@@ -209,7 +209,11 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
 
 						}
 
-						if ( o.morph ) {
+						if ( o.skin ) {
+
+							object = new THREE.SkinnedMesh( geometry, material );
+
+						} else if ( o.morph ) {
 
 							object = new THREE.MorphAnimMesh( geometry, material );
 

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff