How to properly make animation from a Class?

here is link with full code

my animation does not play

It works if you don’t use SkeletonUtils.clone() in your player class to clone a scene object. This method is intended for skinned meshes.

It’s also recommended to call only once and not per frame.

The problem with cloning is that the animation

thank you, i just want make small game.

i tought for performance reason i clone mesh, because each time player connects should create new mesh of robot ?

In general, cloning is the correct approach for this use case. I am also seeing now that you adapt the code of this example:

However, the robot is no part of it. There could be a problem with the structure of the asset which produces a problem when cloning is performed or when you create the instance of AnimationMixer.

even if i clone, i console logged player.animmations, there are animations, but they do not play for some reason

I think the problem is that the robot consist of four separate skinned meshes whereas the example only uses models with a single skinned mesh. You can verify the amount of skinned meshes here:

ahh okey, i just been trying to do same thing as you did in

i just do not understand how you handle events on playing animation when player runs left or right, jumps etc.

This is done in the following method:

It’s important to understand that the routine does not playback just a single animation. Instead, the code computes a weighting for an active set of animations based on the game entitie’s velocity and look direction. In this way, the movement animation is more natural and you never have a sudden change from let’s say move forward to move right.

thank you so much

1 Like

i have question, i just loaded the model (“soldier”) from Dive, the soldier is very small, do i need to scale the model or i need to zoom in camera to the model ?

i just copied camera from Dive
camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 0.1, 1000 );
camera.position.set( 0, 45, 150 );

The camera is too far away^^. The code above represents the spectator settings…

what should it be then ?

here is link, but i can not load model because of cors origin

Well, this depends on your use case. Maybe do it like in this example:

ok i will try it

i tried, but animation does not play

well it is due of weights because

Uncaught TypeError: transformedDirection.copy(…).applyRotation is not a function

transformedDirection.copy( directions[ i ].direction ).applyRotation( quaternion );
const dot = lookDirection );

dot is always 0, thats why my weights do not change

hey, i tried this exemple that you linked,
mixer.addEventListener( ‘loop’, onLoopFinished ); it says it is undefined

here is link

Um, I’m not seeing a runtime error causes by an undefined variable in the browser console.

mixer.addEventListener( ‘loop’, onLoopFinished );
this does not work

console.log(mixer.addEventListener(“loop”, onLoopFinished )) is undefined