src/core/World.js
/**
	* Creates a specific amount of enemies.
	*
	* @return {World} A reference to this world object.
	*/
Creates a specific amount of enemies.
@return {World} A reference to this world object.
Creates a specific amount of enemies . @return { World } A reference to this world object .
_initEnemies() {
		const enemyCount = this.enemyCount;
		const navMesh = this.assetManager.navMesh;
		this.pathPlanner = new PathPlanner( navMesh );
		for ( let i = 0; i < enemyCount; i ++ ) {
			const renderComponent = SceneUtils.cloneWithSkinning( this.assetManager.models.get( 'soldier' ) );
			const enemy = new Enemy( this );
			enemy.name = 'Bot' + i;
			enemy.setRenderComponent( renderComponent, sync );
			const mixer = new AnimationMixer( renderComponent );
			const idleClip = this.assetManager.animations.get( 'soldier_idle' );
			const runForwardClip = this.assetManager.animations.get( 'soldier_forward' );
			const runBackwardClip = this.assetManager.animations.get( 'soldier_backward' );
			const strafeLeftClip = this.assetManager.animations.get( 'soldier_left' );
			const strafeRightClip = this.assetManager.animations.get( 'soldier_right' );
			const death1Clip = this.assetManager.animations.get( 'soldier_death1' );
			const death2Clip = this.assetManager.animations.get( 'soldier_death2' );
			const clips = [ idleClip, runForwardClip, runBackwardClip, strafeLeftClip, strafeRightClip, death1Clip, death2Clip ];
			enemy.setAnimations( mixer, clips );
			this.add( enemy );
			this.competitors.push( enemy );
			this.spawningManager.respawnCompetitor( enemy );
			if ( this.debug ) {
				const pathHelper = NavMeshUtils.createPathHelper();
				enemy.pathHelper = pathHelper;
				this.scene.add( pathHelper );
				this.helpers.pathHelpers.push( pathHelper );
				const uuidHelper = SceneUtils.createUUIDLabel( enemy.uuid );
				uuidHelper.position.y = 2;
				uuidHelper.visible = false;
				renderComponent.add( uuidHelper );
				this.helpers.uuidHelpers.push( uuidHelper );
				const skeletonHelper = new SkeletonHelper( renderComponent );
				skeletonHelper.visible = false;
				this.scene.add( skeletonHelper );
				this.helpers.skeletonHelpers.push( skeletonHelper );
			}
		}
		return this;
	}
_initEnemies ( ) { const enemyCount = this . enemyCount ; const navMesh = this . assetManager . navMesh ; this . pathPlanner = new PathPlanner ( navMesh ) ; for ( let i = 0 ; i < enemyCount ; i ++ ) { const renderComponent = SceneUtils . cloneWithSkinning ( this . assetManager . models . get ( 'soldier' ) ) ; const enemy = new Enemy ( this ) ; enemy . name = 'Bot' + i ; enemy . setRenderComponent ( renderComponent , sync ) ; const mixer = new AnimationMixer ( renderComponent ) ; const idleClip = this . assetManager . animations . get ( 'soldier_idle' ) ; const runForwardClip = this . assetManager . animations . get ( 'soldier_forward' ) ; const runBackwardClip = this . assetManager . animations . get ( 'soldier_backward' ) ; const strafeLeftClip = this . assetManager . animations . get ( 'soldier_left' ) ; const strafeRightClip = this . assetManager . animations . get ( 'soldier_right' ) ; const death1Clip = this . assetManager . animations . get ( 'soldier_death1' ) ; const death2Clip = this . assetManager . animations . get ( 'soldier_death2' ) ; const clips = [ idleClip , runForwardClip , runBackwardClip , strafeLeftClip , strafeRightClip , death1Clip , death2Clip ] ; enemy . setAnimations ( mixer , clips ) ; this . add ( enemy ) ; this . competitors . push ( enemy ) ; this . spawningManager . respawnCompetitor ( enemy ) ; if ( this . debug ) { const pathHelper = NavMeshUtils . createPathHelper ( ) ; enemy . pathHelper = pathHelper ; this . scene . add ( pathHelper ) ; this . helpers . pathHelpers . push ( pathHelper ) ; const uuidHelper = SceneUtils . createUUIDLabel ( enemy . uuid ) ; uuidHelper . position . y = 2 ; uuidHelper . visible = false ; renderComponent . add ( uuidHelper ) ; this . helpers . uuidHelpers . push ( uuidHelper ) ; const skeletonHelper = new SkeletonHelper ( renderComponent ) ; skeletonHelper . visible = false ; this . scene . add ( skeletonHelper ) ; this . helpers . skeletonHelpers . push ( skeletonHelper ) ; } } return this ; }
Creates a specific amount of enemies.
Creates a specific amount of enemies .
// set animations // // // //