@kvyverse/world-runtime 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +57 -0
- package/README.md +87 -0
- package/dist/BallCollider-8ZrxReEd.js +16 -0
- package/dist/CapsuleCollider-bynyf6Mc.js +20 -0
- package/dist/Collider-4_rCTHVA.js +82 -0
- package/dist/ConeCollider-DtRZmgK8.js +20 -0
- package/dist/ConvexMeshCollider-BSmDM4o3.js +14 -0
- package/dist/CuboidCollider-CJvq7--s.js +27 -0
- package/dist/CylinderCollider-CQPSh4tu.js +24 -0
- package/dist/FpsCameraController-BE2EirRj.js +55 -0
- package/dist/MeshInstansing-Bxij0Yc9.js +42 -0
- package/dist/PointerLockCameraControls-DYxxMeSw.js +104 -0
- package/dist/RapierDebugRenderer-sURZDLP4.js +55 -0
- package/dist/RapierFpsPlayerController-VsNfQl6v.js +142 -0
- package/dist/RapierPhysics-C_3b7QOn.js +74 -0
- package/dist/Rigidbody-b7QNF4ev.js +107 -0
- package/dist/ScalingToFro-BD-E5-uR.js +21 -0
- package/dist/SightInteractableArea-DrqyB41W.js +79 -0
- package/dist/SimpleWASDMovement-C2m53YYH.js +17 -0
- package/dist/Spinning-sgUhHld8.js +10 -0
- package/dist/StartAnimation-B9eomOS2.js +37 -0
- package/dist/TrimeshCollider-7dIs_xtZ.js +62 -0
- package/dist/World.d.ts +19 -0
- package/dist/WorldRuntime.d.ts +94 -0
- package/dist/behaviours/animation/ScalingToFro.d.ts +8 -0
- package/dist/behaviours/animation/Spinning.d.ts +5 -0
- package/dist/behaviours/animation/StartAnimation.d.ts +9 -0
- package/dist/behaviours/controls/FpsCameraController.d.ts +10 -0
- package/dist/behaviours/controls/PointerLockCameraControls.d.ts +28 -0
- package/dist/behaviours/controls/SimpleWASDMovement.d.ts +5 -0
- package/dist/behaviours/physics/BallCollider.d.ts +10 -0
- package/dist/behaviours/physics/CapsuleCollider.d.ts +14 -0
- package/dist/behaviours/physics/ConeCollider.d.ts +14 -0
- package/dist/behaviours/physics/ConvexMeshCollider.d.ts +6 -0
- package/dist/behaviours/physics/CuboidCollider.d.ts +22 -0
- package/dist/behaviours/physics/CylinderCollider.d.ts +18 -0
- package/dist/behaviours/physics/HalfspaceCollider.d.ts +7 -0
- package/dist/behaviours/physics/RapierFpsPlayerController.d.ts +35 -0
- package/dist/behaviours/physics/Rigidbody.d.ts +24 -0
- package/dist/behaviours/physics/TrimeshCollider.d.ts +9 -0
- package/dist/behaviours/physics/_required-patch.d.ts +10 -0
- package/dist/behaviours/physics/rapier-addon-core/Collider.d.ts +14 -0
- package/dist/behaviours/physics/rapier-addon-core/RapierDebugRenderer.d.ts +17 -0
- package/dist/behaviours/physics/rapier-addon-core/RapierPhysics.d.ts +131 -0
- package/dist/behaviours/physics/rapier-addon-core/get-scale-from-obj.d.ts +8 -0
- package/dist/behaviours/player/SightInteractableArea.d.ts +23 -0
- package/dist/behaviours/registry.d.ts +16 -0
- package/dist/behaviours/utils/MeshInstansing.d.ts +12 -0
- package/dist/bootstrap.d.ts +8 -0
- package/dist/define-world.d.ts +9 -0
- package/dist/get-scale-from-obj-QKv3Fig5.js +22 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +1707 -0
- package/dist/modules/EnvModule.d.ts +11 -0
- package/dist/modules/HtmlHudModule.d.ts +14 -0
- package/dist/modules/InputSystemModule.d.ts +87 -0
- package/dist/modules/SoundsModule.d.ts +7 -0
- package/dist/modules/UtilsModule.d.ts +9 -0
- package/dist/modules/contracts/env.module-api.d.ts +7 -0
- package/dist/modules/contracts/html.module-api.d.ts +7 -0
- package/dist/modules/contracts/input.module-api.d.ts +31 -0
- package/dist/modules/contracts/rapier.module-api.d.ts +11 -0
- package/dist/modules/contracts/rapierDebug.module-api.d.ts +5 -0
- package/dist/modules/contracts/sounds.module-api.d.ts +5 -0
- package/dist/modules/contracts/utils.module-api.d.ts +7 -0
- package/dist/modules/index.d.ts +22 -0
- package/dist/modules/is-mobile-device.d.ts +1 -0
- package/dist/modules/registry.d.ts +31 -0
- package/dist/rendering/SceneBloom.d.ts +40 -0
- package/dist/rendering/renderer-apply.d.ts +14 -0
- package/dist/rendering/renderer-options.d.ts +11 -0
- package/dist/rendering/tsl-node.d.ts +21 -0
- package/dist/rendering/tsl-uniforms.d.ts +18 -0
- package/dist/resources/audio.d.ts +15 -0
- package/dist/resources/default-resources.d.ts +36 -0
- package/dist/resources/font.d.ts +32 -0
- package/dist/resources/geometry.d.ts +5 -0
- package/dist/resources/hdr.d.ts +6 -0
- package/dist/resources/loaders.d.ts +45 -0
- package/dist/resources/model.d.ts +24 -0
- package/dist/resources/texture.d.ts +8 -0
- package/dist/resources/video.d.ts +14 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/settings/AddonsRuntime.d.ts +19 -0
- package/dist/settings/externals.d.ts +14 -0
- package/dist/settings/lib-loaders.d.ts +7 -0
- package/dist/settings/lib-registry.d.ts +24 -0
- package/dist/settings/module-registry.d.ts +25 -0
- package/dist/settings/types.d.ts +46 -0
- package/dist/types.d.ts +80 -0
- package/dist/utils/lazy.d.ts +4 -0
- package/dist/values.d.ts +6 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.gen.d.ts +1 -0
- package/dist/world-events.d.ts +13 -0
- package/package.json +53 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ContextModule } from "three-start";
|
|
2
|
+
import type { EnvModuleApi } from "./contracts/env.module-api";
|
|
3
|
+
/** Where the world runs: `dev` — testplay from the editor, `prod` — the game. */
|
|
4
|
+
export type EnvMode = EnvModuleApi["mode"];
|
|
5
|
+
export declare class EnvModule extends ContextModule implements EnvModuleApi {
|
|
6
|
+
dev: boolean;
|
|
7
|
+
prod: boolean;
|
|
8
|
+
mode: EnvMode;
|
|
9
|
+
isMobile: boolean;
|
|
10
|
+
constructor(mode: EnvMode);
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ContextModule } from "three-start";
|
|
2
|
+
import type { HtmlModuleApi } from "./contracts/html.module-api";
|
|
3
|
+
export declare class HtmlHudModule extends ContextModule implements HtmlModuleApi {
|
|
4
|
+
readonly root: HTMLDivElement;
|
|
5
|
+
readonly crosshair: HTMLDivElement;
|
|
6
|
+
constructor();
|
|
7
|
+
onAwake(): void;
|
|
8
|
+
append(...nodes: Array<Node | string>): void;
|
|
9
|
+
setCrosshair(innerHtml: string): void;
|
|
10
|
+
/** three-start ContextModule has no onDestroy; teardown is explicit. */
|
|
11
|
+
dispose(): void;
|
|
12
|
+
private readonly onMount;
|
|
13
|
+
private readonly onUnmount;
|
|
14
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ContextModule } from "three-start";
|
|
2
|
+
import EventEmitter from "eventemitter3";
|
|
3
|
+
import * as THREE from "three/webgpu";
|
|
4
|
+
import type { InputModuleApi } from "./contracts/input.module-api";
|
|
5
|
+
declare class PlayerInput extends EventEmitter<{
|
|
6
|
+
dirchanged: [forward: number, lateral: number];
|
|
7
|
+
forcechanged: [force: number];
|
|
8
|
+
jump: [];
|
|
9
|
+
}> {
|
|
10
|
+
private _forward;
|
|
11
|
+
private _lateral;
|
|
12
|
+
private _force;
|
|
13
|
+
/**
|
|
14
|
+
* @default 0
|
|
15
|
+
*/
|
|
16
|
+
get forward(): number;
|
|
17
|
+
/**
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
get lateral(): number;
|
|
21
|
+
/**
|
|
22
|
+
* @default 1
|
|
23
|
+
*/
|
|
24
|
+
get force(): number;
|
|
25
|
+
setDir(forward: number, lateral: number): void;
|
|
26
|
+
setForce(force: number): void;
|
|
27
|
+
jump(): void;
|
|
28
|
+
/**
|
|
29
|
+
* 0 is keyboard, 1 is joystick
|
|
30
|
+
* @default 0
|
|
31
|
+
*/
|
|
32
|
+
mode: 0 | 1;
|
|
33
|
+
}
|
|
34
|
+
export declare class InputSystemModule extends ContextModule<{
|
|
35
|
+
keyschanged: [];
|
|
36
|
+
}> implements InputModuleApi {
|
|
37
|
+
private _dom;
|
|
38
|
+
private readonly _keys;
|
|
39
|
+
private _shift;
|
|
40
|
+
private _alt;
|
|
41
|
+
private _ctrl;
|
|
42
|
+
private _meta;
|
|
43
|
+
private _isDragging;
|
|
44
|
+
private readonly _pointerNdc;
|
|
45
|
+
private readonly _averageActivePointersCoords;
|
|
46
|
+
private _pointerXStack;
|
|
47
|
+
private _pointerYStack;
|
|
48
|
+
private _domBoundingClientRect;
|
|
49
|
+
readonly activePointers: Map<number, PointerEvent>;
|
|
50
|
+
get pointerDeltaX(): number;
|
|
51
|
+
get pointerDeltaY(): number;
|
|
52
|
+
get isDragging(): boolean;
|
|
53
|
+
/** Pointer position {x,y} in normalized device coordinates (-1 to +1) */
|
|
54
|
+
get pointerNdc(): THREE.Vector2;
|
|
55
|
+
get shiftKey(): boolean;
|
|
56
|
+
get altKey(): boolean;
|
|
57
|
+
get ctrlKey(): boolean;
|
|
58
|
+
get metaKey(): boolean;
|
|
59
|
+
isKeyDown: (key: string) => boolean;
|
|
60
|
+
readonly player: PlayerInput;
|
|
61
|
+
onAwake(): void;
|
|
62
|
+
/** three-start `ContextModule` has no `onDestroy`; teardown is explicit. */
|
|
63
|
+
dispose(): void;
|
|
64
|
+
private onWindowResize;
|
|
65
|
+
private onWindowScroll;
|
|
66
|
+
private onDomResize;
|
|
67
|
+
private onFocus;
|
|
68
|
+
private onBlur;
|
|
69
|
+
private onKeyDown;
|
|
70
|
+
private onKeyUp;
|
|
71
|
+
private onPointerEnter;
|
|
72
|
+
private onPointerDown;
|
|
73
|
+
private onPointerMove;
|
|
74
|
+
private onPointerUp;
|
|
75
|
+
private onPointerLeave;
|
|
76
|
+
private resetKeys;
|
|
77
|
+
private updFnKeys;
|
|
78
|
+
private updateAverageActivePointersCoords;
|
|
79
|
+
private updateStackAndNdcByActivePointers;
|
|
80
|
+
private updateStackAndNdcByPointer;
|
|
81
|
+
private pushPointerStack;
|
|
82
|
+
private fillPointerStack;
|
|
83
|
+
private resetPointers;
|
|
84
|
+
private recalculatePointerNdc;
|
|
85
|
+
private updateDomBoundingClientRect;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ContextModule } from "three-start";
|
|
2
|
+
import type { SoundsModuleApi } from "./contracts/sounds.module-api";
|
|
3
|
+
export declare class SoundsModule extends ContextModule implements SoundsModuleApi {
|
|
4
|
+
readonly global: HowlerGlobal;
|
|
5
|
+
/** three-start ContextModule has no onDestroy; teardown is explicit. */
|
|
6
|
+
dispose(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContextModule } from "three-start";
|
|
2
|
+
import { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
3
|
+
import { clone } from "three/examples/jsm/utils/SkeletonUtils.js";
|
|
4
|
+
import type { UtilsModuleApi } from "./contracts/utils.module-api";
|
|
5
|
+
export declare class UtilsModule extends ContextModule implements UtilsModuleApi {
|
|
6
|
+
cloneObject3D: typeof clone;
|
|
7
|
+
mergeGeometries: typeof mergeGeometries;
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Public API of the `html` module — fullscreen HTML HUD on top of the canvas. */
|
|
2
|
+
export interface HtmlModuleApi {
|
|
3
|
+
readonly root: HTMLDivElement;
|
|
4
|
+
readonly crosshair: HTMLDivElement;
|
|
5
|
+
append: (...nodes: Array<Node | string>) => void;
|
|
6
|
+
setCrosshair: (innerHtml: string) => void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as THREE from "three/webgpu";
|
|
2
|
+
/**
|
|
3
|
+
* Public API of the input module, available in user scripts
|
|
4
|
+
* (`this.modules.input` / `Game.ctx.modules.input`).
|
|
5
|
+
*
|
|
6
|
+
* Source of truth: the real `InputSystemModule implements InputModuleApi` —
|
|
7
|
+
* if the class stops matching the contract, the project won't compile.
|
|
8
|
+
* This same file is fed into Monaco (see `monaco/monaco-lib-types.ts`).
|
|
9
|
+
*/
|
|
10
|
+
export interface InputModuleApi {
|
|
11
|
+
readonly pointerDeltaX: number;
|
|
12
|
+
readonly pointerDeltaY: number;
|
|
13
|
+
readonly isDragging: boolean;
|
|
14
|
+
readonly pointerNdc: THREE.Vector2;
|
|
15
|
+
readonly activePointers: ReadonlyMap<number, PointerEvent>;
|
|
16
|
+
readonly shiftKey: boolean;
|
|
17
|
+
readonly altKey: boolean;
|
|
18
|
+
readonly ctrlKey: boolean;
|
|
19
|
+
readonly metaKey: boolean;
|
|
20
|
+
isKeyDown: (key: string) => boolean;
|
|
21
|
+
readonly player: PlayerInputApi;
|
|
22
|
+
}
|
|
23
|
+
/** Player's virtual gamepad stick (`input.player`). */
|
|
24
|
+
export interface PlayerInputApi {
|
|
25
|
+
readonly forward: number;
|
|
26
|
+
readonly lateral: number;
|
|
27
|
+
readonly force: number;
|
|
28
|
+
setDir: (forward: number, lateral: number) => void;
|
|
29
|
+
setForce: (force: number) => void;
|
|
30
|
+
jump: () => void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type RAPIER from "@dimforge/rapier3d-compat";
|
|
2
|
+
export type RapierJsModule = typeof RAPIER;
|
|
3
|
+
/** Public API of the `rapier` module — Rapier physics world, event queue, simulation step. */
|
|
4
|
+
export interface RapierModuleApi {
|
|
5
|
+
readonly isRapierPhysics: true;
|
|
6
|
+
readonly api: RapierJsModule;
|
|
7
|
+
readonly world: RAPIER.World;
|
|
8
|
+
readonly eventQueue: RAPIER.EventQueue;
|
|
9
|
+
/** @default "vary" */
|
|
10
|
+
timeStep: number | "vary";
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
2
|
+
import type { clone } from "three/examples/jsm/utils/SkeletonUtils.js";
|
|
3
|
+
/** Public API of the `utils` module — three.js helpers (clone, merge geometries, type-guard). */
|
|
4
|
+
export interface UtilsModuleApi {
|
|
5
|
+
readonly cloneObject3D: typeof clone;
|
|
6
|
+
readonly mergeGeometries: typeof mergeGeometries;
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EnvModule } from "./EnvModule";
|
|
2
|
+
import { HtmlHudModule } from "./HtmlHudModule";
|
|
3
|
+
import { InputSystemModule } from "./InputSystemModule";
|
|
4
|
+
import { SoundsModule } from "./SoundsModule";
|
|
5
|
+
import { UtilsModule } from "./UtilsModule";
|
|
6
|
+
import type { EnvMode } from "./EnvModule";
|
|
7
|
+
export { EnvModule } from "./EnvModule";
|
|
8
|
+
export { HtmlHudModule } from "./HtmlHudModule";
|
|
9
|
+
export { InputSystemModule } from "./InputSystemModule";
|
|
10
|
+
export { SoundsModule } from "./SoundsModule";
|
|
11
|
+
export { UtilsModule } from "./UtilsModule";
|
|
12
|
+
export { isMobileDevice } from "./is-mobile-device";
|
|
13
|
+
export type { EnvMode } from "./EnvModule";
|
|
14
|
+
export type WorldModules = {
|
|
15
|
+
env: EnvModule;
|
|
16
|
+
html: HtmlHudModule;
|
|
17
|
+
input: InputSystemModule;
|
|
18
|
+
sounds: SoundsModule;
|
|
19
|
+
utils: UtilsModule;
|
|
20
|
+
};
|
|
21
|
+
/** World ctx modules. Registered before `start()` — three-start forbids it later. */
|
|
22
|
+
export declare function createWorldModules(mode?: EnvMode): WorldModules;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isMobileDevice(): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RapierDebugRenderer } from "../behaviours/physics/rapier-addon-core/RapierDebugRenderer";
|
|
2
|
+
import type { RapierPhysics } from "../behaviours/physics/rapier-addon-core/RapierPhysics";
|
|
3
|
+
import type { EnvModule } from "./EnvModule";
|
|
4
|
+
import type { HtmlHudModule } from "./HtmlHudModule";
|
|
5
|
+
import type { InputSystemModule } from "./InputSystemModule";
|
|
6
|
+
import type { SoundsModule } from "./SoundsModule";
|
|
7
|
+
import type { UtilsModule } from "./UtilsModule";
|
|
8
|
+
/**
|
|
9
|
+
* Single registry of the world's three-start modules: key → concrete class.
|
|
10
|
+
* Source of truth for the module list and their types inside the engine; the
|
|
11
|
+
* public contracts of the same modules (for Monaco) live in
|
|
12
|
+
* `./contracts/*.module-api.ts`, which the classes `implements`.
|
|
13
|
+
*
|
|
14
|
+
* three-start types modules globally (no per-ctx generic), so a module declared
|
|
15
|
+
* here may be missing in a particular ctx (e.g. editor-ctx registers only `input`).
|
|
16
|
+
*/
|
|
17
|
+
export interface KvyverseModules {
|
|
18
|
+
input: InputSystemModule;
|
|
19
|
+
env: EnvModule;
|
|
20
|
+
html: HtmlHudModule;
|
|
21
|
+
sounds: SoundsModule;
|
|
22
|
+
utils: UtilsModule;
|
|
23
|
+
rapier: RapierPhysics;
|
|
24
|
+
rapierDebug: RapierDebugRenderer;
|
|
25
|
+
}
|
|
26
|
+
declare module "three-start" {
|
|
27
|
+
interface ThreeStartRegister {
|
|
28
|
+
modules: KvyverseModules;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type BloomNode from "three/addons/tsl/display/BloomNode.js";
|
|
2
|
+
import type * as THREE from "three/webgpu";
|
|
3
|
+
import type { BloomModeName } from "./renderer-options";
|
|
4
|
+
import type { BloomConfig } from "../settings/types";
|
|
5
|
+
/**
|
|
6
|
+
* Enables MRT `{ output, emissive }` on the scenePass. Idempotent. IMPORTANT:
|
|
7
|
+
* MRT is part of the WebGPU pipelines' attachment state; enable it either before
|
|
8
|
+
* the first frame (game), or sticky + material invalidation (editor). It must
|
|
9
|
+
* NEVER be disabled at runtime — see `./README.md` → "MRT and attachment state".
|
|
10
|
+
*/
|
|
11
|
+
export declare function enableSceneEmissiveMrt(scenePass: THREE.PassNode): void;
|
|
12
|
+
/**
|
|
13
|
+
* Bloom post-effect over the scenePass (editor + game). `mode=threshold` —
|
|
14
|
+
* full-frame by brightness; `mode=emissive` — selective, via the emissive MRT
|
|
15
|
+
* target (MRT must be enabled by the caller via `enableSceneEmissiveMrt` BEFORE
|
|
16
|
+
* creation). SceneBloom does not own the MRT topology. Pipeline contracts — `./README.md`.
|
|
17
|
+
*/
|
|
18
|
+
export declare class SceneBloom {
|
|
19
|
+
readonly mode: BloomModeName;
|
|
20
|
+
/** Bloom contribution (RGB) — for custom outputNode composition (editor). */
|
|
21
|
+
readonly node: BloomNode;
|
|
22
|
+
/** `scenePassColor + bloom` — ready outputNode for the default pipeline (game). */
|
|
23
|
+
readonly sceneWithBloom: THREE.Node;
|
|
24
|
+
private constructor();
|
|
25
|
+
static createAsync(props: {
|
|
26
|
+
scenePass: THREE.PassNode;
|
|
27
|
+
config: BloomConfig;
|
|
28
|
+
}): Promise<SceneBloom>;
|
|
29
|
+
/** strength/radius/threshold are uniforms — applied on the fly without a rebuild. */
|
|
30
|
+
updateParams(cfg: BloomConfig): void;
|
|
31
|
+
get strength(): number;
|
|
32
|
+
set strength(value: number);
|
|
33
|
+
get radius(): number;
|
|
34
|
+
set radius(value: number);
|
|
35
|
+
get threshold(): number;
|
|
36
|
+
set threshold(value: number);
|
|
37
|
+
/** true — a mode change requires recreation (dispose + createAsync + new outputNode). */
|
|
38
|
+
needsRebuild(cfg: BloomConfig): boolean;
|
|
39
|
+
dispose(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as THREE from "three/webgpu";
|
|
2
|
+
import type { RendererConfig } from "../settings/types";
|
|
3
|
+
/**
|
|
4
|
+
* Applies the runtime part of `RendererConfig` to an already created WebGPURenderer
|
|
5
|
+
* (shadowMap, toneMapping, pixelRatio). Used by game (once on load) and editor
|
|
6
|
+
* (live, see `editor/rendering`). Defaults: PCFSoft shadows, Neutral tonemap,
|
|
7
|
+
* pixelResolution=1. Construction params (`cfg.renderer`) are applied only in
|
|
8
|
+
* the renderer constructor (see `createGameCtx`).
|
|
9
|
+
*
|
|
10
|
+
* The config is NOT schema-validated at runtime (raw JSON.parse), so bad values
|
|
11
|
+
* (enum typo, non-number) fall back to defaults instead of producing an
|
|
12
|
+
* `undefined` constant / `NaN` (silently broken rendering).
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyRendererConfig(renderer: THREE.Renderer, cfg: RendererConfig): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String names for renderer options set as words in the config and mapped to
|
|
3
|
+
* THREE constants at runtime (game). Single source for the JSON schema
|
|
4
|
+
* (`renderer.schema`) and the runtime mapping (`game`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const SHADOW_MAP_TYPES: readonly ["Basic", "PCF", "PCFSoft", "VSM"];
|
|
7
|
+
export type ShadowMapTypeName = (typeof SHADOW_MAP_TYPES)[number];
|
|
8
|
+
export declare const BLOOM_MODES: readonly ["threshold", "emissive"];
|
|
9
|
+
export type BloomModeName = (typeof BLOOM_MODES)[number];
|
|
10
|
+
export declare const TONE_MAPPING_NAMES: readonly ["None", "Linear", "Reinhard", "Cineon", "ACESFilmic", "AgX", "Neutral"];
|
|
11
|
+
export type ToneMappingName = (typeof TONE_MAPPING_NAMES)[number];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as TSL from "three/tsl";
|
|
2
|
+
import type { Node } from "three/webgpu";
|
|
3
|
+
/** TSL node body: returns a graph node, receiving `TSL` and the uniform nodes. */
|
|
4
|
+
export type TslNodeBuilder = (tsl: typeof TSL, uniforms: Record<string, Node>) => Node | null | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* World TSL node: the built graph node + its uniform nodes. This is what
|
|
7
|
+
* `require("/Shaders/....tsl")` returns, so the method set matches the editor's
|
|
8
|
+
* `TslNodeSource` (`setUniformValue` / `getUniformValue` / `uniformValues`).
|
|
9
|
+
*/
|
|
10
|
+
export declare class TslNode {
|
|
11
|
+
readonly uniforms: Record<string, Node>;
|
|
12
|
+
readonly node: Node;
|
|
13
|
+
private _uniformValuesView?;
|
|
14
|
+
constructor(uniforms: Record<string, Node>, build: TslNodeBuilder, name?: string);
|
|
15
|
+
/** Flat view of uniform values: reads and writes go straight to `node.value`. */
|
|
16
|
+
get uniformValues(): Record<string, unknown>;
|
|
17
|
+
setUniformValue(key: string, value: unknown): void;
|
|
18
|
+
getUniformValue(key: string): unknown;
|
|
19
|
+
}
|
|
20
|
+
/** Factory for the generated code: builds the node and wraps it. */
|
|
21
|
+
export declare function createTslNode(uniforms: Record<string, Node>, build: TslNodeBuilder, name?: string): TslNode;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Node } from "three/webgpu";
|
|
2
|
+
/**
|
|
3
|
+
* Uniform parameter types of a TSL node. The `uniforms` nodes on `TslNodeSource`
|
|
4
|
+
* are the single source of truth: the type is read from the node ({@link uniformType}),
|
|
5
|
+
* the default is baked in ({@link UNIFORM_DEFAULTS}). Details — `docs/tsl-shading.md`.
|
|
6
|
+
*/
|
|
7
|
+
export type UniformType = "float" | "int" | "vec2" | "vec3" | "vec4" | "color" | "bool" | "texture";
|
|
8
|
+
export declare const UNIFORM_TYPES: readonly ["float", "int", "vec2", "vec3", "vec4", "color", "bool", "texture"];
|
|
9
|
+
export declare function isUniformType(x: string): x is UniformType;
|
|
10
|
+
/** Uniform node type. Texture is a separate class; the rest carry an explicit `nodeType`. */
|
|
11
|
+
export declare function uniformType(node: Node): UniformType;
|
|
12
|
+
/** Creates a uniform node with the type's baked-in default. The type is set
|
|
13
|
+
* explicitly — otherwise `int`/`float` and `color`/`vec3` are indistinguishable
|
|
14
|
+
* from the value. */
|
|
15
|
+
export declare function createUniformNode(type: UniformType): Node;
|
|
16
|
+
/** Default value per type — for `Property.setDefault` (value==default is not
|
|
17
|
+
* serialized, restored on load). Factories, since Color/Vec are mutable. */
|
|
18
|
+
export declare const UNIFORM_DEFAULTS: Record<UniformType, () => unknown>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Howl } from "howler";
|
|
2
|
+
/**
|
|
3
|
+
* Audio asset source: a `Howl` with identity — this is what scripts get
|
|
4
|
+
* from `require("/Sounds/...")`.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AudioSource extends Howl {
|
|
7
|
+
private readonly _url;
|
|
8
|
+
name: string;
|
|
9
|
+
uuid: `${string}-${string}-${string}-${string}-${string}`;
|
|
10
|
+
constructor(_url: string, ...args: ConstructorParameters<typeof Howl>);
|
|
11
|
+
/** Revoke blob URLs (the editor keeps the file in memory); external URLs stay. */
|
|
12
|
+
dispose(): void;
|
|
13
|
+
}
|
|
14
|
+
/** Loaded audio from a URL. `format` — extension hint when it's absent from the URL. */
|
|
15
|
+
export declare function createAudio(url: string, format?: string | string[], name?: string): Promise<AudioSource>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as THREE from "three/webgpu";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in engine resources with fixed uuids: world values reference them via
|
|
4
|
+
* a regular ref (`{$A:"6"}`), so the identifiers must never change.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DefaultResourceId: {
|
|
7
|
+
readonly EmptyGeometry: "0";
|
|
8
|
+
readonly BoxGeometry: "1";
|
|
9
|
+
readonly SphereGeometry: "2";
|
|
10
|
+
readonly PlaneGeometry: "3";
|
|
11
|
+
readonly CylinderGeometry: "4";
|
|
12
|
+
readonly PyramidGeometry: "5";
|
|
13
|
+
readonly Material: "6";
|
|
14
|
+
readonly SpriteMaterial: "7";
|
|
15
|
+
readonly Texture: "8";
|
|
16
|
+
};
|
|
17
|
+
export type DefaultResourceIdValue = (typeof DefaultResourceId)[keyof typeof DefaultResourceId];
|
|
18
|
+
/** Resource type by id — so call sites need no casts. */
|
|
19
|
+
export interface DefaultResourceTypes {
|
|
20
|
+
"0": THREE.BufferGeometry;
|
|
21
|
+
"1": THREE.BoxGeometry;
|
|
22
|
+
"2": THREE.SphereGeometry;
|
|
23
|
+
"3": THREE.PlaneGeometry;
|
|
24
|
+
"4": THREE.CylinderGeometry;
|
|
25
|
+
"5": THREE.ConeGeometry;
|
|
26
|
+
"6": THREE.MeshStandardNodeMaterial;
|
|
27
|
+
"7": THREE.SpriteNodeMaterial;
|
|
28
|
+
"8": THREE.DataTexture;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resource by its uuid. Lazy and cached: an exported world creates only
|
|
32
|
+
* what it actually references.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getDefaultResource<TId extends DefaultResourceIdValue>(id: TId): DefaultResourceTypes[TId];
|
|
35
|
+
export declare const DEFAULT_RESOURCE_IDS: DefaultResourceIdValue[];
|
|
36
|
+
export declare function isDefaultResourceId(uuid: string): uuid is DefaultResourceIdValue;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Font } from "three/examples/jsm/loaders/FontLoader.js";
|
|
2
|
+
/** CSS font format by mime (for `@font-face … format(...)`). */
|
|
3
|
+
export declare function fontFormatFromMime(mime: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Font source: the CSS side (`family` + `toFontFaceCss`) and the three side
|
|
6
|
+
* (`getThreeFontAsync`, lazy TTFLoader/opentype chunk).
|
|
7
|
+
*/
|
|
8
|
+
export declare class FontSource {
|
|
9
|
+
readonly url: string;
|
|
10
|
+
/** CSS format (`truetype`, `woff2`, …) — see `fontFormatFromMime`. */
|
|
11
|
+
readonly format: string;
|
|
12
|
+
name: string;
|
|
13
|
+
uuid: `${string}-${string}-${string}-${string}-${string}`;
|
|
14
|
+
/** CSS font-family. Edited in the inspector, persisted in `values.src.family`. */
|
|
15
|
+
family: string;
|
|
16
|
+
private _threeFontPromise;
|
|
17
|
+
constructor(url: string, family: string,
|
|
18
|
+
/** CSS format (`truetype`, `woff2`, …) — see `fontFormatFromMime`. */
|
|
19
|
+
format: string);
|
|
20
|
+
/** Ready-to-use `@font-face` rule for the game document. */
|
|
21
|
+
toFontFaceCss(): string;
|
|
22
|
+
/**
|
|
23
|
+
* three.js `Font` (for TextGeometry etc.). Lazy TTFLoader import
|
|
24
|
+
* (pulls opentype ~100kB gzip), the result is cached. woff2 is not
|
|
25
|
+
* supported by opentype — throws a clear error.
|
|
26
|
+
*/
|
|
27
|
+
getThreeFontAsync(): Promise<Font>;
|
|
28
|
+
dispose(): void;
|
|
29
|
+
private _parseThreeFontAsync;
|
|
30
|
+
}
|
|
31
|
+
/** Font source from a URL. `mime` determines the CSS format of the `@font-face` rule. */
|
|
32
|
+
export declare function createFont(url: string, family: string, mime: string, name?: string): FontSource;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type * as THREE from "three/webgpu";
|
|
2
|
+
/** Geometry from our json format (`BufferGeometry.toJSON`). */
|
|
3
|
+
export declare function parseGeometryJson(json: unknown, name?: string): THREE.BufferGeometry;
|
|
4
|
+
/** Loads geometry from a URL and parses it. */
|
|
5
|
+
export declare function loadGeometry(url: string, name?: string): Promise<THREE.BufferGeometry>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as THREE from "three/webgpu";
|
|
2
|
+
export type HdrFormat = "hdr" | "exr";
|
|
3
|
+
/** Parses hdr/exr into a `DataTexture` with environment defaults (equirect, no mipmaps). */
|
|
4
|
+
export declare function parseHdr(data: ArrayBuffer, format: HdrFormat, name?: string): Promise<THREE.DataTexture>;
|
|
5
|
+
/** Loads hdr/exr from a URL and parses it. */
|
|
6
|
+
export declare function loadHdr(url: string, format: HdrFormat, name?: string): Promise<THREE.DataTexture>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BufferGeometryLoader, LoadingManager, TextureLoader } from "three/webgpu";
|
|
2
|
+
export declare const LOADING_MANAGER: LoadingManager;
|
|
3
|
+
declare const options: {
|
|
4
|
+
/**
|
|
5
|
+
* Draco decoder folder (file names inside are fixed, the folder is
|
|
6
|
+
* versioned). Default — the public Google decoder: always available and
|
|
7
|
+
* served with CORS, so an exported world works without our infrastructure.
|
|
8
|
+
* The host may override it: the app serves its own copy from
|
|
9
|
+
* `public/draco/<hash>/`, a self-hosted world — via `loadWorld({ dracoPath })`.
|
|
10
|
+
*/
|
|
11
|
+
dracoPath: string;
|
|
12
|
+
};
|
|
13
|
+
/** Loader configuration. Called by the host before the first asset load. */
|
|
14
|
+
export declare function configureAssetLoaders(next: Partial<typeof options>): void;
|
|
15
|
+
/** Lazy three loaders: the chunk is pulled only on first use of the format. */
|
|
16
|
+
export declare const AssetLoaders: {
|
|
17
|
+
texture: {
|
|
18
|
+
get: () => TextureLoader;
|
|
19
|
+
};
|
|
20
|
+
gltf: {
|
|
21
|
+
get: () => Promise<import("three/examples/jsm/loaders/GLTFLoader.js").GLTFLoader>;
|
|
22
|
+
};
|
|
23
|
+
fbx: {
|
|
24
|
+
get: () => Promise<import("three/examples/jsm/loaders/FBXLoader.js").FBXLoader>;
|
|
25
|
+
};
|
|
26
|
+
obj: {
|
|
27
|
+
get: () => Promise<import("three/examples/jsm/loaders/OBJLoader.js").OBJLoader>;
|
|
28
|
+
};
|
|
29
|
+
rgbe: {
|
|
30
|
+
get: () => Promise<import("three/examples/jsm/loaders/RGBELoader.js").RGBELoader>;
|
|
31
|
+
};
|
|
32
|
+
exr: {
|
|
33
|
+
get: () => Promise<import("three/examples/jsm/loaders/EXRLoader.js").EXRLoader>;
|
|
34
|
+
};
|
|
35
|
+
bufferGeometry: {
|
|
36
|
+
get: () => BufferGeometryLoader;
|
|
37
|
+
};
|
|
38
|
+
font: {
|
|
39
|
+
get: () => Promise<{
|
|
40
|
+
ttfLoader: import("three/examples/jsm/loaders/TTFLoader.js").TTFLoader;
|
|
41
|
+
Font: typeof import("three/examples/jsm/loaders/FontLoader.js").Font;
|
|
42
|
+
}>;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as THREE from "three/webgpu";
|
|
2
|
+
export type ModelFormat = "gltf" | "glb" | "fbx" | "obj";
|
|
3
|
+
/**
|
|
4
|
+
* 3D model sub-resources in traversal order. The order is part of the contract:
|
|
5
|
+
* the editor numbers sub-assets by it (`<uuid>_geom_<i>`), the export codegen
|
|
6
|
+
* resolves refs by the same indices.
|
|
7
|
+
*/
|
|
8
|
+
export interface ModelSubResources {
|
|
9
|
+
geometries: THREE.BufferGeometry[];
|
|
10
|
+
materials: THREE.Material[];
|
|
11
|
+
textures: THREE.Texture[];
|
|
12
|
+
animations: THREE.AnimationClip[];
|
|
13
|
+
skeletons: THREE.Skeleton[];
|
|
14
|
+
}
|
|
15
|
+
/** Parses model bytes into a hierarchy. `data`: ArrayBuffer, for obj — text. */
|
|
16
|
+
export declare function parseModel(data: ArrayBuffer | string, format: ModelFormat, name?: string): Promise<THREE.Object3D>;
|
|
17
|
+
/** Loads a model from a URL and parses it. */
|
|
18
|
+
export declare function loadModel(url: string, format: ModelFormat, name?: string): Promise<THREE.Object3D>;
|
|
19
|
+
/**
|
|
20
|
+
* Collects model sub-resources in a single traversal. The only implementation:
|
|
21
|
+
* used by `Model3DAsset` in the editor and by the export generator — otherwise
|
|
22
|
+
* refs to the model's materials and geometries drift apart by index.
|
|
23
|
+
*/
|
|
24
|
+
export declare function collectModelSubResources(root: THREE.Object3D): ModelSubResources;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as THREE from "three/webgpu";
|
|
2
|
+
/**
|
|
3
|
+
* World texture defaults: clamp wrapping switches to repeat, color space
|
|
4
|
+
* is sRGB. Identical in the editor, the game and the exported world.
|
|
5
|
+
*/
|
|
6
|
+
export declare function applyTextureDefaults(texture: THREE.Texture, name?: string): void;
|
|
7
|
+
/** Texture from a URL with defaults applied. */
|
|
8
|
+
export declare function loadTexture(url: string, name?: string): Promise<THREE.Texture>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video asset source: a `<video>` with identity — this is what scripts get
|
|
3
|
+
* from `require("/Videos/...")` (and `THREE.VideoTexture` from `element`).
|
|
4
|
+
*/
|
|
5
|
+
export declare class VideoSource {
|
|
6
|
+
readonly element: HTMLVideoElement;
|
|
7
|
+
private _url;
|
|
8
|
+
name: string;
|
|
9
|
+
uuid: `${string}-${string}-${string}-${string}-${string}`;
|
|
10
|
+
constructor(element: HTMLVideoElement, _url: string | null);
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|
|
13
|
+
/** Playback-ready `<video>` from a URL (waits for `loadeddata`). */
|
|
14
|
+
export declare function createVideo(url: string, name?: string): Promise<VideoSource>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AddonsConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Runtime loading of addons (game-only): enabled built-in libs + external
|
|
4
|
+
* scripts (externals). Exposes them to user scripts via `resolve(key)`
|
|
5
|
+
* (used in `ScriptsRuntime.require`). Replaces the old
|
|
6
|
+
* `GameLoader.loadExternalsAsync` / `getExternalLib`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AddonsRuntime {
|
|
9
|
+
/** libs — by requireKey (`@tweenjs/tween.js`), externals — by accessor (`Tone`). */
|
|
10
|
+
private readonly _byKey;
|
|
11
|
+
private readonly _scriptTags;
|
|
12
|
+
load(addons: AddonsConfig): Promise<void>;
|
|
13
|
+
/** Resolves a require key: enabled lib or external accessor; undefined otherwise. */
|
|
14
|
+
resolve(key: string): unknown;
|
|
15
|
+
private _loadLibs;
|
|
16
|
+
private _loadExternals;
|
|
17
|
+
private _mountScript;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External scripts enabled via `settings.addons.json → externals`.
|
|
3
|
+
* The user configures them manually. Resolved in scripts via
|
|
4
|
+
* `require("<accessor>")`. Loading/mount — game (`AddonsRuntime`):
|
|
5
|
+
* - `umd` → `<script>` tag → `window[accessor]`,
|
|
6
|
+
* - `module` → `await import(src)` → cached by `accessor`.
|
|
7
|
+
*/
|
|
8
|
+
export type ExternalType = "umd" | "module";
|
|
9
|
+
export interface ExternalDescriptor {
|
|
10
|
+
accessor: string;
|
|
11
|
+
type: ExternalType;
|
|
12
|
+
src: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const EXTERNAL_TYPES: readonly ExternalType[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LibId } from "./lib-registry";
|
|
2
|
+
/**
|
|
3
|
+
* Dynamic loaders of built-in libs (game-only). Key — `LibId` from the registry;
|
|
4
|
+
* the value resolves for the user via `require("<requireKey>")`. Imports are lazy —
|
|
5
|
+
* bundled only when the lib is enabled in `settings.addons.json`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const LIB_LOADERS: Record<LibId, () => Promise<unknown>>;
|