@realsee/vreo 0.2.0-alpha.10 → 0.2.0-alpha.13

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 (78) hide show
  1. package/README.md +2 -2
  2. package/docs/assets/search.js +1 -1
  3. package/docs/classes/Player.AudioLike.html +52 -0
  4. package/docs/classes/Player.Controller.html +3 -3
  5. package/docs/classes/Player.Player-1.html +3 -3
  6. package/docs/classes/Player.VideoAgentMesh.html +12 -12
  7. package/docs/classes/Player.VideoAgentScene.html +1 -1
  8. package/docs/demo/assets/AppReact.388465e9.js +1 -0
  9. package/docs/demo/assets/default.0350c336.css +1 -0
  10. package/docs/demo/assets/default.f03f1cdd.js +64 -0
  11. package/docs/demo/assets/dynamic.3f7479e4.js +1 -0
  12. package/docs/demo/assets/examples.02abaf01.js +25 -0
  13. package/docs/demo/assets/examples.dac4a6fe.css +1 -0
  14. package/docs/demo/assets/index.485f13f7.js +1 -0
  15. package/docs/demo/assets/index.a7bafdff.css +1 -0
  16. package/docs/demo/assets/main.0b6b41ab.js +1 -0
  17. package/docs/demo/assets/react.aa3cf7f7.css +1 -0
  18. package/docs/demo/assets/react.b14dadc7.js +25 -0
  19. package/docs/demo/assets/vendor.d3e0753c.js +3903 -0
  20. package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +1 -0
  21. package/docs/demo/examples.html +18 -0
  22. package/docs/demo/index-react-dynamic.html +21 -0
  23. package/docs/demo/index-react.html +21 -0
  24. package/docs/demo/index.html +20 -0
  25. package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
  26. package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
  27. package/docs/enums/Player.PanoEffectEnum.html +1 -1
  28. package/docs/enums/Player.PanoTagEnum.html +1 -1
  29. package/docs/enums/Player.PanoTagStyleEnum.html +7 -0
  30. package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
  31. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
  32. package/docs/enums/fivePlugins.Rotation.html +1 -1
  33. package/docs/index.html +2 -2
  34. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
  35. package/docs/interfaces/Player.PlayerConfigs.html +2 -2
  36. package/docs/interfaces/Player.Vertex.html +1 -1
  37. package/docs/interfaces/Player.VideoAgentMeshOptions.html +1 -1
  38. package/docs/interfaces/Player.VreoKeyframe.html +1 -1
  39. package/docs/interfaces/Player.VreoUnit.html +1 -1
  40. package/docs/interfaces/Player.VreoVideo.html +1 -1
  41. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
  42. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
  43. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
  44. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
  45. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
  46. package/docs/interfaces/react.VreoActionCallbacks.html +6 -6
  47. package/docs/interfaces/react.VreoProviderProps.html +1 -1
  48. package/docs/modules/Player.html +16 -14
  49. package/docs/modules/custom.html +1 -1
  50. package/docs/modules/fivePlugins.html +2 -2
  51. package/docs/modules/react.html +1 -1
  52. package/lib/Player/Controller.d.ts +1 -1
  53. package/lib/Player/index.d.ts +1 -1
  54. package/lib/Player/index.js +15 -15
  55. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +4 -2
  56. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +71 -23
  57. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -1
  58. package/lib/Player/modules/keyframes/ModelVideo/index.js +2 -2
  59. package/lib/Player/modules/keyframes/PanoTag/index.js +19 -6
  60. package/lib/Player/modules/keyframes/Prompter/index.js +2 -3
  61. package/lib/react/index.d.ts +2 -2
  62. package/lib/react/index.js +2 -2
  63. package/lib/shared-utils/AduioLike.d.ts +37 -0
  64. package/lib/shared-utils/AduioLike.js +165 -0
  65. package/lib/typings/VreoUnit.d.ts +14 -0
  66. package/lib/typings/VreoUnit.js +13 -1
  67. package/package.json +4 -4
  68. package/resources/Player/Controller.ts +2 -0
  69. package/resources/Player/index.tsx +42 -28
  70. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +39 -9
  71. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +2 -0
  72. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +1 -1
  73. package/resources/Player/modules/keyframes/PanoTag/index.tsx +31 -12
  74. package/resources/Player/modules/keyframes/Prompter/index.tsx +2 -1
  75. package/resources/react/index.tsx +2 -2
  76. package/resources/shared-utils/AduioLike.ts +108 -0
  77. package/resources/typings/VreoUnit.ts +15 -0
  78. package/stylesheets/default.css +25 -4
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = exports.AudioLike = void 0;
9
+
10
+ var _five = require("@realsee/five");
11
+
12
+ var _animationFrame = require("./animationFrame");
13
+
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+
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
+
18
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19
+
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
21
+
22
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
+
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
+
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
+
28
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
+
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; } }
31
+
32
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
33
+
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
+
36
+ /**
37
+ * 模拟 `<Audio>` 功能:没有音频,但执行逻辑跟 `<Audio>` 相似。
38
+ */
39
+ var AudioLike = /*#__PURE__*/function (_Subscribe) {
40
+ _inherits(AudioLike, _Subscribe);
41
+
42
+ var _super = _createSuper(AudioLike);
43
+
44
+ function AudioLike() {
45
+ var _this;
46
+
47
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
48
+ duration = _ref.duration;
49
+
50
+ _classCallCheck(this, AudioLike);
51
+
52
+ _this = _super.call(this);
53
+
54
+ _defineProperty(_assertThisInitialized(_this), "$timestamp", 0);
55
+
56
+ _defineProperty(_assertThisInitialized(_this), "$currentTime", 0);
57
+
58
+ _defineProperty(_assertThisInitialized(_this), "$duration", 0);
59
+
60
+ _defineProperty(_assertThisInitialized(_this), "muted", false);
61
+
62
+ _defineProperty(_assertThisInitialized(_this), "src", '');
63
+
64
+ if (duration) {
65
+ _this.$duration = duration;
66
+ }
67
+
68
+ return _this;
69
+ }
70
+
71
+ _createClass(AudioLike, [{
72
+ key: "setAttribute",
73
+ value: function setAttribute(name, value) {// nothing todo
74
+ }
75
+ }, {
76
+ key: "play",
77
+ value: function play() {
78
+ var _this2 = this;
79
+
80
+ if (this.$timestamp === 0) {
81
+ this.$timestamp = performance.now();
82
+ }
83
+
84
+ if (this.$currentTime === this.$duration) {
85
+ this.$currentTime = 0;
86
+ }
87
+
88
+ this.stopInterval = (0, _animationFrame.requestAnimationFrameInterval)(function () {
89
+ return _this2.requestAnimationFrameLoop();
90
+ });
91
+ this.emit('play');
92
+ }
93
+ }, {
94
+ key: "pause",
95
+ value: function pause() {
96
+ if (this.stopInterval) {
97
+ this.stopInterval();
98
+ this.emit('pause');
99
+ this.stopInterval = undefined;
100
+ }
101
+
102
+ this.$timestamp = 0;
103
+ }
104
+ }, {
105
+ key: "requestAnimationFrameLoop",
106
+ value: function requestAnimationFrameLoop() {
107
+ var now = performance.now();
108
+ this.$currentTime = now - this.$timestamp;
109
+ this.emit('timeupdate');
110
+
111
+ if (this.$currentTime >= this.$duration - 10) {
112
+ this.$currentTime = this.$duration;
113
+ this.pause();
114
+ this.emit('ended');
115
+ }
116
+ }
117
+ }, {
118
+ key: "currentTime",
119
+ get: function get() {
120
+ return this.$currentTime / 1000;
121
+ },
122
+ set: function set(time) {
123
+ this.$currentTime = time;
124
+ }
125
+ }, {
126
+ key: "duration",
127
+ get: function get() {
128
+ return this.$duration;
129
+ },
130
+ set: function set(duration) {
131
+ this.pause();
132
+ this.$duration = duration;
133
+ this.$timestamp = 0;
134
+ this.$currentTime = 0;
135
+ }
136
+ }, {
137
+ key: "ended",
138
+ get: function get() {
139
+ return this.$currentTime === this.$duration;
140
+ }
141
+ }, {
142
+ key: "paused",
143
+ get: function get() {
144
+ return !this.stopInterval;
145
+ }
146
+ }, {
147
+ key: "addEventListener",
148
+ value: function addEventListener(evtName, callback) {
149
+ var useCapture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
150
+ this.on(evtName, callback);
151
+ }
152
+ }, {
153
+ key: "removeEventListener",
154
+ value: function removeEventListener(evtName, callback) {
155
+ var useCapture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
156
+ this.off(evtName, callback);
157
+ }
158
+ }]);
159
+
160
+ return AudioLike;
161
+ }(_five.Subscribe);
162
+
163
+ exports.AudioLike = AudioLike;
164
+ var _default = AudioLike;
165
+ exports["default"] = _default;
@@ -187,8 +187,22 @@ export declare enum PanoTagEnum {
187
187
  Text = "Text",
188
188
  Image = "Image"
189
189
  }
