cos-design 3.7.2 → 3.7.4

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +94 -27
  3. package/dist/index.cjs +3 -3
  4. package/dist/index.css +1 -1
  5. package/dist/index.js +5835 -2930
  6. package/dist/src/components/charge/index.d.ts +2 -0
  7. package/dist/src/components/confetti/index.d.ts +2 -0
  8. package/dist/src/components/fireworks/index.d.ts +2 -0
  9. package/dist/src/components/index.d.ts +26 -4
  10. package/dist/src/components/photoAlbum/types.d.ts +2 -0
  11. package/dist/src/components/photoCarousel/index.d.ts +9 -0
  12. package/dist/src/components/photoCarousel/types.d.ts +49 -0
  13. package/dist/src/components/photoClothesline/constants.d.ts +44 -0
  14. package/dist/src/components/photoClothesline/layout.d.ts +23 -0
  15. package/dist/src/components/photoClothesline/math.d.ts +6 -0
  16. package/dist/src/components/photoClothesline/model.d.ts +110 -0
  17. package/dist/src/components/photoClothesline/ropePath.d.ts +5 -0
  18. package/dist/src/components/photoClothesline/simulation.d.ts +46 -0
  19. package/dist/src/components/photoClothesline/types.d.ts +2 -0
  20. package/dist/src/components/photoFilmstrip/index.d.ts +5 -0
  21. package/dist/src/components/photoFilmstrip/types.d.ts +43 -0
  22. package/dist/src/components/photoFridge/index.d.ts +5 -0
  23. package/dist/src/components/photoFridge/types.d.ts +41 -0
  24. package/dist/src/components/photoLantern/accessories.d.ts +4 -0
  25. package/dist/src/components/photoLantern/constants.d.ts +5 -0
  26. package/dist/src/components/photoLantern/dispose.d.ts +4 -0
  27. package/dist/src/components/photoLantern/geometry.d.ts +5 -0
  28. package/dist/src/components/photoLantern/index.d.ts +5 -0
  29. package/dist/src/components/photoLantern/materials.d.ts +9 -0
  30. package/dist/src/components/photoLantern/scene.d.ts +32 -0
  31. package/dist/src/components/photoLantern/textures.d.ts +9 -0
  32. package/dist/src/components/photoLantern/types.d.ts +61 -0
  33. package/dist/src/components/photoLightbox/index.d.ts +5 -0
  34. package/dist/src/components/photoLightbox/types.d.ts +39 -0
  35. package/dist/src/components/photoPolaroid/index.d.ts +5 -0
  36. package/dist/src/components/photoPolaroid/types.d.ts +39 -0
  37. package/dist/src/components/photoPostcard/index.d.ts +8 -0
  38. package/dist/src/components/photoPostcard/types.d.ts +45 -0
  39. package/dist/src/components/photoPrism/index.d.ts +9 -0
  40. package/dist/src/components/photoPrism/types.d.ts +39 -0
  41. package/dist/src/components/photoScroll/index.d.ts +9 -0
  42. package/dist/src/components/photoScroll/types.d.ts +43 -0
  43. package/dist/src/components/photoTunnel/index.d.ts +9 -0
  44. package/dist/src/components/photoTunnel/types.d.ts +43 -0
  45. package/dist/src/components/photoViewMaster/index.d.ts +9 -0
  46. package/dist/src/components/photoViewMaster/types.d.ts +47 -0
  47. package/dist/src/components/redPacketRain/index.d.ts +17 -1
  48. package/dist/src/components/scratchCard/index.d.ts +9 -1
  49. package/dist/src/components/slotMachine/index.d.ts +13 -1
  50. package/dist/src/components/turntable/index.d.ts +9 -1
  51. package/package.json +10 -3
