@ray-js/ipc-player-integration 0.0.49 → 0.0.50-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ctx/ctx.composition.js +6 -1
- package/lib/ctx/ctx.js +11 -1
- package/lib/features/initPlayerWidgets/index.d.ts +5 -0
- package/lib/features/initPlayerWidgets/index.js +12 -0
- package/lib/i18n/index.d.ts +8 -0
- package/lib/i18n/strings.d.ts +4 -0
- package/lib/i18n/strings.js +4 -0
- package/lib/interface.d.ts +9 -1
- package/lib/ui/bottomLeftContent.js +23 -8
- package/lib/ui/constant.d.ts +10 -0
- package/lib/ui/constant.js +12 -1
- package/lib/ui/ui.js +78 -4
- package/lib/ui/ui.less +15 -0
- package/lib/utils/content/dpCode.d.ts +1 -0
- package/lib/utils/content/dpCode.js +5 -1
- package/lib/utils/storage/index.d.ts +2 -2
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +2 -1
- package/lib/widgets/realTimeMagnification/realTimeMagnification.js +18 -1
- package/lib/widgets/toggleVerticalFull/toggleVerticalFull.less +1 -1
- package/lib/widgets/zoomTurntable/constants.d.ts +92 -0
- package/lib/widgets/zoomTurntable/constants.js +148 -0
- package/lib/widgets/zoomTurntable/entryAnchor.d.ts +7 -0
- package/lib/widgets/zoomTurntable/entryAnchor.js +7 -0
- package/lib/widgets/zoomTurntable/index.d.ts +8 -0
- package/lib/widgets/zoomTurntable/index.js +8 -0
- package/lib/widgets/zoomTurntable/lensModel.d.ts +53 -0
- package/lib/widgets/zoomTurntable/lensModel.js +137 -0
- package/lib/widgets/zoomTurntable/lensModel.test.d.ts +1 -0
- package/lib/widgets/zoomTurntable/lensModel.test.js +336 -0
- package/lib/widgets/zoomTurntable/lensSkill.d.ts +89 -0
- package/lib/widgets/zoomTurntable/lensSkill.js +332 -0
- package/lib/widgets/zoomTurntable/measureVisible.d.ts +22 -0
- package/lib/widgets/zoomTurntable/measureVisible.js +76 -0
- package/lib/widgets/zoomTurntable/turntable/index.d.ts +10 -0
- package/lib/widgets/zoomTurntable/turntable/index.js +76 -0
- package/lib/widgets/zoomTurntable/turntable/index.less +11 -0
- package/lib/widgets/zoomTurntable/turntable/rjs/index.js +242 -0
- package/lib/widgets/zoomTurntable/turntable/rjs/index.json +3 -0
- package/lib/widgets/zoomTurntable/turntable/rjs/index.rjs +691 -0
- package/lib/widgets/zoomTurntable/turntable/rjs/index.tyml +7 -0
- package/lib/widgets/zoomTurntable/turntable/type.d.ts +95 -0
- package/lib/widgets/zoomTurntable/turntable/type.js +1 -0
- package/lib/widgets/zoomTurntable/useLensZoom.d.ts +34 -0
- package/lib/widgets/zoomTurntable/useLensZoom.js +421 -0
- package/lib/widgets/zoomTurntable/zoomTurntableDock.d.ts +17 -0
- package/lib/widgets/zoomTurntable/zoomTurntableDock.js +228 -0
- package/lib/widgets/zoomTurntable/zoomTurntableDock.less +11 -0
- package/lib/widgets/zoomTurntable/zoomTurntableEntry.d.ts +18 -0
- package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +253 -0
- package/lib/widgets/zoomTurntable/zoomTurntableEntry.less +51 -0
- package/lib/widgets/zoomTurntable/zoomTurntableTip.d.ts +16 -0
- package/lib/widgets/zoomTurntable/zoomTurntableTip.js +76 -0
- package/lib/widgets/zoomTurntable/zoomTurntableTip.less +56 -0
- package/package.json +3 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ZoomTurntableStyleOptions } from './turntable/type';
|
|
2
|
+
/** absolute 槽位 id:转盘浮层 */
|
|
3
|
+
export declare const zoomTurntableDockId = "zoomTurntableDockId";
|
|
4
|
+
/** absolute 槽位 id:圈选引导 */
|
|
5
|
+
export declare const zoomTurntableTipId = "zoomTurntableTipId";
|
|
6
|
+
/** 入口 widget id(bottomLeft 槽位) */
|
|
7
|
+
export declare const zoomTurntableEntryId = "ZoomTurntableEntry";
|
|
8
|
+
/** 事件:请求收起转盘 */
|
|
9
|
+
export declare const zoomTurntableClose = "zoomTurntableClose";
|
|
10
|
+
/** 事件:转盘已展开 */
|
|
11
|
+
export declare const zoomTurntableOpen = "zoomTurntableOpen";
|
|
12
|
+
/** 事件:物理镜头切换成功,载荷 { lensId, lensIndex, value } */
|
|
13
|
+
export declare const zoomTurntableLensChange = "zoomTurntableLensChange";
|
|
14
|
+
/** 事件:画面绝对倍率变化,载荷 { curM, d, lensIndex } */
|
|
15
|
+
export declare const zoomTurntableZoomChange = "zoomTurntableZoomChange";
|
|
16
|
+
/** 长按判定时长(ms) */
|
|
17
|
+
export declare const LONG_PRESS_MS = 500;
|
|
18
|
+
/** 长按期间允许的位移容差(px),超出视为横滑并取消长按 */
|
|
19
|
+
export declare const MOVE_TOLERANCE = 10;
|
|
20
|
+
/** switchChannel 下发超时(ms):回调始终不来时不知道切没切成,超时回滚读数 */
|
|
21
|
+
export declare const SWITCH_LENS_TIMEOUT = 3000;
|
|
22
|
+
/**
|
|
23
|
+
* switchChannel 已 success 后,等 channelChange 报「切到位」的时长(ms)。
|
|
24
|
+
* 超时按下发结果自己收尾,**不回滚** —— 指令已被受理,物理镜头其实已经切了,
|
|
25
|
+
* 回滚读数只会让读数和画面对不上。
|
|
26
|
+
*
|
|
27
|
+
* 与 SWITCH_LENS_TIMEOUT 取同一档(3s):设备真正切完镜头本身要一会儿,
|
|
28
|
+
* 给短了会在事件晚到时提前自己收尾,等于白订阅。
|
|
29
|
+
* 真机现状:设备侧暂未推 channelChange,切镜头基本都靠这条超时收尾。
|
|
30
|
+
*/
|
|
31
|
+
export declare const CHANNEL_SETTLE_TIMEOUT = 3000;
|
|
32
|
+
/**
|
|
33
|
+
* 判定「画面是否正好停在镜头光学正倍数」的容差。
|
|
34
|
+
* 回读的 d 是浮点,1.0 附近会有 1.0000001 这种抖动,严格相等判不出来。
|
|
35
|
+
*/
|
|
36
|
+
export declare const D_MATCH_EPS = 0.01;
|
|
37
|
+
/** 查询当前镜头超时(ms):宿主不回调时不能把同步流程一直挂着 */
|
|
38
|
+
export declare const QUERY_LENS_TIMEOUT = 3000;
|
|
39
|
+
/**
|
|
40
|
+
* 手势缩放跨临界点判定的 trailing 防抖(ms)。
|
|
41
|
+
* zoomLevelChange 高频上报,等手势停下来再判定是否切镜头(协议 §4.4)。
|
|
42
|
+
* 待 APP 提供 zoomFree 的「手势是否结束」参数后可改为由该参数触发。
|
|
43
|
+
*/
|
|
44
|
+
export declare const GESTURE_SWITCH_DEBOUNCE = 500;
|
|
45
|
+
/** 横屏 dock 距播放器右边的距离,负值时向右探出 */
|
|
46
|
+
export declare const ZOOM_DOCK_RIGHT = -10;
|
|
47
|
+
/** dock 层级,需高于四角容器的 z-index: 100 */
|
|
48
|
+
export declare const ZOOM_DOCK_Z_INDEX = 120;
|
|
49
|
+
/**
|
|
50
|
+
* 竖屏截取比例:从椭圆上弧顶往下截取多少。
|
|
51
|
+
* 0.5 = 完整上半椭圆(截面底边落在最宽处);> 0.5 会带出两侧下弯段。
|
|
52
|
+
* 取 0.5 让背景一路铺到播放器底边、不留空隙,多出来的部分靠 ZOOM_DOCK_BOTTOM 探出被裁掉。
|
|
53
|
+
*/
|
|
54
|
+
export declare const CROP_RATIO_BOTTOM = 0.5;
|
|
55
|
+
/**
|
|
56
|
+
* 触摸响应余量:把 canvas 向外扩一圈,让整个转盘区域(含椭圆上方空白)都能拖动,
|
|
57
|
+
* 而不是只有椭圆截面那一条带。绘制位置由 renderer 补偿,视觉不变。
|
|
58
|
+
*/
|
|
59
|
+
export declare const HIT_PADDING_X = 16;
|
|
60
|
+
export declare const HIT_PADDING_Y = 24;
|
|
61
|
+
/**
|
|
62
|
+
* 竖屏 dock 高度:必须 >= canvas 实际高度(椭圆截面 + 上下触摸余量),
|
|
63
|
+
* 否则承载它的 CoverView 会把转盘裁掉一截。随 CROP_RATIO_BOTTOM / HIT_PADDING_Y 自动跟随,留 8px 余量。
|
|
64
|
+
*/
|
|
65
|
+
export declare const ZOOM_DOCK_HEIGHT: number;
|
|
66
|
+
/**
|
|
67
|
+
* 竖屏 dock 距播放器底边的距离。
|
|
68
|
+
* 负值 = 椭圆下半探出播放器底边,由 .ipc-player-content 的 overflow: hidden 裁掉,
|
|
69
|
+
* 保证背景铺满到底边、下方不留空隙。
|
|
70
|
+
*/
|
|
71
|
+
export declare const ZOOM_DOCK_BOTTOM: number;
|
|
72
|
+
/** 横屏截取比例(右侧展示空间较窄,截得更深) */
|
|
73
|
+
export declare const CROP_RATIO_RIGHT = 0.45;
|
|
74
|
+
/** 布局沉降兜底:onShow / onResize 后的重挂载延时 */
|
|
75
|
+
export declare const RELAYOUT_DELAYS: number[];
|
|
76
|
+
/** 刻度与文案整体下移量(角度不变,仅平移绘制坐标系) */
|
|
77
|
+
export declare const CONTENT_OFFSET_Y = 10;
|
|
78
|
+
/** 刻度与标记值向椭圆内侧收的距离,加大与遮罩边缘的间距 */
|
|
79
|
+
export declare const TRACK_EDGE_INSET = 10;
|
|
80
|
+
/** 竖屏样式微调 */
|
|
81
|
+
export declare const STYLE_OPTIONS_BOTTOM: ZoomTurntableStyleOptions;
|
|
82
|
+
/** 横屏样式微调:压小刻度、文字与指针,避免与右侧控件重叠 */
|
|
83
|
+
export declare const STYLE_OPTIONS_RIGHT: ZoomTurntableStyleOptions;
|
|
84
|
+
/**
|
|
85
|
+
* 普通刻度震动节流(ms)。step=0.1 时整个区间有几十级,
|
|
86
|
+
* 不节流会震得过密,反而糊成一片没有颗粒感。
|
|
87
|
+
*/
|
|
88
|
+
export declare const VIBRATE_THROTTLE = 60;
|
|
89
|
+
/** 圈选提示:圆环尺寸 */
|
|
90
|
+
export declare const TIP_RING_SIZE = 44;
|
|
91
|
+
/** 可视区判定:避开左下角滚动容器右侧淡出带的安全距离 */
|
|
92
|
+
export declare const FADE_SAFE_PADDING = 24;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/** absolute 槽位 id:转盘浮层 */
|
|
2
|
+
export const zoomTurntableDockId = 'zoomTurntableDockId';
|
|
3
|
+
|
|
4
|
+
/** absolute 槽位 id:圈选引导 */
|
|
5
|
+
export const zoomTurntableTipId = 'zoomTurntableTipId';
|
|
6
|
+
|
|
7
|
+
/** 入口 widget id(bottomLeft 槽位) */
|
|
8
|
+
export const zoomTurntableEntryId = 'ZoomTurntableEntry';
|
|
9
|
+
|
|
10
|
+
/** 事件:请求收起转盘 */
|
|
11
|
+
export const zoomTurntableClose = 'zoomTurntableClose';
|
|
12
|
+
|
|
13
|
+
/** 事件:转盘已展开 */
|
|
14
|
+
export const zoomTurntableOpen = 'zoomTurntableOpen';
|
|
15
|
+
|
|
16
|
+
/** 事件:物理镜头切换成功,载荷 { lensId, lensIndex, value } */
|
|
17
|
+
export const zoomTurntableLensChange = 'zoomTurntableLensChange';
|
|
18
|
+
|
|
19
|
+
/** 事件:画面绝对倍率变化,载荷 { curM, d, lensIndex } */
|
|
20
|
+
export const zoomTurntableZoomChange = 'zoomTurntableZoomChange';
|
|
21
|
+
|
|
22
|
+
/** 长按判定时长(ms) */
|
|
23
|
+
export const LONG_PRESS_MS = 500;
|
|
24
|
+
|
|
25
|
+
/** 长按期间允许的位移容差(px),超出视为横滑并取消长按 */
|
|
26
|
+
export const MOVE_TOLERANCE = 10;
|
|
27
|
+
|
|
28
|
+
/** switchChannel 下发超时(ms):回调始终不来时不知道切没切成,超时回滚读数 */
|
|
29
|
+
export const SWITCH_LENS_TIMEOUT = 3000;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* switchChannel 已 success 后,等 channelChange 报「切到位」的时长(ms)。
|
|
33
|
+
* 超时按下发结果自己收尾,**不回滚** —— 指令已被受理,物理镜头其实已经切了,
|
|
34
|
+
* 回滚读数只会让读数和画面对不上。
|
|
35
|
+
*
|
|
36
|
+
* 与 SWITCH_LENS_TIMEOUT 取同一档(3s):设备真正切完镜头本身要一会儿,
|
|
37
|
+
* 给短了会在事件晚到时提前自己收尾,等于白订阅。
|
|
38
|
+
* 真机现状:设备侧暂未推 channelChange,切镜头基本都靠这条超时收尾。
|
|
39
|
+
*/
|
|
40
|
+
export const CHANNEL_SETTLE_TIMEOUT = 3000;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 判定「画面是否正好停在镜头光学正倍数」的容差。
|
|
44
|
+
* 回读的 d 是浮点,1.0 附近会有 1.0000001 这种抖动,严格相等判不出来。
|
|
45
|
+
*/
|
|
46
|
+
export const D_MATCH_EPS = 0.01;
|
|
47
|
+
|
|
48
|
+
/** 查询当前镜头超时(ms):宿主不回调时不能把同步流程一直挂着 */
|
|
49
|
+
export const QUERY_LENS_TIMEOUT = 3000;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 手势缩放跨临界点判定的 trailing 防抖(ms)。
|
|
53
|
+
* zoomLevelChange 高频上报,等手势停下来再判定是否切镜头(协议 §4.4)。
|
|
54
|
+
* 待 APP 提供 zoomFree 的「手势是否结束」参数后可改为由该参数触发。
|
|
55
|
+
*/
|
|
56
|
+
export const GESTURE_SWITCH_DEBOUNCE = 500;
|
|
57
|
+
|
|
58
|
+
/** 横屏 dock 距播放器右边的距离,负值时向右探出 */
|
|
59
|
+
export const ZOOM_DOCK_RIGHT = -10;
|
|
60
|
+
|
|
61
|
+
/** dock 层级,需高于四角容器的 z-index: 100 */
|
|
62
|
+
export const ZOOM_DOCK_Z_INDEX = 120;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 竖屏截取比例:从椭圆上弧顶往下截取多少。
|
|
66
|
+
* 0.5 = 完整上半椭圆(截面底边落在最宽处);> 0.5 会带出两侧下弯段。
|
|
67
|
+
* 取 0.5 让背景一路铺到播放器底边、不留空隙,多出来的部分靠 ZOOM_DOCK_BOTTOM 探出被裁掉。
|
|
68
|
+
*/
|
|
69
|
+
export const CROP_RATIO_BOTTOM = 0.5;
|
|
70
|
+
|
|
71
|
+
/** 基准椭圆全高,与 rjs 里的 BASE_RY * 2 保持一致 */
|
|
72
|
+
const BASE_ELLIPSE_HEIGHT = 351;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 触摸响应余量:把 canvas 向外扩一圈,让整个转盘区域(含椭圆上方空白)都能拖动,
|
|
76
|
+
* 而不是只有椭圆截面那一条带。绘制位置由 renderer 补偿,视觉不变。
|
|
77
|
+
*/
|
|
78
|
+
export const HIT_PADDING_X = 16;
|
|
79
|
+
export const HIT_PADDING_Y = 24;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 竖屏 dock 高度:必须 >= canvas 实际高度(椭圆截面 + 上下触摸余量),
|
|
83
|
+
* 否则承载它的 CoverView 会把转盘裁掉一截。随 CROP_RATIO_BOTTOM / HIT_PADDING_Y 自动跟随,留 8px 余量。
|
|
84
|
+
*/
|
|
85
|
+
export const ZOOM_DOCK_HEIGHT = Math.ceil(BASE_ELLIPSE_HEIGHT * CROP_RATIO_BOTTOM) + HIT_PADDING_Y * 2 + 8;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 内容顶部到播放器底边的距离(视觉基准)。
|
|
89
|
+
* dock 是 bottom 定位、内容从顶部往下画,所以顶部位置 = 该值,与截取比例无关 ——
|
|
90
|
+
* 改 CROP_RATIO_BOTTOM 只影响背景往下探多深,不会动到当前倍率文案与刻度的位置。
|
|
91
|
+
*/
|
|
92
|
+
const ZOOM_DOCK_TOP_GAP = 169;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 竖屏 dock 距播放器底边的距离。
|
|
96
|
+
* 负值 = 椭圆下半探出播放器底边,由 .ipc-player-content 的 overflow: hidden 裁掉,
|
|
97
|
+
* 保证背景铺满到底边、下方不留空隙。
|
|
98
|
+
*/
|
|
99
|
+
export const ZOOM_DOCK_BOTTOM = ZOOM_DOCK_TOP_GAP - ZOOM_DOCK_HEIGHT;
|
|
100
|
+
|
|
101
|
+
/** 横屏截取比例(右侧展示空间较窄,截得更深) */
|
|
102
|
+
export const CROP_RATIO_RIGHT = 0.45;
|
|
103
|
+
|
|
104
|
+
/** 布局沉降兜底:onShow / onResize 后的重挂载延时 */
|
|
105
|
+
export const RELAYOUT_DELAYS = [80, 260];
|
|
106
|
+
|
|
107
|
+
/** 刻度与文案整体下移量(角度不变,仅平移绘制坐标系) */
|
|
108
|
+
export const CONTENT_OFFSET_Y = 10;
|
|
109
|
+
|
|
110
|
+
/** 刻度与标记值向椭圆内侧收的距离,加大与遮罩边缘的间距 */
|
|
111
|
+
export const TRACK_EDGE_INSET = 10;
|
|
112
|
+
|
|
113
|
+
/** 竖屏样式微调 */
|
|
114
|
+
export const STYLE_OPTIONS_BOTTOM = {
|
|
115
|
+
topSafeArea: 30,
|
|
116
|
+
currentLabelFontSize: 12,
|
|
117
|
+
markLabelFontSize: 10,
|
|
118
|
+
contentOffsetY: CONTENT_OFFSET_Y,
|
|
119
|
+
trackEdgeInset: TRACK_EDGE_INSET,
|
|
120
|
+
hitPaddingX: HIT_PADDING_X,
|
|
121
|
+
hitPaddingY: HIT_PADDING_Y
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** 横屏样式微调:压小刻度、文字与指针,避免与右侧控件重叠 */
|
|
125
|
+
export const STYLE_OPTIONS_RIGHT = {
|
|
126
|
+
topSafeArea: 30,
|
|
127
|
+
currentLabelFontSize: 12,
|
|
128
|
+
markLabelFontSize: 10,
|
|
129
|
+
innerLabelOffsetX: 36,
|
|
130
|
+
innerLabelOffsetY: 36,
|
|
131
|
+
// 横屏画布整体旋转 90°,这里的偏移沿旋转后坐标系生效(即向屏幕右侧)
|
|
132
|
+
contentOffsetY: CONTENT_OFFSET_Y,
|
|
133
|
+
trackEdgeInset: TRACK_EDGE_INSET,
|
|
134
|
+
hitPaddingX: HIT_PADDING_X,
|
|
135
|
+
hitPaddingY: HIT_PADDING_Y
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 普通刻度震动节流(ms)。step=0.1 时整个区间有几十级,
|
|
140
|
+
* 不节流会震得过密,反而糊成一片没有颗粒感。
|
|
141
|
+
*/
|
|
142
|
+
export const VIBRATE_THROTTLE = 60;
|
|
143
|
+
|
|
144
|
+
/** 圈选提示:圆环尺寸 */
|
|
145
|
+
export const TIP_RING_SIZE = 44;
|
|
146
|
+
|
|
147
|
+
/** 可视区判定:避开左下角滚动容器右侧淡出带的安全距离 */
|
|
148
|
+
export const FADE_SAFE_PADDING = 24;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './zoomTurntableEntry';
|
|
2
|
+
export * from './zoomTurntableDock';
|
|
3
|
+
export * from './zoomTurntableTip';
|
|
4
|
+
export * from './lensSkill';
|
|
5
|
+
export * from './lensModel';
|
|
6
|
+
export * from './useLensZoom';
|
|
7
|
+
export * from './entryAnchor';
|
|
8
|
+
export * from './constants';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './zoomTurntableEntry';
|
|
2
|
+
export * from './zoomTurntableDock';
|
|
3
|
+
export * from './zoomTurntableTip';
|
|
4
|
+
export * from './lensSkill';
|
|
5
|
+
export * from './lensModel';
|
|
6
|
+
export * from './useLensZoom';
|
|
7
|
+
export * from './entryAnchor';
|
|
8
|
+
export * from './constants';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 双层缩放换算:物理镜头(光学)× 播放器本地数字缩放 d。
|
|
3
|
+
*
|
|
4
|
+
* curM = lens.basicRatio + (d − 1) × Δ Δ = 区间跨度 / (D_MAX − D_MIN)
|
|
5
|
+
*
|
|
6
|
+
* 是加法不是乘法:thresholds [1,3,6] 的长焦(basicRatio 3、区间 [3,6])上
|
|
7
|
+
* d=1→3.0x、d=2→4.0x、d=3→5.0x、d=4→6.0x,不是 3×4=12。
|
|
8
|
+
* d 是相对当前镜头的读数,同一个 d 在不同镜头上画面倍率不同,直接显示 d 是错的。
|
|
9
|
+
*/
|
|
10
|
+
import { ZoomSkill } from './lensSkill';
|
|
11
|
+
/** 本地数字缩放下限(协议规定) */
|
|
12
|
+
export declare const D_MIN = 1;
|
|
13
|
+
/** 本地数字缩放上限(协议规定 d ∈ [1, 4]) */
|
|
14
|
+
export declare const D_MAX = 4;
|
|
15
|
+
/** 镜头匹配容差缺省值,镜头未声明 step 时使用 */
|
|
16
|
+
export declare const DEFAULT_MATCH_TOLERANCE = 0.1;
|
|
17
|
+
/** 镜头 i 负责的倍率区间 [thresholds[i], thresholds[i + 1]] */
|
|
18
|
+
export declare const lensRange: (skill: ZoomSkill, index: number) => [number, number];
|
|
19
|
+
/** 镜头 i 上「每 1 单位 d」对应的画面倍率增量 */
|
|
20
|
+
export declare const deltaOf: (skill: ZoomSkill, index: number) => number;
|
|
21
|
+
/** 回读方向:本地数字缩放 d → 画面绝对倍率 curM */
|
|
22
|
+
export declare const toDisplayZoom: (skill: ZoomSkill, index: number, d: number) => number;
|
|
23
|
+
/** 下发方向:画面绝对倍率 curM → 该镜头上的本地数字缩放 d */
|
|
24
|
+
export declare const toScaleMultiple: (skill: ZoomSkill, index: number, curM: number) => number;
|
|
25
|
+
/**
|
|
26
|
+
* 镜头 i 上允许的最大本地数字缩放 d —— 即该镜头区间上限换算出的 d(受 D_MAX 约束)。
|
|
27
|
+
* 播放器的 maxScaleMultiple 是 d 口径,多镜头下要按当前镜头换算,不能直接用画面绝对上限。
|
|
28
|
+
*/
|
|
29
|
+
export declare const maxScaleMultiple: (skill: ZoomSkill, index: number) => number;
|
|
30
|
+
/** 镜头 i 的匹配容差:取该镜头的步进精度 step,未声明时用缺省值 */
|
|
31
|
+
export declare const toleranceOf: (skill: ZoomSkill, index: number) => number;
|
|
32
|
+
/** 协议未声明 step 时的缺省步进 */
|
|
33
|
+
export declare const DEFAULT_STEP = 0.1;
|
|
34
|
+
/**
|
|
35
|
+
* 画面倍率 → 目标镜头下标。
|
|
36
|
+
* 容差取各镜头自己的 step;同时命中多个区间时取大镜头,避免临界处反复横跳。
|
|
37
|
+
* 代价:临界带会被判到大镜头,画面至多向上吸附一个 step。
|
|
38
|
+
*/
|
|
39
|
+
export declare const matchLens: (skill: ZoomSkill, curM: number) => number;
|
|
40
|
+
/** 由镜头 id 反查下标 */
|
|
41
|
+
export declare const indexOfLensId: (skill: ZoomSkill, lensId: number) => number;
|
|
42
|
+
/** 转盘可用倍率域:[thresholds[0], thresholds 末位] */
|
|
43
|
+
export declare const zoomBounds: (skill: ZoomSkill) => [number, number];
|
|
44
|
+
/**
|
|
45
|
+
* 次刻度值:逐镜头区间按各自 step 生成,故各段疏密不同。
|
|
46
|
+
* 在逻辑层算好再给 rjs:rjs 只有当前镜头的 step,推不出分段间距。
|
|
47
|
+
*/
|
|
48
|
+
export declare const buildTickValues: (skill: ZoomSkill) => number[];
|
|
49
|
+
/** 主刻度 = 各镜头固定光学倍数 + 上限,与镜头临界点对齐 */
|
|
50
|
+
export declare const buildMarks: (skill: ZoomSkill) => {
|
|
51
|
+
value: number;
|
|
52
|
+
label: string;
|
|
53
|
+
}[];
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
4
|
+
/**
|
|
5
|
+
* 双层缩放换算:物理镜头(光学)× 播放器本地数字缩放 d。
|
|
6
|
+
*
|
|
7
|
+
* curM = lens.basicRatio + (d − 1) × Δ Δ = 区间跨度 / (D_MAX − D_MIN)
|
|
8
|
+
*
|
|
9
|
+
* 是加法不是乘法:thresholds [1,3,6] 的长焦(basicRatio 3、区间 [3,6])上
|
|
10
|
+
* d=1→3.0x、d=2→4.0x、d=3→5.0x、d=4→6.0x,不是 3×4=12。
|
|
11
|
+
* d 是相对当前镜头的读数,同一个 d 在不同镜头上画面倍率不同,直接显示 d 是错的。
|
|
12
|
+
*/
|
|
13
|
+
import { lensCount } from './lensSkill';
|
|
14
|
+
|
|
15
|
+
/** 本地数字缩放下限(协议规定) */
|
|
16
|
+
export const D_MIN = 1.0;
|
|
17
|
+
/** 本地数字缩放上限(协议规定 d ∈ [1, 4]) */
|
|
18
|
+
export const D_MAX = 4.0;
|
|
19
|
+
/** 镜头匹配容差缺省值,镜头未声明 step 时使用 */
|
|
20
|
+
export const DEFAULT_MATCH_TOLERANCE = 0.1;
|
|
21
|
+
|
|
22
|
+
/** 镜头 i 负责的倍率区间 [thresholds[i], thresholds[i + 1]] */
|
|
23
|
+
export const lensRange = (skill, index) => {
|
|
24
|
+
const lo = skill.thresholds[index];
|
|
25
|
+
const hi = skill.thresholds[index + 1];
|
|
26
|
+
return [lo, hi];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** 镜头 i 上「每 1 单位 d」对应的画面倍率增量 */
|
|
30
|
+
export const deltaOf = (skill, index) => {
|
|
31
|
+
const [lo, hi] = lensRange(skill, index);
|
|
32
|
+
const span = hi - lo;
|
|
33
|
+
if (!(span > 0)) return 1;
|
|
34
|
+
return span / (D_MAX - D_MIN);
|
|
35
|
+
};
|
|
36
|
+
const clampD = d => Math.min(D_MAX, Math.max(D_MIN, d));
|
|
37
|
+
|
|
38
|
+
/** 回读方向:本地数字缩放 d → 画面绝对倍率 curM */
|
|
39
|
+
export const toDisplayZoom = (skill, index, d) => {
|
|
40
|
+
var _skill$lenses;
|
|
41
|
+
const lens = skill === null || skill === void 0 || (_skill$lenses = skill.lenses) === null || _skill$lenses === void 0 ? void 0 : _skill$lenses[index];
|
|
42
|
+
if (!lens) return d;
|
|
43
|
+
return lens.basicRatio + (clampD(d) - D_MIN) * deltaOf(skill, index);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** 下发方向:画面绝对倍率 curM → 该镜头上的本地数字缩放 d */
|
|
47
|
+
export const toScaleMultiple = (skill, index, curM) => {
|
|
48
|
+
var _skill$lenses2;
|
|
49
|
+
const lens = skill === null || skill === void 0 || (_skill$lenses2 = skill.lenses) === null || _skill$lenses2 === void 0 ? void 0 : _skill$lenses2[index];
|
|
50
|
+
if (!lens) return D_MIN;
|
|
51
|
+
return clampD(D_MIN + (curM - lens.basicRatio) / deltaOf(skill, index));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 镜头 i 上允许的最大本地数字缩放 d —— 即该镜头区间上限换算出的 d(受 D_MAX 约束)。
|
|
56
|
+
* 播放器的 maxScaleMultiple 是 d 口径,多镜头下要按当前镜头换算,不能直接用画面绝对上限。
|
|
57
|
+
*/
|
|
58
|
+
export const maxScaleMultiple = (skill, index) => toScaleMultiple(skill, index, lensRange(skill, index)[1]);
|
|
59
|
+
|
|
60
|
+
/** 镜头 i 的匹配容差:取该镜头的步进精度 step,未声明时用缺省值 */
|
|
61
|
+
export const toleranceOf = (skill, index) => {
|
|
62
|
+
var _skill$lenses$index$s, _skill$lenses3;
|
|
63
|
+
return (_skill$lenses$index$s = skill === null || skill === void 0 || (_skill$lenses3 = skill.lenses) === null || _skill$lenses3 === void 0 || (_skill$lenses3 = _skill$lenses3[index]) === null || _skill$lenses3 === void 0 ? void 0 : _skill$lenses3.step) !== null && _skill$lenses$index$s !== void 0 ? _skill$lenses$index$s : DEFAULT_MATCH_TOLERANCE;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** 协议未声明 step 时的缺省步进 */
|
|
67
|
+
export const DEFAULT_STEP = 0.1;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 画面倍率 → 目标镜头下标。
|
|
71
|
+
* 容差取各镜头自己的 step;同时命中多个区间时取大镜头,避免临界处反复横跳。
|
|
72
|
+
* 代价:临界带会被判到大镜头,画面至多向上吸附一个 step。
|
|
73
|
+
*/
|
|
74
|
+
export const matchLens = (skill, curM) => {
|
|
75
|
+
let hit = 0;
|
|
76
|
+
const count = lensCount(skill);
|
|
77
|
+
for (let i = 0; i < count; i++) {
|
|
78
|
+
const [lo, hi] = lensRange(skill, i);
|
|
79
|
+
const tolerance = toleranceOf(skill, i);
|
|
80
|
+
if (curM >= lo - tolerance && curM <= hi + tolerance) {
|
|
81
|
+
hit = i;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return hit;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** 由镜头 id 反查下标 */
|
|
88
|
+
export const indexOfLensId = (skill, lensId) => {
|
|
89
|
+
var _skill$lenses4;
|
|
90
|
+
const index = skill === null || skill === void 0 || (_skill$lenses4 = skill.lenses) === null || _skill$lenses4 === void 0 ? void 0 : _skill$lenses4.findIndex(item => item.id === lensId);
|
|
91
|
+
return index != null && index >= 0 ? index : 0;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/** 转盘可用倍率域:[thresholds[0], thresholds 末位] */
|
|
95
|
+
export const zoomBounds = skill => {
|
|
96
|
+
const {
|
|
97
|
+
thresholds
|
|
98
|
+
} = skill;
|
|
99
|
+
return [thresholds[0], thresholds[thresholds.length - 1]];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 次刻度值:逐镜头区间按各自 step 生成,故各段疏密不同。
|
|
104
|
+
* 在逻辑层算好再给 rjs:rjs 只有当前镜头的 step,推不出分段间距。
|
|
105
|
+
*/
|
|
106
|
+
export const buildTickValues = skill => {
|
|
107
|
+
const count = lensCount(skill);
|
|
108
|
+
const values = [];
|
|
109
|
+
for (let i = 0; i < count; i += 1) {
|
|
110
|
+
var _skill$lenses$i$step, _skill$lenses5;
|
|
111
|
+
const [lo, hi] = lensRange(skill, i);
|
|
112
|
+
const step = (_skill$lenses$i$step = (_skill$lenses5 = skill.lenses) === null || _skill$lenses5 === void 0 || (_skill$lenses5 = _skill$lenses5[i]) === null || _skill$lenses5 === void 0 ? void 0 : _skill$lenses5.step) !== null && _skill$lenses$i$step !== void 0 ? _skill$lenses$i$step : DEFAULT_STEP;
|
|
113
|
+
if (step > 0 && hi > lo) {
|
|
114
|
+
// 浮点累加会漂,用格数反推每一格的值
|
|
115
|
+
const gridCount = Math.floor((hi - lo) / step + 1e-9);
|
|
116
|
+
for (let g = 0; g <= gridCount; g += 1) {
|
|
117
|
+
values.push(Number((lo + g * step).toFixed(4)));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const [, max] = zoomBounds(skill);
|
|
122
|
+
values.push(Number(max.toFixed(4)));
|
|
123
|
+
return values.filter(value => value <= max + 1e-9).filter((value, index, arr) => arr.indexOf(value) === index).sort((a, b) => a - b);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/** 主刻度 = 各镜头固定光学倍数 + 上限,与镜头临界点对齐 */
|
|
127
|
+
export const buildMarks = skill => {
|
|
128
|
+
const [, max] = zoomBounds(skill);
|
|
129
|
+
const count = lensCount(skill);
|
|
130
|
+
const values = skill.lenses.slice(0, count).map(item => item.basicRatio);
|
|
131
|
+
values.push(max);
|
|
132
|
+
return values.filter((value, i, arr) => arr.indexOf(value) === i).sort((a, b) => a - b).map(value => ({
|
|
133
|
+
value,
|
|
134
|
+
// 整数不带小数点(1 / 3 / 6),非整数保留一位(1.5)
|
|
135
|
+
label: Number.isInteger(value) ? String(value) : value.toFixed(1)
|
|
136
|
+
}));
|
|
137
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|