@realsee/vreo 1.0.0-alpha.16 → 1.0.0-alpha.19

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 (110) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/docs/assets/highlight.css +10 -10
  3. package/docs/assets/main.js +2 -2
  4. package/docs/assets/search.js +1 -1
  5. package/docs/classes/Player.AudioLike.html +15 -15
  6. package/docs/classes/Player.Controller.html +16 -16
  7. package/docs/classes/Player.Player-1.html +15 -15
  8. package/docs/classes/Player.VideoAgentMesh.html +54 -54
  9. package/docs/classes/Player.VideoAgentScene.html +1 -1
  10. package/docs/demo/assets/{AppReact.9cb4b8b4.js → AppReact.20163f9a.js} +1 -1
  11. package/docs/demo/assets/default.5069891b.js +3988 -0
  12. package/docs/demo/assets/{dynamic.2875538a.js → dynamic.c8118cc9.js} +1 -1
  13. package/docs/demo/assets/{examples.b66fa73b.js → examples.5391fc1f.js} +1 -1
  14. package/docs/demo/assets/{index.faf3d8b7.js → index.2272a9ef.js} +1 -1
  15. package/docs/demo/assets/main.b335b989.js +1 -0
  16. package/docs/demo/assets/{react.40ad4b7f.js → react.efea3f3f.js} +1 -1
  17. package/docs/demo/examples.html +2 -2
  18. package/docs/demo/index-react-dynamic.html +4 -4
  19. package/docs/demo/index-react.html +4 -4
  20. package/docs/demo/index.html +3 -3
  21. package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
  22. package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
  23. package/docs/enums/Player.PanoEffectEnum.html +1 -1
  24. package/docs/enums/Player.PanoTagEnum.html +1 -1
  25. package/docs/enums/Player.PanoTagStyleEnum.html +2 -2
  26. package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
  27. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
  28. package/docs/enums/fivePlugins.Rotation.html +1 -1
  29. package/docs/index.html +30 -27
  30. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
  31. package/docs/interfaces/Player.PlayerConfigs.html +3 -3
  32. package/docs/interfaces/Player.Vertex.html +1 -1
  33. package/docs/interfaces/Player.VideoAgentMeshOptions.html +3 -3
  34. package/docs/interfaces/Player.VreoKeyframe.html +1 -1
  35. package/docs/interfaces/Player.VreoUnit.html +1 -1
  36. package/docs/interfaces/Player.VreoVideo.html +1 -1
  37. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +3 -3
  38. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
  39. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
  40. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
  41. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
  42. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
  43. package/docs/interfaces/fivePlugins.Vector3Position.html +1 -1
  44. package/docs/interfaces/react.VreoActionCallbacks.html +6 -6
  45. package/docs/interfaces/react.VreoProviderProps.html +1 -1
  46. package/docs/modules/Player.html +16 -16
  47. package/docs/modules/custom.html +1 -1
  48. package/docs/modules/fivePlugins.html +3 -3
  49. package/docs/modules/react.html +1 -1
  50. package/lib/PlayController/createHTMLAudioElement.js +11 -6
  51. package/lib/PlayController/index.js +81 -16
  52. package/lib/Player/App.js +24 -0
  53. package/lib/Player/Controller.d.ts +2 -2
  54. package/lib/Player/Controller.js +96 -20
  55. package/lib/Player/custom/SpatialScenePanel/index.js +68 -42
  56. package/lib/Player/hooks.js +10 -0
  57. package/lib/Player/index.js +85 -25
  58. package/lib/Player/modules/Drawer/index.js +17 -0
  59. package/lib/Player/modules/PopUp/index.js +10 -0
  60. package/lib/Player/modules/ResizeObserver/index.js +8 -0
  61. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +2 -2
  62. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +114 -20
  63. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +24 -2
  64. package/lib/Player/modules/VideoAgent/index.js +17 -0
  65. package/lib/Player/modules/Wave/index.js +32 -7
  66. package/lib/Player/modules/keyframes/BgMusic/index.js +44 -14
  67. package/lib/Player/modules/keyframes/CameraMovement/index.js +27 -3
  68. package/lib/Player/modules/keyframes/InfoPanel/index.js +25 -8
  69. package/lib/Player/modules/keyframes/ModelVideo/index.js +29 -3
  70. package/lib/Player/modules/keyframes/PanoEffect/index.js +43 -15
  71. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +7 -0
  72. package/lib/Player/modules/keyframes/PanoTag/index.js +21 -4
  73. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +47 -22
  74. package/lib/Player/modules/keyframes/Prompter/index.js +32 -10
  75. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +25 -18
  76. package/lib/Player/modules/keyframes/VideoEffect/index.js +47 -12
  77. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +2 -0
  78. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +1 -0
  79. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +1 -0
  80. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +60 -19
  81. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +5 -2
  82. package/lib/fivePlugins/CameraMovementPlugin/index.js +75 -28
  83. package/lib/fivePlugins/CameraMovementPlugin/typings.js +4 -0
  84. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +60 -11
  85. package/lib/index.js +1 -0
  86. package/lib/react/index.js +34 -7
  87. package/lib/shared-utils/{AduioLike.d.ts → AudioLike.d.ts} +0 -0
  88. package/lib/shared-utils/{AduioLike.js → AudioLike.js} +43 -11
  89. package/lib/shared-utils/Preloader.js +7 -0
  90. package/lib/shared-utils/addResizeListener.js +5 -0
  91. package/lib/shared-utils/animationFrame/BetterTween.js +38 -2
  92. package/lib/shared-utils/animationFrame/index.js +10 -2
  93. package/lib/shared-utils/animationFrame/tween.js +15 -2
  94. package/lib/shared-utils/createTransMatrix.js +17 -2
  95. package/lib/shared-utils/getFileExpandedName.js +1 -0
  96. package/lib/shared-utils/getMediaInfo.js +9 -0
  97. package/lib/shared-utils/setElementDataset.js +2 -0
  98. package/lib/typings/VreoUnit.d.ts +5 -5
  99. package/lib/typings/VreoUnit.js +15 -0
  100. package/package.json +1 -1
  101. package/resources/PlayController/index.ts +1 -1
  102. package/resources/Player/Controller.ts +4 -4
  103. package/resources/Player/index.tsx +1 -1
  104. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +2 -2
  105. package/resources/Player/modules/keyframes/BgMusic/index.tsx +23 -14
  106. package/resources/Player/modules/keyframes/PanoTag/index.tsx +1 -0
  107. package/resources/shared-utils/{AduioLike.ts → AudioLike.ts} +4 -6
  108. package/resources/typings/VreoUnit.ts +5 -5
  109. package/docs/demo/assets/default.1c2d6361.js +0 -3988
  110. package/docs/demo/assets/main.bc830a33.js +0 -1
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
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
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -8,30 +9,46 @@ exports.VreoProvider = void 0;
8
9
  exports.useVreoAction = useVreoAction;
