src/core/SpawningManager.js
/**
	* Inits the collectable weapons.
	*
	* @return {SpawningManager} A reference to this spawning manager.
	*/
Inits the collectable weapons.
@return {SpawningManager} A reference to this spawning manager.
Inits the collectable weapons . @return { SpawningManager } A reference to this spawning manager .
initWeapons() {
		const world = this.world;
		const assetManager = world.assetManager;
		for ( let spawningPoint of this.blasterSpawningPoints ) {
			const blasterItem = new WeaponItem( WEAPON_TYPES_BLASTER, CONFIG.BLASTER.RESPAWN_TIME, CONFIG.BLASTER.AMMO );
			blasterItem.position.copy( spawningPoint );
			const renderComponent = assetManager.models.get( 'blaster_low' ).clone();
			renderComponent.position.copy( blasterItem.position );
			blasterItem.setRenderComponent( renderComponent, sync );
			this.blasters.push( blasterItem );
			world.add( blasterItem );
			blasterItem.currentRegion = world.navMesh.getRegionForPoint( blasterItem.position, 1 );
			const audio = assetManager.cloneAudio( assetManager.audios.get( 'ammo' ) );
			blasterItem.audio = audio;
			audio.setVolume( 0.5 );
			renderComponent.add( audio );
			this.createTrigger( blasterItem, CONFIG.BLASTER.RADIUS );
		}
		for ( let spawningPoint of this.shotgunSpawningPoints ) {
			const shotgunItem = new WeaponItem( WEAPON_TYPES_SHOTGUN, CONFIG.SHOTGUN.RESPAWN_TIME, CONFIG.SHOTGUN.AMMO );
			shotgunItem.position.copy( spawningPoint );
			const renderComponent = assetManager.models.get( 'shotgun_low' ).clone();
			renderComponent.position.copy( shotgunItem.position );
			shotgunItem.setRenderComponent( renderComponent, sync );
			this.shotguns.push( shotgunItem );
			world.add( shotgunItem );
			shotgunItem.currentRegion = world.navMesh.getRegionForPoint( shotgunItem.position, 1 );
			const audio = assetManager.cloneAudio( assetManager.audios.get( 'ammo' ) );
			shotgunItem.audio = audio;
			audio.setVolume( 0.5 );
			renderComponent.add( audio );
			this.createTrigger( shotgunItem, CONFIG.SHOTGUN.RADIUS );
		}
		for ( let spawningPoint of this.assaultRilflesSpawningPoints ) {
			const assaultRilfleItem = new WeaponItem( WEAPON_TYPES_ASSAULT_RIFLE, CONFIG.ASSAULT_RIFLE.RESPAWN_TIME, CONFIG.ASSAULT_RIFLE.AMMO );
			assaultRilfleItem.position.copy( spawningPoint );
			const renderComponent = assetManager.models.get( 'assaultRifle_low' ).clone();
			renderComponent.position.copy( assaultRilfleItem.position );
			assaultRilfleItem.setRenderComponent( renderComponent, sync );
			this.assaultRilfles.push( assaultRilfleItem );
			this.world.add( assaultRilfleItem );
			assaultRilfleItem.currentRegion = world.navMesh.getRegionForPoint( assaultRilfleItem.position, 1 );
			const audio = assetManager.cloneAudio( assetManager.audios.get( 'ammo' ) );
			audio.setVolume( 0.5 );
			assaultRilfleItem.audio = audio;
			renderComponent.add( audio );
			this.createTrigger( assaultRilfleItem, CONFIG.ASSAULT_RIFLE.RADIUS );
		}
		return this;
	}
initWeapons ( ) { const world = this . world ; const assetManager = world . assetManager ; for ( let spawningPoint of this . blasterSpawningPoints ) { const blasterItem = new WeaponItem ( WEAPON_TYPES_BLASTER , CONFIG . BLASTER . RESPAWN_TIME , CONFIG . BLASTER . AMMO ) ; blasterItem . position . copy ( spawningPoint ) ; const renderComponent = assetManager . models . get ( 'blaster_low' ) . clone ( ) ; renderComponent . position . copy ( blasterItem . position ) ; blasterItem . setRenderComponent ( renderComponent , sync ) ; this . blasters . push ( blasterItem ) ; world . add ( blasterItem ) ; blasterItem . currentRegion = world . navMesh . getRegionForPoint ( blasterItem . position , 1 ) ; const audio = assetManager . cloneAudio ( assetManager . audios . get ( 'ammo' ) ) ; blasterItem . audio = audio ; audio . setVolume ( 0.5 ) ; renderComponent . add ( audio ) ; this . createTrigger ( blasterItem , CONFIG . BLASTER . RADIUS ) ; } for ( let spawningPoint of this . shotgunSpawningPoints ) { const shotgunItem = new WeaponItem ( WEAPON_TYPES_SHOTGUN , CONFIG . SHOTGUN . RESPAWN_TIME , CONFIG . SHOTGUN . AMMO ) ; shotgunItem . position . copy ( spawningPoint ) ; const renderComponent = assetManager . models . get ( 'shotgun_low' ) . clone ( ) ; renderComponent . position . copy ( shotgunItem . position ) ; shotgunItem . setRenderComponent ( renderComponent , sync ) ; this . shotguns . push ( shotgunItem ) ; world . add ( shotgunItem ) ; shotgunItem . currentRegion = world . navMesh . getRegionForPoint ( shotgunItem . position , 1 ) ; const audio = assetManager . cloneAudio ( assetManager . audios . get ( 'ammo' ) ) ; shotgunItem . audio = audio ; audio . setVolume ( 0.5 ) ; renderComponent . add ( audio ) ; this . createTrigger ( shotgunItem , CONFIG . SHOTGUN . RADIUS ) ; } for ( let spawningPoint of this . assaultRilflesSpawningPoints ) { const assaultRilfleItem = new WeaponItem ( WEAPON_TYPES_ASSAULT_RIFLE , CONFIG . ASSAULT_RIFLE . RESPAWN_TIME , CONFIG . ASSAULT_RIFLE . AMMO ) ; assaultRilfleItem . position . copy ( spawningPoint ) ; const renderComponent = assetManager . models . get ( 'assaultRifle_low' ) . clone ( ) ; renderComponent . position . copy ( assaultRilfleItem . position ) ; assaultRilfleItem . setRenderComponent ( renderComponent , sync ) ; this . assaultRilfles . push ( assaultRilfleItem ) ; this . world . add ( assaultRilfleItem ) ; assaultRilfleItem . currentRegion = world . navMesh . getRegionForPoint ( assaultRilfleItem . position , 1 ) ; const audio = assetManager . cloneAudio ( assetManager . audios . get ( 'ammo' ) ) ; audio . setVolume ( 0.5 ) ; assaultRilfleItem . audio = audio ; renderComponent . add ( audio ) ; this . createTrigger ( assaultRilfleItem , CONFIG . ASSAULT_RIFLE . RADIUS ) ; } return this ; }
Inits the collectable weapons.
Inits the collectable weapons .
// blaster item // navigation // audio // trigger // shotgun item // navigation // audio // trigger // assault rifle item // navigation // audio // trigger