|
@@ -35,6 +35,7 @@
|
|
|
<script src="../build/three.js"></script>
|
|
|
|
|
|
<script src="js/controls/FirstPersonControls.js"></script>
|
|
|
+ <script src="js/loaders/GLTFLoader.js"></script>
|
|
|
|
|
|
<script src="js/shaders/UnpackDepthRGBAShader.js"></script>
|
|
|
<script src="js/utils/ShadowMapViewer.js"></script>
|
|
@@ -265,21 +266,19 @@
|
|
|
|
|
|
mixer = new THREE.AnimationMixer( scene );
|
|
|
|
|
|
- function addMorph( geometry, speed, duration, x, y, z, fudgeColor ) {
|
|
|
+ function addMorph( mesh, clip, speed, duration, x, y, z, fudgeColor ) {
|
|
|
|
|
|
- var material = new THREE.MeshLambertMaterial( { color: 0xffaa55, morphTargets: true, vertexColors: THREE.FaceColors } );
|
|
|
+ mesh = mesh.clone();
|
|
|
+ mesh.material = mesh.material.clone();
|
|
|
|
|
|
if ( fudgeColor ) {
|
|
|
|
|
|
- material.color.offsetHSL( 0, Math.random() * 0.5 - 0.25, Math.random() * 0.5 - 0.25 );
|
|
|
+ mesh.material.color.offsetHSL( 0, Math.random() * 0.5 - 0.25, Math.random() * 0.2 - 0.1 );
|
|
|
|
|
|
}
|
|
|
|
|
|
- var mesh = new THREE.Mesh( geometry, material );
|
|
|
mesh.speed = speed;
|
|
|
|
|
|
- var clip = geometry.animations[ 0 ];
|
|
|
-
|
|
|
mixer.clipAction( clip, mesh ).
|
|
|
setDuration( duration ).
|
|
|
// to shift the playback out of phase:
|
|
@@ -298,35 +297,49 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- var loader = new THREE.JSONLoader();
|
|
|
+ var loader = new THREE.GLTFLoader();
|
|
|
+
|
|
|
+ loader.load( "models/gltf/Horse.glb", function( gltf ) {
|
|
|
+
|
|
|
+ var mesh = gltf.scene.children[ 0 ];
|
|
|
+ mesh.material.color.setHex( 0xffaa55 );
|
|
|
|
|
|
- loader.load( "models/animated/horse.js", function( geometry ) {
|
|
|
+ var clip = gltf.animations[ 0 ];
|
|
|
|
|
|
- addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, 300, true );
|
|
|
- addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, 450, true );
|
|
|
- addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, 600, true );
|
|
|
+ addMorph( mesh, clip, 550, 1, 100 - Math.random() * 1000, FLOOR, 300, true );
|
|
|
+ addMorph( mesh, clip, 550, 1, 100 - Math.random() * 1000, FLOOR, 450, true );
|
|
|
+ addMorph( mesh, clip, 550, 1, 100 - Math.random() * 1000, FLOOR, 600, true );
|
|
|
|
|
|
- addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, - 300, true );
|
|
|
- addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, - 450, true );
|
|
|
- addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, - 600, true );
|
|
|
+ addMorph( mesh, clip, 550, 1, 100 - Math.random() * 1000, FLOOR, - 300, true );
|
|
|
+ addMorph( mesh, clip, 550, 1, 100 - Math.random() * 1000, FLOOR, - 450, true );
|
|
|
+ addMorph( mesh, clip, 550, 1, 100 - Math.random() * 1000, FLOOR, - 600, true );
|
|
|
|
|
|
} );
|
|
|
|
|
|
- loader.load( "models/animated/flamingo.js", function( geometry ) {
|
|
|
+ loader.load( "models/gltf/Flamingo.glb", function( gltf ) {
|
|
|
|
|
|
- addMorph( geometry, 500, 1, 500 - Math.random() * 500, FLOOR + 350, 40 );
|
|
|
+ var mesh = gltf.scene.children[ 0 ];
|
|
|
+ var clip = gltf.animations[ 0 ];
|
|
|
+
|
|
|
+ addMorph( mesh, clip, 500, 1, 500 - Math.random() * 500, FLOOR + 350, 40 );
|
|
|
|
|
|
} );
|
|
|
|
|
|
- loader.load( "models/animated/stork.js", function( geometry ) {
|
|
|
+ loader.load( "models/gltf/Stork.glb", function( gltf ) {
|
|
|
+
|
|
|
+ var mesh = gltf.scene.children[ 0 ];
|
|
|
+ var clip = gltf.animations[ 0 ];
|
|
|
|
|
|
- addMorph( geometry, 350, 1, 500 - Math.random() * 500, FLOOR + 350, 340 );
|
|
|
+ addMorph( mesh, clip, 350, 1, 500 - Math.random() * 500, FLOOR + 350, 340 );
|
|
|
|
|
|
} );
|
|
|
|
|
|
- loader.load( "models/animated/parrot.js", function( geometry ) {
|
|
|
+ loader.load( "models/gltf/Parrot.glb", function( gltf ) {
|
|
|
+
|
|
|
+ var mesh = gltf.scene.children[ 0 ];
|
|
|
+ var clip = gltf.animations[ 0 ];
|
|
|
|
|
|
- addMorph( geometry, 450, 0.5, 500 - Math.random() * 500, FLOOR + 300, 700 );
|
|
|
+ addMorph( mesh, clip, 450, 0.5, 500 - Math.random() * 500, FLOOR + 300, 700 );
|
|
|
|
|
|
} );
|
|
|
|