roamwright 0.0.0-stage → 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.
@@ -0,0 +1,12 @@
1
+ # Contributing
2
+
3
+ Use a current Node.js LTS release and npm. From a fresh checkout run `npm ci`, then `npm test`. Run `npx playwright install chromium` followed by `npm run test:browser` to exercise the eye adaptation, temporal history, overlay and GPU batch paths in a real WebGL context. The compatibility workflow runs these checks on both supported revisions. Run `npm run demo` and open `/examples/` to check changes to rendering or input. For a change to renderer behavior, test both Three.js revisions listed in the peer dependency. A separate checkout can switch versions with `npm install --no-save --package-lock=false three@0.170.0`.
4
+
5
+ Keep application content in the consumer. A reusable module accepts the world seed, terrain function, camera, materials or callbacks it needs. Show new public behavior with a small example or a focused test, especially when it changes typed-array layouts or shader inputs. Include the source and license of adapted components in `licenses/`.
6
+
7
+ ## Release process
8
+
9
+ 1. Update the package version and lockfile together with `npm version --no-git-tag-version patch` (or choose the appropriate minor or major increment). Update the installation example and compatibility notes.
10
+ 2. Run the tests, open the example and inspect `npm pack --dry-run` to check the published file list.
11
+ 3. Commit on `main`, tag that commit as `v<version>`, push the commit and tag, and create the matching GitHub release.
12
+ 4. Publish the checked package to the public npm registry with `npm publish --access public`, then verify the version and integrity with `npm view roamwright version dist.integrity`. Consumers can pin the release commit and commit their npm lockfile.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Enes TAYLAN
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
13
+ all 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
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,63 @@
1
- # Temporary Holding Version
1
+ # Roamwright
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
+ Roamwright is a modular Three.js engine for building procedural worlds in the browser. Generate terrain from a seed, combine thousands of colored primitives into meshes, and move a camera through walkable or flyable spaces. The worker pool can prepare geometry while the renderer draws the current frame.
4
+
5
+ ## Try the island
6
+
7
+ With Node.js, npm and Python 3 installed, run the following commands.
8
+
9
+ ```sh
10
+ git clone https://github.com/enestaylan/roamwright.git
11
+ cd roamwright
12
+ npm ci
13
+ npm run demo
14
+ ```
15
+
16
+ Open [the island](http://localhost:8080/examples/) and drag to orbit. Change the `seed` query parameter to generate another coastline. The example serves Three.js from the local installation.
17
+
18
+ ## Use in a project
19
+
20
+ Install with npm. It resolves the Three.js peer automatically for a new project.
21
+
22
+ ```sh
23
+ npm install roamwright
24
+ ```
25
+
26
+ Version 0.1.1 supports **Three.js 0.187.0** and **0.170.0**. To select a revision explicitly, use `npm install roamwright three@0.187.0`. You can also install the tagged source directly with `npm install github:enestaylan/roamwright#v0.1.1`.
27
+
28
+ Use an ES module bundler, or provide a browser import map as in the example. Supply a canvas with a CSS width and height.
29
+
30
+ ```js
31
+ import * as THREE from 'three';
32
+ import { createRenderContext, GeometryBuilder } from 'roamwright';
33
+
34
+ const canvas = document.querySelector('canvas');
35
+ const { renderer, scene, camera, worldGroup } = createRenderContext(canvas);
36
+ const blocks = new GeometryBuilder();
37
+ blocks.box(0, 0, 0, 2, 3, 2, [0.3, 0.55, 0.44]);
38
+ blocks.mesh(new THREE.MeshBasicMaterial({ vertexColors: true }), worldGroup, false);
39
+
40
+ renderer.setSize(canvas.clientWidth, canvas.clientHeight, false);
41
+ camera.aspect = canvas.clientWidth / canvas.clientHeight;
42
+ camera.updateProjectionMatrix();
43
+ camera.position.set(6, 4, 6);
44
+ camera.lookAt(0, 1, 0);
45
+ renderer.render(scene, camera);
46
+ ```
47
+
48
+ ## Modules
49
+
50
+ | Import from `roamwright/` | Use |
51
+ | --- | --- |
52
+ | `math/noise.js`, `math/random.js`, `math/curve.js` | Create independent seeded noise fields, resumable random streams and evenly spaced spline samples. These modules also run in workers. |
53
+ | `geometry/builder.js`, `geometry/primitives.js` | Transform and merge primitives, produce typed vertex buffers, or build a Three.js mesh. Colors passed to the builder are linear RGB. |
54
+ | `geometry/instances.js`, `rendering/piece-batch.js` | Draw repeated geometry with instancing or collect changing pieces into a GPU batch. |
55
+ | `motion/spaces.js`, `motion/player.js` | Give a space terrain height, decks and colliders. Set the controller's input axes, call `update(deltaSeconds)`, then `applyCamera(camera)`. Distances are in metres. |
56
+ | `runtime/pool.js`, `runtime/worker.js` | Register named jobs on a module worker and send work from the page. Typed-array buffers in results transfer back to the caller. |
57
+ | `rendering/context.js`, `rendering/world-matrices.js` | Set up WebGL2, a camera, a scene and world group. Optionally track static transforms once per frame before drawing. |
58
+ | `rendering/post.js`, `rendering/taa.js`, `rendering/dof.js` | Compose HDR passes, temporal antialiasing, depth of field, exposure and upscaling. The application supplies its camera, effect scene and sky occlusion mask. |
59
+ | `runtime/gpu-timing.js`, `runtime/quality-fit.js`, `runtime/quality-store.js` | Measure GPU work, adapt quality and persist a visitor's settings in a storage namespace chosen by the application. |
60
+
61
+ For geometry generated off the main thread, call `builder.parts(true)` in the worker and `geometryOf(parts)` on the page. This path frees static CPU-side attributes after upload. Keep the seed or source data if your application needs to regenerate meshes after a context loss.
62
+
63
+ The [island example](examples/island.js) shows deterministic generation, mesh batching, resize handling and camera input together. See [CONTRIBUTING.md](CONTRIBUTING.md) for testing and releases. Roamwright is distributed under the [MIT license](LICENSE). Notices for adapted components are in [licenses](licenses).
@@ -0,0 +1,19 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <meta charset="utf-8">
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <title>Seeded island · Roamwright</title>
6
+ <style>
7
+ * { box-sizing: border-box }
8
+ body { margin: 0; background: #bad2d9; color: #203e42; font: 15px/1.4 system-ui, sans-serif }
9
+ canvas { display: block; width: 100vw; height: 100dvh; touch-action: none }
10
+ header { position: absolute; left: 1.25rem; top: 1rem; pointer-events: none }
11
+ h1 { margin: 0; font-size: 1.25rem } p { margin: .2rem 0 }
12
+ </style>
13
+ <script type="importmap">
14
+ {"imports":{"three":"../node_modules/three/build/three.module.js","three/addons/":"../node_modules/three/examples/jsm/","roamwright":"../index.js"}}
15
+ </script>
16
+ <header><h1>Seeded island</h1><p>Drag to orbit · Scroll or pinch to zoom</p></header>
17
+ <canvas aria-label="Procedural island surrounded by water"></canvas>
18
+ <script type="module" src="./island.js"></script>
19
+ </html>
@@ -0,0 +1,62 @@
1
+ import * as THREE from 'three';
2
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
3
+ import { createNoise, createRenderContext, mulberry32, GeometryBuilder } from 'roamwright';
4
+
5
+ const canvas = document.querySelector('canvas');
6
+ const { renderer, camera, scene, worldGroup } = createRenderContext(canvas);
7
+ const seed = Number(new URL(location.href).searchParams.get('seed') ?? 42);
8
+ const { fbm } = createNoise(seed);
9
+ const random = mulberry32(seed);
10
+ const terrain = new THREE.PlaneGeometry(100, 100, 144, 144).rotateX(-Math.PI / 2);
11
+ const position = terrain.getAttribute('position');
12
+ const colors = new Float32Array(position.count * 3);
13
+ const color = new THREE.Color();
14
+ const height = (x, z) => {
15
+ const radius = Math.hypot(x * 0.96, z * 1.15) / 47;
16
+ return (1 - radius) * 18 + (fbm(x * 0.079, z * 0.079, 5, 7) - 0.5) * 12 - 3;
17
+ };
18
+ for (let i = 0; i < position.count; i++) {
19
+ const y = height(position.getX(i), position.getZ(i));
20
+ position.setY(i, y);
21
+ color.setHex(y < 1.2 ? 0xd3c295 : y < 9 ? 0x738c61 : 0x8b8b80);
22
+ color.multiplyScalar(0.88 + 0.17 * random()).toArray(colors, i * 3);
23
+ }
24
+ terrain.setAttribute('color', new THREE.BufferAttribute(colors, 3));
25
+ terrain.computeVertexNormals();
26
+ worldGroup.add(new THREE.Mesh(terrain, new THREE.MeshStandardMaterial({ vertexColors: true })));
27
+ const stones = new GeometryBuilder();
28
+ for (let i = 0; i < 100; i++) {
29
+ const x = (random() - 0.5) * 75, z = (random() - 0.5) * 75;
30
+ const y = height(x, z), width = 0.3 + random() * 1.5;
31
+ if (y > 1) stones.box(x, y - 0.35, z, width, width * 1.3, width, [0.22, 0.25, 0.23], random() * Math.PI, 0.15);
32
+ }
33
+ stones.mesh(new THREE.MeshStandardMaterial({ vertexColors: true }), worldGroup, false);
34
+ const water = new THREE.Mesh(new THREE.PlaneGeometry(800, 800), new THREE.MeshStandardMaterial({ color: 0x397988 }));
35
+ water.rotation.x = -Math.PI / 2;
36
+ worldGroup.add(water);
37
+ scene.background = new THREE.Color(0xbad2d9);
38
+ scene.fog = new THREE.FogExp2(scene.background, 0.006);
39
+ scene.add(new THREE.HemisphereLight(0xffffff, 0x737759, 1.8));
40
+ const sun = new THREE.DirectionalLight(0xffebcc, 2.4);
41
+ sun.position.set(-1, 1.4, 0.7);
42
+ scene.add(sun);
43
+ camera.position.set(60, 39, 65);
44
+ const controls = new OrbitControls(camera, canvas);
45
+ controls.target.set(0, 3, 0);
46
+ controls.maxPolarAngle = Math.PI * 0.48;
47
+ controls.minDistance = 10;
48
+ controls.maxDistance = 130;
49
+ function draw() {
50
+ renderer.render(scene, camera);
51
+ }
52
+ controls.addEventListener('change', draw);
53
+ function resize() {
54
+ renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
55
+ renderer.setSize(canvas.clientWidth, canvas.clientHeight, false);
56
+ camera.aspect = canvas.clientWidth / canvas.clientHeight;
57
+ camera.updateProjectionMatrix();
58
+ controls.update();
59
+ draw();
60
+ }
61
+ window.addEventListener('resize', resize);
62
+ resize();