@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,9 @@
|
|
|
1
|
+
import { Object3DBehaviour } from "three-start";
|
|
2
|
+
import * as THREE from "three/webgpu";
|
|
3
|
+
export default class StartAnimation extends Object3DBehaviour {
|
|
4
|
+
mixer?: THREE.AnimationMixer;
|
|
5
|
+
private _action?;
|
|
6
|
+
onEnable(): void;
|
|
7
|
+
onDisable(): void;
|
|
8
|
+
onBeforeRender(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Object3DBehaviour } from "three-start";
|
|
2
|
+
export default class FpsCameraController extends Object3DBehaviour {
|
|
3
|
+
sensitivity: number;
|
|
4
|
+
mobileSensitivity: number;
|
|
5
|
+
inverted: boolean;
|
|
6
|
+
useInvertedOnMobile: boolean;
|
|
7
|
+
private _detach?;
|
|
8
|
+
onEnable(): void;
|
|
9
|
+
onDisable(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Object3DBehaviour } from "three-start";
|
|
2
|
+
import * as THREE from "three/webgpu";
|
|
3
|
+
export default class PointerLockCameraControls extends Object3DBehaviour<{
|
|
4
|
+
lock: [];
|
|
5
|
+
unlock: [];
|
|
6
|
+
change: [];
|
|
7
|
+
}> {
|
|
8
|
+
isLocked: boolean;
|
|
9
|
+
minPolarAngle: number;
|
|
10
|
+
maxPolarAngle: number;
|
|
11
|
+
pointerSpeed: number;
|
|
12
|
+
mobilePointerSpeed: number;
|
|
13
|
+
domElement: HTMLElement | null;
|
|
14
|
+
_canBeLocked: boolean;
|
|
15
|
+
_isMobile: boolean;
|
|
16
|
+
private _detach?;
|
|
17
|
+
onEnable(): void;
|
|
18
|
+
onDisable(): void;
|
|
19
|
+
private _onPointerMove;
|
|
20
|
+
private _onPointerlockChange;
|
|
21
|
+
private connect;
|
|
22
|
+
private disconnect;
|
|
23
|
+
getDirection(v: THREE.Vector3): THREE.Vector3;
|
|
24
|
+
moveForward(distance: number): void;
|
|
25
|
+
moveRight(distance: number): void;
|
|
26
|
+
lock(unadjustedMovement?: boolean): void;
|
|
27
|
+
unlock(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Collider } from "./rapier-addon-core/Collider";
|
|
2
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
3
|
+
export default class BallCollider extends Collider {
|
|
4
|
+
readonly type = "Ball";
|
|
5
|
+
/**
|
|
6
|
+
* @default 0.5
|
|
7
|
+
*/
|
|
8
|
+
radius: number;
|
|
9
|
+
getDesc(rapier: typeof RAPIER): RAPIER.ColliderDesc;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Collider } from "./rapier-addon-core/Collider";
|
|
2
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
3
|
+
export default class CapsuleCollider extends Collider {
|
|
4
|
+
readonly type = "Capsule";
|
|
5
|
+
/**
|
|
6
|
+
* @default 0.5
|
|
7
|
+
*/
|
|
8
|
+
halfHeight: number;
|
|
9
|
+
/**
|
|
10
|
+
* @default 0.5
|
|
11
|
+
*/
|
|
12
|
+
radius: number;
|
|
13
|
+
getDesc(rapier: typeof RAPIER): RAPIER.ColliderDesc;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Collider } from "./rapier-addon-core/Collider";
|
|
2
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
3
|
+
export default class ConeCollider extends Collider {
|
|
4
|
+
readonly type = "Cone";
|
|
5
|
+
/**
|
|
6
|
+
* @default 0.5
|
|
7
|
+
*/
|
|
8
|
+
halfHeight: number;
|
|
9
|
+
/**
|
|
10
|
+
* @default 0.5
|
|
11
|
+
*/
|
|
12
|
+
radius: number;
|
|
13
|
+
getDesc(rapier: typeof RAPIER): RAPIER.ColliderDesc;
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Collider } from "./rapier-addon-core/Collider";
|
|
2
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
3
|
+
export default class ConvexMeshCollider extends Collider {
|
|
4
|
+
readonly type = "Convex";
|
|
5
|
+
getDesc(rapier: typeof RAPIER): RAPIER.ColliderDesc | null;
|
|
6
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Collider } from "./rapier-addon-core/Collider";
|
|
2
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
3
|
+
export default class CuboidCollider extends Collider {
|
|
4
|
+
readonly type = "Cuboid";
|
|
5
|
+
/**
|
|
6
|
+
* @default 0.5
|
|
7
|
+
*/
|
|
8
|
+
hx: number;
|
|
9
|
+
/**
|
|
10
|
+
* @default 0.5
|
|
11
|
+
*/
|
|
12
|
+
hy: number;
|
|
13
|
+
/**
|
|
14
|
+
* @default 0.5
|
|
15
|
+
*/
|
|
16
|
+
hz: number;
|
|
17
|
+
/**
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
useObjectScale: boolean;
|
|
21
|
+
getDesc(rapier: typeof RAPIER): RAPIER.ColliderDesc;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Collider } from "./rapier-addon-core/Collider";
|
|
2
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
3
|
+
export default class CylinderCollider extends Collider {
|
|
4
|
+
readonly type = "Cylinder";
|
|
5
|
+
/**
|
|
6
|
+
* @default 0.5
|
|
7
|
+
*/
|
|
8
|
+
halfHeight: number;
|
|
9
|
+
/**
|
|
10
|
+
* @default 0.5
|
|
11
|
+
*/
|
|
12
|
+
radius: number;
|
|
13
|
+
/**
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
useObjectScale: boolean;
|
|
17
|
+
getDesc(rapier: typeof RAPIER): RAPIER.ColliderDesc;
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Collider } from "./rapier-addon-core/Collider";
|
|
2
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
3
|
+
export default class HalfspaceCollider extends Collider {
|
|
4
|
+
readonly type = "Halfspace";
|
|
5
|
+
radius: number;
|
|
6
|
+
getDesc(rapier: typeof RAPIER): RAPIER.ColliderDesc | null;
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Object3DBehaviour } from "three-start";
|
|
2
|
+
import * as THREE from "three/webgpu";
|
|
3
|
+
import type { Collider, KinematicCharacterController, RayColliderHit, RigidBody } from "@dimforge/rapier3d-compat";
|
|
4
|
+
export default class RapierFpsPlayerController extends Object3DBehaviour {
|
|
5
|
+
halfHeight: number;
|
|
6
|
+
radius: number;
|
|
7
|
+
offset: number;
|
|
8
|
+
walkSpeed: number;
|
|
9
|
+
runSpeed: number;
|
|
10
|
+
useShiftRun: boolean;
|
|
11
|
+
maxSlopeClimbAngle: number;
|
|
12
|
+
minSlopeSlideAngle: number;
|
|
13
|
+
slideEnabled: boolean;
|
|
14
|
+
snapToGround: number;
|
|
15
|
+
applyImplusesToDynamicBodies: boolean;
|
|
16
|
+
enableAutostep: boolean;
|
|
17
|
+
autostepMaxHeight: number;
|
|
18
|
+
autostepMinWidth: number;
|
|
19
|
+
autostepIncludeDynamicBodies: boolean;
|
|
20
|
+
controlsEnabled: boolean;
|
|
21
|
+
rb: RigidBody;
|
|
22
|
+
col: Collider;
|
|
23
|
+
kcc: KinematicCharacterController;
|
|
24
|
+
_isVaryTimeStep: boolean;
|
|
25
|
+
private _detach?;
|
|
26
|
+
onEnable(): void;
|
|
27
|
+
onDisable(): void;
|
|
28
|
+
_inputDir: THREE.Vector3;
|
|
29
|
+
correctedMovement: THREE.Vector3;
|
|
30
|
+
getDt(): number;
|
|
31
|
+
update(): void;
|
|
32
|
+
_hitGround: RayColliderHit | null;
|
|
33
|
+
hitGround(): RayColliderHit | null;
|
|
34
|
+
teleport(position: THREE.Vector3): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Object3DBehaviour } from "three-start";
|
|
2
|
+
import * as THREE from "three/webgpu";
|
|
3
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
4
|
+
/**
|
|
5
|
+
* @see {@link https://github.com/vladkrutenyuk/three-kvy-core/blob/main/src/addons/Rigidbody.ts | Source}
|
|
6
|
+
*/
|
|
7
|
+
export default class Rigidbody extends Object3DBehaviour<{
|
|
8
|
+
ready: [rb: RAPIER.RigidBody];
|
|
9
|
+
}> {
|
|
10
|
+
readonly isRigidbody = true;
|
|
11
|
+
get instance(): RAPIER.RigidBody;
|
|
12
|
+
protected _instance?: RAPIER.RigidBody;
|
|
13
|
+
readonly rigidbodyType: RAPIER.RigidBodyType;
|
|
14
|
+
private _world?;
|
|
15
|
+
constructor();
|
|
16
|
+
onEnable(): void;
|
|
17
|
+
onDisable(): void;
|
|
18
|
+
onBeforeRender(): void;
|
|
19
|
+
syncBodyToObjectKinematically(): void;
|
|
20
|
+
withReady(cb: (rb: RAPIER.RigidBody) => void): void;
|
|
21
|
+
getObjWorldPos(): THREE.Vector3;
|
|
22
|
+
getObjWorldQuat(): THREE.Quaternion;
|
|
23
|
+
syncObjectToBody(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Object3DBehaviour } from "three-start";
|
|
2
|
+
import type * as THREE from "three/webgpu";
|
|
3
|
+
export default class TrimeshCollider extends Object3DBehaviour {
|
|
4
|
+
recursive: boolean;
|
|
5
|
+
private _detach?;
|
|
6
|
+
onEnable(): void;
|
|
7
|
+
onDisable(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function createTrimeshColliderArgsFromMesh(mesh: THREE.Mesh): readonly [Float32Array<ArrayBuffer>, Uint32Array<ArrayBuffer>];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ThreeStart } from "three-start";
|
|
2
|
+
/** rapier loads lazily: the wasm is pulled only in worlds with physics. */
|
|
3
|
+
export declare const lazyRapier: {
|
|
4
|
+
get: () => Promise<typeof import("@dimforge/rapier3d-compat")>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Registers rapier modules before bootstrap: three-start forbids `addModules`
|
|
8
|
+
* after `start()`. Idempotent — a repeated call sees the module in ctx and exits.
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyRapierPhysicsPatch(starter: ThreeStart): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Object3DBehaviour } from "three-start";
|
|
2
|
+
import * as THREE from "three/webgpu";
|
|
3
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
4
|
+
export type ColliderType = keyof typeof RAPIER.ColliderDesc;
|
|
5
|
+
export declare abstract class Collider extends Object3DBehaviour {
|
|
6
|
+
get instance(): RAPIER.Collider;
|
|
7
|
+
private _instance?;
|
|
8
|
+
private _world?;
|
|
9
|
+
protected _vt: THREE.Vector3;
|
|
10
|
+
abstract readonly type: string;
|
|
11
|
+
abstract getDesc(rapier: typeof RAPIER): RAPIER.ColliderDesc | null;
|
|
12
|
+
onEnable(): void;
|
|
13
|
+
onDisable(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ContextModule } from "three-start";
|
|
2
|
+
import type { RapierDebugModuleApi } from "../../../modules/contracts/rapierDebug.module-api";
|
|
3
|
+
/**
|
|
4
|
+
* @see {@link https://github.com/vladkrutenyuk/three-kvy-core/blob/main/src/addons/RapierDebugRenderer.ts | Source}
|
|
5
|
+
*/
|
|
6
|
+
export declare class RapierDebugRenderer extends ContextModule implements RapierDebugModuleApi {
|
|
7
|
+
private _lines?;
|
|
8
|
+
get enabled(): boolean;
|
|
9
|
+
set enabled(value: boolean);
|
|
10
|
+
private _enabled;
|
|
11
|
+
private _clear?;
|
|
12
|
+
private _inited;
|
|
13
|
+
/** three-start ContextModule has no onDestroy; teardown is explicit. */
|
|
14
|
+
dispose(): void;
|
|
15
|
+
init(): void;
|
|
16
|
+
}
|
|
17
|
+
export default RapierDebugRenderer;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { ContextModule } from "three-start";
|
|
2
|
+
import type { ThreeContext } from "three-start";
|
|
3
|
+
import type * as THREE from "three/webgpu";
|
|
4
|
+
import type * as RAPIER from "@dimforge/rapier3d-compat";
|
|
5
|
+
import type { RapierModuleApi } from "../../../modules/contracts/rapier.module-api";
|
|
6
|
+
export type ModulesWithRapierPhysics = {
|
|
7
|
+
rapier: RapierPhysics;
|
|
8
|
+
};
|
|
9
|
+
export type RapierJsModule = typeof RAPIER;
|
|
10
|
+
export declare class RapierPhysics extends ContextModule<{
|
|
11
|
+
stepbefore: [];
|
|
12
|
+
stepafter: [];
|
|
13
|
+
}> implements RapierModuleApi {
|
|
14
|
+
readonly isRapierPhysics: true;
|
|
15
|
+
readonly api: RapierJsModule;
|
|
16
|
+
readonly world: RAPIER.World;
|
|
17
|
+
readonly eventQueue: RAPIER.EventQueue;
|
|
18
|
+
/** @default "vary" */
|
|
19
|
+
timeStep: RapierPhysicsOptions["timeStep"];
|
|
20
|
+
private _steppingState;
|
|
21
|
+
constructor(Rapier: RapierJsModule, options?: Partial<RapierPhysicsOptions>);
|
|
22
|
+
onStart(): void;
|
|
23
|
+
/** three-start ContextModule has no onDestroy; teardown is explicit. */
|
|
24
|
+
dispose(): void;
|
|
25
|
+
private update;
|
|
26
|
+
private stepWorld;
|
|
27
|
+
static findInCtx(ctx: ThreeContext): RapierPhysics | undefined;
|
|
28
|
+
}
|
|
29
|
+
export default RapierPhysics;
|
|
30
|
+
export interface RapierPhysicsOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Set the gravity of the physics world
|
|
33
|
+
* @defaultValue [0, -9.81, 0]
|
|
34
|
+
*/
|
|
35
|
+
gravity: THREE.Vector3Tuple;
|
|
36
|
+
/**
|
|
37
|
+
* Amount of penetration the engine wont attempt to correct
|
|
38
|
+
* @defaultValue 0.001
|
|
39
|
+
*/
|
|
40
|
+
allowedLinearError: number;
|
|
41
|
+
/**
|
|
42
|
+
* The number of solver iterations run by the constraints solver for calculating forces.
|
|
43
|
+
* The greater this value is, the most rigid and realistic the physics simulation will be.
|
|
44
|
+
* However a greater number of iterations is more computationally intensive.
|
|
45
|
+
*
|
|
46
|
+
* @defaultValue 4
|
|
47
|
+
*/
|
|
48
|
+
numSolverIterations: number;
|
|
49
|
+
/**
|
|
50
|
+
* Number of addition friction resolution iteration run during the last solver sub-step.
|
|
51
|
+
* The greater this value is, the most realistic friction will be.
|
|
52
|
+
* However a greater number of iterations is more computationally intensive.
|
|
53
|
+
*
|
|
54
|
+
* @defaultValue 4
|
|
55
|
+
*/
|
|
56
|
+
numAdditionalFrictionIterations: number;
|
|
57
|
+
/**
|
|
58
|
+
* Number of internal Project Gauss Seidel (PGS) iterations run at each solver iteration.
|
|
59
|
+
* Increasing this parameter will improve stability of the simulation. It will have a lesser effect than
|
|
60
|
+
* increasing `numSolverIterations` but is also less computationally expensive.
|
|
61
|
+
*
|
|
62
|
+
* @defaultValue 1
|
|
63
|
+
*/
|
|
64
|
+
numInternalPgsIterations: number;
|
|
65
|
+
/**
|
|
66
|
+
* The maximal distance separating two objects that will generate predictive contacts
|
|
67
|
+
*
|
|
68
|
+
* @defaultValue 0.002
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
predictionDistance: number;
|
|
72
|
+
/**
|
|
73
|
+
* Minimum number of dynamic bodies in each active island
|
|
74
|
+
*
|
|
75
|
+
* @defaultValue 128
|
|
76
|
+
*/
|
|
77
|
+
minIslandSize: number;
|
|
78
|
+
/**
|
|
79
|
+
* Maximum number of substeps performed by the solver
|
|
80
|
+
*
|
|
81
|
+
* @defaultValue 1
|
|
82
|
+
*/
|
|
83
|
+
maxCcdSubsteps: number;
|
|
84
|
+
/**
|
|
85
|
+
* Directly affects the `erp` (Error Reduction Parameter) which is the proportion (0 to 1) of the positional error to be corrected at each time step.
|
|
86
|
+
* The higher this value is, the more the physics engine will try to correct errors.
|
|
87
|
+
*
|
|
88
|
+
* This prop is currently undocumented in the Rapier documentation.
|
|
89
|
+
*
|
|
90
|
+
* @see https://github.com/dimforge/rapier/pull/651 where this change was made to Rapier
|
|
91
|
+
* @defaultValue 30
|
|
92
|
+
*/
|
|
93
|
+
contactNaturalFrequency: number;
|
|
94
|
+
/**
|
|
95
|
+
* The approximate size of most dynamic objects in the scene.
|
|
96
|
+
*
|
|
97
|
+
* This value is used internally to estimate some length-based tolerance.
|
|
98
|
+
* This value can be understood as the number of units-per-meter in your physical world compared to a human-sized world in meter.
|
|
99
|
+
*
|
|
100
|
+
* @defaultValue 1
|
|
101
|
+
*/
|
|
102
|
+
lengthUnit: number;
|
|
103
|
+
/**
|
|
104
|
+
* Set the timestep for the simulation.
|
|
105
|
+
* Setting this to a number (eg. 1/60) will run the
|
|
106
|
+
* simulation at that framerate. Alternatively, you can set this to
|
|
107
|
+
* "vary", which will cause the simulation to always synchronize with
|
|
108
|
+
* the current frame delta times.
|
|
109
|
+
*
|
|
110
|
+
* @defaultValue 1/60
|
|
111
|
+
*/
|
|
112
|
+
timeStep: number | "vary";
|
|
113
|
+
/**
|
|
114
|
+
* Pause the physics simulation
|
|
115
|
+
*
|
|
116
|
+
* @defaultValue false
|
|
117
|
+
*/
|
|
118
|
+
paused: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Interpolate the world transform using the frame delta times.
|
|
121
|
+
* Has no effect if timeStep is set to "vary".
|
|
122
|
+
*
|
|
123
|
+
* @defaultValue true
|
|
124
|
+
**/
|
|
125
|
+
interpolate: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Enable debug rendering of the physics world.
|
|
128
|
+
* @defaultValue false
|
|
129
|
+
*/
|
|
130
|
+
debug: boolean;
|
|
131
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Object3DBehaviour } from "three-start";
|
|
2
|
+
import * as THREE from "three/webgpu";
|
|
3
|
+
export default class SightInteractableArea extends Object3DBehaviour<{
|
|
4
|
+
activechanged: [active: boolean];
|
|
5
|
+
interaction: [];
|
|
6
|
+
}> {
|
|
7
|
+
private static _CURRENT;
|
|
8
|
+
readonly isSightInteractableArea = true;
|
|
9
|
+
radius: number;
|
|
10
|
+
hint: string;
|
|
11
|
+
interactEnabled: boolean;
|
|
12
|
+
isStatic: boolean;
|
|
13
|
+
_sqRadius: number;
|
|
14
|
+
_active: boolean;
|
|
15
|
+
_initWorldPos: THREE.Vector3;
|
|
16
|
+
onEnable(): void;
|
|
17
|
+
onDisable(): void;
|
|
18
|
+
setRadius(r: number): void;
|
|
19
|
+
onBeforeRender(): void;
|
|
20
|
+
private _activate;
|
|
21
|
+
private _deactivate;
|
|
22
|
+
private _interact;
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Object3DBehaviourConstructor, ThreeStart } from "three-start";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in behaviour: uuid is its identity in user worlds — it must never
|
|
4
|
+
* change. The class loads lazily, so a world without physics doesn't pull rapier.
|
|
5
|
+
*/
|
|
6
|
+
export interface BuiltinBehaviour {
|
|
7
|
+
uuid: string;
|
|
8
|
+
name: string;
|
|
9
|
+
load: () => Promise<Object3DBehaviourConstructor>;
|
|
10
|
+
/** Registers ctx modules the behaviour needs. Strictly before `start()`. */
|
|
11
|
+
requiredPatch?: (starter: ThreeStart) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** Registry of built-in behaviours by uuid — source of truth for both game and export. */
|
|
14
|
+
export declare const BUILTIN_BEHAVIOURS: Record<string, BuiltinBehaviour | undefined>;
|
|
15
|
+
export declare const BUILTIN_BEHAVIOUR_LIST: readonly BuiltinBehaviour[];
|
|
16
|
+
export declare function getBuiltinBehaviour(uuid: string): BuiltinBehaviour | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Object3DBehaviour } from "three-start";
|
|
2
|
+
import * as THREE from "three/webgpu";
|
|
3
|
+
export default class MeshInstansing extends Object3DBehaviour {
|
|
4
|
+
private static _totalInstance;
|
|
5
|
+
geometry: THREE.BufferGeometry | null;
|
|
6
|
+
material: THREE.Material | null;
|
|
7
|
+
transformsRoot: THREE.Object3D | null;
|
|
8
|
+
useThisAsRoot: boolean;
|
|
9
|
+
private _detach?;
|
|
10
|
+
onEnable(): void;
|
|
11
|
+
onDisable(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { World } from "./World";
|
|
2
|
+
import type { LoadWorldOptions, WorldDefinition } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* World assembly order. The only place where it is fixed: the artifact supplies
|
|
5
|
+
* the data and steps, the runtime owns the sequence. Mirrors the game's
|
|
6
|
+
* classic-load (`/docs/scripting/game-runtime.md`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function bootstrapWorld<TAssets>(definition: WorldDefinition<TAssets>, options: LoadWorldOptions): Promise<World>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { World } from "./World";
|
|
2
|
+
import type { LoadWorldOptions, WorldDefinition } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Entry point of the generated artifact: world definition → public `loadWorld`.
|
|
5
|
+
* The codegen prints `export const { loadWorld } = defineWorld({ ... })`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function defineWorld<TAssets>(definition: WorldDefinition<TAssets>): {
|
|
8
|
+
loadWorld: (options?: LoadWorldOptions) => Promise<World>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as THREE from "three/webgpu";
|
|
2
|
+
//#region packages/world-runtime/src/behaviours/physics/rapier-addon-core/get-scale-from-obj.ts
|
|
3
|
+
var _hrScale = {
|
|
4
|
+
radius: 1,
|
|
5
|
+
halfHeight: 1
|
|
6
|
+
};
|
|
7
|
+
var _v = new THREE.Vector3();
|
|
8
|
+
var getHalfheightRadiusScale = (object) => {
|
|
9
|
+
const scale = object.getWorldScale(_v);
|
|
10
|
+
_hrScale.radius = Math.max(scale.x, scale.z);
|
|
11
|
+
_hrScale.halfHeight = scale.y;
|
|
12
|
+
return _hrScale;
|
|
13
|
+
};
|
|
14
|
+
var getRadiusScale = (object) => {
|
|
15
|
+
const scale = object.getWorldScale(_v);
|
|
16
|
+
scale.x = Math.max(scale.x, scale.y);
|
|
17
|
+
scale.x = Math.max(scale.x, scale.z);
|
|
18
|
+
_hrScale.radius = scale.x;
|
|
19
|
+
return _hrScale;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getRadiusScale as n, getHalfheightRadiusScale as t };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export { defineWorld } from "./define-world";
|
|
2
|
+
export { World } from "./World";
|
|
3
|
+
export type { InstantiateOptions, PrefabFactory } from "./WorldRuntime";
|
|
4
|
+
export { setColor } from "./values";
|
|
5
|
+
export { RUNTIME_VERSION, WORLD_FORMAT_VERSION } from "./version";
|
|
6
|
+
export { WorldEvent } from "./world-events";
|
|
7
|
+
export { createWorldModules, EnvModule, HtmlHudModule, InputSystemModule, isMobileDevice, SoundsModule, UtilsModule, } from "./modules";
|
|
8
|
+
export type { EnvMode, WorldModules } from "./modules";
|
|
9
|
+
export { DEFAULT_RESOURCE_IDS, DefaultResourceId, getDefaultResource, isDefaultResourceId, } from "./resources/default-resources";
|
|
10
|
+
export type { DefaultResourceIdValue, DefaultResourceTypes, } from "./resources/default-resources";
|
|
11
|
+
export { AssetLoaders, configureAssetLoaders, LOADING_MANAGER } from "./resources/loaders";
|
|
12
|
+
export { applyTextureDefaults, loadTexture } from "./resources/texture";
|
|
13
|
+
export { collectModelSubResources, loadModel, parseModel } from "./resources/model";
|
|
14
|
+
export type { ModelFormat, ModelSubResources } from "./resources/model";
|
|
15
|
+
export { loadHdr, parseHdr } from "./resources/hdr";
|
|
16
|
+
export type { HdrFormat } from "./resources/hdr";
|
|
17
|
+
export { loadGeometry, parseGeometryJson } from "./resources/geometry";
|
|
18
|
+
export { AudioSource, createAudio } from "./resources/audio";
|
|
19
|
+
export { createVideo, VideoSource } from "./resources/video";
|
|
20
|
+
export { createFont, FontSource, fontFormatFromMime } from "./resources/font";
|
|
21
|
+
export { BUILTIN_BEHAVIOUR_LIST, BUILTIN_BEHAVIOURS, getBuiltinBehaviour, } from "./behaviours/registry";
|
|
22
|
+
export type { BuiltinBehaviour } from "./behaviours/registry";
|
|
23
|
+
export { applyRapierPhysicsPatch, lazyRapier, } from "./behaviours/physics/_required-patch";
|
|
24
|
+
export { AddonsRuntime } from "./settings/AddonsRuntime";
|
|
25
|
+
export { applyRendererConfig } from "./rendering/renderer-apply";
|
|
26
|
+
export { enableSceneEmissiveMrt, SceneBloom } from "./rendering/SceneBloom";
|
|
27
|
+
export { createTslNode, TslNode } from "./rendering/tsl-node";
|
|
28
|
+
export type { TslNodeBuilder } from "./rendering/tsl-node";
|
|
29
|
+
export { createUniformNode, isUniformType, UNIFORM_DEFAULTS, UNIFORM_TYPES, uniformType, } from "./rendering/tsl-uniforms";
|
|
30
|
+
export type { UniformType } from "./rendering/tsl-uniforms";
|
|
31
|
+
export { LIB_DESCRIPTORS, LIB_IDS, LIBS, LibId, libByRequireKey } from "./settings/lib-registry";
|
|
32
|
+
export type { LibDescriptor } from "./settings/lib-registry";
|
|
33
|
+
export { MODULE_IDS, ModuleId, normalizePhysics, PHYSICS_ENGINES } from "./settings/module-registry";
|
|
34
|
+
export { EXTERNAL_TYPES } from "./settings/externals";
|
|
35
|
+
export { BLOOM_MODES, SHADOW_MAP_TYPES, TONE_MAPPING_NAMES, } from "./rendering/renderer-options";
|
|
36
|
+
export type { BloomModeName, ShadowMapTypeName, ToneMappingName, } from "./rendering/renderer-options";
|
|
37
|
+
export type { ExternalDescriptor, ExternalType } from "./settings/externals";
|
|
38
|
+
export type { PhysicsConfig, PhysicsEngine } from "./settings/module-registry";
|
|
39
|
+
export type { AddonsConfig, BloomConfig, RendererConfig, RendererParams, } from "./settings/types";
|
|
40
|
+
export { getHalfheightRadiusScale, getRadiusScale } from "./behaviours/physics/rapier-addon-core/get-scale-from-obj";
|
|
41
|
+
export type { EnvModuleApi } from "./modules/contracts/env.module-api";
|
|
42
|
+
export type { HtmlModuleApi } from "./modules/contracts/html.module-api";
|
|
43
|
+
export type { InputModuleApi, PlayerInputApi } from "./modules/contracts/input.module-api";
|
|
44
|
+
export type { RapierJsModule, RapierModuleApi } from "./modules/contracts/rapier.module-api";
|
|
45
|
+
export type { RapierDebugModuleApi } from "./modules/contracts/rapierDebug.module-api";
|
|
46
|
+
export type { SoundsModuleApi } from "./modules/contracts/sounds.module-api";
|
|
47
|
+
export type { UtilsModuleApi } from "./modules/contracts/utils.module-api";
|
|
48
|
+
export type { AssetUrlTable, LoadWorldOptions, RuntimeApi, SceneBuildResult, ScriptModule, ScriptTable, WorldDefinition, WorldLoadProgress, } from "./types";
|