9
10
  exports.useVreoEventCallback = useVreoEventCallback;
10
11
  exports.useVreoPausedState = useVreoPausedState;
12
+
11
13
  var _react = require("@realsee/five/react");
14
+
12
15
  var React = _interopRequireWildcard(require("react"));
16
+
13
17
  var _Player = require("../Player");
18
+
14
19
  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
+
15
21
  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
+
16
23
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
24
+
17
25
  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
+
18
27
  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
+
19
29
  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
+
20
31
  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
+
21
33
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
34
+
22
35
  var VreoContext = /*#__PURE__*/React.createContext(null);
36
+
23
37
  var VreoProvider = function VreoProvider(props) {
24
38
  var five = (0, _react.unsafe__useFiveInstance)();
39
+
25
40
  var _React$useState = React.useState(null),
26
- _React$useState2 = _slicedToArray(_React$useState, 2),
27
- player = _React$useState2[0],
28
- setPlayer = _React$useState2[1];
41
+ _React$useState2 = _slicedToArray(_React$useState, 2),
42
+ player = _React$useState2[0],
43
+ setPlayer = _React$useState2[1];
44
+
29
45
  var playerRef = React.useRef(null);
30
46
  React.useEffect(function () {
31
47
  playerRef.current = new _Player.Player(five, props.configs || {});
32
48
  setPlayer(playerRef.current);
33
49
  return function () {
34
50
  var _playerRef$current;
51
+
35
52
  (_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.dispose();
36
53
  };
37
54
  }, []);
@@ -40,19 +57,23 @@ var VreoProvider = function VreoProvider(props) {
40
57
  value: player
41
58
  }, props.children);
42
59
  };
60
+
43
61
  exports.VreoProvider = VreoProvider;
62
+
44
63
  function useVreoInstance() {
45
64
  var context = React.useContext(VreoContext);
65
+
46
66
  if (!context) {
47
67
  throw new Error('VreoProvider never found.');
48
68
  }
69
+
49
70
  return context;
50
71
  }
