@anov/3d-ability 0.0.141 → 0.0.143

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 (257) hide show
  1. package/dist/business/Animation/motion/index.js +56 -35
  2. package/dist/business/Animation/motion/index.js.map +1 -1
  3. package/dist/business/Animation/type.js +2 -2
  4. package/dist/business/Area/Fence/FenceBase.js +187 -146
  5. package/dist/business/Area/Fence/FenceBase.js.map +1 -1
  6. package/dist/business/Area/Fence/fence_base_01.js +112 -120
  7. package/dist/business/Area/Fence/fence_base_01.js.map +1 -1
  8. package/dist/business/Area/Fence/fence_feeting_01.js +130 -218
  9. package/dist/business/Area/Fence/fence_feeting_01.js.map +1 -1
  10. package/dist/business/Area/Fence/fence_roll_01.js +130 -140
  11. package/dist/business/Area/Fence/fence_roll_01.js.map +1 -1
  12. package/dist/business/Area/FillArea/FillAreaBase.js +126 -87
  13. package/dist/business/Area/FillArea/FillAreaBase.js.map +1 -1
  14. package/dist/business/Area/FillArea/fillArea_face_01.js +98 -72
  15. package/dist/business/Area/FillArea/fillArea_face_01.js.map +1 -1
  16. package/dist/business/Area/FillArea/fillArea_line_01.js +94 -66
  17. package/dist/business/Area/FillArea/fillArea_line_01.js.map +1 -1
  18. package/dist/business/Area/index.js +483 -267
  19. package/dist/business/Area/index.js.map +1 -1
  20. package/dist/business/Area/tool.js +26 -14
  21. package/dist/business/Area/tool.js.map +1 -1
  22. package/dist/business/Base/ObjectLayer.js +46 -21
  23. package/dist/business/Base/ObjectLayer.js.map +1 -1
  24. package/dist/business/Batch/index.js +234 -189
  25. package/dist/business/Batch/index.js.map +1 -1
  26. package/dist/business/Box/index.js +81 -52
  27. package/dist/business/Box/index.js.map +1 -1
  28. package/dist/business/Cylinder/index.js +79 -51
  29. package/dist/business/Cylinder/index.js.map +1 -1
  30. package/dist/business/Flyline/bubble/CircleBubble.js +9 -1
  31. package/dist/business/Flyline/bubble/CircleBubble.js.map +1 -1
  32. package/dist/business/Flyline/bubble/index.js +21 -7
  33. package/dist/business/Flyline/bubble/index.js.map +1 -1
  34. package/dist/business/Flyline/index.js +162 -96
  35. package/dist/business/Flyline/index.js.map +1 -1
  36. package/dist/business/Flyline/line/ArcLine.js +291 -208
  37. package/dist/business/Flyline/line/ArcLine.js.map +1 -1
  38. package/dist/business/Flyline/line/index.js +22 -8
  39. package/dist/business/Flyline/line/index.js.map +1 -1
  40. package/dist/business/HeatMap/HeatMap.js +467 -380
  41. package/dist/business/HeatMap/HeatMap.js.map +1 -1
  42. package/dist/business/HeatMap/core.js +525 -405
  43. package/dist/business/HeatMap/core.js.map +1 -1
  44. package/dist/business/HeatMap/shader.js +3 -69
  45. package/dist/business/HeatMap/shader.js.map +1 -1
  46. package/dist/business/InfoPanel/index.js +242 -201
  47. package/dist/business/InfoPanel/index.js.map +1 -1
  48. package/dist/business/Line/index.js +88 -55
  49. package/dist/business/Line/index.js.map +1 -1
  50. package/dist/business/Mark/KeyframeAnimation.js +176 -145
  51. package/dist/business/Mark/KeyframeAnimation.js.map +1 -1
  52. package/dist/business/Mark/index.js +294 -196
  53. package/dist/business/Mark/index.js.map +1 -1
  54. package/dist/business/Mark/shader/tanhao.js +3 -36
  55. package/dist/business/Mark/shader/tanhao.js.map +1 -1
  56. package/dist/business/Mark/type.js +1 -1
  57. package/dist/business/MaterialSwitch/MaterialSwitchSystem.js +551 -377
  58. package/dist/business/MaterialSwitch/MaterialSwitchSystem.js.map +1 -1
  59. package/dist/business/MaterialSwitch/inject.js +58 -92
  60. package/dist/business/MaterialSwitch/inject.js.map +1 -1
  61. package/dist/business/MaterialSwitch/shader/finalFade.js +2 -74
  62. package/dist/business/MaterialSwitch/shader/finalFade.js.map +1 -1
  63. package/dist/business/MaterialSwitch/shader/ground.js +16 -95
  64. package/dist/business/MaterialSwitch/shader/ground.js.map +1 -1
  65. package/dist/business/MaterialSwitch/shader/groundBase64.js +3 -9
  66. package/dist/business/MaterialSwitch/shader/groundBase64.js.map +1 -1
  67. package/dist/business/MaterialSwitch/shader/realFade.js +9 -48
  68. package/dist/business/MaterialSwitch/shader/realFade.js.map +1 -1
  69. package/dist/business/Plane/index.js +78 -51
  70. package/dist/business/Plane/index.js.map +1 -1
  71. package/dist/business/Poi/index.js +336 -248
  72. package/dist/business/Poi/index.js.map +1 -1
  73. package/dist/business/Poi/link/Cylinder.js +89 -56
  74. package/dist/business/Poi/link/Cylinder.js.map +1 -1
  75. package/dist/business/Poi/link/Pyramid.js +165 -104
  76. package/dist/business/Poi/link/Pyramid.js.map +1 -1
  77. package/dist/business/Poi/link/index.js +114 -54
  78. package/dist/business/Poi/link/index.js.map +1 -1
  79. package/dist/business/Poi/panel/index.js +373 -315
  80. package/dist/business/Poi/panel/index.js.map +1 -1
  81. package/dist/business/Poi/panel/utils.js +10 -5
  82. package/dist/business/Poi/panel/utils.js.map +1 -1
  83. package/dist/business/Poi/particle/DoubleCircle.js +107 -71
  84. package/dist/business/Poi/particle/DoubleCircle.js.map +1 -1
  85. package/dist/business/Poi/particle/DynamicCircle.js +111 -75
  86. package/dist/business/Poi/particle/DynamicCircle.js.map +1 -1
  87. package/dist/business/Poi/particle/SingleCircle.js +98 -62
  88. package/dist/business/Poi/particle/SingleCircle.js.map +1 -1
  89. package/dist/business/Poi/particle/index.js +117 -49
  90. package/dist/business/Poi/particle/index.js.map +1 -1
  91. package/dist/business/Poi/shader/circle.js +3 -31
  92. package/dist/business/Poi/shader/circle.js.map +1 -1
  93. package/dist/business/Poi/shader/cylinder.js +3 -37
  94. package/dist/business/Poi/shader/cylinder.js.map +1 -1
  95. package/dist/business/Poi/shader/doubleCircle.js +3 -55
  96. package/dist/business/Poi/shader/doubleCircle.js.map +1 -1
  97. package/dist/business/Poi/shader/dynamicCircle.js +3 -67
  98. package/dist/business/Poi/shader/dynamicCircle.js.map +1 -1
  99. package/dist/business/Poi/title/Border.js +27 -7
  100. package/dist/business/Poi/title/Border.js.map +1 -1
  101. package/dist/business/Poi/title/Ellipse.js +27 -7
  102. package/dist/business/Poi/title/Ellipse.js.map +1 -1
  103. package/dist/business/Poi/title/index.js +292 -208
  104. package/dist/business/Poi/title/index.js.map +1 -1
  105. package/dist/business/Poi/tools.js +17 -18
  106. package/dist/business/Poi/tools.js.map +1 -1
  107. package/dist/business/Sphere/index.js +72 -47
  108. package/dist/business/Sphere/index.js.map +1 -1
  109. package/dist/business/Spline/index.js +245 -190
  110. package/dist/business/Spline/index.js.map +1 -1
  111. package/dist/business/SplitBuilding/index.js +536 -327
  112. package/dist/business/SplitBuilding/index.js.map +1 -1
  113. package/dist/business/SplitBuilding/type.js +2 -2
  114. package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js +275 -218
  115. package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js.map +1 -1
  116. package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js +177 -132
  117. package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js.map +1 -1
  118. package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js +1 -51
  119. package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js.map +1 -1
  120. package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js +1 -6
  121. package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js.map +1 -1
  122. package/dist/business/TrafficComponents/base.js +55 -32
  123. package/dist/business/TrafficComponents/base.js.map +1 -1
  124. package/dist/business/TrafficComponents/utils.d.ts +1 -1
  125. package/dist/business/TrafficComponents/utils.js +25 -26
  126. package/dist/business/TrafficComponents/utils.js.map +1 -1
  127. package/dist/business/Utils/Curve.js +56 -40
  128. package/dist/business/Utils/Curve.js.map +1 -1
  129. package/dist/business/Utils/constant.js +1 -1
  130. package/dist/business/Utils/constant.js.map +1 -1
  131. package/dist/business/Utils/defineProps.js +14 -13
  132. package/dist/business/Utils/defineProps.js.map +1 -1
  133. package/dist/business/Utils/round-curve.js +153 -127
  134. package/dist/business/Utils/round-curve.js.map +1 -1
  135. package/dist/business/VideoPanel/index.js +319 -258
  136. package/dist/business/VideoPanel/index.js.map +1 -1
  137. package/dist/business/Water/index.js +108 -78
  138. package/dist/business/Water/index.js.map +1 -1
  139. package/dist/business/Water/types.js +1 -1
  140. package/dist/business/Water/types.js.map +1 -1
  141. package/dist/core/Camera/PerspectiveCamera/CameraExpand.js +449 -383
  142. package/dist/core/Camera/PerspectiveCamera/CameraExpand.js.map +1 -1
  143. package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js +142 -107
  144. package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js.map +1 -1
  145. package/dist/core/Controls/FirstViewControl/index.js +96 -84
  146. package/dist/core/Controls/FirstViewControl/index.js.map +1 -1
  147. package/dist/core/Controls/ThirdViewControl/action/input.js +98 -77
  148. package/dist/core/Controls/ThirdViewControl/action/input.js.map +1 -1
  149. package/dist/core/Controls/ThirdViewControl/config/constants.js +1 -1
  150. package/dist/core/Controls/ThirdViewControl/config/constants.js.map +1 -1
  151. package/dist/core/Controls/ThirdViewControl/index.js +28 -19
  152. package/dist/core/Controls/ThirdViewControl/index.js.map +1 -1
  153. package/dist/core/Controls/ThirdViewControl/player/animation.js +155 -126
  154. package/dist/core/Controls/ThirdViewControl/player/animation.js.map +1 -1
  155. package/dist/core/Controls/ThirdViewControl/player/camera.js +63 -47
  156. package/dist/core/Controls/ThirdViewControl/player/camera.js.map +1 -1
  157. package/dist/core/Controls/ThirdViewControl/player/control.js +49 -39
  158. package/dist/core/Controls/ThirdViewControl/player/control.js.map +1 -1
  159. package/dist/core/Controls/ThirdViewControl/player.js +91 -66
  160. package/dist/core/Controls/ThirdViewControl/player.js.map +1 -1
  161. package/dist/core/Controls/base.js +30 -14
  162. package/dist/core/Controls/base.js.map +1 -1
  163. package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js +131 -92
  164. package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js.map +1 -1
  165. package/dist/core/Debug/PerformanceInfo/Performance.js +47 -22
  166. package/dist/core/Debug/PerformanceInfo/Performance.js.map +1 -1
  167. package/dist/core/Light/PointLight/PointLightExt.js +21 -4
  168. package/dist/core/Light/PointLight/PointLightExt.js.map +1 -1
  169. package/dist/core/Material/FinirMaterial/FinirMaterial.js +57 -37
  170. package/dist/core/Material/FinirMaterial/FinirMaterial.js.map +1 -1
  171. package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js +153 -116
  172. package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js.map +1 -1
  173. package/dist/core/Material/PristineGridMaterial/shader/fragment.js +1 -95
  174. package/dist/core/Material/PristineGridMaterial/shader/fragment.js.map +1 -1
  175. package/dist/core/Material/PristineGridMaterial/shader/vertex.js +1 -26
  176. package/dist/core/Material/PristineGridMaterial/shader/vertex.js.map +1 -1
  177. package/dist/core/Material/SurfaceMaterial/index.js +172 -76
  178. package/dist/core/Material/SurfaceMaterial/index.js.map +1 -1
  179. package/dist/core/Material/decorators.js +11 -6
  180. package/dist/core/Material/decorators.js.map +1 -1
  181. package/dist/core/PostEffects/addACESFilmicToneMappingPass.js +12 -16
  182. package/dist/core/PostEffects/addACESFilmicToneMappingPass.js.map +1 -1
  183. package/dist/core/PostEffects/addBrightnessContrastPass.js +13 -17
  184. package/dist/core/PostEffects/addBrightnessContrastPass.js.map +1 -1
  185. package/dist/core/PostEffects/bloomPass.js +10 -17
  186. package/dist/core/PostEffects/bloomPass.js.map +1 -1
  187. package/dist/core/PostEffects/bloomSelect.js +43 -60
  188. package/dist/core/PostEffects/bloomSelect.js.map +1 -1
  189. package/dist/core/PostEffects/colorifyPass.js +13 -17
  190. package/dist/core/PostEffects/colorifyPass.js.map +1 -1
  191. package/dist/core/PostEffects/index.js +22 -28
  192. package/dist/core/PostEffects/index.js.map +1 -1
  193. package/dist/core/PostEffects/outlinePass.js +50 -37
  194. package/dist/core/PostEffects/outlinePass.js.map +1 -1
  195. package/dist/core/PostEffects/postprocessing.js +12 -14
  196. package/dist/core/PostEffects/postprocessing.js.map +1 -1
  197. package/dist/core/PostEffects/saoPass.js +10 -15
  198. package/dist/core/PostEffects/saoPass.js.map +1 -1
  199. package/dist/core/PostEffects/shader/colorify.js +3 -22
  200. package/dist/core/PostEffects/shader/colorify.js.map +1 -1
  201. package/dist/core/PostEffects/shader/gammaCorrectionShader.js +3 -27
  202. package/dist/core/PostEffects/shader/gammaCorrectionShader.js.map +1 -1
  203. package/dist/core/PostEffects/shader/mapping.js +3 -66
  204. package/dist/core/PostEffects/shader/mapping.js.map +1 -1
  205. package/dist/core/PostEffects/shader/thermalMaging.js +3 -28
  206. package/dist/core/PostEffects/shader/thermalMaging.js.map +1 -1
  207. package/dist/core/SceneEffect/grow/grow.js +101 -85
  208. package/dist/core/SceneEffect/grow/grow.js.map +1 -1
  209. package/dist/core/SceneEffect/grow/style_down.js +77 -60
  210. package/dist/core/SceneEffect/grow/style_down.js.map +1 -1
  211. package/dist/core/SceneEffect/grow/style_up.js +81 -64
  212. package/dist/core/SceneEffect/grow/style_up.js.map +1 -1
  213. package/dist/core/SceneEffect/grow/type.js +2 -2
  214. package/dist/core/SceneEffect/grow/type.js.map +1 -1
  215. package/dist/core/WeatherSystem/DynamicWeatherSystem.js +76 -51
  216. package/dist/core/WeatherSystem/DynamicWeatherSystem.js.map +1 -1
  217. package/dist/core/WeatherSystem/hdr/index.js +105 -69
  218. package/dist/core/WeatherSystem/hdr/index.js.map +1 -1
  219. package/dist/core/WeatherSystem/index.js +124 -77
  220. package/dist/core/WeatherSystem/index.js.map +1 -1
  221. package/dist/core/WeatherSystem/objects/fog/index.js +80 -52
  222. package/dist/core/WeatherSystem/objects/fog/index.js.map +1 -1
  223. package/dist/core/WeatherSystem/objects/rain/index.js +84 -72
  224. package/dist/core/WeatherSystem/objects/rain/index.js.map +1 -1
  225. package/dist/core/WeatherSystem/objects/rain/lineRain.js +118 -88
  226. package/dist/core/WeatherSystem/objects/rain/lineRain.js.map +1 -1
  227. package/dist/core/WeatherSystem/objects/rain/plane.js +146 -116
  228. package/dist/core/WeatherSystem/objects/rain/plane.js.map +1 -1
  229. package/dist/core/WeatherSystem/objects/rain/point.js +148 -100
  230. package/dist/core/WeatherSystem/objects/rain/point.js.map +1 -1
  231. package/dist/core/WeatherSystem/objects/sky/cloud.js +104 -71
  232. package/dist/core/WeatherSystem/objects/sky/cloud.js.map +1 -1
  233. package/dist/core/WeatherSystem/objects/sky/index.js +84 -66
  234. package/dist/core/WeatherSystem/objects/sky/index.js.map +1 -1
  235. package/dist/core/WeatherSystem/objects/sky/outline.js +45 -25
  236. package/dist/core/WeatherSystem/objects/sky/outline.js.map +1 -1
  237. package/dist/core/WeatherSystem/shaders/cloud.js +3 -74
  238. package/dist/core/WeatherSystem/shaders/cloud.js.map +1 -1
  239. package/dist/core/WeatherSystem/shaders/fog.js +3 -103
  240. package/dist/core/WeatherSystem/shaders/fog.js.map +1 -1
  241. package/dist/core/WeatherSystem/shaders/rain.js +7 -206
  242. package/dist/core/WeatherSystem/shaders/rain.js.map +1 -1
  243. package/dist/core/WeatherSystem/shaders/sky.js +3 -87
  244. package/dist/core/WeatherSystem/shaders/sky.js.map +1 -1
  245. package/dist/core/WeatherSystem/sky/index.js +135 -104
  246. package/dist/core/WeatherSystem/sky/index.js.map +1 -1
  247. package/dist/core/WeatherSystem/utils/constant.js +38 -44
  248. package/dist/core/WeatherSystem/utils/constant.js.map +1 -1
  249. package/dist/core/WeatherSystem/utils/math.js +25 -18
  250. package/dist/core/WeatherSystem/utils/math.js.map +1 -1
  251. package/dist/core/WeatherSystem/utils/type.js +1 -1
  252. package/dist/core/WeatherSystem/utils/type.js.map +1 -1
  253. package/dist/core/WeatherSystem/weather/index.js +141 -96
  254. package/dist/core/WeatherSystem/weather/index.js.map +1 -1
  255. package/dist/utils/index.js +1 -1
  256. package/dist/utils/index.js.map +1 -1
  257. package/package.json +3 -3
