import { EventBus } from '../core/EventBus';
import type { EntityId, Color } from '../core/types';
export interface Vec3 {
    x: number;
    y: number;
    z: number;
}
export interface Quaternion {
    x: number;
    y: number;
    z: number;
    w: number;
}
export declare const v3: {
    create: (x?: number, y?: number, z?: number) => Vec3;
    zero: () => Vec3;
    one: () => Vec3;
    clone: (a: Vec3) => Vec3;
    add: (a: Vec3, b: Vec3) => Vec3;
    sub: (a: Vec3, b: Vec3) => Vec3;
    scale: (a: Vec3, s: number) => Vec3;
    dot: (a: Vec3, b: Vec3) => number;
    cross: (a: Vec3, b: Vec3) => Vec3;
    length: (a: Vec3) => number;
    normalize: (a: Vec3) => Vec3;
    dist: (a: Vec3, b: Vec3) => number;
    lerp: (a: Vec3, b: Vec3, t: number) => Vec3;
    negate: (a: Vec3) => Vec3;
    min: (a: Vec3, b: Vec3) => Vec3;
    max: (a: Vec3, b: Vec3) => Vec3;
};
export declare const quat: {
    identity: () => Quaternion;
    fromEuler: (x: number, y: number, z: number) => Quaternion;
    multiply: (a: Quaternion, b: Quaternion) => Quaternion;
    normalize: (q: Quaternion) => Quaternion;
    slerp: (a: Quaternion, b: Quaternion, t: number) => Quaternion;
    /** Rotate a Vec3 by quaternion. */
    rotateVec3: (q: Quaternion, v: Vec3) => Vec3;
};
export interface Transform3D {
    entityId: EntityId;
    position: Vec3;
    rotation: Quaternion;
    scale: Vec3;
}
export type MeshPrimitive = 'box' | 'sphere' | 'capsule' | 'cylinder' | 'plane' | 'custom';
export interface MeshComponent {
    entityId: EntityId;
    primitive: MeshPrimitive;
    /** Custom mesh asset ID (when primitive = 'custom'). */
    assetId: string | null;
    castShadow: boolean;
    receiveShadow: boolean;
    visible: boolean;
}
export type LightType = 'directional' | 'point' | 'spot' | 'ambient';
export interface LightComponent {
    entityId: EntityId;
    lightType: LightType;
    color: Color;
    intensity: number;
    range: number;
    spotAngle: number;
    castShadow: boolean;
}
export type CameraMode3D = 'perspective' | 'orthographic';
export interface Camera3DComponent {
    entityId: EntityId;
    mode: CameraMode3D;
    fov: number;
    near: number;
    far: number;
    orthoSize: number;
}
export interface Material3D {
    id: string;
    name: string;
    albedoColor: Color;
    metallic: number;
    roughness: number;
    emissiveColor: Color;
    emissiveIntensity: number;
    albedoTextureId: string | null;
    normalTextureId: string | null;
    metallicRoughnessTextureId: string | null;
    transparent: boolean;
    opacity: number;
}
export declare class World3D {
    readonly events: EventBus;
    private transforms;
    private meshes;
    private lights;
    private cameras;
    private materials;
    private _nextId;
    createTransform(overrides?: Partial<Transform3D>): Transform3D;
    addMesh(entityId: EntityId, primitive?: MeshPrimitive, assetId?: string | null): MeshComponent;
    addLight(entityId: EntityId, lightType?: LightType, color?: Color): LightComponent;
    addCamera(entityId: EntityId, mode?: CameraMode3D): Camera3DComponent;
    getTransform(id: EntityId): Transform3D | undefined;
    getMesh(id: EntityId): MeshComponent | undefined;
    getLight(id: EntityId): LightComponent | undefined;
    getCamera(id: EntityId): Camera3DComponent | undefined;
    allTransforms(): Transform3D[];
    allMeshes(): MeshComponent[];
    allLights(): LightComponent[];
    allCameras(): Camera3DComponent[];
    registerMaterial(mat: Material3D): void;
    getMaterial(id: string): Material3D | undefined;
    allMaterials(): Material3D[];
    static createDefaultMaterial(name?: string): Material3D;
    removeEntity(id: EntityId): void;
    clear(): void;
}
export type CameraController = 'fps' | 'third-person' | 'orbit' | 'fly';
export interface Camera3DSettings {
    controller: CameraController;
    position: Vec3;
    target: Vec3;
    up: Vec3;
    fov: number;
    near: number;
    far: number;
    /** Only for orbit / third-person */
    distance: number;
    /** Orbit angle in radians (yaw, pitch). */
    yaw: number;
    pitch: number;
    minPitch: number;
    maxPitch: number;
    sensitivity: number;
    smoothing: number;
}
export declare function createDefaultCamera3DSettings(controller?: CameraController): Camera3DSettings;
export declare function updateOrbitCamera(settings: Camera3DSettings, dt: number): void;
export type ColliderShape3D = 'box' | 'sphere' | 'capsule' | 'cylinder' | 'trimesh' | 'convex';
export type RigidBodyType3D = 'dynamic' | 'static' | 'kinematic';
export interface Collider3DDef {
    shape: ColliderShape3D;
    halfExtents?: Vec3;
    radius?: number;
    halfHeight?: number;
    isTrigger: boolean;
    friction: number;
    restitution: number;
}
export interface RigidBody3DDef {
    bodyType: RigidBodyType3D;
    mass: number;
    linearDamping: number;
    angularDamping: number;
    gravityScale: number;
    lockRotationX: boolean;
    lockRotationY: boolean;
    lockRotationZ: boolean;
}
export interface PhysicsWorld3DConfig {
    gravity: Vec3;
    timestep: number;
}
/** Abstract 3D physics backend. Implement with Rapier.js, Cannon.js, etc. */
export interface PhysicsBackend3D {
    init(config: PhysicsWorld3DConfig): void;
    step(dt: number): void;
    addRigidBody(entityId: EntityId, def: RigidBody3DDef, position: Vec3, rotation: Quaternion): void;
    removeRigidBody(entityId: EntityId): void;
    addCollider(entityId: EntityId, def: Collider3DDef): void;
    removeCollider(entityId: EntityId): void;
    getPosition(entityId: EntityId): Vec3 | null;
    getRotation(entityId: EntityId): Quaternion | null;
    setPosition(entityId: EntityId, pos: Vec3): void;
    setRotation(entityId: EntityId, rot: Quaternion): void;
    applyForce(entityId: EntityId, force: Vec3): void;
    applyImpulse(entityId: EntityId, impulse: Vec3): void;
    setLinearVelocity(entityId: EntityId, vel: Vec3): void;
    getLinearVelocity(entityId: EntityId): Vec3 | null;
    /** Raycast and return first hit. */
    raycast(origin: Vec3, direction: Vec3, maxDist: number): RaycastHit3D | null;
    destroy(): void;
}
export interface RaycastHit3D {
    entityId: EntityId;
    point: Vec3;
    normal: Vec3;
    distance: number;
}
/** Simple physics world that delegates to a backend. */
export declare class PhysicsWorld3D {
    readonly events: EventBus;
    private backend;
    readonly config: PhysicsWorld3DConfig;
    constructor(config?: Partial<PhysicsWorld3DConfig>);
    setBackend(backend: PhysicsBackend3D): void;
    step(dt: number): void;
    addBody(entityId: EntityId, body: RigidBody3DDef, position: Vec3, rotation: Quaternion): void;
    addCollider(entityId: EntityId, def: Collider3DDef): void;
    removeBody(entityId: EntityId): void;
    getTransform(entityId: EntityId): {
        position: Vec3;
        rotation: Quaternion;
    } | null;
    applyForce(entityId: EntityId, force: Vec3): void;
    applyImpulse(entityId: EntityId, impulse: Vec3): void;
    raycast(origin: Vec3, direction: Vec3, maxDist?: number): RaycastHit3D | null;
    destroy(): void;
}
/** Abstract 3D renderer backend. Implement with Three.js, Babylon.js, etc. */
export interface RendererBackend3D {
    init(canvas: HTMLCanvasElement): void;
    resize(width: number, height: number): void;
    render(world: World3D, cameraSettings: Camera3DSettings): void;
    /** Sync mesh entity from World3D into the render scene. */
    syncEntity(entityId: EntityId, transform: Transform3D, mesh?: MeshComponent): void;
    /** Sync light into the render scene. */
    syncLight(entityId: EntityId, transform: Transform3D, light: LightComponent): void;
    setMaterial(entityId: EntityId, material: Material3D): void;
    removeEntity(entityId: EntityId): void;
    setSkybox(textureIds: string[]): void;
    setAmbientLight(color: Color, intensity: number): void;
    /** Enable/disable shadows globally. */
    setShadows(enabled: boolean): void;
    dispose(): void;
}
/** 3D Renderer that delegates to a swappable backend (Three.js, etc). */
export declare class Renderer3D {
    private backend;
    private canvas;
    setBackend(backend: RendererBackend3D): void;
    init(canvas: HTMLCanvasElement): void;
    resize(width: number, height: number): void;
    render(world: World3D, camera: Camera3DSettings): void;
    setMaterial(entityId: EntityId, material: Material3D): void;
    removeEntity(entityId: EntityId): void;
    dispose(): void;
}
export interface CharacterControllerConfig {
    height: number;
    radius: number;
    stepHeight: number;
    slopeLimit: number;
    moveSpeed: number;
    jumpForce: number;
    gravity: number;
    groundCheckDistance: number;
}
export declare const DEFAULT_CHARACTER_CONFIG: CharacterControllerConfig;
export interface CharacterState {
    velocity: Vec3;
    grounded: boolean;
    jumping: boolean;
}
/** Simple character controller for FPS / third-person games. */
export declare function updateCharacterController(state: CharacterState, input: {
    moveX: number;
    moveZ: number;
    jump: boolean;
}, config: CharacterControllerConfig, dt: number): Vec3;