51
-
52
72
  /**
53
73
  * VreoPlayer 命令集合。
54
74
  */
55
75
 
76
+
56
77
  function useVreoAction() {
57
78
  var player = useVreoInstance();
58
79
  var load = React.useCallback(function (vreoUnit, currentTime) {
@@ -82,12 +103,15 @@ function useVreoAction() {
82
103
  dispose: dispose
83
104
  };
84
105
  }
106
+
85
107
  function useVreoEventCallback(name, callback, deps) {
86
108
  var player = useVreoInstance();
87
109
  var dependencyList = [player, name];
110
+
88
111
  if (deps !== undefined) {
89
112
  dependencyList = dependencyList.concat(deps);
90
113
  }
114
+
91
115
  React.useEffect(function () {
92
116
  // @ts-ignore
93
117
  player.on(name, callback);
@@ -97,12 +121,15 @@ function useVreoEventCallback(name, callback, deps) {
97
121
  };
98
122
  }, dependencyList);
99
123
  }
124
+
100
125
  function useVreoPausedState() {
101
126
  var player = useVreoInstance();
127
+
102
128
  var _React$useState3 = React.useState(player.paused),
103
- _React$useState4 = _slicedToArray(_React$useState3, 2),
104
- state = _React$useState4[0],
105
- setState = _React$useState4[1];
129
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
130
+ state = _React$useState4[0],
131
+ setState = _React$useState4[1];
132
+
106
133
  useVreoEventCallback('paused', function () {
107
134
  return setState(true);
108
135
  });
@@ -1,60 +1,90 @@
1
1
  "use strict";
2
2
 
3
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
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports["default"] = exports.AudioLike = void 0;
9
+
8
10
  var _five = require("@realsee/five");
11
+
9
12
  var _animationFrame = require("./animationFrame");
13
+
10
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+
11
16
  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); } }
17
+
12
18
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
19
+
13
20
  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); }
21
+
22
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
+
15
24
  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); }; }
25
+
16
26
  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); }
27
+
17
28
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
+
18
30
  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); }
31
+
32
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
33
+
20
34
  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; }
35
+
21
36
  /**
22
37
  * 模拟 `<Audio>` 功能:没有音频,但执行逻辑跟 `<Audio>` 相似。
23
38
  */
24
39
  var AudioLike = /*#__PURE__*/function (_Subscribe) {
25
40
  _inherits(AudioLike, _Subscribe);
41
+
26
42
  var _super = _createSuper(AudioLike);
43
+
27
44
  function AudioLike() {
28
45
  var _this;
46
+
29
47
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
30
- duration = _ref.duration;
48
+ duration = _ref.duration;
49
+
31
50
  _classCallCheck(this, AudioLike);
51
+
32
52
  _this = _super.call(this);
53
+
33
54
  _defineProperty(_assertThisInitialized(_this), "$timestamp", null);
55
+
34
56
  _defineProperty(_assertThisInitialized(_this), "$currentTime", 0);
57
+
35
58
  _defineProperty(_assertThisInitialized(_this), "$duration", 0);
59
+
36
60
  _defineProperty(_assertThisInitialized(_this), "muted", false);
61
+
37
62
  _defineProperty(_assertThisInitialized(_this), "src", '');
63
+
38
64
  if (duration) {
39
65
  _this.$duration = duration;
40
66
  }
67
+
41
68
  return _this;
42
69
  }
70
+
43
71
  _createClass(AudioLike, [{
44
72
  key: "setAttribute",
45
- value: function setAttribute(name, value) {
46
- // nothing todo
73
+ value: function setAttribute(name, value) {// nothing todo
47
74
  }
48
75
  }, {
49
76
  key: "play",
50
77
  value: function play() {
51
78
  var _this2 = this;
79
+
52
80
  if (this.$currentTime === this.$duration) {
53
81
  this.$currentTime = 0;
54
82
  }
83
+
55
84
  if (this.$timestamp === null) {
56
- this.$timestamp = performance.now() - this.$currentTime;
85
+ this.$timestamp = performance.now();
57
86
  }
87
+
58
88
  this.stopInterval = (0, _animationFrame.requestAnimationFrameInterval)(function () {
59
89
  return _this2.requestAnimationFrameLoop();
60
90
  });
@@ -68,6 +98,7 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
68
98
  this.emit('pause');
69
99
  this.stopInterval = undefined;
70
100
  }
101
+
71
102
  this.$timestamp = null;
72
103
  }
73
104
  }, {
@@ -75,8 +106,10 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
75
106
  value: function requestAnimationFrameLoop() {
76
107
  if (this.$timestamp === null) return;
77
108
  var now = performance.now();
78
- this.$currentTime = now - this.$timestamp;
109
+ this.$currentTime += now - this.$timestamp;
110
+ this.$timestamp = now;
79
111
  this.emit('timeupdate');
112
+
80
113
  if (this.$currentTime >= this.$duration - 10) {
81
114
  this.$currentTime = this.$duration;
82
115
  this.pause();
@@ -89,7 +122,7 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
89
122
  return this.$currentTime / 1000;
90
123
  },
91
124
  set: function set(time) {
92
- this.$currentTime = time;
125
+ this.$currentTime = time * 1000;
93
126
  }
94
127
  }, {
95
128
  key: "duration",
@@ -97,10 +130,7 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
97
130
  return this.$duration;
98
131
  },
99
132
  set: function set(duration) {
100
- this.pause();
101
133
  this.$duration = duration;
102
- this.$timestamp = null;
103
- this.$currentTime = 0;
104
134
  }
105
135
  }, {
106
136
  key: "ended",
@@ -125,8 +155,10 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
125
155
  this.off(evtName, callback);
126
156
  }
127
157
  }]);
