src/etc/CharacterBounds.js
/**
	* Inits the bounding volumes of this instance.
	*
	* @return {CharacterBounds} A reference to this instance.
	*/
Inits the bounding volumes of this instance.
@return {CharacterBounds} A reference to this instance.
Inits the bounding volumes of this instance . @return { CharacterBounds } A reference to this instance .
init() {
		this._outerHitboxDefinition.set( new Vector3( - 0.5, 0, - 0.5 ), new Vector3( 0.5, 1.8, 0.5 ) );
		const owner = this.owner;
		const renderComponent = owner._renderComponent;
		const hitboxes = this._innerHitboxes;
		renderComponent.updateMatrixWorld( true );
		const headBone = renderComponent.getObjectByName( 'Armature_mixamorigHead' );
		const head = new AABB( new Vector3( - 0.1, 1.6, - 0.1 ), new Vector3( 0.1, 1.8, 0.1 ) );
		let bindMatrix = new Matrix4().copy( headBone.matrixWorld );
		let bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: head, bone: headBone, bindMatrix: bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		const spineBone = renderComponent.getObjectByName( 'Armature_mixamorigSpine1' );
		const spine = new AABB( new Vector3( - 0.2, 1, - 0.2 ), new Vector3( 0.2, 1.6, 0.2 ) );
		bindMatrix = new Matrix4().copy( spineBone.matrixWorld );
		bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: spine, bone: spineBone, bindMatrix: bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		const rightArmBone = renderComponent.getObjectByName( 'Armature_mixamorigRightArm' );
		const rightArm = new AABB( new Vector3( - 0.4, 1.42, - 0.15 ), new Vector3( - 0.2, 1.58, 0.1 ) );
		bindMatrix = new Matrix4().copy( rightArmBone.matrixWorld );
		bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: rightArm, bone: rightArmBone, bindMatrix: bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		const rightForeArmBone = renderComponent.getObjectByName( 'Armature_mixamorigRightForeArm' );
		const rightForeArm = new AABB( new Vector3( - 0.8, 1.42, - 0.15 ), new Vector3( - 0.4, 1.55, 0.05 ) );
		bindMatrix = new Matrix4().copy( rightForeArmBone.matrixWorld );
		bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: rightForeArm, bone: rightForeArmBone, bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		const leftArmBone = renderComponent.getObjectByName( 'Armature_mixamorigLeftArm' );
		const leftArm = new AABB( new Vector3( 0.2, 1.42, - 0.15 ), new Vector3( 0.4, 1.58, 0.1 ) );
		bindMatrix = new Matrix4().copy( leftArmBone.matrixWorld );
		bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: leftArm, bone: leftArmBone, bindMatrix: bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		const leftForeArmBone = renderComponent.getObjectByName( 'Armature_mixamorigLeftForeArm' );
		const leftForeArm = new AABB( new Vector3( 0.4, 1.42, - 0.15 ), new Vector3( 0.8, 1.55, 0.05 ) );
		bindMatrix = new Matrix4().copy( leftForeArmBone.matrixWorld );
		bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: leftForeArm, bone: leftForeArmBone, bindMatrix: bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		const rightUpLegBone = renderComponent.getObjectByName( 'Armature_mixamorigRightUpLeg' );
		const rightUpLeg = new AABB( new Vector3( - 0.2, 0.6, - 0.15 ), new Vector3( 0, 1, 0.15 ) );
		bindMatrix = new Matrix4().copy( rightUpLegBone.matrixWorld );
		bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: rightUpLeg, bone: rightUpLegBone, bindMatrix: bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		const rightLegBone = renderComponent.getObjectByName( 'Armature_mixamorigRightLeg' );
		const rightLeg = new AABB( new Vector3( - 0.2, 0, - 0.15 ), new Vector3( 0, 0.6, 0.15 ) );
		bindMatrix = new Matrix4().copy( rightLegBone.matrixWorld );
		bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: rightLeg, bone: rightLegBone, bindMatrix: bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		const leftUpLegBone = renderComponent.getObjectByName( 'Armature_mixamorigLeftUpLeg' );
		const leftUpLeg = new AABB( new Vector3( 0, 0.6, - 0.15 ), new Vector3( 0.2, 1, 0.15 ) );
		bindMatrix = new Matrix4().copy( leftUpLegBone.matrixWorld );
		bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: leftUpLeg, bone: leftUpLegBone, bindMatrix: bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		const leftLegBone = renderComponent.getObjectByName( 'Armature_mixamorigLeftLeg' );
		const leftLeg = new AABB( new Vector3( 0, 0, - 0.15 ), new Vector3( 0.2, 0.6, 0.15 ) );
		bindMatrix = new Matrix4().copy( leftLegBone.matrixWorld );
		bindMatrixInverse = new Matrix4().getInverse( bindMatrix );
		hitboxes.push( { aabb: leftLeg, bone: leftLegBone, bindMatrix: bindMatrix, bindMatrixInverse: bindMatrixInverse } );
		 debugging the AABBs requires the skeleton the be in bind pose at the origin
		 for ( let i = 0, l = hitboxes.length; i < l; i ++ ) {
		 	const hitbox = hitboxes[ i ];
		 	const hitboxHelper = SceneUtils.createHitboxHelper( hitbox.aabb );
		 	this.owner.world.scene.add( hitboxHelper );
		 }
		return this;
	}
