@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.mjs
CHANGED
|
@@ -1,3 +1,179 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod2) => function __require() {
|
|
11
|
+
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
|
|
12
|
+
};
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __reExport = (target, mod2, secondTarget) => (__copyProps(target, mod2, "default"), secondTarget && __copyProps(secondTarget, mod2, "default"));
|
|
26
|
+
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
|
|
32
|
+
mod2
|
|
33
|
+
));
|
|
34
|
+
|
|
35
|
+
// src/css/main.css
|
|
36
|
+
var init_main = __esm({
|
|
37
|
+
"src/css/main.css"() {
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// src/css/index.ts
|
|
42
|
+
var require_css = __commonJS({
|
|
43
|
+
"src/css/index.ts"() {
|
|
44
|
+
"use strict";
|
|
45
|
+
init_main();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// src/index.ts
|
|
50
|
+
var index_exports = {};
|
|
51
|
+
__export(index_exports, {
|
|
52
|
+
AStar: () => AStar,
|
|
53
|
+
AddThreeComponent: () => AddThreeComponent,
|
|
54
|
+
AsteroidMesh: () => AsteroidMesh,
|
|
55
|
+
AtlasTextureMaterial: () => AtlasTextureMaterial,
|
|
56
|
+
BuildDefaultPalette: () => BuildDefaultPalette,
|
|
57
|
+
BuildVoxelGeometry: () => BuildVoxelGeometry,
|
|
58
|
+
CameraRig: () => CameraRig,
|
|
59
|
+
CanvasRenderer: () => CanvasRenderer,
|
|
60
|
+
Clock: () => Clock,
|
|
61
|
+
Color: () => Color,
|
|
62
|
+
Colors: () => Colors2,
|
|
63
|
+
CompileShader: () => CompileShader,
|
|
64
|
+
CreatePaletteController: () => CreatePaletteController,
|
|
65
|
+
CreateProgram: () => CreateProgram,
|
|
66
|
+
CreateProgramInfo: () => CreateProgramInfo,
|
|
67
|
+
CreateStarfield: () => CreateStarfield,
|
|
68
|
+
CreateSubTexture: () => CreateSubTexture,
|
|
69
|
+
CreateSystemStar: () => CreateSystemStar,
|
|
70
|
+
CreateThreeEntity: () => CreateThreeEntity,
|
|
71
|
+
CreateWebGlContext: () => CreateWebGlContext,
|
|
72
|
+
CubeSphereGeometry: () => CubeSphereGeometry,
|
|
73
|
+
DEFAULT_COLOR: () => DEFAULT_COLOR,
|
|
74
|
+
DEFAULT_FONT: () => DEFAULT_FONT,
|
|
75
|
+
DEFAULT_FONT_NAME: () => DEFAULT_FONT_NAME,
|
|
76
|
+
DEFAULT_FONT_SIZE: () => DEFAULT_FONT_SIZE,
|
|
77
|
+
DEFAULT_MAP_2D_VALUE: () => DEFAULT_MAP_2D_VALUE,
|
|
78
|
+
DEFAULT_MAP_3D_VALUE: () => DEFAULT_MAP_3D_VALUE,
|
|
79
|
+
DEFAULT_PIXEL_SIZE: () => DEFAULT_PIXEL_SIZE,
|
|
80
|
+
DEFAULT_TEXTALIGN: () => DEFAULT_TEXTALIGN,
|
|
81
|
+
DEFAULT_TEXTBASELINE: () => DEFAULT_TEXTBASELINE,
|
|
82
|
+
DEG2RAD: () => DEG2RAD,
|
|
83
|
+
DebugRenderer: () => DebugRenderer,
|
|
84
|
+
Disposable: () => Disposable,
|
|
85
|
+
E: () => E,
|
|
86
|
+
ECS: () => ECS,
|
|
87
|
+
EPSILON: () => EPSILON,
|
|
88
|
+
Emitter: () => Emitter,
|
|
89
|
+
EventQueue: () => EventQueue,
|
|
90
|
+
GenerateDoors: () => GenerateDoors,
|
|
91
|
+
GenerateEntityId: () => GenerateEntityId,
|
|
92
|
+
GenerateRooms: () => GenerateRooms,
|
|
93
|
+
GenerateWalls: () => GenerateWalls,
|
|
94
|
+
GetProgramLocations: () => GetProgramLocations,
|
|
95
|
+
GetThreeComponent: () => GetThreeComponent,
|
|
96
|
+
GetUrlParams: () => GetUrlParams,
|
|
97
|
+
HALF_PI: () => HALF_PI,
|
|
98
|
+
Input: () => Input,
|
|
99
|
+
IsThreeEntity: () => IsThreeEntity,
|
|
100
|
+
LN10: () => LN10,
|
|
101
|
+
LN2: () => LN2,
|
|
102
|
+
LOG10E: () => LOG10E,
|
|
103
|
+
LOG2E: () => LOG2E,
|
|
104
|
+
LoadTexture: () => LoadTexture,
|
|
105
|
+
Map2D: () => Map2D,
|
|
106
|
+
Map3D: () => Map3D,
|
|
107
|
+
Noise: () => Noise,
|
|
108
|
+
ONE_SECOND: () => ONE_SECOND,
|
|
109
|
+
Observable: () => Observable,
|
|
110
|
+
PI: () => PI,
|
|
111
|
+
ParticleRenderer: () => ParticleRenderer,
|
|
112
|
+
ParticleSystem2d: () => ParticleSystem2d,
|
|
113
|
+
ParticleSystem3d: () => ParticleSystem3d,
|
|
114
|
+
PoissonDiskSampler: () => PoissonDiskSampler,
|
|
115
|
+
QUARTER_PI: () => QUARTER_PI,
|
|
116
|
+
RAD2DEG: () => RAD2DEG,
|
|
117
|
+
Random: () => Random,
|
|
118
|
+
Rectangle: () => Rectangle,
|
|
119
|
+
RemoveThreeComponent: () => RemoveThreeComponent,
|
|
120
|
+
Renderer: () => Renderer,
|
|
121
|
+
ResizeWebGlContext: () => ResizeWebGlContext,
|
|
122
|
+
Rng: () => Rng,
|
|
123
|
+
SQRT1_2: () => SQRT1_2,
|
|
124
|
+
SQRT2: () => SQRT2,
|
|
125
|
+
ShaderType: () => ShaderType,
|
|
126
|
+
Signal: () => Signal,
|
|
127
|
+
SimplexNoise: () => SimplexNoise,
|
|
128
|
+
SpatialPartition2d: () => SpatialPartition2d,
|
|
129
|
+
SpatialPartition3d: () => SpatialPartition3d,
|
|
130
|
+
TAU: () => TAU,
|
|
131
|
+
TILE_EMPTY: () => TILE_EMPTY,
|
|
132
|
+
TILE_FLOOR: () => TILE_FLOOR,
|
|
133
|
+
TILE_PATH: () => TILE_PATH,
|
|
134
|
+
TextureAtlas: () => TextureAtlas,
|
|
135
|
+
ThreeJsCameraRig: () => ThreeJsCameraRig,
|
|
136
|
+
ThreeJsPlayerController: () => ThreeJsPlayerController,
|
|
137
|
+
Tilemap: () => Tilemap,
|
|
138
|
+
VOXEL_FACES: () => VOXEL_FACES,
|
|
139
|
+
Vector: () => Vector,
|
|
140
|
+
VoxelFaces: () => VoxelFaces,
|
|
141
|
+
VoxelGeometry: () => VoxelGeometry,
|
|
142
|
+
VoxelMesh: () => VoxelMesh,
|
|
143
|
+
WebGlRenderer: () => WebGlRenderer,
|
|
144
|
+
WorkerInterface: () => WorkerInterface,
|
|
145
|
+
buildColorPalette: () => buildColorPalette,
|
|
146
|
+
clamp: () => clamp,
|
|
147
|
+
degrees: () => degrees,
|
|
148
|
+
distance2d: () => distance2d,
|
|
149
|
+
distance3d: () => distance3d,
|
|
150
|
+
fract: () => fract,
|
|
151
|
+
getRedYellowGreenGradientHex: () => getRedYellowGreenGradientHex,
|
|
152
|
+
hash32: () => hash32,
|
|
153
|
+
hash32mix: () => hash32mix,
|
|
154
|
+
inverseLerp: () => inverseLerp,
|
|
155
|
+
isNullOrUndefined: () => isNullOrUndefined,
|
|
156
|
+
isPositiveString: () => isPositiveString,
|
|
157
|
+
k2xy: () => k2xy,
|
|
158
|
+
k2xyz: () => k2xyz,
|
|
159
|
+
lerp: () => lerp,
|
|
160
|
+
log: () => log,
|
|
161
|
+
manhattanDistance: () => manhattanDistance,
|
|
162
|
+
mod: () => mod,
|
|
163
|
+
nearlyEqual: () => nearlyEqual,
|
|
164
|
+
normalizeRadians: () => normalizeRadians,
|
|
165
|
+
radians: () => radians,
|
|
166
|
+
randomMatrix: () => randomMatrix,
|
|
167
|
+
rng: () => rng,
|
|
168
|
+
roundTo: () => roundTo,
|
|
169
|
+
saturate: () => saturate,
|
|
170
|
+
smoothstep: () => smoothstep,
|
|
171
|
+
squaredDistance: () => squaredDistance,
|
|
172
|
+
wrap: () => wrap,
|
|
173
|
+
xy2k: () => xy2k,
|
|
174
|
+
xyz2k: () => xyz2k
|
|
175
|
+
});
|
|
176
|
+
|
|
1
177
|
// src/astar.ts
|
|
2
178
|
var DIRECTIONS_4_WAY = [
|
|
3
179
|
{ x: 0, y: -1 },
|
|
@@ -370,8 +546,69 @@ var Clock = class {
|
|
|
370
546
|
}
|
|
371
547
|
};
|
|
372
548
|
|
|
549
|
+
// src/color-palette.ts
|
|
550
|
+
var DEFAULT_COLORS = [
|
|
551
|
+
[237, 28, 36],
|
|
552
|
+
// red
|
|
553
|
+
[255, 127, 39],
|
|
554
|
+
// orange
|
|
555
|
+
[255, 242, 0],
|
|
556
|
+
// yellow
|
|
557
|
+
[34, 177, 76],
|
|
558
|
+
// green
|
|
559
|
+
[0, 183, 239],
|
|
560
|
+
// cyan
|
|
561
|
+
[63, 72, 204],
|
|
562
|
+
// blue
|
|
563
|
+
[163, 73, 164],
|
|
564
|
+
// purple
|
|
565
|
+
[236, 0, 140],
|
|
566
|
+
// magenta
|
|
567
|
+
[255, 174, 201],
|
|
568
|
+
// pink
|
|
569
|
+
[139, 90, 43],
|
|
570
|
+
// brown
|
|
571
|
+
[214, 181, 129],
|
|
572
|
+
// tan
|
|
573
|
+
[128, 128, 0],
|
|
574
|
+
// olive
|
|
575
|
+
[0, 128, 128],
|
|
576
|
+
// teal
|
|
577
|
+
[128, 0, 32]
|
|
578
|
+
// maroon
|
|
579
|
+
];
|
|
580
|
+
function packRGB(r, g, b) {
|
|
581
|
+
r = Math.min(255, Math.max(0, Math.round(r)));
|
|
582
|
+
g = Math.min(255, Math.max(0, Math.round(g)));
|
|
583
|
+
b = Math.min(255, Math.max(0, Math.round(b)));
|
|
584
|
+
return r << 16 | g << 8 | b;
|
|
585
|
+
}
|
|
586
|
+
var DARK_FLOOR = 0.28;
|
|
587
|
+
function colorRamp(rgb, steps) {
|
|
588
|
+
const [r, g, b] = rgb;
|
|
589
|
+
const out = [];
|
|
590
|
+
for (let i = 0; i < steps; i++) {
|
|
591
|
+
const t = steps === 1 ? 0 : i / (steps - 1);
|
|
592
|
+
const scale = 1 - t * (1 - DARK_FLOOR);
|
|
593
|
+
out.push(packRGB(r * scale, g * scale, b * scale));
|
|
594
|
+
}
|
|
595
|
+
return out;
|
|
596
|
+
}
|
|
597
|
+
function buildColorPalette(grayscaleSteps = 8, colorSteps = 4, ...colors2) {
|
|
598
|
+
const palette = [];
|
|
599
|
+
for (let i = 0; i < grayscaleSteps; i++) {
|
|
600
|
+
const v = grayscaleSteps === 1 ? 0 : i / (grayscaleSteps - 1) * 255;
|
|
601
|
+
palette.push(packRGB(v, v, v));
|
|
602
|
+
}
|
|
603
|
+
const colorList = colors2.length > 0 ? colors2 : DEFAULT_COLORS;
|
|
604
|
+
for (const rgb of colorList) {
|
|
605
|
+
palette.push(...colorRamp(rgb, colorSteps));
|
|
606
|
+
}
|
|
607
|
+
return palette;
|
|
608
|
+
}
|
|
609
|
+
|
|
373
610
|
// src/log.ts
|
|
374
|
-
var
|
|
611
|
+
var log = console.debug.bind(
|
|
375
612
|
console,
|
|
376
613
|
"%c[dev]",
|
|
377
614
|
"font-weight: bold; color: #888;"
|
|
@@ -420,7 +657,7 @@ var Color = class _Color {
|
|
|
420
657
|
[this._r, this._g, this._b, this._a] = this._parse_hex_color_string(value);
|
|
421
658
|
this._hex = value;
|
|
422
659
|
} else {
|
|
423
|
-
|
|
660
|
+
log(`Color: invalid color string: ${value}. Should be a hexadecimal color string (i.e.: '#ffffff' or '#ffffffff'). Keeping the current color.`);
|
|
424
661
|
}
|
|
425
662
|
}
|
|
426
663
|
get rgba() {
|
|
@@ -431,7 +668,7 @@ var Color = class _Color {
|
|
|
431
668
|
if (r.startsWith("#")) {
|
|
432
669
|
[r, g, b, a] = this._parse_hex_color_string(r);
|
|
433
670
|
} else {
|
|
434
|
-
|
|
671
|
+
log(`Color: invalid color string: ${r}. Should be a hexadecimal color string (i.e.: '#ffffff' or '#ffffffff'). Defaulting to opaque white.`);
|
|
435
672
|
r = g = b = a = 255;
|
|
436
673
|
}
|
|
437
674
|
} else {
|
|
@@ -532,7 +769,7 @@ var Color = class _Color {
|
|
|
532
769
|
const [r, g, b, a] = rgba.map(Number);
|
|
533
770
|
return new _Color(r, g, b, a);
|
|
534
771
|
} else {
|
|
535
|
-
|
|
772
|
+
log(`Color: invalid CSS color name: ${name}. Defaulting to transparent.`);
|
|
536
773
|
return _Color.TRANSPARENT;
|
|
537
774
|
}
|
|
538
775
|
}
|
|
@@ -541,6 +778,81 @@ var Color = class _Color {
|
|
|
541
778
|
}
|
|
542
779
|
};
|
|
543
780
|
|
|
781
|
+
// src/index.ts
|
|
782
|
+
__reExport(index_exports, __toESM(require_css()));
|
|
783
|
+
|
|
784
|
+
// src/debug-label.ts
|
|
785
|
+
import { BufferGeometry, Line, LineBasicMaterial, Vector3 } from "three";
|
|
786
|
+
import { CSS2DRenderer, CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
|
|
787
|
+
var labelRenderer = new CSS2DRenderer();
|
|
788
|
+
labelRenderer.setSize(window.innerWidth, window.innerHeight);
|
|
789
|
+
labelRenderer.domElement.style.position = "absolute";
|
|
790
|
+
labelRenderer.domElement.style.top = "0px";
|
|
791
|
+
labelRenderer.domElement.style.pointerEvents = "none";
|
|
792
|
+
document.body.appendChild(labelRenderer.domElement);
|
|
793
|
+
window.addEventListener("resize", () => {
|
|
794
|
+
labelRenderer.setSize(window.innerWidth, window.innerHeight);
|
|
795
|
+
});
|
|
796
|
+
var FONT_SIZE = 12;
|
|
797
|
+
var DebugRenderer = class extends CSS2DRenderer {
|
|
798
|
+
_labels = /* @__PURE__ */ new Set();
|
|
799
|
+
get width() {
|
|
800
|
+
return this.domElement.clientWidth;
|
|
801
|
+
}
|
|
802
|
+
get height() {
|
|
803
|
+
return this.domElement.clientHeight;
|
|
804
|
+
}
|
|
805
|
+
constructor() {
|
|
806
|
+
super();
|
|
807
|
+
this.setSize(window.innerWidth, window.innerHeight);
|
|
808
|
+
this.domElement.style.position = "absolute";
|
|
809
|
+
this.domElement.style.top = "0px";
|
|
810
|
+
this.domElement.style.pointerEvents = "none";
|
|
811
|
+
}
|
|
812
|
+
resize(width, height) {
|
|
813
|
+
let resized = false;
|
|
814
|
+
width = width ?? this.domElement.parentElement?.clientWidth ?? this.width;
|
|
815
|
+
height = height ?? this.domElement.parentElement?.clientHeight ?? this.height;
|
|
816
|
+
if (this.width !== width || this.height !== height) {
|
|
817
|
+
this.setSize(width, height);
|
|
818
|
+
resized = true;
|
|
819
|
+
}
|
|
820
|
+
return resized;
|
|
821
|
+
}
|
|
822
|
+
createLabel(text, offset) {
|
|
823
|
+
if (!Array.isArray(text)) text = [text];
|
|
824
|
+
offset = offset ?? new Vector3(0, -1, 0);
|
|
825
|
+
const div = document.createElement("div");
|
|
826
|
+
div.innerHTML = text.join("<br>");
|
|
827
|
+
div.style.cssText = `
|
|
828
|
+
color: #888;
|
|
829
|
+
font: ${FONT_SIZE}px monospace;
|
|
830
|
+
padding: 4px 8px;
|
|
831
|
+
background: rgba(0,0,0,0.7);
|
|
832
|
+
border-radius: 4px;
|
|
833
|
+
border: 1px dashed #fff;
|
|
834
|
+
white-space: nowrap;
|
|
835
|
+
`;
|
|
836
|
+
const label = new CSS2DObject(div);
|
|
837
|
+
const lineGeometry = new BufferGeometry().setFromPoints([
|
|
838
|
+
new Vector3(0, 0, 0),
|
|
839
|
+
offset
|
|
840
|
+
]);
|
|
841
|
+
const lineMaterial = new LineBasicMaterial({
|
|
842
|
+
color: 16777215,
|
|
843
|
+
transparent: true,
|
|
844
|
+
opacity: 0.5,
|
|
845
|
+
depthTest: false
|
|
846
|
+
// keep visible through geometry, like a debug overlay
|
|
847
|
+
});
|
|
848
|
+
const line = new Line(lineGeometry, lineMaterial);
|
|
849
|
+
line.renderOrder = 999;
|
|
850
|
+
const debugLabel = { div, label, line };
|
|
851
|
+
this._labels.add(debugLabel);
|
|
852
|
+
return debugLabel;
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
|
|
544
856
|
// src/disposable.ts
|
|
545
857
|
var Disposable = class {
|
|
546
858
|
disposers = [];
|
|
@@ -1161,7 +1473,7 @@ function GenerateRooms(params = {}) {
|
|
|
1161
1473
|
_plot(map, rooms, TILE_FLOOR);
|
|
1162
1474
|
const paths = _generatePaths(map, rooms, params.paths);
|
|
1163
1475
|
_plot(map, paths, TILE_PATH);
|
|
1164
|
-
|
|
1476
|
+
log("GenerateRooms: done:", Date.now() - startTime, "ms");
|
|
1165
1477
|
return { map, rooms, paths };
|
|
1166
1478
|
}
|
|
1167
1479
|
function GenerateDoors(map, paths, params = {}) {
|
|
@@ -1267,26 +1579,6 @@ var ECS = class _ECS {
|
|
|
1267
1579
|
}
|
|
1268
1580
|
};
|
|
1269
1581
|
|
|
1270
|
-
// src/event-queue.ts
|
|
1271
|
-
var EventQueue = class {
|
|
1272
|
-
events = [];
|
|
1273
|
-
emit(event) {
|
|
1274
|
-
this.events.push(event);
|
|
1275
|
-
}
|
|
1276
|
-
consume() {
|
|
1277
|
-
return this.events;
|
|
1278
|
-
}
|
|
1279
|
-
clear() {
|
|
1280
|
-
this.events.length = 0;
|
|
1281
|
-
}
|
|
1282
|
-
drain() {
|
|
1283
|
-
return this.events.splice(0);
|
|
1284
|
-
}
|
|
1285
|
-
get size() {
|
|
1286
|
-
return this.events.length;
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
|
|
1290
1582
|
// src/emitter.ts
|
|
1291
1583
|
var Emitter = class {
|
|
1292
1584
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -1309,6 +1601,26 @@ var Emitter = class {
|
|
|
1309
1601
|
}
|
|
1310
1602
|
};
|
|
1311
1603
|
|
|
1604
|
+
// src/event-queue.ts
|
|
1605
|
+
var EventQueue = class {
|
|
1606
|
+
events = [];
|
|
1607
|
+
emit(event) {
|
|
1608
|
+
this.events.push(event);
|
|
1609
|
+
}
|
|
1610
|
+
consume() {
|
|
1611
|
+
return this.events;
|
|
1612
|
+
}
|
|
1613
|
+
clear() {
|
|
1614
|
+
this.events.length = 0;
|
|
1615
|
+
}
|
|
1616
|
+
drain() {
|
|
1617
|
+
return this.events.splice(0);
|
|
1618
|
+
}
|
|
1619
|
+
get size() {
|
|
1620
|
+
return this.events.length;
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
|
|
1312
1624
|
// src/input.ts
|
|
1313
1625
|
var Input = class _Input extends Emitter {
|
|
1314
1626
|
static _instance;
|
|
@@ -2395,7 +2707,7 @@ var CameraRig = class extends Group {
|
|
|
2395
2707
|
};
|
|
2396
2708
|
|
|
2397
2709
|
// src/three/cube-sphere-geometry.ts
|
|
2398
|
-
import { BoxGeometry, Vector3 } from "three";
|
|
2710
|
+
import { BoxGeometry, Vector3 as Vector32 } from "three";
|
|
2399
2711
|
var CubeSphereGeometry = class extends BoxGeometry {
|
|
2400
2712
|
constructor(size, segments) {
|
|
2401
2713
|
size = Math.floor(size);
|
|
@@ -2405,7 +2717,7 @@ var CubeSphereGeometry = class extends BoxGeometry {
|
|
|
2405
2717
|
this.segments = segments;
|
|
2406
2718
|
this._halfSize = this.size / 2;
|
|
2407
2719
|
const attrPositions = this.attributes.position;
|
|
2408
|
-
const position = new
|
|
2720
|
+
const position = new Vector32();
|
|
2409
2721
|
for (let i = 0; i < attrPositions.count; i++) {
|
|
2410
2722
|
position.fromBufferAttribute(attrPositions, i);
|
|
2411
2723
|
position.normalize().multiplyScalar(this._halfSize);
|
|
@@ -2418,7 +2730,7 @@ var CubeSphereGeometry = class extends BoxGeometry {
|
|
|
2418
2730
|
_halfSize;
|
|
2419
2731
|
applyFractalBrownianMotion(octaves, persistence, scale, amplitude) {
|
|
2420
2732
|
const attrPositions = this.attributes.position;
|
|
2421
|
-
const position = new
|
|
2733
|
+
const position = new Vector32();
|
|
2422
2734
|
for (let i = 0; i < attrPositions.count; i++) {
|
|
2423
2735
|
position.fromBufferAttribute(attrPositions, i);
|
|
2424
2736
|
position.normalize().multiplyScalar(this._halfSize);
|
|
@@ -2469,7 +2781,7 @@ function IsThreeEntity(obj) {
|
|
|
2469
2781
|
}
|
|
2470
2782
|
|
|
2471
2783
|
// src/three/palette-controller.ts
|
|
2472
|
-
import { Color as Color2, Vector3 as
|
|
2784
|
+
import { Color as Color2, Vector3 as Vector33 } from "three";
|
|
2473
2785
|
async function CreatePaletteController(parentGui, colorPalette, onChange, folderName = "palette") {
|
|
2474
2786
|
const { Controller } = await import("three/examples/jsm/libs/lil-gui.module.min.js");
|
|
2475
2787
|
class PaletteControllerImpl extends Controller {
|
|
@@ -2557,11 +2869,11 @@ async function CreatePaletteController(parentGui, colorPalette, onChange, folder
|
|
|
2557
2869
|
}
|
|
2558
2870
|
findClosestColorMatchIndex(color) {
|
|
2559
2871
|
const pickedColor = new Color2(color);
|
|
2560
|
-
const pickedVector = new
|
|
2872
|
+
const pickedVector = new Vector33().setFromColor(pickedColor);
|
|
2561
2873
|
const list = [];
|
|
2562
2874
|
this.colorPalette.forEach((paletteColorString, i) => {
|
|
2563
2875
|
const paletteColor = new Color2(paletteColorString);
|
|
2564
|
-
const paletteVector = new
|
|
2876
|
+
const paletteVector = new Vector33().setFromColor(paletteColor);
|
|
2565
2877
|
const d = paletteVector.distanceTo(pickedVector);
|
|
2566
2878
|
list.push({ i, d });
|
|
2567
2879
|
});
|
|
@@ -2574,7 +2886,7 @@ async function CreatePaletteController(parentGui, colorPalette, onChange, folder
|
|
|
2574
2886
|
}
|
|
2575
2887
|
|
|
2576
2888
|
// src/three/particle-system-3d.ts
|
|
2577
|
-
import { BufferGeometry, Float32BufferAttribute, Group as Group3, Points, ShaderMaterial, Vector3 as
|
|
2889
|
+
import { BufferGeometry as BufferGeometry2, Float32BufferAttribute, Group as Group3, Points, ShaderMaterial, Vector3 as Vector34 } from "three";
|
|
2578
2890
|
var vertexShader = `
|
|
2579
2891
|
uniform float pointSize;
|
|
2580
2892
|
|
|
@@ -2623,7 +2935,7 @@ var ParticleSystem3d = class extends Group3 {
|
|
|
2623
2935
|
this.position.x = -0.5;
|
|
2624
2936
|
this.position.y = -0.5;
|
|
2625
2937
|
this.position.z = -0.5;
|
|
2626
|
-
this._geometry = new
|
|
2938
|
+
this._geometry = new BufferGeometry2();
|
|
2627
2939
|
this._geometry.setAttribute("position", new Float32BufferAttribute([], 3));
|
|
2628
2940
|
this._geometry.setAttribute("color", new Float32BufferAttribute([], 4));
|
|
2629
2941
|
const material = new ShaderMaterial({
|
|
@@ -2730,8 +3042,8 @@ var ParticleSystem3d = class extends Group3 {
|
|
|
2730
3042
|
}
|
|
2731
3043
|
_sortParticles(camera) {
|
|
2732
3044
|
this._particles.sort((a, b) => {
|
|
2733
|
-
const d1 = camera.position.distanceTo(new
|
|
2734
|
-
const d2 = camera.position.distanceTo(new
|
|
3045
|
+
const d1 = camera.position.distanceTo(new Vector34(a.x, a.y, a.z));
|
|
3046
|
+
const d2 = camera.position.distanceTo(new Vector34(b.x, b.y, b.z));
|
|
2735
3047
|
return d1 > d2 ? -1 : d1 > d1 ? 1 : 0;
|
|
2736
3048
|
});
|
|
2737
3049
|
}
|
|
@@ -2792,9 +3104,9 @@ var Renderer = class extends WebGLRenderer {
|
|
|
2792
3104
|
};
|
|
2793
3105
|
|
|
2794
3106
|
// src/three/starfield.ts
|
|
2795
|
-
import { BufferAttribute, BufferGeometry as
|
|
3107
|
+
import { BufferAttribute, BufferGeometry as BufferGeometry3, Group as Group4, Mesh as Mesh2, MeshBasicMaterial, PointLight, Points as Points2, PointsMaterial, SphereGeometry, Vector3 as Vector35 } from "three";
|
|
2796
3108
|
function CreateStarfield(radius = 1e3, count = 5e3, color = 16777215) {
|
|
2797
|
-
const geometry = new
|
|
3109
|
+
const geometry = new BufferGeometry3();
|
|
2798
3110
|
const positions = new Float32Array(count * 3);
|
|
2799
3111
|
for (let i = 0; i < count; i++) {
|
|
2800
3112
|
const theta = rng.nextFloat() * Math.PI * 2;
|
|
@@ -2818,7 +3130,7 @@ function CreateStarfield(radius = 1e3, count = 5e3, color = 16777215) {
|
|
|
2818
3130
|
}
|
|
2819
3131
|
function CreateSystemStar(position) {
|
|
2820
3132
|
const star = new Group4();
|
|
2821
|
-
const starPos = position ?? new
|
|
3133
|
+
const starPos = position ?? new Vector35();
|
|
2822
3134
|
const starGeo = new SphereGeometry(50, 32, 32);
|
|
2823
3135
|
const starMat = new MeshBasicMaterial({ color: 16768426 });
|
|
2824
3136
|
const starMesh = new Mesh2(starGeo, starMat);
|
|
@@ -2911,14 +3223,14 @@ var ThreeJsCameraRig = class extends Group5 {
|
|
|
2911
3223
|
};
|
|
2912
3224
|
|
|
2913
3225
|
// src/three/threejs-player-controller.ts
|
|
2914
|
-
import { Group as Group6, Vector3 as
|
|
3226
|
+
import { Group as Group6, Vector3 as Vector36 } from "three";
|
|
2915
3227
|
var ThreeJsPlayerController = class extends Group6 {
|
|
2916
3228
|
moveSpeed = 1;
|
|
2917
3229
|
cameraRig;
|
|
2918
3230
|
velocity;
|
|
2919
3231
|
constructor(camera) {
|
|
2920
3232
|
super();
|
|
2921
|
-
this.velocity = new
|
|
3233
|
+
this.velocity = new Vector36();
|
|
2922
3234
|
this.cameraRig = new ThreeJsCameraRig({ camera });
|
|
2923
3235
|
this.add(this.cameraRig);
|
|
2924
3236
|
}
|
|
@@ -2930,8 +3242,8 @@ var ThreeJsPlayerController = class extends Group6 {
|
|
|
2930
3242
|
};
|
|
2931
3243
|
|
|
2932
3244
|
// src/three/voxel-geometry.ts
|
|
2933
|
-
import { BufferGeometry as
|
|
2934
|
-
var VoxelGeometry = class extends
|
|
3245
|
+
import { BufferGeometry as BufferGeometry4, Float32BufferAttribute as Float32BufferAttribute2 } from "three";
|
|
3246
|
+
var VoxelGeometry = class extends BufferGeometry4 {
|
|
2935
3247
|
type = "VoxelGeometry";
|
|
2936
3248
|
voxels = new Map3D();
|
|
2937
3249
|
voxelBuildParams = {};
|
|
@@ -3119,7 +3431,7 @@ var VOXEL_FACES = [
|
|
|
3119
3431
|
];
|
|
3120
3432
|
|
|
3121
3433
|
// src/three/voxel-mesh.ts
|
|
3122
|
-
import { BufferAttribute as BufferAttribute2, BufferGeometry as
|
|
3434
|
+
import { BufferAttribute as BufferAttribute2, BufferGeometry as BufferGeometry5, Color as Color3, Mesh as Mesh3 } from "three";
|
|
3123
3435
|
var VoxelMesh = class extends Mesh3 {
|
|
3124
3436
|
type = "VoxelMesh";
|
|
3125
3437
|
width;
|
|
@@ -3138,7 +3450,7 @@ var VoxelMesh = class extends Mesh3 {
|
|
|
3138
3450
|
this.name = name ?? "VoxelMesh";
|
|
3139
3451
|
this.colorPalette = BuildDefaultPalette();
|
|
3140
3452
|
this.voxels = /* @__PURE__ */ new Map();
|
|
3141
|
-
this.geometry = new
|
|
3453
|
+
this.geometry = new BufferGeometry5();
|
|
3142
3454
|
this.updateGeometry();
|
|
3143
3455
|
}
|
|
3144
3456
|
_xyz2k(x, y, z) {
|
|
@@ -3649,10 +3961,12 @@ export {
|
|
|
3649
3961
|
DEFAULT_TEXTALIGN,
|
|
3650
3962
|
DEFAULT_TEXTBASELINE,
|
|
3651
3963
|
DEG2RAD,
|
|
3964
|
+
DebugRenderer,
|
|
3652
3965
|
Disposable,
|
|
3653
3966
|
E,
|
|
3654
3967
|
ECS,
|
|
3655
3968
|
EPSILON,
|
|
3969
|
+
Emitter,
|
|
3656
3970
|
EventQueue,
|
|
3657
3971
|
GenerateDoors,
|
|
3658
3972
|
GenerateEntityId,
|
|
@@ -3709,6 +4023,7 @@ export {
|
|
|
3709
4023
|
VoxelMesh,
|
|
3710
4024
|
WebGlRenderer,
|
|
3711
4025
|
WorkerInterface,
|
|
4026
|
+
buildColorPalette,
|
|
3712
4027
|
clamp,
|
|
3713
4028
|
degrees,
|
|
3714
4029
|
distance2d,
|
|
@@ -3723,6 +4038,7 @@ export {
|
|
|
3723
4038
|
k2xy,
|
|
3724
4039
|
k2xyz,
|
|
3725
4040
|
lerp,
|
|
4041
|
+
log,
|
|
3726
4042
|
manhattanDistance,
|
|
3727
4043
|
mod,
|
|
3728
4044
|
nearlyEqual,
|