@anov/3d 0.0.289 → 0.0.291

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/anov3d.js +43 -40
  2. package/dist/anov3d.js.map +1 -1
  3. package/dist/applicationApi.js +118 -94
  4. package/dist/applicationApi.js.map +1 -1
  5. package/dist/hooksManager.js +10 -10
  6. package/dist/hooksManager.js.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/messageStatus.js +3 -3
  10. package/dist/messageStatus.js.map +1 -1
  11. package/dist/module/animation/index.js +113 -61
  12. package/dist/module/animation/index.js.map +1 -1
  13. package/dist/module/animation/motion/index.js +91 -58
  14. package/dist/module/animation/motion/index.js.map +1 -1
  15. package/dist/module/animation/strategy.js +21 -7
  16. package/dist/module/animation/strategy.js.map +1 -1
  17. package/dist/module/camera/index.js +278 -216
  18. package/dist/module/camera/index.js.map +1 -1
  19. package/dist/module/develop/index.js +35 -27
  20. package/dist/module/develop/index.js.map +1 -1
  21. package/dist/module/entity/area/index.js +87 -29
  22. package/dist/module/entity/area/index.js.map +1 -1
  23. package/dist/module/entity/bar/index.js +24 -5
  24. package/dist/module/entity/bar/index.js.map +1 -1
  25. package/dist/module/entity/bar/style/bar_01.js +52 -13
  26. package/dist/module/entity/bar/style/bar_01.js.map +1 -1
  27. package/dist/module/entity/bar/style/index.js +21 -7
  28. package/dist/module/entity/bar/style/index.js.map +1 -1
  29. package/dist/module/entity/baseEntity.js +66 -43
  30. package/dist/module/entity/baseEntity.js.map +1 -1
  31. package/dist/module/entity/batch/index.js +168 -77
  32. package/dist/module/entity/batch/index.js.map +1 -1
  33. package/dist/module/entity/dispose.js +16 -14
  34. package/dist/module/entity/dispose.js.map +1 -1
  35. package/dist/module/entity/flyline/index.js +90 -34
  36. package/dist/module/entity/flyline/index.js.map +1 -1
  37. package/dist/module/entity/group/index.js +75 -59
  38. package/dist/module/entity/group/index.js.map +1 -1
  39. package/dist/module/entity/heatmap/index.js +79 -62
  40. package/dist/module/entity/heatmap/index.js.map +1 -1
  41. package/dist/module/entity/hybridList.js +67 -49
  42. package/dist/module/entity/hybridList.js.map +1 -1
  43. package/dist/module/entity/index.js +644 -442
  44. package/dist/module/entity/index.js.map +1 -1
  45. package/dist/module/entity/infoPanel/index.js +76 -23
  46. package/dist/module/entity/infoPanel/index.js.map +1 -1
  47. package/dist/module/entity/light/pointLight/index.js +84 -48
  48. package/dist/module/entity/light/pointLight/index.js.map +1 -1
  49. package/dist/module/entity/mark/index.js +101 -51
  50. package/dist/module/entity/mark/index.js.map +1 -1
  51. package/dist/module/entity/model/index.js +151 -108
  52. package/dist/module/entity/model/index.js.map +1 -1
  53. package/dist/module/entity/model/load/loadFbx.js +8 -8
  54. package/dist/module/entity/model/load/loadFbx.js.map +1 -1
  55. package/dist/module/entity/model/load/loadGlb.js +11 -13
  56. package/dist/module/entity/model/load/loadGlb.js.map +1 -1
  57. package/dist/module/entity/model/load.js +57 -19
  58. package/dist/module/entity/model/load.js.map +1 -1
  59. package/dist/module/entity/poi/index.js +90 -34
  60. package/dist/module/entity/poi/index.js.map +1 -1
  61. package/dist/module/entity/shape/index.js +136 -67
  62. package/dist/module/entity/shape/index.js.map +1 -1
  63. package/dist/module/entity/spline/index.js +75 -22
  64. package/dist/module/entity/spline/index.js.map +1 -1
  65. package/dist/module/entity/strategy.js +274 -92
  66. package/dist/module/entity/strategy.js.map +1 -1
  67. package/dist/module/entity/traffic/realismTraffic/index.js +88 -59
  68. package/dist/module/entity/traffic/realismTraffic/index.js.map +1 -1
  69. package/dist/module/entity/traffic/streamerTraffic/index.js +81 -50
  70. package/dist/module/entity/traffic/streamerTraffic/index.js.map +1 -1
  71. package/dist/module/entity/utils.js +13 -11
  72. package/dist/module/entity/utils.js.map +1 -1
  73. package/dist/module/entity/videoPanel/index.js +76 -23
  74. package/dist/module/entity/videoPanel/index.js.map +1 -1
  75. package/dist/module/environment/index.js +73 -54
  76. package/dist/module/environment/index.js.map +1 -1
  77. package/dist/module/environment/season/index.js +184 -342
  78. package/dist/module/environment/season/index.js.map +1 -1
  79. package/dist/module/eventBus/entityEvents.js +1 -1
  80. package/dist/module/eventBus/entityEvents.js.map +1 -1
  81. package/dist/module/eventBus/index.js +93 -79
  82. package/dist/module/eventBus/index.js.map +1 -1
  83. package/dist/module/material/index.js +334 -279
  84. package/dist/module/material/index.js.map +1 -1
  85. package/dist/module/scene/fileParse.js +369 -276
  86. package/dist/module/scene/fileParse.js.map +1 -1
  87. package/dist/module/scene/index.js +161 -106
  88. package/dist/module/scene/index.js.map +1 -1
  89. package/dist/module/tool/index.js +33 -26
  90. package/dist/module/tool/index.js.map +1 -1
  91. package/dist/sdkEntry.js +23 -2
  92. package/dist/sdkEntry.js.map +1 -1
  93. package/dist/utils/abstract.js +15 -12
  94. package/dist/utils/abstract.js.map +1 -1
  95. package/dist/utils/index.js +24 -23
  96. package/dist/utils/index.js.map +1 -1
  97. package/dist/utils/messageFn.js +18 -17
  98. package/dist/utils/messageFn.js.map +1 -1
  99. package/package.json +3 -3
