How to add map with bone animation

Now i add map for the pqwg(the SkinnedMesh), then the animation is not play.

But, If i don’t add map, the animation will play normally.

Demo, model and map are all in this compression package
animationTset.rar (3.7 MB)

This is the demo code

three.js webgl - FBX loader
<body>
	<div id="info">
		<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - FBXLoader<br />
		Character and animation from <a href="https://www.mixamo.com/" target="_blank" rel="noopener">Mixamo</a>
	</div>

	<script type="module">

		import * as THREE from '../build/three.module.js';

		import Stats from './jsm/libs/stats.module.js';

		import { OrbitControls } from './jsm/controls/OrbitControls.js';
		import { FBXLoader } from './jsm/loaders/FBXLoader.js';
		import {AnimationUtils} from './../src/animation/AnimationUtils.js';

		var container, stats, controls;
		var camera, scene, renderer, light;

		var clock = new THREE.Clock();

		var mixer;

		init();
		animate();

		function init() {

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

			camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
			camera.position.set( 100, 200, 300 );

			scene = new THREE.Scene();
			scene.background = new THREE.Color( 0xa0a0a0 );
			scene.fog = new THREE.Fog( 0xa0a0a0, 200, 1000 );

			light = new THREE.HemisphereLight( 0xffffff, 0x444444 );
			light.position.set( 0, 200, 0 );
			scene.add( light );

			light = new THREE.DirectionalLight( 0xffffff );
			light.position.set( 0, 200, 100 );
			light.castShadow = true;
			light.shadow.camera.top = 180;
			light.shadow.camera.bottom = - 100;
			light.shadow.camera.left = - 120;
			light.shadow.camera.right = 120;
			scene.add( light );

			// scene.add( new CameraHelper( light.shadow.camera ) );

			// ground
			var mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2000, 2000 ), new THREE.MeshPhongMaterial( { color: 0x999999, depthWrite: false } ) );
			mesh.rotation.x = - Math.PI / 2;
			mesh.receiveShadow = true;
			scene.add( mesh );

			var grid = new THREE.GridHelper( 2000, 20, 0x000000, 0x000000 );
			grid.material.opacity = 0.2;
			grid.material.transparent = true;
			scene.add( grid );

			// model
			var loader = new FBXLoader();
			loader.load( 'models/PaiQiWeiGuan/PaiQiWeiGuan.FBX', function ( object ) {

				const nClip = AnimationUtils.subclip(object.animations[ 0 ], 'nNamePaiQiWeiGuan' , 0, 32);

				mixer = new THREE.AnimationMixer( object );
				// var action = mixer.clipAction( object.animations[ 0 ] );
				var action = mixer.clipAction( nClip );
				action.loop = THREE.LoopRepeat;
				action.play();

				object.traverse( function ( child ) {

					if ( child.isMesh ) {

						child.castShadow = true;
						child.receiveShadow = true;

					}

				} );

				scene.add( object );
				object.position.set(0,0,0);

				const textureLoader = new THREE.TextureLoader();
				const map = textureLoader.load( 'models/PaiQiWeiGuan/dongwuti_BaseColor.png');
				const aoMap = textureLoader.load( '' );
				const normalMap = textureLoader.load( 'models/PaiQiWeiGuan/dongwuti_Normal.png' );
				const roughnessMap = textureLoader.load( 'models/PaiQiWeiGuan/dongwuti_Roughness.png' );
				const metalnessMap = textureLoader.load( 'models/PaiQiWeiGuan/dongwuti_Metallic.png' );
				const mt = new THREE.MeshStandardMaterial({map:map, aoMap:aoMap, normalMap:normalMap, roughnessMap:roughnessMap, metalnessMap:metalnessMap,
				});
				const obj2 = object.getObjectByName('pqwg');
				//object.material = mt;
				obj2.material = mt;

			} );

			renderer = new THREE.WebGLRenderer( { antialias: true } );
			renderer.setPixelRatio( window.devicePixelRatio );
			renderer.setSize( window.innerWidth, window.innerHeight );
			renderer.shadowMap.enabled = true;
			container.appendChild( renderer.domElement );

			controls = new OrbitControls( camera, renderer.domElement );
			controls.target.set( 0, 100, 0 );
			controls.update();

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

			// stats
			stats = new Stats();
			container.appendChild( stats.dom );

		}

		function onWindowResize() {

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

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

		}

		//

		function animate() {

			requestAnimationFrame( animate );

			var delta = clock.getDelta();

			if ( mixer ) mixer.update( delta );

			renderer.render( scene, camera );

			stats.update();

		}

	</script>

</body>

Hi!
Try to add skinning: true to your mt material parameters.

const mt = new THREE.MeshStandardMaterial({map:map, aoMap:aoMap, normalMap:normalMap, roughnessMap:roughnessMap, metalnessMap:metalnessMap, skinning: true});

1 Like

With this configuration added, i can play the animation normally.
Thank you very much.

@seanin You’re welcome :slight_smile: :beers: