@n3rdw1z4rd/core 0.18.0 → 0.18.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.
- package/dist/css/index.ts +1 -0
- package/dist/index.css +104 -0
- package/dist/index.d.mts +38 -12
- package/dist/index.d.ts +38 -12
- package/dist/index.js +255 -92
- package/dist/index.mjs +353 -39
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,178 @@
|
|
|
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
|
+
manhattanDistance: () => manhattanDistance,
|
|
161
|
+
mod: () => mod,
|
|
162
|
+
nearlyEqual: () => nearlyEqual,
|
|
163
|
+
normalizeRadians: () => normalizeRadians,
|
|
164
|
+
radians: () => radians,
|
|
165
|
+
randomMatrix: () => randomMatrix,
|
|
166
|
+
rng: () => rng,
|
|
167
|
+
roundTo: () => roundTo,
|
|
168
|
+
saturate: () => saturate,
|
|
169
|
+
smoothstep: () => smoothstep,
|
|
170
|
+
squaredDistance: () => squaredDistance,
|
|
171
|
+
wrap: () => wrap,
|
|
172
|
+
xy2k: () => xy2k,
|
|
173
|
+
xyz2k: () => xyz2k
|
|
174
|
+
});
|
|
175
|
+
|
|
1
176
|
// src/astar.ts
|
|
2
177
|
var DIRECTIONS_4_WAY = [
|
|
3
178
|
{ x: 0, y: -1 },
|
|
@@ -370,6 +545,67 @@ var Clock = class {
|
|
|
370
545
|
}
|
|
371
546
|
};
|
|
372
547
|
|
|
548
|
+
// src/color-palette.ts
|
|
549
|
+
var DEFAULT_COLORS = [
|
|
550
|
+
[237, 28, 36],
|
|
551
|
+
// red
|
|
552
|
+
[255, 127, 39],
|
|
553
|
+
// orange
|
|
554
|
+
[255, 242, 0],
|
|
555
|
+
// yellow
|
|
556
|
+
[34, 177, 76],
|
|
557
|
+
// green
|
|
558
|
+
[0, 183, 239],
|
|
559
|
+
// cyan
|
|
560
|
+
[63, 72, 204],
|
|
561
|
+
// blue
|
|
562
|
+
[163, 73, 164],
|
|
563
|
+
// purple
|
|
564
|
+
[236, 0, 140],
|
|
565
|
+
// magenta
|
|
566
|
+
[255, 174, 201],
|
|
567
|
+
// pink
|
|
568
|
+
[139, 90, 43],
|
|
569
|
+
// brown
|
|
570
|
+
[214, 181, 129],
|
|
571
|
+
// tan
|
|
572
|
+
[128, 128, 0],
|
|
573
|
+
// olive
|
|
574
|
+
[0, 128, 128],
|
|
575
|
+
// teal
|
|
576
|
+
[128, 0, 32]
|
|
577
|
+
// maroon
|
|
578
|
+
];
|
|
579
|
+
function packRGB(r, g, b) {
|
|
580
|
+
r = Math.min(255, Math.max(0, Math.round(r)));
|
|
581
|
+
g = Math.min(255, Math.max(0, Math.round(g)));
|
|
582
|
+
b = Math.min(255, Math.max(0, Math.round(b)));
|
|
583
|
+
return r << 16 | g << 8 | b;
|
|
584
|
+
}
|
|
585
|
+
var DARK_FLOOR = 0.28;
|
|
586
|
+
function colorRamp(rgb, steps) {
|
|
587
|
+
const [r, g, b] = rgb;
|
|
588
|
+
const out = [];
|
|
589
|
+
for (let i = 0; i < steps; i++) {
|
|
590
|
+
const t = steps === 1 ? 0 : i / (steps - 1);
|
|
591
|
+
const scale = 1 - t * (1 - DARK_FLOOR);
|
|
592
|
+
out.push(packRGB(r * scale, g * scale, b * scale));
|
|
593
|
+
}
|
|
594
|
+
return out;
|
|
595
|
+
}
|
|
596
|
+
function buildColorPalette(grayscaleSteps = 8, colorSteps = 4, ...colors2) {
|
|
597
|
+
const palette = [];
|
|
598
|
+
for (let i = 0; i < grayscaleSteps; i++) {
|
|
599
|
+
const v = grayscaleSteps === 1 ? 0 : i / (grayscaleSteps - 1) * 255;
|
|
600
|
+
palette.push(packRGB(v, v, v));
|
|
601
|
+
}
|
|
602
|
+
const colorList = colors2.length > 0 ? colors2 : DEFAULT_COLORS;
|
|
603
|
+
for (const rgb of colorList) {
|
|
604
|
+
palette.push(...colorRamp(rgb, colorSteps));
|
|
605
|
+
}
|
|
606
|
+
return palette;
|
|
607
|
+
}
|
|
608
|
+
|
|
373
609
|
// src/log.ts
|
|
374
610
|
var log_default = console.debug.bind(
|
|
375
611
|
console,
|
|
@@ -541,6 +777,81 @@ var Color = class _Color {
|
|
|
541
777
|
}
|
|
542
778
|
};
|
|
543
779
|
|
|
780
|
+
// src/index.ts
|
|
781
|
+
__reExport(index_exports, __toESM(require_css()));
|
|
782
|
+
|
|
783
|
+
// src/debug-label.ts
|
|
784
|
+
import { BufferGeometry, Line, LineBasicMaterial, Vector3 } from "three";
|
|
785
|
+
import { CSS2DRenderer, CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
|
|
786
|
+
var labelRenderer = new CSS2DRenderer();
|
|
787
|
+
labelRenderer.setSize(window.innerWidth, window.innerHeight);
|
|
788
|
+
labelRenderer.domElement.style.position = "absolute";
|
|
789
|
+
labelRenderer.domElement.style.top = "0px";
|
|
790
|
+
labelRenderer.domElement.style.pointerEvents = "none";
|
|
791
|
+
document.body.appendChild(labelRenderer.domElement);
|
|
792
|
+
window.addEventListener("resize", () => {
|
|
793
|
+
labelRenderer.setSize(window.innerWidth, window.innerHeight);
|
|
794
|
+
});
|
|
795
|
+
var FONT_SIZE = 12;
|
|
796
|
+
var DebugRenderer = class extends CSS2DRenderer {
|
|
797
|
+
_labels = /* @__PURE__ */ new Set();
|
|
798
|
+
get width() {
|
|
799
|
+
return this.domElement.clientWidth;
|
|
800
|
+
}
|
|
801
|
+
get height() {
|
|
802
|
+
return this.domElement.clientHeight;
|
|
803
|
+
}
|
|
804
|
+
constructor() {
|
|
805
|
+
super();
|
|
806
|
+
this.setSize(window.innerWidth, window.innerHeight);
|
|
807
|
+
this.domElement.style.position = "absolute";
|
|
808
|
+
this.domElement.style.top = "0px";
|
|
809
|
+
this.domElement.style.pointerEvents = "none";
|
|
810
|
+
}
|
|
811
|
+
resize(width, height) {
|
|
812
|
+
let resized = false;
|
|
813
|
+
width = width ?? this.domElement.parentElement?.clientWidth ?? this.width;
|
|
814
|
+
height = height ?? this.domElement.parentElement?.clientHeight ?? this.height;
|
|
815
|
+
if (this.width !== width || this.height !== height) {
|
|
816
|
+
this.setSize(width, height);
|
|
817
|
+
resized = true;
|
|
818
|
+
}
|
|
819
|
+
return resized;
|
|
820
|
+
}
|
|
821
|
+
createLabel(text, offset) {
|
|
822
|
+
if (!Array.isArray(text)) text = [text];
|
|
823
|
+
offset = offset ?? new Vector3(0, -1, 0);
|
|
824
|
+
const div = document.createElement("div");
|
|
825
|
+
div.innerHTML = text.join("<br>");
|
|
826
|
+
div.style.cssText = `
|
|
827
|
+
color: #888;
|
|
828
|
+
font: ${FONT_SIZE}px monospace;
|
|
829
|
+
padding: 4px 8px;
|
|
830
|
+
background: rgba(0,0,0,0.7);
|
|
831
|
+
border-radius: 4px;
|
|
832
|
+
border: 1px dashed #fff;
|
|
833
|
+
white-space: nowrap;
|
|
834
|
+
`;
|
|
835
|
+
const label = new CSS2DObject(div);
|
|
836
|
+
const lineGeometry = new BufferGeometry().setFromPoints([
|
|
837
|
+
new Vector3(0, 0, 0),
|
|
838
|
+
offset
|
|
839
|
+
]);
|
|
840
|
+
const lineMaterial = new LineBasicMaterial({
|
|
841
|
+
color: 16777215,
|
|
842
|
+
transparent: true,
|
|
843
|
+
opacity: 0.5,
|
|
844
|
+
depthTest: false
|
|
845
|
+
// keep visible through geometry, like a debug overlay
|
|
846
|
+
});
|
|
847
|
+
const line = new Line(lineGeometry, lineMaterial);
|
|
848
|
+
line.renderOrder = 999;
|
|
849
|
+
const debugLabel = { div, label, line };
|
|
850
|
+
this._labels.add(debugLabel);
|
|
851
|
+
return debugLabel;
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
|
|
544
855
|
// src/disposable.ts
|
|
545
856
|
var Disposable = class {
|
|
546
857
|
disposers = [];
|
|
@@ -1267,26 +1578,6 @@ var ECS = class _ECS {
|
|
|
1267
1578
|
}
|
|
1268
1579
|
};
|
|
1269
1580
|
|
|
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
1581
|
// src/emitter.ts
|
|
1291
1582
|
var Emitter = class {
|
|
1292
1583
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -1309,6 +1600,26 @@ var Emitter = class {
|
|
|
1309
1600
|
}
|
|
1310
1601
|
};
|
|
1311
1602
|
|
|
1603
|
+
// src/event-queue.ts
|
|
1604
|
+
var EventQueue = class {
|
|
1605
|
+
events = [];
|
|
1606
|
+
emit(event) {
|
|
1607
|
+
this.events.push(event);
|
|
1608
|
+
}
|
|
1609
|
+
consume() {
|
|
1610
|
+
return this.events;
|
|
1611
|
+
}
|
|
1612
|
+
clear() {
|
|
1613
|
+
this.events.length = 0;
|
|
1614
|
+
}
|
|
1615
|
+
drain() {
|
|
1616
|
+
return this.events.splice(0);
|
|
1617
|
+
}
|
|
1618
|
+
get size() {
|
|
1619
|
+
return this.events.length;
|
|
1620
|
+
}
|
|
1621
|
+
};
|
|
1622
|
+
|
|
1312
1623
|
// src/input.ts
|
|
1313
1624
|
var Input = class _Input extends Emitter {
|
|
1314
1625
|
static _instance;
|
|
@@ -2395,7 +2706,7 @@ var CameraRig = class extends Group {
|
|
|
2395
2706
|
};
|
|
2396
2707
|
|
|
2397
2708
|
// src/three/cube-sphere-geometry.ts
|
|
2398
|
-
import { BoxGeometry, Vector3 } from "three";
|
|
2709
|
+
import { BoxGeometry, Vector3 as Vector32 } from "three";
|
|
2399
2710
|
var CubeSphereGeometry = class extends BoxGeometry {
|
|
2400
2711
|
constructor(size, segments) {
|
|
2401
2712
|
size = Math.floor(size);
|
|
@@ -2405,7 +2716,7 @@ var CubeSphereGeometry = class extends BoxGeometry {
|
|
|
2405
2716
|
this.segments = segments;
|
|
2406
2717
|
this._halfSize = this.size / 2;
|
|
2407
2718
|
const attrPositions = this.attributes.position;
|
|
2408
|
-
const position = new
|
|
2719
|
+
const position = new Vector32();
|
|
2409
2720
|
for (let i = 0; i < attrPositions.count; i++) {
|
|
2410
2721
|
position.fromBufferAttribute(attrPositions, i);
|
|
2411
2722
|
position.normalize().multiplyScalar(this._halfSize);
|
|
@@ -2418,7 +2729,7 @@ var CubeSphereGeometry = class extends BoxGeometry {
|
|
|
2418
2729
|
_halfSize;
|
|
2419
2730
|
applyFractalBrownianMotion(octaves, persistence, scale, amplitude) {
|
|
2420
2731
|
const attrPositions = this.attributes.position;
|
|
2421
|
-
const position = new
|
|
2732
|
+
const position = new Vector32();
|
|
2422
2733
|
for (let i = 0; i < attrPositions.count; i++) {
|
|
2423
2734
|
position.fromBufferAttribute(attrPositions, i);
|
|
2424
2735
|
position.normalize().multiplyScalar(this._halfSize);
|
|
@@ -2469,7 +2780,7 @@ function IsThreeEntity(obj) {
|
|
|
2469
2780
|
}
|
|
2470
2781
|
|
|
2471
2782
|
// src/three/palette-controller.ts
|
|
2472
|
-
import { Color as Color2, Vector3 as
|
|
2783
|
+
import { Color as Color2, Vector3 as Vector33 } from "three";
|
|
2473
2784
|
async function CreatePaletteController(parentGui, colorPalette, onChange, folderName = "palette") {
|
|
2474
2785
|
const { Controller } = await import("three/examples/jsm/libs/lil-gui.module.min.js");
|
|
2475
2786
|
class PaletteControllerImpl extends Controller {
|
|
@@ -2557,11 +2868,11 @@ async function CreatePaletteController(parentGui, colorPalette, onChange, folder
|
|
|
2557
2868
|
}
|
|
2558
2869
|
findClosestColorMatchIndex(color) {
|
|
2559
2870
|
const pickedColor = new Color2(color);
|
|
2560
|
-
const pickedVector = new
|
|
2871
|
+
const pickedVector = new Vector33().setFromColor(pickedColor);
|
|
2561
2872
|
const list = [];
|
|
2562
2873
|
this.colorPalette.forEach((paletteColorString, i) => {
|
|
2563
2874
|
const paletteColor = new Color2(paletteColorString);
|
|
2564
|
-
const paletteVector = new
|
|
2875
|
+
const paletteVector = new Vector33().setFromColor(paletteColor);
|
|
2565
2876
|
const d = paletteVector.distanceTo(pickedVector);
|
|
2566
2877
|
list.push({ i, d });
|
|
2567
2878
|
});
|
|
@@ -2574,7 +2885,7 @@ async function CreatePaletteController(parentGui, colorPalette, onChange, folder
|
|
|
2574
2885
|
}
|
|
2575
2886
|
|
|
2576
2887
|
// src/three/particle-system-3d.ts
|
|
2577
|
-
import { BufferGeometry, Float32BufferAttribute, Group as Group3, Points, ShaderMaterial, Vector3 as
|
|
2888
|
+
import { BufferGeometry as BufferGeometry2, Float32BufferAttribute, Group as Group3, Points, ShaderMaterial, Vector3 as Vector34 } from "three";
|
|
2578
2889
|
var vertexShader = `
|
|
2579
2890
|
uniform float pointSize;
|
|
2580
2891
|
|
|
@@ -2623,7 +2934,7 @@ var ParticleSystem3d = class extends Group3 {
|
|
|
2623
2934
|
this.position.x = -0.5;
|
|
2624
2935
|
this.position.y = -0.5;
|
|
2625
2936
|
this.position.z = -0.5;
|
|
2626
|
-
this._geometry = new
|
|
2937
|
+
this._geometry = new BufferGeometry2();
|
|
2627
2938
|
this._geometry.setAttribute("position", new Float32BufferAttribute([], 3));
|
|
2628
2939
|
this._geometry.setAttribute("color", new Float32BufferAttribute([], 4));
|
|
2629
2940
|
const material = new ShaderMaterial({
|
|
@@ -2730,8 +3041,8 @@ var ParticleSystem3d = class extends Group3 {
|
|
|
2730
3041
|
}
|
|
2731
3042
|
_sortParticles(camera) {
|
|
2732
3043
|
this._particles.sort((a, b) => {
|
|
2733
|
-
const d1 = camera.position.distanceTo(new
|
|
2734
|
-
const d2 = camera.position.distanceTo(new
|
|
3044
|
+
const d1 = camera.position.distanceTo(new Vector34(a.x, a.y, a.z));
|
|
3045
|
+
const d2 = camera.position.distanceTo(new Vector34(b.x, b.y, b.z));
|
|
2735
3046
|
return d1 > d2 ? -1 : d1 > d1 ? 1 : 0;
|
|
2736
3047
|
});
|
|
2737
3048
|
}
|
|
@@ -2792,9 +3103,9 @@ var Renderer = class extends WebGLRenderer {
|
|
|
2792
3103
|
};
|
|
2793
3104
|
|
|
2794
3105
|
// src/three/starfield.ts
|
|
2795
|
-
import { BufferAttribute, BufferGeometry as
|
|
3106
|
+
import { BufferAttribute, BufferGeometry as BufferGeometry3, Group as Group4, Mesh as Mesh2, MeshBasicMaterial, PointLight, Points as Points2, PointsMaterial, SphereGeometry, Vector3 as Vector35 } from "three";
|
|
2796
3107
|
function CreateStarfield(radius = 1e3, count = 5e3, color = 16777215) {
|
|
2797
|
-
const geometry = new
|
|
3108
|
+
const geometry = new BufferGeometry3();
|
|
2798
3109
|
const positions = new Float32Array(count * 3);
|
|
2799
3110
|
for (let i = 0; i < count; i++) {
|
|
2800
3111
|
const theta = rng.nextFloat() * Math.PI * 2;
|
|
@@ -2818,7 +3129,7 @@ function CreateStarfield(radius = 1e3, count = 5e3, color = 16777215) {
|
|
|
2818
3129
|
}
|
|
2819
3130
|
function CreateSystemStar(position) {
|
|
2820
3131
|
const star = new Group4();
|
|
2821
|
-
const starPos = position ?? new
|
|
3132
|
+
const starPos = position ?? new Vector35();
|
|
2822
3133
|
const starGeo = new SphereGeometry(50, 32, 32);
|
|
2823
3134
|
const starMat = new MeshBasicMaterial({ color: 16768426 });
|
|
2824
3135
|
const starMesh = new Mesh2(starGeo, starMat);
|
|
@@ -2911,14 +3222,14 @@ var ThreeJsCameraRig = class extends Group5 {
|
|
|
2911
3222
|
};
|
|
2912
3223
|
|
|
2913
3224
|
// src/three/threejs-player-controller.ts
|
|
2914
|
-
import { Group as Group6, Vector3 as
|
|
3225
|
+
import { Group as Group6, Vector3 as Vector36 } from "three";
|
|
2915
3226
|
var ThreeJsPlayerController = class extends Group6 {
|
|
2916
3227
|
moveSpeed = 1;
|
|
2917
3228
|
cameraRig;
|
|
2918
3229
|
velocity;
|
|
2919
3230
|
constructor(camera) {
|
|
2920
3231
|
super();
|
|
2921
|
-
this.velocity = new
|
|
3232
|
+
this.velocity = new Vector36();
|
|
2922
3233
|
this.cameraRig = new ThreeJsCameraRig({ camera });
|
|
2923
3234
|
this.add(this.cameraRig);
|
|
2924
3235
|
}
|
|
@@ -2930,8 +3241,8 @@ var ThreeJsPlayerController = class extends Group6 {
|
|
|
2930
3241
|
};
|
|
2931
3242
|
|
|
2932
3243
|
// src/three/voxel-geometry.ts
|
|
2933
|
-
import { BufferGeometry as
|
|
2934
|
-
var VoxelGeometry = class extends
|
|
3244
|
+
import { BufferGeometry as BufferGeometry4, Float32BufferAttribute as Float32BufferAttribute2 } from "three";
|
|
3245
|
+
var VoxelGeometry = class extends BufferGeometry4 {
|
|
2935
3246
|
type = "VoxelGeometry";
|
|
2936
3247
|
voxels = new Map3D();
|
|
2937
3248
|
voxelBuildParams = {};
|
|
@@ -3119,7 +3430,7 @@ var VOXEL_FACES = [
|
|
|
3119
3430
|
];
|
|
3120
3431
|
|
|
3121
3432
|
// src/three/voxel-mesh.ts
|
|
3122
|
-
import { BufferAttribute as BufferAttribute2, BufferGeometry as
|
|
3433
|
+
import { BufferAttribute as BufferAttribute2, BufferGeometry as BufferGeometry5, Color as Color3, Mesh as Mesh3 } from "three";
|
|
3123
3434
|
var VoxelMesh = class extends Mesh3 {
|
|
3124
3435
|
type = "VoxelMesh";
|
|
3125
3436
|
width;
|
|
@@ -3138,7 +3449,7 @@ var VoxelMesh = class extends Mesh3 {
|
|
|
3138
3449
|
this.name = name ?? "VoxelMesh";
|
|
3139
3450
|
this.colorPalette = BuildDefaultPalette();
|
|
3140
3451
|
this.voxels = /* @__PURE__ */ new Map();
|
|
3141
|
-
this.geometry = new
|
|
3452
|
+
this.geometry = new BufferGeometry5();
|
|
3142
3453
|
this.updateGeometry();
|
|
3143
3454
|
}
|
|
3144
3455
|
_xyz2k(x, y, z) {
|
|
@@ -3649,10 +3960,12 @@ export {
|
|
|
3649
3960
|
DEFAULT_TEXTALIGN,
|
|
3650
3961
|
DEFAULT_TEXTBASELINE,
|
|
3651
3962
|
DEG2RAD,
|
|
3963
|
+
DebugRenderer,
|
|
3652
3964
|
Disposable,
|
|
3653
3965
|
E,
|
|
3654
3966
|
ECS,
|
|
3655
3967
|
EPSILON,
|
|
3968
|
+
Emitter,
|
|
3656
3969
|
EventQueue,
|
|
3657
3970
|
GenerateDoors,
|
|
3658
3971
|
GenerateEntityId,
|
|
@@ -3709,6 +4022,7 @@ export {
|
|
|
3709
4022
|
VoxelMesh,
|
|
3710
4023
|
WebGlRenderer,
|
|
3711
4024
|
WorkerInterface,
|
|
4025
|
+
buildColorPalette,
|
|
3712
4026
|
clamp,
|
|
3713
4027
|
degrees,
|
|
3714
4028
|
distance2d,
|