@n3rdw1z4rd/core 0.22.0 → 0.23.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/README.md +59 -4
- package/dist/astar.d.ts +1 -3
- package/dist/astar.js +1 -2
- package/dist/canvas-renderer.d.ts +1 -3
- package/dist/canvas-renderer.js +1 -2
- package/dist/clock.d.ts +1 -3
- package/dist/clock.js +1 -2
- package/dist/color-palette.d.ts +1 -3
- package/dist/color-palette.js +1 -2
- package/dist/color.d.ts +1 -3
- package/dist/color.js +1 -2
- package/dist/disposable.d.ts +1 -3
- package/dist/disposable.js +1 -2
- package/dist/dungeon-generator.d.ts +2 -4
- package/dist/dungeon-generator.js +3 -4
- package/dist/ecs.d.ts +1 -3
- package/dist/ecs.js +1 -2
- package/dist/emitter.d.ts +1 -3
- package/dist/emitter.js +1 -2
- package/dist/event-queue.d.ts +1 -3
- package/dist/event-queue.js +1 -2
- package/dist/graph/doc.d.ts +2 -4
- package/dist/graph/doc.js +1 -2
- package/dist/graph/evaluate.d.ts +1 -3
- package/dist/graph/evaluate.js +1 -2
- package/dist/graph/index.d.ts +4 -4
- package/dist/graph/index.js +4 -4
- package/dist/graph/node.d.ts +7 -9
- package/dist/graph/node.js +1 -2
- package/dist/graph/nodes.d.ts +1 -3
- package/dist/graph/nodes.js +1 -2
- package/dist/graph/script.d.ts +37 -40
- package/dist/graph/script.js +14 -60
- package/dist/graph/sources.d.ts +1 -3
- package/dist/graph/sources.js +1 -2
- package/dist/graph/subgraph.d.ts +2 -4
- package/dist/graph/subgraph.js +1 -2
- package/dist/graph/types.d.ts +3 -5
- package/dist/graph/types.js +2 -3
- package/dist/graph.cjs +22 -77
- package/dist/graph.d.cts +44 -61
- package/dist/index.cjs +27 -52
- package/dist/index.d.cts +1 -63
- package/dist/index.d.ts +10 -10
- package/dist/index.js +14 -14
- package/dist/input/_input.d.ts +1 -3
- package/dist/input/_input.js +1 -2
- package/dist/input/action-map.d.ts +1 -3
- package/dist/input/action-map.js +1 -2
- package/dist/input/bindings.d.ts +1 -3
- package/dist/input/bindings.js +1 -2
- package/dist/input/gestures.d.ts +1 -3
- package/dist/input/gestures.js +1 -2
- package/dist/input/index.d.ts +1 -1
- package/dist/input/index.js +1 -1
- package/dist/input/input-action-map.d.ts +3 -5
- package/dist/input/input-action-map.js +3 -4
- package/dist/input/input.d.ts +2 -4
- package/dist/input/input.js +2 -3
- package/dist/log.d.ts +1 -3
- package/dist/log.js +1 -2
- package/dist/map2d.d.ts +1 -3
- package/dist/map2d.js +1 -2
- package/dist/{map3d-CHDJiq5T.d.cts → map3d-DRHhbrFn.d.cts} +0 -8
- package/dist/map3d.d.ts +1 -3
- package/dist/map3d.js +1 -2
- package/dist/math.d.ts +1 -3
- package/dist/math.js +1 -2
- package/dist/misc.d.ts +1 -3
- package/dist/misc.js +1 -2
- package/dist/observable.d.ts +1 -3
- package/dist/observable.js +1 -2
- package/dist/particle-renderer.d.ts +1 -3
- package/dist/particle-renderer.js +1 -2
- package/dist/particle-system-2d.d.ts +1 -3
- package/dist/particle-system-2d.js +3 -4
- package/dist/random.d.ts +1 -3
- package/dist/random.js +1 -2
- package/dist/rectangle.d.ts +1 -3
- package/dist/rectangle.js +1 -2
- package/dist/{rng-Dhqq7owV.cjs → rng-edL6atS3.cjs} +3 -6
- package/dist/rng.d.ts +1 -3
- package/dist/rng.js +2 -3
- package/dist/signal.d.ts +1 -3
- package/dist/signal.js +1 -2
- package/dist/spatial-partition-2d.d.ts +1 -3
- package/dist/spatial-partition-2d.js +1 -2
- package/dist/{spatial-partition-3d-CmSCL87Z.cjs → spatial-partition-3d-D1uyJVhM.cjs} +7 -13
- package/dist/spatial-partition-3d.d.ts +1 -3
- package/dist/spatial-partition-3d.js +1 -2
- package/dist/three/adaptive-grid.d.ts +1 -3
- package/dist/three/adaptive-grid.js +1 -2
- package/dist/three/asteroid-mesh.d.ts +1 -3
- package/dist/three/asteroid-mesh.js +1 -2
- package/dist/three/camera-rig.d.ts +1 -3
- package/dist/three/camera-rig.js +1 -2
- package/dist/three/cube-sphere-geometry.d.ts +1 -3
- package/dist/three/cube-sphere-geometry.js +1 -2
- package/dist/three/ecs.d.ts +1 -3
- package/dist/three/ecs.js +1 -2
- package/dist/three/editor-camera.d.ts +1 -3
- package/dist/three/editor-camera.js +1 -2
- package/dist/three/index.d.ts +4 -4
- package/dist/three/index.js +1 -1
- package/dist/three/particle-system-3d.d.ts +1 -3
- package/dist/three/particle-system-3d.js +3 -4
- package/dist/three/picking.d.ts +2 -4
- package/dist/three/picking.js +1 -2
- package/dist/three/renderer.d.ts +1 -3
- package/dist/three/renderer.js +1 -2
- package/dist/three/schema.d.ts +0 -2
- package/dist/three/schema.js +1 -2
- package/dist/three/starfield.d.ts +1 -3
- package/dist/three/starfield.js +1 -2
- package/dist/three/texture-atlas.d.ts +1 -3
- package/dist/three/texture-atlas.js +1 -2
- package/dist/three/texture-utils.d.ts +1 -3
- package/dist/three/texture-utils.js +1 -2
- package/dist/three/voxel-geometry.d.ts +2 -4
- package/dist/three/voxel-geometry.js +2 -3
- package/dist/three/voxel-mesh.d.ts +1 -3
- package/dist/three/voxel-mesh.js +1 -2
- package/dist/three/world.d.ts +0 -2
- package/dist/three/world.js +1 -2
- package/dist/three.cjs +18 -34
- package/dist/three.d.cts +1 -33
- package/dist/tilemap.d.ts +1 -3
- package/dist/tilemap.js +1 -2
- package/dist/types.d.ts +1 -3
- package/dist/vector.d.ts +1 -3
- package/dist/vector.js +1 -2
- package/dist/vite.cjs +1 -2
- package/dist/vite.d.cts +1 -3
- package/dist/vite.d.ts +1 -3
- package/dist/vite.js +1 -2
- package/dist/webgl-renderer.d.ts +1 -3
- package/dist/webgl-renderer.js +1 -2
- package/dist/webgl.d.ts +1 -3
- package/dist/webgl.js +1 -2
- package/dist/worker-interface.d.ts +1 -3
- package/dist/worker-interface.js +1 -2
- package/package.json +6 -6
package/dist/three/index.js
CHANGED
|
@@ -9,8 +9,8 @@ import { entityOf, pickEntity } from "./picking.js";
|
|
|
9
9
|
import { Renderer } from "./renderer.js";
|
|
10
10
|
import { ComponentRegistry, applyFieldValue, component, componentToJson, componentType, components, defineComponent, field, fieldToJson, inferFieldType } from "./schema.js";
|
|
11
11
|
import { CreateStarfield, CreateSystemStar } from "./starfield.js";
|
|
12
|
-
import { CreateSubTexture, LoadTexture } from "./texture-utils.js";
|
|
13
12
|
import { TextureAtlas } from "./texture-atlas.js";
|
|
13
|
+
import { CreateSubTexture, LoadTexture } from "./texture-utils.js";
|
|
14
14
|
import { VoxelGeometry, buildVoxelGeometry } from "./voxel-geometry.js";
|
|
15
15
|
import { VoxelMesh } from "./voxel-mesh.js";
|
|
16
16
|
import { SCENE_FORMAT, SCENE_VERSION, World } from "./world.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Group, PerspectiveCamera } from "three";
|
|
2
|
-
//#region src/three/particle-system-3d.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* "Particle life" simulation in 3D: 1000 colored points in five species that attract or repel each
|
|
5
4
|
* other according to a random species-by-species matrix, forming moving clusters. Particles live in
|
|
@@ -49,5 +48,4 @@ export declare class ParticleSystem3d extends Group {
|
|
|
49
48
|
* seen from `camera`. `dt` is capped to {@link ParticleSystem3d.maxDeltaTime}.
|
|
50
49
|
*/
|
|
51
50
|
update(camera: PerspectiveCamera, dt: number): void;
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
51
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { fract } from "../math.js";
|
|
2
1
|
import { Random } from "../random.js";
|
|
2
|
+
import { fract } from "../math.js";
|
|
3
|
+
import { SpatialPartition3d } from "../spatial-partition-3d.js";
|
|
3
4
|
import { rng } from "../rng.js";
|
|
4
5
|
import { randomMatrix } from "../particle-system-2d.js";
|
|
5
|
-
import { SpatialPartition3d } from "../spatial-partition-3d.js";
|
|
6
6
|
import { BufferAttribute, BufferGeometry, DynamicDrawUsage, Group, Points, ShaderMaterial, Sphere, Vector3 } from "three";
|
|
7
|
-
|
|
7
|
+
// src/three/particle-system-3d.ts
|
|
8
8
|
const vertexShader = `
|
|
9
9
|
uniform float pointSize;
|
|
10
10
|
|
|
@@ -220,5 +220,4 @@ var ParticleSystem3d = class extends Group {
|
|
|
220
220
|
this._updateGeometry();
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
-
//#endregion
|
|
224
223
|
export { ParticleSystem3d };
|
package/dist/three/picking.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { EditorCamera } from "./editor-camera.js";
|
|
2
1
|
import { ThreeEntity } from "./ecs.js";
|
|
2
|
+
import { EditorCamera } from "./editor-camera.js";
|
|
3
3
|
import { World } from "./world.js";
|
|
4
4
|
import { Object3D, Vector3 } from "three";
|
|
5
|
-
//#region src/three/picking.d.ts
|
|
6
5
|
/** @category Three.js */
|
|
7
6
|
export interface EntityHit {
|
|
8
7
|
entity: ThreeEntity;
|
|
@@ -30,5 +29,4 @@ export interface PickOptions {
|
|
|
30
29
|
*/
|
|
31
30
|
export declare function pickEntity(world: World, view: EditorCamera, sx: number, sy: number, options?: PickOptions): EntityHit | null;
|
|
32
31
|
/** The closest entity of `world` at or above `object`, or null. */
|
|
33
|
-
export declare function entityOf(world: World, object: Object3D): ThreeEntity | null;
|
|
34
|
-
//#endregion
|
|
32
|
+
export declare function entityOf(world: World, object: Object3D): ThreeEntity | null;
|
package/dist/three/picking.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/three/picking.ts
|
|
2
2
|
/**
|
|
3
3
|
* The entity under a screen point (CSS px): raycasts the world's scene and walks up from
|
|
4
4
|
* whatever was hit to the closest entity of `world`. Invisible objects are skipped.
|
|
@@ -55,5 +55,4 @@ function visible(object) {
|
|
|
55
55
|
}
|
|
56
56
|
return true;
|
|
57
57
|
}
|
|
58
|
-
//#endregion
|
|
59
58
|
export { entityOf, pickEntity };
|
package/dist/three/renderer.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { WebGLRenderer, WebGLRendererParameters } from "three";
|
|
2
|
-
//#region src/three/renderer.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* `WebGLRenderer` that uses the device pixel ratio and can size itself to its parent element.
|
|
5
4
|
*
|
|
@@ -34,5 +33,4 @@ export declare class Renderer extends WebGLRenderer {
|
|
|
34
33
|
* @returns whether the size changed
|
|
35
34
|
*/
|
|
36
35
|
resize(width?: number, height?: number): boolean;
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
36
|
+
}
|
package/dist/three/renderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Vector2, WebGLRenderer } from "three";
|
|
2
|
-
|
|
2
|
+
// src/three/renderer.ts
|
|
3
3
|
/**
|
|
4
4
|
* `WebGLRenderer` that uses the device pixel ratio and can size itself to its parent element.
|
|
5
5
|
*
|
|
@@ -53,5 +53,4 @@ var Renderer = class extends WebGLRenderer {
|
|
|
53
53
|
return resized;
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
//#endregion
|
|
57
56
|
export { Renderer };
|
package/dist/three/schema.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/three/schema.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Component schemas: what fields a component type has, their types, defaults and ranges.
|
|
4
3
|
*
|
|
@@ -135,5 +134,4 @@ export declare class ComponentRegistry {
|
|
|
135
134
|
* @category ECS
|
|
136
135
|
*/
|
|
137
136
|
export declare const components: ComponentRegistry;
|
|
138
|
-
//#endregion
|
|
139
137
|
export {};
|
package/dist/three/schema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/three/schema.ts
|
|
2
2
|
const isObj = (v) => typeof v === "object" && v !== null;
|
|
3
3
|
/** Works out a field's type from a value, e.g. a class field's initial value. */
|
|
4
4
|
function inferFieldType(value) {
|
|
@@ -210,5 +210,4 @@ var ComponentRegistry = class {
|
|
|
210
210
|
* @category ECS
|
|
211
211
|
*/
|
|
212
212
|
const components = new ComponentRegistry();
|
|
213
|
-
//#endregion
|
|
214
213
|
export { ComponentRegistry, applyFieldValue, component, componentToJson, componentType, components, defineComponent, field, fieldToJson, inferFieldType };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Group, Points, Vector3 } from "three";
|
|
2
|
-
//#region src/three/starfield.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Points spread uniformly over a sphere's surface, for a distant star backdrop (point size 5 with
|
|
5
4
|
* size attenuation, 0.9 opacity). The same `seed` always gives the same stars; without one,
|
|
@@ -19,5 +18,4 @@ export declare function CreateStarfield(radius?: number, count?: number, color?:
|
|
|
19
18
|
* @param position where to put both, in the group's space; default the origin
|
|
20
19
|
* @category Geometry & Meshes
|
|
21
20
|
*/
|
|
22
|
-
export declare function CreateSystemStar(position?: Vector3): Group;
|
|
23
|
-
//#endregion
|
|
21
|
+
export declare function CreateSystemStar(position?: Vector3): Group;
|
package/dist/three/starfield.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Rng, rng } from "../rng.js";
|
|
2
2
|
import { BufferAttribute, BufferGeometry, Group, Mesh, MeshBasicMaterial, PointLight, Points, PointsMaterial, SphereGeometry, Vector3 } from "three";
|
|
3
|
-
|
|
3
|
+
// src/three/starfield.ts
|
|
4
4
|
/**
|
|
5
5
|
* Points spread uniformly over a sphere's surface, for a distant star backdrop (point size 5 with
|
|
6
6
|
* size attenuation, 0.9 opacity). The same `seed` always gives the same stars; without one,
|
|
@@ -60,5 +60,4 @@ function CreateSystemStar(position) {
|
|
|
60
60
|
star.add(starLight);
|
|
61
61
|
return star;
|
|
62
62
|
}
|
|
63
|
-
//#endregion
|
|
64
63
|
export { CreateStarfield, CreateSystemStar };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TextureData } from "./texture-utils.js";
|
|
2
2
|
import { MeshLambertMaterial, MeshLambertMaterialParameters, Texture } from "three";
|
|
3
|
-
//#region src/three/texture-atlas.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Texture coordinate `[u, v]`, each 0..1, with v = 1 at the image's top (three.js convention).
|
|
6
5
|
*
|
|
@@ -72,5 +71,4 @@ export declare class TextureAtlas {
|
|
|
72
71
|
getUV(tile: number, u: number, v: number): UV;
|
|
73
72
|
/** a Lambert material using this atlas, set up for pixel-art tiles with transparency */
|
|
74
73
|
createMaterial(params?: MeshLambertMaterialParameters): MeshLambertMaterial;
|
|
75
|
-
}
|
|
76
|
-
//#endregion
|
|
74
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LoadTexture } from "./texture-utils.js";
|
|
2
2
|
import { MeshLambertMaterial, NearestFilter } from "three";
|
|
3
|
-
|
|
3
|
+
// src/three/texture-atlas.ts
|
|
4
4
|
/**
|
|
5
5
|
* Tile layout and UV lookup for a texture atlas (tile sheet). Tiles are numbered left to
|
|
6
6
|
* right, top to bottom, starting at 0.
|
|
@@ -80,5 +80,4 @@ var TextureAtlas = class TextureAtlas {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
-
//#endregion
|
|
84
83
|
export { TextureAtlas };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Texture } from "three";
|
|
2
|
-
//#region src/three/texture-utils.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* A loaded texture with its image size, as returned by {@link LoadTexture}.
|
|
5
4
|
*
|
|
@@ -27,5 +26,4 @@ export declare function LoadTexture(url: string): Promise<TextureData>;
|
|
|
27
26
|
*
|
|
28
27
|
* @category Textures
|
|
29
28
|
*/
|
|
30
|
-
export declare function CreateSubTexture(texture: Texture, x: number, y: number, w: number, h: number): Texture;
|
|
31
|
-
//#endregion
|
|
29
|
+
export declare function CreateSubTexture(texture: Texture, x: number, y: number, w: number, h: number): Texture;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NearestFilter, RepeatWrapping, TextureLoader } from "three";
|
|
2
|
-
|
|
2
|
+
// src/three/texture-utils.ts
|
|
3
3
|
/**
|
|
4
4
|
* Loads an image into a `Texture` with three's `TextureLoader`.
|
|
5
5
|
*
|
|
@@ -40,5 +40,4 @@ function CreateSubTexture(texture, x, y, w, h) {
|
|
|
40
40
|
subTexture.needsUpdate = true;
|
|
41
41
|
return subTexture;
|
|
42
42
|
}
|
|
43
|
-
//#endregion
|
|
44
43
|
export { CreateSubTexture, LoadTexture };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ColorPalette } from "../color-palette.js";
|
|
2
1
|
import { Map3D } from "../map3d.js";
|
|
2
|
+
import { ColorPalette } from "../color-palette.js";
|
|
3
3
|
import { BufferGeometry } from "three";
|
|
4
|
-
//#region src/three/voxel-geometry.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Options for {@link buildVoxelGeometry} and {@link VoxelGeometry}.
|
|
7
6
|
*
|
|
@@ -68,5 +67,4 @@ export declare class VoxelGeometry extends BufferGeometry {
|
|
|
68
67
|
constructor(voxels?: Map3D, options?: Omit<BuildVoxelGeometryOptions, 'target'>);
|
|
69
68
|
/** Rebuilds the geometry from `voxels` and `options`. */
|
|
70
69
|
update(): this;
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
70
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Random } from "../random.js";
|
|
2
1
|
import { Map3D } from "../map3d.js";
|
|
2
|
+
import { Random } from "../random.js";
|
|
3
3
|
import { BufferGeometry, Color, Float32BufferAttribute } from "three";
|
|
4
|
-
|
|
4
|
+
// src/three/voxel-geometry.ts
|
|
5
5
|
const cellKey = (u, v) => (u + 33554432) * 67108864 + (v + 33554432);
|
|
6
6
|
const planeKey = (d, side, slice) => (slice + 33554432) * 8 + d * 2 + (side > 0 ? 1 : 0);
|
|
7
7
|
/**
|
|
@@ -227,5 +227,4 @@ var VoxelGeometry = class extends BufferGeometry {
|
|
|
227
227
|
return this;
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
//#endregion
|
|
231
230
|
export { VoxelGeometry, buildVoxelGeometry };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Map3D } from "../map3d.js";
|
|
2
2
|
import { BuildVoxelGeometryOptions, VoxelGeometry } from "./voxel-geometry.js";
|
|
3
3
|
import { Material, Mesh } from "three";
|
|
4
|
-
//#region src/three/voxel-mesh.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Box of voxel cells a {@link VoxelMesh} accepts, from the origin.
|
|
7
6
|
*
|
|
@@ -63,5 +62,4 @@ export declare class VoxelMesh extends Mesh<VoxelGeometry, Material | Material[]
|
|
|
63
62
|
invalidate(): void;
|
|
64
63
|
/** Rebuilds the geometry if the voxels changed; returns whether it did. */
|
|
65
64
|
update(): boolean;
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
65
|
+
}
|
package/dist/three/voxel-mesh.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Map3D } from "../map3d.js";
|
|
2
2
|
import { VoxelGeometry } from "./voxel-geometry.js";
|
|
3
3
|
import { Mesh, MeshLambertMaterial } from "three";
|
|
4
|
-
|
|
4
|
+
// src/three/voxel-mesh.ts
|
|
5
5
|
/**
|
|
6
6
|
* Editable voxel model: `set()` voxels, then `update()` rebuilds the geometry if anything changed.
|
|
7
7
|
* Voxel values are palette indices; `Map3D`'s default value (-1) means empty.
|
|
@@ -67,5 +67,4 @@ var VoxelMesh = class extends Mesh {
|
|
|
67
67
|
return true;
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
//#endregion
|
|
71
70
|
export { VoxelMesh };
|
package/dist/three/world.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ThreeEntity } from "./ecs.js";
|
|
2
2
|
import { ComponentRegistry, ComponentType } from "./schema.js";
|
|
3
3
|
import { Object3D } from "three";
|
|
4
|
-
//#region src/three/world.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* A scene of entities: three.js objects with components (see {@link CreateThreeEntity}),
|
|
7
6
|
* tracked by their `Object3D.uuid`.
|
|
@@ -188,5 +187,4 @@ export interface EntityDoc {
|
|
|
188
187
|
/** component JSON by type name */
|
|
189
188
|
components: Record<string, Record<string, unknown>>;
|
|
190
189
|
}
|
|
191
|
-
//#endregion
|
|
192
190
|
export {};
|
package/dist/three/world.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CreateThreeEntity, IsThreeEntity } from "./ecs.js";
|
|
2
2
|
import { componentToJson, components } from "./schema.js";
|
|
3
3
|
import { MathUtils, Scene } from "three";
|
|
4
|
-
|
|
4
|
+
// src/three/world.ts
|
|
5
5
|
/**
|
|
6
6
|
* A scene of entities: three.js objects with components (see {@link CreateThreeEntity}),
|
|
7
7
|
* tracked by their `Object3D.uuid`.
|
|
@@ -359,5 +359,4 @@ var World = class {
|
|
|
359
359
|
};
|
|
360
360
|
const SCENE_FORMAT = "n3rdw1z4rd.scene";
|
|
361
361
|
const SCENE_VERSION = 1;
|
|
362
|
-
//#endregion
|
|
363
362
|
export { SCENE_FORMAT, SCENE_VERSION, World };
|
package/dist/three.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rng = require("./rng-
|
|
3
|
-
const require_spatial_partition_3d = require("./spatial-partition-3d-
|
|
2
|
+
const require_rng = require("./rng-edL6atS3.cjs");
|
|
3
|
+
const require_spatial_partition_3d = require("./spatial-partition-3d-D1uyJVhM.cjs");
|
|
4
4
|
let three = require("three");
|
|
5
|
-
|
|
5
|
+
// src/three/adaptive-grid.ts
|
|
6
6
|
/**
|
|
7
7
|
* An infinite-looking grid on the XY plane for editor views: each {@link AdaptiveGrid.update}
|
|
8
8
|
* rebuilds just the lines in view, doubling the spacing when zoomed out so lines never get
|
|
@@ -126,8 +126,7 @@ var AdaptiveGrid = class extends three.LineSegments {
|
|
|
126
126
|
this.material.dispose();
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
|
-
|
|
130
|
-
//#region src/three/asteroid-mesh.ts
|
|
129
|
+
// src/three/asteroid-mesh.ts
|
|
131
130
|
/**
|
|
132
131
|
* Lumpy rock: an icosphere whose vertices are pushed in and out by 3D noise, with a
|
|
133
132
|
* `MeshStandardMaterial`. The geometry is non-indexed, so normals are per face (a faceted look).
|
|
@@ -168,8 +167,7 @@ var AsteroidMesh = class extends three.Mesh {
|
|
|
168
167
|
this.geometry.computeVertexNormals();
|
|
169
168
|
}
|
|
170
169
|
};
|
|
171
|
-
|
|
172
|
-
//#region src/three/camera-rig.ts
|
|
170
|
+
// src/three/camera-rig.ts
|
|
173
171
|
const DEFAULT_DISTANCE = 5;
|
|
174
172
|
const damp = (current, target, damping, deltaTime) => damping > 0 ? require_rng.lerp(current, target, 1 - Math.exp(-damping * deltaTime)) : target;
|
|
175
173
|
/**
|
|
@@ -362,8 +360,7 @@ var CameraRig = class extends three.Group {
|
|
|
362
360
|
this.onModeChange?.(firstPerson);
|
|
363
361
|
}
|
|
364
362
|
};
|
|
365
|
-
|
|
366
|
-
//#region src/three/cube-sphere-geometry.ts
|
|
363
|
+
// src/three/cube-sphere-geometry.ts
|
|
367
364
|
const FACES = [
|
|
368
365
|
{
|
|
369
366
|
n: [
|
|
@@ -599,8 +596,7 @@ var CubeSphereGeometry = class CubeSphereGeometry extends three.BufferGeometry {
|
|
|
599
596
|
];
|
|
600
597
|
}
|
|
601
598
|
};
|
|
602
|
-
|
|
603
|
-
//#region src/three/ecs.ts
|
|
599
|
+
// src/three/ecs.ts
|
|
604
600
|
let entityCounter = 0;
|
|
605
601
|
/**
|
|
606
602
|
* Returns a new id `"entity_<n>"` from a module-level counter (unique per page load, not random).
|
|
@@ -663,8 +659,7 @@ function RemoveThreeComponent(entity, name) {
|
|
|
663
659
|
function IsThreeEntity(obj) {
|
|
664
660
|
return obj.userData.entityId !== void 0;
|
|
665
661
|
}
|
|
666
|
-
|
|
667
|
-
//#region src/three/editor-camera.ts
|
|
662
|
+
// src/three/editor-camera.ts
|
|
668
663
|
/**
|
|
669
664
|
* An editor viewport camera: orthographic or perspective, with pan, zoom-at-cursor, orbit
|
|
670
665
|
* and fit-to-bounds, and conversions between screen (CSS px, relative to the canvas) and
|
|
@@ -835,8 +830,7 @@ var EditorCamera = class {
|
|
|
835
830
|
this.pan((insets.l - insets.r) / 2, (insets.t - insets.b) / 2);
|
|
836
831
|
}
|
|
837
832
|
};
|
|
838
|
-
|
|
839
|
-
//#region src/three/particle-system-3d.ts
|
|
833
|
+
// src/three/particle-system-3d.ts
|
|
840
834
|
const vertexShader = `
|
|
841
835
|
uniform float pointSize;
|
|
842
836
|
|
|
@@ -1052,8 +1046,7 @@ var ParticleSystem3d = class extends three.Group {
|
|
|
1052
1046
|
this._updateGeometry();
|
|
1053
1047
|
}
|
|
1054
1048
|
};
|
|
1055
|
-
|
|
1056
|
-
//#region src/three/picking.ts
|
|
1049
|
+
// src/three/picking.ts
|
|
1057
1050
|
/**
|
|
1058
1051
|
* The entity under a screen point (CSS px): raycasts the world's scene and walks up from
|
|
1059
1052
|
* whatever was hit to the closest entity of `world`. Invisible objects are skipped.
|
|
@@ -1110,8 +1103,7 @@ function visible(object) {
|
|
|
1110
1103
|
}
|
|
1111
1104
|
return true;
|
|
1112
1105
|
}
|
|
1113
|
-
|
|
1114
|
-
//#region src/three/renderer.ts
|
|
1106
|
+
// src/three/renderer.ts
|
|
1115
1107
|
/**
|
|
1116
1108
|
* `WebGLRenderer` that uses the device pixel ratio and can size itself to its parent element.
|
|
1117
1109
|
*
|
|
@@ -1165,8 +1157,7 @@ var Renderer = class extends three.WebGLRenderer {
|
|
|
1165
1157
|
return resized;
|
|
1166
1158
|
}
|
|
1167
1159
|
};
|
|
1168
|
-
|
|
1169
|
-
//#region src/three/schema.ts
|
|
1160
|
+
// src/three/schema.ts
|
|
1170
1161
|
const isObj = (v) => typeof v === "object" && v !== null;
|
|
1171
1162
|
/** Works out a field's type from a value, e.g. a class field's initial value. */
|
|
1172
1163
|
function inferFieldType(value) {
|
|
@@ -1378,8 +1369,7 @@ var ComponentRegistry = class {
|
|
|
1378
1369
|
* @category ECS
|
|
1379
1370
|
*/
|
|
1380
1371
|
const components = new ComponentRegistry();
|
|
1381
|
-
|
|
1382
|
-
//#region src/three/starfield.ts
|
|
1372
|
+
// src/three/starfield.ts
|
|
1383
1373
|
/**
|
|
1384
1374
|
* Points spread uniformly over a sphere's surface, for a distant star backdrop (point size 5 with
|
|
1385
1375
|
* size attenuation, 0.9 opacity). The same `seed` always gives the same stars; without one,
|
|
@@ -1439,8 +1429,7 @@ function CreateSystemStar(position) {
|
|
|
1439
1429
|
star.add(starLight);
|
|
1440
1430
|
return star;
|
|
1441
1431
|
}
|
|
1442
|
-
|
|
1443
|
-
//#region src/three/texture-utils.ts
|
|
1432
|
+
// src/three/texture-utils.ts
|
|
1444
1433
|
/**
|
|
1445
1434
|
* Loads an image into a `Texture` with three's `TextureLoader`.
|
|
1446
1435
|
*
|
|
@@ -1481,8 +1470,7 @@ function CreateSubTexture(texture, x, y, w, h) {
|
|
|
1481
1470
|
subTexture.needsUpdate = true;
|
|
1482
1471
|
return subTexture;
|
|
1483
1472
|
}
|
|
1484
|
-
|
|
1485
|
-
//#region src/three/texture-atlas.ts
|
|
1473
|
+
// src/three/texture-atlas.ts
|
|
1486
1474
|
/**
|
|
1487
1475
|
* Tile layout and UV lookup for a texture atlas (tile sheet). Tiles are numbered left to
|
|
1488
1476
|
* right, top to bottom, starting at 0.
|
|
@@ -1562,8 +1550,7 @@ var TextureAtlas = class TextureAtlas {
|
|
|
1562
1550
|
});
|
|
1563
1551
|
}
|
|
1564
1552
|
};
|
|
1565
|
-
|
|
1566
|
-
//#region src/three/voxel-geometry.ts
|
|
1553
|
+
// src/three/voxel-geometry.ts
|
|
1567
1554
|
const cellKey = (u, v) => (u + 33554432) * 67108864 + (v + 33554432);
|
|
1568
1555
|
const planeKey = (d, side, slice) => (slice + 33554432) * 8 + d * 2 + (side > 0 ? 1 : 0);
|
|
1569
1556
|
/**
|
|
@@ -1789,8 +1776,7 @@ var VoxelGeometry = class extends three.BufferGeometry {
|
|
|
1789
1776
|
return this;
|
|
1790
1777
|
}
|
|
1791
1778
|
};
|
|
1792
|
-
|
|
1793
|
-
//#region src/three/voxel-mesh.ts
|
|
1779
|
+
// src/three/voxel-mesh.ts
|
|
1794
1780
|
/**
|
|
1795
1781
|
* Editable voxel model: `set()` voxels, then `update()` rebuilds the geometry if anything changed.
|
|
1796
1782
|
* Voxel values are palette indices; `Map3D`'s default value (-1) means empty.
|
|
@@ -1856,8 +1842,7 @@ var VoxelMesh = class extends three.Mesh {
|
|
|
1856
1842
|
return true;
|
|
1857
1843
|
}
|
|
1858
1844
|
};
|
|
1859
|
-
|
|
1860
|
-
//#region src/three/world.ts
|
|
1845
|
+
// src/three/world.ts
|
|
1861
1846
|
/**
|
|
1862
1847
|
* A scene of entities: three.js objects with components (see {@link CreateThreeEntity}),
|
|
1863
1848
|
* tracked by their `Object3D.uuid`.
|
|
@@ -2215,7 +2200,6 @@ var World = class {
|
|
|
2215
2200
|
};
|
|
2216
2201
|
const SCENE_FORMAT = "n3rdw1z4rd.scene";
|
|
2217
2202
|
const SCENE_VERSION = 1;
|
|
2218
|
-
//#endregion
|
|
2219
2203
|
exports.AdaptiveGrid = AdaptiveGrid;
|
|
2220
2204
|
exports.AddThreeComponent = AddThreeComponent;
|
|
2221
2205
|
exports.AsteroidMesh = AsteroidMesh;
|
package/dist/three.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { d as ColorPalette, h as NoiseFunction3D, i as Map3D } from "./map3d-
|
|
1
|
+
import { d as ColorPalette, h as NoiseFunction3D, i as Map3D } from "./map3d-DRHhbrFn.cjs";
|
|
2
2
|
import { BufferGeometry, ColorRepresentation, Group, LineBasicMaterial, LineSegments, Material, Mesh, MeshLambertMaterial, MeshLambertMaterialParameters, Object3D, OrthographicCamera, PerspectiveCamera, Points, Raycaster, Texture, Vector3, WebGLRenderer, WebGLRendererParameters } from "three";
|
|
3
|
-
//#region src/three/editor-camera.d.ts
|
|
4
3
|
/** Screen edges covered by UI, CSS px. */
|
|
5
4
|
export interface ViewInsets {
|
|
6
5
|
l: number;
|
|
@@ -91,8 +90,6 @@ export declare class EditorCamera {
|
|
|
91
90
|
*/
|
|
92
91
|
fit(minX: number, minY: number, maxX: number, maxY: number, insets?: ViewInsets, margin?: number, maxZoom?: number): void;
|
|
93
92
|
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/three/adaptive-grid.d.ts
|
|
96
93
|
/**
|
|
97
94
|
* An infinite-looking grid on the XY plane for editor views: each {@link AdaptiveGrid.update}
|
|
98
95
|
* rebuilds just the lines in view, doubling the spacing when zoomed out so lines never get
|
|
@@ -132,8 +129,6 @@ export declare class AdaptiveGrid extends LineSegments<BufferGeometry, LineBasic
|
|
|
132
129
|
private ensure;
|
|
133
130
|
dispose(): void;
|
|
134
131
|
}
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region src/three/asteroid-mesh.d.ts
|
|
137
132
|
/**
|
|
138
133
|
* Options for the {@link AsteroidMesh} constructor.
|
|
139
134
|
*
|
|
@@ -171,8 +166,6 @@ export interface AsteroidOptions {
|
|
|
171
166
|
export declare class AsteroidMesh extends Mesh {
|
|
172
167
|
constructor(options: AsteroidOptions);
|
|
173
168
|
}
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/three/camera-rig.d.ts
|
|
176
169
|
/**
|
|
177
170
|
* Options for the {@link CameraRig} constructor.
|
|
178
171
|
*
|
|
@@ -310,8 +303,6 @@ export declare class CameraRig extends Group {
|
|
|
310
303
|
private _clampPitch;
|
|
311
304
|
private _setFirstPerson;
|
|
312
305
|
}
|
|
313
|
-
//#endregion
|
|
314
|
-
//#region src/three/cube-sphere-geometry.d.ts
|
|
315
306
|
/**
|
|
316
307
|
* A sphere built from a subdivided cube, for planets and other displaced spheres.
|
|
317
308
|
*
|
|
@@ -363,8 +354,6 @@ export declare class CubeSphereGeometry extends BufferGeometry {
|
|
|
363
354
|
*/
|
|
364
355
|
static spherify(x: number, y: number, z: number): [number, number, number];
|
|
365
356
|
}
|
|
366
|
-
//#endregion
|
|
367
|
-
//#region src/three/ecs.d.ts
|
|
368
357
|
/**
|
|
369
358
|
* A component: any plain object of data, stored by name on a {@link ThreeEntity}.
|
|
370
359
|
*
|
|
@@ -439,8 +428,6 @@ export declare function IsThreeEntity(obj: Object3D): boolean;
|
|
|
439
428
|
* @category ECS
|
|
440
429
|
*/
|
|
441
430
|
export type ThreeSystem = (entities: Map<string, ThreeEntity>, delta: number, ...args: any) => void;
|
|
442
|
-
//#endregion
|
|
443
|
-
//#region src/three/particle-system-3d.d.ts
|
|
444
431
|
/**
|
|
445
432
|
* "Particle life" simulation in 3D: 1000 colored points in five species that attract or repel each
|
|
446
433
|
* other according to a random species-by-species matrix, forming moving clusters. Particles live in
|
|
@@ -491,8 +478,6 @@ export declare class ParticleSystem3d extends Group {
|
|
|
491
478
|
*/
|
|
492
479
|
update(camera: PerspectiveCamera, dt: number): void;
|
|
493
480
|
}
|
|
494
|
-
//#endregion
|
|
495
|
-
//#region src/three/schema.d.ts
|
|
496
481
|
/**
|
|
497
482
|
* Component schemas: what fields a component type has, their types, defaults and ranges.
|
|
498
483
|
*
|
|
@@ -629,8 +614,6 @@ export declare class ComponentRegistry {
|
|
|
629
614
|
* @category ECS
|
|
630
615
|
*/
|
|
631
616
|
export declare const components: ComponentRegistry;
|
|
632
|
-
//#endregion
|
|
633
|
-
//#region src/three/world.d.ts
|
|
634
617
|
/**
|
|
635
618
|
* A scene of entities: three.js objects with components (see {@link CreateThreeEntity}),
|
|
636
619
|
* tracked by their `Object3D.uuid`.
|
|
@@ -817,8 +800,6 @@ export interface EntityDoc {
|
|
|
817
800
|
/** component JSON by type name */
|
|
818
801
|
components: Record<string, Record<string, unknown>>;
|
|
819
802
|
}
|
|
820
|
-
//#endregion
|
|
821
|
-
//#region src/three/picking.d.ts
|
|
822
803
|
/** @category Three.js */
|
|
823
804
|
export interface EntityHit {
|
|
824
805
|
entity: ThreeEntity;
|
|
@@ -847,8 +828,6 @@ export interface PickOptions {
|
|
|
847
828
|
export declare function pickEntity(world: World, view: EditorCamera, sx: number, sy: number, options?: PickOptions): EntityHit | null;
|
|
848
829
|
/** The closest entity of `world` at or above `object`, or null. */
|
|
849
830
|
export declare function entityOf(world: World, object: Object3D): ThreeEntity | null;
|
|
850
|
-
//#endregion
|
|
851
|
-
//#region src/three/renderer.d.ts
|
|
852
831
|
/**
|
|
853
832
|
* `WebGLRenderer` that uses the device pixel ratio and can size itself to its parent element.
|
|
854
833
|
*
|
|
@@ -884,8 +863,6 @@ export declare class Renderer extends WebGLRenderer {
|
|
|
884
863
|
*/
|
|
885
864
|
resize(width?: number, height?: number): boolean;
|
|
886
865
|
}
|
|
887
|
-
//#endregion
|
|
888
|
-
//#region src/three/starfield.d.ts
|
|
889
866
|
/**
|
|
890
867
|
* Points spread uniformly over a sphere's surface, for a distant star backdrop (point size 5 with
|
|
891
868
|
* size attenuation, 0.9 opacity). The same `seed` always gives the same stars; without one,
|
|
@@ -906,8 +883,6 @@ export declare function CreateStarfield(radius?: number, count?: number, color?:
|
|
|
906
883
|
* @category Geometry & Meshes
|
|
907
884
|
*/
|
|
908
885
|
export declare function CreateSystemStar(position?: Vector3): Group;
|
|
909
|
-
//#endregion
|
|
910
|
-
//#region src/three/texture-utils.d.ts
|
|
911
886
|
/**
|
|
912
887
|
* A loaded texture with its image size, as returned by {@link LoadTexture}.
|
|
913
888
|
*
|
|
@@ -936,8 +911,6 @@ export declare function LoadTexture(url: string): Promise<TextureData>;
|
|
|
936
911
|
* @category Textures
|
|
937
912
|
*/
|
|
938
913
|
export declare function CreateSubTexture(texture: Texture, x: number, y: number, w: number, h: number): Texture;
|
|
939
|
-
//#endregion
|
|
940
|
-
//#region src/three/texture-atlas.d.ts
|
|
941
914
|
/**
|
|
942
915
|
* Texture coordinate `[u, v]`, each 0..1, with v = 1 at the image's top (three.js convention).
|
|
943
916
|
*
|
|
@@ -1010,8 +983,6 @@ export declare class TextureAtlas {
|
|
|
1010
983
|
/** a Lambert material using this atlas, set up for pixel-art tiles with transparency */
|
|
1011
984
|
createMaterial(params?: MeshLambertMaterialParameters): MeshLambertMaterial;
|
|
1012
985
|
}
|
|
1013
|
-
//#endregion
|
|
1014
|
-
//#region src/three/voxel-geometry.d.ts
|
|
1015
986
|
/**
|
|
1016
987
|
* Options for {@link buildVoxelGeometry} and {@link VoxelGeometry}.
|
|
1017
988
|
*
|
|
@@ -1079,8 +1050,6 @@ export declare class VoxelGeometry extends BufferGeometry {
|
|
|
1079
1050
|
/** Rebuilds the geometry from `voxels` and `options`. */
|
|
1080
1051
|
update(): this;
|
|
1081
1052
|
}
|
|
1082
|
-
//#endregion
|
|
1083
|
-
//#region src/three/voxel-mesh.d.ts
|
|
1084
1053
|
/**
|
|
1085
1054
|
* Box of voxel cells a {@link VoxelMesh} accepts, from the origin.
|
|
1086
1055
|
*
|
|
@@ -1143,5 +1112,4 @@ export declare class VoxelMesh extends Mesh<VoxelGeometry, Material | Material[]
|
|
|
1143
1112
|
/** Rebuilds the geometry if the voxels changed; returns whether it did. */
|
|
1144
1113
|
update(): boolean;
|
|
1145
1114
|
}
|
|
1146
|
-
//#endregion
|
|
1147
1115
|
export {};
|
package/dist/tilemap.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/tilemap.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Sparse 2D grid of arbitrary values, keyed by floored integer coordinates. Simpler than
|
|
4
3
|
* {@link Map2D} (string keys, any value type, no default value or range limit).
|
|
@@ -13,5 +12,4 @@ export declare class Tilemap<T = number> {
|
|
|
13
12
|
get(x: number, y: number): T | undefined;
|
|
14
13
|
/** Sets the tile containing (x, y). */
|
|
15
14
|
set(x: number, y: number, v: T): void;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
15
|
+
}
|
package/dist/tilemap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/tilemap.ts
|
|
2
2
|
/**
|
|
3
3
|
* Sparse 2D grid of arbitrary values, keyed by floored integer coordinates. Simpler than
|
|
4
4
|
* {@link Map2D} (string keys, any value type, no default value or range limit).
|
|
@@ -22,5 +22,4 @@ var Tilemap = class {
|
|
|
22
22
|
this.map.set(this._key(x, y), v);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
//#endregion
|
|
26
25
|
export { Tilemap };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Any object with numeric `x` and `y`, such as a {@link Vector}.
|
|
4
3
|
* @property x horizontal coordinate
|
|
@@ -30,5 +29,4 @@ export type KeyValue = Record<string, any>;
|
|
|
30
29
|
* matches simplex-noise's NoiseFunction3D, e.g. createNoise3D(() => rng.nextFloat())
|
|
31
30
|
* @category Math & Random
|
|
32
31
|
*/
|
|
33
|
-
export type NoiseFunction3D = (x: number, y: number, z: number) => number;
|
|
34
|
-
//#endregion
|
|
32
|
+
export type NoiseFunction3D = (x: number, y: number, z: number) => number;
|
package/dist/vector.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { XY } from "./types.js";
|
|
2
|
-
//#region src/vector.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Mutable 2D vector. Most methods modify the vector in place and return `this` for chaining;
|
|
5
4
|
* {@link Vector.clone} and {@link Vector.floored} return new vectors.
|
|
@@ -74,5 +73,4 @@ export declare class Vector {
|
|
|
74
73
|
static get EAST(): Vector;
|
|
75
74
|
/** new (-1, 0) */
|
|
76
75
|
static get WEST(): Vector;
|
|
77
|
-
}
|
|
78
|
-
//#endregion
|
|
76
|
+
}
|