src/core/WeaponSystem.js
/**
	* Inits the render components for the assault rifle.
	*
	* @return {WeaponSystem} A reference to this weapon system.
	*/
Inits the render components for the assault rifle.
@return {WeaponSystem} A reference to this weapon system.
Inits the render components for the assault rifle . @return { WeaponSystem } A reference to this weapon system .
_initAssaultRifleRenderComponent() {
		const assetManager = this.owner.world.assetManager;
		let assaultRifleMesh;
		if ( this.owner.isPlayer === false ) {
			assaultRifleMesh = assetManager.models.get( 'assaultRifle_low' ).clone();
			assaultRifleMesh.scale.set( 100, 100, 100 );
			assaultRifleMesh.rotation.set( Math.PI * 0.5, Math.PI * 1, 0 );
			assaultRifleMesh.position.set( - 5, 20, 7 );
			assaultRifleMesh.updateMatrix();
			const rightHand = this.owner._renderComponent.getObjectByName( 'Armature_mixamorigRightHand' );
			rightHand.add( assaultRifleMesh );
		} else {
			assaultRifleMesh = assetManager.models.get( 'assaultRifle_high' );
			this.owner.world.scene.add( assaultRifleMesh );
		}
		const muzzleSprite = assetManager.models.get( 'muzzle' ).clone();
		muzzleSprite.material = muzzleSprite.material.clone();
		muzzleSprite.position.set( 0, 0, 0.5 );
		muzzleSprite.scale.set( 0.4, 0.4, 0.4 );
		muzzleSprite.updateMatrix();
		assaultRifleMesh.add( muzzleSprite );
		const shot = assetManager.cloneAudio( assetManager.audios.get( 'assault_rifle_shot' ) );
		shot.setRolloffFactor( 0.5 );
		shot.setVolume( 0.8 );
		assaultRifleMesh.add( shot );
		const reload = assetManager.cloneAudio( assetManager.audios.get( 'reload' ) );
		reload.setVolume( 0.1 );
		assaultRifleMesh.add( reload );
		this.renderComponents.assaultRifle.mesh = assaultRifleMesh;
		this.renderComponents.assaultRifle.audios.set( 'shot', shot );
		this.renderComponents.assaultRifle.audios.set( 'reload', reload );
		this.renderComponents.assaultRifle.muzzle = muzzleSprite;
		return this;
	}
_initAssaultRifleRenderComponent ( ) { const assetManager = this . owner . world . assetManager ; let assaultRifleMesh ; if ( this . owner . isPlayer === false ) { assaultRifleMesh = assetManager . models . get ( 'assaultRifle_low' ) . clone ( ) ; assaultRifleMesh . scale . set ( 100 , 100 , 100 ) ; assaultRifleMesh . rotation . set ( Math . PI * 0.5 , Math . PI * 1 , 0 ) ; assaultRifleMesh . position . set ( - 5 , 20 , 7 ) ; assaultRifleMesh . updateMatrix ( ) ; const rightHand = this . owner . _renderComponent . getObjectByName ( 'Armature_mixamorigRightHand' ) ; rightHand . add ( assaultRifleMesh ) ; } else { assaultRifleMesh = assetManager . models . get ( 'assaultRifle_high' ) ; this . owner . world . scene . add ( assaultRifleMesh ) ; } const muzzleSprite = assetManager . models . get ( 'muzzle' ) . clone ( ) ; muzzleSprite . material = muzzleSprite . material . clone ( ) ; muzzleSprite . position . set ( 0 , 0 , 0.5 ) ; muzzleSprite . scale . set ( 0.4 , 0.4 , 0.4 ) ; muzzleSprite . updateMatrix ( ) ; assaultRifleMesh . add ( muzzleSprite ) ; const shot = assetManager . cloneAudio ( assetManager . audios . get ( 'assault_rifle_shot' ) ) ; shot . setRolloffFactor ( 0.5 ) ; shot . setVolume ( 0.8 ) ; assaultRifleMesh . add ( shot ) ; const reload = assetManager . cloneAudio ( assetManager . audios . get ( 'reload' ) ) ; reload . setVolume ( 0.1 ) ; assaultRifleMesh . add ( reload ) ; this . renderComponents . assaultRifle . mesh = assaultRifleMesh ; this . renderComponents . assaultRifle . audios . set ( 'shot' , shot ) ; this . renderComponents . assaultRifle . audios . set ( 'reload' , reload ) ; this . renderComponents . assaultRifle . muzzle = muzzleSprite ; return this ; }
Inits the render components for the assault rifle.
Inits the render components for the assault rifle .
// setup copy of assault rifle mesh // pick the low resolution model for the enemies // add the mesh to the right hand of the enemy // add muzzle sprite // add positional audios // store this configuration