@realsee/vreo 2.2.6 → 2.2.7
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/lib/PlayController/createHTMLAudioElement.js +11 -6
- package/lib/PlayController/index.js +80 -15
- package/lib/Player/App.js +26 -0
- package/lib/Player/Controller.js +100 -23
- package/lib/Player/custom/SpatialScenePanel/index.js +68 -42
- package/lib/Player/hooks.js +10 -0
- package/lib/Player/index.js +88 -24
- package/lib/Player/modules/Drawer/index.js +17 -0
- package/lib/Player/modules/PopUp/index.js +10 -0
- package/lib/Player/modules/ResizeObserver/index.js +8 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +108 -17
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +24 -2
- package/lib/Player/modules/VideoAgent/index.js +17 -0
- package/lib/Player/modules/Wave/index.js +32 -7
- package/lib/Player/modules/keyframes/BgMusic/index.js +25 -7
- package/lib/Player/modules/keyframes/CameraMovement/index.js +27 -3
- package/lib/Player/modules/keyframes/InfoPanel/index.js +29 -6
- package/lib/Player/modules/keyframes/ModelVideo/index.js +29 -3
- package/lib/Player/modules/keyframes/PanoEffect/index.js +43 -15
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +7 -0
- package/lib/Player/modules/keyframes/PanoTag/index.js +22 -4
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +47 -22
- package/lib/Player/modules/keyframes/Prompter/index.js +32 -10
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +25 -18
- package/lib/Player/modules/keyframes/VideoEffect/index.js +65 -16
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +2 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +1 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +1 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +60 -19
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +5 -2
- package/lib/fivePlugins/CameraMovementPlugin/index.js +72 -19
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +4 -0
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +60 -11
- package/lib/index.js +1 -0
- package/lib/react/index.js +34 -7
- package/lib/shared-utils/Audio.js +69 -15
- package/lib/shared-utils/AudioLike.js +39 -5
- package/lib/shared-utils/Preloader.js +7 -0
- package/lib/shared-utils/addResizeListener.js +5 -0
- package/lib/shared-utils/animationFrame/BetterTween.js +38 -2
- package/lib/shared-utils/animationFrame/index.js +10 -2
- package/lib/shared-utils/animationFrame/tween.js +11 -2
- package/lib/shared-utils/createTransMatrix.js +17 -2
- package/lib/shared-utils/getFileExpandedName.js +1 -0
- package/lib/shared-utils/getMediaInfo.js +9 -0
- package/lib/shared-utils/setElementDataset.js +2 -0
- package/lib/typings/VreoUnit.js +15 -0
- package/package.json +4 -2
|
@@ -1,42 +1,68 @@
|
|
|
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.VideoAgentMesh = void 0;
|
|
9
|
+
|
|
8
10
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
+
|
|
9
12
|
var _Preloader = require("../../../shared-utils/Preloader");
|
|
13
|
+
|
|
10
14
|
var _mobx = require("mobx");
|
|
15
|
+
|
|
11
16
|
var _AudioLike = _interopRequireDefault(require("../../../shared-utils/AudioLike"));
|
|
17
|
+
|
|
12
18
|
var _getMediaInfo = require("../../../shared-utils/getMediaInfo");
|
|
19
|
+
|
|
13
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
14
22
|
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); }
|
|
23
|
+
|
|
15
24
|
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; }
|
|
16
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
25
|
+
|
|
17
26
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
27
|
+
|
|
18
28
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
29
|
+
|
|
19
30
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
|
+
|
|
20
32
|
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); } }
|
|
33
|
+
|
|
21
34
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
35
|
+
|
|
22
36
|
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); }
|
|
23
|
-
|
|
37
|
+
|
|
38
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
|
+
|
|
24
40
|
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); }; }
|
|
41
|
+
|
|
25
42
|
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); }
|
|
43
|
+
|
|
26
44
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
|
+
|
|
27
46
|
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; } }
|
|
28
|
-
|
|
47
|
+
|
|
48
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
49
|
+
|
|
29
50
|
var vertexShader = "\nvarying vec2 vUv;\nvarying vec2 vColorUv;\nvarying vec2 vMaskUv;\nvoid main(){\n vUv = uv;\n vColorUv = vec2(uv.x / 2.0, uv.y);\n vMaskUv = vec2(0.5 + uv.x / 2.0, uv.y);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
|
|
51
|
+
|
|
30
52
|
var fragmentShaderTpl = function fragmentShaderTpl() {
|
|
31
53
|
return "\nuniform int enable;\nuniform sampler2D map;\nvarying vec2 vUv;\nvarying vec2 vColorUv;\nvarying vec2 vMaskUv;\n\nvec3 hsv2rgb(vec3 c) {\n const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n\nvec3 rgb2hsv(vec3 c) {\n const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + 0.001)), d / (q.x + 0.001), q.x);\n}\n\nvoid main(void) {\n vec3 color = texture2D(map, vUv).xyz;\n float amask = 1.0;\n\n float ref = color.r;\n if (ref < color.b) ref = color.b;\n amask = color.g - ref + 0.1;\n amask = smoothstep(0.1, 0.3, amask);\n amask = 1.0 - amask;\n\n vec3 target = rgb2hsv(vec3(0.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0));\n vec3 hsv = rgb2hsv(color);\n float distance = abs(hsv.x - target.x);\n if (distance < 0.15) {\n hsv.y = 0.0;\n }\n color = hsv2rgb(hsv);\n\n gl_FragColor = vec4(color.rgb, amask * float(enable));\n}\n";
|
|
32
54
|
};
|
|
55
|
+
|
|
33
56
|
var cacheInstance = {};
|
|
57
|
+
|
|
34
58
|
/**
|
|
35
59
|
* 视频经纪人MESH
|
|
36
60
|
*/
|
|
37
61
|
var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
38
62
|
_inherits(VideoAgentMesh, _THREE$Mesh);
|
|
63
|
+
|
|
39
64
|
var _super = _createSuper(VideoAgentMesh);
|
|
65
|
+
|
|
40
66
|
/**
|
|
41
67
|
*
|
|
42
68
|
* @param width
|
|
@@ -47,11 +73,15 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
47
73
|
*/
|
|
48
74
|
function VideoAgentMesh(width, height, widthSegments, heightSegments) {
|
|
49
75
|
var _this$options$videoIn, _this$options$videoIn2;
|
|
76
|
+
|
|
50
77
|
var _this;
|
|
78
|
+
|
|
51
79
|
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
52
80
|
preload: true
|
|
53
81
|
};
|
|
82
|
+
|
|
54
83
|
_classCallCheck(this, VideoAgentMesh);
|
|
84
|
+
|
|
55
85
|
if (!options.videoInstance) {
|
|
56
86
|
if (cacheInstance.videoInstance) {
|
|
57
87
|
options.videoInstance = cacheInstance.videoInstance;
|
|
@@ -67,6 +97,7 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
67
97
|
videoInstance.controls = false;
|
|
68
98
|
}
|
|
69
99
|
}
|
|
100
|
+
|
|
70
101
|
var geometry = new THREE.PlaneGeometry(width, height, widthSegments, heightSegments);
|
|
71
102
|
var videoTexture = new THREE.VideoTexture(options.videoInstance);
|
|
72
103
|
var material = new THREE.ShaderMaterial({
|
|
@@ -86,13 +117,14 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
86
117
|
_this.options = options;
|
|
87
118
|
_this.freeze = false;
|
|
88
119
|
_this.paused = true;
|
|
120
|
+
|
|
89
121
|
if (!options.audioInstance) {
|
|
90
122
|
if (cacheInstance.audioInstance) {
|
|
91
123
|
_this.audioInstance = cacheInstance.audioInstance;
|
|
92
124
|
} else {
|
|
93
125
|
var audioInstance = document.createElement('audio');
|
|
94
|
-
audioInstance.crossOrigin = '';
|
|
95
|
-
|
|
126
|
+
audioInstance.crossOrigin = ''; // videoInstance.muted = true
|
|
127
|
+
|
|
96
128
|
audioInstance.muted = false;
|
|
97
129
|
audioInstance.autoplay = false;
|
|
98
130
|
audioInstance.style.display = 'none';
|
|
@@ -103,47 +135,66 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
103
135
|
} else {
|
|
104
136
|
_this.audioInstance = options.audioInstance;
|
|
105
137
|
}
|
|
138
|
+
|
|
106
139
|
_this.audioLikeInstance = new _AudioLike["default"]();
|
|
107
140
|
(0, _mobx.makeObservable)(_assertThisInitialized(_this), {
|
|
108
141
|
paused: _mobx.observable
|
|
109
142
|
});
|
|
143
|
+
|
|
110
144
|
var updatePaused = function updatePaused(paused) {
|
|
111
145
|
return (0, _mobx.runInAction)(function () {
|
|
112
146
|
return _this.paused = paused;
|
|
113
147
|
});
|
|
114
148
|
};
|
|
149
|
+
|
|
115
150
|
var onPause = function onPause() {
|
|
116
151
|
return updatePaused(true);
|
|
117
152
|
};
|
|
153
|
+
|
|
118
154
|
var onPlay = function onPlay() {
|
|
119
155
|
return updatePaused(false);
|
|
120
156
|
};
|
|
157
|
+
|
|
121
158
|
_this.audioInstance.addEventListener('pause', onPause);
|
|
159
|
+
|
|
122
160
|
_this.audioInstance.addEventListener('play', onPlay);
|
|
161
|
+
|
|
123
162
|
(_this$options$videoIn = _this.options.videoInstance) === null || _this$options$videoIn === void 0 ? void 0 : _this$options$videoIn.addEventListener('pause', onPause);
|
|
124
163
|
(_this$options$videoIn2 = _this.options.videoInstance) === null || _this$options$videoIn2 === void 0 ? void 0 : _this$options$videoIn2.addEventListener('play', onPlay);
|
|
164
|
+
|
|
125
165
|
_this.audioLikeInstance.addEventListener('pause', onPause);
|
|
166
|
+
|
|
126
167
|
_this.audioLikeInstance.addEventListener('play', onPlay);
|
|
168
|
+
|
|
127
169
|
_this.$removeEventListener = function () {
|
|
128
170
|
var _this$options$videoIn3, _this$options$videoIn4;
|
|
171
|
+
|
|
129
172
|
_this.audioInstance.removeEventListener('pause', onPause);
|
|
173
|
+
|
|
130
174
|
_this.audioInstance.removeEventListener('play', onPlay);
|
|
175
|
+
|
|
131
176
|
(_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 ? void 0 : _this$options$videoIn3.removeEventListener('pause', onPause);
|
|
132
177
|
(_this$options$videoIn4 = _this.options.videoInstance) === null || _this$options$videoIn4 === void 0 ? void 0 : _this$options$videoIn4.removeEventListener('play', onPlay);
|
|
178
|
+
|
|
133
179
|
_this.audioLikeInstance.removeEventListener('pause', onPause);
|
|
180
|
+
|
|
134
181
|
_this.audioLikeInstance.removeEventListener('play', onPlay);
|
|
135
182
|
};
|
|
183
|
+
|
|
136
184
|
return _this;
|
|
137
185
|
}
|
|
186
|
+
|
|
138
187
|
_createClass(VideoAgentMesh, [{
|
|
139
188
|
key: "mediaInstance",
|
|
140
189
|
get: function get() {
|
|
141
190
|
if (!this.videoUrl) {
|
|
142
191
|
return this.audioLikeInstance;
|
|
143
192
|
}
|
|
193
|
+
|
|
144
194
|
if ((0, _getMediaInfo.getMediaType)(this.videoUrl) === 'audio') {
|
|
145
195
|
return this.audioInstance;
|
|
146
196
|
}
|
|
197
|
+
|
|
147
198
|
var uniforms = this.material.uniforms;
|
|
148
199
|
var videoInstance = uniforms.map.value.image;
|
|
149
200
|
return videoInstance;
|
|
@@ -151,10 +202,11 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
151
202
|
}, {
|
|
152
203
|
key: "update",
|
|
153
204
|
value: function () {
|
|
154
|
-
var _update = _asyncToGenerator( /*#__PURE__*/
|
|
205
|
+
var _update = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(videoUrl) {
|
|
155
206
|
var _this2 = this;
|
|
207
|
+
|
|
156
208
|
var uniforms, onStart;
|
|
157
|
-
return
|
|
209
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
158
210
|
while (1) {
|
|
159
211
|
switch (_context.prev = _context.next) {
|
|
160
212
|
case 0:
|
|
@@ -162,11 +214,11 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
162
214
|
_context.next = 2;
|
|
163
215
|
break;
|
|
164
216
|
}
|
|
217
|
+
|
|
165
218
|
return _context.abrupt("return");
|
|
166
|
-
case 2:
|
|
167
|
-
this.videoUrl = videoUrl;
|
|
168
219
|
|
|
169
|
-
|
|
220
|
+
case 2:
|
|
221
|
+
this.videoUrl = videoUrl; // // 兼容非视频场景
|
|
170
222
|
// if (this.mediaInstance instanceof HTMLAudioElement) {
|
|
171
223
|
// this.mediaInstance.style.display = 'none'
|
|
172
224
|
// } else if (this.mediaInstance instanceof HTMLVideoElement) {
|
|
@@ -176,37 +228,48 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
176
228
|
this.freeze = true;
|
|
177
229
|
_context.next = 6;
|
|
178
230
|
return this.mediaInstance.pause();
|
|
231
|
+
|
|
179
232
|
case 6:
|
|
180
233
|
uniforms = this.material.uniforms;
|
|
181
234
|
this.mediaInstance.muted = true;
|
|
235
|
+
|
|
182
236
|
if (!(this.options.preload || this.options.preload === undefined || (0, _getMediaInfo.getMediaType)(this.videoUrl) === 'video')) {
|
|
183
237
|
_context.next = 18;
|
|
184
238
|
break;
|
|
185
239
|
}
|
|
240
|
+
|
|
186
241
|
_context.t1 = URL;
|
|
187
242
|
_context.next = 12;
|
|
188
243
|
return _Preloader.Preloader.blob(this.videoUrl);
|
|
244
|
+
|
|
189
245
|
case 12:
|
|
190
246
|
_context.t2 = _context.sent;
|
|
191
247
|
_context.next = 15;
|
|
192
248
|
return _context.t1.createObjectURL.call(_context.t1, _context.t2);
|
|
249
|
+
|
|
193
250
|
case 15:
|
|
194
251
|
_context.t0 = _context.sent;
|
|
195
252
|
_context.next = 19;
|
|
196
253
|
break;
|
|
254
|
+
|
|
197
255
|
case 18:
|
|
198
256
|
_context.t0 = this.videoUrl;
|
|
257
|
+
|
|
199
258
|
case 19:
|
|
200
259
|
this.mediaInstance.src = _context.t0;
|
|
201
260
|
this.mediaInstance.setAttribute('data-src', this.videoUrl);
|
|
261
|
+
|
|
202
262
|
onStart = function onStart() {
|
|
203
263
|
if (_this2.mediaInstance.currentTime === 0) return;
|
|
204
264
|
_this2.freeze = false;
|
|
205
265
|
_this2.mediaInstance.muted = false;
|
|
206
266
|
uniforms.enable.value = (0, _getMediaInfo.getMediaType)(_this2.videoUrl) ? 1 : 0;
|
|
267
|
+
|
|
207
268
|
_this2.mediaInstance.removeEventListener('timeupdate', onStart, false);
|
|
208
269
|
};
|
|
270
|
+
|
|
209
271
|
this.mediaInstance.addEventListener('timeupdate', onStart, false);
|
|
272
|
+
|
|
210
273
|
case 23:
|
|
211
274
|
case "end":
|
|
212
275
|
return _context.stop();
|
|
@@ -214,21 +277,24 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
214
277
|
}
|
|
215
278
|
}, _callee, this);
|
|
216
279
|
}));
|
|
280
|
+
|
|
217
281
|
function update(_x) {
|
|
218
282
|
return _update.apply(this, arguments);
|
|
219
283
|
}
|
|
284
|
+
|
|
220
285
|
return update;
|
|
221
286
|
}()
|
|
222
287
|
}, {
|
|
223
288
|
key: "play",
|
|
224
289
|
value: function () {
|
|
225
|
-
var _play = _asyncToGenerator( /*#__PURE__*/
|
|
290
|
+
var _play = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
226
291
|
var _this3 = this;
|
|
292
|
+
|
|
227
293
|
var videoUrl,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return
|
|
294
|
+
currentTime,
|
|
295
|
+
duration,
|
|
296
|
+
_args3 = arguments;
|
|
297
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
232
298
|
while (1) {
|
|
233
299
|
switch (_context3.prev = _context3.next) {
|
|
234
300
|
case 0:
|
|
@@ -236,62 +302,78 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
236
302
|
currentTime = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
|
|
237
303
|
duration = _args3.length > 2 ? _args3[2] : undefined;
|
|
238
304
|
videoUrl = videoUrl || '';
|
|
305
|
+
|
|
239
306
|
if (!(duration && !videoUrl)) {
|
|
240
307
|
_context3.next = 10;
|
|
241
308
|
break;
|
|
242
309
|
}
|
|
310
|
+
|
|
243
311
|
if (this.currentTime) {
|
|
244
312
|
this.mediaInstance.currentTime = currentTime;
|
|
245
313
|
}
|
|
314
|
+
|
|
246
315
|
this.mediaInstance.duration = duration;
|
|
247
316
|
this.videoUrl = '';
|
|
248
317
|
this.mediaInstance.play();
|
|
249
318
|
return _context3.abrupt("return", true);
|
|
319
|
+
|
|
250
320
|
case 10:
|
|
251
321
|
if (videoUrl) {
|
|
252
322
|
_context3.next = 18;
|
|
253
323
|
break;
|
|
254
324
|
}
|
|
325
|
+
|
|
255
326
|
if (!this.videoUrl) {
|
|
256
327
|
_context3.next = 16;
|
|
257
328
|
break;
|
|
258
329
|
}
|
|
330
|
+
|
|
259
331
|
_context3.next = 14;
|
|
260
332
|
return this.mediaInstance.play();
|
|
333
|
+
|
|
261
334
|
case 14:
|
|
262
335
|
_context3.next = 17;
|
|
263
336
|
break;
|
|
337
|
+
|
|
264
338
|
case 16:
|
|
265
339
|
console.warn('警告:视频资源未初始化。');
|
|
340
|
+
|
|
266
341
|
case 17:
|
|
267
342
|
return _context3.abrupt("return", true);
|
|
343
|
+
|
|
268
344
|
case 18:
|
|
269
345
|
if (!(videoUrl === this.videoUrl)) {
|
|
270
346
|
_context3.next = 23;
|
|
271
347
|
break;
|
|
272
348
|
}
|
|
349
|
+
|
|
273
350
|
this.mediaInstance.currentTime = currentTime;
|
|
274
351
|
_context3.next = 22;
|
|
275
352
|
return this.mediaInstance.play();
|
|
353
|
+
|
|
276
354
|
case 22:
|
|
277
355
|
return _context3.abrupt("return", true);
|
|
356
|
+
|
|
278
357
|
case 23:
|
|
279
358
|
_context3.next = 25;
|
|
280
359
|
return this.update(videoUrl);
|
|
360
|
+
|
|
281
361
|
case 25:
|
|
282
362
|
this.mediaInstance.pause();
|
|
283
363
|
_context3.next = 28;
|
|
284
364
|
return new Promise(function (resolve) {
|
|
285
|
-
return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
286
|
-
return
|
|
365
|
+
return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
366
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
287
367
|
while (1) {
|
|
288
368
|
switch (_context2.prev = _context2.next) {
|
|
289
369
|
case 0:
|
|
290
370
|
_this3.mediaInstance.currentTime = currentTime;
|
|
291
371
|
_context2.next = 3;
|
|
292
372
|
return _this3.mediaInstance.play();
|
|
373
|
+
|
|
293
374
|
case 3:
|
|
294
375
|
resolve(true);
|
|
376
|
+
|
|
295
377
|
case 4:
|
|
296
378
|
case "end":
|
|
297
379
|
return _context2.stop();
|
|
@@ -300,8 +382,10 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
300
382
|
}, _callee2);
|
|
301
383
|
})), 20);
|
|
302
384
|
});
|
|
385
|
+
|
|
303
386
|
case 28:
|
|
304
387
|
return _context3.abrupt("return", _context3.sent);
|
|
388
|
+
|
|
305
389
|
case 29:
|
|
306
390
|
case "end":
|
|
307
391
|
return _context3.stop();
|
|
@@ -309,14 +393,17 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
309
393
|
}
|
|
310
394
|
}, _callee3, this);
|
|
311
395
|
}));
|
|
396
|
+
|
|
312
397
|
function play() {
|
|
313
398
|
return _play.apply(this, arguments);
|
|
314
399
|
}
|
|
400
|
+
|
|
315
401
|
return play;
|
|
316
402
|
}()
|
|
317
403
|
/**
|
|
318
404
|
* 秒转成毫秒,保障精准度
|
|
319
405
|
*/
|
|
406
|
+
|
|
320
407
|
}, {
|
|
321
408
|
key: "currentTime",
|
|
322
409
|
get: function get() {
|
|
@@ -327,16 +414,20 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
327
414
|
value: function dispose() {
|
|
328
415
|
// 销毁事件监听
|
|
329
416
|
this.$removeEventListener();
|
|
417
|
+
|
|
330
418
|
if (cacheInstance.audioInstance) {
|
|
331
419
|
document.body.removeChild(cacheInstance.audioInstance);
|
|
332
420
|
cacheInstance.audioInstance = undefined;
|
|
333
421
|
}
|
|
422
|
+
|
|
334
423
|
if (cacheInstance.videoInstance) {
|
|
335
424
|
document.body.removeChild(cacheInstance.videoInstance);
|
|
336
425
|
cacheInstance.videoInstance = undefined;
|
|
337
426
|
}
|
|
338
427
|
}
|
|
339
428
|
}]);
|
|
429
|
+
|
|
340
430
|
return VideoAgentMesh;
|
|
341
431
|
}(THREE.Mesh);
|
|
432
|
+
|
|
342
433
|
exports.VideoAgentMesh = VideoAgentMesh;
|
|
@@ -1,45 +1,65 @@
|
|
|
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.VideoAgentScene = void 0;
|
|
9
|
+
|
|
8
10
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
+
|
|
9
12
|
var _addResizeListener = require("../../../shared-utils/addResizeListener");
|
|
13
|
+
|
|
10
14
|
var _VideoAgentMesh = require("./VideoAgentMesh");
|
|
15
|
+
|
|
11
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
|
+
|
|
12
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
|
+
|
|
13
20
|
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); } }
|
|
21
|
+
|
|
14
22
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
23
|
+
|
|
15
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
|
+
|
|
16
26
|
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; }
|
|
27
|
+
|
|
17
28
|
var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(container, options) {
|
|
18
29
|
var _this = this;
|
|
30
|
+
|
|
19
31
|
_classCallCheck(this, VideoAgentScene);
|
|
32
|
+
|
|
20
33
|
_defineProperty(this, "scene", new THREE.Scene());
|
|
34
|
+
|
|
21
35
|
_defineProperty(this, "camera", new THREE.OrthographicCamera(-240, 240, 135, -135));
|
|
36
|
+
|
|
22
37
|
_defineProperty(this, "renderer", new THREE.WebGLRenderer({
|
|
23
38
|
alpha: true
|
|
24
39
|
}));
|
|
40
|
+
|
|
25
41
|
_defineProperty(this, "disposers", []);
|
|
42
|
+
|
|
26
43
|
_defineProperty(this, "run", function () {
|
|
27
44
|
// 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
|
|
28
45
|
if (!(_this.videoAgentMesh.paused || _this.videoAgentMesh.freeze) && _this.videoAgentMesh.currentTime > 1000) {
|
|
29
46
|
_this.renderer.render(_this.scene, _this.camera);
|
|
30
47
|
}
|
|
48
|
+
|
|
31
49
|
requestAnimationFrame(_this.run);
|
|
32
50
|
});
|
|
51
|
+
|
|
33
52
|
_defineProperty(this, "dispose", function () {
|
|
34
53
|
var _this$videoAgentMesh;
|
|
54
|
+
|
|
35
55
|
(_this$videoAgentMesh = _this.videoAgentMesh) === null || _this$videoAgentMesh === void 0 ? void 0 : _this$videoAgentMesh.dispose();
|
|
56
|
+
|
|
36
57
|
_this.disposers.forEach(function (disposer) {
|
|
37
58
|
return disposer === null || disposer === void 0 ? void 0 : disposer();
|
|
38
59
|
});
|
|
39
60
|
});
|
|
40
|
-
this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options);
|
|
41
61
|
|
|
42
|
-
// const needRender = getMediaType(this.videoAgentMesh.videoUrl) === 'video'
|
|
62
|
+
this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options); // const needRender = getMediaType(this.videoAgentMesh.videoUrl) === 'video'
|
|
43
63
|
|
|
44
64
|
if (container) {
|
|
45
65
|
this.camera.position.set(0, 0, 10);
|
|
@@ -48,6 +68,7 @@ var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(contain
|
|
|
48
68
|
domElement.classList.add('VideoAgent-canvas');
|
|
49
69
|
var dispose = (0, _addResizeListener.addResizeListener)(container, function (width, height) {
|
|
50
70
|
_this.renderer.setSize(width * window.devicePixelRatio, height * window.devicePixelRatio);
|
|
71
|
+
|
|
51
72
|
domElement.style.width = "".concat(width, "px");
|
|
52
73
|
domElement.style.height = "".concat(height, "px");
|
|
53
74
|
});
|
|
@@ -57,4 +78,5 @@ var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(contain
|
|
|
57
78
|
this.run();
|
|
58
79
|
}
|
|
59
80
|
});
|
|
81
|
+
|
|
60
82
|
exports.VideoAgentScene = VideoAgentScene;
|
|
@@ -1,40 +1,55 @@
|
|
|
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.VideoAgent = VideoAgent;
|
|
9
|
+
|
|
8
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
9
12
|
var _hooks = require("../../hooks");
|
|
13
|
+
|
|
10
14
|
var _VideoAgentScene = require("./VideoAgentScene");
|
|
15
|
+
|
|
11
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
+
|
|
12
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
13
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
|
+
|
|
14
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
|
+
|
|
15
24
|
function VideoAgent(props) {
|
|
16
25
|
var _controller$avatar2;
|
|
26
|
+
|
|
17
27
|
var ref = React.useRef(null);
|
|
18
28
|
var controller = (0, _hooks.useController)();
|
|
19
29
|
var showAvatar = React.useMemo(function () {
|
|
20
30
|
var _controller$avatar;
|
|
31
|
+
|
|
21
32
|
return ((_controller$avatar = controller.avatar) === null || _controller$avatar === void 0 ? void 0 : _controller$avatar.url) && controller.avatar.force === true;
|
|
22
33
|
}, [controller.avatar]);
|
|
23
34
|
var showVideoAgent = React.useMemo(function () {
|
|
24
35
|
var _controller$videoAgen;
|
|
36
|
+
|
|
25
37
|
if (showAvatar) return false;
|
|
26
38
|
return ((_controller$videoAgen = controller.videoAgentScene) === null || _controller$videoAgen === void 0 ? void 0 : _controller$videoAgen.videoAgentMesh.mediaInstance) instanceof HTMLVideoElement;
|
|
27
39
|
}, [controller.videoAgentScene, showAvatar]);
|
|
28
40
|
React.useEffect(function () {
|
|
29
41
|
if (!ref.current) throw new Error('React 渲染异常,请稍后重试 ...');
|
|
42
|
+
|
|
30
43
|
if (controller.videoAgentScene) {
|
|
31
44
|
console.warn('VideoAgentScene" 重复初始化,已被过滤');
|
|
32
45
|
return;
|
|
33
46
|
}
|
|
47
|
+
|
|
34
48
|
var videoAgentScene = new _VideoAgentScene.VideoAgentScene(ref.current, props.options);
|
|
35
49
|
controller.videoAgentScene = videoAgentScene;
|
|
36
50
|
return function () {
|
|
37
51
|
var _controller$videoAgen2;
|
|
52
|
+
|
|
38
53
|
controller.dispose();
|
|
39
54
|
(_controller$videoAgen2 = controller.videoAgentScene) === null || _controller$videoAgen2 === void 0 ? void 0 : _controller$videoAgen2.dispose();
|
|
40
55
|
};
|
|
@@ -51,6 +66,7 @@ function VideoAgent(props) {
|
|
|
51
66
|
src: (_controller$avatar2 = controller.avatar) === null || _controller$avatar2 === void 0 ? void 0 : _controller$avatar2.url,
|
|
52
67
|
onClick: function onClick() {
|
|
53
68
|
var _props$onClick;
|
|
69
|
+
|
|
54
70
|
return (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props);
|
|
55
71
|
}
|
|
56
72
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
@@ -68,6 +84,7 @@ function VideoAgent(props) {
|
|
|
68
84
|
className: "VideoAgent-play",
|
|
69
85
|
onClick: function onClick() {
|
|
70
86
|
var _props$onClick2;
|
|
87
|
+
|
|
71
88
|
return (_props$onClick2 = props.onClick) === null || _props$onClick2 === void 0 ? void 0 : _props$onClick2.call(props);
|
|
72
89
|
}
|
|
73
90
|
}))))));
|