three-low-poly 0.9.23 → 0.9.25

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/README.md CHANGED
@@ -1,31 +1,67 @@
1
1
  # Three.js Low Poly
2
2
 
3
- Create or enhance stylized low-poly scenes entirely through code using procedurally generated geometries, prefabricated models, and factory utilities.
3
+ Create or enhance stylized low-poly scenes entirely through code using procedurally generated geometries, prefabricated models, factory utilities, and atmospheric layers for [Three.js](https://threejs.org).
4
+
5
+ ![screen-capture](https://github.com/user-attachments/assets/3285ed9a-da3c-4287-ad2f-0c7e82cd70fd)
6
+ _Example Library scene_
4
7
 
5
8
  ## Overview
6
9
 
7
- **Three Low Poly** provides a toolkit for building low-poly environments in [Three.js](https://threejs.org) with minimal manual modeling.
8
- It combines **procedural generation** (algorithmic geometry creation) with **parametric modeling** (user-defined parameters) to produce consistent, customizable results.
10
+ This is an alternative to a modeling pipeline using external DCC tools: author in code via procedural and parametric geometry. Splines, lathe, extrude, parabolic profiles expressing geometry as algorithms. Vertex-built geometry, prefab models, and factory assemblies are first-class.
9
11
 
10
- ### Core Principles
11
- - **Procedural Generation** – Create geometry algorithmically rather than by hand.
12
- - **Parametric Modeling** – Adjust model attributes (size, color, detail, variation) via options.
13
- - **Prefabricated Models** – Drop-in objects like trees, rocks, or books ready for scenes.
14
- - **Factory Utilities** – Generate arrays, grids, or randomized layouts of models with a single call.
12
+ Most adopters will likely import their own assets (glTF, etc.) and use this library as scene enhancement rather than a full replacement for modeling software. This library spans both worlds.
15
13
 
16
- ![screen-capture](https://github.com/user-attachments/assets/3285ed9a-da3c-4287-ad2f-0c7e82cd70fd)
17
- _Example Library scene_
14
+ "Low poly" describes the aesthetic, not the whole thesis. Intention is code-first, parametric, performant scene building. Exported assets often mean one draw call per mesh; this library favors merged geometry, material groups, and instancing so dense procedural scenes stay batch-friendly, a deliberate contrast to typical glTF import cost.
15
+
16
+ ### Core principles
17
+
18
+ - **Procedural generation**: geometry from algorithms, not imported meshes
19
+ - **Parametric modeling**: size, color, detail, and variation controlled via options
20
+ - **Prefabricated models**: drop-in objects (trees, jars, books) ready for `scene.add()`
21
+ - **Factory utilities**: assemblies and fills (rows, grids, tiled floors) from one call
22
+ - **Instanced layers**: weather, scatter, and particles via `InstancedMesh` / `Points`
23
+ - **Time-based animation**: driven by elapsed seconds, not per-frame magic numbers
24
+
25
+ ## Modeling
26
+
27
+ Vertex modeling is preferred over relying on built-in primitives, using geometry groups when a mesh needs multiple materials. Profile-based tools (splines, lathe, extrude, parabolic curves) cover most organic and architectural shapes; NURBS surfaces are exploratory, for cases where profile tools fall short.
28
+
29
+ Where it makes sense, geometry is authored as its own class mirroring how Three.js structures its own `BufferGeometry` subclasses, rather than building shapes inline wherever they're used. That keeps geometry reusable and consistent with how the rest of the ecosystem expects to work with it.
30
+
31
+ ## Models, factories, and instancing
32
+
33
+ Two distinct shapes of API exist, and the distinction is intentional:
34
+
35
+ - **Models ("prefabs")** are stable, ready-to-place objects - geometry plus materials combined into something you just add to a scene. Use these when the artifact itself is the thing you want.
36
+ - **Factories** build assemblies or fill an area - a row of books, a floor of hex tiles, a fence along a path. Use these when the artifact is a composition of many parts rather than a single object.
37
+
38
+ Dense or repeated elements (tiles, books, particles, weather) lean on `InstancedMesh` rather than individual meshes, which is where most of the performance comes from. Batching and merge opportunities are still handled case-by-case rather than enforced everywhere, so there's room to be deliberate about it when adding new factories.
18
39
 
19
- ## Getting Started
40
+ ## Atmosphere and effect layers
20
41
 
21
- To install, execute:
42
+ Anything that moves, flickers, or drifts falls into one of three categories, distinguished by how long it lasts, what it's scoped to, and what triggers it. This taxonomy matters more than it might first appear - it's the difference between something that's always running in the background versus something that fires once and finishes, and it should hold as the library grows:
43
+
44
+ - **Environment**: continuous, scene- or region-scale, generally always on (rain, fog, lightning, a starfield sky dome). These set the atmosphere for the whole scene rather than belonging to any one object.
45
+ - **Ambience**: continuous, but scoped to a volume or bound to a specific prop (bubbles in a jar, petals drifting through a yard, a flickering flame). Same always-on lifecycle as environment layers, just localized rather than global.
46
+ - **FX**: short-lived and event-triggered (dust kicked up on landing, a spell flash). Not just a smaller environment layer - the lifecycle is fundamentally different: it starts on `trigger()`, runs once, and ends, rather than running continuously via `update(dt)`.
47
+
48
+ ## Conventions
49
+
50
+ A few patterns hold consistently across the library, and are worth following when contributing or extending it:
51
+
52
+ - **Options objects**: public APIs take a `Options` interface (exported alongside the class) rather than positional arguments, with defaults set via destructuring and each field documented.
53
+ - **Animation**: anything that moves exposes `update(dt)` where `dt` is elapsed seconds, not a frame-rate-dependent step.
54
+ - **Disposal**: anything owning geometry, materials, or textures exposes `dispose()`.
55
+ - **Documentation**: every public class gets a doc comment with a minimal setup snippet, enough to wire it up without reading the source.
56
+ - **Examples**: every feature has a matching example in the host gallery, so behavior can be seen in motion, not just read about.
57
+ - **Randomness**: variation is unique per runtime by default (plain `Math.random()`); seeded, reproducible randomness is on the roadmap, not yet wired through.
58
+
59
+ ## Getting started
22
60
 
23
61
  ```shell
24
62
  npm i three-low-poly
25
63
  ```
26
64
 
27
- Then, import into a project and use as:
28
-
29
65
  ```js
30
66
  import { MossyRocks } from "three-low-poly";
31
67
 
@@ -33,13 +69,34 @@ const rocks = new MossyRocks();
33
69
  scene.add(rocks);
34
70
  ```
35
71
 
36
- See the [examples](https://jasonsturges.com/three-low-poly/) for more information.
72
+ A drop-in model is the simplest case. Factories and continuous effects follow the same shape - construct with options, add to the scene, call `update(dt)` from your render loop if the thing animates:
73
+
74
+ ```js
75
+ import { RainEffect } from "three-low-poly";
76
+
77
+ const rain = new RainEffect({ area: 12, height: 16, intensity: 0.45 });
78
+ scene.add(rain);
79
+
80
+ function animate(dt) {
81
+ rain.update(dt);
82
+ renderer.render(scene, camera);
83
+ }
84
+ ```
85
+
86
+ See the [example gallery](https://jasonsturges.com/three-low-poly/) for the full catalog of models, effects, and composed scenes. Local dev: `npm run host`.
37
87
 
38
88
  ![screen-capture](https://github.com/user-attachments/assets/d97345cc-bdaa-46d5-a267-531559919ee5)
39
89
  _Example Graveyard scene_
40
90
 
41
- ## Usage
91
+ ## Roadmap
92
+
93
+ Direction, not a committed schedule:
94
+
95
+ - **Seeded randomness**: thread an optional seed through stochastic factories and effects so a scene can be reproduced exactly, while staying unique by default when no seed is given.
96
+ - **Unified fill API**: collapse the growing set of `...ByCount` / `...ByRadius` factory variants into a single discriminated option (fit by count, by item size, or by greedy/random packing), so the same vocabulary applies across books, tiles, fences, and whatever comes next.
97
+ - **WebGPU + TSL**: shaders authored once via Three Shading Language, portable across WebGL and WebGPU.
98
+ - **FX module**: short-lived, triggered bursts (impact dust, spell flashes) as a category distinct from the always-on environment and ambience layers that exist today.
42
99
 
43
- Assets are procedurally generated and customizable through parameters, typically based on a core geometry that combines a mesh with a material.
100
+ ## Author
44
101
 
45
- Alongside these geometries, there are prefabricated models that can be added directly to the scene, as well as factory methods for bulk creation.
102
+ Jason Sturges, procedural low-poly tooling for Three.js.