@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.
- package/dist/business/Animation/motion/index.js +56 -35
- package/dist/business/Animation/motion/index.js.map +1 -1
- package/dist/business/Animation/type.js +2 -2
- package/dist/business/Area/Fence/FenceBase.js +187 -146
- package/dist/business/Area/Fence/FenceBase.js.map +1 -1
- package/dist/business/Area/Fence/fence_base_01.js +112 -120
- package/dist/business/Area/Fence/fence_base_01.js.map +1 -1
- package/dist/business/Area/Fence/fence_feeting_01.js +130 -218
- package/dist/business/Area/Fence/fence_feeting_01.js.map +1 -1
- package/dist/business/Area/Fence/fence_roll_01.js +130 -140
- package/dist/business/Area/Fence/fence_roll_01.js.map +1 -1
- package/dist/business/Area/FillArea/FillAreaBase.js +126 -87
- package/dist/business/Area/FillArea/FillAreaBase.js.map +1 -1
- package/dist/business/Area/FillArea/fillArea_face_01.js +98 -72
- package/dist/business/Area/FillArea/fillArea_face_01.js.map +1 -1
- package/dist/business/Area/FillArea/fillArea_line_01.js +94 -66
- package/dist/business/Area/FillArea/fillArea_line_01.js.map +1 -1
- package/dist/business/Area/index.js +483 -267
- package/dist/business/Area/index.js.map +1 -1
- package/dist/business/Area/tool.js +26 -14
- package/dist/business/Area/tool.js.map +1 -1
- package/dist/business/Base/ObjectLayer.js +46 -21
- package/dist/business/Base/ObjectLayer.js.map +1 -1
- package/dist/business/Batch/index.js +234 -189
- package/dist/business/Batch/index.js.map +1 -1
- package/dist/business/Box/index.js +81 -52
- package/dist/business/Box/index.js.map +1 -1
- package/dist/business/Cylinder/index.js +79 -51
- package/dist/business/Cylinder/index.js.map +1 -1
- package/dist/business/Flyline/bubble/CircleBubble.js +9 -1
- package/dist/business/Flyline/bubble/CircleBubble.js.map +1 -1
- package/dist/business/Flyline/bubble/index.js +21 -7
- package/dist/business/Flyline/bubble/index.js.map +1 -1
- package/dist/business/Flyline/index.js +162 -96
- package/dist/business/Flyline/index.js.map +1 -1
- package/dist/business/Flyline/line/ArcLine.js +291 -208
- package/dist/business/Flyline/line/ArcLine.js.map +1 -1
- package/dist/business/Flyline/line/index.js +22 -8
- package/dist/business/Flyline/line/index.js.map +1 -1
- package/dist/business/HeatMap/HeatMap.js +467 -380
- package/dist/business/HeatMap/HeatMap.js.map +1 -1
- package/dist/business/HeatMap/core.js +525 -405
- package/dist/business/HeatMap/core.js.map +1 -1
- package/dist/business/HeatMap/shader.js +3 -69
- package/dist/business/HeatMap/shader.js.map +1 -1
- package/dist/business/InfoPanel/index.js +242 -201
- package/dist/business/InfoPanel/index.js.map +1 -1
- package/dist/business/Line/index.js +88 -55
- package/dist/business/Line/index.js.map +1 -1
- package/dist/business/Mark/KeyframeAnimation.js +176 -145
- package/dist/business/Mark/KeyframeAnimation.js.map +1 -1
- package/dist/business/Mark/index.js +294 -196
- package/dist/business/Mark/index.js.map +1 -1
- package/dist/business/Mark/shader/tanhao.js +3 -36
- package/dist/business/Mark/shader/tanhao.js.map +1 -1
- package/dist/business/Mark/type.js +1 -1
- package/dist/business/MaterialSwitch/MaterialSwitchSystem.js +551 -377
- package/dist/business/MaterialSwitch/MaterialSwitchSystem.js.map +1 -1
- package/dist/business/MaterialSwitch/inject.js +58 -92
- package/dist/business/MaterialSwitch/inject.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/finalFade.js +2 -74
- package/dist/business/MaterialSwitch/shader/finalFade.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/ground.js +16 -95
- package/dist/business/MaterialSwitch/shader/ground.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/groundBase64.js +3 -9
- package/dist/business/MaterialSwitch/shader/groundBase64.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/realFade.js +9 -48
- package/dist/business/MaterialSwitch/shader/realFade.js.map +1 -1
- package/dist/business/Plane/index.js +78 -51
- package/dist/business/Plane/index.js.map +1 -1
- package/dist/business/Poi/index.js +336 -248
- package/dist/business/Poi/index.js.map +1 -1
- package/dist/business/Poi/link/Cylinder.js +89 -56
- package/dist/business/Poi/link/Cylinder.js.map +1 -1
- package/dist/business/Poi/link/Pyramid.js +165 -104
- package/dist/business/Poi/link/Pyramid.js.map +1 -1
- package/dist/business/Poi/link/index.js +114 -54
- package/dist/business/Poi/link/index.js.map +1 -1
- package/dist/business/Poi/panel/index.js +373 -315
- package/dist/business/Poi/panel/index.js.map +1 -1
- package/dist/business/Poi/panel/utils.js +10 -5
- package/dist/business/Poi/panel/utils.js.map +1 -1
- package/dist/business/Poi/particle/DoubleCircle.js +107 -71
- package/dist/business/Poi/particle/DoubleCircle.js.map +1 -1
- package/dist/business/Poi/particle/DynamicCircle.js +111 -75
- package/dist/business/Poi/particle/DynamicCircle.js.map +1 -1
- package/dist/business/Poi/particle/SingleCircle.js +98 -62
- package/dist/business/Poi/particle/SingleCircle.js.map +1 -1
- package/dist/business/Poi/particle/index.js +117 -49
- package/dist/business/Poi/particle/index.js.map +1 -1
- package/dist/business/Poi/shader/circle.js +3 -31
- package/dist/business/Poi/shader/circle.js.map +1 -1
- package/dist/business/Poi/shader/cylinder.js +3 -37
- package/dist/business/Poi/shader/cylinder.js.map +1 -1
- package/dist/business/Poi/shader/doubleCircle.js +3 -55
- package/dist/business/Poi/shader/doubleCircle.js.map +1 -1
- package/dist/business/Poi/shader/dynamicCircle.js +3 -67
- package/dist/business/Poi/shader/dynamicCircle.js.map +1 -1
- package/dist/business/Poi/title/Border.js +27 -7
- package/dist/business/Poi/title/Border.js.map +1 -1
- package/dist/business/Poi/title/Ellipse.js +27 -7
- package/dist/business/Poi/title/Ellipse.js.map +1 -1
- package/dist/business/Poi/title/index.js +292 -208
- package/dist/business/Poi/title/index.js.map +1 -1
- package/dist/business/Poi/tools.js +17 -18
- package/dist/business/Poi/tools.js.map +1 -1
- package/dist/business/Sphere/index.js +72 -47
- package/dist/business/Sphere/index.js.map +1 -1
- package/dist/business/Spline/index.js +245 -190
- package/dist/business/Spline/index.js.map +1 -1
- package/dist/business/SplitBuilding/index.js +536 -327
- package/dist/business/SplitBuilding/index.js.map +1 -1
- package/dist/business/SplitBuilding/type.js +2 -2
- package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js +275 -218
- package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js.map +1 -1
- package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js +177 -132
- package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js.map +1 -1
- package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js +1 -51
- package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js.map +1 -1
- package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js +1 -6
- package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js.map +1 -1
- package/dist/business/TrafficComponents/base.js +55 -32
- package/dist/business/TrafficComponents/base.js.map +1 -1
- package/dist/business/TrafficComponents/utils.d.ts +1 -1
- package/dist/business/TrafficComponents/utils.js +25 -26
- package/dist/business/TrafficComponents/utils.js.map +1 -1
- package/dist/business/Utils/Curve.js +56 -40
- package/dist/business/Utils/Curve.js.map +1 -1
- package/dist/business/Utils/constant.js +1 -1
- package/dist/business/Utils/constant.js.map +1 -1
- package/dist/business/Utils/defineProps.js +14 -13
- package/dist/business/Utils/defineProps.js.map +1 -1
- package/dist/business/Utils/round-curve.js +153 -127
- package/dist/business/Utils/round-curve.js.map +1 -1
- package/dist/business/VideoPanel/index.js +319 -258
- package/dist/business/VideoPanel/index.js.map +1 -1
- package/dist/business/Water/index.js +108 -78
- package/dist/business/Water/index.js.map +1 -1
- package/dist/business/Water/types.js +1 -1
- package/dist/business/Water/types.js.map +1 -1
- package/dist/core/Camera/PerspectiveCamera/CameraExpand.js +449 -383
- package/dist/core/Camera/PerspectiveCamera/CameraExpand.js.map +1 -1
- package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js +142 -107
- package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js.map +1 -1
- package/dist/core/Controls/FirstViewControl/index.js +96 -84
- package/dist/core/Controls/FirstViewControl/index.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/action/input.js +98 -77
- package/dist/core/Controls/ThirdViewControl/action/input.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/config/constants.js +1 -1
- package/dist/core/Controls/ThirdViewControl/config/constants.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/index.js +28 -19
- package/dist/core/Controls/ThirdViewControl/index.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player/animation.js +155 -126
- package/dist/core/Controls/ThirdViewControl/player/animation.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player/camera.js +63 -47
- package/dist/core/Controls/ThirdViewControl/player/camera.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player/control.js +49 -39
- package/dist/core/Controls/ThirdViewControl/player/control.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player.js +91 -66
- package/dist/core/Controls/ThirdViewControl/player.js.map +1 -1
- package/dist/core/Controls/base.js +30 -14
- package/dist/core/Controls/base.js.map +1 -1
- package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js +131 -92
- package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js.map +1 -1
- package/dist/core/Debug/PerformanceInfo/Performance.js +47 -22
- package/dist/core/Debug/PerformanceInfo/Performance.js.map +1 -1
- package/dist/core/Light/PointLight/PointLightExt.js +21 -4
- package/dist/core/Light/PointLight/PointLightExt.js.map +1 -1
- package/dist/core/Material/FinirMaterial/FinirMaterial.js +57 -37
- package/dist/core/Material/FinirMaterial/FinirMaterial.js.map +1 -1
- package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js +153 -116
- package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js.map +1 -1
- package/dist/core/Material/PristineGridMaterial/shader/fragment.js +1 -95
- package/dist/core/Material/PristineGridMaterial/shader/fragment.js.map +1 -1
- package/dist/core/Material/PristineGridMaterial/shader/vertex.js +1 -26
- package/dist/core/Material/PristineGridMaterial/shader/vertex.js.map +1 -1
- package/dist/core/Material/SurfaceMaterial/index.js +172 -76
- package/dist/core/Material/SurfaceMaterial/index.js.map +1 -1
- package/dist/core/Material/decorators.js +11 -6
- package/dist/core/Material/decorators.js.map +1 -1
- package/dist/core/PostEffects/addACESFilmicToneMappingPass.js +12 -16
- package/dist/core/PostEffects/addACESFilmicToneMappingPass.js.map +1 -1
- package/dist/core/PostEffects/addBrightnessContrastPass.js +13 -17
- package/dist/core/PostEffects/addBrightnessContrastPass.js.map +1 -1
- package/dist/core/PostEffects/bloomPass.js +10 -17
- package/dist/core/PostEffects/bloomPass.js.map +1 -1
- package/dist/core/PostEffects/bloomSelect.js +43 -60
- package/dist/core/PostEffects/bloomSelect.js.map +1 -1
- package/dist/core/PostEffects/colorifyPass.js +13 -17
- package/dist/core/PostEffects/colorifyPass.js.map +1 -1
- package/dist/core/PostEffects/index.js +22 -28
- package/dist/core/PostEffects/index.js.map +1 -1
- package/dist/core/PostEffects/outlinePass.js +50 -37
- package/dist/core/PostEffects/outlinePass.js.map +1 -1
- package/dist/core/PostEffects/postprocessing.js +12 -14
- package/dist/core/PostEffects/postprocessing.js.map +1 -1
- package/dist/core/PostEffects/saoPass.js +10 -15
- package/dist/core/PostEffects/saoPass.js.map +1 -1
- package/dist/core/PostEffects/shader/colorify.js +3 -22
- package/dist/core/PostEffects/shader/colorify.js.map +1 -1
- package/dist/core/PostEffects/shader/gammaCorrectionShader.js +3 -27
- package/dist/core/PostEffects/shader/gammaCorrectionShader.js.map +1 -1
- package/dist/core/PostEffects/shader/mapping.js +3 -66
- package/dist/core/PostEffects/shader/mapping.js.map +1 -1
- package/dist/core/PostEffects/shader/thermalMaging.js +3 -28
- package/dist/core/PostEffects/shader/thermalMaging.js.map +1 -1
- package/dist/core/SceneEffect/grow/grow.js +101 -85
- package/dist/core/SceneEffect/grow/grow.js.map +1 -1
- package/dist/core/SceneEffect/grow/style_down.js +77 -60
- package/dist/core/SceneEffect/grow/style_down.js.map +1 -1
- package/dist/core/SceneEffect/grow/style_up.js +81 -64
- package/dist/core/SceneEffect/grow/style_up.js.map +1 -1
- package/dist/core/SceneEffect/grow/type.js +2 -2
- package/dist/core/SceneEffect/grow/type.js.map +1 -1
- package/dist/core/WeatherSystem/DynamicWeatherSystem.js +76 -51
- package/dist/core/WeatherSystem/DynamicWeatherSystem.js.map +1 -1
- package/dist/core/WeatherSystem/hdr/index.js +105 -69
- package/dist/core/WeatherSystem/hdr/index.js.map +1 -1
- package/dist/core/WeatherSystem/index.js +124 -77
- package/dist/core/WeatherSystem/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/fog/index.js +80 -52
- package/dist/core/WeatherSystem/objects/fog/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/index.js +84 -72
- package/dist/core/WeatherSystem/objects/rain/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/lineRain.js +118 -88
- package/dist/core/WeatherSystem/objects/rain/lineRain.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/plane.js +146 -116
- package/dist/core/WeatherSystem/objects/rain/plane.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/point.js +148 -100
- package/dist/core/WeatherSystem/objects/rain/point.js.map +1 -1
- package/dist/core/WeatherSystem/objects/sky/cloud.js +104 -71
- package/dist/core/WeatherSystem/objects/sky/cloud.js.map +1 -1
- package/dist/core/WeatherSystem/objects/sky/index.js +84 -66
- package/dist/core/WeatherSystem/objects/sky/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/sky/outline.js +45 -25
- package/dist/core/WeatherSystem/objects/sky/outline.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/cloud.js +3 -74
- package/dist/core/WeatherSystem/shaders/cloud.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/fog.js +3 -103
- package/dist/core/WeatherSystem/shaders/fog.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/rain.js +7 -206
- package/dist/core/WeatherSystem/shaders/rain.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/sky.js +3 -87
- package/dist/core/WeatherSystem/shaders/sky.js.map +1 -1
- package/dist/core/WeatherSystem/sky/index.js +135 -104
- package/dist/core/WeatherSystem/sky/index.js.map +1 -1
- package/dist/core/WeatherSystem/utils/constant.js +38 -44
- package/dist/core/WeatherSystem/utils/constant.js.map +1 -1
- package/dist/core/WeatherSystem/utils/math.js +25 -18
- package/dist/core/WeatherSystem/utils/math.js.map +1 -1
- package/dist/core/WeatherSystem/utils/type.js +1 -1
- package/dist/core/WeatherSystem/utils/type.js.map +1 -1
- package/dist/core/WeatherSystem/weather/index.js +141 -96
- package/dist/core/WeatherSystem/weather/index.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- 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" ==
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
_defineProperty(
|
|
17
|
-
_defineProperty(
|
|
18
|
-
_defineProperty(
|
|
19
|
-
_defineProperty(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
duration
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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$
|
|
209
|
+
onComplate: function onComplate() {
|
|
210
|
+
var _params$duration2;
|
|
119
211
|
res({
|
|
120
|
-
position:
|
|
121
|
-
target:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
this.camera.rotationParent.y = MathUtils.degToRad(deg);
|
|
292
|
+
}
|
|
249
293
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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
|