158
+
128
159
  return AudioLike;
129
160
  }(_five.Subscribe);
161
+
130
162
  exports.AudioLike = AudioLike;
131
163
  var _default = AudioLike;
132
164
  exports["default"] = _default;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Preloader = void 0;
7
+
7
8
  /**
8
9
  * 预载器
9
10
  */
@@ -12,21 +13,26 @@ var Preloader = {
12
13
  var noop = function noop() {
13
14
  return null;
14
15
  };
16
+
15
17
  return new Promise(function (resolve, reject) {
16
18
  var xhr = new XMLHttpRequest();
19
+
17
20
  var clear = function clear() {
18
21
  xhr.ontimeout = noop;
19
22
  xhr.onreadystatechange = noop;
20
23
  xhr.onprogress = noop;
21
24
  xhr.onabort = noop;
22
25
  };
26
+
23
27
  xhr.ontimeout = function () {
24
28
  reject(new Error('timeout'));
25
29
  clear();
26
30
  };
31
+
27
32
  xhr.onreadystatechange = function () {
28
33
  if (xhr.readyState !== 4) return;
29
34
  if (xhr.status === 0 && !xhr.response) return;
35
+
30
36
  if (xhr.status === 200 || xhr.status === 0) {
31
37
  resolve(xhr.response);
32
38
  clear();
@@ -35,6 +41,7 @@ var Preloader = {
35
41
  clear();
36
42
  }
37
43
  };
44
+
38
45
  xhr.open('GET', url, true);
39
46
  xhr.responseType = 'blob';
40
47
  xhr.send(null);
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.addResizeListener = addResizeListener;
7
7
  exports.hasResizeListener = hasResizeListener;
8
8
  var resizeObserverCache = new Map();
9
+
9
10
  function addResizeListener(element, resizeHandler) {
10
11
  var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
11
12
  if (!element) return function () {};
12
13
  if (immediate) resizeHandler(element.clientWidth, element.clientHeight);
14
+
13
15
  if (typeof ResizeObserver !== 'undefined' && ResizeObserver) {
14
16
  var resizeObserver = new ResizeObserver(function () {
15
17
  return resizeHandler(element.clientWidth, element.clientHeight);
@@ -18,6 +20,7 @@ function addResizeListener(element, resizeHandler) {
18
20
  resizeObserverCache.set(element, resizeObserverCache.get(element) || 0 + 1);
19
21
  return function () {
20
22
  if (element) resizeObserver.unobserve(element);
23
+
21
24
  if (resizeObserverCache.get(element) === 1) {
22
25
  resizeObserverCache["delete"](element);
23
26
  }
@@ -34,12 +37,14 @@ function addResizeListener(element, resizeHandler) {
34
37
  resizeObserverCache.set(element, resizeObserverCache.get(element) || 0 + 1);
35
38
  return function () {
36
39
  element.removeChild(iframe);
40
+
37
41
  if (resizeObserverCache.get(element) === 1) {
38
42
  resizeObserverCache["delete"](element);
39
43
  }
40
44
  };
41
45
  }
42
46
  }
47
+
43
48
  function hasResizeListener(element) {
44
49
  if (!element) return false;
45
50
  return resizeObserverCache.get(element) || 0 > 0;
@@ -1,62 +1,98 @@
1
1
  "use strict";
2
2
 
3
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
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.BetterTween = void 0;
8
9
  exports.tweenProgress = tweenProgress;
10
+
9
11
  var _tween = _interopRequireDefault(require("@tweenjs/tween.js"));
12
+
10
13
  var _ = require(".");
14
+
11
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
+
12
17
  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); } }
18
+
13
19
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
+
14
21
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
+
15
23
  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); }
24
+
25
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
26
+
17
27
  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); }; }
28
+
18
29
  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); }
