80 lines
2.4 KiB
TypeScript
80 lines
2.4 KiB
TypeScript
export interface SourceVec2 {
|
|
x: number;
|
|
y: number;
|
|
}
|
|
|
|
export interface SourceVec3 extends SourceVec2 {
|
|
z: number;
|
|
}
|
|
|
|
export interface SourceNodeTransform {
|
|
position: SourceVec3;
|
|
scale: SourceVec3;
|
|
euler: SourceVec3;
|
|
size: SourceVec2;
|
|
pivot: SourceVec2;
|
|
}
|
|
|
|
export interface CreatorNodeTransform extends SourceNodeTransform {
|
|
layer: number;
|
|
}
|
|
|
|
export interface SourceCameraState {
|
|
position: SourceVec3;
|
|
orthographicHeight: number;
|
|
near: number;
|
|
far: number;
|
|
visibility: number;
|
|
}
|
|
|
|
export const SOURCE_DESIGN_WIDTH = 720;
|
|
export const SOURCE_DESIGN_HEIGHT = 1280;
|
|
export const PROJECT_MAX_VIEW_WIDTH = SOURCE_DESIGN_WIDTH;
|
|
export const PROJECT_MAX_VIEW_HEIGHT = SOURCE_DESIGN_HEIGHT;
|
|
export const SOURCE_WORLD_LAYER = 1073741824;
|
|
export const SOURCE_CAMERA_VISIBILITY = 1083179010;
|
|
export const SOURCE_CAMERA_ORTHO_HEIGHT = 640;
|
|
// 原 startup.scene 序列化的相机控制器 minZoom 是 0.8,恢复出的交互视觉尺寸以这个源码视野为基准。
|
|
export const SOURCE_CAMERA_SOURCE_DEFAULT_ZOOM = 0.8;
|
|
// 当前需求启动时默认缩小到 0.65,但不改变源码交互视觉的尺寸基准。
|
|
export const SOURCE_CAMERA_INITIAL_ZOOM = 0.65;
|
|
// 运行时缩放下限按当前需求放宽到 0.5,避免初始 0.8 被当成最小值后只能放大不能缩小。
|
|
export const SOURCE_CAMERA_MIN_ZOOM = 0.5;
|
|
export const SOURCE_CAMERA_MAX_ZOOM = 2.4;
|
|
export const SOURCE_CAMERA_MAX_VISIBLE_WIDTH = 2300;
|
|
export const SOURCE_CAMERA_MIN_X = -360;
|
|
export const SOURCE_CAMERA_MAX_X = 360;
|
|
export const SOURCE_CAMERA_MIN_Y = -320;
|
|
export const SOURCE_CAMERA_MAX_Y = 320;
|
|
export const SOURCE_CAMERA_PC_SENSITIVITY = 0.002;
|
|
export const SOURCE_CAMERA_PINCH_ZOOM_SPEED = 2.5;
|
|
|
|
export function sourceCameraInitialZoom(): number {
|
|
return SOURCE_CAMERA_INITIAL_ZOOM;
|
|
}
|
|
|
|
export function sourceCameraInitialOrthoHeight(): number {
|
|
return SOURCE_CAMERA_ORTHO_HEIGHT / sourceCameraInitialZoom();
|
|
}
|
|
|
|
export function toCreatorNodeTransform(source: SourceNodeTransform): CreatorNodeTransform {
|
|
return {
|
|
position: { ...source.position },
|
|
scale: { ...source.scale },
|
|
euler: { ...source.euler },
|
|
size: { ...source.size },
|
|
pivot: { ...source.pivot },
|
|
layer: SOURCE_WORLD_LAYER,
|
|
};
|
|
}
|
|
|
|
export function toCreatorCameraState(source: SourceCameraState): SourceCameraState {
|
|
return {
|
|
position: { ...source.position },
|
|
orthographicHeight: source.orthographicHeight,
|
|
near: source.near,
|
|
far: source.far,
|
|
visibility: source.visibility,
|
|
};
|
|
}
|