@@ -6,6 +6,8 @@ export interface ChargeProps {
6
6
  value?: number;
7
7
  /** 电量变化回调 */
8
8
  onChange?: (value: number) => void;
9
+ /** 电量首次到达 100% 时回调 */
10
+ onComplete?: () => void;
9
11
  /** 是否自动充电,默认 true */
10
12
  autoCharge?: boolean;
11
13
  /** 充电间隔(毫秒),默认 500 */
@@ -8,6 +8,8 @@ export interface ConfettiProps {
8
8
  particleCount?: number;
9
9
  /** 画布操作提示 */
10
10
  hint?: string;
11
+ /** 粒子全部消散后回调 */
12
+ onComplete?: () => void;
11
13
  }
12
14
  export interface ConfettiHandle {
13
15
  /** 手动触发彩纸喷射 */
@@ -6,6 +6,8 @@ export interface FireworksProps {
6
6
  auto?: boolean;
7
7
  /** 画布操作提示 */
8
8
  hint?: string;
9
+ /** 画面空闲(无火箭/粒子)时回调 */
10
+ onComplete?: () => void;
9
11
  }
10
12
  export interface FireworksHandle {
11
13
  /** 手动燃放烟花,可指定 x 坐标 */
@@ -79,8 +79,30 @@ export type { OrbitalChartItem, OrbitalChartProps } from './orbitalChart';
79
79
  export { default as ParticleNetwork } from './particleNetwork';
80
80
  export { default as PhotoAlbum } from './photoAlbum';
81
81
  export type { PhotoAlbumItem, PhotoAlbumLabels, PhotoAlbumProps } from './photoAlbum';
82
+ export { default as PhotoCarousel } from './photoCarousel';
83
+ export type { PhotoCarouselItem, PhotoCarouselProps } from './photoCarousel';
82
84
  export { default as PhotoClothesline } from './photoClothesline';
83
85
  export type { PhotoClotheslineItem, PhotoClotheslineProps } from './photoClothesline';
86
+ export { default as PhotoFilmstrip } from './photoFilmstrip';
87
+ export type { PhotoFilmstripItem, PhotoFilmstripProps } from './photoFilmstrip';
88
+ export { default as PhotoFridge } from './photoFridge';
89
+ export type { PhotoFridgeItem, PhotoFridgeProps } from './photoFridge';
90
+ export { default as PhotoLantern } from './photoLantern';
91
+ export type { PhotoLanternItem, PhotoLanternProps } from './photoLantern';
92
+ export { default as PhotoLightbox } from './photoLightbox';
93
+ export type { PhotoLightboxItem, PhotoLightboxProps } from './photoLightbox';
94
+ export { default as PhotoPolaroid } from './photoPolaroid';
95
+ export type { PhotoPolaroidItem, PhotoPolaroidProps } from './photoPolaroid';
96
+ export { default as PhotoPostcard } from './photoPostcard';
97
+ export type { PhotoPostcardItem, PhotoPostcardProps } from './photoPostcard';
98
+ export { default as PhotoPrism } from './photoPrism';
99
+ export type { PhotoPrismItem, PhotoPrismProps } from './photoPrism';
100
+ export { default as PhotoScroll } from './photoScroll';
101
+ export type { PhotoScrollItem, PhotoScrollProps } from './photoScroll';
102
+ export { default as PhotoTunnel } from './photoTunnel';
103
+ export type { PhotoTunnelItem, PhotoTunnelProps } from './photoTunnel';
104
+ export { default as PhotoViewMaster } from './photoViewMaster';
105
+ export type { PhotoViewMasterItem, PhotoViewMasterProps } from './photoViewMaster';
84
106
  export { default as PlasmaBall } from './plasmaBall';
85
107
  export type { PlasmaBallProps } from './plasmaBall';
86
108
  export { default as SmokeFog } from './smokeFog';
@@ -99,7 +121,7 @@ export type { ProgressChestProps } from './progressChest';
99
121
  export { default as RadarScan } from './radarScan';
100
122
  export type { RadarScanProps } from './radarScan';
101
123
  export { default as RedPacketRain } from './redPacketRain';
102
- export type { RedPacketRainProps } from './redPacketRain';
124
+ export type { RedPacketRainHandle, RedPacketRainProps } from './redPacketRain';
103
125
  export { default as ReturnCity } from './returnCity';
104
126
  export { default as RopeChain } from './ropeChain';
105
127
  export type { RopeChainProps } from './ropeChain';
@@ -116,9 +138,9 @@ export type { RippleWaterProps } from './rippleWater';
116
138
  export { default as ScrambleText } from './scrambleText';
117
139
  export type { ScrambleTextProps } from './scrambleText';
118
140
  export { default as ScratchCard } from './scratchCard';
119
- export type { ScratchCardProps } from './scratchCard';
141
+ export type { ScratchCardHandle, ScratchCardProps } from './scratchCard';
120
142
  export { default as SlotMachine } from './slotMachine';
121
- export type { SlotMachineProps } from './slotMachine';
143
+ export type { SlotMachineHandle, SlotMachineProps } from './slotMachine';
122
144
  export { default as SandFall } from './sandFall';
123
145
  export type { SandFallProps } from './sandFall';
124
146
  export { default as SplitReveal } from './splitReveal';
@@ -130,7 +152,7 @@ export type { SpringMassProps } from './springMass';
130
152
  export { default as Spotlight } from './spotlight';
131
153
  export type { SpotlightProps } from './spotlight';
132
154
  export type { ReturnCityProps } from './returnCity';
133
- export type { TurntablePrize, TurntableProps } from './turntable';
155
+ export type { TurntableHandle, TurntablePrize, TurntableProps } from './turntable';
134
156
  export { default as Turntable } from './turntable';
135
157
  export { default as TextMorph } from './textMorph';
136
158
  export type { TextMorphProps } from './textMorph';
@@ -50,6 +50,8 @@ export interface PhotoAlbumProps {
50
50
  labels?: PhotoAlbumLabels;
51
51
  /** 当前照片变化回调 */
52
52
  onPageChange?: (index: number, photo: PhotoAlbumItem) => void;
53
+ /** 当前照片变化回调别名(与其他 photo 组件对齐) */
54
+ onIndexChange?: (index: number, photo: PhotoAlbumItem) => void;
53
55
  /** 自定义类名 */
54
56
  className?: string;
55
57
  /** 自定义样式 */
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { PhotoCarouselProps } from './types';
3
+ /**
4
+ * 环形照片转盘:照片立于 CSS 3D 圆环上,可拖拽旋转并带惯性,
5
+ * 空闲时可选缓慢自动顺时针转动;正面照片朝向镜头。
6
+ */
7
+ declare const PhotoCarousel: React.FC<PhotoCarouselProps>;
8
+ export default PhotoCarousel;
9
+ export type { PhotoCarouselItem, PhotoCarouselProps } from './types';
@@ -0,0 +1,49 @@
1
+ import { CSSProperties } from 'react';
2
+ export interface PhotoCarouselItem {
3
+ /** 图片地址 */
4
+ src: string;
5
+ /** 图片替代文本 */
6
+ alt?: string;
7
+ /** 照片标题 */
8
+ title?: string;
9
+ /** 照片说明 */
10
+ description?: string;
11
+ }
12
+ export interface PhotoCarouselProps {
13
+ /** 转盘上的照片列表 */
14
+ photos: PhotoCarouselItem[];
15
+ /** 组件宽度 */
16
+ width?: number | string;
17
+ /** 组件高度 */
18
+ height?: number | string;
19
+ /** 照片环半径(px) */
20
+ radius?: number;
21
+ /** 单张照片宽度(px) */
22
+ cardWidth?: number;
23
+ /** 单张照片高度(px) */
24
+ cardHeight?: number;
25
+ /** 空闲时是否自动顺时针旋转 */
26
+ autoRotate?: boolean;
27
+ /** 自动旋转角速度(度/秒) */
28
+ autoRotateSpeed?: number;
29
+ /** 水平拖拽灵敏度,越大同样位移转得越多 */
30
+ dragSensitivity?: number;
31
+ /** 惯性摩擦系数,越大减速越快 */
32
+ friction?: number;
33
+ /** 是否仅对正面照片显示标题与说明 */
34
+ showCaption?: boolean;
35
+ /** 初始旋转角(度),0 表示第一张正对镜头 */
36
+ initialAngle?: number;
37
+ /** 点击正面照片回调 */
38
+ onPhotoClick?: (index: number, photo: PhotoCarouselItem) => void;
39
+ /** 正对镜头的照片索引变化回调 */
40
+ onFaceChange?: (index: number, photo?: PhotoCarouselItem) => void;
41
+ /** 正对镜头照片变化回调别名(与其他 photo 组件对齐) */
42
+ onIndexChange?: (index: number, photo: PhotoCarouselItem) => void;
43
+ /** 无障碍名称 */
44
+ ariaLabel?: string;
45
+ /** 自定义类名 */
46
+ className?: string;
47
+ /** 自定义样式 */
48
+ style?: CSSProperties;
49
+ }
@@ -0,0 +1,44 @@
1
+ /** 固定物理步长:与帧率解耦,掉帧时摆动节奏也一致 */
2
+ export declare const PHYSICS_STEP_MS: number;
3
+ export declare const PHYSICS_STEP_S: number;
4
+ export declare const MAX_FRAME_MS = 64;
5
+ /** 夹子咬住吊带末端的位置在相纸上沿之上,照片以该点为轴摆动 */
6
+ export declare const PIN_GRIP = 13;
7
+ /** 吊带质点数(含固定在主绳上的那一个) */
8
+ export declare const BAND_POINTS = 6;
9
+ /** 每步的约束松弛次数,越多吊带越不可拉伸 */
10
+ export declare const CONSTRAINT_PASSES = 8;
11
+ /** 小于此位移视为点击 */
12
+ export declare const CLICK_SLOP_PX = 4;
13
+ /** 横向拖出边界后的阻尼 */
14
+ export declare const OVERSCROLL_DAMP = 0.42;
15
+ export declare const MAX_FLING_SPEED = 3800;
16
+ /** 松手后照片能带走的最大速度(px/s) */
17
+ export declare const MAX_RELEASE_SPEED = 2600;
18
+ /** 吊带上的重力加速度(px/s²),决定摆动周期 */
19
+ export declare const GRAVITY_ACCEL = 2900;
20
+ /** 相纸绕夹子回正的扭转刚度,制造甩动时的滞后与抖动 */
21
+ export declare const SWING_K = 165;
22
+ /** 相纸最大摆角(deg),再狠的甩动也不会翻过绳子 */
23
+ export declare const MAX_SWING = 76;
24
+ /** 绕 Y 轴翻转的回正刚度与最大角度 */
25
+ export declare const SPIN_K = 60;
26
+ export declare const MAX_SPIN = 34;
27
+ /** 横向速度换算成翻转角的比例(deg per px/s) */
28
+ export declare const SPIN_DRIVE = 0.05;
29
+ /** 松手后多余吊带的收回速率(1/s),时间常数约 90ms */
30
+ export declare const BAND_RECOVER_RATE = 11;
31
+ /** 相纸旋转的兜底上限(deg),只在极端甩动时才会碰到 */
32
+ export declare const ROT_LIMIT = 108;
33
+ /** 吊带中段的渲染跟随速率(1/s),越大越贴合物理、越小越柔 */
34
+ export declare const BAND_SMOOTH_RATE = 34;
35
+ /**
36
+ * 跟手目标的平滑速率(1/s):抹平指针事件与物理步长之间的错拍。
37
+ * 时间常数约 9ms,快速拖动时照片落后指针也只有几个像素,不会有拖泥带水的手感。
38
+ */
39
+ export declare const DRAG_FOLLOW_RATE = 110;
40
+ /** 翻转角驱动速度的平滑速率(1/s),避免指针采样错拍让照片一帧一抖 */
41
+ export declare const SPIN_INPUT_RATE = 18;
42
+ /** 判定静止用的阈值:每步位移、距静止位偏移 */
43
+ export declare const REST_MOTION_PX = 0.02;
44
+ export declare const REST_OFFSET_PX = 0.6;
@@ -0,0 +1,23 @@
1
+ import { Layout, Physics } from './model';
2
+ export interface LayoutInput {
3
+ count: number;
4
+ viewportWidth: number;
5
+ viewportHeight: number;
6
+ photoWidth: number;
7
+ photoHeight: number;
8
+ photoGap: number;
9
+ ropeTop: number;
10
+ ropeSag: number;
11
+ bandLength: number;
12
+ maxPull: number;
13
+ tilt: number;
14
+ }
15
+ export declare const buildLayout: ({ count, viewportWidth, viewportHeight, photoWidth, photoHeight, photoGap, ropeTop, ropeSag, bandLength, maxPull, tilt }: LayoutInput) => Layout;
16
+ export interface PhysicsInput {
17
+ bandLength: number;
18
+ damping: number;
19
+ maxPull: number;
20
+ stiffness: number;
21
+ tension: number;
22
+ }
23
+ export declare const buildPhysics: ({ bandLength, damping, maxPull, stiffness, tension }: PhysicsInput) => Physics;
@@ -0,0 +1,6 @@
1
+ export declare const clamp: (value: number, min: number, max: number) => number;
2
+ /** 由索引推出的稳定伪随机数,SSR 与客户端结果一致 */
3
+ export declare const pseudoRandom: (seed: number) => number;
4
+ export declare const cssSize: (value: number | string) => string;
5
+ /** 超出自然长度后越拉越吃力,等价于吊带被逐渐拉紧 */
6
+ export declare const softPull: (raw: number, limit: number) => number;
@@ -0,0 +1,110 @@
1
+ export interface ChainPoint {
2
+ x: number;
3
+ y: number;
4
+ /** 上一步位置,verlet 用它表示速度 */
5
+ px: number;
6
+ py: number;
7
+ /** 上一物理步开始时的位置,渲染时在它和当前位置之间插值 */
8
+ sx: number;
9
+ sy: number;
10
+ /** 实际画出来的位置,中间质点会再跟随平滑一次 */
11
+ rx: number;
12
+ ry: number;
13
+ }
14
+ export interface HangerNode {
15
+ /** 吊带质点,[0] 固定在主绳上,末尾那个是照片的悬挂点 */
16
+ chain: ChainPoint[];
17
+ /** 相纸平面内的摆角(deg) */
18
+ rot: number;
19
+ vRot: number;
20
+ /** 绕 Y 轴的翻转角(deg) */
21
+ spin: number;
22
+ vSpin: number;
23
+ /** 平滑后的横向速度,只用来驱动翻转 */
24
+ swayVx: number;
25
+ /** 被拖出来的额外吊带长度(px):拉的时候立刻跟手,松手后平滑收回 */
26
+ slack: number;
27
+ /** 主绳在该夹点被拽下的量(px) */
28
+ ropeY: number;
29
+ ropeVy: number;
30
+ /** 上一物理步开始时的姿态,供渲染插值 */
31
+ sRot: number;
32
+ sSpin: number;
33
+ sRopeY: number;
34
+ }
35
+ /** 主绳采样点:基础高度 + 受哪几个夹点牵引 */
36
+ export interface RopeAnchor {
37
+ x: number;
38
+ baseY: number;
39
+ pulls: Array<{
40
+ index: number;
41
+ weight: number;
42
+ }>;
43
+ }
44
+ export interface Layout {
45
+ railWidth: number;
46
+ stageHeight: number;
47
+ cardLefts: number[];
48
+ cardTops: number[];
49
+ pinOffsets: number[];
50
+ /** 吊带固定端在 rail 坐标中的横向位置 */
51
+ pinXs: number[];
52
+ /** 吊带固定端的静止高度(不含动态下拽) */
53
+ anchorYs: number[];
54
+ baseRots: number[];
55
+ centers: number[];
56
+ anchors: RopeAnchor[];
57
+ }
58
+ export interface Physics {
59
+ /** 吊带自然长度与分段长度 */
60
+ bandLength: number;
61
+ segLength: number;
62
+ /** 重力加速度(px/s²) */
63
+ gravityAccel: number;
64
+ /** verlet 每步保留的速度比例 */
65
+ chainKeep: number;
66
+ swingDamp: number;
67
+ spinDamp: number;
68
+ /** 吊带绷紧后把主绳往下拽的强度 */
69
+ bandK: number;
70
+ /** 松手后多余吊带的收回速率(1/s) */
71
+ bandRecover: number;
72
+ springK: number;
73
+ springC: number;
74
+ neighborK: number;
75
+ maxPull: number;
76
+ }
77
+ export interface DragState {
78
+ pointerId: number;
79
+ mode: 'photo' | 'pan';
80
+ photoIndex: number;
81
+ /** 抓取点与悬挂点的偏移,保证按下瞬间照片不跳位 */
82
+ grabDx: number;
83
+ grabDy: number;
84
+ /** 指针在 rail 坐标中的位置 */
85
+ pointerX: number;
86
+ pointerY: number;
87
+ /** 平滑后的跟手目标:指针事件的频率和物理步长对不齐,直接钉上去会抖 */
88
+ smoothX: number;
89
+ smoothY: number;
90
+ /** 按下时量一次容器位置,避免每次 move 都触发同步布局 */
91
+ rectLeft: number;
92
+ rectTop: number;
93
+ startX: number;
94
+ startY: number;
95
+ startOffset: number;
96
+ lastX: number;
97
+ lastY: number;
98
+ lastTime: number;
99
+ vx: number;
100
+ vy: number;
101
+ moved: number;
102
+ }
103
+ export interface Point2 {
104
+ x: number;
105
+ y: number;
106
+ }
107
+ export declare const restChainPoint: (layout: Layout | null, physics: Physics | null, index: number, point: number) => Point2;
108
+ export declare const createChain: (layout: Layout, physics: Physics, index: number) => ChainPoint[];
109
+ export declare const createHangerNode: (layout: Layout, physics: Physics, index: number) => HangerNode;
110
+ export declare const resetHangerNode: (node: HangerNode, layout: Layout | null, physics: Physics | null, index: number) => void;
@@ -0,0 +1,5 @@
1
+ /** Catmull-Rom 采样点转三次贝塞尔,绳索过每个夹点且整体平滑 */
2
+ export declare const buildRopeD: (points: Array<{
3
+ x: number;
4
+ y: number;
5
+ }>, length?: number) => string;
@@ -0,0 +1,46 @@
1
+ import { DragState, HangerNode, Layout, Physics, Point2 } from './model';
2
+ export interface SimPaintTargets {
3
+ rail: HTMLDivElement | null;
4
+ ropePaths: Array<SVGPathElement | null>;
5
+ bandPaths: Array<SVGPathElement | null>;
6
+ bandGloss: Array<SVGPathElement | null>;
7
+ knots: Array<SVGCircleElement | null>;
8
+ cards: Array<HTMLDivElement | null>;
9
+ }
10
+ export interface SimPaintCache {
11
+ bands: string[];
12
+ cards: string[];
13
+ rope: string;
14
+ rail: string;
15
+ }
16
+ export interface SimState {
17
+ nodes: HangerNode[];
18
+ layout: Layout | null;
19
+ physics: Physics | null;
20
+ offset: number;
21
+ offsetVelocity: number;
22
+ snapTarget: number | null;
23
+ drag: DragState | null;
24
+ impulse: {
25
+ index: number;
26
+ vx: number;
27
+ vy: number;
28
+ } | null;
29
+ buffer: Point2[];
30
+ }
31
+ export declare const getOffsetBounds: (viewWidth: number, railWidth: number) => {
32
+ min: number;
33
+ max: number;
34
+ };
35
+ /**
36
+ * 物理是定步长跑的,屏幕刷新率跟它对不齐;直接画最新状态会出现「有的帧走两步、有的帧一步都没走」的顿挫。
37
+ * 这里按 alpha 在上一步与当前步之间插值,等价于 rapier 默认开启的插值渲染。
38
+ */
39
+ export declare const paintSimulation: (state: SimState, targets: SimPaintTargets, cache: SimPaintCache, alpha: number, dt: number) => void;
40
+ export declare const stepPhysics: (state: SimState, viewWidth: number, h: number) => void;
41
+ /**
42
+ * 静止判定看「每步位移」而不是绝对位置:绳索约束会让吊带静态多伸长零点几个像素,
43
+ * 再叠加「距静止位足够近」这一条,摆到最高点那一帧速度为零也不会被误判成停下。
44
+ */
45
+ export declare const isSimulationSettled: (state: SimState, viewWidth: number) => boolean;
46
+ export declare const settleSimulation: (state: SimState) => void;
@@ -56,6 +56,8 @@ export interface PhotoClotheslineProps {
56
56
  showCaption?: boolean;
57
57
  /** 初始居中显示的照片索引 */
58
58
  initialIndex?: number;
59
+ /** 居中照片变化回调(拖拽/惯性停稳后) */
60
+ onIndexChange?: (index: number, photo: PhotoClotheslineItem) => void;
59
61
  /** 点击照片回调 */
60
62
  onPhotoClick?: (index: number, photo: PhotoClotheslineItem) => void;
61
63
  /** 无障碍名称 */
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+ import { PhotoFilmstripProps } from './types';
3
+ declare const PhotoFilmstrip: React.FC<PhotoFilmstripProps>;
4
+ export type { PhotoFilmstripItem, PhotoFilmstripProps } from './types';
5
+ export default PhotoFilmstrip;
@@ -0,0 +1,43 @@
1
+ import { CSSProperties } from 'react';
2
+ export interface PhotoFilmstripItem {
3
+ /** 图片地址 */
4
+ src: string;
5
+ /** 图片替代文本 */
6
+ alt?: string;
7
+ /** 照片标题 */
8
+ title?: string;
9
+ /** 照片说明 */
10
+ description?: string;
11
+ }
12
+ export interface PhotoFilmstripProps {
13
+ /** 胶片条上的照片列表 */
14
+ photos: PhotoFilmstripItem[];
15
+ /** 组件宽度 */
16
+ width?: number | string;
17
+ /** 组件高度 */
18
+ height?: number | string;
19
+ /** 单帧宽度(px) */
20
+ frameWidth?: number;
21
+ /** 单帧高度(px) */
22
+ frameHeight?: number;
23
+ /** 帧间距(px) */
24
+ frameGap?: number;
25
+ /** 是否显示标题与说明 */
26
+ showCaption?: boolean;
27
+ /** 惯性摩擦系数,越大停得越快 */
28
+ friction?: number;
29
+ /** 拖拽灵敏度,1 为 1:1 跟手 */
30
+ dragSensitivity?: number;
31
+ /** 初始居中显示的帧索引 */
32
+ initialIndex?: number;
33
+ /** 点击照片回调 */
34
+ onPhotoClick?: (index: number, photo: PhotoFilmstripItem) => void;
35
+ /** 当前居中帧变化回调 */
36
+ onIndexChange?: (index: number, photo: PhotoFilmstripItem) => void;
37
+ /** 无障碍名称 */
38
+ ariaLabel?: string;
39
+ /** 自定义类名 */
40
+ className?: string;
41
+ /** 自定义样式 */
42
+ style?: CSSProperties;
43
+ }
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+ import { PhotoFridgeProps } from './types';
3
+ declare const PhotoFridge: React.FC<PhotoFridgeProps>;
4
+ export default PhotoFridge;
5
+ export type { PhotoFridgeItem, PhotoFridgeProps } from './types';
@@ -0,0 +1,41 @@
1
+ import { CSSProperties } from 'react';
2
+ /** 单张冰箱磁贴照片数据 */
3
+ export interface PhotoFridgeItem {
4
+ /** 图片地址 */
5
+ src: string;
6
+ /** 图片替代文本 */
7
+ alt?: string;
8
+ /** 照片标题(显示在图片下方) */
9
+ title?: string;
10
+ /** 照片说明(显示在标题下方) */
11
+ description?: string;
12
+ }
13
+ /** PhotoFridge 组件属性 */
14
+ export interface PhotoFridgeProps {
15
+ /** 磁贴照片列表 */
16
+ photos: PhotoFridgeItem[];
17
+ /** 组件宽度 */
18
+ width?: number | string;
19
+ /** 组件高度 */
20
+ height?: number | string;
21
+ /** 单张卡片宽度(px) */
22
+ cardWidth?: number;
23
+ /** 单张卡片高度(px) */
24
+ cardHeight?: number;
25
+ /** 散落程度,0 为紧凑,1 为默认散布,>1 更分散 */
26
+ scatter?: number;
27
+ /** 释放惯性摩擦系数,越大减速越快(指数衰减,默认 2.0) */
28
+ friction?: number;
29
+ /** 是否显示标题与说明 */
30
+ showCaption?: boolean;
31
+ /** 初始置于最前的照片索引 */
32
+ initialIndex?: number;
33
+ /** 点击照片回调(几乎无位移时触发) */
34
+ onPhotoClick?: (index: number, photo: PhotoFridgeItem) => void;
35
+ /** 无障碍名称 */
36
+ ariaLabel?: string;
37
+ /** 自定义类名 */
38
+ className?: string;
39
+ /** 自定义样式 */
40
+ style?: CSSProperties;
41
+ }
@@ -0,0 +1,4 @@
1
+ import { LanternMaterials } from './materials';
2
+ import * as THREE from 'three';
3
+ /** 吊环、角饰、流苏、底穗 —— 几何与材质参数保持与原实现一致 */
4
+ export declare const addLanternAccessories: (rotor: THREE.Group, mats: LanternMaterials, vertexR: number, apothem: number) => void;
@@ -0,0 +1,5 @@
1
+ export declare const FACE_COUNT = 6;
2
+ export declare const FACE_ANGLE: number;
3
+ export declare const PANEL_W = 1.12;
4
+ export declare const PANEL_H = 2.05;
5
+ export declare const PHOTO_SCALE = 0.84;
@@ -0,0 +1,4 @@
1
+ import * as THREE from 'three';
2
+ export declare const disposeMaterial: (material: THREE.Material | THREE.Material[]) => void;
3
+ /** 释放场景内几何与材质;shared 用于跨 mesh 共用材质只 dispose 一次 */
4
+ export declare const disposeObject: (root: THREE.Object3D, shared?: Set<THREE.Material<THREE.MaterialEventMap>>) => void;
@@ -0,0 +1,5 @@
1
+ import * as THREE from 'three';
2
+ export declare const createHexShape: (radius: number) => THREE.Shape;
3
+ /** 圆角矩形:灯纸外框 / 内缘装饰 */
4
+ export declare const createRoundedRectShape: (w: number, h: number, r: number) => THREE.Shape;
5
+ export declare const createFramedRect: (outerW: number, outerH: number, outerR: number, holeW: number, holeH: number, holeR: number) => THREE.Shape;
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+ import { PhotoLanternProps } from './types';
3
+ declare const PhotoLantern: React.FC<PhotoLanternProps>;
4
+ export type { PhotoLanternItem, PhotoLanternProps } from './types';
5
+ export default PhotoLantern;
@@ -0,0 +1,9 @@
1
+ import * as THREE from 'three';
2
+ export interface LanternMaterials {
3
+ frameMat: THREE.MeshPhysicalMaterial;
4
+ accentMat: THREE.MeshPhysicalMaterial;
5
+ trimMat: THREE.MeshPhysicalMaterial;
6
+ beadMat: THREE.MeshPhysicalMaterial;
7
+ silkMat: THREE.MeshPhysicalMaterial;
8
+ }
9
+ export declare const createLanternMaterials: (frameColor: THREE.Color, tasselColor: THREE.Color, anisotropy: number) => LanternMaterials;
@@ -0,0 +1,32 @@
1
+ import { PhotoLanternItem } from './types';
2
+ import * as THREE from 'three';
3
+ export { FACE_COUNT, FACE_ANGLE } from './constants';
4
+ export interface LanternSceneOptions {
5
+ width: number;
6
+ height: number;
7
+ photos: (PhotoLanternItem | undefined)[];
8
+ frameColor: string;
9
+ paperColor: string;
10
+ lightColor: string;
11
+ tasselColor: string;
12
+ showAccessories: boolean;
13
+ showCaption: boolean;
14
+ silhouette: boolean;
15
+ objectFit: 'cover' | 'contain' | 'fill' | string;
16
+ background?: string;
17
+ initialAngleDeg: number;
18
+ /** 首批照片加载完成(或超时)后回调,用于避免首屏白闪 */
19
+ onReady?: () => void;
20
+ }
21
+ export interface LanternSceneApi {
22
+ renderer: THREE.WebGLRenderer;
23
+ setAngleDeg: (deg: number) => void;
24
+ getAngleDeg: () => number;
25
+ setLightSway: (t: number, sway: number) => void;
26
+ setSize: (width: number, height: number) => void;
27
+ updatePhotos: (photos: (PhotoLanternItem | undefined)[], silhouette: boolean, objectFit: string, showCaption: boolean) => void;
28
+ render: () => void;
29
+ dispose: () => void;
30
+ }
31
+ export declare const createLanternScene: (canvas: HTMLCanvasElement, options: LanternSceneOptions) => LanternSceneApi;
32
+ export declare const frontFaceIndex: (angleDeg: number) => number;
@@ -0,0 +1,9 @@
1
+ import * as THREE from 'three';
2
+ export declare const parseColor: (value: string) => THREE.Color;
3
+ export declare const createSoftShadowTexture: () => THREE.CanvasTexture<HTMLCanvasElement>;
4
+ /** 程序化木纹:纵向年轮 + 细微噪点 */
5
+ export declare const createWoodGrainTexture: (base: string, vein: string, size?: number) => THREE.CanvasTexture<HTMLCanvasElement>;
6
+ export declare const createWoodMap: (base: string, vein: string, repeatX: number, repeatY: number, anisotropy: number) => THREE.CanvasTexture<HTMLCanvasElement>;
7
+ export declare const fitTexture: (texture: THREE.Texture, objectFit: string, panelAspect: number, anisotropy: number) => void;
8
+ /** 把标题/说明画进照片底部 */
9
+ export declare const composeCaptionTexture: (source: CanvasImageSource, title?: string, description?: string) => THREE.CanvasTexture;