190
+ /**
191
+ * 标签样式种类
192
+ */
193
+ export declare enum PanoTagStyleEnum {
194
+ /**
195
+ * 生长动画:默认值
196
+ */
197
+ Growth = "Growth",
198
+ /**
199
+ * 展开动画
200
+ */
201
+ Expand = "Expand"
202
+ }
190
203
  export declare type PanoTagData = {
191
204
  type: PanoTagEnum;
205
+ style: PanoTagStyleEnum;
192
206
  text: string;
193
207
  vertex: Vertex;
194
208
  imgUrl?: string;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VreoKeyframeEnum = exports.PanoTagEnum = exports.PanoEffectEnum = exports.InfoPanelTypeEnum = exports.InfoPanelStyleEnum = void 0;
6
+ exports.VreoKeyframeEnum = exports.PanoTagStyleEnum = exports.PanoTagEnum = exports.PanoEffectEnum = exports.InfoPanelTypeEnum = exports.InfoPanelStyleEnum = void 0;
7
7
  var VreoKeyframeEnum;
8
8
  /**
9
9
  * 支持自定义剧本关键帧配置项
@@ -30,6 +30,10 @@ exports.VreoKeyframeEnum = VreoKeyframeEnum;
30
30
  * 全景标签枚举
31
31
  */
32
32
  var PanoTagEnum;
33
+ /**
34
+ * 标签样式种类
35
+ */
36
+
33
37
  exports.PanoTagEnum = PanoTagEnum;
34
38
 
35
39
  (function (PanoTagEnum) {
@@ -37,6 +41,14 @@ exports.PanoTagEnum = PanoTagEnum;
37
41
  PanoTagEnum["Image"] = "Image";
38
42
  })(PanoTagEnum || (exports.PanoTagEnum = PanoTagEnum = {}));
39
43
 
44
+ var PanoTagStyleEnum;
45
+ exports.PanoTagStyleEnum = PanoTagStyleEnum;
46
+
47
+ (function (PanoTagStyleEnum) {
48
+ PanoTagStyleEnum["Growth"] = "Growth";
49
+ PanoTagStyleEnum["Expand"] = "Expand";
50
+ })(PanoTagStyleEnum || (exports.PanoTagStyleEnum = PanoTagStyleEnum = {}));
51
+
40
52
  /**
41
53
  * 全景特效枚举
42
54
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realsee/vreo",
3
- "version": "0.2.0-alpha.10",
3
+ "version": "0.2.0-alpha.13",
4
4
  "description": "Vreo (VR Video 缩写) 是基于如视三维渲染引擎 Five 和 用户界面构建库 React 实现的如视 3D 空间剧本播放器。",
5
5
  "keywords": [
6
6
  "realsee",
@@ -21,13 +21,13 @@
21
21
  "dev": "vite --port=3088 --host 0.0.0.0",
22
22
  "build": "tsc && vite build",
23
23
  "preview": "vite preview",
24
- "docs": "npx typedoc",
24
+ "docs": "npx typedoc && yarn run build",
25
25
  "packages": "node ./dev-tools/build-packages.js"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@realsee/five": "^5.0.0-alpha.103",
29
- "react": "^16.0.0",
30
- "react-dom": "^16.0.0"
29
+ "react": "^17.0.0",
30
+ "react-dom": "^17.0.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/cli": "^7.16.0",
@@ -114,12 +114,14 @@ export class Controller extends Subscribe<VreoKeyframeEvent> {
114
114
  this.videoInstance.pause()
115
115
  return
116
116
  }
117
+
117
118
  if (!this.playing) {
118
119
  if (!this.videoInstance?.paused) {
119
120
  this.videoInstance?.pause()
120
121
  }
121
122
  return
122
123
  }
124
+
123
125
  if (this.videoInstance?.paused && this.playing) {
124
126
  this.videoInstance.play()
125
127
  }
@@ -91,47 +91,56 @@ export class Player extends Subscribe<VreoKeyframeEvent> {
91
91
 
92
92
  // 预载逻辑
93
93
  // 是否降低图片分辨率
94
- if (this.$five.imageOptions.size && this.configs.imageOptions?.size && this.$five.imageOptions.size > this.configs.imageOptions.size) {
94
+ if (
95
+ this.$five.imageOptions.size &&
96
+ this.configs.imageOptions?.size &&
97
+ this.$five.imageOptions.size > this.configs.imageOptions.size
98
+ ) {
95
99
  this.$five.imageOptions.size = this.configs.imageOptions.size
96
100
  }
97
-
101
+
98
102
  // 预载数据中的点位
99
103
  if (preload || (preload === undefined && this.configs.autoPreload)) {
100
- const panoIndexMap = vreoUnit.keyframes.filter((vreoKeyframe) => {
101
- if (vreoKeyframe.type !== VreoKeyframeEnum.CameraMovement) {
102
- return false
103
- }
104
-
105
- const data = vreoKeyframe.data as CameraMovementData
106
- if (data.panoIndex === undefined) {
107
- return false
108
- }
109
- return true
110
- }).reduce((accu: Record<number, boolean>, curr) => {
111
- const panoIndex = curr.data.panoIndex as number
112
- if (!accu[panoIndex]) {
113
- accu[panoIndex] = true
114
- }
115
- return accu
116
- }, {})
117
-
104
+ const panoIndexMap = vreoUnit.keyframes
105
+ .filter((vreoKeyframe) => {
106
+ if (vreoKeyframe.type !== VreoKeyframeEnum.CameraMovement) {
107
+ return false
108
+ }
109
+
110
+ const data = vreoKeyframe.data as CameraMovementData
111
+ if (data.panoIndex === undefined) {
112
+ return false
113
+ }
114
+ return true
115
+ })
116
+ .reduce((accu: Record<number, boolean>, curr) => {
117
+ const panoIndex = curr.data.panoIndex as number
118
+ if (!accu[panoIndex]) {
119
+ accu[panoIndex] = true
120
+ }
121
+ return accu
122
+ }, {})
123
+
118
124
  const panoIndexs = Object.keys(panoIndexMap)
119
125
  for (let i = 0; i < panoIndexs.length; i++) {
120
126
  await this.$five.preloadPano(Number(panoIndexs[i]))
121
127
  }
122
128
  }
123
-
129
+
124
130
  // 新数据载入就绪
125
131
  this.emit('loaded', vreoUnit)
126
132
  this.controller.emit('loaded', vreoUnit)
127
133
 
128
- if (vreoUnit.video.url) {
129
- if (this.controller.videoAgentScene?.videoAgentMesh.videoInstance) {
130
- this.controller.videoAgentScene.videoAgentMesh.videoInstance.currentTime = currentTime / 1000
131
- }
132
- await this.controller.videoAgentScene?.videoAgentMesh.play(vreoUnit.video.url)
133
- this.play()
134
+ if (this.controller.videoAgentScene?.videoAgentMesh.videoInstance) {
135
+ this.controller.videoAgentScene.videoAgentMesh.videoInstance.currentTime = currentTime / 1000
134
136
  }
137
+ await this.controller.videoAgentScene?.videoAgentMesh.play(
138
+ vreoUnit.video.url,
139
+ currentTime / 1000,
140
+ vreoUnit.video.duration
141
+ )
142
+ this.play()
143
+
135
144
  this.controller.run((type, keyframe) => this.emit(type, keyframe))
136
145
  return true
137
146
  }
@@ -140,8 +149,13 @@ export class Player extends Subscribe<VreoKeyframeEvent> {
140
149
  return !this.controller.playing
141
150
  }
142
151
 
143
- play() {
152
+ play(currentTime?: number) {
144
153
  if (this.controller.playing) return true
154
+ if (currentTime && this.controller.videoInstance) {
155
+ this.controller.videoInstance.currentTime = currentTime / 1000
156
+ }
157
+ Object.assign(window, {$vreoController: this.controller})
158
+
145
159
  this.controller.setPlaying(true)
146
160
  return true
147
161
  }
@@ -1,6 +1,7 @@
1
1
  import * as THREE from 'three'
2
2
  import { Preloader } from '../../../shared-utils/Preloader'
3
3
  import { makeObservable, observable, runInAction } from 'mobx'
4
+ import AudioLike from '../../../shared-utils/AduioLike'
4
5
 
5
6
  const vertexShader = `
6
7
  varying vec2 vUv;
@@ -76,14 +77,21 @@ export class VideoAgentMesh extends THREE.Mesh {
76
77
  freeze: boolean
77
78
  paused: boolean
78
79
  audioInstance: HTMLAudioElement
80
+ audioLikeInstance: AudioLike
79
81
  $removeEventListener: () => void
80
82
 
81
- get videoInstance(): HTMLAudioElement {
83
+ get videoInstance(): HTMLAudioElement | AudioLike {
84
+ if (!this.videoUrl) {
85
+ return this.audioLikeInstance
86
+ }
87
+
82
88
  if (this.videoUrl?.endsWith('mp3')) {
83
89
  return this.audioInstance
84
90
  }
91
+
85
92
  const uniforms = (this.material as THREE.ShaderMaterial).uniforms
86
93
  const videoInstance = uniforms.map.value.image as HTMLVideoElement
94
+
87
95
  return videoInstance
88
96
  }
89
97
 
@@ -155,23 +163,33 @@ export class VideoAgentMesh extends THREE.Mesh {
155
163
  this.audioInstance = options.audioInstance
156
164
  }
157
165
 
166
+ this.audioLikeInstance = new AudioLike()
167
+
158
168
  makeObservable(this, { paused: observable })
159
169
 
160
170
  const updatePaused = (paused: boolean) => runInAction(() => (this.paused = paused))
161
171
  const onPause = () => updatePaused(true)
162
172
  const onPlay = () => updatePaused(false)
163
173
 
164
- this.videoInstance.addEventListener('pause', onPause)
165
- this.videoInstance.addEventListener('play', onPlay)
174
+ this.audioInstance.addEventListener('pause', onPause)
175
+ this.audioInstance.addEventListener('play', onPlay)
176
+ this.options.videoInstance?.addEventListener('pause', onPause)
177
+ this.options.videoInstance?.addEventListener('play', onPlay)
178
+ this.audioLikeInstance.addEventListener('pause', onPause)
179
+ this.audioLikeInstance.addEventListener('play', onPlay)
166
180
 
167
181
  this.$removeEventListener = () => {
168
- this.videoInstance.removeEventListener('pause', onPause)
169
- this.videoInstance.removeEventListener('play', onPlay)
182
+ this.audioInstance.removeEventListener('pause', onPause)
183
+ this.audioInstance.removeEventListener('play', onPlay)
184
+ this.options.videoInstance?.removeEventListener('pause', onPause)
185
+ this.options.videoInstance?.removeEventListener('play', onPlay)
186
+ this.audioLikeInstance.removeEventListener('pause', onPause)
187
+ this.audioLikeInstance.removeEventListener('play', onPlay)
170
188
  }
171
189
  }
172
190
 
173
-
174
191
  private async update(videoUrl: string) {
192
+
175
193
  if (this.videoUrl === videoUrl) {
176
194
  return
177
195
  }
@@ -191,21 +209,33 @@ export class VideoAgentMesh extends THREE.Mesh {
191
209
  this.videoInstance.muted = false
192
210
  uniforms.enable.value = this.videoUrl?.endsWith('.mp4') ? 1 : 0
193
211
  this.videoInstance.removeEventListener('timeupdate', onStart, false)
212
+
194
213
  }
195
214
 
196
215
  this.videoInstance.addEventListener('timeupdate', onStart, false)
197
216
  }
198
217
 
199
- async play(videoUrl = '') {
218
+ async play(videoUrl = '', currentTime = 0, duration?: number) {
200
219
  videoUrl = videoUrl || ''
220
+ if (duration && !videoUrl) {
221
+ if (this.currentTime) {
222
+ this.videoInstance.currentTime = currentTime
223
+ }
224
+ (this.videoInstance as AudioLike).duration = duration
225
+ this.videoUrl = ''
226
+ this.videoInstance.play()
227
+ return true
228
+ }
229
+
201
230
  if (!videoUrl) {
202
231
  if (this.videoUrl) await this.videoInstance.play()
203
232
  else console.warn('警告:视频资源未初始化。')
204
233
  return true
205
234
  }
206
235
 
236
+ console.log('play', videoUrl, this.videoUrl)
207
237
  if (videoUrl === this.videoUrl) {
208
- this.videoInstance.currentTime = 0
238
+ this.videoInstance.currentTime = currentTime
209
239
  await this.videoInstance.play()
210
240
  return true
211
241
  }
@@ -216,7 +246,7 @@ export class VideoAgentMesh extends THREE.Mesh {
216
246
 
217
247
  return await new Promise((resolve) =>
218
248
  setTimeout(async () => {
219
- this.videoInstance.currentTime = 0
249
+ this.videoInstance.currentTime = currentTime
220
250
  await this.videoInstance.play()
221
251
  resolve(true)
222
252
  }, 20),
@@ -33,6 +33,8 @@ export class VideoAgentScene {
33
33
  run = () => {
34
34
  const domElement = this.renderer.domElement
35
35
 
36
+ // console.log('renderder', this.videoAgentMesh.paused, this.videoAgentMesh.freeze)
37
+
36
38
  // 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
37
39
  if (!(this.videoAgentMesh.paused || this.videoAgentMesh.freeze) && this.videoAgentMesh.currentTime > 1000) {
38
40
  this.renderer.render(this.scene, this.camera)
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react'
2
2
  import * as THREE from 'three'
3
+ import { useController, useFiveInstance } from '../../../hooks'
3
4
  import { ModelTVVideoPlugin } from '../../../../fivePlugins/ModelTVVideoPlugin'
4
5
  import { createTransMatrix } from '../../../../shared-utils/createTransMatrix'
5
6
  import { ModelVideoData, VreoKeyframe, VreoKeyframeEnum } from '../../../../typings/VreoUnit'
6
- import { useController, useFiveInstance } from '../../../hooks'
7
7
 
8
8
  export function ModelVideo() {
9
9
  const controller = useController()
@@ -2,13 +2,21 @@ import classNames from 'classnames'
2
2
  import * as React from 'react'
3
3
  import { Vector3 } from 'three'
4
4
  import { useController, useFiveInstance, useFiveProject2d } from '../../../hooks'
5
- import { PanoTagData, PanoTagEnum, Vertex, VreoKeyframe, VreoKeyframeEnum } from '../../../../typings/VreoUnit'
5
+ import {
6
+ PanoTagData,
7
+ PanoTagEnum,
8
+ PanoTagStyleEnum,
9
+ Vertex,
10
+ VreoKeyframe,
11
+ VreoKeyframeEnum,
12
+ } from '../../../../typings/VreoUnit'
6
13
 
7
14
  export function PanoTag() {
8
15
  const [state, setState] = React.useState<{
9
16
  vertex: Vertex
10
17
  text?: string
11
18
  type: PanoTagEnum
19
+ style?: PanoTagStyleEnum
12
20
  imgUrl?: string
13
21
  } | null>(null)
14
22
 
@@ -30,6 +38,7 @@ export function PanoTag() {
30
38
  const vertex = panoTagData.vertex
31
39
  const { x, y, z } = panoTagData.vertex
32
40
  const res = project2d(new Vector3(x, y, z))
41
+
33
42
  if (!res) return
34
43
  const { x: left, y: top } = res
35
44
  setState({
@@ -37,6 +46,7 @@ export function PanoTag() {
37
46
  text: panoTagData.text || PanoTagEnum.Text,
38
47
  type: panoTagData.type,
39
48
  imgUrl: panoTagData.imgUrl,
49
+ style: panoTagData.style || PanoTagStyleEnum.Growth,
40
50
  })
41
51
  setPos({ left, top })
42
52
  timeoutRef.current = setTimeout(() => {
@@ -92,6 +102,25 @@ export function PanoTag() {
92
102
  return undefined
93
103
  })()
94
104
 
105
+ if (state?.style === PanoTagStyleEnum.Expand) {
106
+ return (
107
+ <>
108
+ <div
109
+ className={classNames('PanoTag', {
110
+ 'PanoTag--expand': true,
111
+ 'PanoTag--notHidden': state,
112
+ })}
113
+ style={{
114
+ left: (pos?.left || 0) + 'px',
115
+ top: (pos?.top || 0) + 'px',
116
+ }}
117
+ >
118
+ <div className={'PanoTag-box PanoTag-box--' + (state?.type || '')}>{boxContent}</div>
119
+ <div className="PanoTag-guideline"></div>
120
+ </div>
121
+ </>
122
+ )
123
+ }
95
124
  return (
96
125
  <>
97
126
  <div
@@ -109,17 +138,7 @@ export function PanoTag() {
109
138
  <span className="PanoTag-slashline"></span>
110
139
  <span className="PanoTag-straightline"></span>
111
140
  </span>
112
- <div
113
- onClick={() => {
114
- if (state?.imgUrl) {
115
- // @TODO
116
- // setDrawerVisible(true)
117
- }
118
- }}
119
- className={'PanoTag-box PanoTag-box--' + (state?.type || '')}
120
- >
121
- {boxContent}
122
- </div>
141
+ <div className={'PanoTag-box PanoTag-box--' + (state?.type || '')}>{boxContent}</div>
123
142
  </div>
124
143
  </div>
125
144
  </>
@@ -26,7 +26,8 @@ export function Prompter() {
26
26
 
27
27
  ref.current = setTimeout(() => {
28
28
  setHidden(true)
29
- setTimeout(() => setText(''), 500)
29
+ setText('')
30
+ // setTimeout(() => setText(''), 500)
30
31
 
31
32
  if (ref.current) clearTimeout(ref.current)
32
33
  ref.current = null
@@ -54,7 +54,7 @@ export interface VreoActionCallbacks {
54
54
  /**
55
55
  * 播放。
56
56
  */
57
- play: () => void
57
+ play: (currentTime?: number) => void
58
58
  /**
59
59
  * 暂停。
60
60
  */
@@ -81,7 +81,7 @@ export function useVreoAction() {
81
81
  [player]
82
82
  )
83
83
 
84
- const play = React.useCallback(() => player.play(), [player])
84
+ const play = React.useCallback((currentTime?: number) => player.play(currentTime || 0), [player])
85
85
  const pause = React.useCallback(() => player.pause(), [player])
86
86
  const show = React.useCallback(() => player.show(), [player])
87
87
  const hide = React.useCallback(() => player.hide(), [player])