@realsee/vreo 1.2.1-alpha.1 → 1.2.1-alpha.2
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 +6 -11
- package/lib/PlayController/index.js +15 -80
- package/lib/Player/App.js +0 -26
- package/lib/Player/Controller.js +23 -100
- package/lib/Player/custom/SpatialScenePanel/index.js +42 -68
- package/lib/Player/hooks.js +0 -10
- package/lib/Player/index.js +24 -86
- package/lib/Player/modules/Drawer/index.js +0 -17
- package/lib/Player/modules/PopUp/index.js +0 -10
- package/lib/Player/modules/ResizeObserver/index.js +0 -8
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +17 -108
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -24
- package/lib/Player/modules/VideoAgent/index.js +0 -17
- package/lib/Player/modules/Wave/index.js +7 -32
- package/lib/Player/modules/keyframes/BgMusic/index.js +7 -23
- package/lib/Player/modules/keyframes/CameraMovement/index.js +3 -27
- package/lib/Player/modules/keyframes/InfoPanel/index.js +8 -29
- package/lib/Player/modules/keyframes/ModelVideo/index.js +3 -29
- package/lib/Player/modules/keyframes/PanoEffect/index.js +15 -43
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +0 -7
- package/lib/Player/modules/keyframes/PanoTag/index.js +5 -22
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +22 -47
- package/lib/Player/modules/keyframes/Prompter/index.js +10 -32
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +18 -25
- package/lib/Player/modules/keyframes/VideoEffect/index.js +12 -47
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +0 -2
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +0 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +0 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +19 -60
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +2 -5
- package/lib/fivePlugins/CameraMovementPlugin/index.js +28 -76
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -4
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +11 -60
- package/lib/index.js +0 -1
- package/lib/react/index.js +7 -34
- package/lib/shared-utils/Audio.js +15 -69
- package/lib/shared-utils/AudioLike.js +5 -39
- package/lib/shared-utils/Preloader.js +0 -7
- package/lib/shared-utils/addResizeListener.js +0 -5
- package/lib/shared-utils/animationFrame/BetterTween.js +2 -38
- package/lib/shared-utils/animationFrame/index.js +2 -10
- package/lib/shared-utils/animationFrame/tween.js +2 -11
- package/lib/shared-utils/createTransMatrix.js +2 -17
- package/lib/shared-utils/getFileExpandedName.js +0 -1
- package/lib/shared-utils/getMediaInfo.js +0 -9
- package/lib/shared-utils/setElementDataset.js +0 -2
- package/lib/typings/VreoUnit.js +0 -15
- package/package.json +2 -2
|
@@ -1,68 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.VideoAgentMesh = void 0;
|
|
9
|
-
|
|
10
8
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
-
|
|
12
9
|
var _Preloader = require("../../../shared-utils/Preloader");
|
|
13
|
-
|
|
14
10
|
var _mobx = require("mobx");
|
|
15
|
-
|
|
16
11
|
var _AudioLike = _interopRequireDefault(require("../../../shared-utils/AudioLike"));
|
|
17
|
-
|
|
18
12
|
var _getMediaInfo = require("../../../shared-utils/getMediaInfo");
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
-
|
|
22
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
-
|
|
24
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
-
|
|
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; }
|
|
26
17
|
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
|
-
|
|
28
18
|
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
|
-
|
|
30
19
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
|
-
|
|
32
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); } }
|
|
33
|
-
|
|
34
21
|
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
|
-
|
|
36
22
|
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); }
|
|
37
|
-
|
|
38
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
|
-
|
|
23
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
40
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); }; }
|
|
41
|
-
|
|
42
25
|
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
|
-
|
|
44
26
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
|
-
|
|
46
27
|
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; } }
|
|
47
|
-
|
|
48
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
49
|
-
|
|
28
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
50
29
|
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
|
-
|
|
52
30
|
var fragmentShaderTpl = function fragmentShaderTpl() {
|
|
53
31
|
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";
|
|
54
32
|
};
|
|
55
|
-
|
|
56
33
|
var cacheInstance = {};
|
|
57
|
-
|
|
58
34
|
/**
|
|
59
35
|
* 视频经纪人MESH
|
|
60
36
|
*/
|
|
61
37
|
var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
62
38
|
_inherits(VideoAgentMesh, _THREE$Mesh);
|
|
63
|
-
|
|
64
39
|
var _super = _createSuper(VideoAgentMesh);
|
|
65
|
-
|
|
66
40
|
/**
|
|
67
41
|
*
|
|
68
42
|
* @param width
|
|
@@ -73,15 +47,11 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
73
47
|
*/
|
|
74
48
|
function VideoAgentMesh(width, height, widthSegments, heightSegments) {
|
|
75
49
|
var _this$options$videoIn, _this$options$videoIn2;
|
|
76
|
-
|
|
77
50
|
var _this;
|
|
78
|
-
|
|
79
51
|
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
80
52
|
preload: true
|
|
81
53
|
};
|
|
82
|
-
|
|
83
54
|
_classCallCheck(this, VideoAgentMesh);
|
|
84
|
-
|
|
85
55
|
if (!options.videoInstance) {
|
|
86
56
|
if (cacheInstance.videoInstance) {
|
|
87
57
|
options.videoInstance = cacheInstance.videoInstance;
|
|
@@ -97,7 +67,6 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
97
67
|
videoInstance.controls = false;
|
|
98
68
|
}
|
|
99
69
|
}
|
|
100
|
-
|
|
101
70
|
var geometry = new THREE.PlaneGeometry(width, height, widthSegments, heightSegments);
|
|
102
71
|
var videoTexture = new THREE.VideoTexture(options.videoInstance);
|
|
103
72
|
var material = new THREE.ShaderMaterial({
|
|
@@ -117,14 +86,13 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
117
86
|
_this.options = options;
|
|
118
87
|
_this.freeze = false;
|
|
119
88
|
_this.paused = true;
|
|
120
|
-
|
|
121
89
|
if (!options.audioInstance) {
|
|
122
90
|
if (cacheInstance.audioInstance) {
|
|
123
91
|
_this.audioInstance = cacheInstance.audioInstance;
|
|
124
92
|
} else {
|
|
125
93
|
var audioInstance = document.createElement('audio');
|
|
126
|
-
audioInstance.crossOrigin = '';
|
|
127
|
-
|
|
94
|
+
audioInstance.crossOrigin = '';
|
|
95
|
+
// videoInstance.muted = true
|
|
128
96
|
audioInstance.muted = false;
|
|
129
97
|
audioInstance.autoplay = false;
|
|
130
98
|
audioInstance.style.display = 'none';
|
|
@@ -135,66 +103,47 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
135
103
|
} else {
|
|
136
104
|
_this.audioInstance = options.audioInstance;
|
|
137
105
|
}
|
|
138
|
-
|
|
139
106
|
_this.audioLikeInstance = new _AudioLike["default"]();
|
|
140
107
|
(0, _mobx.makeObservable)(_assertThisInitialized(_this), {
|
|
141
108
|
paused: _mobx.observable
|
|
142
109
|
});
|
|
143
|
-
|
|
144
110
|
var updatePaused = function updatePaused(paused) {
|
|
145
111
|
return (0, _mobx.runInAction)(function () {
|
|
146
112
|
return _this.paused = paused;
|
|
147
113
|
});
|
|
148
114
|
};
|
|
149
|
-
|
|
150
115
|
var onPause = function onPause() {
|
|
151
116
|
return updatePaused(true);
|
|
152
117
|
};
|
|
153
|
-
|
|
154
118
|
var onPlay = function onPlay() {
|
|
155
119
|
return updatePaused(false);
|
|
156
120
|
};
|
|
157
|
-
|
|
158
121
|
_this.audioInstance.addEventListener('pause', onPause);
|
|
159
|
-
|
|
160
122
|
_this.audioInstance.addEventListener('play', onPlay);
|
|
161
|
-
|
|
162
123
|
(_this$options$videoIn = _this.options.videoInstance) === null || _this$options$videoIn === void 0 ? void 0 : _this$options$videoIn.addEventListener('pause', onPause);
|
|
163
124
|
(_this$options$videoIn2 = _this.options.videoInstance) === null || _this$options$videoIn2 === void 0 ? void 0 : _this$options$videoIn2.addEventListener('play', onPlay);
|
|
164
|
-
|
|
165
125
|
_this.audioLikeInstance.addEventListener('pause', onPause);
|
|
166
|
-
|
|
167
126
|
_this.audioLikeInstance.addEventListener('play', onPlay);
|
|
168
|
-
|
|
169
127
|
_this.$removeEventListener = function () {
|
|
170
128
|
var _this$options$videoIn3, _this$options$videoIn4;
|
|
171
|
-
|
|
172
129
|
_this.audioInstance.removeEventListener('pause', onPause);
|
|
173
|
-
|
|
174
130
|
_this.audioInstance.removeEventListener('play', onPlay);
|
|
175
|
-
|
|
176
131
|
(_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 ? void 0 : _this$options$videoIn3.removeEventListener('pause', onPause);
|
|
177
132
|
(_this$options$videoIn4 = _this.options.videoInstance) === null || _this$options$videoIn4 === void 0 ? void 0 : _this$options$videoIn4.removeEventListener('play', onPlay);
|
|
178
|
-
|
|
179
133
|
_this.audioLikeInstance.removeEventListener('pause', onPause);
|
|
180
|
-
|
|
181
134
|
_this.audioLikeInstance.removeEventListener('play', onPlay);
|
|
182
135
|
};
|
|
183
|
-
|
|
184
136
|
return _this;
|
|
185
137
|
}
|
|
186
|
-
|
|
187
138
|
_createClass(VideoAgentMesh, [{
|
|
188
139
|
key: "mediaInstance",
|
|
189
140
|
get: function get() {
|
|
190
141
|
if (!this.videoUrl) {
|
|
191
142
|
return this.audioLikeInstance;
|
|
192
143
|
}
|
|
193
|
-
|
|
194
144
|
if ((0, _getMediaInfo.getMediaType)(this.videoUrl) === 'audio') {
|
|
195
145
|
return this.audioInstance;
|
|
196
146
|
}
|
|
197
|
-
|
|
198
147
|
var uniforms = this.material.uniforms;
|
|
199
148
|
var videoInstance = uniforms.map.value.image;
|
|
200
149
|
return videoInstance;
|
|
@@ -202,11 +151,10 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
202
151
|
}, {
|
|
203
152
|
key: "update",
|
|
204
153
|
value: function () {
|
|
205
|
-
var _update = _asyncToGenerator( /*#__PURE__*/
|
|
154
|
+
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(videoUrl) {
|
|
206
155
|
var _this2 = this;
|
|
207
|
-
|
|
208
156
|
var uniforms, onStart;
|
|
209
|
-
return
|
|
157
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
210
158
|
while (1) {
|
|
211
159
|
switch (_context.prev = _context.next) {
|
|
212
160
|
case 0:
|
|
@@ -214,11 +162,11 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
214
162
|
_context.next = 2;
|
|
215
163
|
break;
|
|
216
164
|
}
|
|
217
|
-
|
|
218
165
|
return _context.abrupt("return");
|
|
219
|
-
|
|
220
166
|
case 2:
|
|
221
|
-
this.videoUrl = videoUrl;
|
|
167
|
+
this.videoUrl = videoUrl;
|
|
168
|
+
|
|
169
|
+
// // 兼容非视频场景
|
|
222
170
|
// if (this.mediaInstance instanceof HTMLAudioElement) {
|
|
223
171
|
// this.mediaInstance.style.display = 'none'
|
|
224
172
|
// } else if (this.mediaInstance instanceof HTMLVideoElement) {
|
|
@@ -228,48 +176,37 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
228
176
|
this.freeze = true;
|
|
229
177
|
_context.next = 6;
|
|
230
178
|
return this.mediaInstance.pause();
|
|
231
|
-
|
|
232
179
|
case 6:
|
|
233
180
|
uniforms = this.material.uniforms;
|
|
234
181
|
this.mediaInstance.muted = true;
|
|
235
|
-
|
|
236
182
|
if (!(this.options.preload || this.options.preload === undefined || (0, _getMediaInfo.getMediaType)(this.videoUrl) === 'video')) {
|
|
237
183
|
_context.next = 18;
|
|
238
184
|
break;
|
|
239
185
|
}
|
|
240
|
-
|
|
241
186
|
_context.t1 = URL;
|
|
242
187
|
_context.next = 12;
|
|
243
188
|
return _Preloader.Preloader.blob(this.videoUrl);
|
|
244
|
-
|
|
245
189
|
case 12:
|
|
246
190
|
_context.t2 = _context.sent;
|
|
247
191
|
_context.next = 15;
|
|
248
192
|
return _context.t1.createObjectURL.call(_context.t1, _context.t2);
|
|
249
|
-
|
|
250
193
|
case 15:
|
|
251
194
|
_context.t0 = _context.sent;
|
|
252
195
|
_context.next = 19;
|
|
253
196
|
break;
|
|
254
|
-
|
|
255
197
|
case 18:
|
|
256
198
|
_context.t0 = this.videoUrl;
|
|
257
|
-
|
|
258
199
|
case 19:
|
|
259
200
|
this.mediaInstance.src = _context.t0;
|
|
260
201
|
this.mediaInstance.setAttribute('data-src', this.videoUrl);
|
|
261
|
-
|
|
262
202
|
onStart = function onStart() {
|
|
263
203
|
if (_this2.mediaInstance.currentTime === 0) return;
|
|
264
204
|
_this2.freeze = false;
|
|
265
205
|
_this2.mediaInstance.muted = false;
|
|
266
206
|
uniforms.enable.value = (0, _getMediaInfo.getMediaType)(_this2.videoUrl) ? 1 : 0;
|
|
267
|
-
|
|
268
207
|
_this2.mediaInstance.removeEventListener('timeupdate', onStart, false);
|
|
269
208
|
};
|
|
270
|
-
|
|
271
209
|
this.mediaInstance.addEventListener('timeupdate', onStart, false);
|
|
272
|
-
|
|
273
210
|
case 23:
|
|
274
211
|
case "end":
|
|
275
212
|
return _context.stop();
|
|
@@ -277,24 +214,21 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
277
214
|
}
|
|
278
215
|
}, _callee, this);
|
|
279
216
|
}));
|
|
280
|
-
|
|
281
217
|
function update(_x) {
|
|
282
218
|
return _update.apply(this, arguments);
|
|
283
219
|
}
|
|
284
|
-
|
|
285
220
|
return update;
|
|
286
221
|
}()
|
|
287
222
|
}, {
|
|
288
223
|
key: "play",
|
|
289
224
|
value: function () {
|
|
290
|
-
var _play = _asyncToGenerator( /*#__PURE__*/
|
|
225
|
+
var _play = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
291
226
|
var _this3 = this;
|
|
292
|
-
|
|
293
227
|
var videoUrl,
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return
|
|
228
|
+
currentTime,
|
|
229
|
+
duration,
|
|
230
|
+
_args3 = arguments;
|
|
231
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
298
232
|
while (1) {
|
|
299
233
|
switch (_context3.prev = _context3.next) {
|
|
300
234
|
case 0:
|
|
@@ -302,78 +236,62 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
302
236
|
currentTime = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
|
|
303
237
|
duration = _args3.length > 2 ? _args3[2] : undefined;
|
|
304
238
|
videoUrl = videoUrl || '';
|
|
305
|
-
|
|
306
239
|
if (!(duration && !videoUrl)) {
|
|
307
240
|
_context3.next = 10;
|
|
308
241
|
break;
|
|
309
242
|
}
|
|
310
|
-
|
|
311
243
|
if (this.currentTime) {
|
|
312
244
|
this.mediaInstance.currentTime = currentTime;
|
|
313
245
|
}
|
|
314
|
-
|
|
315
246
|
this.mediaInstance.duration = duration;
|
|
316
247
|
this.videoUrl = '';
|
|
317
248
|
this.mediaInstance.play();
|
|
318
249
|
return _context3.abrupt("return", true);
|
|
319
|
-
|
|
320
250
|
case 10:
|
|
321
251
|
if (videoUrl) {
|
|
322
252
|
_context3.next = 18;
|
|
323
253
|
break;
|
|
324
254
|
}
|
|
325
|
-
|
|
326
255
|
if (!this.videoUrl) {
|
|
327
256
|
_context3.next = 16;
|
|
328
257
|
break;
|
|
329
258
|
}
|
|
330
|
-
|
|
331
259
|
_context3.next = 14;
|
|
332
260
|
return this.mediaInstance.play();
|
|
333
|
-
|
|
334
261
|
case 14:
|
|
335
262
|
_context3.next = 17;
|
|
336
263
|
break;
|
|
337
|
-
|
|
338
264
|
case 16:
|
|
339
265
|
console.warn('警告:视频资源未初始化。');
|
|
340
|
-
|
|
341
266
|
case 17:
|
|
342
267
|
return _context3.abrupt("return", true);
|
|
343
|
-
|
|
344
268
|
case 18:
|
|
345
269
|
if (!(videoUrl === this.videoUrl)) {
|
|
346
270
|
_context3.next = 23;
|
|
347
271
|
break;
|
|
348
272
|
}
|
|
349
|
-
|
|
350
273
|
this.mediaInstance.currentTime = currentTime;
|
|
351
274
|
_context3.next = 22;
|
|
352
275
|
return this.mediaInstance.play();
|
|
353
|
-
|
|
354
276
|
case 22:
|
|
355
277
|
return _context3.abrupt("return", true);
|
|
356
|
-
|
|
357
278
|
case 23:
|
|
358
279
|
_context3.next = 25;
|
|
359
280
|
return this.update(videoUrl);
|
|
360
|
-
|
|
361
281
|
case 25:
|
|
362
282
|
this.mediaInstance.pause();
|
|
363
283
|
_context3.next = 28;
|
|
364
284
|
return new Promise(function (resolve) {
|
|
365
|
-
return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
366
|
-
return
|
|
285
|
+
return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
286
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
367
287
|
while (1) {
|
|
368
288
|
switch (_context2.prev = _context2.next) {
|
|
369
289
|
case 0:
|
|
370
290
|
_this3.mediaInstance.currentTime = currentTime;
|
|
371
291
|
_context2.next = 3;
|
|
372
292
|
return _this3.mediaInstance.play();
|
|
373
|
-
|
|
374
293
|
case 3:
|
|
375
294
|
resolve(true);
|
|
376
|
-
|
|
377
295
|
case 4:
|
|
378
296
|
case "end":
|
|
379
297
|
return _context2.stop();
|
|
@@ -382,10 +300,8 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
382
300
|
}, _callee2);
|
|
383
301
|
})), 20);
|
|
384
302
|
});
|
|
385
|
-
|
|
386
303
|
case 28:
|
|
387
304
|
return _context3.abrupt("return", _context3.sent);
|
|
388
|
-
|
|
389
305
|
case 29:
|
|
390
306
|
case "end":
|
|
391
307
|
return _context3.stop();
|
|
@@ -393,17 +309,14 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
393
309
|
}
|
|
394
310
|
}, _callee3, this);
|
|
395
311
|
}));
|
|
396
|
-
|
|
397
312
|
function play() {
|
|
398
313
|
return _play.apply(this, arguments);
|
|
399
314
|
}
|
|
400
|
-
|
|
401
315
|
return play;
|
|
402
316
|
}()
|
|
403
317
|
/**
|
|
404
318
|
* 秒转成毫秒,保障精准度
|
|
405
319
|
*/
|
|
406
|
-
|
|
407
320
|
}, {
|
|
408
321
|
key: "currentTime",
|
|
409
322
|
get: function get() {
|
|
@@ -414,20 +327,16 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
414
327
|
value: function dispose() {
|
|
415
328
|
// 销毁事件监听
|
|
416
329
|
this.$removeEventListener();
|
|
417
|
-
|
|
418
330
|
if (cacheInstance.audioInstance) {
|
|
419
331
|
document.body.removeChild(cacheInstance.audioInstance);
|
|
420
332
|
cacheInstance.audioInstance = undefined;
|
|
421
333
|
}
|
|
422
|
-
|
|
423
334
|
if (cacheInstance.videoInstance) {
|
|
424
335
|
document.body.removeChild(cacheInstance.videoInstance);
|
|
425
336
|
cacheInstance.videoInstance = undefined;
|
|
426
337
|
}
|
|
427
338
|
}
|
|
428
339
|
}]);
|
|
429
|
-
|
|
430
340
|
return VideoAgentMesh;
|
|
431
341
|
}(THREE.Mesh);
|
|
432
|
-
|
|
433
342
|
exports.VideoAgentMesh = VideoAgentMesh;
|
|
@@ -1,65 +1,45 @@
|
|
|
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
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.VideoAgentScene = void 0;
|
|
9
|
-
|
|
10
8
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
-
|
|
12
9
|
var _addResizeListener = require("../../../shared-utils/addResizeListener");
|
|
13
|
-
|
|
14
10
|
var _VideoAgentMesh = require("./VideoAgentMesh");
|
|
15
|
-
|
|
16
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
13
|
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
|
-
|
|
22
14
|
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
|
-
|
|
24
15
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
|
-
|
|
26
16
|
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
|
-
|
|
28
17
|
var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(container, options) {
|
|
29
18
|
var _this = this;
|
|
30
|
-
|
|
31
19
|
_classCallCheck(this, VideoAgentScene);
|
|
32
|
-
|
|
33
20
|
_defineProperty(this, "scene", new THREE.Scene());
|
|
34
|
-
|
|
35
21
|
_defineProperty(this, "camera", new THREE.OrthographicCamera(-240, 240, 135, -135));
|
|
36
|
-
|
|
37
22
|
_defineProperty(this, "renderer", new THREE.WebGLRenderer({
|
|
38
23
|
alpha: true
|
|
39
24
|
}));
|
|
40
|
-
|
|
41
25
|
_defineProperty(this, "disposers", []);
|
|
42
|
-
|
|
43
26
|
_defineProperty(this, "run", function () {
|
|
44
27
|
// 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
|
|
45
28
|
if (!(_this.videoAgentMesh.paused || _this.videoAgentMesh.freeze) && _this.videoAgentMesh.currentTime > 1000) {
|
|
46
29
|
_this.renderer.render(_this.scene, _this.camera);
|
|
47
30
|
}
|
|
48
|
-
|
|
49
31
|
requestAnimationFrame(_this.run);
|
|
50
32
|
});
|
|
51
|
-
|
|
52
33
|
_defineProperty(this, "dispose", function () {
|
|
53
34
|
var _this$videoAgentMesh;
|
|
54
|
-
|
|
55
35
|
(_this$videoAgentMesh = _this.videoAgentMesh) === null || _this$videoAgentMesh === void 0 ? void 0 : _this$videoAgentMesh.dispose();
|
|
56
|
-
|
|
57
36
|
_this.disposers.forEach(function (disposer) {
|
|
58
37
|
return disposer === null || disposer === void 0 ? void 0 : disposer();
|
|
59
38
|
});
|
|
60
39
|
});
|
|
40
|
+
this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options);
|
|
61
41
|
|
|
62
|
-
|
|
42
|
+
// const needRender = getMediaType(this.videoAgentMesh.videoUrl) === 'video'
|
|
63
43
|
|
|
64
44
|
if (container) {
|
|
65
45
|
this.camera.position.set(0, 0, 10);
|
|
@@ -68,7 +48,6 @@ var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(contain
|
|
|
68
48
|
domElement.classList.add('VideoAgent-canvas');
|
|
69
49
|
var dispose = (0, _addResizeListener.addResizeListener)(container, function (width, height) {
|
|
70
50
|
_this.renderer.setSize(width * window.devicePixelRatio, height * window.devicePixelRatio);
|
|
71
|
-
|
|
72
51
|
domElement.style.width = "".concat(width, "px");
|
|
73
52
|
domElement.style.height = "".concat(height, "px");
|
|
74
53
|
});
|
|
@@ -78,5 +57,4 @@ var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(contain
|
|
|
78
57
|
this.run();
|
|
79
58
|
}
|
|
80
59
|
});
|
|
81
|
-
|
|
82
60
|
exports.VideoAgentScene = VideoAgentScene;
|
|
@@ -1,55 +1,40 @@
|
|
|
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
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.VideoAgent = VideoAgent;
|
|
9
|
-
|
|
10
8
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _hooks = require("../../hooks");
|
|
13
|
-
|
|
14
10
|
var _VideoAgentScene = require("./VideoAgentScene");
|
|
15
|
-
|
|
16
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
13
|
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
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
15
|
function VideoAgent(props) {
|
|
25
16
|
var _controller$avatar2;
|
|
26
|
-
|
|
27
17
|
var ref = React.useRef(null);
|
|
28
18
|
var controller = (0, _hooks.useController)();
|
|
29
19
|
var showAvatar = React.useMemo(function () {
|
|
30
20
|
var _controller$avatar;
|
|
31
|
-
|
|
32
21
|
return ((_controller$avatar = controller.avatar) === null || _controller$avatar === void 0 ? void 0 : _controller$avatar.url) && controller.avatar.force === true;
|
|
33
22
|
}, [controller.avatar]);
|
|
34
23
|
var showVideoAgent = React.useMemo(function () {
|
|
35
24
|
var _controller$videoAgen;
|
|
36
|
-
|
|
37
25
|
if (showAvatar) return false;
|
|
38
26
|
return ((_controller$videoAgen = controller.videoAgentScene) === null || _controller$videoAgen === void 0 ? void 0 : _controller$videoAgen.videoAgentMesh.mediaInstance) instanceof HTMLVideoElement;
|
|
39
27
|
}, [controller.videoAgentScene, showAvatar]);
|
|
40
28
|
React.useEffect(function () {
|
|
41
29
|
if (!ref.current) throw new Error('React 渲染异常,请稍后重试 ...');
|
|
42
|
-
|
|
43
30
|
if (controller.videoAgentScene) {
|
|
44
31
|
console.warn('VideoAgentScene" 重复初始化,已被过滤');
|
|
45
32
|
return;
|
|
46
33
|
}
|
|
47
|
-
|
|
48
34
|
var videoAgentScene = new _VideoAgentScene.VideoAgentScene(ref.current, props.options);
|
|
49
35
|
controller.videoAgentScene = videoAgentScene;
|
|
50
36
|
return function () {
|
|
51
37
|
var _controller$videoAgen2;
|
|
52
|
-
|
|
53
38
|
controller.dispose();
|
|
54
39
|
(_controller$videoAgen2 = controller.videoAgentScene) === null || _controller$videoAgen2 === void 0 ? void 0 : _controller$videoAgen2.dispose();
|
|
55
40
|
};
|
|
@@ -66,7 +51,6 @@ function VideoAgent(props) {
|
|
|
66
51
|
src: (_controller$avatar2 = controller.avatar) === null || _controller$avatar2 === void 0 ? void 0 : _controller$avatar2.url,
|
|
67
52
|
onClick: function onClick() {
|
|
68
53
|
var _props$onClick;
|
|
69
|
-
|
|
70
54
|
return (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props);
|
|
71
55
|
}
|
|
72
56
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
@@ -84,7 +68,6 @@ function VideoAgent(props) {
|
|
|
84
68
|
className: "VideoAgent-play",
|
|
85
69
|
onClick: function onClick() {
|
|
86
70
|
var _props$onClick2;
|
|
87
|
-
|
|
88
71
|
return (_props$onClick2 = props.onClick) === null || _props$onClick2 === void 0 ? void 0 : _props$onClick2.call(props);
|
|
89
72
|
}
|
|
90
73
|
}))))));
|