@anov/3d 0.0.288 → 0.0.290
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/dist/anov3d.js +43 -40
- package/dist/anov3d.js.map +1 -1
- package/dist/applicationApi.js +118 -94
- package/dist/applicationApi.js.map +1 -1
- package/dist/hooksManager.js +10 -10
- package/dist/hooksManager.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/messageStatus.js +3 -3
- package/dist/messageStatus.js.map +1 -1
- package/dist/module/animation/index.js +113 -61
- package/dist/module/animation/index.js.map +1 -1
- package/dist/module/animation/motion/index.js +91 -58
- package/dist/module/animation/motion/index.js.map +1 -1
- package/dist/module/animation/strategy.js +21 -7
- package/dist/module/animation/strategy.js.map +1 -1
- package/dist/module/camera/index.js +278 -216
- package/dist/module/camera/index.js.map +1 -1
- package/dist/module/develop/index.js +35 -27
- package/dist/module/develop/index.js.map +1 -1
- package/dist/module/entity/area/index.js +87 -29
- package/dist/module/entity/area/index.js.map +1 -1
- package/dist/module/entity/bar/index.js +24 -5
- package/dist/module/entity/bar/index.js.map +1 -1
- package/dist/module/entity/bar/style/bar_01.js +52 -13
- package/dist/module/entity/bar/style/bar_01.js.map +1 -1
- package/dist/module/entity/bar/style/index.js +21 -7
- package/dist/module/entity/bar/style/index.js.map +1 -1
- package/dist/module/entity/baseEntity.js +66 -43
- package/dist/module/entity/baseEntity.js.map +1 -1
- package/dist/module/entity/batch/index.js +168 -77
- package/dist/module/entity/batch/index.js.map +1 -1
- package/dist/module/entity/dispose.js +16 -14
- package/dist/module/entity/dispose.js.map +1 -1
- package/dist/module/entity/flyline/index.js +90 -34
- package/dist/module/entity/flyline/index.js.map +1 -1
- package/dist/module/entity/group/index.js +75 -59
- package/dist/module/entity/group/index.js.map +1 -1
- package/dist/module/entity/heatmap/index.js +79 -62
- package/dist/module/entity/heatmap/index.js.map +1 -1
- package/dist/module/entity/hybridList.js +67 -49
- package/dist/module/entity/hybridList.js.map +1 -1
- package/dist/module/entity/index.js +644 -442
- package/dist/module/entity/index.js.map +1 -1
- package/dist/module/entity/infoPanel/index.js +76 -23
- package/dist/module/entity/infoPanel/index.js.map +1 -1
- package/dist/module/entity/light/pointLight/index.js +84 -48
- package/dist/module/entity/light/pointLight/index.js.map +1 -1
- package/dist/module/entity/mark/index.js +101 -51
- package/dist/module/entity/mark/index.js.map +1 -1
- package/dist/module/entity/model/index.js +151 -108
- package/dist/module/entity/model/index.js.map +1 -1
- package/dist/module/entity/model/load/loadFbx.js +8 -8
- package/dist/module/entity/model/load/loadFbx.js.map +1 -1
- package/dist/module/entity/model/load/loadGlb.js +11 -13
- package/dist/module/entity/model/load/loadGlb.js.map +1 -1
- package/dist/module/entity/model/load.js +57 -19
- package/dist/module/entity/model/load.js.map +1 -1
- package/dist/module/entity/poi/index.js +90 -34
- package/dist/module/entity/poi/index.js.map +1 -1
- package/dist/module/entity/shape/index.js +136 -67
- package/dist/module/entity/shape/index.js.map +1 -1
- package/dist/module/entity/spline/index.js +75 -22
- package/dist/module/entity/spline/index.js.map +1 -1
- package/dist/module/entity/strategy.js +274 -92
- package/dist/module/entity/strategy.js.map +1 -1
- package/dist/module/entity/traffic/realismTraffic/index.js +88 -59
- package/dist/module/entity/traffic/realismTraffic/index.js.map +1 -1
- package/dist/module/entity/traffic/streamerTraffic/index.js +81 -50
- package/dist/module/entity/traffic/streamerTraffic/index.js.map +1 -1
- package/dist/module/entity/utils.js +13 -11
- package/dist/module/entity/utils.js.map +1 -1
- package/dist/module/entity/videoPanel/index.js +76 -23
- package/dist/module/entity/videoPanel/index.js.map +1 -1
- package/dist/module/environment/index.js +73 -54
- package/dist/module/environment/index.js.map +1 -1
- package/dist/module/environment/season/index.js +184 -342
- package/dist/module/environment/season/index.js.map +1 -1
- package/dist/module/eventBus/entityEvents.js +1 -1
- package/dist/module/eventBus/entityEvents.js.map +1 -1
- package/dist/module/eventBus/index.js +93 -79
- package/dist/module/eventBus/index.js.map +1 -1
- package/dist/module/material/index.js +334 -279
- package/dist/module/material/index.js.map +1 -1
- package/dist/module/scene/fileParse.js +369 -276
- package/dist/module/scene/fileParse.js.map +1 -1
- package/dist/module/scene/index.js +161 -106
- package/dist/module/scene/index.js.map +1 -1
- package/dist/module/tool/index.js +33 -26
- package/dist/module/tool/index.js.map +1 -1
- package/dist/sdkEntry.js +23 -2
- package/dist/sdkEntry.js.map +1 -1
- package/dist/utils/abstract.js +15 -12
- package/dist/utils/abstract.js.map +1 -1
- package/dist/utils/index.js +24 -23
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/messageFn.js +18 -17
- package/dist/utils/messageFn.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
5
|
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); } }
|
|
4
6
|
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); }); }; }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
10
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
13
|
import { Group, use, utils } from '@anov/3d-core';
|
|
9
14
|
import { MaterialSwitchSystem, createHighSelectedTool } from '@anov/3d-ability';
|
|
10
15
|
import debounce from 'lodash/debounce';
|
|
@@ -14,13 +19,14 @@ import HybridList from "./hybridList";
|
|
|
14
19
|
import { entityStrategy, eventPenetrateType } from "./strategy";
|
|
15
20
|
import createDisposeFn from "./dispose";
|
|
16
21
|
import { getMinimumEntity } from "./utils";
|
|
17
|
-
export
|
|
22
|
+
export var hybridList = new HybridList();
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* todo: 统一优化
|
|
21
26
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
var Entity = /*#__PURE__*/function () {
|
|
28
|
+
function Entity(app) {
|
|
29
|
+
_classCallCheck(this, Entity);
|
|
24
30
|
_defineProperty(this, "app", void 0);
|
|
25
31
|
_defineProperty(this, "catchStrategy", new Map());
|
|
26
32
|
_defineProperty(this, "select", void 0);
|
|
@@ -31,15 +37,14 @@ class Entity {
|
|
|
31
37
|
isApi: true
|
|
32
38
|
});
|
|
33
39
|
use.useScene().scene.add(this.materialSwitchSystem);
|
|
34
|
-
this.materialSwitchSystem.addEventListener('onStyleChanged', ({
|
|
35
|
-
style
|
|
36
|
-
}) => {
|
|
40
|
+
this.materialSwitchSystem.addEventListener('onStyleChanged', function (_ref) {
|
|
41
|
+
var style = _ref.style;
|
|
37
42
|
sendToMessage({
|
|
38
43
|
messageType: MessageType.Event,
|
|
39
44
|
messageName: 'onStyleChanged',
|
|
40
45
|
status: EMessageStatus.Success
|
|
41
46
|
}, {
|
|
42
|
-
style
|
|
47
|
+
style: style
|
|
43
48
|
});
|
|
44
49
|
});
|
|
45
50
|
}
|
|
@@ -49,463 +54,660 @@ class Entity {
|
|
|
49
54
|
* @param entityType
|
|
50
55
|
* @returns
|
|
51
56
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
_createClass(Entity, [{
|
|
58
|
+
key: "registerStrategy",
|
|
59
|
+
value: (function () {
|
|
60
|
+
var _registerStrategy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(entityType) {
|
|
61
|
+
var strategyMap, strategyClass;
|
|
62
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
63
|
+
while (1) switch (_context.prev = _context.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
strategyMap = _objectSpread({}, entityStrategy);
|
|
66
|
+
if (entityType in strategyMap) {
|
|
67
|
+
_context.next = 3;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
throw new Error("entityType ".concat(entityType, " is not supported"));
|
|
71
|
+
case 3:
|
|
72
|
+
if (!(entityType in strategyMap && !this.catchStrategy.has(entityType))) {
|
|
73
|
+
_context.next = 8;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
_context.next = 6;
|
|
77
|
+
return strategyMap[entityType]();
|
|
78
|
+
case 6:
|
|
79
|
+
strategyClass = _context.sent;
|
|
80
|
+
// eslint-disable-next-line new-cap
|
|
81
|
+
this.catchStrategy.set(entityType, new strategyClass());
|
|
82
|
+
case 8:
|
|
83
|
+
return _context.abrupt("return", this.catchStrategy.get(entityType));
|
|
84
|
+
case 9:
|
|
85
|
+
case "end":
|
|
86
|
+
return _context.stop();
|
|
87
|
+
}
|
|
88
|
+
}, _callee, this);
|
|
89
|
+
}));
|
|
90
|
+
function registerStrategy(_x) {
|
|
91
|
+
return _registerStrategy.apply(this, arguments);
|
|
62
92
|
}
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
return registerStrategy;
|
|
94
|
+
}())
|
|
95
|
+
}, {
|
|
96
|
+
key: "singleCreate",
|
|
97
|
+
value: function () {
|
|
98
|
+
var _singleCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id, strategy, option, group, layerId) {
|
|
99
|
+
var _this = this;
|
|
100
|
+
var entityInfoArray, targetEntityInfo, _option$interactable, interactable, _option$interactiveEf, interactiveEffect, _option$collision, collision, entity;
|
|
101
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
102
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
103
|
+
case 0:
|
|
104
|
+
_context2.next = 2;
|
|
105
|
+
return Promise.allSettled([strategy.create(option)]);
|
|
106
|
+
case 2:
|
|
107
|
+
entityInfoArray = _context2.sent;
|
|
108
|
+
targetEntityInfo = entityInfoArray[0];
|
|
109
|
+
_option$interactable = option.interactable, interactable = _option$interactable === void 0 ? true : _option$interactable, _option$interactiveEf = option.interactiveEffect, interactiveEffect = _option$interactiveEf === void 0 ? false : _option$interactiveEf, _option$collision = option.collision, collision = _option$collision === void 0 ? true : _option$collision;
|
|
110
|
+
interactable = interactable && collision;
|
|
111
|
+
if (!(targetEntityInfo.status === 'rejected')) {
|
|
112
|
+
_context2.next = 8;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
throw new Error(targetEntityInfo.reason);
|
|
116
|
+
case 8:
|
|
117
|
+
entity = targetEntityInfo.value;
|
|
118
|
+
entity.tag = 'entity'; // used for event penetration identification
|
|
119
|
+
entity.entityId = id;
|
|
120
|
+
entity.userData.entityParams = {
|
|
121
|
+
id: id,
|
|
122
|
+
type: option.type,
|
|
123
|
+
layerId: layerId,
|
|
124
|
+
interactable: interactable,
|
|
125
|
+
name: option.name,
|
|
126
|
+
interactiveEffect: interactiveEffect
|
|
127
|
+
};
|
|
128
|
+
if (entity.userData.entityParams.type === 'model' && entity.visible) this.materialSwitchSystem.addObject(entity);
|
|
129
|
+
hybridList.add(id, entity);
|
|
130
|
+
group === null || group === void 0 || group.add(entity);
|
|
131
|
+
if (interactiveEffect && entity.userData.entityParams.type === 'model') {
|
|
132
|
+
entity.addEventListener('mouseover', function () {
|
|
133
|
+
var _this$select;
|
|
134
|
+
if (entity.userData.entityParams.interactiveEffect) (_this$select = _this.select) === null || _this$select === void 0 || _this$select.call(_this, [entity]);
|
|
135
|
+
});
|
|
136
|
+
entity.addEventListener('mouseout', function () {
|
|
137
|
+
var _this$select2;
|
|
138
|
+
(_this$select2 = _this.select) === null || _this$select2 === void 0 || _this$select2.call(_this, []);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, option), {}, {
|
|
142
|
+
id: id,
|
|
143
|
+
position: entity.position.toArray(),
|
|
144
|
+
rotation: entity.rotation.toArray(),
|
|
145
|
+
scale: entity.scale.toArray(),
|
|
146
|
+
visible: entity.visible
|
|
147
|
+
}));
|
|
148
|
+
case 17:
|
|
149
|
+
case "end":
|
|
150
|
+
return _context2.stop();
|
|
151
|
+
}
|
|
152
|
+
}, _callee2, this);
|
|
153
|
+
}));
|
|
154
|
+
function singleCreate(_x2, _x3, _x4, _x5, _x6) {
|
|
155
|
+
return _singleCreate.apply(this, arguments);
|
|
101
156
|
}
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
} = json;
|
|
121
|
-
interactable = interactable && collision;
|
|
122
|
-
const group = new Group();
|
|
157
|
+
return singleCreate;
|
|
158
|
+
}()
|
|
159
|
+
}, {
|
|
160
|
+
key: "multiCreate",
|
|
161
|
+
value: function multiCreate(id, strategy, json) {
|
|
162
|
+
var _this2 = this;
|
|
163
|
+
var itemType = json.itemType,
|
|
164
|
+
_json$items = json.items,
|
|
165
|
+
items = _json$items === void 0 ? [] : _json$items,
|
|
166
|
+
_json$legends = json.legends,
|
|
167
|
+
legends = _json$legends === void 0 ? [] : _json$legends,
|
|
168
|
+
_json$interactable = json.interactable,
|
|
169
|
+
interactable = _json$interactable === void 0 ? true : _json$interactable,
|
|
170
|
+
_json$collision = json.collision,
|
|
171
|
+
collision = _json$collision === void 0 ? true : _json$collision,
|
|
172
|
+
name = json.name;
|
|
173
|
+
interactable = interactable && collision;
|
|
174
|
+
var group = new Group();
|
|
123
175
|
|
|
124
|
-
|
|
176
|
+
// TODO 优化,定制化非实体逻辑
|
|
125
177
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
178
|
+
var promises = items.map( /*#__PURE__*/function () {
|
|
179
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(item) {
|
|
180
|
+
var currentData;
|
|
181
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
182
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
183
|
+
case 0:
|
|
184
|
+
currentData = item;
|
|
185
|
+
if (currentData.legend) {
|
|
186
|
+
currentData = _objectSpread(_objectSpread({}, legends.find(function (legend) {
|
|
187
|
+
return legend.name === item.legend;
|
|
188
|
+
})), item);
|
|
189
|
+
}
|
|
190
|
+
currentData.type = itemType;
|
|
191
|
+
_context3.next = 5;
|
|
192
|
+
return _this2.singleCreate(item.id, strategy, currentData, group, id);
|
|
193
|
+
case 5:
|
|
194
|
+
return _context3.abrupt("return", _context3.sent);
|
|
195
|
+
case 6:
|
|
196
|
+
case "end":
|
|
197
|
+
return _context3.stop();
|
|
198
|
+
}
|
|
199
|
+
}, _callee3);
|
|
200
|
+
}));
|
|
201
|
+
return function (_x7) {
|
|
202
|
+
return _ref2.apply(this, arguments);
|
|
203
|
+
};
|
|
204
|
+
}());
|
|
205
|
+
return Promise.all(promises).then(function () {
|
|
206
|
+
group.userData.entityParams = {
|
|
207
|
+
id: id,
|
|
208
|
+
type: 'layer',
|
|
209
|
+
itemType: itemType,
|
|
210
|
+
interactable: interactable,
|
|
211
|
+
name: name
|
|
212
|
+
};
|
|
213
|
+
hybridList.add(id, group);
|
|
214
|
+
use.useScene().scene.add(group);
|
|
215
|
+
return _objectSpread(_objectSpread({}, json), {}, {
|
|
216
|
+
id: id,
|
|
217
|
+
position: group.position.toArray(),
|
|
218
|
+
rotation: group.rotation.toArray(),
|
|
219
|
+
scale: group.scale.toArray(),
|
|
220
|
+
visible: group.visible
|
|
221
|
+
});
|
|
155
222
|
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
223
|
+
}
|
|
158
224
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
type,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
225
|
+
/**
|
|
226
|
+
* create entity
|
|
227
|
+
* @param json
|
|
228
|
+
* @returns
|
|
229
|
+
*/
|
|
230
|
+
}, {
|
|
231
|
+
key: "create",
|
|
232
|
+
value: (function () {
|
|
233
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(json) {
|
|
234
|
+
var _this3 = this;
|
|
235
|
+
var id, type, itemType, asyncTask;
|
|
236
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
237
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
238
|
+
case 0:
|
|
239
|
+
id = json.id, type = json.type, itemType = json.itemType;
|
|
240
|
+
asyncTask = Promise.resolve().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
241
|
+
var strategy, res;
|
|
242
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
243
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
244
|
+
case 0:
|
|
245
|
+
_context4.next = 2;
|
|
246
|
+
return _this3.registerStrategy(itemType || type);
|
|
247
|
+
case 2:
|
|
248
|
+
strategy = _context4.sent;
|
|
249
|
+
if (itemType && type === 'layer') res = _this3.multiCreate(id, strategy, json);else res = _this3.singleCreate(id, strategy, json);
|
|
250
|
+
return _context4.abrupt("return", _this3.handleResult(id, res));
|
|
251
|
+
case 5:
|
|
252
|
+
case "end":
|
|
253
|
+
return _context4.stop();
|
|
254
|
+
}
|
|
255
|
+
}, _callee4);
|
|
256
|
+
})));
|
|
257
|
+
return _context5.abrupt("return", _objectSpread(_objectSpread({}, json), {}, {
|
|
258
|
+
asyncTask: asyncTask
|
|
259
|
+
}));
|
|
260
|
+
case 3:
|
|
261
|
+
case "end":
|
|
262
|
+
return _context5.stop();
|
|
263
|
+
}
|
|
264
|
+
}, _callee5);
|
|
177
265
|
}));
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
entityParams
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
266
|
+
function create(_x8) {
|
|
267
|
+
return _create.apply(this, arguments);
|
|
268
|
+
}
|
|
269
|
+
return create;
|
|
270
|
+
}())
|
|
271
|
+
}, {
|
|
272
|
+
key: "singleUpdate",
|
|
273
|
+
value: function () {
|
|
274
|
+
var _singleUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id, strategy, option, group) {
|
|
275
|
+
var _this4 = this;
|
|
276
|
+
var target, _target$userData$enti, entityParams, entityInfoArray, targetEntityInfo, _option$interactiveEf2, interactiveEffect, entity, interactable;
|
|
277
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
278
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
279
|
+
case 0:
|
|
280
|
+
target = hybridList.get(id);
|
|
281
|
+
_target$userData$enti = target.userData.entityParams, entityParams = _target$userData$enti === void 0 ? {} : _target$userData$enti;
|
|
282
|
+
if (target.userData.entityParams.type === 'model') this.materialSwitchSystem.removeObject(target);
|
|
283
|
+
_context6.next = 5;
|
|
284
|
+
return Promise.allSettled([strategy.update(target, option)]);
|
|
285
|
+
case 5:
|
|
286
|
+
entityInfoArray = _context6.sent;
|
|
287
|
+
targetEntityInfo = entityInfoArray[0];
|
|
288
|
+
_option$interactiveEf2 = option.interactiveEffect, interactiveEffect = _option$interactiveEf2 === void 0 ? false : _option$interactiveEf2;
|
|
289
|
+
if (!(targetEntityInfo.status === 'rejected')) {
|
|
290
|
+
_context6.next = 10;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
throw new Error(targetEntityInfo.reason);
|
|
294
|
+
case 10:
|
|
295
|
+
entity = targetEntityInfo.value;
|
|
296
|
+
entity.tag = 'entity'; // use used for event penetration identification
|
|
297
|
+
entity.entityId = id;
|
|
298
|
+
interactable = entityParams.interactable;
|
|
299
|
+
if (option.collision !== undefined) interactable = option.collision;
|
|
300
|
+
entity.userData.entityParams = _objectSpread(_objectSpread(_objectSpread({}, entityParams), {}, {
|
|
301
|
+
interactable: interactable
|
|
302
|
+
}, option), {}, {
|
|
303
|
+
interactiveEffect: interactiveEffect
|
|
304
|
+
});
|
|
207
305
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
306
|
+
// 兼容修改图层下的单个实体
|
|
307
|
+
if (!group && entityParams.layerId) group = hybridList.get(entityParams.layerId);
|
|
308
|
+
if (group) {
|
|
309
|
+
group.remove(hybridList.get(id));
|
|
310
|
+
group.add(entity);
|
|
311
|
+
}
|
|
312
|
+
hybridList.update(id, entity);
|
|
313
|
+
if (interactiveEffect && entity.userData.entityParams.type === 'model') {
|
|
314
|
+
entity.addEventListener('mouseover', function () {
|
|
315
|
+
var _this4$select;
|
|
316
|
+
if (entity.userData.entityParams.interactiveEffect) (_this4$select = _this4.select) === null || _this4$select === void 0 || _this4$select.call(_this4, [entity]);
|
|
317
|
+
});
|
|
318
|
+
entity.addEventListener('mouseout', function () {
|
|
319
|
+
var _this4$select2;
|
|
320
|
+
(_this4$select2 = _this4.select) === null || _this4$select2 === void 0 || _this4$select2.call(_this4, []);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
if (entity.userData.entityParams.type === 'model' && entity.visible) this.materialSwitchSystem.addObject(entity);
|
|
324
|
+
return _context6.abrupt("return", _objectSpread(_objectSpread({}, option), {}, {
|
|
325
|
+
id: id,
|
|
326
|
+
position: entity.position.toArray(),
|
|
327
|
+
rotation: entity.rotation.toArray(),
|
|
328
|
+
scale: entity.scale.toArray(),
|
|
329
|
+
visible: entity.visible
|
|
330
|
+
}));
|
|
331
|
+
case 22:
|
|
332
|
+
case "end":
|
|
333
|
+
return _context6.stop();
|
|
334
|
+
}
|
|
335
|
+
}, _callee6, this);
|
|
336
|
+
}));
|
|
337
|
+
function singleUpdate(_x9, _x10, _x11, _x12) {
|
|
338
|
+
return _singleUpdate.apply(this, arguments);
|
|
213
339
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
340
|
+
return singleUpdate;
|
|
341
|
+
}()
|
|
342
|
+
}, {
|
|
343
|
+
key: "multiUpdate",
|
|
344
|
+
value: function () {
|
|
345
|
+
var _multiUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id, strategy, option) {
|
|
346
|
+
var _this5 = this;
|
|
347
|
+
var group, items, legends, itemType, promises, interactable;
|
|
348
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
349
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
350
|
+
case 0:
|
|
351
|
+
group = hybridList.get(id);
|
|
352
|
+
items = option.items, legends = option.legends, itemType = option.itemType;
|
|
353
|
+
promises = items.map( /*#__PURE__*/function () {
|
|
354
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(item) {
|
|
355
|
+
var legendItem, currentItem;
|
|
356
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
357
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
358
|
+
case 0:
|
|
359
|
+
legendItem = legends === null || legends === void 0 ? void 0 : legends.find(function (legend) {
|
|
360
|
+
return legend.name === item.legend;
|
|
361
|
+
});
|
|
362
|
+
currentItem = legendItem ? _objectSpread(_objectSpread({}, legendItem), item) : item;
|
|
363
|
+
if (!hybridList.get(item.id)) {
|
|
364
|
+
_context7.next = 8;
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
_context7.next = 5;
|
|
368
|
+
return _this5.singleUpdate(item.id, strategy, currentItem, group);
|
|
369
|
+
case 5:
|
|
370
|
+
return _context7.abrupt("return", _context7.sent);
|
|
371
|
+
case 8:
|
|
372
|
+
currentItem.type = itemType;
|
|
373
|
+
_context7.next = 11;
|
|
374
|
+
return _this5.singleCreate(item.id, strategy, currentItem, group);
|
|
375
|
+
case 11:
|
|
376
|
+
return _context7.abrupt("return", _context7.sent);
|
|
377
|
+
case 12:
|
|
378
|
+
case "end":
|
|
379
|
+
return _context7.stop();
|
|
380
|
+
}
|
|
381
|
+
}, _callee7);
|
|
382
|
+
}));
|
|
383
|
+
return function (_x16) {
|
|
384
|
+
return _ref4.apply(this, arguments);
|
|
385
|
+
};
|
|
386
|
+
}());
|
|
387
|
+
_context8.next = 5;
|
|
388
|
+
return Promise.all(promises);
|
|
389
|
+
case 5:
|
|
390
|
+
interactable = group.userData.entityParams.interactable;
|
|
391
|
+
if (option.collision !== undefined) interactable = option.collision;
|
|
392
|
+
group.userData.entityParams = _objectSpread(_objectSpread({}, group.userData.entityParams), {}, {
|
|
393
|
+
interactable: interactable
|
|
394
|
+
}, option);
|
|
395
|
+
return _context8.abrupt("return", _objectSpread(_objectSpread({}, option), {}, {
|
|
396
|
+
id: id,
|
|
397
|
+
position: group.position.toArray(),
|
|
398
|
+
rotation: group.rotation.toArray(),
|
|
399
|
+
scale: group.scale.toArray(),
|
|
400
|
+
visible: group.visible
|
|
401
|
+
}));
|
|
402
|
+
case 9:
|
|
403
|
+
case "end":
|
|
404
|
+
return _context8.stop();
|
|
405
|
+
}
|
|
406
|
+
}, _callee8);
|
|
407
|
+
}));
|
|
408
|
+
function multiUpdate(_x13, _x14, _x15) {
|
|
409
|
+
return _multiUpdate.apply(this, arguments);
|
|
224
410
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
411
|
+
return multiUpdate;
|
|
412
|
+
}()
|
|
413
|
+
/**
|
|
414
|
+
* update entity
|
|
415
|
+
* @param json
|
|
416
|
+
* @returns
|
|
417
|
+
*/
|
|
418
|
+
}, {
|
|
419
|
+
key: "update",
|
|
420
|
+
value: (function () {
|
|
421
|
+
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(json) {
|
|
422
|
+
var _this6 = this;
|
|
423
|
+
var id;
|
|
424
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
425
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
426
|
+
case 0:
|
|
427
|
+
id = json.id;
|
|
428
|
+
Promise.resolve().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
429
|
+
var target, _target$userData$enti2, type, itemType, strategy, res;
|
|
430
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
431
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
432
|
+
case 0:
|
|
433
|
+
target = hybridList.get(id);
|
|
434
|
+
_target$userData$enti2 = target.userData.entityParams, type = _target$userData$enti2.type, itemType = _target$userData$enti2.itemType;
|
|
435
|
+
_context9.next = 4;
|
|
436
|
+
return _this6.registerStrategy(itemType || type);
|
|
437
|
+
case 4:
|
|
438
|
+
strategy = _context9.sent;
|
|
439
|
+
if (itemType && type === 'layer') res = _this6.multiUpdate(id, strategy, _objectSpread({
|
|
440
|
+
itemType: itemType
|
|
441
|
+
}, json));else res = _this6.singleUpdate(id, strategy, json);
|
|
442
|
+
_this6.handleResult(id, res);
|
|
443
|
+
case 7:
|
|
444
|
+
case "end":
|
|
445
|
+
return _context9.stop();
|
|
446
|
+
}
|
|
447
|
+
}, _callee9);
|
|
448
|
+
})));
|
|
449
|
+
return _context10.abrupt("return", json);
|
|
450
|
+
case 3:
|
|
451
|
+
case "end":
|
|
452
|
+
return _context10.stop();
|
|
253
453
|
}
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
id,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
454
|
+
}, _callee10);
|
|
455
|
+
}));
|
|
456
|
+
function update(_x17) {
|
|
457
|
+
return _update.apply(this, arguments);
|
|
458
|
+
}
|
|
459
|
+
return update;
|
|
460
|
+
}())
|
|
461
|
+
}, {
|
|
462
|
+
key: "execute",
|
|
463
|
+
value: function () {
|
|
464
|
+
var _execute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(json) {
|
|
465
|
+
var _this7 = this;
|
|
466
|
+
var id, method, args;
|
|
467
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
468
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
469
|
+
case 0:
|
|
470
|
+
id = json.id, method = json.method, args = json.args;
|
|
471
|
+
if (id && method) {
|
|
472
|
+
Promise.resolve().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
473
|
+
var target, type, strategy, entityInfoArray, targetEntityInfo, entity;
|
|
474
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
475
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
476
|
+
case 0:
|
|
477
|
+
target = hybridList.get(id);
|
|
478
|
+
type = target.userData.entityParams.type;
|
|
479
|
+
_context11.next = 4;
|
|
480
|
+
return _this7.registerStrategy(type);
|
|
481
|
+
case 4:
|
|
482
|
+
strategy = _context11.sent;
|
|
483
|
+
_context11.next = 7;
|
|
484
|
+
return Promise.allSettled([strategy[method](args, target)]);
|
|
485
|
+
case 7:
|
|
486
|
+
entityInfoArray = _context11.sent;
|
|
487
|
+
targetEntityInfo = entityInfoArray[0];
|
|
488
|
+
if (!(targetEntityInfo.status === 'rejected')) {
|
|
489
|
+
_context11.next = 11;
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
throw new Error(targetEntityInfo.reason);
|
|
493
|
+
case 11:
|
|
494
|
+
entity = targetEntityInfo.value;
|
|
495
|
+
hybridList.update(id, entity);
|
|
496
|
+
_this7.handleResult(id, _objectSpread(_objectSpread({}, json), {}, {
|
|
497
|
+
id: id,
|
|
498
|
+
position: entity.position.toArray(),
|
|
499
|
+
rotation: entity.rotation.toArray(),
|
|
500
|
+
scale: entity.scale.toArray(),
|
|
501
|
+
visible: entity.visible
|
|
502
|
+
}));
|
|
503
|
+
case 14:
|
|
504
|
+
case "end":
|
|
505
|
+
return _context11.stop();
|
|
506
|
+
}
|
|
507
|
+
}, _callee11);
|
|
508
|
+
})));
|
|
509
|
+
}
|
|
510
|
+
return _context12.abrupt("return", json);
|
|
511
|
+
case 3:
|
|
512
|
+
case "end":
|
|
513
|
+
return _context12.stop();
|
|
292
514
|
}
|
|
293
|
-
}
|
|
294
|
-
const strategy = yield _this7.registerStrategy(itemType || type);
|
|
295
|
-
let res;
|
|
296
|
-
if (itemType && type === 'layer') res = _this7.multiUpdate(id, strategy, _objectSpread({
|
|
297
|
-
itemType
|
|
298
|
-
}, json));else res = _this7.singleUpdate(id, strategy, json);
|
|
299
|
-
_this7.handleResult(id, res);
|
|
515
|
+
}, _callee12);
|
|
300
516
|
}));
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
execute(json) {
|
|
305
|
-
var _this8 = this;
|
|
306
|
-
return _asyncToGenerator(function* () {
|
|
307
|
-
const {
|
|
308
|
-
id,
|
|
309
|
-
method,
|
|
310
|
-
args
|
|
311
|
-
} = json;
|
|
312
|
-
if (id && method) {
|
|
313
|
-
Promise.resolve().then( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
314
|
-
const target = hybridList.get(id);
|
|
315
|
-
const {
|
|
316
|
-
entityParams: {
|
|
317
|
-
type
|
|
318
|
-
}
|
|
319
|
-
} = target.userData;
|
|
320
|
-
const strategy = yield _this8.registerStrategy(type);
|
|
321
|
-
const entityInfoArray = yield Promise.allSettled([strategy[method](args, target)]);
|
|
322
|
-
const targetEntityInfo = entityInfoArray[0];
|
|
323
|
-
if (targetEntityInfo.status === 'rejected') throw new Error(targetEntityInfo.reason);
|
|
324
|
-
const entity = targetEntityInfo.value;
|
|
325
|
-
hybridList.update(id, entity);
|
|
326
|
-
_this8.handleResult(id, _objectSpread(_objectSpread({}, json), {}, {
|
|
327
|
-
id,
|
|
328
|
-
position: entity.position.toArray(),
|
|
329
|
-
rotation: entity.rotation.toArray(),
|
|
330
|
-
scale: entity.scale.toArray(),
|
|
331
|
-
visible: entity.visible
|
|
332
|
-
}));
|
|
333
|
-
}));
|
|
517
|
+
function execute(_x18) {
|
|
518
|
+
return _execute.apply(this, arguments);
|
|
334
519
|
}
|
|
335
|
-
return
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
const {
|
|
383
|
-
id
|
|
384
|
-
} = json;
|
|
385
|
-
const target = hybridList.get(id);
|
|
386
|
-
if (!target) throw new Error(`entity ${id} is not exist`);
|
|
387
|
-
if (target.userData.entityParams.type === 'model') this.materialSwitchSystem.removeObject(target);
|
|
388
|
-
const deleteChildren = entityId => {
|
|
389
|
-
const entity = hybridList.get(entityId);
|
|
390
|
-
if (!entity) return;
|
|
391
|
-
if (entity.children) {
|
|
392
|
-
entity.children.forEach(child => {
|
|
393
|
-
const {
|
|
394
|
-
id
|
|
395
|
-
} = child.userData.entityParams || {};
|
|
396
|
-
id && deleteChildren(id);
|
|
397
|
-
});
|
|
520
|
+
return execute;
|
|
521
|
+
}()
|
|
522
|
+
/**
|
|
523
|
+
* handle create or update loadded result
|
|
524
|
+
* @param id
|
|
525
|
+
* @param res
|
|
526
|
+
*/
|
|
527
|
+
}, {
|
|
528
|
+
key: "handleResult",
|
|
529
|
+
value: (function () {
|
|
530
|
+
var _handleResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(id, res) {
|
|
531
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
532
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
533
|
+
case 0:
|
|
534
|
+
return _context13.abrupt("return", Promise.resolve(res).then(function () {
|
|
535
|
+
sendToMessage({
|
|
536
|
+
messageType: MessageType.Event,
|
|
537
|
+
messageName: 'onLoaded',
|
|
538
|
+
status: EMessageStatus.Success,
|
|
539
|
+
global: false
|
|
540
|
+
}, {
|
|
541
|
+
id: id,
|
|
542
|
+
success: true
|
|
543
|
+
});
|
|
544
|
+
}).catch(function () {
|
|
545
|
+
sendToMessage({
|
|
546
|
+
messageType: MessageType.Event,
|
|
547
|
+
messageName: 'onLoaded',
|
|
548
|
+
status: EMessageStatus.Success,
|
|
549
|
+
global: false
|
|
550
|
+
}, {
|
|
551
|
+
id: id,
|
|
552
|
+
success: false
|
|
553
|
+
});
|
|
554
|
+
}).finally(function () {
|
|
555
|
+
utils.emitter.emit('onEntityLoaded', {
|
|
556
|
+
id: id
|
|
557
|
+
});
|
|
558
|
+
}));
|
|
559
|
+
case 1:
|
|
560
|
+
case "end":
|
|
561
|
+
return _context13.stop();
|
|
562
|
+
}
|
|
563
|
+
}, _callee13);
|
|
564
|
+
}));
|
|
565
|
+
function handleResult(_x19, _x20) {
|
|
566
|
+
return _handleResult.apply(this, arguments);
|
|
398
567
|
}
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
568
|
+
return handleResult;
|
|
569
|
+
}())
|
|
570
|
+
}, {
|
|
571
|
+
key: "customizer",
|
|
572
|
+
value: function customizer(objValue, srcValue) {
|
|
573
|
+
if (Array.isArray(objValue) && srcValue) return srcValue;
|
|
574
|
+
}
|
|
404
575
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
576
|
+
/**
|
|
577
|
+
* delete entity
|
|
578
|
+
* @param json
|
|
579
|
+
*/
|
|
580
|
+
}, {
|
|
581
|
+
key: "delete",
|
|
582
|
+
value: function _delete(json) {
|
|
583
|
+
var id = json.id;
|
|
584
|
+
var target = hybridList.get(id);
|
|
585
|
+
if (!target) throw new Error("entity ".concat(id, " is not exist"));
|
|
586
|
+
if (target.userData.entityParams.type === 'model') this.materialSwitchSystem.removeObject(target);
|
|
587
|
+
var deleteChildren = function deleteChildren(entityId) {
|
|
588
|
+
var entity = hybridList.get(entityId);
|
|
589
|
+
if (!entity) return;
|
|
590
|
+
if (entity.children) {
|
|
591
|
+
entity.children.forEach(function (child) {
|
|
592
|
+
var _ref7 = child.userData.entityParams || {},
|
|
593
|
+
id = _ref7.id;
|
|
594
|
+
id && deleteChildren(id);
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
hybridList.has(entityId) && hybridList.delete(entityId);
|
|
598
|
+
};
|
|
599
|
+
deleteChildren(id);
|
|
600
|
+
target.removeFromParent();
|
|
601
|
+
var entityDispose = createDisposeFn();
|
|
412
602
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
id
|
|
421
|
-
} = params;
|
|
422
|
-
const entity = hybridList.get(id);
|
|
423
|
-
const option = this.getEntityOption(entity);
|
|
424
|
-
return _objectSpread(_objectSpread({}, option), {}, {
|
|
425
|
-
id,
|
|
426
|
-
position: entity.position.toArray(),
|
|
427
|
-
rotation: entity.rotation.toArray(),
|
|
428
|
-
scale: entity.scale.toArray(),
|
|
429
|
-
visible: entity.visible,
|
|
430
|
-
type: entity.userData.entityParams.type,
|
|
431
|
-
name: entity.userData.entityParams.name
|
|
432
|
-
});
|
|
433
|
-
}
|
|
603
|
+
// @ts-ignore
|
|
604
|
+
// eslint-disable-next-line no-proto
|
|
605
|
+
target.__proto__.dispose = entityDispose;
|
|
606
|
+
// @ts-ignore
|
|
607
|
+
target.dispose();
|
|
608
|
+
hybridList.delete(id);
|
|
609
|
+
}
|
|
434
610
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
611
|
+
/**
|
|
612
|
+
* get entity
|
|
613
|
+
* @param params
|
|
614
|
+
* @returns
|
|
615
|
+
*/
|
|
616
|
+
}, {
|
|
617
|
+
key: "get",
|
|
618
|
+
value: function get(params) {
|
|
619
|
+
var id = params.id;
|
|
620
|
+
var entity = hybridList.get(id);
|
|
621
|
+
var option = this.getEntityOption(entity);
|
|
622
|
+
return _objectSpread(_objectSpread({}, option), {}, {
|
|
623
|
+
id: id,
|
|
624
|
+
position: entity.position.toArray(),
|
|
625
|
+
rotation: entity.rotation.toArray(),
|
|
626
|
+
scale: entity.scale.toArray(),
|
|
627
|
+
visible: entity.visible,
|
|
628
|
+
type: entity.userData.entityParams.type,
|
|
629
|
+
name: entity.userData.entityParams.name
|
|
630
|
+
});
|
|
631
|
+
}
|
|
443
632
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
const realEventName = eventName.slice(2).toLowerCase();
|
|
454
|
-
const target = hybridList.get(id);
|
|
455
|
-
if (!target) throw new Error(`entity ${id} is not exist`);
|
|
456
|
-
if (!(target.userData.entityParams.type === 'model' || target.userData.entityParams.type === 'poi')) return;
|
|
457
|
-
if (!target.userData.entityParams.interactable) {
|
|
458
|
-
this.unregisterEvents(opts);
|
|
459
|
-
return;
|
|
633
|
+
/**
|
|
634
|
+
* get entity option
|
|
635
|
+
* @param target
|
|
636
|
+
* @returns
|
|
637
|
+
*/
|
|
638
|
+
}, {
|
|
639
|
+
key: "getEntityOption",
|
|
640
|
+
value: function getEntityOption(target) {
|
|
641
|
+
return target && (target.userData.option || {});
|
|
460
642
|
}
|
|
461
643
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
644
|
+
/**
|
|
645
|
+
* register entity events
|
|
646
|
+
* @param opts
|
|
647
|
+
*/
|
|
648
|
+
}, {
|
|
649
|
+
key: "registerEvents",
|
|
650
|
+
value: function registerEvents(opts) {
|
|
651
|
+
var eventName = opts.eventName,
|
|
652
|
+
id = opts.entityId;
|
|
653
|
+
var realEventName = eventName.slice(2).toLowerCase();
|
|
654
|
+
var target = hybridList.get(id);
|
|
655
|
+
if (!target) throw new Error("entity ".concat(id, " is not exist"));
|
|
656
|
+
if (!(target.userData.entityParams.type === 'model' || target.userData.entityParams.type === 'poi')) return;
|
|
657
|
+
if (!target.userData.entityParams.interactable) {
|
|
658
|
+
this.unregisterEvents(opts);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// @ts-ignore
|
|
663
|
+
if (eventPenetrateType.includes(target.entityType)) {
|
|
664
|
+
target.userData[realEventName] = debounce(function (e) {
|
|
665
|
+
var closestMesh = e.newClosestMesh;
|
|
666
|
+
var minimumEntity = getMinimumEntity(closestMesh, target);
|
|
667
|
+
minimumEntity && sendToMessage({
|
|
668
|
+
messageType: MessageType.Event,
|
|
669
|
+
messageName: eventName,
|
|
670
|
+
status: EMessageStatus.Success,
|
|
671
|
+
global: false
|
|
672
|
+
}, {
|
|
673
|
+
targetId: minimumEntity.entityId,
|
|
674
|
+
id: id
|
|
675
|
+
});
|
|
475
676
|
});
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
677
|
+
target.addEventListener(realEventName, target.userData[realEventName]);
|
|
678
|
+
} else {
|
|
679
|
+
target.userData[realEventName] = debounce(function (e) {
|
|
680
|
+
console.log('e:', e);
|
|
681
|
+
sendToMessage({
|
|
682
|
+
messageType: MessageType.Event,
|
|
683
|
+
messageName: eventName,
|
|
684
|
+
status: EMessageStatus.Success,
|
|
685
|
+
global: false
|
|
686
|
+
}, {
|
|
687
|
+
targetId: id,
|
|
688
|
+
id: id
|
|
689
|
+
});
|
|
489
690
|
});
|
|
490
|
-
|
|
491
|
-
|
|
691
|
+
target.addEventListener(realEventName, target.userData[realEventName]);
|
|
692
|
+
}
|
|
492
693
|
}
|
|
493
|
-
}
|
|
494
694
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
}
|
|
695
|
+
/**
|
|
696
|
+
* unregister entity events
|
|
697
|
+
* @param opts
|
|
698
|
+
*/
|
|
699
|
+
}, {
|
|
700
|
+
key: "unregisterEvents",
|
|
701
|
+
value: function unregisterEvents(opts) {
|
|
702
|
+
var eventName = opts.eventName,
|
|
703
|
+
id = opts.entityId;
|
|
704
|
+
var realEventName = eventName.slice(2).toLowerCase();
|
|
705
|
+
var target = hybridList.get(id);
|
|
706
|
+
if (!target) throw new Error("entity ".concat(id, " is not exist"));
|
|
707
|
+
target.removeEventListener(realEventName, target.userData[realEventName]);
|
|
708
|
+
}
|
|
709
|
+
}]);
|
|
710
|
+
return Entity;
|
|
711
|
+
}();
|
|
510
712
|
export default Entity;
|
|
511
713
|
//# sourceMappingURL=index.js.map
|