types.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { KrpanoActionProxy } from "./models";
  2. declare global {
  3. interface Window {
  4. krpanoJS?: {
  5. version: string;
  6. };
  7. embedpano?: (config: IKrpanoConfig) => void;
  8. /**
  9. * 开启 dev 模式,在拖动热点时会调用此事件
  10. */
  11. draggbleHotspotEvent?: (ath: number, atv: number) => void;
  12. ReactKrpanoActionProxy?: KrpanoActionProxy;
  13. onVideoSceneReady: () => void;
  14. onVideoScenePlay: () => void;
  15. onVideoScenePaused: () => void;
  16. onVideoSceneComplete: () => void;
  17. onVideoSceneError: (err: string) => void;
  18. }
  19. interface EventMapper {
  20. "Event.videoScene.ready": undefined;
  21. "Event.videoScene.play": undefined;
  22. "Event.videoScene.pause": undefined;
  23. "Event.videoScene.complete": undefined;
  24. "Event.videoScene.error": string;
  25. }
  26. }
  27. export interface NativeKrpanoRendererObject {
  28. buildversion: string;
  29. get(key: string): any;
  30. call(action: string): void;
  31. }
  32. /**
  33. * @see https://krpano.com/docu/html/#wmode
  34. */
  35. export interface IKrpanoConfig {
  36. /**
  37. * 全景图xml路径。需要手动设置为null才不会加载。
  38. * @see https://krpano.com/docu/html/#xml
  39. */
  40. xml?: string | null;
  41. /** 挂载点id */
  42. target: string;
  43. swf?: string;
  44. id?: string;
  45. bgcolor?: string;
  46. /**
  47. * @see https://krpano.com/docu/html/#html5
  48. */
  49. html5?: string;
  50. flash?: string;
  51. wmode?: string;
  52. localfallback?: string;
  53. vars?: Record<string, unknown>;
  54. initvars?: Record<string, unknown>;
  55. consolelog?: boolean;
  56. basepath?: string;
  57. mwheel?: boolean;
  58. capturetouch?: boolean;
  59. focus?: boolean;
  60. webglsettings?: Record<string, unknown>;
  61. webxr?: string;
  62. mobilescale?: number;
  63. touchdevicemousesupport?: boolean;
  64. fakedevice?: string;
  65. passQueryParameters?: boolean;
  66. onready?: (renderer: NativeKrpanoRendererObject) => void;
  67. }
  68. export type EventCallback = (renderer: KrpanoActionProxy) => void;
  69. export interface XMLMeta {
  70. tag: string;
  71. attrs: Record<string, string | number | boolean>;
  72. children?: XMLMeta[];
  73. }
  74. /**
  75. * 旋转方位
  76. */
  77. export enum ROTATE_DIRECTION {
  78. UP = "up",
  79. DOWN = "down",
  80. LEFT = "left",
  81. RIGHT = "right",
  82. }
  83. /**
  84. * 缩放动作
  85. */
  86. export enum ZOOM_ACTION {
  87. IN = "in",
  88. OUT = "out",
  89. }