@anov/3d 0.0.286 → 0.0.288

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