import * as THREE from 'three'; import RAPIER from '@dimforge/rapier3d-compat'; import { createNoise2D, createNoise3D, createNoise4D } from 'simplex-noise'; import { spawn } from './core/spawn'; import { InputState } from './core/input'; import { addCollisionEvent } from './core/systems/collision'; import { addSystem, ECSContext, getModule } from './core/ecs'; import { registerArchetype } from './modules/archetype'; import { Inventory, InventoryChangeCallback } from './core/inventory'; import EventEmitter from './utils/eventEmitter'; import TriggerInput, { TriggerInputKey } from './core/triggerInput'; import type { EditorTaskStore } from './core/ui/editor/TaskStore'; import { type ScreenshotOptions, type ScreenshotResult } from './core/render/screenshot'; import { type FrameSelectionOptions, type ViewportCameraPose, type ViewportCameraSetOptions } from './core/viewportCamera'; import { initialize } from './core/initializeWorld'; import { type WorldDefinition } from './core/worldSchema'; import { type RuntimeModuleTypeDefinition as PersistedRuntimeModuleTypeDefinition, type RuntimeModuleTypeCatalogEntry, type RuntimeModuleInstanceCatalogEntry } from './core/runtimeModuleTypes'; import type { EditorSessionConfig } from './core/editor/sessionConfig'; export type { InputState } from './core/input'; export { SETTINGS_KEYS, RENDER_SCALES, getMouseSensitivity, setMouseSensitivity, getSSAOQuality, setSSAOQuality, getAntialias, setAntialias, getShadowQuality, setShadowQuality, getBryceMode, setBryceMode, getRenderScale, setRenderScale, getUseLights, setUseLights } from './core/settings'; export type { RenderScale, SSAOQuality, ShadowQuality } from './core/settings'; export { initialize, createWorldDefinition } from './core/initializeWorld'; export { serializeWorld } from './core/serializeWorld'; export { saveWorldToFile, loadWorldFromFile, serializeWorldToJSON, loadWorldFromJSON } from './core/worldPersistence'; export type { WorldDefinition, InitializeWorldOptions, SerializeWorldOptions, AchievementDefinition, DimensionDefinition, ChunkDefinition, PlayerState, RuntimeModuleTypeDefinition, } from './core/worldSchema'; export { registerRuntimeModuleType, unregisterRuntimeModuleType, listRuntimeModuleTypes, getPersistedRuntimeModuleType, upsertRuntimeModuleInstance, removeRuntimeModuleInstance, listRuntimeModuleInstances, } from './core/runtimeModuleTypes'; export declare enum EngineMode { GAME = "game", DISPLAY = "display", EDITOR = "editor" } export declare enum LifecycleEvent { LOAD_WORLD = "load_world", QUIT = "quit", PLAYER_DEATH = "player_death" } export declare enum DebugState { NONE = "none", PERF = "perf", PHYSICS = "physics", AI = "ai" } export { setupWebControls } from './setupWebControls'; export { setupTouchControls } from './setupTouchControls'; export { KILL_PLANE_Y } from './core/systems/killPlane'; export declare const ENGINE_UI_ROOT_ID = "engine-ui-root"; export { EditorProvider, useEditor, useSelectedEntity, useSelectedEntities } from './core/ui/editor/EditorContext'; export { Toolbar } from './core/ui/editor/Toolbar'; export { HierarchyPanel } from './core/ui/editor/HierarchyPanel'; export { InspectorPanel } from './core/ui/editor/InspectorPanel'; export { TransformEditor } from './core/ui/editor/TransformEditor'; export { ComponentInspector } from './core/ui/editor/ComponentInspector'; export { BodyEditor } from './core/ui/editor/BodyEditor'; export { WorldInspector } from './core/ui/editor/WorldInspector'; export { WorldSettingsPanel } from './core/ui/editor/WorldSettingsPanel'; export { ArchetypeBrowser } from './core/ui/editor/ArchetypeBrowser'; export { GenericComponentEditor } from './core/ui/editor/GenericComponentEditor'; export { Vector3Input } from './core/ui/editor/components/Vector3Input'; export { CommandManager } from './core/editor/CommandManager'; export { PlayModeController } from './core/editor/PlayModeController'; export { ComponentEditorRegistry, componentEditorRegistry } from './core/editor/ComponentEditorRegistry'; export { resolveEditorSessionConfig, getResolvedEditorSessionConfig } from './core/editor/sessionConfig'; export { TransformCommand } from './core/editor/commands/TransformCommand'; export { AddEntityCommand, DeleteEntityCommand, DuplicateEntityCommand } from './core/editor/commands/EntityCommand'; export { ModifyBodyCommand } from './core/editor/commands/BodyCommand'; export { ModifyWorldSettingsCommand } from './core/editor/commands/WorldSettingsCommand'; export { ReinitializeWorldCommand } from './core/editor/commands/ReinitializeWorldCommand'; export { ModifyComponentCommand } from './core/editor/commands/ModifyComponentCommand'; export * from './automation/definitions'; export * from './core/editor/schema'; export * from './core/ui/editor/fieldRenderers'; export type { EditorState, EditorTool, EditorMode } from './core/editor/EditorState'; export type { EditorSessionConfig, EditorSessionScope, EditorSessionCapabilities, ResolvedEditorSessionConfig } from './core/editor/sessionConfig'; export type { EditorCommand } from './core/editor/CommandManager'; export type { EditorContextValue } from './core/ui/editor/EditorContext'; export type { ComponentEditorProps, ComponentEditorComponent } from './core/editor/ComponentEditorRegistry'; export type { EditorTaskCommand, EditorTaskItem, EditorTaskMessage, EditorTaskSnapshot, EditorTaskStore, } from './core/ui/editor/TaskStore'; export type ConsoleCommand = (...args: string[]) => Promise | string | null | undefined; import { type AutomationCommandCall } from './automation/commands'; import type { AutomationCommandParameter } from './automation/commands'; export type { AutomationResource } from './automation/resources'; export type { AutomationCommand, AutomationCommandParameter } from './automation/commands'; export interface EngineConfig { /** @deprecated Use mode instead */ display?: boolean; mode?: EngineMode; hudVisible?: boolean; /** Optional hook for editor UI to open the web-layer composer */ onRequestComposer?: () => void; /** Optional hook for editor UI to save world to Cloud Storage (Milestone 1.2) */ onSaveWorld?: (worldId: string) => Promise; /** Optional hook for editor exports in embedded/live environments */ onExportBlob?: (payload: { blob: Blob; filename: string; mimeType?: string; }) => Promise<{ path?: string; url?: string; message?: string; } | void>; /** Optional hook for editor UI to open a new-tab play session */ onOpenPlayMode?: (mode: 'game' | 'display') => void; /** Optional hook for editor UI to list available assets */ onListAssets?: () => Promise; /** Optional hook for editor UI to upload a new asset */ onUploadAsset?: (file: File) => Promise; /** Optional editor task store for task history UI */ taskStore?: EditorTaskStore; /** Optional session scoping for the shared editor UI */ editorSessionConfig?: EditorSessionConfig; /** Enable WebXR hooks and APIs */ enableXR?: boolean; /** Default session init options when entering XR */ xrSessionInit?: XRSessionInit; /** Default session mode when entering XR */ xrSessionMode?: XRSessionMode; /** Optional runtime settings overrides (keys from SETTINGS_KEYS). */ settingsOverrides?: Record; /** Custom console commands to register */ consoleCommands?: Record; } export type SkyboxObjects = { skybox: THREE.Mesh; ambientLight: THREE.AmbientLight; directionalLight: THREE.DirectionalLight | null; lightTarget: THREE.Object3D | null; }; export type DeathScreenButton = { text: string; callback: () => void; }; export type PlayerDeathEvent = { playerEid: number; killerEid?: number; killerName?: string; }; export type EditorAssetType = 'model'; export type EditorAssetRecord = { id: string; name: string; type: EditorAssetType; format: string; url: string; storagePath: string; contentType?: string; sizeBytes?: number; updatedAt?: number; createdAt?: number; }; export interface EngineAPI { scene: THREE.Scene; worldRoot: THREE.Group; camera: THREE.PerspectiveCamera; renderer: THREE.WebGLRenderer; /** Active XR session camera controller */ physicsWorld: RAPIER.World; THREE: typeof THREE; RAPIER: typeof RAPIER; createNoise2D: typeof createNoise2D; createNoise3D: typeof createNoise3D; createNoise4D: typeof createNoise4D; /** ECS world instance */ ecsWorld: ECSContext; /** spawn an entity from an archetype or bundle */ spawn: typeof spawn; /** initialize world from declarative definition */ initialize: typeof initialize; /** register a new archetype */ registerArchetype: typeof registerArchetype; /** register additional ECS systems */ addSystem: typeof addSystem; /** add a resource to the engine */ setResource: (name: string, resource: R, disposeFn?: (res: R) => void) => void; /** get a resource by name */ getResource: (name: string, hideWarnings?: boolean) => R | undefined; /** get a module by name */ getModule: typeof getModule; /** register a persisted runtime module type backed by factory source */ registerRuntimeModuleType: (definition: PersistedRuntimeModuleTypeDefinition) => PersistedRuntimeModuleTypeDefinition; /** unregister a persisted runtime module type */ unregisterRuntimeModuleType: (moduleName: string, typeName: string) => boolean; /** register or replace a named module instance */ registerRuntimeModuleInstance: (moduleName: string, instanceName: string, definition: { type: string; params: any; }) => void; /** remove a named module instance */ unregisterRuntimeModuleInstance: (moduleName: string, instanceName: string) => boolean; /** list all registered module types */ listRuntimeModuleTypes: () => RuntimeModuleTypeCatalogEntry[]; /** list all named module instances */ listRuntimeModuleInstances: () => RuntimeModuleInstanceCatalogEntry[]; /** current generic input state */ input: InputState; /** update input state */ updateInput: (data: Partial) => void; /** current trigger input state */ triggerInput: TriggerInput; /** set a trigger input state */ setTriggerInput: (key: TriggerInputKey) => void; /** add a collision event callback */ addCollisionEvent: typeof addCollisionEvent; /** get the player inventory */ getPlayerInventory: () => Inventory | undefined; /** render a preview image for an entity definition */ getPreview: (def: Record) => string; /** select active hotbar slot */ selectHotbarSlot: (index: number) => void; /** subscribe to inventory changes for an entity */ onInventoryChange: (eid: number, cb: InventoryChangeCallback) => () => void; /** subscribe to the player inventory */ onPlayerInventoryChange: (cb: InventoryChangeCallback) => () => void; /** get the current player entity id */ getPlayerEid: () => number | undefined; lifecycleEvents: EventEmitter; canvas?: HTMLCanvasElement; isDebugMode: () => boolean; isHUDVisible: () => boolean; /** Whether an XR session is currently presenting */ isXRSessionActive: () => boolean; /** Check if XR is supported in this browser/environment */ isXRSupported: () => Promise; /** Request entry into an immersive XR session */ enterXR: (mode?: XRSessionMode, sessionInit?: XRSessionInit) => Promise; /** Exit an active XR session */ exitXR: () => Promise; /** Get the current XR session */ getXRSession: () => XRSession | null; /** configure death screen buttons */ setDeathScreenButtons: (buttons: DeathScreenButton[]) => void; getConfig: () => EngineConfig; /** save world state to a JSON file */ saveWorldToFile: (filename?: string) => WorldDefinition; /** load world state from a file (opens file picker), returns world script for loadWorld */ loadWorldFromFile: (onLoad: (worldScript: string) => void, onError?: (error: Error) => void) => void; /** serialize world to JSON string */ serializeWorldToJSON: () => string; /** serialize world to WorldDefinition object with options */ serializeWorld: (options?: { includeEntities?: boolean; includeRuntime?: boolean; }) => WorldDefinition; /** load world from JSON string, returns world script for loadWorld */ loadWorldFromJSON: (json: string) => string; /** capture a screenshot of the current world viewport */ captureWorldScreenshot: (options?: ScreenshotOptions) => ScreenshotResult; /** capture a screenshot of a specific entity */ captureEntityScreenshot: (eid: number, options?: ScreenshotOptions) => ScreenshotResult; /** read the current viewport camera pose */ getViewportCamera: () => ViewportCameraPose; /** update the current viewport camera pose */ setViewportCamera: (options: ViewportCameraSetOptions) => ViewportCameraPose; /** frame the viewport camera around an entity */ frameViewportEntity: (eid: number, options?: FrameSelectionOptions) => ViewportCameraPose; /** frame the viewport camera around arbitrary bounds */ frameViewportBounds: (bounds: { center: { x: number; y: number; z: number; }; size: { x: number; y: number; z: number; }; }, options?: FrameSelectionOptions) => ViewportCameraPose; /** register a handler used by the Render Inspector to upscale screenshots */ setImageUpscaleHandler: (handler: ((payload: ImageUpscaleRequest) => Promise) | null, meta?: ImageUpscaleMeta | null) => void; /** get metadata for the current image upscale handler */ getImageUpscaleMeta: () => ImageUpscaleMeta | null; /** set available image upscale models */ setImageUpscaleModels: (models: ImageUpscaleModelOption[]) => void; /** get available image upscale models */ getImageUpscaleModels: () => ImageUpscaleModelOption[]; /** set active image upscale model id */ setActiveImageUpscaleModelId: (modelId: string) => void; /** get active image upscale model id */ getActiveImageUpscaleModelId: () => string | null; /** request image upscale using the registered handler */ upscaleImage: (payload: ImageUpscaleRequest) => Promise; /** Automation interface for structured inspection and editing */ automation: { getResource: (name: string, params?: Record) => any; executeCommand: (name: string, params: any) => Promise; executeBatch: (calls: AutomationCommandCall[], description?: string) => Promise; listResources: () => Array<{ name: string; description: string; }>; listCommands: () => Array<{ name: string; description: string; parameters: AutomationCommandParameter[]; }>; }; /** load world directly from WorldDefinition (bypasses script generation) */ loadWorldFromDefinition: (worldDefinition: WorldDefinition) => Promise; /** hot-reload a world script */ loadWorld: (code: string) => Promise; /** dispose and cleanup the engine */ dispose: () => void; } export interface ImageUpscaleRequest { dataUrl: string; prompt?: string; scope?: 'world' | 'entity'; eid?: number; modelId?: string | null; } export interface ImageUpscaleResult extends ScreenshotResult { modelId?: string; modelName?: string; } export interface ImageUpscaleMeta { modelId?: string; modelName?: string; supportsImageGeneration?: boolean; activeModelId?: string | null; } export interface ImageUpscaleModelOption { id: string; name: string; supportsImageGeneration: boolean; } export interface WorldScript { setupScene?(api: EngineAPI): void; run?(api: EngineAPI): void; tick?(delta: number, api: EngineAPI): void; } export declare function loadDependencies(): Promise; export declare function startEngine(canvas: HTMLCanvasElement, config?: EngineConfig): EngineAPI & { loadWorld: (code: string) => Promise; loadWorldFromDefinition: (worldDefinition: WorldDefinition) => Promise; dispose: () => Promise; }; //# sourceMappingURL=index.d.ts.map