MCPcopy Create free account
hub / github.com/esengine/esengine / CameraManagerImpl

Class CameraManagerImpl

packages/camera/src/CameraManager.ts:87–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85 * ```
86 */
87export class CameraManagerImpl implements ICameraManager {
88 private _scene: IScene | null = null;
89 private _viewportWidth: number = 800;
90 private _viewportHeight: number = 600;
91 private _mainCameraEntity: Entity | null = null;
92 private _mainCameraEntityDirty: boolean = true;
93
94 /**
95 * 设置场景引用
96 * Set scene reference
97 */
98 setScene(scene: IScene | null): void {
99 this._scene = scene;
100 this._mainCameraEntityDirty = true;
101 this._mainCameraEntity = null;
102 }
103
104 /**
105 * 设置视口尺寸
106 * Set viewport size
107 */
108 setViewportSize(width: number, height: number): void {
109 this._viewportWidth = Math.max(1, width);
110 this._viewportHeight = Math.max(1, height);
111 }
112
113 /**
114 * 获取视口宽度
115 * Get viewport width
116 */
117 get viewportWidth(): number {
118 return this._viewportWidth;
119 }
120
121 /**
122 * 获取视口高度
123 * Get viewport height
124 */
125 get viewportHeight(): number {
126 return this._viewportHeight;
127 }
128
129 /**
130 * 获取视口宽高比
131 * Get viewport aspect ratio
132 */
133 get aspectRatio(): number {
134 return this._viewportWidth / this._viewportHeight;
135 }
136
137 /**
138 * 标记主相机需要重新查找
139 * Mark main camera as dirty (needs re-lookup)
140 */
141 invalidateMainCamera(): void {
142 this._mainCameraEntityDirty = true;
143 }
144

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected