bs-community/skinview3d

Head Bobbing change

Closed this issue · 2 comments

Make Head Bobbing a separate setting from the animations for people who don’t want head bobbing.

I nearly suggested this in a separate issue. The head bobbing may look good in some situations, but it can look a bit out of place.

You can use this lambda expression as a temporary workaround:

(player, time) => {
	const skin = player.skin;

	// Multiply by animation's natural speed
	time *= 8;

	// Leg swing
	skin.leftLeg.rotation.x = Math.sin(time) * 0.5;
	skin.rightLeg.rotation.x = Math.sin(time + Math.PI) * 0.5;

	// Arm swing
	skin.leftArm.rotation.x = Math.sin(time + Math.PI) * 0.5;
	skin.rightArm.rotation.x = Math.sin(time) * 0.5;
	const basicArmRotationZ = Math.PI * 0.02;
	skin.leftArm.rotation.z = Math.cos(time) * 0.03 + basicArmRotationZ;
	skin.rightArm.rotation.z = Math.cos(time + Math.PI) * 0.03 - basicArmRotationZ;

	// Head shaking with different frequency & amplitude
	// skin.head.rotation.y = Math.sin(time / 4) * 0.2;
	// skin.head.rotation.x = Math.sin(time / 5) * 0.1;

	// Always add an angle for cape around the x axis
	const basicCapeRotationX = Math.PI * 0.06;
	player.cape.rotation.x = Math.sin(time / 1.5) * 0.06 + basicCapeRotationX;
}

Just use it in place of skinview3d.WalkingAnimation. I just commented out the parts we don't want.

Implemented in v3.0.0-alpha.1. You can now use:

skinViewer.animation = new WalkingAnimation();
skinViewer.animation.headBobbing = false;