lecodes-sdk 0.19.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/README.md +114 -0
- package/dist/global.d.ts +503 -0
- package/dist/host.d.ts +61 -0
- package/dist/inject.js +4730 -0
- package/dist/types/animate/animate.d.ts +20 -0
- package/dist/types/animate/bezier.d.ts +2 -0
- package/dist/types/animate/easings.d.ts +21 -0
- package/dist/types/canvas/Canvas.d.ts +168 -0
- package/dist/types/core/Aspect.d.ts +171 -0
- package/dist/types/core/InspectorUI.d.ts +88 -0
- package/dist/types/core/StateMachine.d.ts +81 -0
- package/dist/types/core/color.d.ts +13 -0
- package/dist/types/core/compWrite.d.ts +11 -0
- package/dist/types/core/events.d.ts +11 -0
- package/dist/types/core/fields.d.ts +58 -0
- package/dist/types/core/registry.d.ts +7 -0
- package/dist/types/core/signals.d.ts +29 -0
- package/dist/types/core/time.d.ts +31 -0
- package/dist/types/g2/Camera2D.d.ts +19 -0
- package/dist/types/g2/CharacterController2D.d.ts +134 -0
- package/dist/types/g2/Node2D.d.ts +91 -0
- package/dist/types/g2/OneWay2D.d.ts +24 -0
- package/dist/types/g2/Physics2D.d.ts +147 -0
- package/dist/types/g2/Scene2D.d.ts +72 -0
- package/dist/types/g2/Shape2D.d.ts +58 -0
- package/dist/types/g2/Sprite.d.ts +51 -0
- package/dist/types/g2/SpriteAnimation.d.ts +50 -0
- package/dist/types/g2/SpriteSheet.d.ts +69 -0
- package/dist/types/g2/Texture2D.d.ts +16 -0
- package/dist/types/g2/Tilemap.d.ts +20 -0
- package/dist/types/g2/Tileset.d.ts +32 -0
- package/dist/types/g2/Trigger2D.d.ts +20 -0
- package/dist/types/g2/autotile.d.ts +133 -0
- package/dist/types/g2/cells.d.ts +14 -0
- package/dist/types/g2/defineScene2d.d.ts +141 -0
- package/dist/types/g2/groups2d.d.ts +16 -0
- package/dist/types/g2/loop.d.ts +4 -0
- package/dist/types/g2/scenarios2d.d.ts +30 -0
- package/dist/types/g2/touch.d.ts +2 -0
- package/dist/types/gl/Camera.d.ts +79 -0
- package/dist/types/gl/CameraPlace.d.ts +26 -0
- package/dist/types/gl/CharacterController.d.ts +98 -0
- package/dist/types/gl/Gearbox.d.ts +86 -0
- package/dist/types/gl/Geometry.d.ts +39 -0
- package/dist/types/gl/IK.d.ts +53 -0
- package/dist/types/gl/InstancedMesh.d.ts +46 -0
- package/dist/types/gl/Light.d.ts +73 -0
- package/dist/types/gl/Lightmap.d.ts +85 -0
- package/dist/types/gl/Locomotion.d.ts +279 -0
- package/dist/types/gl/Material.d.ts +100 -0
- package/dist/types/gl/Mesh.d.ts +33 -0
- package/dist/types/gl/Model.d.ts +53 -0
- package/dist/types/gl/NavAgent.d.ts +99 -0
- package/dist/types/gl/NavMesh.d.ts +169 -0
- package/dist/types/gl/Node.d.ts +99 -0
- package/dist/types/gl/Noise.d.ts +20 -0
- package/dist/types/gl/Particles.d.ts +277 -0
- package/dist/types/gl/Physics.d.ts +91 -0
- package/dist/types/gl/Plane.d.ts +19 -0
- package/dist/types/gl/Ragdoll.d.ts +86 -0
- package/dist/types/gl/Ray.d.ts +8 -0
- package/dist/types/gl/Scene.d.ts +221 -0
- package/dist/types/gl/Shape.d.ts +122 -0
- package/dist/types/gl/Terrain.d.ts +280 -0
- package/dist/types/gl/Texture.d.ts +27 -0
- package/dist/types/gl/Trigger.d.ts +10 -0
- package/dist/types/gl/Vehicle.d.ts +191 -0
- package/dist/types/gl/Wheel.d.ts +95 -0
- package/dist/types/gl/animation/AnimationClip.d.ts +60 -0
- package/dist/types/gl/animation/Animator.d.ts +219 -0
- package/dist/types/gl/animation/Layer.d.ts +31 -0
- package/dist/types/gl/animation/Loop.d.ts +17 -0
- package/dist/types/gl/animation/Playback.d.ts +36 -0
- package/dist/types/gl/animation/core.d.ts +367 -0
- package/dist/types/gl/controls.d.ts +19 -0
- package/dist/types/gl/physicsEvents.d.ts +1 -0
- package/dist/types/gl/scenarios.d.ts +98 -0
- package/dist/types/gl/state.d.ts +5 -0
- package/dist/types/gl/terrainMesh.d.ts +46 -0
- package/dist/types/gl/touch.d.ts +2 -0
- package/dist/types/inject.d.ts +123 -0
- package/dist/types/math/Mathf.d.ts +39 -0
- package/dist/types/math/mat4.d.ts +66 -0
- package/dist/types/math/quat.d.ts +53 -0
- package/dist/types/math/vec.d.ts +129 -0
- package/dist/types/net/codec.d.ts +25 -0
- package/dist/types/net/core.d.ts +106 -0
- package/dist/types/net/index.d.ts +80 -0
- package/dist/types/net/replication.d.ts +101 -0
- package/dist/types/plugins/camera.d.ts +25 -0
- package/dist/types/plugins/geolocation.d.ts +39 -0
- package/dist/types/plugins/oauth.d.ts +25 -0
- package/dist/types/plugins/permission.d.ts +1 -0
- package/dist/types/plugins/push.d.ts +46 -0
- package/dist/types/plugins/qr.d.ts +21 -0
- package/dist/types/plugins/service.d.ts +33 -0
- package/dist/types/runtime/app.d.ts +67 -0
- package/dist/types/runtime/appEvents.d.ts +7 -0
- package/dist/types/runtime/channel.d.ts +1 -0
- package/dist/types/runtime/clipboard.d.ts +7 -0
- package/dist/types/runtime/datetime.d.ts +80 -0
- package/dist/types/runtime/device.d.ts +126 -0
- package/dist/types/runtime/fetch.d.ts +31 -0
- package/dist/types/runtime/files.d.ts +33 -0
- package/dist/types/runtime/input.d.ts +121 -0
- package/dist/types/runtime/media.d.ts +46 -0
- package/dist/types/runtime/misc.d.ts +11 -0
- package/dist/types/runtime/net.d.ts +15 -0
- package/dist/types/runtime/rpc.d.ts +44 -0
- package/dist/types/runtime/service.d.ts +1 -0
- package/dist/types/runtime/share.d.ts +2 -0
- package/dist/types/runtime/storage.d.ts +5 -0
- package/dist/types/runtime/touch.d.ts +56 -0
- package/dist/types/scene/defineScene.d.ts +296 -0
- package/dist/types/scene/editorPlugins.d.ts +82 -0
- package/dist/types/scene/gizmos.d.ts +56 -0
- package/dist/types/scene/grammar.d.ts +56 -0
- package/dist/types/scene/level.d.ts +98 -0
- package/dist/types/scene/material.d.ts +76 -0
- package/dist/types/server/auth/appConfig.d.ts +16 -0
- package/dist/types/server/auth/global.d.ts +56 -0
- package/dist/types/server/auth/models.d.ts +164 -0
- package/dist/types/server/auth/types.d.ts +56 -0
- package/dist/types/server/channel.d.ts +28 -0
- package/dist/types/server/context.d.ts +27 -0
- package/dist/types/server/db/defineDb.d.ts +36 -0
- package/dist/types/server/db/fields.d.ts +146 -0
- package/dist/types/server/db/index.d.ts +6 -0
- package/dist/types/server/db/marci/query.d.ts +326 -0
- package/dist/types/server/db/types.d.ts +163 -0
- package/dist/types/server/errors.d.ts +8 -0
- package/dist/types/server/inject.d.ts +5 -0
- package/dist/types/ui/NativeView.d.ts +38 -0
- package/dist/types/ui/UI.d.ts +27 -0
- package/dist/types/ui/UIBottomSheet.d.ts +71 -0
- package/dist/types/ui/UIButton.d.ts +30 -0
- package/dist/types/ui/UIContainer.d.ts +33 -0
- package/dist/types/ui/UIImage.d.ts +35 -0
- package/dist/types/ui/UIInput.d.ts +110 -0
- package/dist/types/ui/UIModal.d.ts +70 -0
- package/dist/types/ui/UINode.d.ts +363 -0
- package/dist/types/ui/UIPager.d.ts +123 -0
- package/dist/types/ui/UIPopover.d.ts +39 -0
- package/dist/types/ui/UIScreen.d.ts +57 -0
- package/dist/types/ui/UIScrollable.d.ts +40 -0
- package/dist/types/ui/UISpacer.d.ts +9 -0
- package/dist/types/ui/UITabs.d.ts +96 -0
- package/dist/types/ui/UIText.d.ts +19 -0
- package/dist/types/ui/UIVideo.d.ts +28 -0
- package/dist/types/ui/UIVirtualizedList.d.ts +97 -0
- package/dist/types/ui/UIWidget.d.ts +65 -0
- package/dist/types/ui/fonts.d.ts +9 -0
- package/dist/types/ui/presentable.d.ts +68 -0
- package/dist/types/ui/router.d.ts +40 -0
- package/dist/types/ui/theme.d.ts +26 -0
- package/dist/types.json +1 -0
- package/package.json +46 -0
- package/prompts/2d.md +395 -0
- package/prompts/3d-scene-files.md +113 -0
- package/prompts/3d-scene.md +119 -0
- package/prompts/3d.md +303 -0
- package/prompts/README.md +142 -0
- package/prompts/ar.md +109 -0
- package/prompts/canvas.md +27 -0
- package/prompts/compose.ts +46 -0
- package/prompts/concept.md +49 -0
- package/prompts/core-design.md +75 -0
- package/prompts/core.md +264 -0
- package/prompts/design.md +218 -0
- package/prompts/dist/2d-game.md +1530 -0
- package/prompts/dist/3d-app.md +1672 -0
- package/prompts/dist/ar-app.md +1548 -0
- package/prompts/dist/concept.md +49 -0
- package/prompts/dist/design.md +498 -0
- package/prompts/dist/ui-app.md +1134 -0
- package/prompts/index.md +37 -0
- package/prompts/intake-prompt.md +33 -0
- package/prompts/namer-prompt.md +12 -0
- package/prompts/router-prompt.md +50 -0
- package/prompts/select.ts +111 -0
- package/prompts/ui-design.md +203 -0
- package/prompts/ui.md +803 -0
- package/src/animate/animate.ts +238 -0
- package/src/animate/bezier.ts +138 -0
- package/src/animate/easings.ts +126 -0
- package/src/bridges.d.ts +1345 -0
- package/src/canvas/Canvas.ts +305 -0
- package/src/compile/__tests__/assetIconMacro.test.ts +219 -0
- package/src/compile/__tests__/assetMacro.test.ts +74 -0
- package/src/compile/__tests__/assetName.test.ts +55 -0
- package/src/compile/__tests__/compile.test.ts +287 -0
- package/src/compile/__tests__/detectEntry.test.ts +132 -0
- package/src/compile/__tests__/fontMacro.test.ts +199 -0
- package/src/compile/aspectMacro.ts +86 -0
- package/src/compile/assetIconMacro.ts +384 -0
- package/src/compile/assetMacro.ts +146 -0
- package/src/compile/assetName.ts +50 -0
- package/src/compile/bundler.ts +287 -0
- package/src/compile/compileProject.ts +127 -0
- package/src/compile/detectEntry.ts +128 -0
- package/src/compile/fontMacro.ts +459 -0
- package/src/compile/fontRegistry.ts +78 -0
- package/src/compile/header.ts +67 -0
- package/src/compile/index.ts +100 -0
- package/src/compile/libraryImports.ts +52 -0
- package/src/compile/liteMaterial.ts +247 -0
- package/src/compile/sceneEditor.ts +88 -0
- package/src/compile/serverSplit.ts +233 -0
- package/src/compile/serverTypes.ts +227 -0
- package/src/compile/sfnt.ts +98 -0
- package/src/compile/shaderSchema.ts +202 -0
- package/src/compile/shaderTargets.ts +77 -0
- package/src/compile/sourcemap.ts +25 -0
- package/src/core/Aspect.ts +568 -0
- package/src/core/InspectorUI.ts +212 -0
- package/src/core/StateMachine.ts +308 -0
- package/src/core/__tests__/stateMachine.test.ts +132 -0
- package/src/core/color.ts +66 -0
- package/src/core/compWrite.ts +42 -0
- package/src/core/events.ts +38 -0
- package/src/core/fields.ts +120 -0
- package/src/core/registry.ts +23 -0
- package/src/core/signals.ts +277 -0
- package/src/core/time.ts +84 -0
- package/src/g2/Camera2D.ts +40 -0
- package/src/g2/CharacterController2D.ts +276 -0
- package/src/g2/Node2D.ts +267 -0
- package/src/g2/OneWay2D.ts +66 -0
- package/src/g2/Physics2D.ts +346 -0
- package/src/g2/Scene2D.ts +209 -0
- package/src/g2/Shape2D.ts +259 -0
- package/src/g2/Sprite.ts +89 -0
- package/src/g2/SpriteAnimation.ts +171 -0
- package/src/g2/SpriteSheet.ts +166 -0
- package/src/g2/Texture2D.ts +47 -0
- package/src/g2/Tilemap.ts +41 -0
- package/src/g2/Tileset.ts +71 -0
- package/src/g2/Trigger2D.ts +77 -0
- package/src/g2/autotile.ts +433 -0
- package/src/g2/cells.ts +91 -0
- package/src/g2/defineScene2d.ts +381 -0
- package/src/g2/groups2d.ts +106 -0
- package/src/g2/loop.ts +50 -0
- package/src/g2/scenarios2d.ts +69 -0
- package/src/g2/touch.ts +83 -0
- package/src/gl/Camera.ts +160 -0
- package/src/gl/CameraPlace.ts +52 -0
- package/src/gl/CharacterController.ts +238 -0
- package/src/gl/Gearbox.ts +212 -0
- package/src/gl/Geometry.ts +279 -0
- package/src/gl/IK.ts +193 -0
- package/src/gl/InstancedMesh.ts +132 -0
- package/src/gl/Light.ts +135 -0
- package/src/gl/Lightmap.ts +402 -0
- package/src/gl/Locomotion.ts +498 -0
- package/src/gl/Material.ts +279 -0
- package/src/gl/Mesh.ts +83 -0
- package/src/gl/Model.ts +124 -0
- package/src/gl/NavAgent.ts +337 -0
- package/src/gl/NavMesh.ts +397 -0
- package/src/gl/Node.ts +350 -0
- package/src/gl/Noise.ts +30 -0
- package/src/gl/Particles.ts +676 -0
- package/src/gl/Physics.ts +222 -0
- package/src/gl/Plane.ts +53 -0
- package/src/gl/Ragdoll.ts +270 -0
- package/src/gl/Ray.ts +16 -0
- package/src/gl/Scene.ts +505 -0
- package/src/gl/Shape.ts +409 -0
- package/src/gl/Terrain.ts +1092 -0
- package/src/gl/Texture.ts +63 -0
- package/src/gl/Trigger.ts +45 -0
- package/src/gl/Vehicle.ts +473 -0
- package/src/gl/Wheel.ts +240 -0
- package/src/gl/animation/AnimationClip.ts +204 -0
- package/src/gl/animation/Animator.ts +329 -0
- package/src/gl/animation/Layer.ts +39 -0
- package/src/gl/animation/Loop.ts +31 -0
- package/src/gl/animation/Playback.ts +52 -0
- package/src/gl/animation/core.ts +670 -0
- package/src/gl/controls.ts +95 -0
- package/src/gl/physicsEvents.ts +20 -0
- package/src/gl/scenarios.ts +291 -0
- package/src/gl/state.ts +6 -0
- package/src/gl/terrainMesh.ts +219 -0
- package/src/gl/touch.ts +68 -0
- package/src/host.d.ts +61 -0
- package/src/inject.ts +203 -0
- package/src/math/Mathf.ts +118 -0
- package/src/math/mat4.ts +278 -0
- package/src/math/quat.ts +232 -0
- package/src/math/vec.ts +255 -0
- package/src/net/codec.ts +119 -0
- package/src/net/core.ts +384 -0
- package/src/net/index.ts +181 -0
- package/src/net/replication.ts +622 -0
- package/src/plugins/camera.ts +81 -0
- package/src/plugins/geolocation.ts +123 -0
- package/src/plugins/oauth.ts +61 -0
- package/src/plugins/permission.ts +7 -0
- package/src/plugins/push.ts +132 -0
- package/src/plugins/qr.ts +73 -0
- package/src/plugins/service.ts +47 -0
- package/src/runtime/app.ts +101 -0
- package/src/runtime/appEvents.ts +54 -0
- package/src/runtime/channel.ts +61 -0
- package/src/runtime/clipboard.ts +20 -0
- package/src/runtime/datetime.ts +329 -0
- package/src/runtime/device.ts +293 -0
- package/src/runtime/fetch.ts +77 -0
- package/src/runtime/files.ts +108 -0
- package/src/runtime/input.ts +175 -0
- package/src/runtime/media.ts +111 -0
- package/src/runtime/misc.ts +16 -0
- package/src/runtime/net.ts +36 -0
- package/src/runtime/rpc.ts +218 -0
- package/src/runtime/service.ts +83 -0
- package/src/runtime/share.ts +9 -0
- package/src/runtime/storage.ts +13 -0
- package/src/runtime/touch.ts +76 -0
- package/src/scene/defineScene.ts +1396 -0
- package/src/scene/editorPlugins.ts +110 -0
- package/src/scene/gizmos.ts +148 -0
- package/src/scene/grammar.ts +120 -0
- package/src/scene/level.ts +296 -0
- package/src/scene/material.ts +188 -0
- package/src/server/auth/appConfig.ts +12 -0
- package/src/server/auth/global.ts +80 -0
- package/src/server/auth/host.ts +318 -0
- package/src/server/auth/models.ts +83 -0
- package/src/server/auth/types.ts +50 -0
- package/src/server/channel.ts +56 -0
- package/src/server/context.ts +36 -0
- package/src/server/db/defineDb.ts +237 -0
- package/src/server/db/fields.ts +132 -0
- package/src/server/db/httpTransport.ts +93 -0
- package/src/server/db/index.ts +7 -0
- package/src/server/db/marci/query.ts +412 -0
- package/src/server/db/types.ts +202 -0
- package/src/server/errors.ts +12 -0
- package/src/server/host.ts +74 -0
- package/src/server/inject.ts +13 -0
- package/src/server/runtime.ts +133 -0
- package/src/server/validate.ts +87 -0
- package/src/ui/NativeView.ts +142 -0
- package/src/ui/UI.ts +39 -0
- package/src/ui/UIBottomSheet.ts +139 -0
- package/src/ui/UIButton.ts +101 -0
- package/src/ui/UIContainer.ts +60 -0
- package/src/ui/UIImage.ts +83 -0
- package/src/ui/UIInput.ts +185 -0
- package/src/ui/UIModal.ts +139 -0
- package/src/ui/UINode.ts +830 -0
- package/src/ui/UIPager.ts +362 -0
- package/src/ui/UIPopover.ts +100 -0
- package/src/ui/UIScreen.ts +123 -0
- package/src/ui/UIScrollable.ts +87 -0
- package/src/ui/UISpacer.ts +14 -0
- package/src/ui/UITabs.ts +236 -0
- package/src/ui/UIText.ts +51 -0
- package/src/ui/UIVideo.ts +88 -0
- package/src/ui/UIVirtualizedList.ts +241 -0
- package/src/ui/UIWidget.ts +127 -0
- package/src/ui/fonts.ts +13 -0
- package/src/ui/presentable.ts +117 -0
- package/src/ui/router.ts +132 -0
- package/src/ui/theme.ts +84 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export { Mathf } from "./math/Mathf";
|
|
2
|
+
export { Vec2, Vec3 } from "./math/vec";
|
|
3
|
+
export { Quat } from "./math/quat";
|
|
4
|
+
export { Mat4 } from "./math/mat4";
|
|
5
|
+
export { Color } from "./core/color";
|
|
6
|
+
export { Aspect, System, type With, type SystemHost } from "./core/Aspect";
|
|
7
|
+
export { type EventMap } from "./core/events";
|
|
8
|
+
export { Time } from "./core/time";
|
|
9
|
+
export { StateMachine, defineStates, type StateDef, type StatesDef, type StateGuard, type StateHandler, type StateMachineEvents } from "./core/StateMachine";
|
|
10
|
+
export { InspectorUI } from "./core/InspectorUI";
|
|
11
|
+
export { signal, computed, effect, type Signal, type Computed } from "./core/signals";
|
|
12
|
+
export { __compWrite, __compOp, type CompAxis, type CompWriter } from "./core/compWrite";
|
|
13
|
+
export { Canvas, Bitmap } from "./canvas/Canvas";
|
|
14
|
+
export { toast, openURL, SvgSource } from "./runtime/misc";
|
|
15
|
+
export { app, type AppState, type OrientationLock } from "./runtime/app";
|
|
16
|
+
export { clipboard } from "./runtime/clipboard";
|
|
17
|
+
export { date, type DateValue, type DateInput, type Unit, type Locale } from "./runtime/datetime";
|
|
18
|
+
export { fetch, fetchLocal, FormData, File, type FetchResponse } from "./runtime/fetch";
|
|
19
|
+
export { localStorage } from "./runtime/storage";
|
|
20
|
+
export { device, type HapticStyle, type MotionOptions } from "./runtime/device";
|
|
21
|
+
export { Input, InputChannel, type InputKeyEvent, type InputGamepadEvent, type InputEventName, type GamepadState, type GamepadAxisName } from "./runtime/input";
|
|
22
|
+
export { WebSocket } from "./runtime/net";
|
|
23
|
+
export { Net, NetPlayer, Replicated, NetEntity, type NetMessage, type NetRole, type NetStatus, type NetEvents, type NetLaunch, type NetInput, type NetKind, type NetTransform } from "./net";
|
|
24
|
+
export { __rpc, __channel, __serverOnly, RpcError, type ClientChannel } from "./runtime/rpc";
|
|
25
|
+
export { AudioPlayer, VideoPlayer } from "./runtime/media";
|
|
26
|
+
export { openFilePicker, files, type FileData } from "./runtime/files";
|
|
27
|
+
export { share } from "./runtime/share";
|
|
28
|
+
export { ClickEvent, TouchStartEvent, LongPressEvent } from "./runtime/touch";
|
|
29
|
+
export { Scene2D } from "./g2/Scene2D";
|
|
30
|
+
export { Node2D } from "./g2/Node2D";
|
|
31
|
+
export { Camera2D } from "./g2/Camera2D";
|
|
32
|
+
export { Sprite } from "./g2/Sprite";
|
|
33
|
+
export { SpriteAnimation } from "./g2/SpriteAnimation";
|
|
34
|
+
export { Shape2D } from "./g2/Shape2D";
|
|
35
|
+
export { Physics2D } from "./g2/Physics2D";
|
|
36
|
+
export { Trigger2D } from "./g2/Trigger2D";
|
|
37
|
+
export { CharacterController2D } from "./g2/CharacterController2D";
|
|
38
|
+
export { OneWay2D } from "./g2/OneWay2D";
|
|
39
|
+
export { PhysicsGroup2D } from "./g2/groups2d";
|
|
40
|
+
export { Tilemap } from "./g2/Tilemap";
|
|
41
|
+
export { Texture2D } from "./g2/Texture2D";
|
|
42
|
+
export { SpriteSheet, defineSpriteSheet } from "./g2/SpriteSheet";
|
|
43
|
+
export type { SpriteSheetDef, SheetSprite, SpriteMakeOptions } from "./g2/SpriteSheet";
|
|
44
|
+
export { Tileset, defineTileset, Autotile2D } from "./g2/Tileset";
|
|
45
|
+
export { rawCell, isRawCell, rawIndex } from "./g2/autotile";
|
|
46
|
+
export { rot90, rot180, rot270, flipX, packTile, tileIndex, tileTurns, tileFlip, tileOriented } from "./g2/autotile";
|
|
47
|
+
export type { TilesetDef, TileMaterial, PatchMaterial, PathMaterial, PatchSlots, EdgeSlot, FillBlock, BlockEntry, TileBlock, TilePart, } from "./g2/autotile";
|
|
48
|
+
export { defineScene2d, Scene2dHandle } from "./g2/defineScene2d";
|
|
49
|
+
export type { Scene2dDef, Scene2dNodeDef, Scene2dEnv, SpriteSourceDef, TilemapSourceDef, Camera2dNodeDef, LoadedScene2d } from "./g2/defineScene2d";
|
|
50
|
+
export { cells, encodeCells, type CellsData } from "./g2/cells";
|
|
51
|
+
export { CameraFollow } from "./g2/scenarios2d";
|
|
52
|
+
export { UIScreen, type UIScreenStyle, UIRow, UIColumn, UIBox, type UIContainerStyle, UIText, type UITextStyle, UIButton, type UIButtonStyle, UIImage, type UIImageStyle, UIVideo, type UIVideoStyle, UIInput, UITextArea, type UIInputStyle, UIScrollable, type UIScrollableStyle, UIPager, type UIPagerStyle, UITabs, type UITabDef, defineTabs, type TabDef, type TabsHandle, UIWidget, type UIWidgetStyle, UIModal, type UIModalStyle, UIBottomSheet, type UIBottomSheetStyle, UIPopover, type UIPopoverStyle, UISpacer, type UISpacerStyle, UIVirtualizedList, Router, NativeView, type UINativeViewStyle, registerFont, __uiMap, __UIColumn, __UIRow, __UIBox, __UIButton, __UIScreen, __UIScrollable, __UIWidget, } from "./ui/UI";
|
|
53
|
+
export { Presentable } from "./ui/UI";
|
|
54
|
+
export type { PresentOptions, Transition, TransitionName, TransitionSpec, TransitionTransform } from "./ui/UI";
|
|
55
|
+
export type { UINode, UINodeChild } from "./ui/UINode";
|
|
56
|
+
export { theme, type ThemeValues, type ThemeAccessors } from "./ui/theme";
|
|
57
|
+
export { animate, animateMat4, stopAnimation, pauseAnimation, resumeAnimation } from "./animate/animate";
|
|
58
|
+
export { cubicBezier } from "./animate/bezier";
|
|
59
|
+
export { easeIn, easeOut, easeInOut } from "./animate/easings";
|
|
60
|
+
export { QRScanner } from "./plugins/qr";
|
|
61
|
+
export { CameraView, type CameraFacing } from "./plugins/camera";
|
|
62
|
+
export { Geolocation, type GeoPosition, type GeoOptions, type GeoWatch } from "./plugins/geolocation";
|
|
63
|
+
export { Push, type PushPayload, type PushStatus, type PushRegisterOptions, type PushEvent } from "./plugins/push";
|
|
64
|
+
export { OAuth, type OAuthCredential, type OAuthProviderName } from "./plugins/oauth";
|
|
65
|
+
export { Service } from "./plugins/service";
|
|
66
|
+
export { defineScene, use, ref, make, SceneHandle, applyEditorPose as __applyEditorPose } from "./scene/defineScene";
|
|
67
|
+
export { defineMaterial, MaterialHandle, assignMaterialDef as __assignMaterialDef, applyMaterialParam as __applyMaterialParam, } from "./scene/material";
|
|
68
|
+
export type { MaterialData, MaterialParamValue, ShaderMaterialDef, LitMaterialDef, UnlitMaterialDef } from "./scene/material";
|
|
69
|
+
export type { SceneDef, SceneNodeDef, MeshDef, LightDef, MaterialDef, CameraNodeDef, AspectEntry, MakeEntry, LoadedScene, SceneInstance } from "./scene/defineScene";
|
|
70
|
+
export { CameraPlace } from "./gl/CameraPlace";
|
|
71
|
+
export { Level } from "./scene/level";
|
|
72
|
+
export type { LevelSpot, LevelBuild, LevelCollider, LevelLineOptions, LevelGridOptions, LevelRingOptions, LevelScatterOptions, LevelPlaceOptions } from "./scene/level";
|
|
73
|
+
export type { FieldMeta } from "./core/fields";
|
|
74
|
+
export { Gizmos, GizmoBuffer as __GizmoBuffer, withGizmoScope as __withGizmoScope } from "./scene/gizmos";
|
|
75
|
+
export type { GizmoStyle, GizmoAnchor } from "./scene/gizmos";
|
|
76
|
+
export { MoveTo, FollowPath, Spin, LookAt, PlayAnimation } from "./gl/scenarios";
|
|
77
|
+
export { registerEditorWindow, registerEditorTool, __editorPlugins } from "./scene/editorPlugins";
|
|
78
|
+
export type { EditorApi, EditorRayHit, EditorToolHooks, EditorWindowFn } from "./scene/editorPlugins";
|
|
79
|
+
export { Scene, ARScene, VRScene } from "./gl/Scene";
|
|
80
|
+
export { Node } from "./gl/Node";
|
|
81
|
+
export { Mesh } from "./gl/Mesh";
|
|
82
|
+
export { Model } from "./gl/Model";
|
|
83
|
+
export { Shape } from "./gl/Shape";
|
|
84
|
+
export { Physics } from "./gl/Physics";
|
|
85
|
+
export { Trigger } from "./gl/Trigger";
|
|
86
|
+
export { CharacterController } from "./gl/CharacterController";
|
|
87
|
+
export { Vehicle } from "./gl/Vehicle";
|
|
88
|
+
export type { DriveLayout, DifferentialMode, EngineConfig, SteeringConfig, AeroConfig } from "./gl/Vehicle";
|
|
89
|
+
export { Wheel } from "./gl/Wheel";
|
|
90
|
+
export { Ragdoll } from "./gl/Ragdoll";
|
|
91
|
+
export type { RagdollPart, RagdollHinge } from "./gl/Ragdoll";
|
|
92
|
+
export type { TireCurve, WheelSuspension, WheelTire, WheelVisual } from "./gl/Wheel";
|
|
93
|
+
export { Gearbox } from "./gl/Gearbox";
|
|
94
|
+
export { AnimationClip } from "./gl/animation/AnimationClip";
|
|
95
|
+
export type { ClipDef, ClipTrackDef, ClipKey } from "./gl/animation/AnimationClip";
|
|
96
|
+
export { Animator } from "./gl/animation/Animator";
|
|
97
|
+
export type { WarpOptions, FeetOptions, FootState } from "./gl/animation/Animator";
|
|
98
|
+
export { Playback } from "./gl/animation/Playback";
|
|
99
|
+
export { Loop } from "./gl/animation/Loop";
|
|
100
|
+
export { Layer } from "./gl/animation/Layer";
|
|
101
|
+
export type { PlayOptions, StopOptions, LayerOptions, LoopOptions, LoopDef, BlendPosition, ActiveClip } from "./gl/animation/core";
|
|
102
|
+
export { IK } from "./gl/IK";
|
|
103
|
+
export type { IKTwoBone, IKLookAt } from "./gl/IK";
|
|
104
|
+
export { Light } from "./gl/Light";
|
|
105
|
+
export { Lightmap } from "./gl/Lightmap";
|
|
106
|
+
export { Terrain } from "./gl/Terrain";
|
|
107
|
+
export type { TerrainOptions, TerrainLayer, TerrainRegion, ConformOptions, RibbonOptions, AutoPaintRules, SculptOptions, TerrainHit, TerrainSnapshot } from "./gl/Terrain";
|
|
108
|
+
export { NavMesh, NavCrowd } from "./gl/NavMesh";
|
|
109
|
+
export type { NavMeshLoadOptions, NavMeshInfo, NavPath, NavQueryOptions, NavRaycastHit, NavAgentSize } from "./gl/NavMesh";
|
|
110
|
+
export { NavAgent } from "./gl/NavAgent";
|
|
111
|
+
export type { NavAgentState, NavAgentAvoidance, NavAgentDrive, NavAgentEvents } from "./gl/NavAgent";
|
|
112
|
+
export { Locomotion } from "./gl/Locomotion";
|
|
113
|
+
export type { LocomotionSet, LocomotionClip, LocomotionTuning, LocomotionState, LocomotionEvents, Displacement, Gait } from "./gl/Locomotion";
|
|
114
|
+
export { Material } from "./gl/Material";
|
|
115
|
+
export { Geometry } from "./gl/Geometry";
|
|
116
|
+
export { InstancedMesh } from "./gl/InstancedMesh";
|
|
117
|
+
export type { InstanceTransform } from "./gl/InstancedMesh";
|
|
118
|
+
export { Texture } from "./gl/Texture";
|
|
119
|
+
export { Camera } from "./gl/Camera";
|
|
120
|
+
export { Ray } from "./gl/Ray";
|
|
121
|
+
export { Plane } from "./gl/Plane";
|
|
122
|
+
export { Noise } from "./gl/Noise";
|
|
123
|
+
export { Particles, Trail, curve, colorCurve } from "./gl/Particles";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type Damper<T extends number | number[]> = ((target: T, dt: number) => T) & {
|
|
2
|
+
/** Snap the damper's internal current value (e.g. on teleport). */
|
|
3
|
+
setValue(value: T): void;
|
|
4
|
+
};
|
|
5
|
+
declare function smoothDamp(initial: number, smoothTime: number, maxSpeed?: number): Damper<number>;
|
|
6
|
+
declare function smoothDamp(initial: number[], smoothTime: number, maxSpeed?: number): Damper<number[]>;
|
|
7
|
+
export declare const Mathf: {
|
|
8
|
+
PI: number;
|
|
9
|
+
TAU: number;
|
|
10
|
+
EPSILON: number;
|
|
11
|
+
DEG2RAD: number;
|
|
12
|
+
RAD2DEG: number;
|
|
13
|
+
deg2rad: (deg: number) => number;
|
|
14
|
+
rad2deg: (rad: number) => number;
|
|
15
|
+
clamp: (v: number, min: number, max: number) => number;
|
|
16
|
+
clamp01: (v: number) => number;
|
|
17
|
+
lerp: (a: number, b: number, t: number) => number;
|
|
18
|
+
inverseLerp: (a: number, b: number, v: number) => number;
|
|
19
|
+
remap: (v: number, inMin: number, inMax: number, outMin: number, outMax: number) => number;
|
|
20
|
+
/** Move `a` toward `b` by at most `maxDelta`. */
|
|
21
|
+
moveTowards: (a: number, b: number, maxDelta: number) => number;
|
|
22
|
+
/** Frame-rate-independent exponential approach (good default: lambda 5..15). */
|
|
23
|
+
damp: (a: number, b: number, lambda: number, dt: number) => number;
|
|
24
|
+
sign: (x: number) => number;
|
|
25
|
+
/** Loop a value into [0, length). */
|
|
26
|
+
repeat: (t: number, length: number) => number;
|
|
27
|
+
/** Ping-pong a value in [0, length]. */
|
|
28
|
+
pingPong: (t: number, length: number) => number;
|
|
29
|
+
random: (min?: number, max?: number) => number;
|
|
30
|
+
randomInt: (min: number, max: number) => number;
|
|
31
|
+
/**
|
|
32
|
+
* Critically-damped follow (Unity SmoothDamp). Returns a stateful damper you call every frame:
|
|
33
|
+
* const d = Mathf.smoothDamp([x, y], 0.15)
|
|
34
|
+
* pos = d(targetPos, dt)
|
|
35
|
+
* Works on a number or a numeric array (vec2 / vec3).
|
|
36
|
+
*/
|
|
37
|
+
smoothDamp: typeof smoothDamp;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Vec3, type Vec3Like } from "./vec";
|
|
2
|
+
import { Quat, type QuatLike, type EulerOrder } from "./quat";
|
|
3
|
+
export type Mat4Like = Mat4 | number[] | Float32Array | readonly number[];
|
|
4
|
+
export declare class Mat4 {
|
|
5
|
+
/** The raw column-major elements (length 16). Public on purpose — read/write directly when you want
|
|
6
|
+
* the metal: `mat.m[12] += vx * dt`. The fluent methods never mutate it (they return a new Mat4). */
|
|
7
|
+
m: number[];
|
|
8
|
+
constructor(src?: Mat4Like);
|
|
9
|
+
set(values: ArrayLike<number>): this;
|
|
10
|
+
copy(src: Mat4Like): this;
|
|
11
|
+
/** `this · b` (apply `b` first in local space, then `this`). */
|
|
12
|
+
mul(b: Mat4Like): Mat4;
|
|
13
|
+
/** `b · this` — multiply on the other side (apply `this` first, then `b`). */
|
|
14
|
+
premul(b: Mat4Like): Mat4;
|
|
15
|
+
invert(): Mat4;
|
|
16
|
+
transpose(): Mat4;
|
|
17
|
+
determinant(): number;
|
|
18
|
+
/** `this · translate(v)`. */
|
|
19
|
+
translate(v: Vec3Like): Mat4;
|
|
20
|
+
/** `this · scale(v)`. Accepts a vector or a uniform scalar. */
|
|
21
|
+
scale(v: Vec3Like | number): Mat4;
|
|
22
|
+
/** `this · rotate(axis, rad)`. */
|
|
23
|
+
rotate(rad: number, axis: Vec3Like): Mat4;
|
|
24
|
+
rotateX(rad: number): Mat4;
|
|
25
|
+
rotateY(rad: number): Mat4;
|
|
26
|
+
rotateZ(rad: number): Mat4;
|
|
27
|
+
/** Transform a point (applies translation + perspective divide). */
|
|
28
|
+
transformPoint(v: Vec3Like): Vec3;
|
|
29
|
+
/** Transform a direction (rotation/scale only — no translation, no divide). */
|
|
30
|
+
transformDirection(v: Vec3Like): Vec3;
|
|
31
|
+
get position(): Vec3;
|
|
32
|
+
get scaling(): Vec3;
|
|
33
|
+
get rotation(): Quat;
|
|
34
|
+
get eulerAngles(): Vec3;
|
|
35
|
+
toEuler(order?: EulerOrder): Vec3;
|
|
36
|
+
/** `{ position, rotation, scale }` in one shot. */
|
|
37
|
+
decompose(): {
|
|
38
|
+
position: Vec3;
|
|
39
|
+
rotation: Quat;
|
|
40
|
+
scale: Vec3;
|
|
41
|
+
};
|
|
42
|
+
/** Column basis vectors (the local X / Y / Z axes in world space). */
|
|
43
|
+
get basisX(): Vec3;
|
|
44
|
+
get basisY(): Vec3;
|
|
45
|
+
get basisZ(): Vec3;
|
|
46
|
+
clone(): Mat4;
|
|
47
|
+
toArray(): number[];
|
|
48
|
+
toFloat32Array(): Float32Array;
|
|
49
|
+
equals(b: Mat4Like, eps?: number): boolean;
|
|
50
|
+
static identity(): Mat4;
|
|
51
|
+
static from(src: Mat4Like): Mat4;
|
|
52
|
+
/** Translation · Rotation · Scale into one matrix. `scale` defaults to 1 and accepts a scalar. */
|
|
53
|
+
static compose(position: Vec3Like, rotation: QuatLike, scale?: Vec3Like | number): Mat4;
|
|
54
|
+
static fromQuat(q: QuatLike): Mat4;
|
|
55
|
+
static fromTranslation(v: Vec3Like): Mat4;
|
|
56
|
+
static fromScale(v: Vec3Like | number): Mat4;
|
|
57
|
+
static fromEuler(x: number, y: number, z: number, order?: EulerOrder): Mat4;
|
|
58
|
+
/** A view matrix that looks from `eye` toward `center` with `up`. */
|
|
59
|
+
static lookAt(eye: Vec3Like, center: Vec3Like, up?: Vec3Like): Mat4;
|
|
60
|
+
/** A world matrix that places something at `eye` oriented to look at `target`. */
|
|
61
|
+
static targetTo(eye: Vec3Like, target: Vec3Like, up?: Vec3Like): Mat4;
|
|
62
|
+
/** Perspective projection (WebGL/OpenGL clip, NDC z ∈ [−1, 1]). `fovy` is in RADIANS. */
|
|
63
|
+
static perspective(fovy: number, aspect: number, near: number, far: number): Mat4;
|
|
64
|
+
/** Orthographic projection (WebGL/OpenGL clip, NDC z ∈ [−1, 1]). */
|
|
65
|
+
static ortho(left: number, right: number, bottom: number, top: number, near: number, far: number): Mat4;
|
|
66
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Vec3, type Vec3Like } from "./vec";
|
|
2
|
+
export type QuatLike = Quat | readonly [number, number, number, number] | number[] | Float32Array;
|
|
3
|
+
export type EulerOrder = "XYZ" | "YXZ" | "ZXY" | "ZYX" | "YZX" | "XZY";
|
|
4
|
+
/** Read the w / 4th component of any quaternion-like (wrapper `.w`, or array-like `[3]`). */
|
|
5
|
+
export declare const cw: (q: {
|
|
6
|
+
w?: number;
|
|
7
|
+
} | ArrayLike<number>) => number;
|
|
8
|
+
export declare class Quat {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
z: number;
|
|
12
|
+
w: number;
|
|
13
|
+
constructor(x?: number | QuatLike, y?: number, z?: number, w?: number);
|
|
14
|
+
set(x: number, y: number, z: number, w: number): this;
|
|
15
|
+
copy(q: QuatLike): this;
|
|
16
|
+
/** Hamilton product `this ⊗ b` (apply `b` first, then `this`). */
|
|
17
|
+
mul(b: QuatLike): Quat;
|
|
18
|
+
normalize(): Quat;
|
|
19
|
+
conjugate(): Quat;
|
|
20
|
+
/** Inverse rotation. For a unit quaternion this equals `conjugate()`. */
|
|
21
|
+
invert(): Quat;
|
|
22
|
+
dot(b: QuatLike): number;
|
|
23
|
+
/** Spherical interpolation toward `b` by `t ∈ [0, 1]`. */
|
|
24
|
+
slerp(b: QuatLike, t: number): Quat;
|
|
25
|
+
/** Angular distance (radians) between two unit quaternions. */
|
|
26
|
+
angle(b: QuatLike): number;
|
|
27
|
+
/** Rotate a vector by this quaternion → a new `Vec3`. */
|
|
28
|
+
rotateVec3(v: Vec3Like): Vec3;
|
|
29
|
+
/** Extract euler angles (DEGREES) in the given order. */
|
|
30
|
+
toEuler(order?: EulerOrder): Vec3;
|
|
31
|
+
equals(b: QuatLike, eps?: number): boolean;
|
|
32
|
+
/** True if the two unit quaternions represent the same rotation (±q are equal). */
|
|
33
|
+
sameRotation(b: QuatLike, eps?: number): boolean;
|
|
34
|
+
clone(): Quat;
|
|
35
|
+
toArray(): [number, number, number, number];
|
|
36
|
+
[Symbol.iterator](): Iterator<number>;
|
|
37
|
+
static from(q: QuatLike): Quat;
|
|
38
|
+
static get identity(): Quat;
|
|
39
|
+
/** From euler angles in DEGREES (default order "YXZ"). Inverts `toEuler`. */
|
|
40
|
+
static fromEuler(x: number, y: number, z: number, order?: EulerOrder): Quat;
|
|
41
|
+
/** From a rotation `axis` and an angle in RADIANS. The axis is normalized for you. */
|
|
42
|
+
static fromAxisAngle(axis: Vec3Like, rad: number): Quat;
|
|
43
|
+
/** The shortest rotation that takes direction `a` onto direction `b`. */
|
|
44
|
+
static fromTo(a: Vec3Like, b: Vec3Like): Quat;
|
|
45
|
+
/** A rotation whose forward (−Z) points along `forward`, with `up` as the reference up axis. */
|
|
46
|
+
static lookRotation(forward: Vec3Like, up?: Vec3Like): Quat;
|
|
47
|
+
}
|
|
48
|
+
/** Quaternion from a column-major rotation matrix (≥3×3, indices 0,1,2,4,5,6,8,9,10). gl-matrix's
|
|
49
|
+
* `getRotation` algorithm — the exact inverse of building a matrix from a quaternion. */
|
|
50
|
+
export declare const quatFromColMajor: (m: ArrayLike<number>) => Quat;
|
|
51
|
+
/** Euler angles (DEGREES) from a column-major rotation matrix, standard three.js extraction.
|
|
52
|
+
* Element naming follows the column-major layout: mRC = m[(C-1)*4 + (R-1)]. */
|
|
53
|
+
export declare const eulerFromColMajor: (m: ArrayLike<number>, order?: EulerOrder) => Vec3;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export type Vec2Like = Vec2 | readonly [number, number] | number[] | Float32Array;
|
|
2
|
+
export type Vec3Like = Vec3 | readonly [number, number, number] | number[] | Float32Array;
|
|
3
|
+
/** Read the x / first component of any vector-like (wrapper, tuple, or typed array). `?? ` is safe on
|
|
4
|
+
* 0 and NaN — it only falls through on `undefined` (i.e. a non-wrapper that has no `.x`). */
|
|
5
|
+
export declare const cx: (v: {
|
|
6
|
+
x?: number;
|
|
7
|
+
} | ArrayLike<number>) => number;
|
|
8
|
+
export declare const cy: (v: {
|
|
9
|
+
y?: number;
|
|
10
|
+
} | ArrayLike<number>) => number;
|
|
11
|
+
export declare const cz: (v: {
|
|
12
|
+
z?: number;
|
|
13
|
+
} | ArrayLike<number>) => number;
|
|
14
|
+
export declare class Vec2 {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
constructor(x?: number | Vec2Like, y?: number);
|
|
18
|
+
/** Mutate the components in place. Returns `this`. */
|
|
19
|
+
set(x: number, y: number): this;
|
|
20
|
+
/** Copy another vector's components into this one. Returns `this`. */
|
|
21
|
+
copy(v: Vec2Like): this;
|
|
22
|
+
add(v: Vec2Like): Vec2;
|
|
23
|
+
sub(v: Vec2Like): Vec2;
|
|
24
|
+
mul(v: Vec2Like): Vec2;
|
|
25
|
+
div(v: Vec2Like): Vec2;
|
|
26
|
+
scale(s: number): Vec2;
|
|
27
|
+
/** `this + v * s` (fused multiply-add). */
|
|
28
|
+
scaleAndAdd(v: Vec2Like, s: number): Vec2;
|
|
29
|
+
negate(): Vec2;
|
|
30
|
+
dot(v: Vec2Like): number;
|
|
31
|
+
/** 2D cross product → the scalar z of the 3D cross (signed parallelogram area). */
|
|
32
|
+
cross(v: Vec2Like): number;
|
|
33
|
+
length(): number;
|
|
34
|
+
lengthSq(): number;
|
|
35
|
+
distanceTo(v: Vec2Like): number;
|
|
36
|
+
distanceSqTo(v: Vec2Like): number;
|
|
37
|
+
normalize(): Vec2;
|
|
38
|
+
lerp(v: Vec2Like, t: number): Vec2;
|
|
39
|
+
clamp(min: Vec2Like, max: Vec2Like): Vec2;
|
|
40
|
+
min(v: Vec2Like): Vec2;
|
|
41
|
+
max(v: Vec2Like): Vec2;
|
|
42
|
+
/** Left-hand perpendicular: (-y, x), a 90° CCW turn. */
|
|
43
|
+
perp(): Vec2;
|
|
44
|
+
/** Rotate by `rad` (CCW) around `origin` (default 0). */
|
|
45
|
+
rotate(rad: number, origin?: Vec2Like): Vec2;
|
|
46
|
+
/** The vector's heading in radians: `atan2(y, x)`. */
|
|
47
|
+
heading(): number;
|
|
48
|
+
/** Angle (radians) between this and `v`. */
|
|
49
|
+
angle(v: Vec2Like): number;
|
|
50
|
+
withX(x: number): Vec2;
|
|
51
|
+
withY(y: number): Vec2;
|
|
52
|
+
equals(v: Vec2Like, eps?: number): boolean;
|
|
53
|
+
clone(): Vec2;
|
|
54
|
+
toArray(): [number, number];
|
|
55
|
+
[Symbol.iterator](): Iterator<number>;
|
|
56
|
+
static from(v: Vec2Like): Vec2;
|
|
57
|
+
static get zero(): Vec2;
|
|
58
|
+
static get one(): Vec2;
|
|
59
|
+
static get up(): Vec2;
|
|
60
|
+
static get down(): Vec2;
|
|
61
|
+
static get left(): Vec2;
|
|
62
|
+
static get right(): Vec2;
|
|
63
|
+
}
|
|
64
|
+
export declare class Vec3 {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
z: number;
|
|
68
|
+
constructor(x?: number | Vec3Like, y?: number, z?: number);
|
|
69
|
+
set(x: number, y: number, z: number): this;
|
|
70
|
+
copy(v: Vec3Like): this;
|
|
71
|
+
add(v: Vec3Like): Vec3;
|
|
72
|
+
sub(v: Vec3Like): Vec3;
|
|
73
|
+
mul(v: Vec3Like): Vec3;
|
|
74
|
+
div(v: Vec3Like): Vec3;
|
|
75
|
+
scale(s: number): Vec3;
|
|
76
|
+
/** `this + v * s` (fused multiply-add). */
|
|
77
|
+
scaleAndAdd(v: Vec3Like, s: number): Vec3;
|
|
78
|
+
negate(): Vec3;
|
|
79
|
+
dot(v: Vec3Like): number;
|
|
80
|
+
cross(v: Vec3Like): Vec3;
|
|
81
|
+
length(): number;
|
|
82
|
+
lengthSq(): number;
|
|
83
|
+
distanceTo(v: Vec3Like): number;
|
|
84
|
+
distanceSqTo(v: Vec3Like): number;
|
|
85
|
+
normalize(): Vec3;
|
|
86
|
+
lerp(v: Vec3Like, t: number): Vec3;
|
|
87
|
+
clamp(min: Vec3Like, max: Vec3Like): Vec3;
|
|
88
|
+
min(v: Vec3Like): Vec3;
|
|
89
|
+
max(v: Vec3Like): Vec3;
|
|
90
|
+
/** Reflect this vector about a (unit) `normal`: `v - 2·(v·n)·n`. */
|
|
91
|
+
reflect(normal: Vec3Like): Vec3;
|
|
92
|
+
/** Vector projection of this onto `onto`. */
|
|
93
|
+
project(onto: Vec3Like): Vec3;
|
|
94
|
+
/** Angle (radians) between this and `v`. */
|
|
95
|
+
angle(v: Vec3Like): number;
|
|
96
|
+
/** Rotate this point around the X axis through `origin` (default 0) by `rad`. */
|
|
97
|
+
rotateX(rad: number, origin?: Vec3Like): Vec3;
|
|
98
|
+
rotateY(rad: number, origin?: Vec3Like): Vec3;
|
|
99
|
+
rotateZ(rad: number, origin?: Vec3Like): Vec3;
|
|
100
|
+
/** Rotate this vector by a quaternion (x, y, z, w). Accepts a `Quat` or a raw `[x,y,z,w]`. */
|
|
101
|
+
rotate(q: ArrayLike<number> | {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
z: number;
|
|
105
|
+
w: number;
|
|
106
|
+
}): Vec3;
|
|
107
|
+
/** Transform this point by a column-major mat4 (a `Mat4`, its `.m`, or a raw length-16 array),
|
|
108
|
+
* applying translation and the perspective divide. */
|
|
109
|
+
transform(m: ArrayLike<number> | {
|
|
110
|
+
m: ArrayLike<number>;
|
|
111
|
+
}): Vec3;
|
|
112
|
+
withX(x: number): Vec3;
|
|
113
|
+
withY(y: number): Vec3;
|
|
114
|
+
withZ(z: number): Vec3;
|
|
115
|
+
equals(v: Vec3Like, eps?: number): boolean;
|
|
116
|
+
clone(): Vec3;
|
|
117
|
+
toArray(): [number, number, number];
|
|
118
|
+
[Symbol.iterator](): Iterator<number>;
|
|
119
|
+
static from(v: Vec3Like): Vec3;
|
|
120
|
+
static get zero(): Vec3;
|
|
121
|
+
static get one(): Vec3;
|
|
122
|
+
static get up(): Vec3;
|
|
123
|
+
static get down(): Vec3;
|
|
124
|
+
static get left(): Vec3;
|
|
125
|
+
static get right(): Vec3;
|
|
126
|
+
/** Forward is −Z (the engine's cameras look down −Z; `node.forward` is −Z at identity). */
|
|
127
|
+
static get forward(): Vec3;
|
|
128
|
+
static get back(): Vec3;
|
|
129
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type FieldKind = 0 | 1 | 2;
|
|
2
|
+
export type Field = {
|
|
3
|
+
key: string;
|
|
4
|
+
kind: FieldKind;
|
|
5
|
+
len: number;
|
|
6
|
+
};
|
|
7
|
+
export type Layout = {
|
|
8
|
+
fields: Field[];
|
|
9
|
+
floats: number;
|
|
10
|
+
bools: number;
|
|
11
|
+
bytes: number;
|
|
12
|
+
sig: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const makeLayout: (defaults: Record<string, unknown>, what: string) => Layout;
|
|
15
|
+
/** A fresh state object shaped like the defaults (arrays copied, never shared). */
|
|
16
|
+
export declare const cloneDefaults: <T extends object>(defaults: T) => T;
|
|
17
|
+
/** Copy the layout's fields from `from` into `into` (array elements copied in place; unknown keys
|
|
18
|
+
* ignored — a JSON spawn state or a partial `setInput`). */
|
|
19
|
+
export declare const assignState: (layout: Layout, into: any, from: any) => void;
|
|
20
|
+
export declare const packInto: (view: DataView, offset: number, layout: Layout, s: any) => number;
|
|
21
|
+
export declare const unpackFrom: (view: DataView, offset: number, layout: Layout, into: any) => number;
|
|
22
|
+
/** `out = a + (b − a) · t` for the numeric fields; booleans take `b`'s. */
|
|
23
|
+
export declare const lerpState: (layout: Layout, a: any, b: any, t: number, out: any) => void;
|
|
24
|
+
/** FNV-1a over a string → 8 hex chars. Enough to tell two bundles' schemas apart. */
|
|
25
|
+
export declare const hashString: (s: string) => string;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export type Listener = (...args: any[]) => void;
|
|
2
|
+
export type NetRole = "offline" | "host" | "client" | "server";
|
|
3
|
+
export type NetStatus = "idle" | "connecting" | "online" | "error";
|
|
4
|
+
/** A typed message key: `const Fire = Net.message<{ dir: number[] }>("fire")`. The type lives in
|
|
5
|
+
* TypeScript only; the payload is JSON. */
|
|
6
|
+
export type NetMessage<T = unknown> = {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly unreliable: boolean;
|
|
9
|
+
readonly __t?: T;
|
|
10
|
+
};
|
|
11
|
+
export type NetEvents = {
|
|
12
|
+
/** Client: welcomed by the server. Host/server: listening. */
|
|
13
|
+
connect: () => void;
|
|
14
|
+
/** The connection ended (`reason` from the transport, e.g. "timed out", "kicked"). */
|
|
15
|
+
disconnect: (reason: string) => void;
|
|
16
|
+
/** The server refused us (`reason`: "full" | "version" | "schema" | a kick reason). */
|
|
17
|
+
reject: (reason: string) => void;
|
|
18
|
+
join: (player: NetPlayer) => void;
|
|
19
|
+
leave: (player: NetPlayer, reason: string) => void;
|
|
20
|
+
error: (message: string) => void;
|
|
21
|
+
};
|
|
22
|
+
export type NetLaunch = {
|
|
23
|
+
role: "server" | "client";
|
|
24
|
+
address: string;
|
|
25
|
+
port: number;
|
|
26
|
+
maxClients: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const CH_RELIABLE = 0;
|
|
29
|
+
export declare const CH_UNRELIABLE = 1;
|
|
30
|
+
export declare const PROTO = 2;
|
|
31
|
+
export declare const LOCAL_SLOT = -1;
|
|
32
|
+
export declare const bridge: () => typeof _creatorNet | null;
|
|
33
|
+
export declare class NetPlayer {
|
|
34
|
+
/** Session-unique id assigned by the server (1 = the host's own player when hosting). */
|
|
35
|
+
readonly id: number;
|
|
36
|
+
name: string;
|
|
37
|
+
readonly connectedAt: number;
|
|
38
|
+
/** A local bag for game facts (score, team, ready). NOT replicated — anything a client must see
|
|
39
|
+
* goes through a message or replicated state. */
|
|
40
|
+
data: any;
|
|
41
|
+
private _leave;
|
|
42
|
+
constructor(id: number, name: string, slot: number);
|
|
43
|
+
get isMe(): boolean;
|
|
44
|
+
/** Round trip to this player in ms (server side) or to the server (our own player on a client). */
|
|
45
|
+
get rtt(): number;
|
|
46
|
+
get loss(): number;
|
|
47
|
+
/** Server → this player. */
|
|
48
|
+
send<T>(msg: NetMessage<T>, data: T): void;
|
|
49
|
+
kick(reason?: string): void;
|
|
50
|
+
on(event: "leave", cb: (player: NetPlayer, reason: string) => void): this;
|
|
51
|
+
off(event: "leave", cb: (player: NetPlayer, reason: string) => void): this;
|
|
52
|
+
}
|
|
53
|
+
export declare const state: {
|
|
54
|
+
role: NetRole;
|
|
55
|
+
status: NetStatus;
|
|
56
|
+
isServer: boolean;
|
|
57
|
+
isClient: boolean;
|
|
58
|
+
me: NetPlayer | null;
|
|
59
|
+
players: NetPlayer[];
|
|
60
|
+
nextId: number;
|
|
61
|
+
/** a session is up: the phase hooks are installed and pump every frame */
|
|
62
|
+
active: boolean;
|
|
63
|
+
events: Map<string, Listener[]>;
|
|
64
|
+
handlers: Map<string, Listener[]>;
|
|
65
|
+
connectResolve: null | (() => void);
|
|
66
|
+
connectReject: null | ((e: Error) => void);
|
|
67
|
+
myName: string;
|
|
68
|
+
};
|
|
69
|
+
export declare const hooks: {
|
|
70
|
+
frameEarly: null | ((dt: number) => void);
|
|
71
|
+
frameFixed: null | ((dt: number) => void);
|
|
72
|
+
frameLate: null | ((dt: number) => void);
|
|
73
|
+
/** client: extra `$hello` fields (schema hash) */
|
|
74
|
+
helloExtra: null | (() => Record<string, unknown>);
|
|
75
|
+
/** server: a reject reason for this `$hello`, or null to accept */
|
|
76
|
+
helloCheck: null | ((data: any) => string | null);
|
|
77
|
+
/** server: extra `$welcome` fields (tick, kind table) */
|
|
78
|
+
welcomeExtra: null | (() => Record<string, unknown>);
|
|
79
|
+
/** server: right after `$welcome` + `$join` went out — send the live entities to the newcomer */
|
|
80
|
+
afterWelcome: null | ((p: NetPlayer) => void);
|
|
81
|
+
/** client: the `$welcome` arrived (before the connect event) */
|
|
82
|
+
onWelcome: null | ((data: any) => void);
|
|
83
|
+
/** client: a reserved `$` message the roster does not know (spawn / despawn) */
|
|
84
|
+
clientReserved: null | ((name: string, data: any) => void);
|
|
85
|
+
/** binary payloads (channel 1): inputs on the server, snapshots on the client */
|
|
86
|
+
serverBinary: null | ((p: NetPlayer, channel: number, data: ArrayBuffer) => void);
|
|
87
|
+
clientBinary: null | ((channel: number, data: ArrayBuffer) => void);
|
|
88
|
+
/** server: a player is gone (after the leave event) */
|
|
89
|
+
playerLeft: null | ((p: NetPlayer) => void);
|
|
90
|
+
/** the session ends (before the state resets); `role` = the role we are leaving */
|
|
91
|
+
reset: null | ((role: NetRole) => void);
|
|
92
|
+
};
|
|
93
|
+
export declare const emit: (event: keyof NetEvents, ...args: any[]) => void;
|
|
94
|
+
export declare const playerBySlot: (slot: number) => NetPlayer | undefined;
|
|
95
|
+
export declare const addPlayer: (id: number, name: string, slot: number) => NetPlayer;
|
|
96
|
+
export declare const removePlayer: (p: NetPlayer, reason: string) => void;
|
|
97
|
+
export declare const ensureMe: () => NetPlayer;
|
|
98
|
+
export declare const sendRaw: (slot: number, channel: number, payload: string | ArrayBuffer) => boolean;
|
|
99
|
+
export declare const queueLocal: (fn: () => void) => void;
|
|
100
|
+
export declare const dispatchMessage: (name: string, data: unknown, from: NetPlayer | null) => void;
|
|
101
|
+
export declare const deliverTo: (p: NetPlayer, msg: NetMessage<any>, data: unknown) => void;
|
|
102
|
+
export declare const broadcastRaw: (payload: string | ArrayBuffer, except: NetPlayer | null, channel?: number) => void;
|
|
103
|
+
export declare const startPhases: () => void;
|
|
104
|
+
export declare const stopPhases: () => void;
|
|
105
|
+
export declare const resetToOffline: () => void;
|
|
106
|
+
export declare const pump: () => void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { NetPlayer, type NetEvents, type NetLaunch, type NetMessage, type NetRole, type NetStatus } from "./core";
|
|
2
|
+
import { NetEntity, Replicated, stats, type NetInput, type NetKind, type NetTransform } from "./replication";
|
|
3
|
+
export { NetPlayer, NetEntity, Replicated };
|
|
4
|
+
export type { NetEvents, NetLaunch, NetMessage, NetRole, NetStatus, NetInput, NetKind, NetTransform };
|
|
5
|
+
declare class NetImpl {
|
|
6
|
+
get role(): NetRole;
|
|
7
|
+
get status(): NetStatus;
|
|
8
|
+
get isServer(): boolean;
|
|
9
|
+
get isClient(): boolean;
|
|
10
|
+
/** True on hosts that ship the transport (desktop, the 3d/full Android variants, iOS). Web: false. */
|
|
11
|
+
get supported(): boolean;
|
|
12
|
+
/** What the exe was launched as (`--server --port N` / `--connect ADDR`), or null. */
|
|
13
|
+
get launch(): NetLaunch | null;
|
|
14
|
+
get me(): NetPlayer;
|
|
15
|
+
get players(): readonly NetPlayer[];
|
|
16
|
+
player(id: number): NetPlayer | undefined;
|
|
17
|
+
/** Our round trip to the server (client), 0 otherwise. */
|
|
18
|
+
get rtt(): number;
|
|
19
|
+
/** The simulation tick — one per fixed step (`updateFixed`). The server's is THE tick; a client
|
|
20
|
+
* runs a few ticks ahead so its inputs arrive in time. */
|
|
21
|
+
get tick(): number;
|
|
22
|
+
/** Live counters: snapshots, input lead / `ahead`, corrections, missed inputs, bytes out. */
|
|
23
|
+
get stats(): typeof stats;
|
|
24
|
+
/** Start serving on `port`. From offline this makes us the host (a player who is also the
|
|
25
|
+
* server); on the dedicated exe (`Net.launch.role === "server"`) there is no local player. */
|
|
26
|
+
listen(opts?: {
|
|
27
|
+
port?: number;
|
|
28
|
+
maxClients?: number;
|
|
29
|
+
name?: string;
|
|
30
|
+
dedicated?: boolean;
|
|
31
|
+
}): boolean;
|
|
32
|
+
/** Connect to a host/server (`address` = "ip:port"). Resolves once the server welcomed us. */
|
|
33
|
+
connect(target: {
|
|
34
|
+
address: string;
|
|
35
|
+
}, opts?: {
|
|
36
|
+
name?: string;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
/** Client → offline. Host/server → everyone is dropped, back to offline. */
|
|
39
|
+
disconnect(): void;
|
|
40
|
+
/** Declare a message type once; the name is the wire id. `unreliable` = channel 1 (fire-and-forget). */
|
|
41
|
+
message<T = void>(name: string, opts?: {
|
|
42
|
+
unreliable?: boolean;
|
|
43
|
+
}): NetMessage<T>;
|
|
44
|
+
/** Client → server (offline / host: delivered in-process, `from` = our own player). */
|
|
45
|
+
send<T>(msg: NetMessage<T>, data: T): void;
|
|
46
|
+
/** Server → every player (incl. the host's own), minus `except`. */
|
|
47
|
+
broadcast<T>(msg: NetMessage<T>, data: T, opts?: {
|
|
48
|
+
except?: NetPlayer | null;
|
|
49
|
+
}): void;
|
|
50
|
+
/** Subscribe to a built-in event or to a message (`from` = the sending player on the server,
|
|
51
|
+
* null on a client — the server sent it). Returns `Net` for chaining. */
|
|
52
|
+
on<K extends keyof NetEvents>(event: K, cb: NetEvents[K]): this;
|
|
53
|
+
on<T>(msg: NetMessage<T>, cb: (data: T, from: NetPlayer | null) => void): this;
|
|
54
|
+
off<K extends keyof NetEvents>(event: K, cb: NetEvents[K]): this;
|
|
55
|
+
off<T>(msg: NetMessage<T>, cb: (data: T, from: NetPlayer | null) => void): this;
|
|
56
|
+
/** The per-tick input layout (one per game): `const PlayerInput = Net.input({ moveX: 0, moveY: 0, jump: false })`.
|
|
57
|
+
* Fields: number → f32, boolean → 1 bit, number[] → f32 × length. */
|
|
58
|
+
input<T extends object>(defaults: T): NetInput<T>;
|
|
59
|
+
/** Set this tick's input — from `updateFixed`, once per tick, on the machine that owns the player
|
|
60
|
+
* (client / host / offline). The owner's sim reads it back through `rep.input(PlayerInput)`; a
|
|
61
|
+
* client also ships it to the server for the same tick. */
|
|
62
|
+
setInput<T extends object>(inp: NetInput<T>, values: Partial<T>): void;
|
|
63
|
+
/** A replicated entity type: the defaults are the snapshot layout (same field rules as `input`),
|
|
64
|
+
* `transform` tells the SDK which fields mirror the node's pose, `client` births the proxy on a
|
|
65
|
+
* client when the server spawns one (`new Node().aspect(Replicated, { kind, owner })`). */
|
|
66
|
+
kind<S extends object>(name: string, defaults: S, opts?: {
|
|
67
|
+
transform?: NetTransform;
|
|
68
|
+
client?: (rep: NetEntity<S>, scene: any) => any;
|
|
69
|
+
}): NetKind<S>;
|
|
70
|
+
/** Every replicated entity this machine knows. */
|
|
71
|
+
get entities(): readonly NetEntity[];
|
|
72
|
+
entity(netId: number): NetEntity | undefined;
|
|
73
|
+
/** Dev only: yojimbo's network simulator on our side of the wire (latency/jitter in ms, loss in %). */
|
|
74
|
+
simulate(opts: {
|
|
75
|
+
latency?: number;
|
|
76
|
+
jitter?: number;
|
|
77
|
+
loss?: number;
|
|
78
|
+
}): void;
|
|
79
|
+
}
|
|
80
|
+
export declare const Net: NetImpl;
|