@realsee/vreo 0.1.6 → 0.2.0-alpha.11
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/README.md +103 -16
- package/docs/assets/custom.css +4 -4
- package/docs/assets/search.js +1 -1
- package/docs/classes/Player.Controller.html +54 -0
- package/docs/classes/Player.Player-1.html +11 -11
- package/docs/classes/Player.VideoAgentMesh.html +142 -0
- package/docs/classes/Player.VideoAgentScene.html +1 -0
- package/docs/enums/Player.InfoPanelStyleEnum.html +1 -0
- package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
- package/docs/enums/Player.PanoEffectEnum.html +2 -2
- package/docs/enums/Player.PanoTagEnum.html +1 -1
- package/docs/enums/Player.VreoKeyframeEnum.html +14 -12
- package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
- package/docs/enums/fivePlugins.Rotation.html +1 -1
- package/docs/index.html +52 -19
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -0
- package/docs/interfaces/Player.PlayerConfigs.html +4 -2
- package/docs/interfaces/Player.Vertex.html +1 -1
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +1 -0
- package/docs/interfaces/Player.VreoKeyframe.html +1 -1
- package/docs/interfaces/Player.VreoUnit.html +1 -1
- package/docs/interfaces/Player.VreoVideo.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +3 -3
- 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/react.VreoActionCallbacks.html +15 -7
- package/docs/interfaces/react.VreoProviderProps.html +1 -0
- package/docs/modules/Player.html +17 -15
- package/docs/modules/custom.html +3 -0
- package/docs/modules/fivePlugins.html +2 -2
- package/docs/modules/react.html +1 -1
- package/docs/modules.html +1 -1
- package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
- package/lib/PlayController/createHTMLAudioElement.js +47 -0
- package/lib/PlayController/index.d.ts +38 -0
- package/lib/PlayController/index.js +300 -0
- package/lib/Player/App.js +8 -3
- package/lib/Player/Controller.d.ts +2 -0
- package/lib/Player/Controller.js +14 -0
- package/lib/Player/custom/SpatialScenePanel/index.d.ts +22 -0
- package/lib/Player/custom/SpatialScenePanel/index.js +279 -0
- package/lib/Player/index.d.ts +1 -1
- package/lib/Player/index.js +98 -11
- package/lib/Player/modules/Drawer/index.js +1 -1
- package/lib/Player/modules/PopUp/index.d.ts +2 -0
- package/lib/Player/modules/PopUp/index.js +43 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +1 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +6 -2
- package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +4 -1
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +21 -6
- package/lib/Player/modules/VideoAgent/index.d.ts +2 -0
- package/lib/Player/modules/VideoAgent/index.js +1 -1
- package/lib/Player/modules/keyframes/BgMusic/index.d.ts +2 -0
- package/lib/Player/modules/keyframes/BgMusic/index.js +76 -0
- package/lib/Player/modules/keyframes/CameraMovement/index.js +41 -5
- package/lib/Player/modules/keyframes/InfoPanel/index.js +105 -23
- package/lib/Player/modules/keyframes/ModelVideo/index.js +47 -10
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +4 -12
- package/lib/Player/modules/keyframes/Prompter/index.js +4 -18
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +71 -12
- package/lib/Player/typings.d.ts +19 -1
- package/lib/fivePlugins/CameraMovementPlugin/index.js +104 -90
- package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +1 -0
- package/lib/react/index.d.ts +10 -2
- package/lib/react/index.js +1 -1
- package/lib/shared-utils/createTransMatrix.d.ts +1 -0
- package/lib/shared-utils/createTransMatrix.js +43 -0
- package/lib/typings/VreoUnit.d.ts +47 -7
- package/lib/typings/VreoUnit.js +15 -6
- package/package.json +6 -6
- package/resources/PlayController/createHTMLAudioElement.ts +53 -0
- package/resources/PlayController/index.ts +167 -0
- package/resources/Player/App.tsx +6 -1
- package/resources/Player/Controller.ts +12 -0
- package/resources/Player/custom/SpatialScenePanel/index.tsx +264 -0
- package/resources/Player/index.tsx +56 -2
- package/resources/Player/modules/Drawer/index.tsx +1 -1
- package/resources/Player/modules/PopUp/index.tsx +26 -0
- package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +5 -4
- package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +11 -2
- package/resources/Player/modules/VideoAgent/index.tsx +3 -2
- package/resources/Player/modules/keyframes/BgMusic/index.tsx +66 -0
- package/resources/Player/modules/keyframes/CameraMovement/index.tsx +7 -3
- package/resources/Player/modules/keyframes/InfoPanel/index.tsx +109 -11
- package/resources/Player/modules/keyframes/ModelVideo/index.tsx +38 -5
- package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +2 -2
- package/resources/Player/modules/keyframes/Prompter/index.tsx +5 -15
- package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +75 -12
- package/resources/Player/typings.ts +21 -1
- package/resources/fivePlugins/CameraMovementPlugin/index.ts +59 -48
- package/resources/fivePlugins/CameraMovementPlugin/typings.ts +2 -1
- package/resources/react/index.tsx +12 -3
- package/resources/shared-utils/createTransMatrix.ts +12 -0
- package/resources/typings/VreoUnit.ts +56 -7
- package/stylesheets/custom/SpatialScenePanel.css +309 -0
- package/stylesheets/default.css +127 -9
|
@@ -0,0 +1,279 @@
|
|
|
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.SpatialScenePanel = SpatialScenePanel;
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
|
+
|
|
14
|
+
var _three = require("three");
|
|
15
|
+
|
|
16
|
+
var _BetterTween = require("@realsee/dnalogel/shared-utils/animationFrame/BetterTween");
|
|
17
|
+
|
|
18
|
+
var _CSS3DRenderPlugin = require("@realsee/dnalogel/plugins/CSS3DRenderPlugin");
|
|
19
|
+
|
|
20
|
+
var _VreoUnit = require("../../../typings/VreoUnit");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
+
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
29
|
+
|
|
30
|
+
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."); }
|
|
31
|
+
|
|
32
|
+
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); }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
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; }
|
|
37
|
+
|
|
38
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
39
|
+
|
|
40
|
+
// const getSphere = (position: Vector3, color = 0xffff00) => {
|
|
41
|
+
// const geometry = new SphereGeometry(0.05, 32, 16)
|
|
42
|
+
// const material = new MeshBasicMaterial({ color })
|
|
43
|
+
// const sphere = new Mesh(geometry, material)
|
|
44
|
+
// sphere.position.copy(position)
|
|
45
|
+
// return sphere
|
|
46
|
+
// }
|
|
47
|
+
var searchV1 = function searchV1(_ref) {
|
|
48
|
+
var five = _ref.five,
|
|
49
|
+
dom = _ref.dom;
|
|
50
|
+
var cameraDirection = new _three.Vector3();
|
|
51
|
+
five.camera.getWorldDirection(cameraDirection);
|
|
52
|
+
var cameraPosition = five.camera.position;
|
|
53
|
+
|
|
54
|
+
var _five$model$intersect = five.model.intersectRaycaster(new _three.Raycaster(cameraPosition, cameraDirection)),
|
|
55
|
+
_five$model$intersect2 = _slicedToArray(_five$model$intersect, 1),
|
|
56
|
+
intersect = _five$model$intersect2[0];
|
|
57
|
+
|
|
58
|
+
var point = five.project2d(intersect.point);
|
|
59
|
+
var widescreen = window.innerWidth > 560 ? true : false; // const width = dom!.clientWidth
|
|
60
|
+
|
|
61
|
+
var height = dom.clientHeight;
|
|
62
|
+
dom.style.left = point.x + 'px';
|
|
63
|
+
dom.style.top = point.y - height / 2 + 'px';
|
|
64
|
+
var rect = dom.getBoundingClientRect();
|
|
65
|
+
var left = rect.left,
|
|
66
|
+
top = rect.top,
|
|
67
|
+
bottom = rect.bottom,
|
|
68
|
+
right = rect.right;
|
|
69
|
+
var leftBottom = new _three.Vector3(left, bottom);
|
|
70
|
+
var leftTop = new _three.Vector3(left, top);
|
|
71
|
+
var rightTop = new _three.Vector3(right, top);
|
|
72
|
+
var rightBottom = new _three.Vector3(right, bottom);
|
|
73
|
+
var points = [leftBottom, rightBottom, rightTop, leftTop].map(function (point) {
|
|
74
|
+
point.setX(point.x / window.innerWidth * 2 - (widescreen ? 1.25 : 1.75));
|
|
75
|
+
point.setY(-(point.y / window.innerHeight) * 2 + (widescreen ? 1.35 : 1.125));
|
|
76
|
+
point.setZ(0.5);
|
|
77
|
+
return point.unproject(five.camera).addScaledVector(cameraDirection, 0.2);
|
|
78
|
+
}); // __debug__
|
|
79
|
+
// const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
|
|
80
|
+
// points.forEach((p, index) => five.scene.add(getSphere(p, colors[index])))
|
|
81
|
+
// 判断是手机 150
|
|
82
|
+
|
|
83
|
+
var ratio = leftBottom.distanceTo(rightBottom) / (widescreen ? 150 : 120);
|
|
84
|
+
return {
|
|
85
|
+
points: points,
|
|
86
|
+
ratio: ratio
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* 空间场景面板
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
function SpatialScenePanel(props) {
|
|
96
|
+
var timeoutRef = React.useRef(null);
|
|
97
|
+
var ref = React.useRef(null);
|
|
98
|
+
var panelRef = React.useRef(null);
|
|
99
|
+
var rendererRef = React.useRef((0, _CSS3DRenderPlugin.CSS3DRenderPlugin)(props.five));
|
|
100
|
+
React.useEffect(function () {
|
|
101
|
+
if (!ref.current) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var callback = function callback(keyframe) {
|
|
106
|
+
if (keyframe.data.customType !== 'SpatialScenePanel') {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
var data = keyframe.data; // const data = mockData
|
|
111
|
+
|
|
112
|
+
var _searchV = searchV1({
|
|
113
|
+
five: props.five,
|
|
114
|
+
dom: ref.current
|
|
115
|
+
}),
|
|
116
|
+
points = _searchV.points,
|
|
117
|
+
ratio = _searchV.ratio;
|
|
118
|
+
|
|
119
|
+
var _ref2 = rendererRef.current.create3DDomContainer(points, {
|
|
120
|
+
ratio: ratio,
|
|
121
|
+
autoRender: false
|
|
122
|
+
}) || {},
|
|
123
|
+
container = _ref2.container,
|
|
124
|
+
dispose = _ref2.dispose,
|
|
125
|
+
css3DObject = _ref2.css3DObject,
|
|
126
|
+
render = _ref2.render;
|
|
127
|
+
|
|
128
|
+
Object.assign(window, {
|
|
129
|
+
$css3DObject: css3DObject
|
|
130
|
+
});
|
|
131
|
+
if (!container) return;
|
|
132
|
+
|
|
133
|
+
_reactDom["default"].render( /*#__PURE__*/React.createElement(Panel, {
|
|
134
|
+
ref: function ref(_ref3) {
|
|
135
|
+
return panelRef.current = _ref3;
|
|
136
|
+
},
|
|
137
|
+
data: data
|
|
138
|
+
}), container);
|
|
139
|
+
|
|
140
|
+
var startRotateY = -(Math.PI * 2) / 9;
|
|
141
|
+
var lastRotateY = 0;
|
|
142
|
+
(0, _BetterTween.tweenProgress)(1000).onUpdate(function (_ref4) {
|
|
143
|
+
var progress = _ref4.progress;
|
|
144
|
+
var needRotateY = Math.PI / 90 * 11 * progress;
|
|
145
|
+
var rotateY = needRotateY - lastRotateY;
|
|
146
|
+
css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(rotateY); // css3DObject?.rotateZ
|
|
147
|
+
|
|
148
|
+
lastRotateY = needRotateY;
|
|
149
|
+
}).onStart(function () {
|
|
150
|
+
css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(startRotateY);
|
|
151
|
+
render();
|
|
152
|
+
}).onDispose(function () {
|
|
153
|
+
var _panelRef$current;
|
|
154
|
+
|
|
155
|
+
(_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.classList.add('show');
|
|
156
|
+
}).play(); // Object.assign(window, { $dispose: () => {
|
|
157
|
+
// panelRef.current?.classList.add('hide')
|
|
158
|
+
// setTimeout(() => dispose?.(), 1500)
|
|
159
|
+
// } })
|
|
160
|
+
|
|
161
|
+
var start = keyframe.start,
|
|
162
|
+
end = keyframe.end;
|
|
163
|
+
timeoutRef.current = setTimeout(function () {
|
|
164
|
+
var _panelRef$current2;
|
|
165
|
+
|
|
166
|
+
(_panelRef$current2 = panelRef.current) === null || _panelRef$current2 === void 0 ? void 0 : _panelRef$current2.classList.add('hide');
|
|
167
|
+
timeoutRef.current = setTimeout(function () {
|
|
168
|
+
dispose === null || dispose === void 0 ? void 0 : dispose();
|
|
169
|
+
timeoutRef.current = null;
|
|
170
|
+
}, 1500);
|
|
171
|
+
}, end - start);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
Object.assign(window, {
|
|
175
|
+
$callback: callback
|
|
176
|
+
}); // setTimeout(() => {callback()}, 8000)
|
|
177
|
+
|
|
178
|
+
props.subscribe.on(_VreoUnit.VreoKeyframeEnum.Custom, callback);
|
|
179
|
+
return function () {
|
|
180
|
+
props.subscribe.off(_VreoUnit.VreoKeyframeEnum.Custom, callback);
|
|
181
|
+
|
|
182
|
+
if (timeoutRef.current) {
|
|
183
|
+
clearTimeout(timeoutRef.current);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}, []);
|
|
187
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
188
|
+
className: "vreo-SpatialScenePanel",
|
|
189
|
+
ref: ref
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/** 背景动画:控制延迟 */
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
function SpatialScenePanelBg() {
|
|
196
|
+
var ref = React.useRef(null);
|
|
197
|
+
var timeoutRef = React.useRef(null);
|
|
198
|
+
React.useEffect(function () {
|
|
199
|
+
if (!ref.current) return;
|
|
200
|
+
|
|
201
|
+
var listener = function listener() {
|
|
202
|
+
var _ref$current;
|
|
203
|
+
|
|
204
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.setAttribute('class', 'SpatialScenePanel-bg');
|
|
205
|
+
timeoutRef.current = setTimeout(function () {
|
|
206
|
+
var _ref$current2;
|
|
207
|
+
|
|
208
|
+
(_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.setAttribute('class', 'SpatialScenePanel-bg SpatialScenePanel-bg--animation');
|
|
209
|
+
timeoutRef.current = null;
|
|
210
|
+
}, 3000);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
ref.current.addEventListener('animationend', listener);
|
|
214
|
+
return function () {
|
|
215
|
+
if (ref.current) ref.current.removeEventListener('animationend', listener);
|
|
216
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
217
|
+
};
|
|
218
|
+
}, []);
|
|
219
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
220
|
+
ref: ref,
|
|
221
|
+
className: "SpatialScenePanel-bg SpatialScenePanel-bg--animation"
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
|
|
226
|
+
var _props$data, _props$data2, _props$data3, _props$data3$stateLis;
|
|
227
|
+
|
|
228
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
229
|
+
className: "SpatialScenePanel",
|
|
230
|
+
ref: myRef
|
|
231
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
232
|
+
className: "SpatialScenePanel-show-area"
|
|
233
|
+
}, /*#__PURE__*/React.createElement(SpatialScenePanelBg, null), /*#__PURE__*/React.createElement("div", {
|
|
234
|
+
className: "SpatialScenePanel-header"
|
|
235
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
236
|
+
className: "SpatialScenePanel-title"
|
|
237
|
+
}, (_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.title), /*#__PURE__*/React.createElement("div", {
|
|
238
|
+
className: "SpatialScenePanel-temperature"
|
|
239
|
+
}, (_props$data2 = props.data) === null || _props$data2 === void 0 ? void 0 : _props$data2.temperature, "\u2103")), /*#__PURE__*/React.createElement("div", {
|
|
240
|
+
className: "SpatialScenePanel-body"
|
|
241
|
+
}, (_props$data3 = props.data) === null || _props$data3 === void 0 ? void 0 : (_props$data3$stateLis = _props$data3.stateList) === null || _props$data3$stateLis === void 0 ? void 0 : _props$data3$stateLis.map(function (state, index) {
|
|
242
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
243
|
+
key: "scene-".concat(state.text),
|
|
244
|
+
className: "SpatialScenePanel-item index_".concat(index)
|
|
245
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
246
|
+
className: "SpatialScenePanel-icon",
|
|
247
|
+
src: state.icon
|
|
248
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
249
|
+
className: "SpatialScenePanel-text"
|
|
250
|
+
}, state.text), /*#__PURE__*/React.createElement("div", {
|
|
251
|
+
className: "SpatialScenePanel-dot"
|
|
252
|
+
}));
|
|
253
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
254
|
+
className: "SpatialScenePanel-disappear-area"
|
|
255
|
+
}));
|
|
256
|
+
}); // export function SpatialScenePanel() {
|
|
257
|
+
// // const data = mockData
|
|
258
|
+
// return (
|
|
259
|
+
// <div className="SpatialScenePanel" >
|
|
260
|
+
// <div className="SpatialScenePanel-show-area">
|
|
261
|
+
// <SpatialScenePanelBg />
|
|
262
|
+
// <div className="SpatialScenePanel-header">
|
|
263
|
+
// <div className="SpatialScenePanel-title">{data?.title}</div>
|
|
264
|
+
// <div className="SpatialScenePanel-temperature">{data?.temperature}℃</div>
|
|
265
|
+
// </div>
|
|
266
|
+
// <div className="SpatialScenePanel-body">
|
|
267
|
+
// {data?.stateList?.map((state, index) => (
|
|
268
|
+
// <div key={`scene-${state.text}`} className={`SpatialScenePanel-item index_${index}`}>
|
|
269
|
+
// <img className="SpatialScenePanel-icon" src={state.icon}></img>
|
|
270
|
+
// <div className="SpatialScenePanel-text">{state.text}</div>
|
|
271
|
+
// <div className="SpatialScenePanel-dot"></div>
|
|
272
|
+
// </div>
|
|
273
|
+
// ))}
|
|
274
|
+
// </div>
|
|
275
|
+
// </div>
|
|
276
|
+
// <div className="SpatialScenePanel-disappear-area"></div>
|
|
277
|
+
// </div>
|
|
278
|
+
// )
|
|
279
|
+
// }
|
package/lib/Player/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
|
|
|
6
6
|
private controller;
|
|
7
7
|
configs: Readonly<PlayerConfigs>;
|
|
8
8
|
constructor(five: Five, configs?: Partial<PlayerConfigs>);
|
|
9
|
-
load(vreoUnit: VreoUnit, currentTime?: number): Promise<boolean>;
|
|
9
|
+
load(vreoUnit: VreoUnit, currentTime?: number, preload?: boolean, force?: boolean): Promise<boolean>;
|
|
10
10
|
get paused(): boolean;
|
|
11
11
|
play(): boolean;
|
|
12
12
|
pause(): void;
|
package/lib/Player/index.js
CHANGED
|
@@ -17,10 +17,14 @@ var _App = require("./App");
|
|
|
17
17
|
|
|
18
18
|
var _Controller = require("./Controller");
|
|
19
19
|
|
|
20
|
+
var _VreoUnit = require("../typings/VreoUnit");
|
|
21
|
+
|
|
20
22
|
var _mobx = require("mobx");
|
|
21
23
|
|
|
22
24
|
var _Drawer = require("./modules/Drawer");
|
|
23
25
|
|
|
26
|
+
var _PopUp = require("./modules/PopUp");
|
|
27
|
+
|
|
24
28
|
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); }
|
|
25
29
|
|
|
26
30
|
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; }
|
|
@@ -79,7 +83,23 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
79
83
|
_this.controller.configs = _this.configs;
|
|
80
84
|
ReactDOM.render( /*#__PURE__*/React.createElement(_Controller.ControllerContext.Provider, {
|
|
81
85
|
value: _this.controller
|
|
82
|
-
}, /*#__PURE__*/React.createElement(_App.App, null), /*#__PURE__*/React.createElement(_Drawer.Drawer, null)), configs.
|
|
86
|
+
}, /*#__PURE__*/React.createElement(_App.App, null), /*#__PURE__*/React.createElement(_Drawer.Drawer, null), /*#__PURE__*/React.createElement(_PopUp.PopUp, null), _this.configs.customKeyframes && _this.configs.customKeyframes.map(function (CustomCmpt, key) {
|
|
87
|
+
return /*#__PURE__*/React.createElement(CustomCmpt, {
|
|
88
|
+
key: key,
|
|
89
|
+
subscribe: {
|
|
90
|
+
on: function on(name, callback) {
|
|
91
|
+
return _this.on(name, callback);
|
|
92
|
+
},
|
|
93
|
+
once: function once(name, callback) {
|
|
94
|
+
return _this.once(name, callback);
|
|
95
|
+
},
|
|
96
|
+
off: function off(name, callback) {
|
|
97
|
+
return _this.off(name, callback);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
five: five
|
|
101
|
+
});
|
|
102
|
+
})), configs.containter); // 监听播放情况:抛出触发时机
|
|
83
103
|
|
|
84
104
|
(0, _mobx.reaction)(function () {
|
|
85
105
|
return _this.controller.playing;
|
|
@@ -94,9 +114,15 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
94
114
|
value: function () {
|
|
95
115
|
var _load = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(vreoUnit) {
|
|
96
116
|
var _this$controller$vide,
|
|
117
|
+
_this$configs$imageOp,
|
|
97
118
|
_this2 = this;
|
|
98
119
|
|
|
99
120
|
var currentTime,
|
|
121
|
+
preload,
|
|
122
|
+
force,
|
|
123
|
+
panoIndexMap,
|
|
124
|
+
panoIndexs,
|
|
125
|
+
i,
|
|
100
126
|
_this$controller$vide2,
|
|
101
127
|
_this$controller$vide3,
|
|
102
128
|
_args = arguments;
|
|
@@ -106,31 +132,92 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
106
132
|
switch (_context.prev = _context.next) {
|
|
107
133
|
case 0:
|
|
108
134
|
currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
|
|
135
|
+
preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
|
|
136
|
+
force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
|
|
137
|
+
|
|
138
|
+
if (force) {
|
|
139
|
+
vreoUnit = JSON.parse(JSON.stringify(vreoUnit));
|
|
140
|
+
}
|
|
109
141
|
|
|
110
142
|
if (this.controller.visible) {
|
|
111
|
-
_context.next =
|
|
143
|
+
_context.next = 8;
|
|
112
144
|
break;
|
|
113
145
|
}
|
|
114
146
|
|
|
115
|
-
this.controller.setVisible(true);
|
|
116
|
-
|
|
147
|
+
this.controller.setVisible(true); // 延迟 500ms 规避跟 DOM 动画冲突
|
|
148
|
+
|
|
149
|
+
_context.next = 8;
|
|
117
150
|
return new Promise(function (resolve) {
|
|
118
151
|
setTimeout(function () {
|
|
119
152
|
return resolve(true);
|
|
120
153
|
}, 500);
|
|
121
154
|
});
|
|
122
155
|
|
|
123
|
-
case
|
|
156
|
+
case 8:
|
|
124
157
|
if (this.controller.stopInterval) {
|
|
125
158
|
this.controller.stopInterval();
|
|
126
159
|
this.controller.stopInterval = undefined;
|
|
127
160
|
}
|
|
128
161
|
|
|
129
162
|
this.controller.vreoUnit = vreoUnit;
|
|
130
|
-
(_this$controller$vide = this.controller.videoInstance) === null || _this$controller$vide === void 0 ? void 0 : _this$controller$vide.pause();
|
|
163
|
+
(_this$controller$vide = this.controller.videoInstance) === null || _this$controller$vide === void 0 ? void 0 : _this$controller$vide.pause(); // 预载逻辑
|
|
164
|
+
// 是否降低图片分辨率
|
|
165
|
+
|
|
166
|
+
if (this.$five.imageOptions.size && (_this$configs$imageOp = this.configs.imageOptions) !== null && _this$configs$imageOp !== void 0 && _this$configs$imageOp.size && this.$five.imageOptions.size > this.configs.imageOptions.size) {
|
|
167
|
+
this.$five.imageOptions.size = this.configs.imageOptions.size;
|
|
168
|
+
} // 预载数据中的点位
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if (!(preload || preload === undefined && this.configs.autoPreload)) {
|
|
172
|
+
_context.next = 22;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
|
|
177
|
+
if (vreoKeyframe.type !== _VreoUnit.VreoKeyframeEnum.CameraMovement) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var data = vreoKeyframe.data;
|
|
182
|
+
|
|
183
|
+
if (data.panoIndex === undefined) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return true;
|
|
188
|
+
}).reduce(function (accu, curr) {
|
|
189
|
+
var panoIndex = curr.data.panoIndex;
|
|
190
|
+
|
|
191
|
+
if (!accu[panoIndex]) {
|
|
192
|
+
accu[panoIndex] = true;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return accu;
|
|
196
|
+
}, {});
|
|
197
|
+
panoIndexs = Object.keys(panoIndexMap);
|
|
198
|
+
i = 0;
|
|
199
|
+
|
|
200
|
+
case 16:
|
|
201
|
+
if (!(i < panoIndexs.length)) {
|
|
202
|
+
_context.next = 22;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
_context.next = 19;
|
|
207
|
+
return this.$five.preloadPano(Number(panoIndexs[i]));
|
|
208
|
+
|
|
209
|
+
case 19:
|
|
210
|
+
i++;
|
|
211
|
+
_context.next = 16;
|
|
212
|
+
break;
|
|
213
|
+
|
|
214
|
+
case 22:
|
|
215
|
+
// 新数据载入就绪
|
|
216
|
+
this.emit('loaded', vreoUnit);
|
|
217
|
+
this.controller.emit('loaded', vreoUnit);
|
|
131
218
|
|
|
132
219
|
if (!vreoUnit.video.url) {
|
|
133
|
-
_context.next =
|
|
220
|
+
_context.next = 29;
|
|
134
221
|
break;
|
|
135
222
|
}
|
|
136
223
|
|
|
@@ -138,19 +225,19 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
138
225
|
this.controller.videoAgentScene.videoAgentMesh.videoInstance.currentTime = currentTime / 1000;
|
|
139
226
|
}
|
|
140
227
|
|
|
141
|
-
_context.next =
|
|
228
|
+
_context.next = 28;
|
|
142
229
|
return (_this$controller$vide3 = this.controller.videoAgentScene) === null || _this$controller$vide3 === void 0 ? void 0 : _this$controller$vide3.videoAgentMesh.play(vreoUnit.video.url);
|
|
143
230
|
|
|
144
|
-
case
|
|
231
|
+
case 28:
|
|
145
232
|
this.play();
|
|
146
233
|
|
|
147
|
-
case
|
|
234
|
+
case 29:
|
|
148
235
|
this.controller.run(function (type, keyframe) {
|
|
149
236
|
return _this2.emit(type, keyframe);
|
|
150
237
|
});
|
|
151
238
|
return _context.abrupt("return", true);
|
|
152
239
|
|
|
153
|
-
case
|
|
240
|
+
case 31:
|
|
154
241
|
case "end":
|
|
155
242
|
return _context.stop();
|
|
156
243
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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.PopUp = PopUp;
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _mobxReact = require("mobx-react");
|
|
15
|
+
|
|
16
|
+
var _hooks = require("../../hooks");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
var PopUpView = (0, _mobxReact.observer)(function (_ref) {
|
|
25
|
+
var controller = _ref.controller;
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
className: (0, _classnames["default"])('vreo-PopUp', {
|
|
28
|
+
'vreo-PopUp-visible': controller.popUp
|
|
29
|
+
}),
|
|
30
|
+
onClick: function onClick() {
|
|
31
|
+
return controller.openPopUp(false);
|
|
32
|
+
}
|
|
33
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: "vreo-PopUp-inner"
|
|
35
|
+
}, controller.popUp || ''));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function PopUp() {
|
|
39
|
+
var controller = (0, _hooks.useController)();
|
|
40
|
+
return /*#__PURE__*/React.createElement(PopUpView, {
|
|
41
|
+
controller: controller
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -106,7 +106,8 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
106
106
|
_this.options = options;
|
|
107
107
|
_this.freeze = false;
|
|
108
108
|
_this.paused = true;
|
|
109
|
-
|
|
109
|
+
|
|
110
|
+
if (!options.audioInstance) {
|
|
110
111
|
if (cacheInstance.audioInstance) {
|
|
111
112
|
_this.audioInstance = cacheInstance.audioInstance;
|
|
112
113
|
} else {
|
|
@@ -122,7 +123,10 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
122
123
|
_this.audioInstance = audioInstance;
|
|
123
124
|
cacheInstance.audioInstance = audioInstance;
|
|
124
125
|
}
|
|
126
|
+
} else {
|
|
127
|
+
_this.audioInstance = options.audioInstance;
|
|
125
128
|
}
|
|
129
|
+
|
|
126
130
|
(0, _mobx.makeObservable)(_assertThisInitialized(_this), {
|
|
127
131
|
paused: _mobx.observable
|
|
128
132
|
});
|
|
@@ -247,7 +251,7 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
247
251
|
switch (_context3.prev = _context3.next) {
|
|
248
252
|
case 0:
|
|
249
253
|
videoUrl = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : '';
|
|
250
|
-
videoUrl =
|
|
254
|
+
videoUrl = videoUrl || '';
|
|
251
255
|
|
|
252
256
|
if (videoUrl) {
|
|
253
257
|
_context3.next = 10;
|
|
@@ -6,7 +6,10 @@ export declare class VideoAgentScene {
|
|
|
6
6
|
camera: THREE.OrthographicCamera;
|
|
7
7
|
renderer: THREE.WebGLRenderer;
|
|
8
8
|
container: HTMLElement;
|
|
9
|
-
constructor(container: HTMLElement, needRender?: boolean
|
|
9
|
+
constructor(container: HTMLElement, needRender?: boolean, options?: {
|
|
10
|
+
videoInstance?: HTMLVideoElement;
|
|
11
|
+
audioInstance?: HTMLAudioElement;
|
|
12
|
+
});
|
|
10
13
|
run: () => void;
|
|
11
14
|
dispose: () => void;
|
|
12
15
|
}
|
|
@@ -23,6 +23,7 @@ var VideoAgentScene = function VideoAgentScene(container) {
|
|
|
23
23
|
var _this = this;
|
|
24
24
|
|
|
25
25
|
var needRender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
26
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
26
27
|
|
|
27
28
|
_classCallCheck(this, VideoAgentScene);
|
|
28
29
|
|
|
@@ -35,9 +36,19 @@ var VideoAgentScene = function VideoAgentScene(container) {
|
|
|
35
36
|
}));
|
|
36
37
|
|
|
37
38
|
_defineProperty(this, "run", function () {
|
|
38
|
-
|
|
39
|
+
var _this$videoAgentMesh$;
|
|
40
|
+
|
|
41
|
+
var domElement = _this.renderer.domElement; // 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
|
|
42
|
+
|
|
39
43
|
if (!(_this.videoAgentMesh.paused || _this.videoAgentMesh.freeze) && _this.videoAgentMesh.currentTime > 1000) {
|
|
40
44
|
_this.renderer.render(_this.scene, _this.camera);
|
|
45
|
+
} // 兼容非视频场景
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if (!((_this$videoAgentMesh$ = _this.videoAgentMesh.videoUrl) !== null && _this$videoAgentMesh$ !== void 0 && _this$videoAgentMesh$.endsWith('.mp4'))) {
|
|
49
|
+
if (domElement.style.display !== 'none') domElement.style.display = 'none';
|
|
50
|
+
} else {
|
|
51
|
+
if (domElement.style.display !== 'block') domElement.style.display = 'block';
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
requestAnimationFrame(_this.run);
|
|
@@ -56,14 +67,18 @@ var VideoAgentScene = function VideoAgentScene(container) {
|
|
|
56
67
|
width: container.offsetWidth,
|
|
57
68
|
height: container.offsetHeight
|
|
58
69
|
};
|
|
59
|
-
var
|
|
60
|
-
|
|
70
|
+
var _domElement = this.renderer.domElement;
|
|
71
|
+
|
|
72
|
+
_domElement.classList.add('VideoAgent-canvas');
|
|
73
|
+
|
|
61
74
|
this.renderer.setSize(state.width * window.devicePixelRatio, state.height * window.devicePixelRatio);
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
|
|
76
|
+
_domElement.setAttribute('style', "width: ".concat(state.width, "px;height: ").concat(state.height, "px;"));
|
|
77
|
+
|
|
78
|
+
this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options);
|
|
64
79
|
|
|
65
80
|
if (needRender) {
|
|
66
|
-
container.append(
|
|
81
|
+
container.append(_domElement);
|
|
67
82
|
this.scene.add(this.videoAgentMesh);
|
|
68
83
|
this.run();
|
|
69
84
|
}
|
|
@@ -28,7 +28,7 @@ function VideoAgent(props) {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
var videoAgentScene = new _VideoAgentScene.VideoAgentScene(ref.current);
|
|
31
|
+
var videoAgentScene = new _VideoAgentScene.VideoAgentScene(ref.current, true, props.options || {});
|
|
32
32
|
controller.videoAgentScene = videoAgentScene;
|
|
33
33
|
return function () {
|
|
34
34
|
var _controller$videoAgen;
|