Skip to content

Commit

Permalink
feat: use nodenext standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Sceat committed Jan 16, 2025
1 parent 49ebe2d commit 7be7583
Show file tree
Hide file tree
Showing 34 changed files with 151 additions and 141 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.7.3",
"description": "Procedural voxel terrain generation for AresRPG",
"main": "dist/index.js",
"type": "module",
"scripts": {
"watch": "tsc --watch",
"build": "tsc",
Expand Down
16 changes: 8 additions & 8 deletions src/config/WorldEnv.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Vector2, Vector3 } from 'three'

import { ItemType } from '../factory/ItemsFactory'
import { BlockType } from '../procgen/Biome'
import { ProcItemConf } from '../tools/ProceduralGenerators'
import { SchematicsBlocksMapping } from '../tools/SchematicLoader'
import { BiomesRawConf, BlockMode } from '../utils/types'

// import { NoiseSamplerParams } from '../procgen/NoiseSampler'
// import { ProcLayerParams } from '../procgen/ProcLayer'
import { ItemType } from '../factory/ItemsFactory.js'
import { BlockType } from '../procgen/Biome.js'
import { ProcItemConf } from '../tools/ProceduralGenerators.js'
import { SchematicsBlocksMapping } from '../tools/SchematicLoader.js'
import { BiomesRawConf, BlockMode } from '../utils/types.js'

// import { NoiseSamplerParams } from '../procgen/NoiseSampler.js'
// import { ProcLayerParams } from '../procgen/ProcLayer.js'

export class WorldEnv {
// eslint-disable-next-line no-use-before-define
Expand Down
4 changes: 2 additions & 2 deletions src/config/demo-samples/configs/biome_landscapes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BiomeType, BlockType } from '../../../index'
import { BiomeType, BlockType } from '../../../index.js'

import { SCHEMATICS_COLLECTIONS } from './schematics_collections'
import { SCHEMATICS_COLLECTIONS } from './schematics_collections.js'

const { alpine, temperate_forest, siberian } = SCHEMATICS_COLLECTIONS

Expand Down
2 changes: 1 addition & 1 deletion src/config/demo-samples/configs/blocks_mappings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockType, WorldUtils } from '../../../index'
import { BlockType, WorldUtils } from '../../../index.js'

