@n3rdw1z4rd/core 0.18.0 → 0.18.2
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/dist/css/index.ts +1 -0
- package/dist/index.css +104 -0
- package/dist/index.d.mts +40 -12
- package/dist/index.d.ts +40 -12
- package/dist/index.js +262 -97
- package/dist/index.mjs +360 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod2) => function __require() {
|
|
12
|
+
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
|
|
13
|
+
};
|
|
8
14
|
var __export = (target, all) => {
|
|
9
15
|
for (var name in all)
|
|
10
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,6 +23,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
23
|
}
|
|
18
24
|
return to;
|
|
19
25
|
};
|
|
26
|
+
var __reExport = (target, mod2, secondTarget) => (__copyProps(target, mod2, "default"), secondTarget && __copyProps(secondTarget, mod2, "default"));
|
|
20
27
|
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
21
28
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
29
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -27,6 +34,20 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
|
|
|
27
34
|
));
|
|
28
35
|
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
|
29
36
|
|
|
37
|
+
// src/css/main.css
|
|
38
|
+
var init_main = __esm({
|
|
39
|
+
"src/css/main.css"() {
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// src/css/index.ts
|
|
44
|
+
var require_css = __commonJS({
|
|
45
|
+
"src/css/index.ts"() {
|
|
46
|
+
"use strict";
|
|
47
|
+
init_main();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
30
51
|
// src/index.ts
|
|
31
52
|
var index_exports = {};
|
|
32
53
|
__export(index_exports, {
|
|
@@ -61,10 +82,12 @@ __export(index_exports, {
|
|
|
61
82
|
DEFAULT_TEXTALIGN: () => DEFAULT_TEXTALIGN,
|
|
62
83
|
DEFAULT_TEXTBASELINE: () => DEFAULT_TEXTBASELINE,
|
|
63
84
|
DEG2RAD: () => DEG2RAD,
|
|
85
|
+
DebugRenderer: () => DebugRenderer,
|
|
64
86
|
Disposable: () => Disposable,
|
|
65
87
|
E: () => E,
|
|
66
88
|
ECS: () => ECS,
|
|
67
89
|
EPSILON: () => EPSILON,
|
|
90
|
+
Emitter: () => Emitter,
|
|
68
91
|
EventQueue: () => EventQueue,
|
|
69
92
|
GenerateDoors: () => GenerateDoors,
|
|
70
93
|
GenerateEntityId: () => GenerateEntityId,
|
|
@@ -121,6 +144,7 @@ __export(index_exports, {
|
|
|
121
144
|
VoxelMesh: () => VoxelMesh,
|
|
122
145
|
WebGlRenderer: () => WebGlRenderer,
|
|
123
146
|
WorkerInterface: () => WorkerInterface,
|
|
147
|
+
buildColorPalette: () => buildColorPalette,
|
|
124
148
|
clamp: () => clamp,
|
|
125
149
|
degrees: () => degrees,
|
|
126
150
|
distance2d: () => distance2d,
|
|
@@ -135,6 +159,7 @@ __export(index_exports, {
|
|
|
135
159
|
k2xy: () => k2xy,
|
|
136
160
|
k2xyz: () => k2xyz,
|
|
137
161
|
lerp: () => lerp,
|
|
162
|
+
log: () => log,
|
|
138
163
|
manhattanDistance: () => manhattanDistance,
|
|
139
164
|
mod: () => mod,
|
|
140
165
|
nearlyEqual: () => nearlyEqual,
|
|
@@ -524,8 +549,69 @@ var Clock = class {
|
|
|
524
549
|
}
|
|
525
550
|
};
|
|
526
551
|
|
|
552
|
+
// src/color-palette.ts
|
|
553
|
+
var DEFAULT_COLORS = [
|
|
554
|
+
[237, 28, 36],
|
|
555
|
+
// red
|
|
556
|
+
[255, 127, 39],
|
|
557
|
+
// orange
|
|
558
|
+
[255, 242, 0],
|
|
559
|
+
// yellow
|
|
560
|
+
[34, 177, 76],
|
|
561
|
+
// green
|
|
562
|
+
[0, 183, 239],
|
|
563
|
+
// cyan
|
|
564
|
+
[63, 72, 204],
|
|
565
|
+
// blue
|
|
566
|
+
[163, 73, 164],
|
|
567
|
+
// purple
|
|
568
|
+
[236, 0, 140],
|
|
569
|
+
// magenta
|
|
570
|
+
[255, 174, 201],
|
|
571
|
+
// pink
|
|
572
|
+
[139, 90, 43],
|
|
573
|
+
// brown
|
|
574
|
+
[214, 181, 129],
|
|
575
|
+
// tan
|
|
576
|
+
[128, 128, 0],
|
|
577
|
+
// olive
|
|
578
|
+
[0, 128, 128],
|
|
579
|
+
// teal
|
|
580
|
+
[128, 0, 32]
|
|
581
|
+
// maroon
|
|
582
|
+
];
|
|
583
|
+
function packRGB(r, g, b) {
|
|
584
|
+
r = Math.min(255, Math.max(0, Math.round(r)));
|
|
585
|
+
g = Math.min(255, Math.max(0, Math.round(g)));
|
|
586
|
+
b = Math.min(255, Math.max(0, Math.round(b)));
|
|
587
|
+
return r << 16 | g << 8 | b;
|
|
588
|
+
}
|
|
589
|
+
var DARK_FLOOR = 0.28;
|
|
590
|
+
function colorRamp(rgb, steps) {
|
|
591
|
+
const [r, g, b] = rgb;
|
|
592
|
+
const out = [];
|
|
593
|
+
for (let i = 0; i < steps; i++) {
|
|
594
|
+
const t = steps === 1 ? 0 : i / (steps - 1);
|
|
595
|
+
const scale = 1 - t * (1 - DARK_FLOOR);
|
|
596
|
+
out.push(packRGB(r * scale, g * scale, b * scale));
|
|
597
|
+
}
|
|
598
|
+
return out;
|
|
599
|
+
}
|
|
600
|
+
function buildColorPalette(grayscaleSteps = 8, colorSteps = 4, ...colors2) {
|
|
601
|
+
const palette = [];
|
|
602
|
+
for (let i = 0; i < grayscaleSteps; i++) {
|
|
603
|
+
const v = grayscaleSteps === 1 ? 0 : i / (grayscaleSteps - 1) * 255;
|
|
604
|
+
palette.push(packRGB(v, v, v));
|
|
605
|
+
}
|
|
606
|
+
const colorList = colors2.length > 0 ? colors2 : DEFAULT_COLORS;
|
|
607
|
+
for (const rgb of colorList) {
|
|
608
|
+
palette.push(...colorRamp(rgb, colorSteps));
|
|
609
|
+
}
|
|
610
|
+
return palette;
|
|
611
|
+
}
|
|
612
|
+
|
|
527
613
|
// src/log.ts
|
|
528
|
-
var
|
|
614
|
+
var log = console.debug.bind(
|
|
529
615
|
console,
|
|
530
616
|
"%c[dev]",
|
|
531
617
|
"font-weight: bold; color: #888;"
|
|
@@ -574,7 +660,7 @@ var Color = class _Color {
|
|
|
574
660
|
[this._r, this._g, this._b, this._a] = this._parse_hex_color_string(value);
|
|
575
661
|
this._hex = value;
|
|
576
662
|
} else {
|
|
577
|
-
|
|
663
|
+
log(`Color: invalid color string: ${value}. Should be a hexadecimal color string (i.e.: '#ffffff' or '#ffffffff'). Keeping the current color.`);
|
|
578
664
|
}
|
|
579
665
|
}
|
|
580
666
|
get rgba() {
|
|
@@ -585,7 +671,7 @@ var Color = class _Color {
|
|
|
585
671
|
if (r.startsWith("#")) {
|
|
586
672
|
[r, g, b, a] = this._parse_hex_color_string(r);
|
|
587
673
|
} else {
|
|
588
|
-
|
|
674
|
+
log(`Color: invalid color string: ${r}. Should be a hexadecimal color string (i.e.: '#ffffff' or '#ffffffff'). Defaulting to opaque white.`);
|
|
589
675
|
r = g = b = a = 255;
|
|
590
676
|
}
|
|
591
677
|
} else {
|
|
@@ -686,7 +772,7 @@ var Color = class _Color {
|
|
|
686
772
|
const [r, g, b, a] = rgba.map(Number);
|
|
687
773
|
return new _Color(r, g, b, a);
|
|
688
774
|
} else {
|
|
689
|
-
|
|
775
|
+
log(`Color: invalid CSS color name: ${name}. Defaulting to transparent.`);
|
|
690
776
|
return _Color.TRANSPARENT;
|
|
691
777
|
}
|
|
692
778
|
}
|
|
@@ -695,6 +781,81 @@ var Color = class _Color {
|
|
|
695
781
|
}
|
|
696
782
|
};
|
|
697
783
|
|
|
784
|
+
// src/index.ts
|
|
785
|
+
__reExport(index_exports, __toESM(require_css()), module.exports);
|
|
786
|
+
|
|
787
|
+
// src/debug-label.ts
|
|
788
|
+
var import_three = require("three");
|
|
789
|
+
var import_CSS2DRenderer = require("three/addons/renderers/CSS2DRenderer.js");
|
|
790
|
+
var labelRenderer = new import_CSS2DRenderer.CSS2DRenderer();
|
|
791
|
+
labelRenderer.setSize(window.innerWidth, window.innerHeight);
|
|
792
|
+
labelRenderer.domElement.style.position = "absolute";
|
|
793
|
+
labelRenderer.domElement.style.top = "0px";
|
|
794
|
+
labelRenderer.domElement.style.pointerEvents = "none";
|
|
795
|
+
document.body.appendChild(labelRenderer.domElement);
|
|
796
|
+
window.addEventListener("resize", () => {
|
|
797
|
+
labelRenderer.setSize(window.innerWidth, window.innerHeight);
|
|
798
|
+
});
|
|
799
|
+
var FONT_SIZE = 12;
|
|
800
|
+
var DebugRenderer = class extends import_CSS2DRenderer.CSS2DRenderer {
|
|
801
|
+
_labels = /* @__PURE__ */ new Set();
|
|
802
|
+
get width() {
|
|
803
|
+
return this.domElement.clientWidth;
|
|
804
|
+
}
|
|
805
|
+
get height() {
|
|
806
|
+
return this.domElement.clientHeight;
|
|
807
|
+
}
|
|
808
|
+
constructor() {
|
|
809
|
+
super();
|
|
810
|
+
this.setSize(window.innerWidth, window.innerHeight);
|
|
811
|
+
this.domElement.style.position = "absolute";
|
|
812
|
+
this.domElement.style.top = "0px";
|
|
813
|
+
this.domElement.style.pointerEvents = "none";
|
|
814
|
+
}
|
|
815
|
+
resize(width, height) {
|
|
816
|
+
let resized = false;
|
|
817
|
+
width = width ?? this.domElement.parentElement?.clientWidth ?? this.width;
|
|
818
|
+
height = height ?? this.domElement.parentElement?.clientHeight ?? this.height;
|
|
819
|
+
if (this.width !== width || this.height !== height) {
|
|
820
|
+
this.setSize(width, height);
|
|
821
|
+
resized = true;
|
|
822
|
+
}
|
|
823
|
+
return resized;
|
|
824
|
+
}
|
|
825
|
+
createLabel(text, offset) {
|
|
826
|
+
if (!Array.isArray(text)) text = [text];
|
|
827
|
+
offset = offset ?? new import_three.Vector3(0, -1, 0);
|
|
828
|
+
const div = document.createElement("div");
|
|
829
|
+
div.innerHTML = text.join("<br>");
|
|
830
|
+
div.style.cssText = `
|
|
831
|
+
color: #888;
|
|
832
|
+
font: ${FONT_SIZE}px monospace;
|
|
833
|
+
padding: 4px 8px;
|
|
834
|
+
background: rgba(0,0,0,0.7);
|
|
835
|
+
border-radius: 4px;
|
|
836
|
+
border: 1px dashed #fff;
|
|
837
|
+
white-space: nowrap;
|
|
838
|
+
`;
|
|
839
|
+
const label = new import_CSS2DRenderer.CSS2DObject(div);
|
|
840
|
+
const lineGeometry = new import_three.BufferGeometry().setFromPoints([
|
|
841
|
+
new import_three.Vector3(0, 0, 0),
|
|
842
|
+
offset
|
|
843
|
+
]);
|
|
844
|
+
const lineMaterial = new import_three.LineBasicMaterial({
|
|
845
|
+
color: 16777215,
|
|
846
|
+
transparent: true,
|
|
847
|
+
opacity: 0.5,
|
|
848
|
+
depthTest: false
|
|
849
|
+
// keep visible through geometry, like a debug overlay
|
|
850
|
+
});
|
|
851
|
+
const line = new import_three.Line(lineGeometry, lineMaterial);
|
|
852
|
+
line.renderOrder = 999;
|
|
853
|
+
const debugLabel = { div, label, line };
|
|
854
|
+
this._labels.add(debugLabel);
|
|
855
|
+
return debugLabel;
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
|
|
698
859
|
// src/disposable.ts
|
|
699
860
|
var Disposable = class {
|
|
700
861
|
disposers = [];
|
|
@@ -1315,7 +1476,7 @@ function GenerateRooms(params = {}) {
|
|
|
1315
1476
|
_plot(map, rooms, TILE_FLOOR);
|
|
1316
1477
|
const paths = _generatePaths(map, rooms, params.paths);
|
|
1317
1478
|
_plot(map, paths, TILE_PATH);
|
|
1318
|
-
|
|
1479
|
+
log("GenerateRooms: done:", Date.now() - startTime, "ms");
|
|
1319
1480
|
return { map, rooms, paths };
|
|
1320
1481
|
}
|
|
1321
1482
|
function GenerateDoors(map, paths, params = {}) {
|
|
@@ -1421,26 +1582,6 @@ var ECS = class _ECS {
|
|
|
1421
1582
|
}
|
|
1422
1583
|
};
|
|
1423
1584
|
|
|
1424
|
-
// src/event-queue.ts
|
|
1425
|
-
var EventQueue = class {
|
|
1426
|
-
events = [];
|
|
1427
|
-
emit(event) {
|
|
1428
|
-
this.events.push(event);
|
|
1429
|
-
}
|
|
1430
|
-
consume() {
|
|
1431
|
-
return this.events;
|
|
1432
|
-
}
|
|
1433
|
-
clear() {
|
|
1434
|
-
this.events.length = 0;
|
|
1435
|
-
}
|
|
1436
|
-
drain() {
|
|
1437
|
-
return this.events.splice(0);
|
|
1438
|
-
}
|
|
1439
|
-
get size() {
|
|
1440
|
-
return this.events.length;
|
|
1441
|
-
}
|
|
1442
|
-
};
|
|
1443
|
-
|
|
1444
1585
|
// src/emitter.ts
|
|
1445
1586
|
var Emitter = class {
|
|
1446
1587
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -1463,6 +1604,26 @@ var Emitter = class {
|
|
|
1463
1604
|
}
|
|
1464
1605
|
};
|
|
1465
1606
|
|
|
1607
|
+
// src/event-queue.ts
|
|
1608
|
+
var EventQueue = class {
|
|
1609
|
+
events = [];
|
|
1610
|
+
emit(event) {
|
|
1611
|
+
this.events.push(event);
|
|
1612
|
+
}
|
|
1613
|
+
consume() {
|
|
1614
|
+
return this.events;
|
|
1615
|
+
}
|
|
1616
|
+
clear() {
|
|
1617
|
+
this.events.length = 0;
|
|
1618
|
+
}
|
|
1619
|
+
drain() {
|
|
1620
|
+
return this.events.splice(0);
|
|
1621
|
+
}
|
|
1622
|
+
get size() {
|
|
1623
|
+
return this.events.length;
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1466
1627
|
// src/input.ts
|
|
1467
1628
|
var Input = class _Input extends Emitter {
|
|
1468
1629
|
static _instance;
|
|
@@ -2358,9 +2519,9 @@ var SpatialPartition3d = class {
|
|
|
2358
2519
|
};
|
|
2359
2520
|
|
|
2360
2521
|
// src/three/asteroid-mesh.ts
|
|
2361
|
-
var
|
|
2522
|
+
var import_three2 = require("three");
|
|
2362
2523
|
var import_simplex_noise2 = require("simplex-noise");
|
|
2363
|
-
var AsteroidMesh = class extends
|
|
2524
|
+
var AsteroidMesh = class extends import_three2.Mesh {
|
|
2364
2525
|
constructor(options = {}) {
|
|
2365
2526
|
const radius = options.radius ?? 1;
|
|
2366
2527
|
const detail = options.detail ?? 1;
|
|
@@ -2368,8 +2529,8 @@ var AsteroidMesh = class extends import_three.Mesh {
|
|
|
2368
2529
|
const displacement = options.displacement ?? 0.1;
|
|
2369
2530
|
const secondaryNoise = options.secondaryNoise ?? false;
|
|
2370
2531
|
const color = options.color ?? 8947848;
|
|
2371
|
-
const geometry = new
|
|
2372
|
-
const material = new
|
|
2532
|
+
const geometry = new import_three2.IcosahedronGeometry(radius, detail);
|
|
2533
|
+
const material = new import_three2.MeshStandardMaterial({ color });
|
|
2373
2534
|
super(geometry, material);
|
|
2374
2535
|
const noise3d = (0, import_simplex_noise2.createNoise3D)(rng.nextFloat);
|
|
2375
2536
|
const noise3d2 = secondaryNoise ? (0, import_simplex_noise2.createNoise3D)(rng.nextFloat) : null;
|
|
@@ -2393,13 +2554,13 @@ var AsteroidMesh = class extends import_three.Mesh {
|
|
|
2393
2554
|
};
|
|
2394
2555
|
|
|
2395
2556
|
// src/three/atlas-texture-material.ts
|
|
2396
|
-
var
|
|
2557
|
+
var import_three4 = require("three");
|
|
2397
2558
|
|
|
2398
2559
|
// src/three/texture-utils.ts
|
|
2399
|
-
var
|
|
2560
|
+
var import_three3 = require("three");
|
|
2400
2561
|
function LoadTexture(url) {
|
|
2401
2562
|
return new Promise((res, rej) => {
|
|
2402
|
-
new
|
|
2563
|
+
new import_three3.TextureLoader().load(
|
|
2403
2564
|
url,
|
|
2404
2565
|
(texture) => {
|
|
2405
2566
|
const width = texture.source.data.width;
|
|
@@ -2414,8 +2575,8 @@ function LoadTexture(url) {
|
|
|
2414
2575
|
}
|
|
2415
2576
|
function CreateSubTexture(texture, x, y, w, h) {
|
|
2416
2577
|
const subTexture = texture.clone();
|
|
2417
|
-
subTexture.magFilter =
|
|
2418
|
-
subTexture.wrapS =
|
|
2578
|
+
subTexture.magFilter = import_three3.NearestFilter;
|
|
2579
|
+
subTexture.wrapS = import_three3.RepeatWrapping;
|
|
2419
2580
|
w /= subTexture.width;
|
|
2420
2581
|
h /= subTexture.height;
|
|
2421
2582
|
x /= subTexture.width;
|
|
@@ -2427,7 +2588,7 @@ function CreateSubTexture(texture, x, y, w, h) {
|
|
|
2427
2588
|
}
|
|
2428
2589
|
|
|
2429
2590
|
// src/three/atlas-texture-material.ts
|
|
2430
|
-
var AtlasTextureMaterial = class _AtlasTextureMaterial extends
|
|
2591
|
+
var AtlasTextureMaterial = class _AtlasTextureMaterial extends import_three4.MeshLambertMaterial {
|
|
2431
2592
|
textureData;
|
|
2432
2593
|
tilePixelWidth;
|
|
2433
2594
|
tilePixelHeight;
|
|
@@ -2445,7 +2606,7 @@ var AtlasTextureMaterial = class _AtlasTextureMaterial extends import_three3.Mes
|
|
|
2445
2606
|
...materialParams
|
|
2446
2607
|
});
|
|
2447
2608
|
this.textureData = textureData;
|
|
2448
|
-
this.textureData.texture.magFilter =
|
|
2609
|
+
this.textureData.texture.magFilter = import_three4.NearestFilter;
|
|
2449
2610
|
this.tilePixelWidth = atlasParams.tilePixelWidth ?? 16;
|
|
2450
2611
|
this.tilePixelHeight = atlasParams.tilePixelHeight ?? 16;
|
|
2451
2612
|
this._textureOffsetWidth = atlasParams.tilePixelOffsetWidth ?? 0;
|
|
@@ -2484,7 +2645,7 @@ var AtlasTextureMaterial = class _AtlasTextureMaterial extends import_three3.Mes
|
|
|
2484
2645
|
};
|
|
2485
2646
|
|
|
2486
2647
|
// src/three/camera-rig.ts
|
|
2487
|
-
var
|
|
2648
|
+
var import_three5 = require("three");
|
|
2488
2649
|
var DEFAULT_CAMERA_ASPECT = 2;
|
|
2489
2650
|
var DEFAULT_CAMERA_DISTANCE = 5;
|
|
2490
2651
|
var DEFAULT_CAMERA_FAR = 1e3;
|
|
@@ -2497,7 +2658,7 @@ var DEFAULT_GIMBLE_MAX_ANGLE = 0;
|
|
|
2497
2658
|
var DEFAULT_GIMBLE_MIN_ANGLE = radians(-90);
|
|
2498
2659
|
var DEFAULT_MOUSE_SENSITIVITY = 0.01;
|
|
2499
2660
|
var DEFAULT_WHEEL_SENSITIVITY = 0.02;
|
|
2500
|
-
var CameraRig = class extends
|
|
2661
|
+
var CameraRig = class extends import_three5.Group {
|
|
2501
2662
|
gimbal;
|
|
2502
2663
|
camera;
|
|
2503
2664
|
_target;
|
|
@@ -2510,9 +2671,9 @@ var CameraRig = class extends import_three4.Group {
|
|
|
2510
2671
|
wheelSensitivity = DEFAULT_WHEEL_SENSITIVITY;
|
|
2511
2672
|
constructor(params) {
|
|
2512
2673
|
super();
|
|
2513
|
-
this.gimbal = new
|
|
2674
|
+
this.gimbal = new import_three5.Group();
|
|
2514
2675
|
this.add(this.gimbal);
|
|
2515
|
-
this.camera = new
|
|
2676
|
+
this.camera = new import_three5.PerspectiveCamera(
|
|
2516
2677
|
params?.fov ?? DEFAULT_CAMERA_FOV,
|
|
2517
2678
|
params?.aspect ?? DEFAULT_CAMERA_ASPECT,
|
|
2518
2679
|
params?.near ?? DEFAULT_CAMERA_NEAR,
|
|
@@ -2549,8 +2710,8 @@ var CameraRig = class extends import_three4.Group {
|
|
|
2549
2710
|
};
|
|
2550
2711
|
|
|
2551
2712
|
// src/three/cube-sphere-geometry.ts
|
|
2552
|
-
var
|
|
2553
|
-
var CubeSphereGeometry = class extends
|
|
2713
|
+
var import_three6 = require("three");
|
|
2714
|
+
var CubeSphereGeometry = class extends import_three6.BoxGeometry {
|
|
2554
2715
|
constructor(size, segments) {
|
|
2555
2716
|
size = Math.floor(size);
|
|
2556
2717
|
segments = Math.floor(segments);
|
|
@@ -2559,7 +2720,7 @@ var CubeSphereGeometry = class extends import_three5.BoxGeometry {
|
|
|
2559
2720
|
this.segments = segments;
|
|
2560
2721
|
this._halfSize = this.size / 2;
|
|
2561
2722
|
const attrPositions = this.attributes.position;
|
|
2562
|
-
const position = new
|
|
2723
|
+
const position = new import_three6.Vector3();
|
|
2563
2724
|
for (let i = 0; i < attrPositions.count; i++) {
|
|
2564
2725
|
position.fromBufferAttribute(attrPositions, i);
|
|
2565
2726
|
position.normalize().multiplyScalar(this._halfSize);
|
|
@@ -2572,7 +2733,7 @@ var CubeSphereGeometry = class extends import_three5.BoxGeometry {
|
|
|
2572
2733
|
_halfSize;
|
|
2573
2734
|
applyFractalBrownianMotion(octaves, persistence, scale, amplitude) {
|
|
2574
2735
|
const attrPositions = this.attributes.position;
|
|
2575
|
-
const position = new
|
|
2736
|
+
const position = new import_three6.Vector3();
|
|
2576
2737
|
for (let i = 0; i < attrPositions.count; i++) {
|
|
2577
2738
|
position.fromBufferAttribute(attrPositions, i);
|
|
2578
2739
|
position.normalize().multiplyScalar(this._halfSize);
|
|
@@ -2598,13 +2759,13 @@ var CubeSphereGeometry = class extends import_three5.BoxGeometry {
|
|
|
2598
2759
|
};
|
|
2599
2760
|
|
|
2600
2761
|
// src/three/ecs.ts
|
|
2601
|
-
var
|
|
2762
|
+
var import_three7 = require("three");
|
|
2602
2763
|
var entityCounter = 0;
|
|
2603
2764
|
function GenerateEntityId() {
|
|
2604
2765
|
return `entity_${entityCounter++}`;
|
|
2605
2766
|
}
|
|
2606
2767
|
function CreateThreeEntity(obj) {
|
|
2607
|
-
const entity = obj ?? new
|
|
2768
|
+
const entity = obj ?? new import_three7.Group();
|
|
2608
2769
|
entity.userData.entityId = GenerateEntityId();
|
|
2609
2770
|
entity.userData.components = {};
|
|
2610
2771
|
return entity;
|
|
@@ -2623,7 +2784,7 @@ function IsThreeEntity(obj) {
|
|
|
2623
2784
|
}
|
|
2624
2785
|
|
|
2625
2786
|
// src/three/palette-controller.ts
|
|
2626
|
-
var
|
|
2787
|
+
var import_three8 = require("three");
|
|
2627
2788
|
async function CreatePaletteController(parentGui, colorPalette, onChange, folderName = "palette") {
|
|
2628
2789
|
const { Controller } = await import("three/examples/jsm/libs/lil-gui.module.min.js");
|
|
2629
2790
|
class PaletteControllerImpl extends Controller {
|
|
@@ -2710,12 +2871,12 @@ async function CreatePaletteController(parentGui, colorPalette, onChange, folder
|
|
|
2710
2871
|
this.colorButtons[this.currentColorIndex].style.setProperty("border", this.selectedBorderStyle);
|
|
2711
2872
|
}
|
|
2712
2873
|
findClosestColorMatchIndex(color) {
|
|
2713
|
-
const pickedColor = new
|
|
2714
|
-
const pickedVector = new
|
|
2874
|
+
const pickedColor = new import_three8.Color(color);
|
|
2875
|
+
const pickedVector = new import_three8.Vector3().setFromColor(pickedColor);
|
|
2715
2876
|
const list = [];
|
|
2716
2877
|
this.colorPalette.forEach((paletteColorString, i) => {
|
|
2717
|
-
const paletteColor = new
|
|
2718
|
-
const paletteVector = new
|
|
2878
|
+
const paletteColor = new import_three8.Color(paletteColorString);
|
|
2879
|
+
const paletteVector = new import_three8.Vector3().setFromColor(paletteColor);
|
|
2719
2880
|
const d = paletteVector.distanceTo(pickedVector);
|
|
2720
2881
|
list.push({ i, d });
|
|
2721
2882
|
});
|
|
@@ -2728,7 +2889,7 @@ async function CreatePaletteController(parentGui, colorPalette, onChange, folder
|
|
|
2728
2889
|
}
|
|
2729
2890
|
|
|
2730
2891
|
// src/three/particle-system-3d.ts
|
|
2731
|
-
var
|
|
2892
|
+
var import_three9 = require("three");
|
|
2732
2893
|
var vertexShader = `
|
|
2733
2894
|
uniform float pointSize;
|
|
2734
2895
|
|
|
@@ -2760,7 +2921,7 @@ var Colors = [
|
|
|
2760
2921
|
[1, 0, 1, 1]
|
|
2761
2922
|
// magenta,
|
|
2762
2923
|
];
|
|
2763
|
-
var ParticleSystem3d = class extends
|
|
2924
|
+
var ParticleSystem3d = class extends import_three9.Group {
|
|
2764
2925
|
particleCount = 1e3;
|
|
2765
2926
|
_geometry;
|
|
2766
2927
|
_particles = [];
|
|
@@ -2777,10 +2938,10 @@ var ParticleSystem3d = class extends import_three8.Group {
|
|
|
2777
2938
|
this.position.x = -0.5;
|
|
2778
2939
|
this.position.y = -0.5;
|
|
2779
2940
|
this.position.z = -0.5;
|
|
2780
|
-
this._geometry = new
|
|
2781
|
-
this._geometry.setAttribute("position", new
|
|
2782
|
-
this._geometry.setAttribute("color", new
|
|
2783
|
-
const material = new
|
|
2941
|
+
this._geometry = new import_three9.BufferGeometry();
|
|
2942
|
+
this._geometry.setAttribute("position", new import_three9.Float32BufferAttribute([], 3));
|
|
2943
|
+
this._geometry.setAttribute("color", new import_three9.Float32BufferAttribute([], 4));
|
|
2944
|
+
const material = new import_three9.ShaderMaterial({
|
|
2784
2945
|
uniforms,
|
|
2785
2946
|
vertexShader,
|
|
2786
2947
|
fragmentShader,
|
|
@@ -2788,7 +2949,7 @@ var ParticleSystem3d = class extends import_three8.Group {
|
|
|
2788
2949
|
depthWrite: false,
|
|
2789
2950
|
vertexColors: true
|
|
2790
2951
|
});
|
|
2791
|
-
const pointsMesh = new
|
|
2952
|
+
const pointsMesh = new import_three9.Points(this._geometry, material);
|
|
2792
2953
|
this.add(pointsMesh);
|
|
2793
2954
|
for (let i = 0; i < this.particleCount; i++) {
|
|
2794
2955
|
this._particles.push({
|
|
@@ -2884,8 +3045,8 @@ var ParticleSystem3d = class extends import_three8.Group {
|
|
|
2884
3045
|
}
|
|
2885
3046
|
_sortParticles(camera) {
|
|
2886
3047
|
this._particles.sort((a, b) => {
|
|
2887
|
-
const d1 = camera.position.distanceTo(new
|
|
2888
|
-
const d2 = camera.position.distanceTo(new
|
|
3048
|
+
const d1 = camera.position.distanceTo(new import_three9.Vector3(a.x, a.y, a.z));
|
|
3049
|
+
const d2 = camera.position.distanceTo(new import_three9.Vector3(b.x, b.y, b.z));
|
|
2889
3050
|
return d1 > d2 ? -1 : d1 > d1 ? 1 : 0;
|
|
2890
3051
|
});
|
|
2891
3052
|
}
|
|
@@ -2905,8 +3066,8 @@ var ParticleSystem3d = class extends import_three8.Group {
|
|
|
2905
3066
|
Colors[particle.color][3]
|
|
2906
3067
|
);
|
|
2907
3068
|
}
|
|
2908
|
-
this._geometry.setAttribute("position", new
|
|
2909
|
-
this._geometry.setAttribute("color", new
|
|
3069
|
+
this._geometry.setAttribute("position", new import_three9.Float32BufferAttribute(positions, 3));
|
|
3070
|
+
this._geometry.setAttribute("color", new import_three9.Float32BufferAttribute(colors2, 4));
|
|
2910
3071
|
this._geometry.attributes.position.needsUpdate = true;
|
|
2911
3072
|
}
|
|
2912
3073
|
update(camera, dt) {
|
|
@@ -2918,8 +3079,8 @@ var ParticleSystem3d = class extends import_three8.Group {
|
|
|
2918
3079
|
};
|
|
2919
3080
|
|
|
2920
3081
|
// src/three/renderer.ts
|
|
2921
|
-
var
|
|
2922
|
-
var Renderer = class extends
|
|
3082
|
+
var import_three10 = require("three");
|
|
3083
|
+
var Renderer = class extends import_three10.WebGLRenderer {
|
|
2923
3084
|
get width() {
|
|
2924
3085
|
return this.domElement.width;
|
|
2925
3086
|
}
|
|
@@ -2946,9 +3107,9 @@ var Renderer = class extends import_three9.WebGLRenderer {
|
|
|
2946
3107
|
};
|
|
2947
3108
|
|
|
2948
3109
|
// src/three/starfield.ts
|
|
2949
|
-
var
|
|
3110
|
+
var import_three11 = require("three");
|
|
2950
3111
|
function CreateStarfield(radius = 1e3, count = 5e3, color = 16777215) {
|
|
2951
|
-
const geometry = new
|
|
3112
|
+
const geometry = new import_three11.BufferGeometry();
|
|
2952
3113
|
const positions = new Float32Array(count * 3);
|
|
2953
3114
|
for (let i = 0; i < count; i++) {
|
|
2954
3115
|
const theta = rng.nextFloat() * Math.PI * 2;
|
|
@@ -2958,35 +3119,35 @@ function CreateStarfield(radius = 1e3, count = 5e3, color = 16777215) {
|
|
|
2958
3119
|
const z = radius * Math.cos(phi);
|
|
2959
3120
|
positions.set([x, y, z], i * 3);
|
|
2960
3121
|
}
|
|
2961
|
-
geometry.setAttribute("position", new
|
|
2962
|
-
const material = new
|
|
3122
|
+
geometry.setAttribute("position", new import_three11.BufferAttribute(positions, 3));
|
|
3123
|
+
const material = new import_three11.PointsMaterial({
|
|
2963
3124
|
color,
|
|
2964
3125
|
size: 5,
|
|
2965
3126
|
sizeAttenuation: true,
|
|
2966
3127
|
transparent: true,
|
|
2967
3128
|
opacity: 0.9
|
|
2968
3129
|
});
|
|
2969
|
-
const stars = new
|
|
3130
|
+
const stars = new import_three11.Points(geometry, material);
|
|
2970
3131
|
stars.name = "Starfield";
|
|
2971
3132
|
return stars;
|
|
2972
3133
|
}
|
|
2973
3134
|
function CreateSystemStar(position) {
|
|
2974
|
-
const star = new
|
|
2975
|
-
const starPos = position ?? new
|
|
2976
|
-
const starGeo = new
|
|
2977
|
-
const starMat = new
|
|
2978
|
-
const starMesh = new
|
|
3135
|
+
const star = new import_three11.Group();
|
|
3136
|
+
const starPos = position ?? new import_three11.Vector3();
|
|
3137
|
+
const starGeo = new import_three11.SphereGeometry(50, 32, 32);
|
|
3138
|
+
const starMat = new import_three11.MeshBasicMaterial({ color: 16768426 });
|
|
3139
|
+
const starMesh = new import_three11.Mesh(starGeo, starMat);
|
|
2979
3140
|
starMesh.position.copy(starPos);
|
|
2980
3141
|
star.add(starMesh);
|
|
2981
|
-
const starLight = new
|
|
3142
|
+
const starLight = new import_three11.PointLight(16777215, 10, 0, 0);
|
|
2982
3143
|
starLight.position.copy(starPos);
|
|
2983
3144
|
star.add(starLight);
|
|
2984
3145
|
return star;
|
|
2985
3146
|
}
|
|
2986
3147
|
|
|
2987
3148
|
// src/three/texture-atlas.ts
|
|
2988
|
-
var
|
|
2989
|
-
var TextureAtlas = class _TextureAtlas extends
|
|
3149
|
+
var import_three12 = require("three");
|
|
3150
|
+
var TextureAtlas = class _TextureAtlas extends import_three12.MeshLambertMaterial {
|
|
2990
3151
|
constructor(textureData, textureWidth, textureHeight = textureWidth, params) {
|
|
2991
3152
|
super({
|
|
2992
3153
|
map: textureData.texture,
|
|
@@ -2999,7 +3160,7 @@ var TextureAtlas = class _TextureAtlas extends import_three11.MeshLambertMateria
|
|
|
2999
3160
|
this.textureHeight = textureHeight;
|
|
3000
3161
|
this._uw = this.textureWidth / this.textureData.width;
|
|
3001
3162
|
this._uh = this.textureHeight / this.textureData.height;
|
|
3002
|
-
this.textureData.texture.magFilter =
|
|
3163
|
+
this.textureData.texture.magFilter = import_three12.NearestFilter;
|
|
3003
3164
|
}
|
|
3004
3165
|
textureData;
|
|
3005
3166
|
textureWidth;
|
|
@@ -3023,8 +3184,8 @@ var TextureAtlas = class _TextureAtlas extends import_three11.MeshLambertMateria
|
|
|
3023
3184
|
};
|
|
3024
3185
|
|
|
3025
3186
|
// src/three/threejs-camera-rig.ts
|
|
3026
|
-
var
|
|
3027
|
-
var ThreeJsCameraRig = class extends
|
|
3187
|
+
var import_three13 = require("three");
|
|
3188
|
+
var ThreeJsCameraRig = class extends import_three13.Group {
|
|
3028
3189
|
gimbal;
|
|
3029
3190
|
camera;
|
|
3030
3191
|
target;
|
|
@@ -3037,9 +3198,9 @@ var ThreeJsCameraRig = class extends import_three12.Group {
|
|
|
3037
3198
|
clampTiltAngle = false;
|
|
3038
3199
|
constructor(params) {
|
|
3039
3200
|
super();
|
|
3040
|
-
this.gimbal = new
|
|
3201
|
+
this.gimbal = new import_three13.Group();
|
|
3041
3202
|
this.add(this.gimbal);
|
|
3042
|
-
this.camera = params?.camera ?? new
|
|
3203
|
+
this.camera = params?.camera ?? new import_three13.PerspectiveCamera(
|
|
3043
3204
|
params?.fov ?? 75,
|
|
3044
3205
|
params?.aspect ?? 2,
|
|
3045
3206
|
params?.near ?? 0.1,
|
|
@@ -3065,14 +3226,14 @@ var ThreeJsCameraRig = class extends import_three12.Group {
|
|
|
3065
3226
|
};
|
|
3066
3227
|
|
|
3067
3228
|
// src/three/threejs-player-controller.ts
|
|
3068
|
-
var
|
|
3069
|
-
var ThreeJsPlayerController = class extends
|
|
3229
|
+
var import_three14 = require("three");
|
|
3230
|
+
var ThreeJsPlayerController = class extends import_three14.Group {
|
|
3070
3231
|
moveSpeed = 1;
|
|
3071
3232
|
cameraRig;
|
|
3072
3233
|
velocity;
|
|
3073
3234
|
constructor(camera) {
|
|
3074
3235
|
super();
|
|
3075
|
-
this.velocity = new
|
|
3236
|
+
this.velocity = new import_three14.Vector3();
|
|
3076
3237
|
this.cameraRig = new ThreeJsCameraRig({ camera });
|
|
3077
3238
|
this.add(this.cameraRig);
|
|
3078
3239
|
}
|
|
@@ -3084,8 +3245,8 @@ var ThreeJsPlayerController = class extends import_three13.Group {
|
|
|
3084
3245
|
};
|
|
3085
3246
|
|
|
3086
3247
|
// src/three/voxel-geometry.ts
|
|
3087
|
-
var
|
|
3088
|
-
var VoxelGeometry = class extends
|
|
3248
|
+
var import_three15 = require("three");
|
|
3249
|
+
var VoxelGeometry = class extends import_three15.BufferGeometry {
|
|
3089
3250
|
type = "VoxelGeometry";
|
|
3090
3251
|
voxels = new Map3D();
|
|
3091
3252
|
voxelBuildParams = {};
|
|
@@ -3152,9 +3313,9 @@ function BuildVoxelGeometry(voxelMap, params) {
|
|
|
3152
3313
|
}
|
|
3153
3314
|
});
|
|
3154
3315
|
const geometry = params.voxelGeometry ?? new VoxelGeometry();
|
|
3155
|
-
geometry.setAttribute("position", new
|
|
3156
|
-
geometry.setAttribute("normal", new
|
|
3157
|
-
geometry.setAttribute("color", new
|
|
3316
|
+
geometry.setAttribute("position", new import_three15.Float32BufferAttribute(positions, 3));
|
|
3317
|
+
geometry.setAttribute("normal", new import_three15.Float32BufferAttribute(normals, 3));
|
|
3318
|
+
geometry.setAttribute("color", new import_three15.Float32BufferAttribute(colors2, 3));
|
|
3158
3319
|
geometry.setIndex(indices);
|
|
3159
3320
|
if (smoothNormals) geometry.computeVertexNormals();
|
|
3160
3321
|
geometry.computeBoundingBox();
|
|
@@ -3273,8 +3434,8 @@ var VOXEL_FACES = [
|
|
|
3273
3434
|
];
|
|
3274
3435
|
|
|
3275
3436
|
// src/three/voxel-mesh.ts
|
|
3276
|
-
var
|
|
3277
|
-
var VoxelMesh = class extends
|
|
3437
|
+
var import_three16 = require("three");
|
|
3438
|
+
var VoxelMesh = class extends import_three16.Mesh {
|
|
3278
3439
|
type = "VoxelMesh";
|
|
3279
3440
|
width;
|
|
3280
3441
|
depth;
|
|
@@ -3292,7 +3453,7 @@ var VoxelMesh = class extends import_three15.Mesh {
|
|
|
3292
3453
|
this.name = name ?? "VoxelMesh";
|
|
3293
3454
|
this.colorPalette = BuildDefaultPalette();
|
|
3294
3455
|
this.voxels = /* @__PURE__ */ new Map();
|
|
3295
|
-
this.geometry = new
|
|
3456
|
+
this.geometry = new import_three16.BufferGeometry();
|
|
3296
3457
|
this.updateGeometry();
|
|
3297
3458
|
}
|
|
3298
3459
|
_xyz2k(x, y, z) {
|
|
@@ -3370,7 +3531,7 @@ var VoxelMesh = class extends import_three15.Mesh {
|
|
|
3370
3531
|
const [nx, ny, nz, px, py, pz] = face;
|
|
3371
3532
|
positions.push(x + px, y + py, z + pz);
|
|
3372
3533
|
normals.push(nx, ny, nz);
|
|
3373
|
-
const { r, g, b } = new
|
|
3534
|
+
const { r, g, b } = new import_three16.Color(this.colorPalette[n]);
|
|
3374
3535
|
colors2.push(r, g, b, 1);
|
|
3375
3536
|
});
|
|
3376
3537
|
indices.push(
|
|
@@ -3384,9 +3545,9 @@ var VoxelMesh = class extends import_three15.Mesh {
|
|
|
3384
3545
|
}
|
|
3385
3546
|
});
|
|
3386
3547
|
});
|
|
3387
|
-
this.geometry.setAttribute("position", new
|
|
3388
|
-
this.geometry.setAttribute("normal", new
|
|
3389
|
-
this.geometry.setAttribute("color", new
|
|
3548
|
+
this.geometry.setAttribute("position", new import_three16.BufferAttribute(new Float32Array(positions), 3));
|
|
3549
|
+
this.geometry.setAttribute("normal", new import_three16.BufferAttribute(new Float32Array(normals), 3));
|
|
3550
|
+
this.geometry.setAttribute("color", new import_three16.BufferAttribute(new Float32Array(colors2), 4));
|
|
3390
3551
|
this.geometry.setIndex(indices);
|
|
3391
3552
|
this.geometry.computeBoundingSphere();
|
|
3392
3553
|
this.updateMatrixWorld();
|
|
@@ -3804,10 +3965,12 @@ var WorkerInterface = class {
|
|
|
3804
3965
|
DEFAULT_TEXTALIGN,
|
|
3805
3966
|
DEFAULT_TEXTBASELINE,
|
|
3806
3967
|
DEG2RAD,
|
|
3968
|
+
DebugRenderer,
|
|
3807
3969
|
Disposable,
|
|
3808
3970
|
E,
|
|
3809
3971
|
ECS,
|
|
3810
3972
|
EPSILON,
|
|
3973
|
+
Emitter,
|
|
3811
3974
|
EventQueue,
|
|
3812
3975
|
GenerateDoors,
|
|
3813
3976
|
GenerateEntityId,
|
|
@@ -3864,6 +4027,7 @@ var WorkerInterface = class {
|
|
|
3864
4027
|
VoxelMesh,
|
|
3865
4028
|
WebGlRenderer,
|
|
3866
4029
|
WorkerInterface,
|
|
4030
|
+
buildColorPalette,
|
|
3867
4031
|
clamp,
|
|
3868
4032
|
degrees,
|
|
3869
4033
|
distance2d,
|
|
@@ -3878,6 +4042,7 @@ var WorkerInterface = class {
|
|
|
3878
4042
|
k2xy,
|
|
3879
4043
|
k2xyz,
|
|
3880
4044
|
lerp,
|
|
4045
|
+
log,
|
|
3881
4046
|
manhattanDistance,
|
|
3882
4047
|
mod,
|
|
3883
4048
|
nearlyEqual,
|