30
+
19
31
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
32
+
20
33
  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; } }
21
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
34
+
35
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
36
+
22
37
  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; }
38
+
23
39
  var BetterTween = /*#__PURE__*/function (_TWEEN$Tween) {
24
40
  _inherits(BetterTween, _TWEEN$Tween);
41
+
25
42
  var _super = _createSuper(BetterTween);
43
+
26
44
  function BetterTween() {
27
45
  var _this;
46
+
28
47
  _classCallCheck(this, BetterTween);
48
+
29
49
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
30
50
  args[_key] = arguments[_key];
31
51
  }
52
+
32
53
  _this = _super.call.apply(_super, [this].concat(args));
54
+
33
55
  _defineProperty(_assertThisInitialized(_this), "disposeMethods", []);
56
+
34
57
  _defineProperty(_assertThisInitialized(_this), "onDispose", function (callback) {
35
58
  _this.disposeMethods.push(callback);
59
+
36
60
  return _assertThisInitialized(_this);
37
61
  });
62
+
38
63
  _defineProperty(_assertThisInitialized(_this), "play", function () {
39
64
  _this.start();
65
+
40
66
  _this.animationFrameDisposer = (0, _.requestAnimationFrameInterval)(function () {
41
67
  return _this.update();
42
68
  });
43
69
  return _assertThisInitialized(_this);
44
70
  });
71
+
45
72
  _defineProperty(_assertThisInitialized(_this), "dispose", function () {
46
73
  var _this$animationFrameD, _this2;
74
+
47
75
  _this.stop();
76
+
48
77
  (_this$animationFrameD = (_this2 = _this).animationFrameDisposer) === null || _this$animationFrameD === void 0 ? void 0 : _this$animationFrameD.call(_this2);
78
+
49
79
  _this.disposeMethods.forEach(function (fn) {
50
80
  return fn();
51
81
  });
82
+
52
83
  _this.disposeMethods = [];
84
+
53
85
  _tween["default"].remove(_assertThisInitialized(_this));
54
86
  });
87
+
55
88
  return _this;
56
89
  }
90
+
57
91
  return _createClass(BetterTween);
58
92
  }(_tween["default"].Tween);
93
+
59
94
  exports.BetterTween = BetterTween;
