src/core/World.js
/**
	* Creates the actual level.
	*
	* @return {World} A reference to this world object.
	*/
Creates the actual level.
@return {World} A reference to this world object.
Creates the actual level . @return { World } A reference to this world object .
_initLevel() {
		const renderComponent = this.assetManager.models.get( 'level' );
		const mesh = renderComponent.getObjectByName( 'level' );
		const vertices = mesh.geometry.attributes.position.array;
		const indices = mesh.geometry.index.array;
		const geometry = new MeshGeometry( vertices, indices );
		const level = new Level( geometry );
		level.name = 'level';
		level.setRenderComponent( renderComponent, sync );
		this.add( level );
		this.navMesh = this.assetManager.navMesh;
		this.costTable = this.assetManager.costTable;
		const levelConfig = this.assetManager.configs.get( 'level' );
		const width = levelConfig.spatialIndex.width;
		const height = levelConfig.spatialIndex.height;
		const depth = levelConfig.spatialIndex.depth;
		const cellsX = levelConfig.spatialIndex.cellsX;
		const cellsY = levelConfig.spatialIndex.cellsY;
		const cellsZ = levelConfig.spatialIndex.cellsZ;
		this.navMesh.spatialIndex = new CellSpacePartitioning( width, height, depth, cellsX, cellsY, cellsZ );
		this.navMesh.updateSpatialIndex();
		this.helpers.spatialIndexHelper = NavMeshUtils.createCellSpaceHelper( this.navMesh.spatialIndex );
		this.scene.add( this.helpers.spatialIndexHelper );
		this.spawningManager.init();
		if ( this.debug ) {
			this.helpers.convexRegionHelper = NavMeshUtils.createConvexRegionHelper( this.navMesh );
			this.scene.add( this.helpers.convexRegionHelper );
			this.helpers.graphHelper = NavMeshUtils.createGraphHelper( this.navMesh.graph, 0.2 );
			this.scene.add( this.helpers.graphHelper );
			this.helpers.spawnHelpers = SceneUtils.createSpawnPointHelper( this.spawningManager.spawningPoints );
			this.scene.add( this.helpers.spawnHelpers );
		}
		return this;
	}
_initLevel ( ) { const renderComponent = this . assetManager . models . get ( 'level' ) ; const mesh = renderComponent . getObjectByName ( 'level' ) ; const vertices = mesh . geometry . attributes . position . array ; const indices = mesh . geometry . index . array ; const geometry = new MeshGeometry ( vertices , indices ) ; const level = new Level ( geometry ) ; level . name = 'level' ; level . setRenderComponent ( renderComponent , sync ) ; this . add ( level ) ; this . navMesh = this . assetManager . navMesh ; this . costTable = this . assetManager . costTable ; const levelConfig = this . assetManager . configs . get ( 'level' ) ; const width = levelConfig . spatialIndex . width ; const height = levelConfig . spatialIndex . height ; const depth = levelConfig . spatialIndex . depth ; const cellsX = levelConfig . spatialIndex . cellsX ; const cellsY = levelConfig . spatialIndex . cellsY ; const cellsZ = levelConfig . spatialIndex . cellsZ ; this . navMesh . spatialIndex = new CellSpacePartitioning ( width , height , depth , cellsX , cellsY , cellsZ ) ; this . navMesh . updateSpatialIndex ( ) ; this . helpers . spatialIndexHelper = NavMeshUtils . createCellSpaceHelper ( this . navMesh . spatialIndex ) ; this . scene . add ( this . helpers . spatialIndexHelper ) ; this . spawningManager . init ( ) ; if ( this . debug ) { this . helpers . convexRegionHelper = NavMeshUtils . createConvexRegionHelper ( this . navMesh ) ; this . scene . add ( this . helpers . convexRegionHelper ) ; this . helpers . graphHelper = NavMeshUtils . createGraphHelper ( this . navMesh . graph , 0.2 ) ; this . scene . add ( this . helpers . graphHelper ) ; this . helpers . spawnHelpers = SceneUtils . createSpawnPointHelper ( this . spawningManager . spawningPoints ) ; this . scene . add ( this . helpers . spawnHelpers ) ; } return this ; }
Creates the actual level.
Creates the actual level .
// level entity // navigation mesh // spatial index // init spawning points and items // debugging // //