@connected-web/terrain-editor 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +148 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # @connected-web/terrain-editor
2
+
3
+ A TypeScript library for loading, viewing, and editing `.wyn` terrain files in the browser using Three.js.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @connected-web/terrain-editor three
9
+ ```
10
+
11
+ ## What are .wyn files?
12
+
13
+ `.wyn` files are compressed archives containing terrain data with the following structure:
14
+
15
+ - `legend.json`: Metadata about the terrain (layers, name, author, description)
16
+ - `layers/*.png`: Terrain layers (heightmap, colormap, normalmap, etc.)
17
+ - `locations.json`: Predefined camera locations and points of interest
18
+ - `theme.json`: Visual theme for markers and UI elements
19
+ - `thumbnails/thumbnail.png`: Preview thumbnail
20
+
21
+ ## Usage
22
+
23
+ ### Loading a Wyn Archive
24
+
25
+ ```typescript
26
+ import { loadWynArchive } from '@connected-web/terrain-editor'
27
+
28
+ const archive = await loadWynArchive('/path/to/terrain.wyn')
29
+
30
+ console.log(archive.legend) // Terrain metadata
31
+ console.log(archive.layers) // Layer image data
32
+ console.log(archive.locations) // Points of interest
33
+ console.log(archive.theme) // Visual theme
34
+ ```
35
+
36
+ ### Creating a Terrain Viewer
37
+
38
+ ```typescript
39
+ import { TerrainViewer } from '@connected-web/terrain-editor'
40
+ import * as THREE from 'three'
41
+
42
+ const viewer = new TerrainViewer({
43
+ container: document.getElementById('viewer'),
44
+ archive: archive,
45
+ onLocationClick: (location) => {
46
+ console.log('Clicked:', location.label)
47
+ }
48
+ })
49
+
50
+ // Start rendering
51
+ viewer.start()
52
+
53
+ // Clean up when done
54
+ viewer.dispose()
55
+ ```
56
+
57
+ ### Geometry Utilities
58
+
59
+ ```typescript
60
+ import {
61
+ createHeightSampler,
62
+ sampleHeightValue,
63
+ applyHeightField
64
+ } from '@connected-web/terrain-editor'
65
+
66
+ // Sample height values from a texture
67
+ const sampler = createHeightSampler(heightTexture)
68
+ const height = sampleHeightValue(sampler, u, v)
69
+
70
+ // Apply heightfield to plane geometry
71
+ const geometry = new THREE.PlaneGeometry(100, 100, 256, 256)
72
+ applyHeightField(geometry, sampler, {
73
+ seaLevel: 0.3,
74
+ heightScale: 20
75
+ })
76
+ ```
77
+
78
+ ### Editor Features
79
+
80
+ For building and editing terrain archives:
81
+
82
+ ```typescript
83
+ import {
84
+ ProjectStore,
85
+ buildWynArchive
86
+ } from '@connected-web/terrain-editor'
87
+
88
+ // Create a new project
89
+ const project = new ProjectStore()
90
+ project.setLegend({
91
+ name: 'My Terrain',
92
+ description: 'Custom terrain map',
93
+ layers: [
94
+ { name: 'heightmap', type: 'height' },
95
+ { name: 'colormap', type: 'color' }
96
+ ]
97
+ })
98
+
99
+ // Build archive
100
+ const blob = await buildWynArchive(project)
101
+ ```
102
+
103
+ ## API Reference
104
+
105
+ ### Core Modules
106
+
107
+ - **`loadWynArchive`**: Load and parse .wyn files
108
+ - **`TerrainViewer`**: Complete 3D terrain viewer with controls
109
+ - **`ViewerHost`**: Lower-level scene/camera management
110
+ - **`ViewerOverlay`**: UI overlay for locations and markers
111
+
112
+ ### Geometry
113
+
114
+ - **`createHeightSampler`**: Sample height data from textures
115
+ - **`applyHeightField`**: Apply height displacement to geometry
116
+ - **`buildRimMesh`**: Generate terrain edge geometry
117
+
118
+ ### Editor
119
+
120
+ - **`ProjectStore`**: State management for terrain editing
121
+ - **`buildWynArchive`**: Package terrain data into .wyn format
122
+ - **`LayerBrowser`**: Layer management utilities
123
+ - **`MaskToolkit`**: Layer masking and blending
124
+
125
+ ### Theming
126
+
127
+ - **`MarkerSpriteTheme`**: Customize location marker appearance
128
+ - **`MarkerStemTheme`**: Customize marker stems (3D poles)
129
+
130
+ ## Examples
131
+
132
+ See the full demos:
133
+
134
+ - [Viewer Demo](https://connected-web.github.io/terrain-editor/viewer-js/) - Vanilla TypeScript viewer
135
+ - [Editor Demo](https://connected-web.github.io/terrain-editor/editor/) - Full-featured Vue 3 editor
136
+
137
+ ## Requirements
138
+
139
+ - Three.js ^0.181.1
140
+ - Modern browser with WebGL support
141
+
142
+ ## License
143
+
144
+ ISC
145
+
146
+ ## Repository
147
+
148
+ https://github.com/connected-web/terrain-editor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connected-web/terrain-editor",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Reusable viewer/editor utilities for Wyn terrain files.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -14,7 +14,8 @@
14
14
  }
15
15
  },
16
16
  "files": [
17
- "dist"
17
+ "dist",
18
+ "README.md"
18
19
  ],
19
20
  "scripts": {
20
21
  "build": "tsup src/index.ts --dts --format cjs,esm --out-dir dist --clean --tsconfig tsconfig.json"