95
+
60
96
  function tweenProgress(duration) {
61
97
  var easing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _tween["default"].Easing.Linear.None;
62
98
  var tween = new BetterTween({
@@ -7,31 +7,37 @@ exports["default"] = void 0;
7
7
  exports.getFrameTime = getFrameTime;
8
8
  exports.nextFrame = nextFrame;
9
9
  exports.requestAnimationFrameInterval = requestAnimationFrameInterval;
10
+
10
11
  var _requestAnimationFrame = window.requestAnimationFrame || function (fn) {
11
12
  return setTimeout(fn, 16);
12
13
  };
14
+
13
15
  var _cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
16
+
14
17
  var _default = _requestAnimationFrame;
15
18
  exports["default"] = _default;
19
+
16
20
  function nextFrame(fn) {
17
21
  var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
18
22
  if (delay <= 0) _requestAnimationFrame(fn);else _requestAnimationFrame(function () {
19
23
  return nextFrame(fn, delay - 1);
20
24
  });
21
25
  }
22
-
23
26
  /**
24
27
  * 在每个 AnimationFrame 中调用传入的函数
25
28
  * @param callback 每次 AnimationFrame 中调用的函数
26
29
  * @param frame 每秒运行多少次
27
30
  * @returns 返回一个函数,调用可以停止 AnimationFrameLoop
28
31
  */
32
+
33
+
29
34
  function requestAnimationFrameInterval(callback) {
30
35
  var frame = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 60;
31
36
  var index = -1;
32
37
  var oldTime = 0;
33
38
  var startTime = -1;
34
39
  var minDeltaTime = 1000 / frame;
40
+
35
41
  function loop(time) {
36
42
  startTime === -1 && (startTime = time);
37
43
  index = _requestAnimationFrame(loop);
@@ -40,16 +46,18 @@ function requestAnimationFrameInterval(callback) {
40
46
  oldTime = time;
41
47
  callback && callback(time - startTime);
42
48
  }
49
+
43
50
  index = _requestAnimationFrame(loop);
44
51
  return function stop() {
45
52
  _cancelAnimationFrame(index);
46
53
  };
47
54
  }
48
-
49
55
  /**
50
56
  * 获取两个 AnimationFrame 间隔的时间
51
57
  * @returns 返回一个 Promise,resolve 的结果是两个 AnimationFrame 间隔的时间
52
58
  */
59
+
60
+
53
61
  function getFrameTime() {
54
62
  var start = Date.now();
55
63
  return new Promise(function (resolve) {
@@ -1,18 +1,25 @@
1
1
  "use strict";
2
2
 
3
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
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.Easing = void 0;
8
9
  exports["default"] = tween;
9
10
  exports.tweenProgress = tweenProgress;
11
+
10
12
  var TWEEN = _interopRequireWildcard(require("@tweenjs/tween.js"));
13
+
11
14
  var _index = require("./index");
15
+
12
16
  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
+
13
18
  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
+
14
20
  var Easing = TWEEN.Easing;
15
21
  exports.Easing = Easing;
22
+
16
23
  /**
17
24
  * 对象变化的补间动画
18
25
  * 1. 应用 requestAnimationFrameInterval 做 update
@@ -25,8 +32,8 @@ exports.Easing = Easing;
25
32
  */
26
33
  function tween(from, to, duration) {
27
34
  var easing = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Easing.Linear.None;
28
- var tween = new TWEEN.Tween(from).to(to, duration).easing(easing);
29
- // 这里注意一下,因为 requestAnimationFrameInterval 给的时间是从 0 开始的,tween 动画也从 0 开始
35
+ var tween = new TWEEN.Tween(from).to(to, duration).easing(easing); // 这里注意一下,因为 requestAnimationFrameInterval 给的时间是从 0 开始的,tween 动画也从 0 开始
36
+
30
37
  (0, _index.nextFrame)(function () {
31
38
  return tween.start(0);
32
39
  });
@@ -34,10 +41,12 @@ function tween(from, to, duration) {
34
41
  if (tween.update(time) === false) cancelAnimationFrame();
35
42
  });
36
43
  var destroyMethods = [];
44
+
37
45
  tween.onDestroy = function (fn) {
38
46
  destroyMethods.push(fn);
39
47
  return tween;
40
48
  };
49
+
41
50
  tween.destroy = function () {
42
51
  this.stop();
43
52
  Object.assign(tween, {
@@ -47,13 +56,17 @@ function tween(from, to, duration) {
47
56
  _onStopCallbackL: null
48
57
  });
49
58
  var destroyMethod;
59
+
50
60
  while (destroyMethod = destroyMethods.shift()) {
51
61
  destroyMethod();
52
62
  }
63
+
53
64
  cancelAnimationFrame();
54
65
  };
66
+
55
67
  return tween;
56
68
  }
69
+
57
70
  function tweenProgress(duration, easing) {
58
71
  return tween({
59
72
  progress: 0
@@ -1,27 +1,42 @@
1
1
  "use strict";
2
2
 
3
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
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.createTransMatrix = createTransMatrix;
9
+
8
10
  var THREE = _interopRequireWildcard(require("three"));
11
+
9
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); }
13
+
10
14
  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; }
11
- function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
15
+
16
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
17
+
12
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; } }
13
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19
+
20
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
+
14
22
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
23
+
15
24
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
+
16
26
  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); }
27
+
17
28
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
29
+
18
30
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
31
+
19
32
  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; }
33
+
20
34
  function createTransMatrix(arr1) {
21
35
  var matrix4 = new THREE.Matrix4();
22
36
  matrix4.fromArray(arr1);
23
37
  return function (arr2) {
24
38
  var vector3 = _construct(THREE.Vector3, _toConsumableArray(arr2));
39
+
25
40
  vector3.applyMatrix4(matrix4);
26
41
  return vector3.toArray();
27
42
  };
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = getFileExpandedName;
7
+
7
8
  function getFileExpandedName(filePath) {
8
9
  if (!filePath) return '';
9
10
  var index = filePath.lastIndexOf('.');