@adatechnology/game-terrain-three 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anderson Fernandes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # @adatechnology/game-terrain-three
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ three.js renderer for [`@adatechnology/game-terrain`](../game-terrain).
4
+
5
+ ```ts
6
+ import { createTerrainRenderer } from '@adatechnology/game-terrain-three'
7
+
8
+ const view = createTerrainRenderer(THREE, { terrain })
9
+ scene.add(view.group)
10
+ // every frame:
11
+ view.sync(camera.position)
12
+ ```
13
+
14
+ - Chunks nobody touched share one flat geometry (one draw call for a whole floor); a dug chunk gets a mesh that draws half or a quarter of its vertices far away (`lodDistance`).
15
+ - The pattern of each surface (grass, grout, planks, asphalt, slab joints) is drawn per pixel from the world position, so it never tiles or stretches; the edge between two materials stays sharp.
16
+ - Marks are instanced decals (not drawn beyond `markDistance`), thrown pieces are instanced, and rebar appears where a slab is dug past its cover.
17
+ - `createTerrainTestModule()`: a strip of each ground side by side to shoot, blow up, burn and drop weights on. `room.openArea('terrain')`.
18
+
19
+ ## Português
20
+
21
+ Renderizador three.js do terreno: chunks intactos numa só geometria, chunks escavados com malha própria e LOD ao longe, padrão de cada piso por pixel, marcas e torrões instanciados, vergalhão onde a laje foi escavada além do cobrimento. `createTerrainTestModule()` traz as faixas de piso lado a lado para testar tiro, explosão, fogo e queda de peso.
@@ -0,0 +1,50 @@
1
+ import * as THREE_NS from 'three';
2
+ import { Terrain } from '@adatechnology/game-terrain';
3
+ import { GroundLayout, TestableModule } from '@adatechnology/game-contracts';
4
+
5
+ type ThreeLib$1 = typeof THREE_NS;
6
+ interface TerrainRendererOptions {
7
+ readonly terrain: Terrain;
8
+ /** Beyond this distance in metres a dug chunk draws half its vertices (default 30), twice this a quarter. */
9
+ readonly lodDistance?: number;
10
+ /** Marks farther than this in metres are not drawn (default 45). */
11
+ readonly markDistance?: number;
12
+ /** Metres the untouched ground goes on beyond the terrain, so that it has no edge in sight (default 300). */
13
+ readonly skirt?: number;
14
+ }
15
+ interface TerrainRenderer {
16
+ readonly group: THREE_NS.Group;
17
+ /** Call every frame with the camera's position. Redraws at most the terrain's budget of chunks. */
18
+ sync(camera: {
19
+ readonly x: number;
20
+ readonly y: number;
21
+ readonly z: number;
22
+ }): void;
23
+ /** What is on the screen, for a bench. */
24
+ stats(): {
25
+ readonly chunkMeshes: number;
26
+ readonly pristineChunks: number;
27
+ readonly marksDrawn: number;
28
+ readonly debrisDrawn: number;
29
+ };
30
+ dispose(): void;
31
+ }
32
+ /** The ground of a `Terrain`: chunks nobody touched share one flat geometry, a dug one gets a mesh of its own that gets simpler far away. */
33
+ declare function createTerrainRenderer(THREE: ThreeLib$1, options: TerrainRendererOptions): TerrainRenderer;
34
+
35
+ type ThreeLib = typeof THREE_NS;
36
+ /** The ground's material: the colour of what is exposed comes per vertex, flat so that the edge between two materials stays sharp, its pattern (blades of grass, grout, planks) is drawn per pixel from the world position so that it never tiles or stretches. */
37
+ declare function createSurfaceMaterial(THREE: ThreeLib): THREE_NS.MeshStandardMaterial;
38
+
39
+ /** The strips of the area, side by side, one of each ground. */
40
+ declare const TERRAIN_STRIPS: readonly ["dirt", "lawn", "sand", "road", "concrete_slab", "suspended_slab", "wood_floor", "tile_floor", "stone_paving"];
41
+ declare const TERRAIN_AREA_GROUND: GroundLayout;
42
+ /**
43
+ * The ground bench: a strip of each surface side by side to shoot, blow up, burn and drop weights on. Opening the area lays the strips (`ground`) and drops a concrete block
44
+ * on each from four metres.
45
+ */
46
+ declare function createTerrainTestModule(options?: {
47
+ readonly locale?: string;
48
+ }): TestableModule;
49
+
50
+ export { TERRAIN_AREA_GROUND, TERRAIN_STRIPS, type TerrainRenderer, type TerrainRendererOptions, createSurfaceMaterial, createTerrainRenderer, createTerrainTestModule };