src/core/WeaponSystem.js
/**
	* Inits the render components for the shotgun.
	*
	* @return {WeaponSystem} A reference to this weapon system.
	*/
Inits the render components for the shotgun.
@return {WeaponSystem} A reference to this weapon system.
Inits the render components for the shotgun . @return { WeaponSystem } A reference to this weapon system .
_initShotgunRenderComponent() {
		const assetManager = this.owner.world.assetManager;
		let shotgunMesh;
		if ( this.owner.isPlayer === false ) {
			shotgunMesh = assetManager.models.get( 'shotgun_low' ).clone();
			shotgunMesh.scale.set( 100, 100, 100 );
			shotgunMesh.rotation.set( Math.PI * 0.5, Math.PI * 1.05, 0 );
			shotgunMesh.position.set( - 5, 30, 2 );
			shotgunMesh.updateMatrix();
			const rightHand = this.owner._renderComponent.getObjectByName( 'Armature_mixamorigRightHand' );
			rightHand.add( shotgunMesh );
		} else {
			shotgunMesh = assetManager.models.get( 'shotgun_high' );
			this.owner.world.scene.add( shotgunMesh );
		}
		const muzzleSprite = assetManager.models.get( 'muzzle' ).clone();
		muzzleSprite.material = muzzleSprite.material.clone();
		muzzleSprite.position.set( 0, 0.05, 0.3 );
		muzzleSprite.scale.set( 0.4, 0.4, 0.4 );
		muzzleSprite.updateMatrix();
		shotgunMesh.add( muzzleSprite );
		const shot = assetManager.cloneAudio( assetManager.audios.get( 'shotgun_shot' ) );
		shot.setRolloffFactor( 0.5 );
		shot.setVolume( 0.4 );
		shotgunMesh.add( shot );
		const reload = assetManager.cloneAudio( assetManager.audios.get( 'reload' ) );
		reload.setVolume( 0.1 );
		shotgunMesh.add( reload );
		const shotReload = assetManager.cloneAudio( assetManager.audios.get( 'shotgun_shot_reload' ) );
		shotReload.setVolume( 0.1 );
		shotgunMesh.add( shotReload );
		this.renderComponents.shotgun.mesh = shotgunMesh;
		this.renderComponents.shotgun.audios.set( 'shot', shot );
		this.renderComponents.shotgun.audios.set( 'reload', reload );
		this.renderComponents.shotgun.audios.set( 'shot_reload', shotReload );
		this.renderComponents.shotgun.muzzle = muzzleSprite;
		return this;
	}
_initShotgunRenderComponent ( ) { const assetManager = this . owner . world . assetManager ; let shotgunMesh ; if ( this . owner . isPlayer === false ) { shotgunMesh = assetManager . models . get ( 'shotgun_low' ) . clone ( ) ; shotgunMesh . scale . set ( 100 , 100 , 100 ) ; shotgunMesh . rotation . set ( Math . PI * 0.5 , Math . PI * 1.05 , 0 ) ; shotgunMesh . position . set ( - 5 , 30 , 2 ) ; shotgunMesh . updateMatrix ( ) ; const rightHand = this . owner . _renderComponent . getObjectByName ( 'Armature_mixamorigRightHand' ) ; rightHand . add ( shotgunMesh ) ; } else { shotgunMesh = assetManager . models . get ( 'shotgun_high' ) ; this . owner . world . scene . add ( shotgunMesh ) ; } const muzzleSprite = assetManager . models . get ( 'muzzle' ) . clone ( ) ; muzzleSprite . material = muzzleSprite . material . clone ( ) ; muzzleSprite . position . set ( 0 , 0.05 , 0.3 ) ; muzzleSprite . scale . set ( 0.4 , 0.4 , 0.4 ) ; muzzleSprite . updateMatrix ( ) ; shotgunMesh . add ( muzzleSprite ) ; const shot = assetManager . cloneAudio ( assetManager . audios . get ( 'shotgun_shot' ) ) ; shot . setRolloffFactor ( 0.5 ) ; shot . setVolume ( 0.4 ) ; shotgunMesh . add ( shot ) ; const reload = assetManager . cloneAudio ( assetManager . audios . get ( 'reload' ) ) ; reload . setVolume ( 0.1 ) ; shotgunMesh . add ( reload ) ; const shotReload = assetManager . cloneAudio ( assetManager . audios . get ( 'shotgun_shot_reload' ) ) ; shotReload . setVolume ( 0.1 ) ; shotgunMesh . add ( shotReload ) ; this . renderComponents . shotgun . mesh = shotgunMesh ; this . renderComponents . shotgun . audios . set ( 'shot' , shot ) ; this . renderComponents . shotgun . audios . set ( 'reload' , reload ) ; this . renderComponents . shotgun . audios . set ( 'shot_reload' , shotReload ) ; this . renderComponents . shotgun . muzzle = muzzleSprite ; return this ; }
Inits the render components for the shotgun.
Inits the render components for the shotgun .
// setup copy of shotgun 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