/**
* Extending world reserved blocks
Expand Down
2 changes: 1 addition & 1 deletion src/config/demo-samples/configs/procedural_items.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProcItemCategory, ProcItemType } from '../../../index'
import { ProcItemCategory, ProcItemType } from '../../../index.js'

export const proc_items = {
AppleTree_S: 'appletree_s',
Expand Down
10 changes: 5 additions & 5 deletions src/config/demo-samples/configs/world_dev_setup.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// import { SCHEMATICS_FILES_INDEX } from '../assets/schematics/index'
import { WorldEnv } from '../../../index'
// import { SCHEMATICS_FILES_INDEX } from '../assets/schematics/index.js'
import { WorldEnv } from '../../../index.js'

import { BIOMES_LANDSCAPES_CONFIG } from './biome_landscapes'
import { PROC_ITEMS_CONFIG } from './procedural_items'
import { BIOMES_LANDSCAPES_CONFIG } from './biome_landscapes.js'
import { PROC_ITEMS_CONFIG } from './procedural_items.js'
import {
BLOCKS_COLOR_MAPPING,
// ExtBlock,
SCHEMATICS_BLOCKS_MAPPING,
} from './blocks_mappings'
} from './blocks_mappings.js'

/**
* @param worldEnv provide it to setup worker's own env or it will default to main thread env
Expand Down
8 changes: 4 additions & 4 deletions src/datacontainers/ChunkContainer.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Vector2, Box3, Vector3 } from 'three'

import { BlockMode, ChunkId, ChunkKey } from '../utils/types'
import { BlockMode, ChunkId, ChunkKey } from '../utils/types.js'
import {
asVect3,
asChunkBounds,
parseChunkKey,
serializeChunkId,
parseThreeStub,
asVect2,
} from '../utils/convert'
import { WorldEnv } from '../config/WorldEnv'
import { BlockType } from '../index'
} from '../utils/convert.js'
import { WorldEnv } from '../config/WorldEnv.js'
import { BlockType } from '../index.js'

enum ChunkAxisOrder {
ZXY,
Expand Down
6 changes: 3 additions & 3 deletions src/datacontainers/PatchBase.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Vector2, Box2, Vector3 } from 'three'

import { PatchKey } from '../utils/types'
import { PatchKey } from '../utils/types.js'
import {
parsePatchKey,
asPatchBounds,
asVect2,
parseThreeStub,
} from '../utils/convert'
import { WorldEnv } from '../index'
} from '../utils/convert.js'
import { WorldEnv } from '../index.js'

// export class PatchChunkCommon<T> {

Expand Down
12 changes: 6 additions & 6 deletions src/factory/ChunksFactory.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { MathUtils, Vector3 } from 'three'

import { WorldEnv } from '../config/WorldEnv'
import { asVect2, serializePatchId, asBox2 } from '../utils/convert'
import { BlockMode, ChunkKey, PatchBlock } from '../utils/types'
import { WorldEnv } from '../config/WorldEnv.js'
import { asVect2, serializePatchId, asBox2 } from '../utils/convert.js'
import { BlockMode, ChunkKey, PatchBlock } from '../utils/types.js'
import {
ChunkBuffer,
ChunkContainer,
ChunkMask,
} from '../datacontainers/ChunkContainer'
import { BlockType, Biome, BiomeType, DensityVolume } from '../index'
import { GroundPatch, parseGroundFlags } from '../processing/GroundPatch'
} from '../datacontainers/ChunkContainer.js'
import { BlockType, Biome, BiomeType, DensityVolume } from '../index.js'
import { GroundPatch, parseGroundFlags } from '../processing/GroundPatch.js'

export class EmptyChunk extends ChunkContainer {
constructor(chunkKey: ChunkKey) {
Expand Down
8 changes: 4 additions & 4 deletions src/factory/ItemsFactory.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Box3, Vector3 } from 'three'

import { ChunkContainer } from '../datacontainers/ChunkContainer'
import { ProceduralItemGenerator } from '../tools/ProceduralGenerators'
import { SchematicLoader } from '../tools/SchematicLoader'
import { WorldEnv } from '../config/WorldEnv'
import { ChunkContainer } from '../datacontainers/ChunkContainer.js'
import { ProceduralItemGenerator } from '../tools/ProceduralGenerators.js'
import { SchematicLoader } from '../tools/SchematicLoader.js'
import { WorldEnv } from '../config/WorldEnv.js'

export type ItemType = string
export type SpawnedItems = Record<ItemType, Vector3[]>
Expand Down
40 changes: 20 additions & 20 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
// Utils
export * as WorldUtils from './utils/index'
export { BlockMode } from './utils/types'
export * as WorldUtils from './utils/index.js'
export { BlockMode } from './utils/types.js'
// Processing
export { ProcessingTask } from './processing/TaskProcessing'
export { BatchProcess } from './processing/BatchProcessing'
export { ProcessingTask } from './processing/TaskProcessing.js'
export { BatchProcess } from './processing/BatchProcessing.js'
export {
BlocksProcessing,
BlocksProcessingRecipe,
BlockProcessor,
} from './processing/BlocksProcessing'
export { BoardProcessor, BlockCategory } from './processing/BoardProcessing'
} from './processing/BlocksProcessing.js'
export { BoardProcessor, BlockCategory } from './processing/BoardProcessing.js'
export {
ViewChunksBatch,
LowerChunksBatch,
UpperChunksBatch,
} from './processing/ChunksBatch'
} from './processing/ChunksBatch.js'
export {
PseudoDistributionMap,
DistributionProfile,
} from './processing/RandomDistributionMap'
export { ChunksProcessor } from './processing/ChunksProcessing'
} from './processing/RandomDistributionMap.js'
export { ChunksProcessor } from './processing/ChunksProcessing.js'
// Procgen
export { Biome, BiomeType, BlockType } from './procgen/Biome'
export { Heightmap } from './procgen/Heightmap'
export { DensityVolume } from './procgen/DensityVolume'
export { Biome, BiomeType, BlockType } from './procgen/Biome.js'
export { Heightmap } from './procgen/Heightmap.js'
export { DensityVolume } from './procgen/DensityVolume.js'
// Data structures
// export { GroundContainer, GroundCache } from './datacontainers/PatchesIndexer'
export { ChunkContainer } from './datacontainers/ChunkContainer'
export { ChunkContainer } from './datacontainers/ChunkContainer.js'
// Factory
export { ItemsInventory } from './factory/ItemsFactory'
export { GroundChunk, EmptyChunk, CavesMask } from './factory/ChunksFactory'
export { ItemsInventory } from './factory/ItemsFactory.js'
export { GroundChunk, EmptyChunk, CavesMask } from './factory/ChunksFactory.js'
// Tools
export { SchematicLoader } from './tools/SchematicLoader'
export { SchematicLoader } from './tools/SchematicLoader.js'
export {
ProceduralItemGenerator,
ProcItemType,
ProcItemCategory,
} from './tools/ProceduralGenerators'
// export * as ProceduralGenerators from './tools/ProceduralGenerators'
} from './tools/ProceduralGenerators.js'
// export * as ProceduralGenerators from './tools/ProceduralGenerators.js'
// Config
export { WorldEnv } from './config/WorldEnv'
export * as WorldDevSetup from './config/demo-samples/configs/world_dev_setup'
export { WorldEnv } from './config/WorldEnv.js'
export * as WorldDevSetup from './config/demo-samples/configs/world_dev_setup.js'
2 changes: 1 addition & 1 deletion src/processing/BatchProcessing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProcessingState, ProcessingTask } from './TaskProcessing'
import { ProcessingState, ProcessingTask } from './TaskProcessing.js'

export class BatchProcess<T extends ProcessingTask> {
// eslint-disable-next-line no-use-before-define
Expand Down
18 changes: 9 additions & 9 deletions src/processing/BoardProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ import {
getPatchId,
getUpperScalarId,
serializePatchId,
} from '../utils/convert'
} from '../utils/convert.js'
import {
WorldEnv,
ChunkContainer,
BatchProcess,
ChunksProcessor,
BlockType,
} from '../index'
import { ProcLayer } from '../procgen/ProcLayer'
import { BlockMode, ChunkId, PatchKey } from '../utils/types'
} from '../index.js'
import { ProcLayer } from '../procgen/ProcLayer.js'
import { BlockMode, ChunkId, PatchKey } from '../utils/types.js'
import {
DataContainer,
PatchBase,
PatchElement,
} from '../datacontainers/PatchBase'
import { copySourceToTargetPatch } from '../utils/data'
} from '../datacontainers/PatchBase.js'
import { copySourceToTargetPatch } from '../utils/data.js'

import {
ItemsBaker,
ItemsProcessingParams,
ItemsProcessingRecipes,
} from './ItemsProcessing'
import { ProcessingTask } from './TaskProcessing'
import { ChunksProcessingParams } from './ChunksProcessing'
} from './ItemsProcessing.js'
import { ProcessingTask } from './TaskProcessing.js'
import { ChunksProcessingParams } from './ChunksProcessing.js'
// import { UndegroundChunkset } from './ChunksProcessing'

export enum BlockCategory {
Expand Down
10 changes: 5 additions & 5 deletions src/processing/ChunksBatch.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Box2, Vector2 } from 'three'

import { serializePatchId } from '../utils/convert'
import { PatchKey } from '../utils/types'
import { serializePatchId } from '../utils/convert.js'
import { PatchKey } from '../utils/types.js'

import { BatchProcess } from './BatchProcessing'
import { BatchProcess } from './BatchProcessing.js'
import {
ChunksProcessor,
lowerChunksProcessingParams,
upperChunksProcessingParams,
} from './ChunksProcessing'
import { ProcessingState } from './TaskProcessing'
} from './ChunksProcessing.js'
import { ProcessingState } from './TaskProcessing.js'

// const { patchSize, patchDimensions } = WorldEnv.current

Expand Down
16 changes: 8 additions & 8 deletions src/processing/ChunksProcessing.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { Vector2 } from 'three'

import { WorldEnv } from '../config/WorldEnv'
import { WorldEnv } from '../config/WorldEnv.js'
import {
parsePatchKey,
asVect3,
serializeChunkId,
asPatchBounds,
} from '../utils/convert'
import { ChunkIndex, PatchId, PatchKey } from '../utils/types'
} from '../utils/convert.js'
import { ChunkIndex, PatchId, PatchKey } from '../utils/types.js'
import {
ChunkContainer,
ChunkStub,
defaultDataEncoder,
} from '../datacontainers/ChunkContainer'
import { CavesMask, EmptyChunk, GroundChunk } from '../factory/ChunksFactory'
} from '../datacontainers/ChunkContainer.js'
import { CavesMask, EmptyChunk, GroundChunk } from '../factory/ChunksFactory.js'

import { GroundPatch } from './GroundPatch'
import { ProcessingState, ProcessingTask } from './TaskProcessing'
import { ItemsBaker } from './ItemsProcessing'
import { GroundPatch } from './GroundPatch.js'
import { ProcessingState, ProcessingTask } from './TaskProcessing.js'
import { ItemsBaker } from './ItemsProcessing.js'
const chunksRange = WorldEnv.current.chunks.range
const { patchDimensions: patchDims } = WorldEnv.current

Expand Down
14 changes: 7 additions & 7 deletions src/processing/GroundPatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ import {
PatchBlock,
PatchBoundId,
PatchKey,
} from '../utils/types'
import { asVect3, asVect2 } from '../utils/convert'
import { BlockMode, Heightmap, WorldEnv } from '../index'
} from '../utils/types.js'
import { asVect3, asVect2 } from '../utils/convert.js'
import { BlockMode, Heightmap, WorldEnv } from '../index.js'
import {
Biome,
BiomeInfluence,
BiomeNumericType,
BiomeType,
BlockType,
ReverseBiomeNumericType,
} from '../procgen/Biome'
} from '../procgen/Biome.js'
import {
PatchBase,
PatchDataContainer,
PatchStub,
} from '../datacontainers/PatchBase'
import { getPatchBoundingPoints } from '../utils/spatial'
import { bilinearInterpolation } from '../utils/math'
} from '../datacontainers/PatchBase.js'
import { getPatchBoundingPoints } from '../utils/spatial.js'
import { bilinearInterpolation } from '../utils/math.js'

export type PatchBoundingBiomes = Record<PatchBoundId, BiomeInfluence>

Expand Down
24 changes: 14 additions & 10 deletions src/processing/ItemsProcessing.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { Box2, Box3, Vector3 } from 'three'

import { ChunkContainer, ChunkStub } from '../datacontainers/ChunkContainer'
import { ChunkContainer, ChunkStub } from '../datacontainers/ChunkContainer.js'
import {
Biome,
BlocksProcessing,
DistributionProfile,
ProcessingTask,
PseudoDistributionMap,
} from '../index'
import { DistributionParams } from '../procgen/BlueNoisePattern'
import { asPatchBounds, asVect2, asVect3 } from '../utils/convert'
import { PatchKey } from '../utils/types'
import { WorldEnv } from '../config/WorldEnv'
import { ItemsInventory, ItemType, SpawnedItems } from '../factory/ItemsFactory'

import { GroundPatch } from './GroundPatch'
import { DistributionProfiles } from './RandomDistributionMap'
} from '../index.js'
import { DistributionParams } from '../procgen/BlueNoisePattern.js'
import { asPatchBounds, asVect2, asVect3 } from '../utils/convert.js'
import { PatchKey } from '../utils/types.js'
import { WorldEnv } from '../config/WorldEnv.js'
import {
ItemsInventory,
ItemType,
SpawnedItems,
} from '../factory/ItemsFactory.js'

import { GroundPatch } from './GroundPatch.js'
import { DistributionProfiles } from './RandomDistributionMap.js'

const defaultDistribution: DistributionParams = {
...DistributionProfiles[DistributionProfile.MEDIUM],
Expand Down
10 changes: 5 additions & 5 deletions src/processing/RandomDistributionMap.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import alea from 'alea'
import { Box2, Vector2 } from 'three'

import { ProcLayer } from '../procgen/ProcLayer'
import { ProcLayer } from '../procgen/ProcLayer.js'
import {
BlueNoisePattern,
DistributionParams,
} from '../procgen/BlueNoisePattern'
import { asVect3, getPatchIds } from '../utils/convert'
import { WorldEnv } from '../config/WorldEnv'
import { ItemType } from '../factory/ItemsFactory'
} from '../procgen/BlueNoisePattern.js'
import { asVect3, getPatchIds } from '../utils/convert.js'
import { WorldEnv } from '../config/WorldEnv.js'
import { ItemType } from '../factory/ItemsFactory.js'

const distDefaults = {
aleaSeed: 'treeMap',
Expand Down
Loading

0 comments on commit 7be7583

Please sign in to comment.