@brandonlukas/luminar 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 Brandon Lukas
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 ADDED
@@ -0,0 +1,49 @@
1
+ # luminar
2
+
3
+ Looping particle-flow study inspired by the bloom-heavy look of [lumap](https://github.com/brandonlukas/lumap). It renders a 2D vector field using Three.js with additive particles and an Unreal Bloom pass; flow magnitude controls glow intensity.
4
+
5
+ ## Quick start
6
+
7
+ Visualize a CSV field (columns: x, y, dx, dy; header optional) with zero install:
8
+
9
+ ```sh
10
+ npx @brandonlukas/luminar path/to/field.csv
11
+ ```
12
+
13
+ Optional flags: `--port 5173`, `--host 0.0.0.0`, `--preview` (uses production build)
14
+
15
+ ### Local development
16
+
17
+ ```sh
18
+ npm install
19
+ npm run dev
20
+ ```
21
+
22
+ Or use the old script syntax:
23
+
24
+ ```sh
25
+ npm run visualize:csv -- --file path/to/field.csv
26
+ ```
27
+ The parser auto-detects and skips header rows if present. Use `--preview` to run against the built bundle instead of dev, and `--host 0.0.0.0` to expose on your network.
28
+
29
+ Build for production:
30
+
31
+ ```sh
32
+ npm run build
33
+ ```
34
+
35
+ ## How it works
36
+ - Orthographic camera framing a square field with particles advected each frame.
37
+ - Vector field defined in `sampleField` inside [src/main.ts](src/main.ts#L98-L110); edit to fit your data or dynamics.
38
+ - Glow intensity maps to local speed; particles respawn when leaving the world bounds.
39
+ - Unreal Bloom and additive blending preserve the luminous, hazy aesthetic.
40
+ - On-canvas controls (top-right) adjust size, bloom strength, and bloom radius in real time.
41
+
42
+ ## Tweaks to try
43
+ - Increase `PARTICLE_COUNT` or `FLOW_SCALE` in [src/main.ts](src/main.ts#L20-L24) for denser motion.
44
+ - Adjust `WORLD_EXTENT` and `JITTER` to change containment and randomness.
45
+ - Swap `sampleField` to consume your own `(x, y, dx, dy)` tuples; normalize magnitudes before applying `FLOW_SCALE` for stability.
46
+
47
+ ## Notes
48
+ - The scene is non-interactive and loops continuously.
49
+ - Fonts and overlay styling live in [src/style.css](src/style.css).
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs'
3
+ import { resolve, dirname } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+ import { spawn } from 'node:child_process'
6
+
7
+ const __filename = fileURLToPath(import.meta.url)
8
+ const __dirname = dirname(__filename)
9
+ const projectRoot = resolve(__dirname, '..')
10
+
11
+ function parseArgs() {
12
+ const args = process.argv.slice(2)
13
+ const out = { file: null, port: 5173, host: '0.0.0.0', preview: false }
14
+
15
+ for (let i = 0; i < args.length; i += 1) {
16
+ const arg = args[i]
17
+ if (arg === '--port' || arg === '-p') {
18
+ out.port = Number(args[++i]) || out.port
19
+ } else if (arg === '--host') {
20
+ out.host = args[++i] || out.host
21
+ } else if (arg === '--preview') {
22
+ out.preview = true
23
+ } else if (!arg.startsWith('-') && !out.file) {
24
+ // First positional argument is the file
25
+ out.file = arg
26
+ }
27
+ }
28
+ return out
29
+ }
30
+
31
+ function parseCsv(text) {
32
+ const lines = text.split(/\r?\n/).filter(Boolean)
33
+ const rows = []
34
+ let skippedHeader = false
35
+ for (const line of lines) {
36
+ const parts = line.split(/[,\s]+/).filter(Boolean)
37
+ if (parts.length < 4) continue
38
+ const [x, y, dx, dy] = parts.map(Number)
39
+ if ([x, y, dx, dy].some((n) => Number.isNaN(n))) {
40
+ if (!skippedHeader && rows.length === 0) {
41
+ skippedHeader = true
42
+ console.log('skipping header line:', line.substring(0, 60))
43
+ }
44
+ continue
45
+ }
46
+ rows.push({ x, y, dx, dy })
47
+ }
48
+ return rows
49
+ }
50
+
51
+ function writeFieldJson(rows) {
52
+ const target = resolve(projectRoot, 'public', 'vector-field.json')
53
+ writeFileSync(target, JSON.stringify(rows, null, 2), 'utf8')
54
+ console.log(`wrote ${rows.length} vectors to ${target}`)
55
+ }
56
+
57
+ function runServer({ port, host, preview }) {
58
+ const cmd = 'npm'
59
+ const args = preview
60
+ ? ['run', 'build-and-preview', '--', '--host', host, '--port', String(port)]
61
+ : ['run', 'dev', '--', '--host', host, '--port', String(port)]
62
+ console.log(`starting ${preview ? 'preview' : 'dev'} server on http://${host}:${port}`)
63
+ const child = spawn(cmd, args, {
64
+ stdio: 'inherit',
65
+ cwd: projectRoot,
66
+ env: process.env,
67
+ })
68
+ child.on('exit', (code) => process.exit(code ?? 0))
69
+ }
70
+
71
+ function main() {
72
+ const { file, port, host, preview } = parseArgs()
73
+ if (!file) {
74
+ console.error('Usage: luminar <file.csv> [--port 5173] [--host 0.0.0.0] [--preview]')
75
+ console.error('Example: luminar data.csv')
76
+ process.exit(1)
77
+ }
78
+ const resolved = resolve(process.cwd(), file)
79
+ if (!existsSync(resolved)) {
80
+ console.error(`File not found: ${resolved}`)
81
+ process.exit(1)
82
+ }
83
+ const text = readFileSync(resolved, 'utf8')
84
+ const rows = parseCsv(text)
85
+ if (rows.length === 0) {
86
+ console.error('Parsed 0 rows; ensure CSV has x,y,dx,dy columns (header optional)')
87
+ process.exit(1)
88
+ }
89
+ writeFieldJson(rows)
90
+ runServer({ port, host, preview })
91
+ }
92
+
93
+ main()