@anov/3d 0.0.177 → 0.0.185

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 (139) hide show
  1. package/dist/anov3d.js +0 -2
  2. package/dist/anov3d.js.map +1 -1
  3. package/dist/applicationApi.js +38 -39
  4. package/dist/applicationApi.js.map +1 -1
  5. package/dist/module/camera/index.js +20 -17
  6. package/dist/module/camera/index.js.map +1 -1
  7. package/dist/module/entity/area/index.js +29 -0
  8. package/dist/module/entity/area/index.js.map +1 -0
  9. package/dist/module/{model/index.js → entity/area/style/area_01.js} +40 -79
  10. package/dist/module/entity/area/style/area_01.js.map +1 -0
  11. package/dist/module/entity/area/style/index.js +27 -0
  12. package/dist/module/entity/area/style/index.js.map +1 -0
  13. package/dist/module/entity/area/type.js.map +1 -0
  14. package/dist/module/entity/bar/index.js +29 -0
  15. package/dist/module/entity/bar/index.js.map +1 -0
  16. package/dist/{factory/unit/poi.js → module/entity/bar/style/bar_01.js} +36 -249
  17. package/dist/module/entity/bar/style/bar_01.js.map +1 -0
  18. package/dist/module/entity/bar/style/index.js +27 -0
  19. package/dist/module/entity/bar/style/index.js.map +1 -0
  20. package/dist/module/entity/bar/type.js +2 -0
  21. package/dist/module/entity/bar/type.js.map +1 -0
  22. package/dist/module/entity/baseEntity.js +1 -1
  23. package/dist/module/entity/baseEntity.js.map +1 -1
  24. package/dist/module/entity/index.js +5 -12
  25. package/dist/module/entity/index.js.map +1 -1
  26. package/dist/module/entity/model/index.js +9 -6
  27. package/dist/module/entity/model/index.js.map +1 -1
  28. package/dist/module/entity/model/load/loadFbx.js.map +1 -1
  29. package/dist/module/entity/model/load/loadGlb.js +7 -4
  30. package/dist/module/entity/model/load/loadGlb.js.map +1 -1
  31. package/dist/module/entity/poi/style/base.js.map +1 -1
  32. package/dist/module/entity/poi/style/index.js +40 -0
  33. package/dist/module/entity/poi/style/index.js.map +1 -1
  34. package/dist/module/entity/poi/type.js.map +1 -1
  35. package/dist/{factory/unit/districtLine.js → module/entity/realismTraffic/index.js} +91 -109
  36. package/dist/module/entity/realismTraffic/index.js.map +1 -0
  37. package/dist/module/entity/spline/style/index.js.map +1 -1
  38. package/dist/module/entity/spline/style/line_01.js +2 -2
  39. package/dist/module/entity/spline/style/line_01.js.map +1 -1
  40. package/dist/module/entity/spline/style/line_texture_01.js +6 -6
  41. package/dist/module/entity/spline/style/line_texture_01.js.map +1 -1
  42. package/dist/module/entity/spline/type.js.map +1 -1
  43. package/dist/module/entity/strategy.js +22 -0
  44. package/dist/module/entity/strategy.js.map +1 -1
  45. package/dist/module/entity/utils.js +17 -0
  46. package/dist/module/entity/utils.js.map +1 -1
  47. package/dist/module/environment/index.js +35 -113
  48. package/dist/module/environment/index.js.map +1 -1
  49. package/dist/module/scene/fileParse.js +232 -132
  50. package/dist/module/scene/fileParse.js.map +1 -1
  51. package/dist/module/scene/index.js +84 -137
  52. package/dist/module/scene/index.js.map +1 -1
  53. package/dist/{factory/globalControl.js → module/tool/index.js} +8 -16
  54. package/dist/module/tool/index.js.map +1 -0
  55. package/dist/sdkEntry.js +4 -9
  56. package/dist/sdkEntry.js.map +1 -1
  57. package/package.json +3 -3
  58. package/dist/factory/3d.js +0 -535
  59. package/dist/factory/3d.js.map +0 -1
  60. package/dist/factory/globalControl.js.map +0 -1
  61. package/dist/factory/globalData.js +0 -2
  62. package/dist/factory/globalData.js.map +0 -1
  63. package/dist/factory/regionData.js +0 -499
  64. package/dist/factory/regionData.js.map +0 -1
  65. package/dist/factory/type.js.map +0 -1
  66. package/dist/factory/unit/CameraPoi.js +0 -1047
  67. package/dist/factory/unit/CameraPoi.js.map +0 -1
  68. package/dist/factory/unit/areaBoundingBox.js +0 -28
  69. package/dist/factory/unit/areaBoundingBox.js.map +0 -1
  70. package/dist/factory/unit/circle.js +0 -225
  71. package/dist/factory/unit/circle.js.map +0 -1
  72. package/dist/factory/unit/cylinder.js +0 -269
  73. package/dist/factory/unit/cylinder.js.map +0 -1
  74. package/dist/factory/unit/districtLine.js.map +0 -1
  75. package/dist/factory/unit/glsl/heat/frag.glsl +0 -37
  76. package/dist/factory/unit/glsl/heat/frag.js +0 -4
  77. package/dist/factory/unit/glsl/heat/frag.js.map +0 -1
  78. package/dist/factory/unit/glsl/heat/ver.glsl +0 -15
  79. package/dist/factory/unit/glsl/heat/ver.js +0 -4
  80. package/dist/factory/unit/glsl/heat/ver.js.map +0 -1
  81. package/dist/factory/unit/glsl/highway/fragmentShader.js +0 -4
  82. package/dist/factory/unit/glsl/highway/fragmentShader.js.map +0 -1
  83. package/dist/factory/unit/glsl/highway/fragmentShader2.js +0 -4
  84. package/dist/factory/unit/glsl/highway/fragmentShader2.js.map +0 -1
  85. package/dist/factory/unit/glsl/highway/vertexShader.js +0 -4
  86. package/dist/factory/unit/glsl/highway/vertexShader.js.map +0 -1
  87. package/dist/factory/unit/glsl/point/fragment.glsl +0 -12
  88. package/dist/factory/unit/glsl/point/vertex.glsl +0 -7
  89. package/dist/factory/unit/glsl/wall/fragmentShader.glsl +0 -30
  90. package/dist/factory/unit/glsl/wall/vertexShader.glsl +0 -6
  91. package/dist/factory/unit/handle.js +0 -132
  92. package/dist/factory/unit/handle.js.map +0 -1
  93. package/dist/factory/unit/index.js +0 -264
  94. package/dist/factory/unit/index.js.map +0 -1
  95. package/dist/factory/unit/inspection/InspectionObject.js +0 -608
  96. package/dist/factory/unit/inspection/InspectionObject.js.map +0 -1
  97. package/dist/factory/unit/inspection/defaultFirstPerspectiveControls.js +0 -382
  98. package/dist/factory/unit/inspection/defaultFirstPerspectiveControls.js.map +0 -1
  99. package/dist/factory/unit/inspection/index.js +0 -379
  100. package/dist/factory/unit/inspection/index.js.map +0 -1
  101. package/dist/factory/unit/inspection/lineData.js +0 -44
  102. package/dist/factory/unit/inspection/lineData.js.map +0 -1
  103. package/dist/factory/unit/inspection/map.js +0 -67
  104. package/dist/factory/unit/inspection/map.js.map +0 -1
  105. package/dist/factory/unit/inspection/tubeGeometry.js +0 -152
  106. package/dist/factory/unit/inspection/tubeGeometry.js.map +0 -1
  107. package/dist/factory/unit/layer/rise.js +0 -142
  108. package/dist/factory/unit/layer/rise.js.map +0 -1
  109. package/dist/factory/unit/line.js +0 -96
  110. package/dist/factory/unit/line.js.map +0 -1
  111. package/dist/factory/unit/poi.js.map +0 -1
  112. package/dist/factory/unit/region.js +0 -72
  113. package/dist/factory/unit/region.js.map +0 -1
  114. package/dist/factory/unit/slice.js +0 -122
  115. package/dist/factory/unit/slice.js.map +0 -1
  116. package/dist/factory/unit/wall.js +0 -119
  117. package/dist/factory/unit/wall.js.map +0 -1
  118. package/dist/factory/utils/areaBoundingBox.js +0 -54
  119. package/dist/factory/utils/areaBoundingBox.js.map +0 -1
  120. package/dist/factory/utils/constant.js +0 -15
  121. package/dist/factory/utils/constant.js.map +0 -1
  122. package/dist/factory/utils/finirMaterial.js +0 -56
  123. package/dist/factory/utils/finirMaterial.js.map +0 -1
  124. package/dist/factory/utils/fontMesh.js +0 -49
  125. package/dist/factory/utils/fontMesh.js.map +0 -1
  126. package/dist/factory/utils/ground.js +0 -65
  127. package/dist/factory/utils/ground.js.map +0 -1
  128. package/dist/factory/utils/index.js +0 -24
  129. package/dist/factory/utils/index.js.map +0 -1
  130. package/dist/factory/utils/observe.js +0 -23
  131. package/dist/factory/utils/observe.js.map +0 -1
  132. package/dist/factory/utils/switchMaterial.js +0 -110
  133. package/dist/factory/utils/switchMaterial.js.map +0 -1
  134. package/dist/module/environment/time/index.js +0 -28
  135. package/dist/module/environment/time/index.js.map +0 -1
  136. package/dist/module/environment/weather/type.js +0 -28
  137. package/dist/module/environment/weather/type.js.map +0 -1
  138. package/dist/module/model/index.js.map +0 -1
  139. /package/dist/{factory → module/entity/area}/type.js +0 -0
