@realsee/vreo 0.2.0-alpha.9 → 1.0.0-alpha.10
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/CHANGELOG.md +30 -0
- package/README.md +16 -5
- package/docs/assets/highlight.css +1 -1
- package/docs/assets/main.js +2 -2
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +28 -2
- package/docs/classes/Player.AudioLike.html +52 -0
- package/docs/classes/Player.Controller.html +13 -13
- package/docs/classes/Player.Player-1.html +11 -11
- package/docs/classes/Player.VideoAgentMesh.html +53 -53
- package/docs/classes/Player.VideoAgentScene.html +1 -1
- package/docs/demo/assets/AppReact.ea8cbdb3.js +1 -0
- package/docs/demo/assets/default.1dd2b2d4.js +3988 -0
- package/docs/demo/assets/default.bc4c715d.css +1 -0
- package/docs/demo/assets/dynamic.cd7d1da6.js +1 -0
- package/docs/demo/assets/examples.98aaf9e2.js +25 -0
- package/docs/demo/assets/examples.dac4a6fe.css +1 -0
- package/docs/demo/assets/index.9331038f.css +1 -0
- package/docs/demo/assets/index.a3d7bd8a.js +1 -0
- package/docs/demo/assets/main.f0c47cae.js +1 -0
- package/docs/demo/assets/react.2ee8565f.css +1 -0
- package/docs/demo/assets/react.5f3bcfc5.js +25 -0
- package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +1 -0
- package/docs/demo/examples.html +17 -0
- package/docs/demo/index-react-dynamic.html +20 -0
- package/docs/demo/index-react.html +20 -0
- package/docs/demo/index.html +19 -0
- package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
- package/docs/enums/Player.InfoPanelTypeEnum.html +2 -2
- package/docs/enums/Player.PanoEffectEnum.html +2 -2
- package/docs/enums/Player.PanoTagEnum.html +2 -2
- package/docs/enums/Player.PanoTagStyleEnum.html +7 -0
- package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
- package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
- package/docs/enums/fivePlugins.Rotation.html +1 -1
- package/docs/index.html +13 -6
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
- package/docs/interfaces/Player.PlayerConfigs.html +4 -3
- package/docs/interfaces/Player.Vertex.html +2 -2
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +8 -1
- package/docs/interfaces/Player.VreoKeyframe.html +2 -2
- package/docs/interfaces/Player.VreoUnit.html +2 -2
- package/docs/interfaces/Player.VreoVideo.html +2 -2
- package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +4 -0
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
- package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/fivePlugins.Vector3Position.html +3 -0
- package/docs/interfaces/react.VreoActionCallbacks.html +15 -7
- package/docs/interfaces/react.VreoProviderProps.html +1 -1
- package/docs/modules/Player.html +21 -15
- package/docs/modules/custom.html +1 -1
- package/docs/modules/fivePlugins.html +5 -2
- package/docs/modules/react.html +1 -1
- package/docs/modules.html +1 -1
- package/lib/PlayController/createHTMLAudioElement.js +6 -11
- package/lib/PlayController/index.js +19 -85
- package/lib/Player/App.js +7 -29
- package/lib/Player/Controller.d.ts +29 -8
- package/lib/Player/Controller.js +185 -87
- package/lib/Player/custom/SpatialScenePanel/index.js +47 -72
- package/lib/Player/hooks.js +2 -12
- package/lib/Player/index.d.ts +5 -3
- package/lib/Player/index.js +108 -122
- package/lib/Player/modules/Drawer/index.js +1 -18
- package/lib/Player/modules/PopUp/index.js +1 -11
- package/lib/Player/modules/ResizeObserver/index.d.ts +2 -0
- package/lib/Player/modules/ResizeObserver/index.js +29 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +16 -2
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +124 -145
- package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +3 -6
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +25 -52
- package/lib/Player/modules/VideoAgent/index.js +46 -22
- package/lib/Player/modules/Wave/index.d.ts +5 -0
- package/lib/Player/modules/Wave/index.js +77 -0
- package/lib/Player/modules/keyframes/BgMusic/index.js +3 -16
- package/lib/Player/modules/keyframes/CameraMovement/index.js +4 -28
- package/lib/Player/modules/keyframes/InfoPanel/index.js +30 -35
- package/lib/Player/modules/keyframes/ModelVideo/index.js +40 -29
- package/lib/Player/modules/keyframes/PanoEffect/index.js +16 -44
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -8
- package/lib/Player/modules/keyframes/PanoTag/index.d.ts +1 -2
- package/lib/Player/modules/keyframes/PanoTag/index.js +75 -132
- package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +3 -0
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +93 -66
- package/lib/Player/modules/keyframes/Prompter/index.js +18 -53
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +22 -25
- package/lib/Player/modules/keyframes/VideoEffect/index.js +13 -48
- package/lib/Player/typings.d.ts +12 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts +2 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +10 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts +7 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +31 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts +3 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +10 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +56 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +234 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts +7 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +15 -0
- package/lib/fivePlugins/CameraMovementPlugin/index.js +36 -82
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -4
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +12 -61
- package/lib/index.js +0 -1
- package/lib/react/index.d.ts +8 -4
- package/lib/react/index.js +10 -37
- package/lib/shared-utils/AduioLike.d.ts +37 -0
- package/lib/shared-utils/AduioLike.js +132 -0
- package/lib/shared-utils/Preloader.js +0 -7
- package/lib/shared-utils/addResizeListener.d.ts +4 -0
- package/lib/shared-utils/addResizeListener.js +46 -0
- package/lib/shared-utils/animationFrame/BetterTween.js +7 -39
- package/lib/shared-utils/animationFrame/index.js +2 -10
- package/lib/shared-utils/animationFrame/tween.js +3 -16
- package/lib/shared-utils/createTransMatrix.d.ts +1 -0
- package/lib/shared-utils/createTransMatrix.js +28 -0
- package/lib/shared-utils/getFileExpandedName.d.ts +1 -0
- package/lib/shared-utils/getFileExpandedName.js +12 -0
- package/lib/shared-utils/getMediaInfo.d.ts +9 -0
- package/lib/shared-utils/getMediaInfo.js +66 -0
- package/lib/shared-utils/setElementDataset.d.ts +1 -0
- package/lib/shared-utils/setElementDataset.js +22 -0
- package/lib/typings/VreoUnit.d.ts +37 -2
- package/lib/typings/VreoUnit.js +10 -13
- package/package.json +10 -10
- package/resources/PlayController/index.ts +0 -13
- package/resources/Player/App.tsx +5 -4
- package/resources/Player/Controller.ts +274 -146
- package/resources/Player/custom/SpatialScenePanel/index.tsx +5 -5
- package/resources/Player/hooks.ts +3 -5
- package/resources/Player/index.tsx +190 -140
- package/resources/Player/modules/ResizeObserver/index.tsx +23 -0
- package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +87 -31
- package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +27 -24
- package/resources/Player/modules/VideoAgent/index.tsx +28 -12
- package/resources/Player/modules/Wave/index.tsx +64 -0
- package/resources/Player/modules/keyframes/InfoPanel/index.tsx +26 -11
- package/resources/Player/modules/keyframes/ModelVideo/index.tsx +36 -3
- package/resources/Player/modules/keyframes/PanoTag/index.tsx +52 -97
- package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +86 -34
- package/resources/Player/modules/keyframes/Prompter/index.tsx +6 -16
- package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +6 -2
- package/resources/Player/typings.ts +15 -1
- package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +5 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +17 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +4 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +254 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +5 -0
- package/resources/fivePlugins/CameraMovementPlugin/index.ts +19 -12
- package/resources/react/index.tsx +7 -3
- package/resources/shared-utils/AduioLike.ts +109 -0
- package/resources/shared-utils/addResizeListener.ts +46 -0
- package/resources/shared-utils/createTransMatrix.ts +12 -0
- package/resources/shared-utils/getFileExpandedName.ts +6 -0
- package/resources/shared-utils/getMediaInfo.ts +52 -0
- package/resources/shared-utils/setElementDataset.ts +18 -0
- package/resources/typings/VreoUnit.ts +41 -3
- package/stylesheets/custom/SpatialScenePanel.css +2 -1
- package/stylesheets/default.css +350 -84
package/lib/index.js
CHANGED
package/lib/react/index.d.ts
CHANGED
|
@@ -11,12 +11,16 @@ export declare const VreoProvider: React.FC<VreoProviderProps>;
|
|
|
11
11
|
export interface VreoActionCallbacks {
|
|
12
12
|
/**
|
|
13
13
|
* 载入剧本数据。
|
|
14
|
+
* @param vreoUnit 剧本数据
|
|
15
|
+
* @param currentTime 开始时间戳
|
|
16
|
+
* @param preload 是否开启预载
|
|
17
|
+
* @param force 是否强制载入
|
|
14
18
|
*/
|
|
15
|
-
load: (vreoUnit: VreoUnit, currentTime?: number) => Promise<boolean>;
|
|
19
|
+
load: (vreoUnit: VreoUnit, currentTime?: number, preload?: boolean, force?: boolean) => Promise<boolean>;
|
|
16
20
|
/**
|
|
17
21
|
* 播放。
|
|
18
22
|
*/
|
|
19
|
-
play: () => void;
|
|
23
|
+
play: (currentTime?: number) => void;
|
|
20
24
|
/**
|
|
21
25
|
* 暂停。
|
|
22
26
|
*/
|
|
@@ -35,10 +39,10 @@ export interface VreoActionCallbacks {
|
|
|
35
39
|
dispose: () => void;
|
|
36
40
|
}
|
|
37
41
|
export declare function useVreoAction(): {
|
|
38
|
-
load: (vreoUnit: VreoUnit, currentTime?: number
|
|
42
|
+
load: (vreoUnit: VreoUnit, currentTime?: number) => Promise<boolean>;
|
|
39
43
|
pause: () => void;
|
|
40
44
|
show: () => void;
|
|
41
|
-
play: () => boolean;
|
|
45
|
+
play: (currentTime?: number) => boolean;
|
|
42
46
|
hide: () => void;
|
|
43
47
|
dispose: () => void;
|
|
44
48
|
};
|
package/lib/react/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
4
|
-
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,46 +8,30 @@ exports.VreoProvider = void 0;
|
|
|
9
8
|
exports.useVreoAction = useVreoAction;
|
|
10
9
|
exports.useVreoEventCallback = useVreoEventCallback;
|
|
11
10
|
exports.useVreoPausedState = useVreoPausedState;
|
|
12
|
-
|
|
13
11
|
var _react = require("@realsee/five/react");
|
|
14
|
-
|
|
15
12
|
var React = _interopRequireWildcard(require("react"));
|
|
16
|
-
|
|
17
13
|
var _Player = require("../Player");
|
|
18
|
-
|
|
19
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
|
-
|
|
21
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
-
|
|
23
16
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
24
|
-
|
|
25
17
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
26
|
-
|
|
27
18
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
28
|
-
|
|
29
19
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
30
|
-
|
|
31
20
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
32
|
-
|
|
33
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
34
|
-
|
|
35
22
|
var VreoContext = /*#__PURE__*/React.createContext(null);
|
|
36
|
-
|
|
37
23
|
var VreoProvider = function VreoProvider(props) {
|
|
38
24
|
var five = (0, _react.unsafe__useFiveInstance)();
|
|
39
|
-
|
|
40
25
|
var _React$useState = React.useState(null),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
27
|
+
player = _React$useState2[0],
|
|
28
|
+
setPlayer = _React$useState2[1];
|
|
45
29
|
var playerRef = React.useRef(null);
|
|
46
30
|
React.useEffect(function () {
|
|
47
31
|
playerRef.current = new _Player.Player(five, props.configs || {});
|
|
48
32
|
setPlayer(playerRef.current);
|
|
49
33
|
return function () {
|
|
50
34
|
var _playerRef$current;
|
|
51
|
-
|
|
52
35
|
(_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.dispose();
|
|
53
36
|
};
|
|
54
37
|
}, []);
|
|
@@ -57,30 +40,26 @@ var VreoProvider = function VreoProvider(props) {
|
|
|
57
40
|
value: player
|
|
58
41
|
}, props.children);
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
exports.VreoProvider = VreoProvider;
|
|
62
|
-
|
|
63
44
|
function useVreoInstance() {
|
|
64
45
|
var context = React.useContext(VreoContext);
|
|
65
|
-
|
|
66
46
|
if (!context) {
|
|
67
47
|
throw new Error('VreoProvider never found.');
|
|
68
48
|
}
|
|
69
|
-
|
|
70
49
|
return context;
|
|
71
50
|
}
|
|
51
|
+
|
|
72
52
|
/**
|
|
73
53
|
* VreoPlayer 命令集合。
|
|
74
54
|
*/
|
|
75
55
|
|
|
76
|
-
|
|
77
56
|
function useVreoAction() {
|
|
78
57
|
var player = useVreoInstance();
|
|
79
58
|
var load = React.useCallback(function (vreoUnit, currentTime) {
|
|
80
59
|
return player.load(vreoUnit, currentTime);
|
|
81
60
|
}, [player]);
|
|
82
|
-
var play = React.useCallback(function () {
|
|
83
|
-
return player.play();
|
|
61
|
+
var play = React.useCallback(function (currentTime) {
|
|
62
|
+
return player.play(currentTime || 0);
|
|
84
63
|
}, [player]);
|
|
85
64
|
var pause = React.useCallback(function () {
|
|
86
65
|
return player.pause();
|
|
@@ -103,15 +82,12 @@ function useVreoAction() {
|
|
|
103
82
|
dispose: dispose
|
|
104
83
|
};
|
|
105
84
|
}
|
|
106
|
-
|
|
107
85
|
function useVreoEventCallback(name, callback, deps) {
|
|
108
86
|
var player = useVreoInstance();
|
|
109
87
|
var dependencyList = [player, name];
|
|
110
|
-
|
|
111
88
|
if (deps !== undefined) {
|
|
112
89
|
dependencyList = dependencyList.concat(deps);
|
|
113
90
|
}
|
|
114
|
-
|
|
115
91
|
React.useEffect(function () {
|
|
116
92
|
// @ts-ignore
|
|
117
93
|
player.on(name, callback);
|
|
@@ -121,15 +97,12 @@ function useVreoEventCallback(name, callback, deps) {
|
|
|
121
97
|
};
|
|
122
98
|
}, dependencyList);
|
|
123
99
|
}
|
|
124
|
-
|
|
125
100
|
function useVreoPausedState() {
|
|
126
101
|
var player = useVreoInstance();
|
|
127
|
-
|
|
128
102
|
var _React$useState3 = React.useState(player.paused),
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
103
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
104
|
+
state = _React$useState4[0],
|
|
105
|
+
setState = _React$useState4[1];
|
|
133
106
|
useVreoEventCallback('paused', function () {
|
|
134
107
|
return setState(true);
|
|
135
108
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Subscribe } from '@realsee/five';
|
|
2
|
+
/**
|
|
3
|
+
* 模拟 `<Audio>` 事件。
|
|
4
|
+
*/
|
|
5
|
+
export declare type AudioLikeEvent = {
|
|
6
|
+
play: () => void;
|
|
7
|
+
pause: () => void;
|
|
8
|
+
timeupdate: () => void;
|
|
9
|
+
ended: () => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 模拟 `<Audio>` 功能:没有音频,但执行逻辑跟 `<Audio>` 相似。
|
|
13
|
+
*/
|
|
14
|
+
export declare class AudioLike extends Subscribe<AudioLikeEvent> {
|
|
15
|
+
private $timestamp;
|
|
16
|
+
private $currentTime;
|
|
17
|
+
private $duration;
|
|
18
|
+
private stopInterval?;
|
|
19
|
+
muted: boolean;
|
|
20
|
+
src: string;
|
|
21
|
+
setAttribute(name: string, value: string): void;
|
|
22
|
+
constructor({ duration }?: {
|
|
23
|
+
duration?: number;
|
|
24
|
+
});
|
|
25
|
+
play(): void;
|
|
26
|
+
pause(): void;
|
|
27
|
+
requestAnimationFrameLoop(): void;
|
|
28
|
+
get currentTime(): number;
|
|
29
|
+
set currentTime(time: number);
|
|
30
|
+
get duration(): number;
|
|
31
|
+
set duration(duration: number);
|
|
32
|
+
get ended(): boolean;
|
|
33
|
+
get paused(): boolean;
|
|
34
|
+
addEventListener(evtName: keyof AudioLikeEvent, callback: () => void, useCapture?: boolean): void;
|
|
35
|
+
removeEventListener(evtName: keyof AudioLikeEvent, callback: () => void, useCapture?: boolean): void;
|
|
36
|
+
}
|
|
37
|
+
export default AudioLike;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = exports.AudioLike = void 0;
|
|
8
|
+
var _five = require("@realsee/five");
|
|
9
|
+
var _animationFrame = require("./animationFrame");
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
17
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
20
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
/**
|
|
22
|
+
* 模拟 `<Audio>` 功能:没有音频,但执行逻辑跟 `<Audio>` 相似。
|
|
23
|
+
*/
|
|
24
|
+
var AudioLike = /*#__PURE__*/function (_Subscribe) {
|
|
25
|
+
_inherits(AudioLike, _Subscribe);
|
|
26
|
+
var _super = _createSuper(AudioLike);
|
|
27
|
+
function AudioLike() {
|
|
28
|
+
var _this;
|
|
29
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
30
|
+
duration = _ref.duration;
|
|
31
|
+
_classCallCheck(this, AudioLike);
|
|
32
|
+
_this = _super.call(this);
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "$timestamp", null);
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "$currentTime", 0);
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "$duration", 0);
|
|
36
|
+
_defineProperty(_assertThisInitialized(_this), "muted", false);
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "src", '');
|
|
38
|
+
if (duration) {
|
|
39
|
+
_this.$duration = duration;
|
|
40
|
+
}
|
|
41
|
+
return _this;
|
|
42
|
+
}
|
|
43
|
+
_createClass(AudioLike, [{
|
|
44
|
+
key: "setAttribute",
|
|
45
|
+
value: function setAttribute(name, value) {
|
|
46
|
+
// nothing todo
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "play",
|
|
50
|
+
value: function play() {
|
|
51
|
+
var _this2 = this;
|
|
52
|
+
if (this.$currentTime === this.$duration) {
|
|
53
|
+
this.$currentTime = 0;
|
|
54
|
+
}
|
|
55
|
+
if (this.$timestamp === null) {
|
|
56
|
+
this.$timestamp = performance.now() - this.$currentTime;
|
|
57
|
+
}
|
|
58
|
+
this.stopInterval = (0, _animationFrame.requestAnimationFrameInterval)(function () {
|
|
59
|
+
return _this2.requestAnimationFrameLoop();
|
|
60
|
+
});
|
|
61
|
+
this.emit('play');
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "pause",
|
|
65
|
+
value: function pause() {
|
|
66
|
+
if (this.stopInterval) {
|
|
67
|
+
this.stopInterval();
|
|
68
|
+
this.emit('pause');
|
|
69
|
+
this.stopInterval = undefined;
|
|
70
|
+
}
|
|
71
|
+
this.$timestamp = null;
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "requestAnimationFrameLoop",
|
|
75
|
+
value: function requestAnimationFrameLoop() {
|
|
76
|
+
if (this.$timestamp === null) return;
|
|
77
|
+
var now = performance.now();
|
|
78
|
+
this.$currentTime = now - this.$timestamp;
|
|
79
|
+
this.emit('timeupdate');
|
|
80
|
+
if (this.$currentTime >= this.$duration - 10) {
|
|
81
|
+
this.$currentTime = this.$duration;
|
|
82
|
+
this.pause();
|
|
83
|
+
this.emit('ended');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "currentTime",
|
|
88
|
+
get: function get() {
|
|
89
|
+
return this.$currentTime / 1000;
|
|
90
|
+
},
|
|
91
|
+
set: function set(time) {
|
|
92
|
+
this.$currentTime = time;
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "duration",
|
|
96
|
+
get: function get() {
|
|
97
|
+
return this.$duration;
|
|
98
|
+
},
|
|
99
|
+
set: function set(duration) {
|
|
100
|
+
this.pause();
|
|
101
|
+
this.$duration = duration;
|
|
102
|
+
this.$timestamp = null;
|
|
103
|
+
this.$currentTime = 0;
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "ended",
|
|
107
|
+
get: function get() {
|
|
108
|
+
return this.$currentTime === this.$duration;
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "paused",
|
|
112
|
+
get: function get() {
|
|
113
|
+
return !this.stopInterval;
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "addEventListener",
|
|
117
|
+
value: function addEventListener(evtName, callback) {
|
|
118
|
+
var useCapture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
119
|
+
this.on(evtName, callback);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "removeEventListener",
|
|
123
|
+
value: function removeEventListener(evtName, callback) {
|
|
124
|
+
var useCapture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
125
|
+
this.off(evtName, callback);
|
|
126
|
+
}
|
|
127
|
+
}]);
|
|
128
|
+
return AudioLike;
|
|
129
|
+
}(_five.Subscribe);
|
|
130
|
+
exports.AudioLike = AudioLike;
|
|
131
|
+
var _default = AudioLike;
|
|
132
|
+
exports["default"] = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Preloader = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* 预载器
|
|
10
9
|
*/
|
|
@@ -13,26 +12,21 @@ var Preloader = {
|
|
|
13
12
|
var noop = function noop() {
|
|
14
13
|
return null;
|
|
15
14
|
};
|
|
16
|
-
|
|
17
15
|
return new Promise(function (resolve, reject) {
|
|
18
16
|
var xhr = new XMLHttpRequest();
|
|
19
|
-
|
|
20
17
|
var clear = function clear() {
|
|
21
18
|
xhr.ontimeout = noop;
|
|
22
19
|
xhr.onreadystatechange = noop;
|
|
23
20
|
xhr.onprogress = noop;
|
|
24
21
|
xhr.onabort = noop;
|
|
25
22
|
};
|
|
26
|
-
|
|
27
23
|
xhr.ontimeout = function () {
|
|
28
24
|
reject(new Error('timeout'));
|
|
29
25
|
clear();
|
|
30
26
|
};
|
|
31
|
-
|
|
32
27
|
xhr.onreadystatechange = function () {
|
|
33
28
|
if (xhr.readyState !== 4) return;
|
|
34
29
|
if (xhr.status === 0 && !xhr.response) return;
|
|
35
|
-
|
|
36
30
|
if (xhr.status === 200 || xhr.status === 0) {
|
|
37
31
|
resolve(xhr.response);
|
|
38
32
|
clear();
|
|
@@ -41,7 +35,6 @@ var Preloader = {
|
|
|
41
35
|
clear();
|
|
42
36
|
}
|
|
43
37
|
};
|
|
44
|
-
|
|
45
38
|
xhr.open('GET', url, true);
|
|
46
39
|
xhr.responseType = 'blob';
|
|
47
40
|
xhr.send(null);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare type ResizeHandler = (width: number, height: number) => void;
|
|
2
|
+
export declare function addResizeListener(element: Element | undefined | null, resizeHandler: ResizeHandler, immediate?: boolean): () => void;
|
|
3
|
+
export declare function hasResizeListener(element?: Element | null): number | boolean;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.addResizeListener = addResizeListener;
|
|
7
|
+
exports.hasResizeListener = hasResizeListener;
|
|
8
|
+
var resizeObserverCache = new Map();
|
|
9
|
+
function addResizeListener(element, resizeHandler) {
|
|
10
|
+
var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
11
|
+
if (!element) return function () {};
|
|
12
|
+
if (immediate) resizeHandler(element.clientWidth, element.clientHeight);
|
|
13
|
+
if (typeof ResizeObserver !== 'undefined' && ResizeObserver) {
|
|
14
|
+
var resizeObserver = new ResizeObserver(function () {
|
|
15
|
+
return resizeHandler(element.clientWidth, element.clientHeight);
|
|
16
|
+
});
|
|
17
|
+
resizeObserver.observe(element);
|
|
18
|
+
resizeObserverCache.set(element, resizeObserverCache.get(element) || 0 + 1);
|
|
19
|
+
return function () {
|
|
20
|
+
if (element) resizeObserver.unobserve(element);
|
|
21
|
+
if (resizeObserverCache.get(element) === 1) {
|
|
22
|
+
resizeObserverCache["delete"](element);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
var iframe = document.createElement('iframe');
|
|
27
|
+
iframe.style.cssText = 'position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;opacity:0;visibility:hidden;margin:0;border:0;padding:0;z-index:-1;';
|
|
28
|
+
iframe.classList.add('resize-sensor-iframe');
|
|
29
|
+
element.appendChild(iframe);
|
|
30
|
+
if (!iframe.contentWindow) return function () {};
|
|
31
|
+
iframe.contentWindow.addEventListener('resize', function () {
|
|
32
|
+
resizeHandler(iframe.clientWidth, iframe.clientHeight);
|
|
33
|
+
});
|
|
34
|
+
resizeObserverCache.set(element, resizeObserverCache.get(element) || 0 + 1);
|
|
35
|
+
return function () {
|
|
36
|
+
element.removeChild(iframe);
|
|
37
|
+
if (resizeObserverCache.get(element) === 1) {
|
|
38
|
+
resizeObserverCache["delete"](element);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function hasResizeListener(element) {
|
|
44
|
+
if (!element) return false;
|
|
45
|
+
return resizeObserverCache.get(element) || 0 > 0;
|
|
46
|
+
}
|
|
@@ -1,94 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
4
|
-
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.BetterTween = void 0;
|
|
9
8
|
exports.tweenProgress = tweenProgress;
|
|
10
|
-
|
|
11
9
|
var _tween = _interopRequireDefault(require("@tweenjs/tween.js"));
|
|
12
|
-
|
|
13
10
|
var _ = require(".");
|
|
14
|
-
|
|
15
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
-
|
|
12
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
13
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
22
|
-
|
|
15
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
17
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
24
|
-
|
|
25
18
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
26
|
-
|
|
27
19
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
|
-
|
|
29
20
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
30
|
-
|
|
31
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
32
|
-
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
22
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
34
|
-
|
|
35
23
|
var BetterTween = /*#__PURE__*/function (_TWEEN$Tween) {
|
|
36
24
|
_inherits(BetterTween, _TWEEN$Tween);
|
|
37
|
-
|
|
38
25
|
var _super = _createSuper(BetterTween);
|
|
39
|
-
|
|
40
26
|
function BetterTween() {
|
|
41
27
|
var _this;
|
|
42
|
-
|
|
43
28
|
_classCallCheck(this, BetterTween);
|
|
44
|
-
|
|
45
29
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
46
30
|
args[_key] = arguments[_key];
|
|
47
31
|
}
|
|
48
|
-
|
|
49
32
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
50
|
-
|
|
51
33
|
_defineProperty(_assertThisInitialized(_this), "disposeMethods", []);
|
|
52
|
-
|
|
53
34
|
_defineProperty(_assertThisInitialized(_this), "onDispose", function (callback) {
|
|
54
35
|
_this.disposeMethods.push(callback);
|
|
55
|
-
|
|
56
36
|
return _assertThisInitialized(_this);
|
|
57
37
|
});
|
|
58
|
-
|
|
59
38
|
_defineProperty(_assertThisInitialized(_this), "play", function () {
|
|
60
39
|
_this.start();
|
|
61
|
-
|
|
62
40
|
_this.animationFrameDisposer = (0, _.requestAnimationFrameInterval)(function () {
|
|
63
41
|
return _this.update();
|
|
64
42
|
});
|
|
65
43
|
return _assertThisInitialized(_this);
|
|
66
44
|
});
|
|
67
|
-
|
|
68
45
|
_defineProperty(_assertThisInitialized(_this), "dispose", function () {
|
|
69
46
|
var _this$animationFrameD, _this2;
|
|
70
|
-
|
|
71
47
|
_this.stop();
|
|
72
|
-
|
|
73
48
|
(_this$animationFrameD = (_this2 = _this).animationFrameDisposer) === null || _this$animationFrameD === void 0 ? void 0 : _this$animationFrameD.call(_this2);
|
|
74
|
-
|
|
75
49
|
_this.disposeMethods.forEach(function (fn) {
|
|
76
50
|
return fn();
|
|
77
51
|
});
|
|
78
|
-
|
|
79
52
|
_this.disposeMethods = [];
|
|
80
|
-
|
|
81
53
|
_tween["default"].remove(_assertThisInitialized(_this));
|
|
82
54
|
});
|
|
83
|
-
|
|
84
55
|
return _this;
|
|
85
56
|
}
|
|
86
|
-
|
|
87
|
-
return BetterTween;
|
|
57
|
+
return _createClass(BetterTween);
|
|
88
58
|
}(_tween["default"].Tween);
|
|
89
|
-
|
|
90
59
|
exports.BetterTween = BetterTween;
|
|
91
|
-
|
|
92
60
|
function tweenProgress(duration) {
|
|
93
61
|
var easing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _tween["default"].Easing.Linear.None;
|
|
94
62
|
var tween = new BetterTween({
|
|
@@ -7,37 +7,31 @@ exports["default"] = void 0;
|
|
|
7
7
|
exports.getFrameTime = getFrameTime;
|
|
8
8
|
exports.nextFrame = nextFrame;
|
|
9
9
|
exports.requestAnimationFrameInterval = requestAnimationFrameInterval;
|
|
10
|
-
|
|
11
10
|
var _requestAnimationFrame = window.requestAnimationFrame || function (fn) {
|
|
12
11
|
return setTimeout(fn, 16);
|
|
13
12
|
};
|
|
14
|
-
|
|
15
13
|
var _cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
|
16
|
-
|
|
17
14
|
var _default = _requestAnimationFrame;
|
|
18
15
|
exports["default"] = _default;
|
|
19
|
-
|
|
20
16
|
function nextFrame(fn) {
|
|
21
17
|
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
22
18
|
if (delay <= 0) _requestAnimationFrame(fn);else _requestAnimationFrame(function () {
|
|
23
19
|
return nextFrame(fn, delay - 1);
|
|
24
20
|
});
|
|
25
21
|
}
|
|
22
|
+
|
|
26
23
|
/**
|
|
27
24
|
* 在每个 AnimationFrame 中调用传入的函数
|
|
28
25
|
* @param callback 每次 AnimationFrame 中调用的函数
|
|
29
26
|
* @param frame 每秒运行多少次
|
|
30
27
|
* @returns 返回一个函数,调用可以停止 AnimationFrameLoop
|
|
31
28
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
29
|
function requestAnimationFrameInterval(callback) {
|
|
35
30
|
var frame = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 60;
|
|
36
31
|
var index = -1;
|
|
37
32
|
var oldTime = 0;
|
|
38
33
|
var startTime = -1;
|
|
39
34
|
var minDeltaTime = 1000 / frame;
|
|
40
|
-
|
|
41
35
|
function loop(time) {
|
|
42
36
|
startTime === -1 && (startTime = time);
|
|
43
37
|
index = _requestAnimationFrame(loop);
|
|
@@ -46,18 +40,16 @@ function requestAnimationFrameInterval(callback) {
|
|
|
46
40
|
oldTime = time;
|
|
47
41
|
callback && callback(time - startTime);
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
index = _requestAnimationFrame(loop);
|
|
51
44
|
return function stop() {
|
|
52
45
|
_cancelAnimationFrame(index);
|
|
53
46
|
};
|
|
54
47
|
}
|
|
48
|
+
|
|
55
49
|
/**
|
|
56
50
|
* 获取两个 AnimationFrame 间隔的时间
|
|
57
51
|
* @returns 返回一个 Promise,resolve 的结果是两个 AnimationFrame 间隔的时间
|
|
58
52
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
53
|
function getFrameTime() {
|
|
62
54
|
var start = Date.now();
|
|
63
55
|
return new Promise(function (resolve) {
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
4
|
-
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.Easing = void 0;
|
|
9
8
|
exports["default"] = tween;
|
|
10
9
|
exports.tweenProgress = tweenProgress;
|
|
11
|
-
|
|
12
10
|
var TWEEN = _interopRequireWildcard(require("@tweenjs/tween.js"));
|
|
13
|
-
|
|
14
11
|
var _index = require("./index");
|
|
15
|
-
|
|
16
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
14
|
var Easing = TWEEN.Easing;
|
|
21
15
|
exports.Easing = Easing;
|
|
22
|
-
|
|
23
16
|
/**
|
|
24
17
|
* 对象变化的补间动画
|
|
25
18
|
* 1. 应用 requestAnimationFrameInterval 做 update
|
|
@@ -32,8 +25,8 @@ exports.Easing = Easing;
|
|
|
32
25
|
*/
|
|
33
26
|
function tween(from, to, duration) {
|
|
34
27
|
var easing = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Easing.Linear.None;
|
|
35
|
-
var tween = new TWEEN.Tween(from).to(to, duration).easing(easing);
|
|
36
|
-
|
|
28
|
+
var tween = new TWEEN.Tween(from).to(to, duration).easing(easing);
|
|
29
|
+
// 这里注意一下,因为 requestAnimationFrameInterval 给的时间是从 0 开始的,tween 动画也从 0 开始
|
|
37
30
|
(0, _index.nextFrame)(function () {
|
|
38
31
|
return tween.start(0);
|
|
39
32
|
});
|
|
@@ -41,12 +34,10 @@ function tween(from, to, duration) {
|
|
|
41
34
|
if (tween.update(time) === false) cancelAnimationFrame();
|
|
42
35
|
});
|
|
43
36
|
var destroyMethods = [];
|
|
44
|
-
|
|
45
37
|
tween.onDestroy = function (fn) {
|
|
46
38
|
destroyMethods.push(fn);
|
|
47
39
|
return tween;
|
|
48
40
|
};
|
|
49
|
-
|
|
50
41
|
tween.destroy = function () {
|
|
51
42
|
this.stop();
|
|
52
43
|
Object.assign(tween, {
|
|
@@ -56,17 +47,13 @@ function tween(from, to, duration) {
|
|
|
56
47
|
_onStopCallbackL: null
|
|
57
48
|
});
|
|
58
49
|
var destroyMethod;
|
|
59
|
-
|
|
60
50
|
while (destroyMethod = destroyMethods.shift()) {
|
|
61
51
|
destroyMethod();
|
|
62
52
|
}
|
|
63
|
-
|
|
64
53
|
cancelAnimationFrame();
|
|
65
54
|
};
|
|
66
|
-
|
|
67
55
|
return tween;
|
|
68
56
|
}
|
|
69
|
-
|
|
70
57
|
function tweenProgress(duration, easing) {
|
|
71
58
|
return tween({
|
|
72
59
|
progress: 0
|