@@ -1,418 +1,484 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
6
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
9
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1
12
  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; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
3
- 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); }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
+ 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); }
4
15
  import { Box3, EventDispatcher, Group, MathUtils, Plane, Quaternion, TWEEN, Vector3, use, utils } from '@anov/3d-core';
5
16
  import FollowControls from "./FollowOrbitControls";
6
17
  /**
7
18
  * CameraExpand, 主要提供了一些PerspectiveCamera的拓展能力
8
19
  */
9
- export class PerspectiveCameraExpand extends EventDispatcher {
10
- constructor(camera, controls, sceneControl) {
11
- super();
12
- _defineProperty(this, "_isTransitionPeriod", false);
13
- _defineProperty(this, "camera", void 0);
14
- _defineProperty(this, "controls", void 0);
15
- _defineProperty(this, "sceneControl", void 0);
16
- _defineProperty(this, "tween", void 0);
17
- _defineProperty(this, "_isCameraChange", false);
18
- _defineProperty(this, "followId", 0);
19
- _defineProperty(this, "followCancelMap", new Map());
20
- this.camera = camera;
21
- this.controls = controls;
22
- this.sceneControl = sceneControl;
23
- this.bindEvent();
20
+ export var PerspectiveCameraExpand = /*#__PURE__*/function (_EventDispatcher) {
21
+ _inherits(PerspectiveCameraExpand, _EventDispatcher);
22
+ var _super = _createSuper(PerspectiveCameraExpand);
23
+ function PerspectiveCameraExpand(camera, controls, sceneControl) {
24
+ var _this;
25
+ _classCallCheck(this, PerspectiveCameraExpand);
26
+ _this = _super.call(this);
27
+ _defineProperty(_assertThisInitialized(_this), "_isTransitionPeriod", false);
28
+ _defineProperty(_assertThisInitialized(_this), "camera", void 0);
29
+ _defineProperty(_assertThisInitialized(_this), "controls", void 0);
30
+ _defineProperty(_assertThisInitialized(_this), "sceneControl", void 0);
31
+ _defineProperty(_assertThisInitialized(_this), "tween", void 0);
32
+ _defineProperty(_assertThisInitialized(_this), "_isCameraChange", false);
33
+ _defineProperty(_assertThisInitialized(_this), "followId", 0);
34
+ _defineProperty(_assertThisInitialized(_this), "followCancelMap", new Map());
35
+ _this.camera = camera;
36
+ _this.controls = controls;
37
+ _this.sceneControl = sceneControl;
38
+ _this.bindEvent();
39
+ return _this;
24
40
  }
25
- get isTransitionPeriod() {
26
- return this._isTransitionPeriod;
27
- }
28
- get isCameraChange() {
29
- return this._isCameraChange;
30
- }
31
- bindEvent() {
32
- this.controls.addEventListener('start', () => {
33
- utils.storeManagement.set('enableEvents', false);
34
- this._isCameraChange = true;
35
- });
36
- this.controls.addEventListener('end', () => {
37
- utils.storeManagement.set('enableEvents', true);
38
- this._isCameraChange = false;
39
- });
40
- this.controls.addEventListener('change', () => {
41
- this.dispatchEvent({
42
- type: 'change',
43
- position: this.camera.position,
44
- target: this.controls.target
41
+ _createClass(PerspectiveCameraExpand, [{
42
+ key: "isTransitionPeriod",
43
+ get: function get() {
44
+ return this._isTransitionPeriod;
45
+ }
46
+ }, {
47
+ key: "isCameraChange",
48
+ get: function get() {
49
+ return this._isCameraChange;
50
+ }
51
+ }, {
52
+ key: "bindEvent",
53
+ value: function bindEvent() {
54
+ var _this2 = this;
55
+ this.controls.addEventListener('start', function () {
56
+ utils.storeManagement.set('enableEvents', false);
57
+ _this2._isCameraChange = true;
45
58
  });
46
- });
47
- }
59
+ this.controls.addEventListener('end', function () {
60
+ utils.storeManagement.set('enableEvents', true);
61
+ _this2._isCameraChange = false;
62
+ });
63
+ this.controls.addEventListener('change', function () {
64
+ _this2.dispatchEvent({
65
+ type: 'change',
66
+ position: _this2.camera.position,
67
+ target: _this2.controls.target
68
+ });
69
+ });
70
+ }
48
71
 
49
- /**
50
- * calculate last position from position box
51
- * if distance is not defined, calculate distance from box size
52
- * @param currentPos
53
- * @param distanceCoefficient
54
- * @param distance
55
- * @returns
56
- */
57
- caclCurrentPos(currentPos, distanceCoefficient = 1, distance) {
58
- const box = new Box3();
59
- box.setFromPoints(currentPos.map(item => new Vector3(item[0], item[1], item[2])));
60
- const center = box.getCenter(new Vector3());
61
- const size = box.getSize(new Vector3());
62
- const halfDiagonal = size.length() * 0.5;
63
- const maxDistance = halfDiagonal / Math.tan(this.camera.fov / 2 * Math.PI / 180);
64
- const cameraToCenterDistance = maxDistance;
65
- const directionVector = this.camera.position.clone().sub(this.controls.target).normalize();
66
- const lastPosition = directionVector.multiplyScalar(distance !== null && distance !== void 0 ? distance : cameraToCenterDistance * distanceCoefficient).add(center);
67
- const lastLookat = center;
68
- return {
69
- lastPosition,
70
- lastLookat
71
- };
72
- }
72
+ /**
73
+ * calculate last position from position box
74
+ * if distance is not defined, calculate distance from box size
75
+ * @param currentPos
76
+ * @param distanceCoefficient
77
+ * @param distance
78
+ * @returns
79
+ */
80
+ }, {
81
+ key: "caclCurrentPos",
82
+ value: function caclCurrentPos(currentPos) {
83
+ var distanceCoefficient = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
84
+ var distance = arguments.length > 2 ? arguments[2] : undefined;
85
+ var box = new Box3();
86
+ box.setFromPoints(currentPos.map(function (item) {
87
+ return new Vector3(item[0], item[1], item[2]);
88
+ }));
89
+ var center = box.getCenter(new Vector3());
90
+ var size = box.getSize(new Vector3());
91
+ var halfDiagonal = size.length() * 0.5;
92
+ var maxDistance = halfDiagonal / Math.tan(this.camera.fov / 2 * Math.PI / 180);
93
+ var cameraToCenterDistance = maxDistance;
94
+ var directionVector = this.camera.position.clone().sub(this.controls.target).normalize();
95
+ var lastPosition = directionVector.multiplyScalar(distance !== null && distance !== void 0 ? distance : cameraToCenterDistance * distanceCoefficient).add(center);
96
+ var lastLookat = center;
97
+ return {
98
+ lastPosition: lastPosition,
99
+ lastLookat: lastLookat
100
+ };
101
+ }
73
102
 
74
- /**
75
- * caclSingleCoordinate, when use focus and target is single point
76
- * @param prevTarget
77
- * @param prevPosition
78
- * @param lastTarget
79
- * @returns
80
- */
81
- caclSingleCoordinate(prevTarget, prevPosition, lastTarget, distance) {
82
- const directionVector = prevPosition.clone().sub(prevTarget).normalize();
83
- const lastPosition = directionVector.multiplyScalar(distance).add(lastTarget);
84
- return lastPosition;
85
- }
103
+ /**
104
+ * caclSingleCoordinate, when use focus and target is single point
105
+ * @param prevTarget
106
+ * @param prevPosition
107
+ * @param lastTarget
108
+ * @returns
109
+ */
110
+ }, {
111
+ key: "caclSingleCoordinate",
112
+ value: function caclSingleCoordinate(prevTarget, prevPosition, lastTarget, distance) {
113
+ var directionVector = prevPosition.clone().sub(prevTarget).normalize();
114
+ var lastPosition = directionVector.multiplyScalar(distance).add(lastTarget);
115
+ return lastPosition;
116
+ }
117
+
118
+ /**
119
+ * camera focus
120
+ * @param params
121
+ * @returns
122
+ */
123
+ }, {
124
+ key: "focus",
125
+ value: function focus(params) {
126
+ var _this3 = this;
127
+ return new Promise(function (res) {
128
+ var position = params.target,
129
+ _params$pitch = params.pitch,
130
+ pitch = _params$pitch === void 0 ? 0 : _params$pitch,
131
+ _params$yaw = params.yaw,
132
+ yaw = _params$yaw === void 0 ? 0 : _params$yaw,
133
+ _params$distance = params.distance,
134
+ distance = _params$distance === void 0 ? undefined : _params$distance,
135
+ duration = params.duration,
136
+ _onUpdate = params.onUpdate,
137
+ _params$distanceCoeff = params.distanceCoefficient,
138
+ distanceCoefficient = _params$distanceCoeff === void 0 ? 1 : _params$distanceCoeff;
139
+ var moveOptions = function moveOptions() {
140
+ var _ref, _params$isTrigger;
141
+ return {
142
+ duration: (_ref = duration && duration * 1000) !== null && _ref !== void 0 ? _ref : 1000,
143
+ isTrigger: (_params$isTrigger = params.isTrigger) !== null && _params$isTrigger !== void 0 ? _params$isTrigger : true,
144
+ onUpdate: function onUpdate(_ref2) {
145
+ var position = _ref2.position,
146
+ lookat = _ref2.lookat;
147
+ _onUpdate && _onUpdate({
148
+ position: position,
149
+ target: lookat
150
+ });
151
+ },
152
+ onComplate: function onComplate() {
153
+ var _params$duration;
154
+ res({
155
+ position: _this3.camera.position.toArray(),
156
+ target: _this3.controls.target.toArray(),
157
+ duration: (_params$duration = params.duration) !== null && _params$duration !== void 0 ? _params$duration : 0,
158
+ userInput: true,
159
+ pitch: pitch !== null && pitch !== void 0 ? pitch : 40
160
+ });
161
+ }
162
+ };
163
+ };
164
+
165
+ // if target is multiple points
166
+ if (Array.isArray(position[0])) {
167
+ var currentPos = position;
168
+ var _this3$caclCurrentPos = _this3.caclCurrentPos(currentPos, distanceCoefficient, distance),
169
+ lastPosition = _this3$caclCurrentPos.lastPosition,
170
+ lastLookat = _this3$caclCurrentPos.lastLookat;
171
+ _this3.motion(lastPosition, lastLookat, pitch, yaw, moveOptions());
172
+ }
173
+ // if target is single point
174
+ else {
175
+ var _currentPos = position;
176
+ var _lastPosition = _this3.caclSingleCoordinate(_this3.controls.target, _this3.camera.position, new Vector3().fromArray(_currentPos), distance);
177
+ var _lastLookat = new Vector3().fromArray(_currentPos);
178
+ _this3.motion(_lastPosition, _lastLookat, pitch, yaw, moveOptions());
179
+ }
180
+ });
181
+ }
86
182
 
87
- /**
88
- * camera focus
89
- * @param params
90
- * @returns
91
- */
92
- focus(params) {
93
- return new Promise(res => {
94
- const {
95
- target: position,
96
- pitch = 0,
97
- yaw = 0,
98
- distance = undefined,
99
- duration,
100
- onUpdate,
101
- distanceCoefficient = 1
102
- } = params;
103
- const moveOptions = () => {
104
- var _ref, _params$isTrigger;
105
- return {
106
- duration: (_ref = duration && duration * 1000) !== null && _ref !== void 0 ? _ref : 1000,
107
- isTrigger: (_params$isTrigger = params.isTrigger) !== null && _params$isTrigger !== void 0 ? _params$isTrigger : true,
108
- onUpdate: ({
109
- position,
110
- lookat
111
- }) => {
112
- onUpdate && onUpdate({
113
- position,
183
+ /**
184
+ * set camera main set position and target
185
+ * @param params
186
+ * @returns
187
+ */
188
+ }, {
189
+ key: "set",
190
+ value: function set(params) {
191
+ var _this4 = this;
192
+ var position = params.position,
193
+ target = params.target,
194
+ isTrigger = params.isTrigger,
195
+ duration = params.duration;
196
+ return new Promise(function (res, _) {
197
+ var _ref3;
198
+ _this4.motion(new Vector3(position[0], position[1], position[2]), new Vector3(target[0], target[1], target[2]), 0, 0, {
199
+ isTrigger: isTrigger !== null && isTrigger !== void 0 ? isTrigger : true,
200
+ duration: (_ref3 = duration && duration * 1000) !== null && _ref3 !== void 0 ? _ref3 : 1000,
201
+ onUpdate: function onUpdate(_ref4) {
202
+ var position = _ref4.position,
203
+ lookat = _ref4.lookat;
204
+ params.onUpdate && params.onUpdate({
205
+ position: position,
114
206
  target: lookat
115
207
  });
116
208
  },
117
- onComplate: () => {
118
- var _params$duration;
209
+ onComplate: function onComplate() {
210
+ var _params$duration2;
119
211
  res({
120
- position: this.camera.position.toArray(),
121
- target: this.controls.target.toArray(),
122
- duration: (_params$duration = params.duration) !== null && _params$duration !== void 0 ? _params$duration : 0,
123
- userInput: true,
124
- pitch: pitch !== null && pitch !== void 0 ? pitch : 40
212
+ position: _this4.camera.position.toArray(),
213
+ target: _this4.controls.target.toArray(),
214
+ isTrigger: true,
215
+ duration: (_params$duration2 = params.duration) !== null && _params$duration2 !== void 0 ? _params$duration2 : 0,
216
+ userInput: true
125
217
  });
126
218
  }
127
- };
128
- };
129
-
130
- // if target is multiple points
131
- if (Array.isArray(position[0])) {
132
- const currentPos = position;
133
- const {
134
- lastPosition,
135
- lastLookat
136
- } = this.caclCurrentPos(currentPos, distanceCoefficient, distance);
137
- this.motion(lastPosition, lastLookat, pitch, yaw, moveOptions());
138
- }
139
- // if target is single point
140
- else {
141
- const currentPos = position;
142
- const lastPosition = this.caclSingleCoordinate(this.controls.target, this.camera.position, new Vector3().fromArray(currentPos), distance);
143
- const lastLookat = new Vector3().fromArray(currentPos);
144
- this.motion(lastPosition, lastLookat, pitch, yaw, moveOptions());
145
- }
146
- });
147
- }
148
-
149
- /**
150
- * set camera, main set position and target
151
- * @param params
152
- * @returns
153
- */
154
- set(params) {
155
- const {
156
- position,
157
- target,
158
- isTrigger,
159
- duration
160
- } = params;
161
- return new Promise((res, _) => {
162
- var _ref2;
163
- this.motion(new Vector3(position[0], position[1], position[2]), new Vector3(target[0], target[1], target[2]), 0, 0, {
164
- isTrigger: isTrigger !== null && isTrigger !== void 0 ? isTrigger : true,
165
- duration: (_ref2 = duration && duration * 1000) !== null && _ref2 !== void 0 ? _ref2 : 1000,
166
- onUpdate: ({
167
- position,
168
- lookat
169
- }) => {
170
- params.onUpdate && params.onUpdate({
171
- position,
172
- target: lookat
173
- });
174
- },
175
- onComplate: () => {
176
- var _params$duration2;
177
- res({
178
- position: this.camera.position.toArray(),
179
- target: this.controls.target.toArray(),
180
- isTrigger: true,
181
- duration: (_params$duration2 = params.duration) !== null && _params$duration2 !== void 0 ? _params$duration2 : 0,
182
- userInput: true
183
- });
184
- }
219
+ });
185
220
  });
186
- });
187
- }
221
+ }
188
222
 
189
- /**
190
- * get camera position and target
191
- * @returns
192
- */
193
- get() {
194
- return {
195
- position: [this.camera.position.x, this.camera.position.y, this.camera.position.z],
196
- target: [this.controls.target.x, this.controls.target.y, this.controls.target.z]
197
- };
198
- }
223
+ /**
224
+ * get camera position and target
225
+ * @returns
226
+ */
227
+ }, {
228
+ key: "get",
229
+ value: function get() {
230
+ return {
231
+ position: [this.camera.position.x, this.camera.position.y, this.camera.position.z],
232
+ target: [this.controls.target.x, this.controls.target.y, this.controls.target.z]
233
+ };
234
+ }
199
235
 
200
- /**
201
- * get current pitch
202
- */
203
- get pitch() {
204
- const targetPosition = this.controls.target;
205
- const cameraPosition = this.camera.position;
206
- const currentDirection = cameraPosition.clone().sub(targetPosition);
207
- const plane = new Plane(new Vector3(0, 1, 0), 0);
208
- return -(MathUtils.radToDeg(plane.normal.angleTo(currentDirection)) - 90);
209
- }
236
+ /**
237
+ * get current pitch
238
+ */
239
+ }, {
240
+ key: "pitch",
241
+ get: function get() {
242
+ var targetPosition = this.controls.target;
243
+ var cameraPosition = this.camera.position;
244
+ var currentDirection = cameraPosition.clone().sub(targetPosition);
245
+ var plane = new Plane(new Vector3(0, 1, 0), 0);
246
+ return -(MathUtils.radToDeg(plane.normal.angleTo(currentDirection)) - 90);
247
+ }
210
248
 
211
- /**
212
- * get current yaw
213
- * @returns
214
- */
215
- get yaw() {
216
- return this.camera.rotationParent.y;
217
- }
249
+ /**
250
+ * get current yaw
251
+ * @returns
252
+ */
253
+ }, {
254
+ key: "yaw",
255
+ get: function get() {
256
+ return this.camera.rotationParent.y;
257
+ }
218
258
 
219
- /**
220
- * set pitch, similar to ue
221
- * @param deg
222
- */
223
- setPitch(deg) {
224
- if (deg > 90) deg = 90;
225
- if (deg < -90) deg = -90;
226
- const direction = new Vector3(0, 0, 1);
227
- const quaternion = new Quaternion();
228
- const pitchQuat = new Quaternion();
229
- pitchQuat.setFromAxisAngle(new Vector3(1, 0, 0), MathUtils.degToRad(-deg));
230
- quaternion.multiply(pitchQuat);
231
- direction.applyQuaternion(quaternion);
232
- direction.normalize();
233
- const distance = this.camera.position.distanceTo(this.controls.target);
234
- const cameraPosition = this.controls.target.clone().add(direction.multiplyScalar(distance));
235
- this.camera.position.copy(cameraPosition);
236
- }
259
+ /**
260
+ * set pitch, similar to ue
261
+ * @param deg
262
+ */
263
+ }, {
264
+ key: "setPitch",
265
+ value: function setPitch(deg) {
266
+ if (deg > 90) deg = 90;
267
+ if (deg < -90) deg = -90;
268
+ var direction = new Vector3(0, 0, 1);
269
+ var quaternion = new Quaternion();
270
+ var pitchQuat = new Quaternion();
271
+ pitchQuat.setFromAxisAngle(new Vector3(1, 0, 0), MathUtils.degToRad(-deg));
272
+ quaternion.multiply(pitchQuat);
273
+ direction.applyQuaternion(quaternion);
274
+ direction.normalize();
275
+ var distance = this.camera.position.distanceTo(this.controls.target);
276
+ var cameraPosition = this.controls.target.clone().add(direction.multiplyScalar(distance));
277
+ this.camera.position.copy(cameraPosition);
278
+ }
237
279
 
238
- /**
239
- * set yaw, similar to ue
240
- * @param deg
241
- */
242
- setYaw(deg) {
243
- if (deg > 180) deg = 180;
244
- if (deg < -180) deg = -180;
280
+ /**
281
+ * set yaw, similar to ue
282
+ * @param deg
283
+ */
284
+ }, {
285
+ key: "setYaw",
286
+ value: function setYaw(deg) {
287
+ if (deg > 180) deg = 180;
288
+ if (deg < -180) deg = -180;
245
289
 
246
- // @ts-ignore
247
- this.camera.rotationParent.y = MathUtils.degToRad(deg);
248
- }
290
+ // @ts-ignore
291
+ this.camera.rotationParent.y = MathUtils.degToRad(deg);
292
+ }
249
293
 
250
- /**
251
- * cacl Position By Follow
252
- * @param pitch
253
- * @param yaw
254
- * @param distance
255
- * @returns
256
- */
257
- caclPositionByFollow(pitch = 30, yaw = 0, distance = 60) {
258
- const axisX = new Vector3(1, 0, 0);
259
- const axisY = new Vector3(0, 1, 0);
260
- const axisZ = new Vector3(0, 0, -1);
261
- const position = new Vector3(0, 0, 0);
262
- const anglePitch = MathUtils.degToRad(pitch);
263
- const angleYaw = MathUtils.degToRad(yaw);
264
- const quaternionX = new Quaternion().setFromAxisAngle(axisX, anglePitch);
265
- const quaternionY = new Quaternion().setFromAxisAngle(axisY, angleYaw);
266
- position.addScaledVector(axisZ, distance);
267
- position.applyQuaternion(quaternionX);
268
- position.applyQuaternion(quaternionY);
269
- return position;
270
- }
294
+ /**
295
+ * cacl Position By Follow
296
+ * @param pitch
297
+ * @param yaw
298
+ * @param distance
299
+ * @returns
300
+ */
301
+ }, {
302
+ key: "caclPositionByFollow",
303
+ value: function caclPositionByFollow() {
304
+ var pitch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 30;
305
+ var yaw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
306
+ var distance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 60;
307
+ var axisX = new Vector3(1, 0, 0);
308
+ var axisY = new Vector3(0, 1, 0);
309
+ var axisZ = new Vector3(0, 0, -1);
310
+ var position = new Vector3(0, 0, 0);
311
+ var anglePitch = MathUtils.degToRad(pitch);
312
+ var angleYaw = MathUtils.degToRad(yaw);
313
+ var quaternionX = new Quaternion().setFromAxisAngle(axisX, anglePitch);
314
+ var quaternionY = new Quaternion().setFromAxisAngle(axisY, angleYaw);
315
+ position.addScaledVector(axisZ, distance);
316
+ position.applyQuaternion(quaternionX);
317
+ position.applyQuaternion(quaternionY);
318
+ return position;
319
+ }
271
320
 
272
- /**
273
- * follow 3d object, not only use in camera
274
- * @param target
275
- * @param camera
276
- * @param option
277
- * @returns
278
- */
279
- follow(target, camera, option) {
280
- const followId = this.followId++;
281
- const {
282
- relativeRotation = false,
283
- pitch = 30,
284
- yaw = 0,
285
- distance = 10
286
- } = option || {};
287
- const container = new Group();
288
- container.rotation.copy(target.rotation);
289
- container.scale.copy(target.scale);
290
- const oldCameraParent = camera.parent;
291
- let needUpdateRotation = true;
292
- container.add(camera);
293
- target.parent.add(container);
294
- this.controls.enabled = false;
295
- const followControls = new FollowControls(this.camera, this.sceneControl.renderer.domElement);
296
- const curPosition = this.caclPositionByFollow(pitch, yaw, distance);
297
- camera.position.copy(curPosition);
298
- followControls.radius = camera.position.distanceTo(target.position);
299
- followControls.addEventListener('start', () => {
300
- relativeRotation && (needUpdateRotation = false);
301
- });
302
- this.controls.target.copy(target.position);
303
- followControls.target = target.position;
304
- const cancelMotion = use.useframe(() => {
305
- container.position.copy(target.position);
321
+ /**
322
+ * follow 3d object, not only use in camera
323
+ * @param target
324
+ * @param camera
325
+ * @param option
326
+ * @returns
327
+ */
328
+ }, {
329
+ key: "follow",
330
+ value: function follow(target, camera, option) {
331
+ var _this5 = this;
332
+ var followId = this.followId++;
333
+ var _ref5 = option || {},
334
+ _ref5$relativeRotatio = _ref5.relativeRotation,
335
+ relativeRotation = _ref5$relativeRotatio === void 0 ? false : _ref5$relativeRotatio,
336
+ _ref5$pitch = _ref5.pitch,
337
+ pitch = _ref5$pitch === void 0 ? 30 : _ref5$pitch,
338
+ _ref5$yaw = _ref5.yaw,
339
+ yaw = _ref5$yaw === void 0 ? 0 : _ref5$yaw,
340
+ _ref5$distance = _ref5.distance,
341
+ distance = _ref5$distance === void 0 ? 10 : _ref5$distance;
342
+ var container = new Group();
343
+ container.rotation.copy(target.rotation);
306
344
  container.scale.copy(target.scale);
307
- needUpdateRotation && container.rotation.copy(target.rotation);
345
+ var oldCameraParent = camera.parent;
346
+ var needUpdateRotation = true;
347
+ container.add(camera);
348
+ target.parent.add(container);
349
+ this.controls.enabled = false;
350
+ var followControls = new FollowControls(this.camera, this.sceneControl.renderer.domElement);
351
+ var curPosition = this.caclPositionByFollow(pitch, yaw, distance);
352
+ camera.position.copy(curPosition);
353
+ followControls.radius = camera.position.distanceTo(target.position);
354
+ followControls.addEventListener('start', function () {
355
+ relativeRotation && (needUpdateRotation = false);
356
+ });
308
357
  this.controls.target.copy(target.position);
309
358
  followControls.target = target.position;
310
- followControls.update();
311
- });
312
- const cancel = () => {
313
- this.controls.enabled = true;
314
- oldCameraParent.add(camera);
315
- target.parent.remove(container);
316
- cancelMotion();
317
- followControls.dispose();
318
- };
319
- this.followCancelMap.set(followId, cancel);
320
- return followId;
321
- }
359
+ var cancelMotion = use.useframe(function () {
360
+ container.position.copy(target.position);
361
+ container.scale.copy(target.scale);
362
+ needUpdateRotation && container.rotation.copy(target.rotation);
363
+ _this5.controls.target.copy(target.position);
364
+ followControls.target = target.position;
365
+ followControls.update();
366
+ });
367
+ var cancel = function cancel() {
368
+ _this5.controls.enabled = true;
369
+ oldCameraParent.add(camera);
370
+ target.parent.remove(container);
371
+ cancelMotion();
372
+ followControls.dispose();
373
+ };
374
+ this.followCancelMap.set(followId, cancel);
375
+ return followId;
376
+ }
322
377
 
323
- /**
324
- * cancel follow
325
- * @param followId
326
- */
327
- cancelFollow(followId) {
328
- const cancel = this.followCancelMap.get(followId);
329
- cancel && cancel();
330
- }
378
+ /**
379
+ * cancel follow
380
+ * @param followId
381
+ */
382
+ }, {
383
+ key: "cancelFollow",
384
+ value: function cancelFollow(followId) {
385
+ var cancel = this.followCancelMap.get(followId);
386
+ cancel && cancel();
387
+ }
331
388
 
332
- /**
333
- * cancel all follow
334
- */
335
- cancelAllFollow() {
336
- this.followCancelMap.forEach(cancel => {
337
- cancel();
338
- });
339
- }
389
+ /**
390
+ * cancel all follow
391
+ */
392
+ }, {
393
+ key: "cancelAllFollow",
394
+ value: function cancelAllFollow() {
395
+ this.followCancelMap.forEach(function (cancel) {
396
+ cancel();
397
+ });
398
+ }
340
399
 
341
- /**
342
- * interpolation move camera
343
- * @param position
344
- * @param target
345
- * @param pitch
346
- * @param yaw
347
- * @param options
348
- * @returns
349
- */
350
- motion(position, target, pitch = 0, yaw = 0, options) {
351
- const currentPoition = this.camera.position.clone();
352
- const currentPositionInterpolation = new Vector3();
353
- if ((options === null || options === void 0 ? void 0 : options.duration) === 0) {
354
- this.camera.position.copy(position);
355
- this.controls.target.copy(target);
356
- if (pitch) {
357
- // @ts-ignore
358
- this.camera.rotationParent.x = MathUtils.degToRad(pitch);
359
- }
360
- if (yaw) {
361
- // @ts-ignore
362
- this.camera.rotationParent.y = MathUtils.degToRad(yaw);
400
+ /**
401
+ * interpolation move camera
402
+ * @param position
403
+ * @param target
404
+ * @param pitch
405
+ * @param yaw
406
+ * @param options
407
+ * @returns
408
+ */
409
+ }, {
410
+ key: "motion",
411
+ value: function motion(position, target) {
412
+ var _this6 = this;
413
+ var pitch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
414
+ var yaw = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
415
+ var options = arguments.length > 4 ? arguments[4] : undefined;
416
+ var currentPoition = this.camera.position.clone();
417
+ var currentPositionInterpolation = new Vector3();
418
+ if ((options === null || options === void 0 ? void 0 : options.duration) === 0) {
419
+ this.camera.position.copy(position);
420
+ this.controls.target.copy(target);
421
+ if (pitch) {
422
+ // @ts-ignore
423
+ this.camera.rotationParent.x = MathUtils.degToRad(pitch);
424
+ }
425
+ if (yaw) {
426
+ // @ts-ignore
427
+ this.camera.rotationParent.y = MathUtils.degToRad(yaw);
428
+ }
429
+ requestAnimationFrame(function () {
430
+ (options === null || options === void 0 ? void 0 : options.onComplate) && options.onComplate();
431
+ _this6.sceneControl.renderer.render(_this6.sceneControl.scene, _this6.sceneControl.camera);
432
+ });
433
+ return;
363
434
  }
364
- requestAnimationFrame(() => {
365
- (options === null || options === void 0 ? void 0 : options.onComplate) && options.onComplate();
366
- this.sceneControl.renderer.render(this.sceneControl.scene, this.sceneControl.camera);
367
- });
368
- return;
435
+ if (this.tween) this.tween.stop();
436
+ this.tween = new TWEEN.Tween(
437
+ // @ts-ignore
438
+ {
439
+ t: 0,
440
+ lookat: this.controls.target.clone(),
441
+ p: this.camera.rotationParent.x,
442
+ yaw: this.camera.rotationParent.y
443
+ })
444
+ // @ts-ignore
445
+ .to({
446
+ t: 1,
447
+ lookat: target,
448
+ p: MathUtils.degToRad(pitch),
449
+ y: MathUtils.degToRad(yaw)
450
+ }, (options === null || options === void 0 ? void 0 : options.duration) || 1000).onStart(function () {
451
+ (options === null || options === void 0 ? void 0 : options.onStart) && options.onStart();
452
+ _this6.controls.enabled = false;
453
+ _this6._isTransitionPeriod = true;
454
+ }).easing(TWEEN.Easing.Quadratic.InOut).onUpdate(function (_ref6) {
455
+ var t = _ref6.t,
456
+ lookat = _ref6.lookat,
457
+ p = _ref6.p;
458
+ _this6.controls.target.copy(lookat);
459
+ if (pitch)
460
+ // @ts-ignore
461
+ _this6.camera.rotationParent.x = p;
462
+ if (yaw)
463
+ // @ts-ignore
464
+ _this6.camera.rotationParent.y = p;
465
+ var currentPosition = currentPositionInterpolation.lerpVectors(currentPoition, position, t);
466
+ _this6.camera.position.copy(currentPosition);
467
+ (options === null || options === void 0 ? void 0 : options.onUpdate) && options.onUpdate({
468
+ position: currentPosition,
469
+ lookat: lookat
470
+ });
471
+ }).onComplete(function () {
472
+ requestAnimationFrame(function () {
473
+ (options === null || options === void 0 ? void 0 : options.onComplate) && options.onComplate();
474
+ });
475
+ _this6.controls.enabled = true;
476
+ setTimeout(function () {
477
+ _this6._isTransitionPeriod = false;
478
+ });
479
+ }).start();
369
480
  }
370
- if (this.tween) this.tween.stop();
371
- this.tween = new TWEEN.Tween(
372
- // @ts-ignore
373
- {
374
- t: 0,
375
- lookat: this.controls.target.clone(),
376
- p: this.camera.rotationParent.x,
377
- yaw: this.camera.rotationParent.y
378
- })
379
- // @ts-ignore
380
- .to({
381
- t: 1,
382
- lookat: target,
383
- p: MathUtils.degToRad(pitch),
384
- y: MathUtils.degToRad(yaw)
385
- }, (options === null || options === void 0 ? void 0 : options.duration) || 1000).onStart(() => {
386
- (options === null || options === void 0 ? void 0 : options.onStart) && options.onStart();
387
- this.controls.enabled = false;
388
- this._isTransitionPeriod = true;
389
- }).easing(TWEEN.Easing.Quadratic.InOut).onUpdate(({
390
- t,
391
- lookat,
392
- p
393
- }) => {
394
- this.controls.target.copy(lookat);
395
- if (pitch)
396
- // @ts-ignore
397
- this.camera.rotationParent.x = p;
398
- if (yaw)
399
- // @ts-ignore
400
- this.camera.rotationParent.y = p;
401
- const currentPosition = currentPositionInterpolation.lerpVectors(currentPoition, position, t);
402
- this.camera.position.copy(currentPosition);
403
- (options === null || options === void 0 ? void 0 : options.onUpdate) && options.onUpdate({
404
- position: currentPosition,
405
- lookat
406
- });
407
- }).onComplete(() => {
408
- requestAnimationFrame(() => {
409
- (options === null || options === void 0 ? void 0 : options.onComplate) && options.onComplate();
410
- });
411
- this.controls.enabled = true;
412
- setTimeout(() => {
413
- this._isTransitionPeriod = false;
414
- });
415
- }).start();
416
- }
417
- }
481
+ }]);
482
+ return PerspectiveCameraExpand;
483
+ }(EventDispatcher);
418
484
  //# sourceMappingURL=CameraExpand.js.map