@@ -1,1047 +0,0 @@
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; }
3
- 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
- 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); }); }; }
5
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
- 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); } }
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
- 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; }
9
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
- 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); }
11
- import { AdditiveBlending, Box3, CircleGeometry, Clock, Color, DoubleSide, Group, MathUtils, Matrix4, Mesh, MeshBasicMaterial, ModelLoader, PerspectiveCamera, PlaneGeometry, ShaderMaterial, Sprite, SpriteMaterial, Texture, TextureLoader, Vector3, gsap, use } from '@anov/3d-core';
12
- import { Css2DPoi, SpritePoi } from '@anov/3d-ability';
13
- import heatMap from 'anov-heat-map';
14
- import { MessageType, sendToMessage } from "../../utils/messageFn";
15
- import { EMessageStatus } from "../../messageStatus";
16
- import { loadingManager, usePath } from "../3d";
17
-
18
- // @ts-ignore
19
-
20
- var data = {
21
- camera: [{
22
- id: '1',
23
- name: '摄像头1',
24
- position: [-315, 30, -150],
25
- fovDefault: 60,
26
- fovRange: [30, 120],
27
- dialogCamera: {
28
- position: [-315, 30, -150],
29
- rotation: [30, 180, 0]
30
- }
31
- }, {
32
- id: '2',
33
- name: '摄像头2',
34
- position: [30, 30, -150],
35
- fovDefault: 60,
36
- fovRange: [30, 120],
37
- dialogCamera: {
38
- position: [30, 30, -150],
39
- rotation: [30, 180, 0]
40
- }
41
- }, {
42
- id: '3',
43
- name: '摄像头3',
44
- position: [360, 30, -150],
45
- fovDefault: 60,
46
- fovRange: [30, 120],
47
- dialogCamera: {
48
- position: [360, 30, -150],
49
- rotation: [30, 180, 0]
50
- }
51
- }, {
52
- id: '4',
53
- name: '摄像头4',
54
- position: [-320, 30, 32],
55
- dialogCamera: {
56
- position: [-320, 30, 32],
57
- rotation: [30, 180, 0]
58
- }
59
- }, {
60
- id: '5',
61
- name: '摄像头5',
62
- position: [-307, 30, 170],
63
- fovDefault: 60,
64
- fovRange: [30, 120],
65
- dialogCamera: {
66
- position: [-307, 30, 170],
67
- rotation: [30, 180, 0]
68
- }
69
- }, {
70
- id: '6',
71
- name: '摄像头6',
72
- position: [77, 30, 96],
73
- fovDefault: 60,
74
- fovRange: [30, 120],
75
- dialogCamera: {
76
- position: [77, 30, 96],
77
- rotation: [30, 180, 0]
78
- }
79
- }, {
80
- id: '7',
81
- name: '摄像头7',
82
- position: [404, 30, 85],
83
- fovDefault: 60,
84
- fovRange: [30, 120],
85
- dialogCamera: {
86
- position: [404, 30, 85],
87
- rotation: [30, 180, 0]
88
- }
89
- }],
90
- probePoint: [{
91
- id: '1',
92
- name: '异常监测点1',
93
- warn: true,
94
- position: [56, 21, 86]
95
- }, {
96
- id: '2',
97
- name: '甲烷监测点2',
98
- warn: false,
99
- position: [384, 21, 75]
100
- }, {
101
- id: '3',
102
- name: '甲烷监测点3',
103
- warn: false,
104
- position: [9, 21, -134]
105
- }]
106
- };
107
- var load = new ModelLoader();
108
- var CameraPoi = /*#__PURE__*/function () {
109
- function CameraPoi(gobal) {
110
- _classCallCheck(this, CameraPoi);
111
- _defineProperty(this, "gobal", void 0);
112
- _defineProperty(this, "cameraMesh", new Map());
113
- _defineProperty(this, "warnMesh", new Map());
114
- _defineProperty(this, "headMap", void 0);
115
- _defineProperty(this, "dialogManage", void 0);
116
- _defineProperty(this, "eventListener", new Set());
117
- _defineProperty(this, "currentDialogMesh", void 0);
118
- _defineProperty(this, "startPosition", void 0);
119
- _defineProperty(this, "cameraLookAt", void 0);
120
- this.gobal = gobal;
121
- this.dialogManage = new Dialog(this);
122
- this.dialogManage.addStyle();
123
- }
124
- _createClass(CameraPoi, [{
125
- key: "generateObject",
126
- value: function () {
127
- var _generateObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
128
- var _this = this,
129
- _data$probePoint;
130
- var model, point, rotatingRight, unFrame;
131
- return _regeneratorRuntime().wrap(function _callee$(_context) {
132
- while (1) switch (_context.prev = _context.next) {
133
- case 0:
134
- _context.next = 2;
135
- return load.loadGLTF("".concat(usePath, "shexiang.glb"), false, true, './draco/', function (gltf) {
136
- return gltf;
137
- });
138
- case 2:
139
- model = _context.sent;
140
- data.camera.forEach(function (region) {
141
- var group = new Group();
142
- group.name = region.id;
143
- var sprite = new SpritePoi("".concat(usePath, "p4/camera.png"), {
144
- scale: [22, 22, 1]
145
- });
146
- sprite.rotation.y = Math.PI;
147
- var position = new Vector3().fromArray(region.position);
148
- sprite.position.copy(position);
149
- group.add(sprite);
150
- var scan = model.scene.clone();
151
- scan.scale.addScalar(8);
152
- scan.rotation.x = -Math.PI / 2 + 0.5;
153
- scan.position.copy(position.clone().add(new Vector3(0, -2, 0)));
154
- group.add(scan);
155
- _this.cameraMesh.set(region.name, group);
156
- _this.cameraEvent(group, region);
157
- _this.gobal.scene.add(group);
158
- });
159
-
160
- // 甲烷检测点
161
- point = new MethanePoint();
162
- (_data$probePoint = data.probePoint) === null || _data$probePoint === void 0 || _data$probePoint.forEach(function (item) {
163
- var mesh;
164
- if (item.warn) {
165
- mesh = new SpritePoi("".concat(usePath, "p4/warn.png"), {
166
- scale: [22, 22, 1]
167
- });
168
- _this.probeEvent(mesh, item);
169
- // 使用GSAP创建跳动动画
170
- gsap.to(mesh.position, {
171
- y: '+=3',
172
- // 上跳10个单位
173
- duration: 0.2,
174
- // 动画持续时间
175
- ease: 'power1.inOut',
176
- // 缓动函数
177
- yoyo: true,
178
- // 循环
179
- repeat: -1 // 无限重复
180
- });
181
- } else {
182
- mesh = point.create();
183
- }
184
- mesh.position.copy(new Vector3().fromArray(item.position));
185
- _this.warnMesh.set(item.name, mesh);
186
- _this.gobal.scene.add(mesh);
187
- });
188
- // 设置左右旋转的标志位和旋转速度
189
- rotatingRight = true; // 是否正在向右转动
190
- unFrame = use.useframe(function () {
191
- _this.cameraMesh.forEach(function (group) {
192
- var scan = group.children[1];
193
- // 更新相机的旋转角度
194
- if (rotatingRight) {
195
- // 向右旋转
196
- scan.rotation.z += 0.005;
197
- } else {
198
- // 向左旋转
199
- scan.rotation.z -= 0.005;
200
- }
201
-
202
- // 检查是否达到目标旋转角度
203
- if (Math.abs(scan.rotation.z) >= Math.abs(Math.PI / 4)) {
204
- // 到达目标角度,切换旋转方向并更新目标角度
205
- rotatingRight = !rotatingRight;
206
- }
207
- });
208
- });
209
- this.eventListener.add(unFrame);
210
- case 9:
211
- case "end":
212
- return _context.stop();
213
- }
214
- }, _callee, this);
215
- }));
216
- function generateObject() {
217
- return _generateObject.apply(this, arguments);
218
- }
219
- return generateObject;
220
- }()
221
- }, {
222
- key: "cameraEvent",
223
- value: function cameraEvent(sprite, region) {
224
- var _this2 = this;
225
- var fn = /*#__PURE__*/function () {
226
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
227
- var isClose, _use$useScene, camera, position, targetPosition, camaraPosition;
228
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
229
- while (1) switch (_context2.prev = _context2.next) {
230
- case 0:
231
- if (!_this2.currentDialogMesh) {
232
- _context2.next = 7;
233
- break;
234
- }
235
- isClose = _this2.currentDialogMesh.name === region.name;
236
- _this2.dialogManage.close();
237
- if (!isClose) {
238
- _context2.next = 5;
239
- break;
240
- }
241
- return _context2.abrupt("return");
242
- case 5:
243
- _context2.next = 8;
244
- break;
245
- case 7:
246
- if (_this2.headMap && _this2.headMap.isShow) {
247
- _this2.closeHotmap();
248
- } else {
249
- _use$useScene = use.useScene(), camera = _use$useScene.camera;
250
- _this2.startPosition = camera.position.clone();
251
- // 获取相机朝向
252
- _this2.cameraLookAt = new Vector3(); // 创建一个向量来存储相机朝向
253
- camera.getWorldDirection(_this2.cameraLookAt); // 获取相机朝向并存储在向量中
254
- }
255
- case 8:
256
- sendToMessage({
257
- messageType: MessageType.Event,
258
- messageName: 'onCameraStatus',
259
- status: EMessageStatus.Success
260
- }, {
261
- id: region.id
262
- });
263
- position = new Vector3().fromArray(region.position);
264
- targetPosition = position.clone().toArray();
265
- camaraPosition = position.clone().add(new Vector3(0, 40, 80)).toArray();
266
- _this2.gobal.cameraUtil.set({
267
- position: camaraPosition,
268
- target: targetPosition
269
- });
270
- _this2.setMeshVisible(false);
271
- _context2.next = 16;
272
- return _this2.dialogManage.getMesh(position, region);
273
- case 16:
274
- _this2.currentDialogMesh = _context2.sent;
275
- _this2.dialogManage.addEventListener('close', function () {
276
- // 初始相机到原始位置
277
- _this2.gobal.cameraUtil.set({
278
- position: _this2.startPosition.toArray(),
279
- target: _this2.cameraLookAt.toArray()
280
- });
281
- _this2.setMeshVisible(true);
282
- _this2.currentDialogMesh = null;
283
- _this2.cameraMesh.forEach(function (mesh) {
284
- mesh.visible = true;
285
- });
286
- sendToMessage({
287
- messageType: MessageType.Event,
288
- messageName: 'onCancelCameraStatus',
289
- status: EMessageStatus.Success
290
- }, {
291
- id: region.id
292
- });
293
- });
294
- _this2.currentDialogMesh.name = region.name;
295
- _this2.gobal.scene.add(_this2.currentDialogMesh);
296
- case 20:
297
- case "end":
298
- return _context2.stop();
299
- }
300
- }, _callee2);
301
- }));
302
- return function fn() {
303
- return _ref.apply(this, arguments);
304
- };
305
- }();
306
- sprite.addEventListener('click', fn);
307
- this.eventListener.add(function () {
308
- return sprite.removeEventListener('click', fn);
309
- });
310
- }
311
- }, {
312
- key: "probeEvent",
313
- value: function probeEvent(sprite, region) {
314
- var _this3 = this;
315
- var _use$useScene2 = use.useScene(),
316
- camera = _use$useScene2.camera;
317
- this.headMap = new HeadMap();
318
- var unClick = sprite.addEventListener('click', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
319
- var position, camaraPosition;
320
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
321
- while (1) switch (_context3.prev = _context3.next) {
322
- case 0:
323
- if (sprite.visible) {
324
- _context3.next = 2;
325
- break;
326
- }
327
- return _context3.abrupt("return");
328
- case 2:
329
- sprite.visible = false;
330
- sendToMessage({
331
- messageType: MessageType.Event,
332
- messageName: 'onGasMonitorStatus',
333
- status: EMessageStatus.Success
334
- }, {
335
- id: region.id
336
- });
337
- _this3.togglePoi(false);
338
- position = new Vector3().fromArray(region.position);
339
- camaraPosition = position.clone().add(new Vector3(0, 30, 0));
340
- _this3.startPosition = camera.position.clone();
341
- // 获取相机朝向
342
- _this3.cameraLookAt = new Vector3(); // 创建一个向量来存储相机朝向
343
- camera.getWorldDirection(_this3.cameraLookAt); // 获取相机朝向并存储在向量中
344
- _this3.gobal.cameraUtil.set({
345
- position: camaraPosition.toArray(),
346
- target: position.clone().toArray()
347
- }).then(function () {
348
- var mesh = _this3.headMap.create(camaraPosition.distanceTo(position));
349
- mesh.position.copy(sprite.position);
350
- mesh.position.y = 0.5;
351
- _this3.gobal.scene.add(mesh);
352
- var _use$useScene3 = use.useScene(),
353
- orbitControls = _use$useScene3.orbitControls;
354
- orbitControls.enabled = false;
355
-
356
- // this.headMap.addBack()
357
- _this3.headMap.addEventListener('close', function () {
358
- _this3.closeHotmap();
359
- // this.togglePoi(true)
360
-
361
- // this.gobal.cameraUtil.set({
362
- // position: this.startPosition.toArray(),
363
- // target: this.cameraLookAt.toArray(),
364
- // })
365
- });
366
- });
367
- case 11:
368
- case "end":
369
- return _context3.stop();
370
- }
371
- }, _callee3);
372
- })));
373
- this.eventListener.add(unClick);
374
- }
375
- }, {
376
- key: "setMeshVisible",
377
- value: function setMeshVisible(visible) {
378
- this.cameraMesh.forEach(function (mesh) {
379
- return mesh.visible = visible;
380
- });
381
- this.warnMesh.forEach(function (mesh) {
382
- return mesh.visible = visible;
383
- });
384
- }
385
- }, {
386
- key: "closeHotmap",
387
- value: function closeHotmap() {
388
- if (!this.headMap) return;
389
- this.headMap.remove();
390
- this.togglePoi(true);
391
- this.gobal.cameraUtil.set({
392
- position: this.startPosition.toArray(),
393
- target: this.cameraLookAt.toArray()
394
- });
395
- var _use$useScene4 = use.useScene(),
396
- orbitControls = _use$useScene4.orbitControls;
397
- orbitControls.enabled = true;
398
- }
399
- }, {
400
- key: "togglePoi",
401
- value: function togglePoi() {
402
- var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
403
- this.warnMesh.forEach(function (sprite) {
404
- sprite.visible = visible;
405
- });
406
- this.cameraMesh.forEach(function (sprite) {
407
- sprite.visible = visible;
408
- });
409
- }
410
- }, {
411
- key: "remove",
412
- value: function remove() {
413
- this.dialogManage.close();
414
- // 删除摄像机POI点
415
- this.cameraMesh.forEach(function (sprite) {
416
- sprite.removeFromParent();
417
- sprite.remove();
418
- });
419
- this.cameraMesh.clear();
420
- this.warnMesh.forEach(function (sprite) {
421
- sprite.removeFromParent();
422
- sprite.remove();
423
- });
424
- this.warnMesh.clear();
425
- this.eventListener.forEach(function (fn) {
426
- fn();
427
- });
428
- // 热力图
429
- if (this.headMap) {
430
- this.headMap.remove();
431
- var _use$useScene5 = use.useScene(),
432
- orbitControls = _use$useScene5.orbitControls;
433
- orbitControls.enabled = true;
434
- }
435
- this.eventListener.clear();
436
- }
437
- }]);
438
- return CameraPoi;
439
- }();
440
- export default CameraPoi;
441
- var MethanePoint = /*#__PURE__*/function () {
442
- function MethanePoint() {
443
- _classCallCheck(this, MethanePoint);
444
- }
445
- _createClass(MethanePoint, [{
446
- key: "create",
447
- value: function create() {
448
- // 定义Shader的uniform变量
449
-
450
- var geometry = new PlaneGeometry(10, 10);
451
- var texture = new TextureLoader(loadingManager).load("".concat(usePath, "p4/monitor.png"));
452
- var circle = new Mesh(geometry, new MeshBasicMaterial({
453
- map: texture,
454
- side: DoubleSide,
455
- transparent: true
456
- }));
457
- circle.rotateX(-Math.PI / 3);
458
- return circle;
459
- }
460
-
461
- // 随机多点的方案
462
- }, {
463
- key: "createBack",
464
- value: function createBack() {
465
- // 定义Shader的uniform变量
466
-
467
- var group = new Group();
468
- var geometry = new CircleGeometry(2, 32);
469
- // 创建自定义着色器材质
470
- var material = new ShaderMaterial({
471
- vertexShader: "\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n gl_PointSize = 20.0; // \u8BBE\u7F6E\u70B9\u7684\u5927\u5C0F\n }\n ",
472
- fragmentShader: "\n void main() {\n vec2 center = vec2(0.5, 0.5); // \u5706\u5FC3\u5750\u6807\n vec2 toCenter = gl_PointCoord - center; // \u8BA1\u7B97\u70B9\u5230\u5706\u5FC3\u7684\u5411\u91CF\n float distance = length(toCenter); // \u8BA1\u7B97\u70B9\u5230\u5706\u5FC3\u7684\u8DDD\u79BB\n if (distance > 0.5) discard; // \u8D85\u51FA\u534A\u5F84\u8303\u56F4\u7684\u70B9\u76F4\u63A5\u4E22\u5F03\n vec3 innerColor = vec3(1.0, .8, 0.0); // \u5185\u5708\u989C\u8272\u4E3A\u9EC4\u8272\n vec3 outerColor = vec3(0.8, 0.4, 0.0); // \u5916\u5708\u989C\u8272\u4E3A\u6DF1\u6A58\u8272\n \n vec3 finalColor = mix(innerColor, outerColor, smoothstep(0.1, 0.23, distance)); // \u6839\u636E\u8DDD\u79BB\u6DF7\u5408\u989C\u8272\n if(distance>0.3) finalColor = mix(finalColor, vec3(0.75, 0.4, 0.0), smoothstep(0.25, 0.3, distance)); // \u6839\u636E\u8DDD\u79BB\u6DF7\u5408\u989C\u8272\n gl_FragColor = vec4(finalColor, 1.0); // \u8BBE\u7F6E\u7247\u6BB5\u989C\u8272\n }\n ",
473
- blending: AdditiveBlending,
474
- depthTest: false,
475
- transparent: true,
476
- side: DoubleSide
477
- });
478
- var circle = new Mesh(geometry, new MeshBasicMaterial({
479
- color: '#f7a157'
480
- }));
481
- var numPoints = 100; // 点的数量
482
-
483
- for (var i = 0; i < numPoints; i++) {
484
- var x = Math.random() * 700 - 322; // 随机生成 x 坐标
485
- var z = Math.random() * 340 - 144; // 随机生成 z 坐标
486
- var point = circle.clone();
487
- point.position.copy(new Vector3(x, 20.55, z));
488
- point.rotateX(-Math.PI / 2);
489
- group.add(point);
490
- }
491
- return group;
492
- }
493
- }]);
494
- return MethanePoint;
495
- }();
496
- var Dialog = /*#__PURE__*/function () {
497
- function Dialog(cameraManage) {
498
- _classCallCheck(this, Dialog);
499
- _defineProperty(this, "manage", void 0);
500
- _defineProperty(this, "camera", void 0);
501
- _defineProperty(this, "cameraPosition", void 0);
502
- _defineProperty(this, "cameraTargetPosition", void 0);
503
- _defineProperty(this, "cuteSprites", []);
504
- _defineProperty(this, "eventListener", new Set());
505
- _defineProperty(this, "eventList", new Map());
506
- this.manage = cameraManage;
507
- }
508
- _createClass(Dialog, [{
509
- key: "getMesh",
510
- value: function () {
511
- var _getMesh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(position, careraParams) {
512
- var _this4 = this;
513
- var _this$manage$gobal$sc, texture, close, cuteSprite, unFrame;
514
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
515
- while (1) switch (_context4.prev = _context4.next) {
516
- case 0:
517
- this.close();
518
- this.camera = new PerspectiveCamera(careraParams.fovDefault || 60, window.innerWidth / window.innerHeight, 0.1, 10000);
519
- this.camera.position.copy(new Vector3().fromArray(careraParams.position));
520
- this.camera.rotation.set(Math.PI / 6, Math.PI, 0);
521
- _this$manage$gobal$sc = this.manage.gobal.scene.setCustomPerspective(this.camera), texture = _this$manage$gobal$sc.texture, close = _this$manage$gobal$sc.close;
522
- cuteSprite = new Sprite(new SpriteMaterial({
523
- map: texture,
524
- depthTest: false,
525
- depthWrite: false
526
- }));
527
- cuteSprite.center.set(0.5, 0.5);
528
- cuteSprite.renderOrder = 5;
529
- cuteSprite.position.copy(position);
530
- unFrame = use.useframe(function () {
531
- _this4.updateScale(cuteSprite);
532
- });
533
- this.eventListener.add(unFrame);
534
- return _context4.abrupt("return", new Promise(function (reslove) {
535
- setTimeout(function () {
536
- var borderMesh = _this4.getBorderMesh(_this4.camera, cuteSprite);
537
- var group = new Group();
538
- group.add(borderMesh);
539
- group.add(cuteSprite);
540
- _this4.cuteSprites.push(borderMesh);
541
- _this4.cuteSprites.push(cuteSprite);
542
- close();
543
- reslove(group);
544
- }, 1000);
545
- }));
546
- case 12:
547
- case "end":
548
- return _context4.stop();
549
- }
550
- }, _callee4, this);
551
- }));
552
- function getMesh(_x, _x2) {
553
- return _getMesh.apply(this, arguments);
554
- }
555
- return getMesh;
556
- }()
557
- }, {
558
- key: "getTarget",
559
- value: function getTarget(cameraPosition) {
560
- var rotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 30, 0];
561
- // 将旋转角度转换为弧度
562
- var angleX = MathUtils.degToRad(rotation[0]);
563
- var angleY = MathUtils.degToRad(rotation[1]);
564
- var angleZ = MathUtils.degToRad(rotation[2]);
565
-
566
- // 创建旋转矩阵
567
- var rotationMatrix = new Matrix4();
568
- rotationMatrix.makeRotationX(angleX);
569
- rotationMatrix.multiply(new Matrix4().makeRotationY(angleY));
570
- rotationMatrix.multiply(new Matrix4().makeRotationZ(angleZ));
571
-
572
- // 定义相机的方向向量(例如,相机的方向默认为(0, 0, -1))
573
- var cameraDirection = new Vector3(0, 0, 1);
574
-
575
- // 将相机的方向向量乘以旋转矩阵,得到相机目标位置的向量
576
- var targetDirection = cameraDirection.clone().applyMatrix4(rotationMatrix);
577
-
578
- // 计算相机的目标位置
579
- return cameraPosition.clone().add(targetDirection);
580
- }
581
- }, {
582
- key: "getBoxSize",
583
- value: function getBoxSize(sprite) {
584
- var _use$useScene6 = use.useScene(),
585
- camera = _use$useScene6.camera;
586
-
587
- // 获取设备像素比
588
- var devicePixelRatio = window.devicePixelRatio || 1;
589
- // 获取精灵对象的边界框
590
- var bbox = new Box3().setFromObject(sprite);
591
- // 将边界框的最小和最大顶点转换为屏幕坐标
592
- var min = bbox.min.project(camera);
593
- var max = bbox.max.project(camera);
594
- console.log('min:', min);
595
- console.log('max:', max);
596
- var _ref3 = [window.innerWidth, window.innerHeight],
597
- w = _ref3[0],
598
- h = _ref3[1];
599
- var dom = document.querySelector('#app');
600
- if (dom) {
601
- w = dom.clientWidth;
602
- h = dom.clientHeight;
603
- }
604
- var ratio = 0;
605
- if (camera.fov >= 60) ratio = -0.05 * (camera.fov - 60) / 30;else ratio = 0.02 * (60 - camera.fov) / 30;
606
-
607
- // 计算精灵在屏幕中的宽度和高度像素值
608
- var width = (max.x - min.x) * w / devicePixelRatio * (0.97 + ratio);
609
- var height = (max.y - min.y) * h / devicePixelRatio * (1.089 + ratio);
610
- var scaleFactor = devicePixelRatio * 0.5;
611
- // 应用缩放系数
612
- width *= scaleFactor;
613
- height *= scaleFactor;
614
- return {
615
- width: width,
616
- height: height
617
- };
618
- }
619
- }, {
620
- key: "updateScale",
621
- value: function updateScale(sprite) {
622
- var _use$useScene7 = use.useScene(),
623
- camera = _use$useScene7.camera;
624
- var ratio = 60 / camera.fov;
625
- // 距离限制范围的值,用于计算缩放比例
626
- var minDistance = 0.1;
627
- var maxDistance = 1000000;
628
- // 获取相机和物体的世界坐标位置
629
- var cameraPosition = camera === null || camera === void 0 ? void 0 : camera.position;
630
- var objectPosition = sprite.position;
631
-
632
- // 计算相机和物体之间的距离
633
- var distance = (cameraPosition === null || cameraPosition === void 0 ? void 0 : cameraPosition.distanceTo(objectPosition)) || 0.1;
634
-
635
- // 使用 Math.min() 和 Math.max() 方法限制 resultDistance 的范围
636
- var clampedDistance = Math.max(minDistance, Math.min(maxDistance, distance));
637
- // console.log('clampedDistance:',clampedDistance)
638
- // 按照缩放系数和距离进行缩放,缩放系数应该约定好一个固定值
639
- sprite.scale.copy(new Vector3(clampedDistance * (1.3281 / ratio), 0.8316 / ratio * clampedDistance, 1));
640
- }
641
- }, {
642
- key: "addEventListener",
643
- value: function addEventListener(eventName, fn) {
644
- if (this.eventList.has(eventName)) this.eventList[eventName] = fn;else this.eventList.set(eventName, fn);
645
- }
646
- }, {
647
- key: "getBorderMesh",
648
- value: function getBorderMesh(camera, sprite) {
649
- var _this5 = this;
650
- var _this$getBoxSize = this.getBoxSize(sprite),
651
- width = _this$getBoxSize.width,
652
- height = _this$getBoxSize.height;
653
-
654
- // 弹窗容器
655
- var dialogDiv = document.createElement('div');
656
- width += 10;
657
- height += 10;
658
- Object.assign(dialogDiv.style, {
659
- 'width': "".concat(width, "px"),
660
- 'height': "".concat(height, "px"),
661
- 'z-index': '3 !important',
662
- 'backgroundImage': "url(".concat(usePath, "p4/border.png)"),
663
- 'backgroundSize': '100% 100%',
664
- 'backgroundRepeat': 'no-repeat',
665
- 'position': 'relative'
666
-
667
- // left: `${(window.innerWidth - width) / 2}px`,
668
- // top: `${(window.innerHeight - height) / 2}px`,
669
- });
670
- var maskingDiv = document.createElement('div');
671
- maskingDiv.className = 'dialog-mask';
672
- dialogDiv.appendChild(maskingDiv);
673
-
674
- // 关闭按钮
675
- var closeSpan = document.createElement('span');
676
- closeSpan.className = 'dialog-close';
677
- dialogDiv.appendChild(closeSpan);
678
- closeSpan.addEventListener('click', function () {
679
- _this5.close();
680
- });
681
-
682
- // 操作按钮
683
- var op = document.createElement('div');
684
- op.className = 'dialog-operate';
685
- dialogDiv.appendChild(op);
686
- var opList = ['left', 'right', 'top', 'bottom'];
687
- opList.forEach(function (key) {
688
- var btnSpan = document.createElement('span');
689
- btnSpan.className = "dialog-operate-btn dialog-operate-".concat(key);
690
- var handleClick = function handleClick() {
691
- switch (key) {
692
- case 'top':
693
- camera.rotation.x -= 0.01;
694
- break;
695
- case 'bottom':
696
- camera.rotation.x += 0.01;
697
- break;
698
- case 'left':
699
- camera.rotation.y += 0.01;
700
- break;
701
- case 'right':
702
- camera.rotation.y -= 0.01;
703
- break;
704
- }
705
- var _this5$manage$gobal$s = _this5.manage.gobal.scene.setCustomPerspective(camera),
706
- texture = _this5$manage$gobal$s.texture,
707
- close = _this5$manage$gobal$s.close;
708
- sprite.material = new SpriteMaterial({
709
- map: texture,
710
- depthTest: false,
711
- depthWrite: false
712
- });
713
- setTimeout(function () {
714
- return close();
715
- }, 800);
716
- };
717
- var clock;
718
- var longPress;
719
- var time;
720
- btnSpan.addEventListener('mousedown', function () {
721
- clock = new Clock();
722
- clock.getDelta();
723
- time = setTimeout(function () {
724
- longPress = use.useframe(handleClick);
725
- }, 500);
726
- });
727
- btnSpan.addEventListener('mouseup', function () {
728
- if (clock.getDelta() < 0.5) handleClick();
729
- clearTimeout(time);
730
- longPress && longPress();
731
- });
732
-
733
- // btnSpan.addEventListener('click', handleClick)
734
- op.appendChild(btnSpan);
735
- });
736
- var cb = function cb(fov) {
737
- if (!fov) return;
738
- camera.fov = fov;
739
- camera.updateProjectionMatrix();
740
- var _this5$manage$gobal$s2 = _this5.manage.gobal.scene.setCustomPerspective(camera),
741
- texture = _this5$manage$gobal$s2.texture,
742
- close = _this5$manage$gobal$s2.close;
743
- sprite.material = new SpriteMaterial({
744
- map: texture,
745
- depthTest: false,
746
- depthWrite: false
747
- });
748
- setTimeout(function () {
749
- return close();
750
- }, 800);
751
- };
752
- var slider = this.getFovView(cb);
753
- dialogDiv.appendChild(slider);
754
- var borderMesh = new Css2DPoi(dialogDiv);
755
- borderMesh.position.copy(sprite.position);
756
- return borderMesh;
757
- }
758
- }, {
759
- key: "getFovView",
760
- value: function getFovView(cb) {
761
- var data = [{
762
- text: '0.5',
763
- fov: '90'
764
- }, {
765
- text: '1',
766
- fov: '80'
767
- }, {
768
- text: '1.5',
769
- fov: '70'
770
- }, {
771
- text: '2.0',
772
- fov: '60'
773
- }, {
774
- text: '2.5',
775
- fov: '50'
776
- }, {
777
- text: '3.0',
778
- fov: '40'
779
- }, {
780
- text: '3.5',
781
- fov: '30'
782
- }];
783
- var container = document.createElement('div');
784
- container.className = 'dialog-slider-container';
785
- var itemsContainer = document.createElement('div');
786
- itemsContainer.className = 'dialog-slider-items';
787
- container.appendChild(itemsContainer);
788
- data.forEach(function (item) {
789
- var div = document.createElement('div');
790
- div.className = 'dialog-slider-item';
791
- div.innerHTML = "".concat(item.text, " X&nbsp;&nbsp;-");
792
- div.setAttribute('fov', item.fov);
793
- itemsContainer.appendChild(div);
794
- });
795
- var items = itemsContainer.children;
796
- var itemHeight = 58;
797
- var totalHeight = items.length * itemHeight;
798
- var cloneItems = function cloneItems() {
799
- Array.from(items).forEach(function (item) {
800
- itemsContainer.appendChild(item.cloneNode(true));
801
- });
802
- };
803
- cloneItems();
804
- cloneItems();
805
- var highlightMiddleItem = function highlightMiddleItem() {
806
- var middlePosition = container.scrollTop + container.clientHeight / 2;
807
- var middleIndex = Math.floor(middlePosition / itemHeight) % items.length;
808
- Array.from(items).forEach(function (item, index) {
809
- if (index === middleIndex) {
810
- item.classList.add('highlight');
811
- cb(item.getAttribute('fov'));
812
- } else {
813
- item.classList.remove('highlight');
814
- }
815
- });
816
- };
817
- container.addEventListener('scroll', function () {
818
- if (container.scrollTop <= 0) container.scrollTop += totalHeight;else if (container.scrollTop >= totalHeight * 2) container.scrollTop -= totalHeight;
819
- highlightMiddleItem();
820
- });
821
- var smoothScrollTo = function smoothScrollTo(targetPosition) {
822
- var startPosition = container.scrollTop;
823
- var distance = targetPosition - startPosition;
824
- var duration = 200;
825
- var start = null;
826
- var step = function step(timestamp) {
827
- if (!start) start = timestamp;
828
- var progress = timestamp - start;
829
- var progressRatio = Math.min(progress / duration, 1);
830
- container.scrollTop = startPosition + distance * progressRatio;
831
- if (progress < duration) window.requestAnimationFrame(step);else highlightMiddleItem();
832
- };
833
- window.requestAnimationFrame(step);
834
- };
835
- var scrollToItem = function scrollToItem(item) {
836
- var index = Array.from(items).indexOf(item);
837
- var targetPosition = index * itemHeight - container.clientHeight / 2 + itemHeight / 2;
838
- smoothScrollTo(targetPosition);
839
- };
840
- Array.from(items).forEach(function (item) {
841
- item.addEventListener('click', function () {
842
- scrollToItem(item);
843
- });
844
- });
845
- setTimeout(function () {
846
- // items && (items[3] as HTMLDivElement).click()
847
- container.scrollTop = totalHeight;
848
- highlightMiddleItem();
849
- });
850
- var conSlider = document.createElement('div');
851
- conSlider.className = 'dialog-slider-bg';
852
- conSlider.appendChild(container);
853
- return conSlider;
854
- }
855
- }, {
856
- key: "addStyle",
857
- value: function addStyle() {
858
- // 设置 CSS 规则
859
- var css = "\n .page-mask{\n position: fixed;\n top: 0;\n left: 0;\n bottom:0;\n right:0;\n //width: 100%;\n //height: 100%;\n background-color: rgba(0, 0, 0, 0.5); /* \u534A\u900F\u660E\u80CC\u666F */\n //filter: blur(10px); /* \u6A21\u7CCA\u6548\u679C */\n z-index: 1 !important; /* \u786E\u4FDD\u8499\u7248\u4F4D\u4E8E\u5176\u4ED6\u5143\u7D20\u4E4B\u4E0A */\n }\n .dialog-mask{\n position: absolute;\n top: 8px;\n left: 6px;\n width: calc(100% - 12px);\n height: calc(100% - 16px);\n background: linear-gradient(90deg, rgba(0, 0, 0,.4) 0%,rgba(0, 0, 0,.2) 10%, rgba(0, 0, 0,0) 20%, rgba(0,0,0, 0) 50%, rgba(0, 0, 0,0) 80%, rgba(0, 0, 0,0.2) 90%, rgba(0, 0, 0,.4) 100%);\n pointer-events: auto;\n opacity: 1;\n transform: perspective(100px) rotateX(0deg) rotateY(0deg) rotateZ(0deg);\n transform-origin: center center;\n }\n .hot-back{\n width: 70px;\n height: 25px;\n border-radius: 2px;\n color: #fff;\n font-weight: bold;\n font-size: 14px;\n border:1px solid #d1ae6d;\n background-color: #c8ab75;\n cursor: pointer; /* \u9F20\u6807\u6307\u9488\u6837\u5F0F */\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n left: 30px;\n top: 30px;\n pointer-events: auto;\n }\n .hot-back:hover{\n background-color:#c8a158;\n }\n .dialog-close{\n width: 26px;\n height: 26px;\n background-image: url(".concat(usePath, "p4/close.png);\n background-size: 100% 100%;\n background-repeat: no-repeat;\n color: #fff;\n cursor: pointer; /* \u9F20\u6807\u6307\u9488\u6837\u5F0F */\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n right: 28px;\n top: 20px;\n pointer-events: auto;\n }\n .dialog-operate{\n width: 199px;\n height: 182px;\n background-image: url(").concat(usePath, "p4/operate.png);\n background-size: 100% 100%;\n background-repeat: no-repeat;\n position: absolute;\n right: 20px;\n bottom: 20px;\n pointer-events: auto;\n }\n\n .dialog-operate-btn{\n width: 20px;\n height: 34px;\n position: absolute;\n cursor: pointer;\n pointer-events: auto;\n background-image: url(").concat(usePath, "p4/arrow1.png);\n background-size: 100% 100%;\n background-repeat: no-repeat;\n transition: all .2s;\n }\n .dialog-operate-btn:hover{\n background-image: url(").concat(usePath, "p4/arrow2.png);\n }\n\n .dialog-operate-top{\n transform: rotateZ(90deg);\n left: calc(50% - 9px);\n top: 40px;\n }\n .dialog-operate-top:hover{\n border-bottom-color:#fff2dd;\n }\n\n .dialog-operate-bottom{\n transform: rotateZ(270deg);\n left: calc(50% - 9px);\n bottom: 40px;\n }\n\n .dialog-operate-bottom:hover{\n border-top-color:#fff2dd;\n }\n\n .dialog-operate-left{\n top: calc(50% - 18px);\n left: 58px;\n }\n .dialog-operate-left:hover{\n border-right-color:#fff2dd;\n }\n\n .dialog-operate-right{\n transform: rotateZ(180deg);\n top: calc(50% - 18px);\n right: 57px;\n }\n\n .dialog-operate-right:hover{\n border-left-color:#fff2dd;\n }\n .dialog-slider-bg {\n width: 166px;\n height: 493px;\n position:absolute;\n right:36px;\n top:100px;\n background: url(").concat(usePath, "p4/fov-bg.png);\n background-size: 100% 100%;\n background-repeat: no-repeat;\n pointer-events: auto;\n }\n\n .dialog-slider-container {\n height: 406px;\n margin: 44px 21px;\n overflow: auto;\n position: relative;\n text-align: center;\n scrollbar-width: none;\n -ms-overflow-style: none;\n pointer-events: auto;\n }\n\n .dialog-slider-container::-webkit-scrollbar {\n display: none;\n /* Safari and Chrome */\n }\n\n .dialog-slider-items {\n display: flex;\n flex-direction: column;\n width: 100%;\n }\n\n .dialog-slider-item {\n width: 100%;\n height: 58px;\n display: flex;\n justify-content: center;\n align-items: center;\n box-sizing: border-box;\n font-size: 20px;\n color: #fff;\n transition: all .2s;\n cursor: pointer;\n pointer-events: auto;\n }\n\n .dialog-slider-item.highlight {\n background-image: url(").concat(usePath, "p4/fov-border.png);\n background-size: 100% 100%;\n background-repeat: no-repeat;\n font-size: 28px;\n color: #ffda77;\n }\n");
860
- // 创建一个 <style> 元素
861
- var styleElement = document.createElement('style');
862
- styleElement.appendChild(document.createTextNode(css));
863
- // 将 <style> 元素添加到 <head> 中
864
- document.head.appendChild(styleElement);
865
- }
866
- }, {
867
- key: "close",
868
- value: function close() {
869
- if (this.cuteSprites) {
870
- this.cuteSprites.forEach(function (mesh) {
871
- mesh.remove();
872
- mesh.removeFromParent();
873
- });
874
- this.cuteSprites.length = 0;
875
- }
876
- this.eventList.has('close') && this.eventList.get('close')();
877
- // 移除事件监听
878
- this.eventListener.forEach(function (fn) {
879
- fn();
880
- });
881
- this.eventListener.clear();
882
- this.eventList.clear();
883
- }
884
- }]);
885
- return Dialog;
886
- }();
887
- var HeadMap = /*#__PURE__*/function () {
888
- function HeadMap() {
889
- _classCallCheck(this, HeadMap);
890
- _defineProperty(this, "TemperatureColorStops", {
891
- 1.0: '#f00',
892
- 0.9: '#e2fa00',
893
- 0.6: '#33f900',
894
- 0.3: '#0349df',
895
- 0.0: '#0f00ff'
896
- });
897
- _defineProperty(this, "eventList", new Map());
898
- _defineProperty(this, "backEle", void 0);
899
- _defineProperty(this, "heatMapPlane", void 0);
900
- _defineProperty(this, "canvasList", []);
901
- _defineProperty(this, "isShow", false);
902
- }
903
-
904
- // 热力图
905
- _createClass(HeadMap, [{
906
- key: "create",
907
- value: function create(distance) {
908
- this.isShow = true;
909
- var heatmap = heatMap.create({
910
- container: this.createDom(),
911
- gradient: this.TemperatureColorStops
912
- });
913
- var len = 100;
914
- var _ref4 = [window.innerWidth, window.innerHeight],
915
- width = _ref4[0],
916
- height = _ref4[1];
917
- var dom = document.querySelector('#app');
918
- if (dom) {
919
- width = dom.clientWidth;
920
- height = dom.clientHeight;
921
- }
922
- var points = [];
923
- var max = 0;
924
- while (len--) {
925
- var val = Math.floor(Math.random() * 5);
926
- max = Math.max(max, val);
927
- var point = {
928
- x: Math.floor(Math.random() * width),
929
- y: Math.floor(Math.random() * height),
930
- value: val
931
- };
932
- points.push(point);
933
- }
934
- heatmap.setData({
935
- max: max,
936
- data: points
937
- });
938
-
939
- // 灰度图
940
- var greymap = heatMap.create({
941
- container: this.createDom(),
942
- gradient: {
943
- '0': 'black',
944
- '1.0': 'white'
945
- }
946
- });
947
- greymap.setData({
948
- max: max,
949
- data: points
950
- });
951
- var heatMapMaterial = new ShaderMaterial({
952
- transparent: true,
953
- depthTest: false,
954
- side: DoubleSide,
955
- vertexShader: "varying vec2 vUv;\n uniform float Zscale;\n uniform sampler2D greyMap;\n void main() {\n vUv = uv;\n vec4 frgColor = texture2D(greyMap, uv);//\u83B7\u53D6\u7070\u5EA6\u56FE\u70B9\u4F4D\u4FE1\u606F\n float height = Zscale * frgColor.a;//\u901A\u8FC7\u7070\u5EA6\u56FE\u7684rgb*\u9700\u8981\u8BBE\u7F6E\u7684\u9AD8\u5EA6\u8BA1\u7B97\u51FA\u70ED\u529B\u56FE\u6BCF\u4E2A\u70B9\u4F4D\u6700\u7EC8\u5728z\u8F74\u9AD8\u5EA6\n vec3 transformed = vec3( position.x, position.y, height);//\u91CD\u65B0\u7EC4\u88C5\u70B9\u5750\u6807\n gl_Position = projectionMatrix * modelViewMatrix * vec4(transformed, 1.0);//\u6E32\u67D3\u70B9\u4F4D\n \n }\n ",
956
- fragmentShader: "varying vec2 vUv;\n uniform sampler2D heatMap;//\u70ED\u529B\u56FE\n uniform vec3 u_color;//\u57FA\u7840\u989C\u8272\n uniform float u_opacity; // \u900F\u660E\u5EA6\n void main() {\n //vec4 alphaColor = texture2D(heatMap, vUv);\n // gl_FragColor = alphaColor;\n gl_FragColor = vec4(u_color, u_opacity) * texture2D(heatMap, vUv);//\u628A\u70ED\u529B\u56FE\u989C\u8272\u548C\u900F\u660E\u5EA6\u8FDB\u884C\u6E32\u67D3\n }",
957
- uniforms: {
958
- heatMap: {
959
- value: {
960
- value: undefined
961
- }
962
- },
963
- greyMap: {
964
- value: {
965
- value: undefined
966
- }
967
- },
968
- Zscale: {
969
- value: 0
970
- },
971
- // 高度参数
972
- u_color: {
973
- value: new Color('rgb(255, 255, 255)')
974
- },
975
- u_opacity: {
976
- value: 0.8
977
- }
978
- }
979
- });
980
- var texture = new Texture(heatmap._renderer.canvas);
981
- texture.needsUpdate = true;
982
- var greyTexture = new Texture(greymap._renderer.canvas);
983
- greyTexture.needsUpdate = true;
984
- heatMapMaterial.uniforms.heatMap.value = texture;
985
- heatMapMaterial.uniforms.greyMap.value = greyTexture;
986
- var _use$useScene8 = use.useScene(),
987
- camera = _use$useScene8.camera;
988
- // 计算平面的尺寸
989
- var h = 2 * Math.tan(camera.fov * Math.PI / 360) * distance * 2 * 0.85;
990
- var w = h * camera.aspect;
991
- var heatMapGeometry = new PlaneGeometry(60, 60 * height / width); // 3d热力图大小,及分块数量
992
-
993
- var heatMapPlane = new Mesh(heatMapGeometry, heatMapMaterial);
994
- heatMapPlane.rotation.set(-Math.PI / 2, 0, 0);
995
- this.heatMapPlane = heatMapPlane;
996
- return heatMapPlane;
997
- }
998
- }, {
999
- key: "addEventListener",
1000
- value: function addEventListener(eventName, fn) {
1001
- if (this.eventList.has(eventName)) this.eventList[eventName] = fn;else this.eventList.set(eventName, fn);
1002
- }
1003
- }, {
1004
- key: "addBack",
1005
- value: function addBack() {
1006
- var _this6 = this;
1007
- this.backEle = document.createElement('div');
1008
- this.backEle.className = 'hot-back';
1009
- this.backEle.innerHTML = '返回';
1010
- document.body.appendChild(this.backEle);
1011
- this.backEle.addEventListener('click', function () {
1012
- _this6.eventList.has('close') && _this6.eventList.get('close')();
1013
- // this.remove()
1014
- });
1015
- }
1016
- }, {
1017
- key: "createDom",
1018
- value: function createDom() {
1019
- // 创建一个新的 canvas 元素
1020
- var canvas = document.createElement('canvas');
1021
- canvas.style.zIndex = '-1';
1022
- // 设置 canvas 元素的宽度和高度
1023
- canvas.width = window.innerWidth;
1024
- canvas.height = window.innerHeight;
1025
- document.body.appendChild(canvas);
1026
- this.canvasList.push(canvas);
1027
- return canvas;
1028
- }
1029
- }, {
1030
- key: "remove",
1031
- value: function remove() {
1032
- this.canvasList.forEach(function (canvas) {
1033
- canvas.remove();
1034
- });
1035
- // this.eventList.has('close') && this.eventList.get('close')()
1036
- this.canvasList.length = 0;
1037
- this.backEle && this.backEle.remove();
1038
- if (this.heatMapPlane) {
1039
- this.heatMapPlane.removeFromParent();
1040
- this.heatMapPlane.remove();
1041
- }
1042
- this.isShow = false;
1043
- }
1044
- }]);
1045
- return HeadMap;
1046
- }();
1047
- //# sourceMappingURL=CameraPoi.js.map