@@ -1,10 +1,21 @@
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ 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
9
  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); } }
2
10
  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); }); }; }
3
11
  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; }
4
12
  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; }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ 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); } }
15
+ 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
16
  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" == typeof i ? i : String(i); }
7
- 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); }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
+ 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
19
  import _ from 'lodash';
9
20
  import { FogExp2, use, utils } from '@anov/3d-core';
10
21
  import { Map as CMap } from '@anov/geo-3d';
@@ -20,11 +31,10 @@ var EObjectType = /*#__PURE__*/function (EObjectType) {
20
31
  EObjectType["entity"] = "entity";
21
32
  return EObjectType;
22
33
  }(EObjectType || {});
23
- const {
24
- emitter
25
- } = utils;
26
- class FileParse {
27
- constructor(app) {
34
+ var emitter = utils.emitter;
35
+ var FileParse = /*#__PURE__*/function () {
36
+ function FileParse(app) {
37
+ _classCallCheck(this, FileParse);
28
38
  _defineProperty(this, "app", void 0);
29
39
  _defineProperty(this, "json", void 0);
30
40
  _defineProperty(this, "scene", void 0);
@@ -35,302 +45,385 @@ class FileParse {
35
45
  }
36
46
 
37
47
  // 解析场景
38
- parseScene(json, action) {
39
- this.json = json;
40
- this.action = action;
41
- emitter.off('model-loading-progress');
42
- this.modelProgress.clear();
43
- const {
44
- scene: index = 0,
45
- scenes,
46
- nodes,
47
- layers
48
- } = json || {};
49
- const sceneNode = scenes && scenes[index];
50
- if (!sceneNode) {
51
- console.error('Invalid scene or nodeIndex.');
52
- return;
53
- }
54
- try {
55
- // 递归解析节点并计算模型节点的数量
56
- const {
57
- modelCount,
58
- nodes: parsedNodes
59
- } = this.parseNode(sceneNode.nodeIndex, nodes, 0);
60
- this.scene = _objectSpread(_objectSpread({
61
- index
62
- }, sceneNode), {}, {
63
- nodes: parsedNodes.filter(Boolean),
64
- layers,
65
- modelCount // 计算模型节点数量并放到 scene 对象中
66
- });
67
- this.addListener();
68
- this.addLayers();
69
- this.scene.environment && this.setEnvironment(this.scene.environment);
70
- return this.addNodes(this.scene.nodes);
71
- } catch (error) {
72
- return false;
73
- }
74
- }
75
-
76
- // 递归解析节点,并计算模型节点数量
77
- parseNode(indexes, nodes, modelCount) {
78
- const result = {
79
- modelCount,
80
- nodes: []
81
- };
82
- indexes.forEach(index => {
83
- const node = nodes[index];
84
- if (!node) {
85
- console.warn(`Node with index ${index} not found.`);
48
+ _createClass(FileParse, [{
49
+ key: "parseScene",
50
+ value: function parseScene(json, action) {
51
+ this.json = json;
52
+ this.action = action;
53
+ emitter.off('model-loading-progress');
54
+ this.modelProgress.clear();
55
+ var _ref = json || {},
56
+ _ref$scene = _ref.scene,
57
+ index = _ref$scene === void 0 ? 0 : _ref$scene,
58
+ scenes = _ref.scenes,
59
+ nodes = _ref.nodes,
60
+ layers = _ref.layers;
61
+ var sceneNode = scenes && scenes[index];
62
+ if (!sceneNode) {
63
+ console.error('Invalid scene or nodeIndex.');
86
64
  return;
87
65
  }
88
- if (node.type === EObjectType.camera) return;
89
-
90
- // 如果是 'model' 类型的节点,增加计数
91
- if (node.type === 'model') {
92
- this.modelProgress.set(node.id, 0);
93
- result.modelCount++;
66
+ try {
67
+ // 递归解析节点并计算模型节点的数量
68
+ var _this$parseNode = this.parseNode(sceneNode.nodeIndex, nodes, 0),
69
+ modelCount = _this$parseNode.modelCount,
70
+ parsedNodes = _this$parseNode.nodes;
71
+ this.scene = _objectSpread(_objectSpread({
72
+ index: index
73
+ }, sceneNode), {}, {
74
+ nodes: parsedNodes.filter(Boolean),
75
+ layers: layers,
76
+ modelCount: modelCount // 计算模型节点数量并放到 scene 对象中
77
+ });
78
+ this.addListener();
79
+ this.addLayers();
80
+ this.scene.environment && this.setEnvironment(this.scene.environment);
81
+ return this.addNodes(this.scene.nodes);
82
+ } catch (error) {
83
+ return false;
94
84
  }
85
+ }
95
86
 
96
- // 如果节点有子节点,递归处理
97
- const childModelCount = result.modelCount;
98
- if (node.children) {
99
- const childResult = this.parseNode(node.children, nodes, childModelCount);
100
- result.modelCount = childResult.modelCount;
101
- result.nodes.push(_objectSpread(_objectSpread({}, node), {}, {
102
- children: childResult.nodes.filter(Boolean)
103
- }));
104
- } else {
105
- result.nodes.push(node);
106
- }
107
- });
108
- return result;
109
- }
110
- addNodes(nodes) {
111
- var _this = this;
112
- return _asyncToGenerator(function* () {
113
- const result = nodes.map(node => {
114
- return _this.addSingelNode(node);
115
- });
116
- return Promise.all(result);
117
- })();
118
- }
87
+ // 递归解析节点,并计算模型节点数量
88
+ }, {
89
+ key: "parseNode",
90
+ value: function parseNode(indexes, nodes, modelCount) {
91
+ var _this = this;
92
+ var result = {
93
+ modelCount: modelCount,
94
+ nodes: []
95
+ };
96
+ indexes.forEach(function (index) {
97
+ var node = nodes[index];
98
+ if (!node) {
99
+ console.warn("Node with index ".concat(index, " not found."));
100
+ return;
101
+ }
102
+ if (node.type === EObjectType.camera) return;
119
103
 
120
- // 解析环境
121
- setEnvironment(params) {
122
- const {
123
- time,
124
- weather
125
- } = params;
126
- const environmentManage = this.app[EObjectType.environment];
127
- let hour = 12;
128
- const currentTime = (time === null || time === void 0 ? void 0 : time.value) || (time === null || time === void 0 ? void 0 : time.time);
129
- if (currentTime) {
130
- environmentManage.setTime({
131
- time: currentTime
104
+ // 如果是 'model' 类型的节点,增加计数
105
+ if (node.type === 'model') {
106
+ _this.modelProgress.set(node.id, 0);
107
+ result.modelCount++;
108
+ }
109
+
110
+ // 如果节点有子节点,递归处理
111
+ var childModelCount = result.modelCount;
112
+ if (node.children) {
113
+ var childResult = _this.parseNode(node.children, nodes, childModelCount);
114
+ result.modelCount = childResult.modelCount;
115
+ result.nodes.push(_objectSpread(_objectSpread({}, node), {}, {
116
+ children: childResult.nodes.filter(Boolean)
117
+ }));
118
+ } else {
119
+ result.nodes.push(node);
120
+ }
132
121
  });
133
- const timeRange = this.timeToRange2400(currentTime);
134
- if (timeRange) hour = timeRange.hour;
135
- }
136
- if (weather !== null && weather !== void 0 && weather.weather) environmentManage.setWeather({
137
- weather: weather.weather,
138
- time: hour
139
- });
140
- const {
141
- exposure
142
- } = this.scene; // 曝光度
143
- if (exposure !== undefined) {
144
- const {
145
- renderer
146
- } = use.useScene();
147
- renderer.toneMappingExposure = exposure;
122
+ return result;
148
123
  }
149
- }
150
- addLayers() {
151
- const {
152
- layers,
153
- layerIndex
154
- } = this.scene;
155
- const {
156
- scene,
157
- camera,
158
- renderer,
159
- orbitControls
160
- } = use.useScene();
161
- layerIndex && layerIndex.forEach(index => {
162
- if (index >= layers.length) return;
163
- const type = layers[index].type;
164
- switch (type) {
165
- case 'city':
166
- {
167
- CMap.load({
168
- scene,
169
- camera,
170
- renderer,
171
- control: orbitControls,
172
- sccData: layers[index]
173
- });
174
- break;
175
- }
176
- case 'water':
177
- {
178
- const water = new Water(layers[index]);
179
- water.update();
180
- scene.add(water);
181
- break;
182
- }
183
- case 'fog':
184
- {
185
- const {
186
- color,
187
- density
188
- } = layers[index];
189
- scene.fog = new FogExp2(color, density);
190
- break;
124
+ }, {
125
+ key: "addNodes",
126
+ value: function () {
127
+ var _addNodes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(nodes) {
128
+ var _this2 = this;
129
+ var result;
130
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
131
+ while (1) switch (_context.prev = _context.next) {
132
+ case 0:
133
+ result = nodes.map(function (node) {
134
+ return _this2.addSingelNode(node);
135
+ });
136
+ return _context.abrupt("return", Promise.all(result));
137
+ case 2:
138
+ case "end":
139
+ return _context.stop();
191
140
  }
141
+ }, _callee);
142
+ }));
143
+ function addNodes(_x) {
144
+ return _addNodes.apply(this, arguments);
192
145
  }
193
- });
194
- }
195
-
196
- // 解析单个节点
197
- addSingelNode(node) {
198
- var _this2 = this;
199
- return _asyncToGenerator(function* () {
200
- const isDefineType = _this2.isEnumValue(EObjectType, node.type);
201
- const nodeObject = isDefineType ? _this2.app[node.type] : _this2.app[EObjectType.entity];
202
- if (!nodeObject) {
203
- console.error(`Unknown node type: ${node.type}`);
204
- return;
146
+ return addNodes;
147
+ }() // 解析环境
148
+ }, {
149
+ key: "setEnvironment",
150
+ value: function setEnvironment(params) {
151
+ var time = params.time,
152
+ weather = params.weather;
153
+ var environmentManage = this.app[EObjectType.environment];
154
+ var hour = 12;
155
+ var currentTime = (time === null || time === void 0 ? void 0 : time.value) || (time === null || time === void 0 ? void 0 : time.time);
156
+ if (currentTime) {
157
+ environmentManage.setTime({
158
+ time: currentTime
159
+ });
160
+ var timeRange = this.timeToRange2400(currentTime);
161
+ if (timeRange) hour = timeRange.hour;
205
162
  }
206
- const params = _.clone(node);
207
- if (node.type === 'group' && node.children) {
208
- const childPromises = node.children.map(childIndex => _this2.addSingelNode(childIndex));
209
- const childNodes = yield Promise.all(childPromises);
210
- params.children = childNodes.map(child => child.id);
163
+ if (weather !== null && weather !== void 0 && weather.weather) environmentManage.setWeather({
164
+ weather: weather.weather,
165
+ time: hour
166
+ });
167
+ var exposure = this.scene.exposure; // 曝光度
168
+ if (exposure !== undefined) {
169
+ var _use$useScene = use.useScene(),
170
+ renderer = _use$useScene.renderer;
171
+ renderer.toneMappingExposure = exposure;
211
172
  }
173
+ }
174
+ }, {
175
+ key: "addLayers",
176
+ value: function addLayers() {
177
+ var _this$scene = this.scene,
178
+ layers = _this$scene.layers,
179
+ layerIndex = _this$scene.layerIndex;
180
+ var _use$useScene2 = use.useScene(),
181
+ scene = _use$useScene2.scene,
182
+ camera = _use$useScene2.camera,
183
+ renderer = _use$useScene2.renderer,
184
+ orbitControls = _use$useScene2.orbitControls;
185
+ layerIndex && layerIndex.forEach(function (index) {
186
+ if (index >= layers.length) return;
187
+ var type = layers[index].type;
188
+ switch (type) {
189
+ case 'city':
190
+ {
191
+ CMap.load({
192
+ scene: scene,
193
+ camera: camera,
194
+ renderer: renderer,
195
+ control: orbitControls,
196
+ sccData: layers[index]
197
+ });
198
+ break;
199
+ }
200
+ case 'water':
201
+ {
202
+ var water = new Water(layers[index]);
203
+ water.update();
204
+ scene.add(water);
205
+ break;
206
+ }
207
+ case 'fog':
208
+ {
209
+ var _layers$index = layers[index],
210
+ color = _layers$index.color,
211
+ density = _layers$index.density;
212
+ scene.fog = new FogExp2(color, density);
213
+ break;
214
+ }
215
+ }
216
+ });
217
+ }
212
218
 
213
- // 判断逻辑:符合夸引擎调用逻辑,先通过initialResult表示调用成功,然后通过asyncTask表示执行成功
214
- const initialResult = yield nodeObject.create(params);
215
- yield initialResult.asyncTask;
216
- return node;
217
- })();
218
- }
219
- addListener() {
220
- if (this.scene.modelCount > 0) {
221
- emitter.on('model-loading-progress', data => {
222
- const {
223
- id,
224
- progress
225
- } = data;
226
- if (!this.modelProgress.has(id)) return;
227
- this.modelProgress.set(id, progress);
228
- // 更新累积进度
229
- const progressValue = Array.from(this.modelProgress.values()).reduce((sum, currentProgress) => sum + currentProgress, 0);
230
- // 计算进度
231
- const totalProgress = progressValue / this.scene.modelCount;
219
+ // 解析单个节点
220
+ }, {
221
+ key: "addSingelNode",
222
+ value: function () {
223
+ var _addSingelNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(node) {
224
+ var _this3 = this;
225
+ var isDefineType, nodeObject, params, childPromises, childNodes, initialResult;
226
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
227
+ while (1) switch (_context2.prev = _context2.next) {
228
+ case 0:
229
+ isDefineType = this.isEnumValue(EObjectType, node.type);
230
+ nodeObject = isDefineType ? this.app[node.type] : this.app[EObjectType.entity];
231
+ if (nodeObject) {
232
+ _context2.next = 5;
233
+ break;
234
+ }
235
+ console.error("Unknown node type: ".concat(node.type));
236
+ return _context2.abrupt("return");
237
+ case 5:
238
+ params = _.clone(node);
239
+ if (!(node.type === 'group' && node.children)) {
240
+ _context2.next = 12;
241
+ break;
242
+ }
243
+ childPromises = node.children.map(function (childIndex) {
244
+ return _this3.addSingelNode(childIndex);
245
+ });
246
+ _context2.next = 10;
247
+ return Promise.all(childPromises);
248
+ case 10:
249
+ childNodes = _context2.sent;
250
+ params.children = childNodes.map(function (child) {
251
+ return child.id;
252
+ });
253
+ case 12:
254
+ _context2.next = 14;
255
+ return nodeObject.create(params);
256
+ case 14:
257
+ initialResult = _context2.sent;
258
+ _context2.next = 17;
259
+ return initialResult.asyncTask;
260
+ case 17:
261
+ return _context2.abrupt("return", node);
262
+ case 18:
263
+ case "end":
264
+ return _context2.stop();
265
+ }
266
+ }, _callee2, this);
267
+ }));
268
+ function addSingelNode(_x2) {
269
+ return _addSingelNode.apply(this, arguments);
270
+ }
271
+ return addSingelNode;
272
+ }()
273
+ }, {
274
+ key: "addListener",
275
+ value: function addListener() {
276
+ var _this4 = this;
277
+ if (this.scene.modelCount > 0) {
278
+ emitter.on('model-loading-progress', function (data) {
279
+ var id = data.id,
280
+ progress = data.progress;
281
+ if (!_this4.modelProgress.has(id)) return;
282
+ _this4.modelProgress.set(id, progress);
283
+ // 更新累积进度
284
+ var progressValue = Array.from(_this4.modelProgress.values()).reduce(function (sum, currentProgress) {
285
+ return sum + currentProgress;
286
+ }, 0);
287
+ // 计算进度
288
+ var totalProgress = progressValue / _this4.scene.modelCount;
289
+ sendToMessage({
290
+ messageType: MessageType.Event,
291
+ messageName: 'onProgress',
292
+ status: EMessageStatus.Success,
293
+ global: false
294
+ }, {
295
+ progress: totalProgress,
296
+ state: _this4.action
297
+ });
298
+ });
299
+ } else {
232
300
  sendToMessage({
233
301
  messageType: MessageType.Event,
234
302
  messageName: 'onProgress',
235
303
  status: EMessageStatus.Success,
236
304
  global: false
237
305
  }, {
238
- progress: totalProgress,
306
+ progress: 1,
239
307
  state: this.action
240
308
  });
241
- });
242
- } else {
243
- sendToMessage({
244
- messageType: MessageType.Event,
245
- messageName: 'onProgress',
246
- status: EMessageStatus.Success,
247
- global: false
248
- }, {
249
- progress: 1,
250
- state: this.action
251
- });
309
+ }
252
310
  }
253
- }
254
311
 
255
- // 获取节点参数
256
- setMaterialParams(node) {
257
- const {
258
- materials
259
- } = node;
260
- // 处理材质节点
261
- if (materials) {
262
- const updatedMaterials = materials.map(item => {
263
- const material = this.getMaterialNode(item.material);
264
- if (material) return _objectSpread(_objectSpread({}, item), {}, {
265
- materialId: material.materialId
266
- });
267
- }).filter(Boolean);
268
- node.override = {
269
- materials: updatedMaterials
270
- };
312
+ // 获取节点参数
313
+ }, {
314
+ key: "setMaterialParams",
315
+ value: function setMaterialParams(node) {
316
+ var _this5 = this;
317
+ var materials = node.materials;
318
+ // 处理材质节点
319
+ if (materials) {
320
+ var updatedMaterials = materials.map(function (item) {
321
+ var material = _this5.getMaterialNode(item.material);
322
+ if (material) return _objectSpread(_objectSpread({}, item), {}, {
323
+ materialId: material.materialId
324
+ });
325
+ }).filter(Boolean);
326
+ node.override = {
327
+ materials: updatedMaterials
328
+ };
329
+ }
271
330
  }
272
- }
273
- getMaterialNode(index) {
274
- const materials = this.json.materials;
275
- return materials && materials.length > index ? materials[index] : null;
276
- }
277
- isEnumValue(enumObj, value) {
278
- return Object.values(enumObj).includes(value);
279
- }
280
- timeToRange2400(time) {
281
- // 检查输入时间格式是否正确,包括 24:00
282
- const timePattern = /^(?:([01]?\d|2[0-3]):([0-5]\d)|24:00)$/;
283
- if (!timePattern.test(time)) {
284
- console.error('Invalid time format. Please use "HH:MM" format.');
285
- return null;
331
+ }, {
332
+ key: "getMaterialNode",
333
+ value: function getMaterialNode(index) {
334
+ var materials = this.json.materials;
335
+ return materials && materials.length > index ? materials[index] : null;
286
336
  }
337
+ }, {
338
+ key: "isEnumValue",
339
+ value: function isEnumValue(enumObj, value) {
340
+ return Object.values(enumObj).includes(value);
341
+ }
342
+ }, {
343
+ key: "timeToRange2400",
344
+ value: function timeToRange2400(time) {
345
+ // 检查输入时间格式是否正确,包括 24:00
346
+ var timePattern = /^(?:([01]?\d|2[0-3]):([0-5]\d)|24:00)$/;
347
+ if (!timePattern.test(time)) {
348
+ console.error('Invalid time format. Please use "HH:MM" format.');
349
+ return null;
350
+ }
287
351
 
288
- // 分离小时和分钟
289
- const [hour, minute] = time.split(':').map(Number);
352
+ // 分离小时和分钟
353
+ var _time$split$map = time.split(':').map(Number),
354
+ _time$split$map2 = _slicedToArray(_time$split$map, 2),
355
+ hour = _time$split$map2[0],
356
+ minute = _time$split$map2[1];
290
357
 
291
- // 特殊处理 24:00
292
- if (hour === 24 && minute === 0) return {
293
- hour,
294
- minute,
295
- dateTime: 2400
296
- };
358
+ // 特殊处理 24:00
359
+ if (hour === 24 && minute === 0) return {
360
+ hour: hour,
361
+ minute: minute,
362
+ dateTime: 2400
363
+ };
297
364
 
298
- // 计算转换后的值
299
- const dateTime = hour * 100 + minute / 60 * 100;
300
- return {
301
- hour,
302
- minute,
303
- dateTime
304
- };
305
- }
365
+ // 计算转换后的值
366
+ var dateTime = hour * 100 + minute / 60 * 100;
367
+ return {
368
+ hour: hour,
369
+ minute: minute,
370
+ dateTime: dateTime
371
+ };
372
+ }
306
373
 
307
- // 清除场景所有对象
308
- clear() {
309
- var _this3 = this;
310
- return _asyncToGenerator(function* () {
311
- var _this3$scene$nodes;
312
- const result = (_this3$scene$nodes = _this3.scene.nodes) === null || _this3$scene$nodes === void 0 ? void 0 : _this3$scene$nodes.map( /*#__PURE__*/function () {
313
- var _ref = _asyncToGenerator(function* (node) {
314
- const isDefineType = _this3.isEnumValue(EObjectType, node.type);
315
- const nodeObject = isDefineType ? _this3.app[node.type] : _this3.app[EObjectType.entity];
316
- return nodeObject.delete(node);
317
- });
318
- return function (_x) {
319
- return _ref.apply(this, arguments);
320
- };
321
- }());
322
- _this3.setEnvironment({
323
- weather: {
324
- type: 'Sunny'
325
- },
326
- time: {
327
- value: '12:00'
328
- }
329
- });
330
- _this3.modelProgress.clear();
331
- return Promise.all(result);
332
- })();
333
- }
334
- }
374
+ // 清除场景所有对象
375
+ }, {
376
+ key: "clear",
377
+ value: function () {
378
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
379
+ var _this$scene$nodes,
380
+ _this6 = this;
381
+ var result;
382
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
383
+ while (1) switch (_context4.prev = _context4.next) {
384
+ case 0:
385
+ result = (_this$scene$nodes = this.scene.nodes) === null || _this$scene$nodes === void 0 ? void 0 : _this$scene$nodes.map( /*#__PURE__*/function () {
386
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(node) {
387
+ var isDefineType, nodeObject;
388
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
389
+ while (1) switch (_context3.prev = _context3.next) {
390
+ case 0:
391
+ isDefineType = _this6.isEnumValue(EObjectType, node.type);
392
+ nodeObject = isDefineType ? _this6.app[node.type] : _this6.app[EObjectType.entity];
393
+ return _context3.abrupt("return", nodeObject.delete(node));
394
+ case 3:
395
+ case "end":
396
+ return _context3.stop();
397
+ }
398
+ }, _callee3);
399
+ }));
400
+ return function (_x3) {
401
+ return _ref2.apply(this, arguments);
402
+ };
403
+ }());
404
+ this.setEnvironment({
405
+ weather: {
406
+ type: 'Sunny'
407
+ },
408
+ time: {
409
+ value: '12:00'
410
+ }
411
+ });
412
+ this.modelProgress.clear();
413
+ return _context4.abrupt("return", Promise.all(result));
414
+ case 4:
415
+ case "end":
416
+ return _context4.stop();
417
+ }
418
+ }, _callee4, this);
419
+ }));
420
+ function clear() {
421
+ return _clear.apply(this, arguments);
422
+ }
423
+ return clear;
424
+ }()
425
+ }]);
426
+ return FileParse;
427
+ }();
335
428
  export default FileParse;
336
429
  //# sourceMappingURL=fileParse.js.map