init ( ) { this . _outerHitboxDefinition . set ( new Vector3 ( - 0.5 , 0 , - 0.5 ) , new Vector3 ( 0.5 , 1.8 , 0.5 ) ) ; const owner = this . owner ; const renderComponent = owner . _renderComponent ; const hitboxes = this . _innerHitboxes ; renderComponent . updateMatrixWorld ( true ) ; const headBone = renderComponent . getObjectByName ( 'Armature_mixamorigHead' ) ; const head = new AABB ( new Vector3 ( - 0.1 , 1.6 , - 0.1 ) , new Vector3 ( 0.1 , 1.8 , 0.1 ) ) ; let bindMatrix = new Matrix4 ( ) . copy ( headBone . matrixWorld ) ; let bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : head , bone : headBone , bindMatrix : bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; const spineBone = renderComponent . getObjectByName ( 'Armature_mixamorigSpine1' ) ; const spine = new AABB ( new Vector3 ( - 0.2 , 1 , - 0.2 ) , new Vector3 ( 0.2 , 1.6 , 0.2 ) ) ; bindMatrix = new Matrix4 ( ) . copy ( spineBone . matrixWorld ) ; bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : spine , bone : spineBone , bindMatrix : bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; const rightArmBone = renderComponent . getObjectByName ( 'Armature_mixamorigRightArm' ) ; const rightArm = new AABB ( new Vector3 ( - 0.4 , 1.42 , - 0.15 ) , new Vector3 ( - 0.2 , 1.58 , 0.1 ) ) ; bindMatrix = new Matrix4 ( ) . copy ( rightArmBone . matrixWorld ) ; bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : rightArm , bone : rightArmBone , bindMatrix : bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; const rightForeArmBone = renderComponent . getObjectByName ( 'Armature_mixamorigRightForeArm' ) ; const rightForeArm = new AABB ( new Vector3 ( - 0.8 , 1.42 , - 0.15 ) , new Vector3 ( - 0.4 , 1.55 , 0.05 ) ) ; bindMatrix = new Matrix4 ( ) . copy ( rightForeArmBone . matrixWorld ) ; bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : rightForeArm , bone : rightForeArmBone , bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; const leftArmBone = renderComponent . getObjectByName ( 'Armature_mixamorigLeftArm' ) ; const leftArm = new AABB ( new Vector3 ( 0.2 , 1.42 , - 0.15 ) , new Vector3 ( 0.4 , 1.58 , 0.1 ) ) ; bindMatrix = new Matrix4 ( ) . copy ( leftArmBone . matrixWorld ) ; bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : leftArm , bone : leftArmBone , bindMatrix : bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; const leftForeArmBone = renderComponent . getObjectByName ( 'Armature_mixamorigLeftForeArm' ) ; const leftForeArm = new AABB ( new Vector3 ( 0.4 , 1.42 , - 0.15 ) , new Vector3 ( 0.8 , 1.55 , 0.05 ) ) ; bindMatrix = new Matrix4 ( ) . copy ( leftForeArmBone . matrixWorld ) ; bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : leftForeArm , bone : leftForeArmBone , bindMatrix : bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; const rightUpLegBone = renderComponent . getObjectByName ( 'Armature_mixamorigRightUpLeg' ) ; const rightUpLeg = new AABB ( new Vector3 ( - 0.2 , 0.6 , - 0.15 ) , new Vector3 ( 0 , 1 , 0.15 ) ) ; bindMatrix = new Matrix4 ( ) . copy ( rightUpLegBone . matrixWorld ) ; bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : rightUpLeg , bone : rightUpLegBone , bindMatrix : bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; const rightLegBone = renderComponent . getObjectByName ( 'Armature_mixamorigRightLeg' ) ; const rightLeg = new AABB ( new Vector3 ( - 0.2 , 0 , - 0.15 ) , new Vector3 ( 0 , 0.6 , 0.15 ) ) ; bindMatrix = new Matrix4 ( ) . copy ( rightLegBone . matrixWorld ) ; bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : rightLeg , bone : rightLegBone , bindMatrix : bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; const leftUpLegBone = renderComponent . getObjectByName ( 'Armature_mixamorigLeftUpLeg' ) ; const leftUpLeg = new AABB ( new Vector3 ( 0 , 0.6 , - 0.15 ) , new Vector3 ( 0.2 , 1 , 0.15 ) ) ; bindMatrix = new Matrix4 ( ) . copy ( leftUpLegBone . matrixWorld ) ; bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : leftUpLeg , bone : leftUpLegBone , bindMatrix : bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; const leftLegBone = renderComponent . getObjectByName ( 'Armature_mixamorigLeftLeg' ) ; const leftLeg = new AABB ( new Vector3 ( 0 , 0 , - 0.15 ) , new Vector3 ( 0.2 , 0.6 , 0.15 ) ) ; bindMatrix = new Matrix4 ( ) . copy ( leftLegBone . matrixWorld ) ; bindMatrixInverse = new Matrix4 ( ) . getInverse ( bindMatrix ) ; hitboxes . push ( { aabb : leftLeg , bone : leftLegBone , bindMatrix : bindMatrix , bindMatrixInverse : bindMatrixInverse } ) ; return this ; }
Inits the bounding volumes of this instance.
Inits the bounding volumes of this instance .
// skeleton based AABBs // ensure world matrices are up to date // head and torso // arms // legs // // debugging the AABBs requires the skeleton the be in bind pose at the origin // for ( let i = 0, l = hitboxes.length; i < l; i ++ ) { // 	const hitbox = hitboxes[ i ]; // 	const hitboxHelper = SceneUtils.createHitboxHelper( hitbox.aabb ); // 	this.owner.world.scene.add( hitboxHelper ); // }