import { Loader } from './Loader.js'; import { Camera, CameraAttribute } from './objects/Camera.js'; import { Rectangle } from './objects/Rectangle.js'; import { Ellipse } from './objects/Ellipse.js'; import { Text } from './objects/Text.js'; import { LeviarObject } from './LeviarObject.js'; import { LeviarImage } from './objects/LeviarImage.js'; import { LeviarVideo } from './objects/LeviarVideo.js'; import { Sprite } from './objects/Sprite.js'; import { Particle } from './objects/Particle.js'; import type { ParticleOptions } from './objects/Particle.js'; import { SpriteManager } from './SpriteManager.js'; import { VideoManager } from './VideoManager.js'; import { ParticleManager } from './ParticleManager.js'; import type { LeviarObjectOptions, WorldEvents } from './types.js'; import type { RectangleOptions } from './objects/Rectangle.js'; import { EventEmitter } from './EventEmitter.js'; export interface WorldOptions { /** 캔버스 엘리먼트. 지정하지 않으면 자동으로 생성합니다. */ canvas?: HTMLCanvasElement; /** * 브라우저 기본 우클릭 메뉴를 막을지 여부. * true로 설정해도 LeviarObject의 'contextmenu' 이벤트는 정상적으로 수신됩니다. * @default true */ disableContextMenu?: boolean; } export declare class World extends EventEmitter { private renderer; private objects; private rafId; private physics; private _canvas; /** 현재 포커스 중인 카메라 (지정되지 않으면 객체 중 Camera를 찾습니다) */ private _activeCamera; /** 물리 엔진의 중력 프로퍼티 프록시 */ private _gravityProxy; /** mouseover 상태 추적 (객체 id → boolean) */ private _mouseOver; /** destroy 호출 여부 — true이면 모든 공개 메서드가 즉시 반환됩니다 */ private _destroyed; /** 캔버스에 등록된 마우스 이벤트 핸들러 (destroy 시 제거용) */ private _mouseEventHandlers; /** 브라우저 기본 컨텍스트 메뉴 비활성화 여부 */ disableContextMenu: boolean; /** 스프라이트 애니메이션 클립 매니저 */ readonly spriteManager: SpriteManager; /** 비디오 클립 매니저 */ readonly videoManager: VideoManager; /** 파티클 클립 매니저 */ readonly particleManager: ParticleManager; /** 에셋 로더 */ readonly loader: Loader; /** 모든 Loader에서 로드된 에셋의 통합 맵 */ private _assets; constructor(canvasOrOptions?: HTMLCanvasElement | WorldOptions); private createCanvas; /** * 캔버스상의 정확한 내부 마우스 좌표를 계산합니다. (object-fit: contain 보정 포함) */ private _getCanvasMousePos; private _setupMouseEvents; /** * 화면좌표 기준으로 마우스 위치에 겹쳐지는 객체를 반환합니다. (AABB hit-test) */ private _getHitObjects; /** * 월드에 연결된 캔버스 엘리먼트를 반환합니다. */ get canvas(): HTMLCanvasElement | null; /** * 월드의 중력 x, y 값. 직접 수정하거나 새 객체를 할당할 수 있습니다. */ get gravity(): { x: number; y: number; }; set gravity(g: { x: number; y: number; }); /** * 월드의 활성 카메라 객체를 반환합니다. */ get camera(): Camera | null; /** * 월드의 카메라를 특정 객체로 지정합니다. 카메라 객체만 지정할 수 있습니다. * `null`을 할당하면 기본 동작으로 돌아갑니다. */ set camera(camera: Camera | null); /** * 디버그 모드 활성화 여부를 반환합니다. */ get debugMode(): boolean; /** * 디버그 모드를 활성화하거나 비활성화합니다. * 활성화 시 각 오브젝트의 실제 렌더 경계(outline)와 margin 영역이 * 기존 스타일을 건드리지 않고 별도 레이어로 시각화됩니다. */ set debugMode(value: boolean); /** * CSS querySelector와 유사한 방식으로 오브젝트를 선택합니다. * 지원 셀렉터: `.className`, `#id`, `[attribute=value]` */ select(query: string): LeviarObject[]; /** * 에셋 로더를 생성합니다. 로드 완료 시 World 내부 에셋 맵에 자동으로 병합됩니다. * @deprecated world.loader를 직접 사용하십시오. */ createLoader(): Loader; private _registerObject; createCamera = Record>(options?: LeviarObjectOptions): Camera; createRectangle = Record>(options?: RectangleOptions): Rectangle; createEllipse = Record>(options?: LeviarObjectOptions, D>): Ellipse; createText = Record>(options?: LeviarObjectOptions, D>): Text; createImage = Record>(options?: LeviarObjectOptions, D>): LeviarImage; createVideo = Record>(options?: LeviarObjectOptions, D>): LeviarVideo; createSprite = Record>(options?: LeviarObjectOptions, D>): Sprite; createParticle = Record>(options?: ParticleOptions): Particle; removeObject(obj: LeviarObject): void; /** * 렌더 루프를 시작합니다. 파괴된 월드에서는 아무것도 하지 않습니다. * @returns this */ start(): this; /** * 렌더 루프를 중지합니다. 재시작은 start() 호출로 가능합니다. * @returns this */ stop(): this; /** * 월드가 파괴되었는지 여부를 반환합니다. */ get destroyed(): boolean; /** * 월드를 완전히 파괴합니다. * 렌더 루프를 중지하고, 모든 비디오를 정지하며, 에셋의 Blob URL을 해제하고, * 물리 엔진·매니저·렌더러(WebGL 컨텍스트 포함)를 정리합니다. * 호출 후 이 World 인스턴스는 다시 사용할 수 없습니다. */ destroy(): void; /** * 객체의 Z 좌표 또는 zIndex 변경 시 Z-Sort 캐시를 무효화합니다. */ private _trackSortDirty; private _tryAddPhysics; }