@anov/3d-ability 0.0.142 → 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.js +24 -25
- 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,8 +1,26 @@
|
|
|
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); }
|
|
1
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
5
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
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); } }
|
|
13
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
+
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); }
|
|
15
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
|
+
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); }; }
|
|
17
|
+
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); }
|
|
18
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
19
|
+
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; } }
|
|
20
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
3
21
|
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; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
23
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
24
|
/*
|
|
7
25
|
* @Descripttion:
|
|
8
26
|
* @version:
|
|
@@ -15,63 +33,78 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
15
33
|
*/
|
|
16
34
|
import ObjectLayer from "../Base/ObjectLayer";
|
|
17
35
|
import { Vector3, BufferGeometry, LineDashedMaterial, LineBasicMaterial, Line as ThreeLine } from '@anov/3d-core';
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
material = {}
|
|
30
|
-
} = options;
|
|
31
|
-
const vecPoints = points.map(p => Array.isArray(p) ? new Vector3(...p) : p);
|
|
32
|
-
const geometry = new BufferGeometry().setFromPoints(vecPoints);
|
|
33
|
-
// 默认参数
|
|
34
|
-
const defaultBasic = {
|
|
35
|
-
color: 0xffffff,
|
|
36
|
-
linewidth: 1,
|
|
37
|
-
linecap: 'round',
|
|
38
|
-
linejoin: 'round',
|
|
39
|
-
opacity: 1,
|
|
40
|
-
transparent: false,
|
|
41
|
-
visible: true,
|
|
42
|
-
depthTest: true,
|
|
43
|
-
depthWrite: true
|
|
44
|
-
};
|
|
45
|
-
const defaultDashed = _objectSpread(_objectSpread({}, defaultBasic), {}, {
|
|
46
|
-
scale: 1,
|
|
47
|
-
dashSize: 3,
|
|
48
|
-
gapSize: 1
|
|
49
|
-
});
|
|
50
|
-
const mat = dashed ? new LineDashedMaterial(_objectSpread(_objectSpread({}, defaultDashed), material)) : new LineBasicMaterial(_objectSpread(_objectSpread({}, defaultBasic), material));
|
|
51
|
-
const line = new ThreeLine(geometry, mat);
|
|
52
|
-
if (dashed) line.computeLineDistances();
|
|
53
|
-
return line;
|
|
36
|
+
export var Line = /*#__PURE__*/function (_ObjectLayer) {
|
|
37
|
+
_inherits(Line, _ObjectLayer);
|
|
38
|
+
var _super = _createSuper(Line);
|
|
39
|
+
function Line(options) {
|
|
40
|
+
var _this;
|
|
41
|
+
_classCallCheck(this, Line);
|
|
42
|
+
_this = _super.call(this);
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "line", void 0);
|
|
44
|
+
_this.line = _this.createLine(options);
|
|
45
|
+
_this.add(_this.line); // 挂载到 ObjectLayer 中
|
|
46
|
+
return _this;
|
|
54
47
|
}
|
|
48
|
+
_createClass(Line, [{
|
|
49
|
+
key: "createLine",
|
|
50
|
+
value: function createLine(options) {
|
|
51
|
+
var points = options.points,
|
|
52
|
+
_options$dashed = options.dashed,
|
|
53
|
+
dashed = _options$dashed === void 0 ? false : _options$dashed,
|
|
54
|
+
_options$material = options.material,
|
|
55
|
+
material = _options$material === void 0 ? {} : _options$material;
|
|
56
|
+
var vecPoints = points.map(function (p) {
|
|
57
|
+
return Array.isArray(p) ? _construct(Vector3, _toConsumableArray(p)) : p;
|
|
58
|
+
});
|
|
59
|
+
var geometry = new BufferGeometry().setFromPoints(vecPoints);
|
|
60
|
+
// 默认参数
|
|
61
|
+
var defaultBasic = {
|
|
62
|
+
color: 0xffffff,
|
|
63
|
+
linewidth: 1,
|
|
64
|
+
linecap: 'round',
|
|
65
|
+
linejoin: 'round',
|
|
66
|
+
opacity: 1,
|
|
67
|
+
transparent: false,
|
|
68
|
+
visible: true,
|
|
69
|
+
depthTest: true,
|
|
70
|
+
depthWrite: true
|
|
71
|
+
};
|
|
72
|
+
var defaultDashed = _objectSpread(_objectSpread({}, defaultBasic), {}, {
|
|
73
|
+
scale: 1,
|
|
74
|
+
dashSize: 3,
|
|
75
|
+
gapSize: 1
|
|
76
|
+
});
|
|
77
|
+
var mat = dashed ? new LineDashedMaterial(_objectSpread(_objectSpread({}, defaultDashed), material)) : new LineBasicMaterial(_objectSpread(_objectSpread({}, defaultBasic), material));
|
|
78
|
+
var line = new ThreeLine(geometry, mat);
|
|
79
|
+
if (dashed) line.computeLineDistances();
|
|
80
|
+
return line;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** 更新线条 */
|
|
84
|
+
}, {
|
|
85
|
+
key: "updateLine",
|
|
86
|
+
value: function updateLine(options) {
|
|
87
|
+
if (this.line) {
|
|
88
|
+
this.remove(this.line);
|
|
89
|
+
this.line.geometry.dispose();
|
|
90
|
+
this.line.material.dispose();
|
|
91
|
+
}
|
|
92
|
+
this.line = this.createLine(options);
|
|
93
|
+
this.add(this.line);
|
|
94
|
+
}
|
|
55
95
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
96
|
+
/** 销毁释放资源 */
|
|
97
|
+
}, {
|
|
98
|
+
key: "destroy",
|
|
99
|
+
value: function destroy() {
|
|
100
|
+
if (!this.line) return;
|
|
59
101
|
this.remove(this.line);
|
|
60
102
|
this.line.geometry.dispose();
|
|
61
103
|
this.line.material.dispose();
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
this.line = null;
|
|
62
106
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/** 销毁释放资源 */
|
|
68
|
-
destroy() {
|
|
69
|
-
if (!this.line) return;
|
|
70
|
-
this.remove(this.line);
|
|
71
|
-
this.line.geometry.dispose();
|
|
72
|
-
this.line.material.dispose();
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
this.line = null;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
107
|
+
}]);
|
|
108
|
+
return Line;
|
|
109
|
+
}(ObjectLayer);
|
|
77
110
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ObjectLayer","Vector3","BufferGeometry","LineDashedMaterial","LineBasicMaterial","Line","ThreeLine","
|
|
1
|
+
{"version":3,"names":["ObjectLayer","Vector3","BufferGeometry","LineDashedMaterial","LineBasicMaterial","Line","ThreeLine","_ObjectLayer","_inherits","_super","_createSuper","options","_this","_classCallCheck","call","_defineProperty","_assertThisInitialized","line","createLine","add","_createClass","key","value","points","_options$dashed","dashed","_options$material","material","vecPoints","map","p","Array","isArray","_construct","_toConsumableArray","geometry","setFromPoints","defaultBasic","color","linewidth","linecap","linejoin","opacity","transparent","visible","depthTest","depthWrite","defaultDashed","_objectSpread","scale","dashSize","gapSize","mat","computeLineDistances","updateLine","remove","dispose","destroy"],"sources":["../../../src/business/Line/index.ts"],"sourcesContent":["/*\n * @Descripttion: \n * @version: \n * @Author: 周志国\n * @Date: 2025-09-08 16:09:35\n * @LastEditors: 周志国\n * @LastEditTime: 2025-09-08 17:02:11\n * @changeLog: \n * @FilePath: /anov-3d-webgl/packages/anov-3d-ability/src/business/Line/index.ts\n */\nimport ObjectLayer from '../Base/ObjectLayer'\nimport type { options } from './types'\nimport { ILine } from './interface'\nimport type { Line as TLine } from '@anov/3d-core'\nimport {\n Vector3,\n BufferGeometry,\n LineDashedMaterial,\n LineDashedMaterialParameters,\n LineBasicMaterial,\n LineBasicMaterialParameters,\n Line as ThreeLine\n} from '@anov/3d-core'\n\nexport class Line extends ObjectLayer implements ILine {\n private line: TLine\n\n constructor(options: options) {\n super()\n this.line = this.createLine(options)\n this.add(this.line) // 挂载到 ObjectLayer 中\n }\n\n public createLine(options: options): TLine {\n const { points, dashed = false, material = {} } = options\n const vecPoints = points.map(p =>\n Array.isArray(p) ? new Vector3(...p) : p\n )\n const geometry = new BufferGeometry().setFromPoints(vecPoints)\n // 默认参数\n const defaultBasic: LineBasicMaterialParameters = {\n color: 0xffffff,\n linewidth: 1,\n linecap: 'round',\n linejoin: 'round',\n opacity: 1,\n transparent: false,\n visible: true,\n depthTest: true,\n depthWrite: true\n }\n\n const defaultDashed: LineDashedMaterialParameters = {\n ...defaultBasic,\n scale: 1,\n dashSize: 3,\n gapSize: 1\n }\n\n const mat = dashed\n ? new LineDashedMaterial({ ...defaultDashed, ...material })\n : new LineBasicMaterial({ ...defaultBasic, ...material })\n\n const line = new ThreeLine(geometry, mat)\n\n if (dashed) line.computeLineDistances()\n\n return line\n }\n\n /** 更新线条 */\n public updateLine(options: options) {\n if (this.line) {\n this.remove(this.line)\n this.line.geometry.dispose()\n ; (this.line.material as any).dispose()\n }\n this.line = this.createLine(options)\n this.add(this.line)\n }\n\n /** 销毁释放资源 */\n public destroy() {\n if (!this.line) return\n this.remove(this.line)\n this.line.geometry.dispose()\n ; (this.line.material as any).dispose()\n // @ts-ignore\n this.line = null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,WAAW;AAIlB,SACEC,OAAO,EACPC,cAAc,EACdC,kBAAkB,EAElBC,iBAAiB,EAEjBC,IAAI,IAAIC,SAAS,QACZ,eAAe;AAEtB,WAAcD,IAAI,0BAAAE,YAAA;EAAAC,SAAA,CAAAH,IAAA,EAAAE,YAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAL,IAAA;EAGhB,SAAAA,KAAYM,OAAgB,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAR,IAAA;IAC5BO,KAAA,GAAAH,MAAA,CAAAK,IAAA;IAAOC,eAAA,CAAAC,sBAAA,CAAAJ,KAAA;IACPA,KAAA,CAAKK,IAAI,GAAGL,KAAA,CAAKM,UAAU,CAACP,OAAO,CAAC;IACpCC,KAAA,CAAKO,GAAG,CAACP,KAAA,CAAKK,IAAI,CAAC,EAAC;IAAA,OAAAL,KAAA;EACtB;EAACQ,YAAA,CAAAf,IAAA;IAAAgB,GAAA;IAAAC,KAAA,EAED,SAAA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iB,GAAG,CAAC;MAEzC,IAAI3B,MAAM,EAAER,IAAI,CAACoC,oBAAoB,CAAC,CAAC;MAEvC,OAAOpC,IAAI;IACb;;IAEA;EAAA;IAAAI,GAAA;IAAAC,KAAA,EACA,SAAAgC,WAAkB3C,OAAgB,EAAE;MAClC,IAAI,IAAI,CAACM,IAAI,EAAE;QACb,IAAI,CAACsC,MAAM,CAAC,IAAI,CAACtC,IAAI,CAAC;QACtB,IAAI,CAACA,IAAI,CAACkB,QAAQ,CAACqB,OAAO,CAAC,CAAC;QACvB,IAAI,CAACvC,IAAI,CAACU,QAAQ,CAAS6B,OAAO,CAAC,CAAC;MAC3C;MACA,IAAI,CAACvC,IAAI,GAAG,IAAI,CAACC,UAAU,CAACP,OAAO,CAAC;MACpC,IAAI,CAACQ,GAAG,CAAC,IAAI,CAACF,IAAI,CAAC;IACrB;;IAEA;EAAA;IAAAI,GAAA;IAAAC,KAAA,EACA,SAAAmC,QAAA,EAAiB;MACf,IAAI,CAAC,IAAI,CAACxC,IAAI,EAAE;MAChB,IAAI,CAACsC,MAAM,CAAC,IAAI,CAACtC,IAAI,CAAC;MACtB,IAAI,CAACA,IAAI,CAACkB,QAAQ,CAACqB,OAAO,CAAC,CAAC;MACvB,IAAI,CAACvC,IAAI,CAACU,QAAQ,CAAS6B,OAAO,CAAC,CAAC;MACzC;MACA,IAAI,CAACvC,IAAI,GAAG,IAAI;IAClB;EAAC;EAAA,OAAAZ,IAAA;AAAA,EAjEwBL,WAAW"}
|
|
@@ -1,6 +1,10 @@
|
|
|
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; }
|
|
1
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
8
|
import { AnimationClip, AnimationMixer, Box3, LoopRepeat, NumberKeyframeTrack, VectorKeyframeTrack } from '@anov/3d-core';
|
|
5
9
|
|
|
6
10
|
// 动画类型
|
|
@@ -11,8 +15,9 @@ var EMarkAnimationType = /*#__PURE__*/function (EMarkAnimationType) {
|
|
|
11
15
|
EMarkAnimationType["Flash"] = "flash";
|
|
12
16
|
return EMarkAnimationType;
|
|
13
17
|
}(EMarkAnimationType || {}); // 闪烁
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
var KeyframeAnimation = /*#__PURE__*/function () {
|
|
19
|
+
function KeyframeAnimation(target, options) {
|
|
20
|
+
_classCallCheck(this, KeyframeAnimation);
|
|
16
21
|
_defineProperty(this, "_target", void 0);
|
|
17
22
|
_defineProperty(this, "_duration", void 0);
|
|
18
23
|
_defineProperty(this, "_type", void 0);
|
|
@@ -21,11 +26,11 @@ class KeyframeAnimation {
|
|
|
21
26
|
_defineProperty(this, "_animations", new Map());
|
|
22
27
|
_defineProperty(this, "_animationClips", new Map());
|
|
23
28
|
this._target = target;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
duration = 1,
|
|
27
|
-
enable =
|
|
28
|
-
|
|
29
|
+
var type = options.type,
|
|
30
|
+
_options$duration = options.duration,
|
|
31
|
+
duration = _options$duration === void 0 ? 1 : _options$duration,
|
|
32
|
+
_options$enable = options.enable,
|
|
33
|
+
enable = _options$enable === void 0 ? true : _options$enable;
|
|
29
34
|
this._type = type;
|
|
30
35
|
this._duration = duration;
|
|
31
36
|
this._enable = enable;
|
|
@@ -36,153 +41,179 @@ class KeyframeAnimation {
|
|
|
36
41
|
/**
|
|
37
42
|
* 获取动画混合器
|
|
38
43
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
_createClass(KeyframeAnimation, [{
|
|
45
|
+
key: "mixer",
|
|
46
|
+
get: function get() {
|
|
47
|
+
return this._mixer;
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "duration",
|
|
51
|
+
get: function get() {
|
|
52
|
+
return this._duration;
|
|
53
|
+
},
|
|
54
|
+
set: function set(value) {
|
|
55
|
+
if (this._duration === value) return;
|
|
56
|
+
this._duration = value;
|
|
57
|
+
this.reset();
|
|
58
|
+
this.setupAnimations();
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "type",
|
|
62
|
+
get: function get() {
|
|
63
|
+
return this._type;
|
|
64
|
+
},
|
|
65
|
+
set: function set(value) {
|
|
66
|
+
this._type = value;
|
|
67
|
+
this.reset();
|
|
68
|
+
this.setupAnimations();
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "enable",
|
|
72
|
+
get: function get() {
|
|
73
|
+
return this._enable;
|
|
74
|
+
}
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
/**
|
|
77
|
+
* 重置所有动画
|
|
78
|
+
*/
|
|
79
|
+
}, {
|
|
80
|
+
key: "reset",
|
|
81
|
+
value: function reset() {
|
|
82
|
+
var _this = this;
|
|
83
|
+
this._mixer.stopAllAction();
|
|
84
|
+
this._animationClips.forEach(function (clip) {
|
|
85
|
+
_this._mixer.uncacheClip(clip);
|
|
86
|
+
});
|
|
87
|
+
this._animations.clear();
|
|
88
|
+
this._animationClips.clear();
|
|
89
|
+
}
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
/**
|
|
92
|
+
* 设置动画
|
|
93
|
+
*/
|
|
94
|
+
}, {
|
|
95
|
+
key: "setupAnimations",
|
|
96
|
+
value: function setupAnimations() {
|
|
97
|
+
var _this$_target,
|
|
98
|
+
_this2 = this;
|
|
99
|
+
if (!this.enable) return;
|
|
100
|
+
var types = Array.isArray(this.type) ? this.type : [this.type];
|
|
82
101
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const action = this._mixer.clipAction(animationClip);
|
|
102
|
+
// 获取Mesh的高度、位置
|
|
103
|
+
var _this$getBoxSize = this.getBoxSize(this._target),
|
|
104
|
+
height = _this$getBoxSize.height;
|
|
105
|
+
var positionY = (_this$_target = this._target) === null || _this$_target === void 0 ? void 0 : _this$_target.position.y;
|
|
106
|
+
types.forEach(function (type) {
|
|
107
|
+
var tracks = _this2.createKeyframeTracks(type, _this2._duration, {
|
|
108
|
+
position: positionY,
|
|
109
|
+
height: height / 2
|
|
110
|
+
});
|
|
111
|
+
var animationClip = new AnimationClip("".concat(type), _this2.duration, tracks);
|
|
112
|
+
_this2._animationClips.set(type, animationClip);
|
|
113
|
+
var action = _this2._mixer.clipAction(animationClip);
|
|
96
114
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
// 配置动画Action
|
|
116
|
+
action.setLoop(LoopRepeat, Infinity).clampWhenFinished = true;
|
|
117
|
+
_this2._animations.set(type, action);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "getBoxSize",
|
|
122
|
+
value: function getBoxSize(mesh) {
|
|
123
|
+
// mesh.updateWorldMatrix(true, true)
|
|
124
|
+
var _Box3$setFromObject = new Box3().setFromObject(mesh),
|
|
125
|
+
max = _Box3$setFromObject.max,
|
|
126
|
+
min = _Box3$setFromObject.min;
|
|
127
|
+
return {
|
|
128
|
+
width: max.x - min.x,
|
|
129
|
+
height: max.y - min.y
|
|
130
|
+
};
|
|
131
|
+
}
|
|
113
132
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
/**
|
|
134
|
+
* 创建关键帧轨道
|
|
135
|
+
*/
|
|
136
|
+
}, {
|
|
137
|
+
key: "createKeyframeTracks",
|
|
138
|
+
value: function createKeyframeTracks(type, duration, trackParams) {
|
|
139
|
+
var tracks = [];
|
|
140
|
+
switch (type) {
|
|
141
|
+
case EMarkAnimationType.Bounce:
|
|
142
|
+
// eslint-disable-next-line no-case-declarations
|
|
143
|
+
var _trackParams$position = trackParams.position,
|
|
144
|
+
position = _trackParams$position === void 0 ? 0 : _trackParams$position,
|
|
145
|
+
_trackParams$height = trackParams.height,
|
|
146
|
+
height = _trackParams$height === void 0 ? 0 : _trackParams$height;
|
|
147
|
+
tracks.push(new VectorKeyframeTrack('.position', [0, duration / 2, duration], [0, position, 0, 0, position + height, 0, 0, position, 0]));
|
|
148
|
+
break;
|
|
149
|
+
case EMarkAnimationType.Pulse:
|
|
150
|
+
tracks.push(new VectorKeyframeTrack('.scale', [0, duration / 2, duration], [1, 1, 1, 1.2, 1.2, 1.2, 1, 1, 1]));
|
|
151
|
+
break;
|
|
152
|
+
case EMarkAnimationType.Rotate:
|
|
153
|
+
tracks.push(new NumberKeyframeTrack('.rotation[y]', [0, duration], [0, Math.PI * 2]));
|
|
154
|
+
break;
|
|
155
|
+
case EMarkAnimationType.Flash:
|
|
156
|
+
tracks.push(new NumberKeyframeTrack('.material.opacity', [0, duration / 2, duration], [1, 0.2, 1]));
|
|
157
|
+
break;
|
|
158
|
+
default:
|
|
159
|
+
console.error("animation type ".concat(type, " does not exist"));
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
return tracks;
|
|
140
163
|
}
|
|
141
|
-
return tracks;
|
|
142
|
-
}
|
|
143
164
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
165
|
+
/**
|
|
166
|
+
* 更新动画
|
|
167
|
+
*/
|
|
168
|
+
}, {
|
|
169
|
+
key: "update",
|
|
170
|
+
value: function update(delta) {
|
|
171
|
+
if (this._mixer) this._mixer.update(delta);
|
|
172
|
+
}
|
|
150
173
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
174
|
+
/**
|
|
175
|
+
* 播放动画
|
|
176
|
+
*/
|
|
177
|
+
}, {
|
|
178
|
+
key: "play",
|
|
179
|
+
value: function play(type) {
|
|
180
|
+
if (type) {
|
|
181
|
+
var animation = this._animations.get(type);
|
|
182
|
+
if (animation) animation.reset().play();
|
|
183
|
+
} else {
|
|
184
|
+
this._animations.forEach(function (animation) {
|
|
185
|
+
animation.reset().play();
|
|
186
|
+
});
|
|
187
|
+
}
|
|
162
188
|
}
|
|
163
|
-
}
|
|
164
189
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
190
|
+
/**
|
|
191
|
+
* 停止动画
|
|
192
|
+
*/
|
|
193
|
+
}, {
|
|
194
|
+
key: "stop",
|
|
195
|
+
value: function stop(type) {
|
|
196
|
+
if (type) {
|
|
197
|
+
var animation = this._animations.get(type);
|
|
198
|
+
animation === null || animation === void 0 || animation.stop();
|
|
199
|
+
} else {
|
|
200
|
+
this._animations.forEach(function (animation) {
|
|
201
|
+
animation.stop();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
176
204
|
}
|
|
177
|
-
}
|
|
178
205
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
206
|
+
/**
|
|
207
|
+
* 销毁资源
|
|
208
|
+
*/
|
|
209
|
+
}, {
|
|
210
|
+
key: "destroy",
|
|
211
|
+
value: function destroy() {
|
|
212
|
+
this.reset();
|
|
213
|
+
this._mixer = null;
|
|
214
|
+
}
|
|
215
|
+
}]);
|
|
216
|
+
return KeyframeAnimation;
|
|
217
|
+
}();
|
|
187
218
|
export { KeyframeAnimation, EMarkAnimationType };
|
|
188
219
|
//# sourceMappingURL=KeyframeAnimation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AnimationClip","AnimationMixer","Box3","LoopRepeat","NumberKeyframeTrack","VectorKeyframeTrack","EMarkAnimationType","KeyframeAnimation","constructor","target","options","_defineProperty","Map","_target","type","duration","enable","_type","_duration","_enable","_mixer","setupAnimations","mixer","value","reset","stopAllAction","_animationClips","forEach","clip","uncacheClip","_animations","clear","_this$_target","types","Array","isArray","height","getBoxSize","positionY","position","y","tracks","createKeyframeTracks","animationClip","set","action","clipAction","setLoop","Infinity","clampWhenFinished","mesh","max","min","setFromObject","width","x","trackParams","Bounce","push","Pulse","Rotate","Math","PI","Flash","console","error","update","delta","play","animation","get","stop","destroy"],"sources":["../../../src/business/Mark/KeyframeAnimation.ts"],"sourcesContent":["import type {\n AnimationAction,\n Group,\n KeyframeTrack,\n} from '@anov/3d-core'\nimport {\n AnimationClip,\n AnimationMixer,\n Box3,\n LoopRepeat,\n NumberKeyframeTrack,\n VectorKeyframeTrack,\n} from '@anov/3d-core'\n\n// 动画类型\nenum EMarkAnimationType {\n Bounce = 'bounce', // 上下弹跳\n Pulse = 'pulse', // 缩放\n Rotate = 'rotate', // 旋转\n Flash = 'flash', // 闪烁\n}\n\ninterface AnimationOption {\n enable: boolean\n type: EMarkAnimationType | EMarkAnimationType[]\n duration: number\n}\n\nclass KeyframeAnimation {\n private _target: Group\n\n private _duration: number\n private _type: EMarkAnimationType | EMarkAnimationType[]\n private _enable: boolean\n private _mixer: AnimationMixer\n private _animations: Map<EMarkAnimationType, AnimationAction> = new Map()\n private _animationClips: Map<EMarkAnimationType, AnimationClip> = new Map()\n\n constructor(target: Group, options: AnimationOption) {\n this._target = target\n const { type, duration = 1, enable = true } = options\n this._type = type\n this._duration = duration\n this._enable = enable\n this._mixer = new AnimationMixer(target)\n\n this.setupAnimations()\n }\n\n /**\n * 获取动画混合器\n */\n public get mixer(): AnimationMixer {\n return this._mixer\n }\n\n public get duration(): number {\n return this._duration\n }\n\n public set duration(value: number) {\n if (this._duration === value)\n return\n this._duration = value\n this.reset()\n this.setupAnimations()\n }\n\n public get type() {\n return this._type\n }\n\n public set type(value: EMarkAnimationType | EMarkAnimationType[]) {\n this._type = value\n this.reset()\n this.setupAnimations()\n }\n\n public get enable(): boolean {\n return this._enable\n }\n\n /**\n * 重置所有动画\n */\n public reset(): void {\n this._mixer.stopAllAction()\n\n this._animationClips.forEach((clip) => {\n this._mixer.uncacheClip(clip)\n })\n\n this._animations.clear()\n this._animationClips.clear()\n }\n\n /**\n * 设置动画\n */\n private setupAnimations(): void {\n if (!this.enable)\n return\n\n const types = Array.isArray(this.type)\n ? this.type\n : [this.type]\n\n // 获取Mesh的高度、位置\n const { height } = this.getBoxSize(this._target)\n const positionY = this._target?.position.y\n\n types.forEach((type) => {\n const tracks = this.createKeyframeTracks(type, this._duration, { position: positionY, height: height / 2 })\n\n const animationClip = new AnimationClip(\n `${type}`,\n this.duration,\n tracks,\n )\n\n this._animationClips.set(type, animationClip)\n const action = this._mixer.clipAction(animationClip)\n\n // 配置动画Action\n action\n .setLoop(LoopRepeat, Infinity)\n .clampWhenFinished = true\n\n this._animations.set(type, action)\n })\n }\n\n private getBoxSize(mesh) {\n // mesh.updateWorldMatrix(true, true)\n const { max, min } = new Box3().setFromObject(mesh)\n return { width: max.x - min.x, height: max.y - min.y }\n }\n\n /**\n * 创建关键帧轨道\n */\n private createKeyframeTracks(\n type: EMarkAnimationType,\n duration: number,\n trackParams: { height: number; position: number },\n ): KeyframeTrack[] {\n const tracks: KeyframeTrack[] = []\n\n switch (type) {\n case EMarkAnimationType.Bounce:\n // eslint-disable-next-line no-case-declarations\n const { position = 0, height = 0 } = trackParams\n tracks.push(\n new VectorKeyframeTrack(\n '.position',\n [0, duration / 2, duration],\n [0, position, 0, 0, position + height, 0, 0, position, 0],\n ),\n )\n break\n\n case EMarkAnimationType.Pulse:\n tracks.push(\n new VectorKeyframeTrack(\n '.scale',\n [0, duration / 2, duration],\n [1, 1, 1, 1.2, 1.2, 1.2, 1, 1, 1],\n ),\n )\n break\n\n case EMarkAnimationType.Rotate:\n tracks.push(\n new NumberKeyframeTrack(\n '.rotation[y]',\n [0, duration],\n [0, Math.PI * 2],\n ),\n )\n break\n\n case EMarkAnimationType.Flash:\n tracks.push(\n new NumberKeyframeTrack(\n '.material.opacity',\n [0, duration / 2, duration],\n [1, 0.2, 1],\n ),\n )\n break\n\n default:\n console.error(`animation type ${type} does not exist`)\n break\n }\n\n return tracks\n }\n\n /**\n * 更新动画\n */\n public update(delta: number): void {\n if (this._mixer)\n this._mixer.update(delta)\n }\n\n /**\n * 播放动画\n */\n public play(type?: EMarkAnimationType): void {\n if (type) {\n const animation = this._animations.get(type)\n if (animation)\n animation.reset().play()\n }\n else {\n this._animations.forEach((animation) => {\n animation.reset().play()\n })\n }\n }\n\n /**\n * 停止动画\n */\n public stop(type?: EMarkAnimationType): void {\n if (type) {\n const animation = this._animations.get(type)\n animation?.stop()\n }\n else {\n this._animations.forEach((animation) => {\n animation.stop()\n })\n }\n }\n\n /**\n * 销毁资源\n */\n public destroy(): void {\n this.reset()\n this._mixer = null\n }\n}\n\nexport { KeyframeAnimation, EMarkAnimationType, AnimationOption }"],"mappings":";;;AAKA,SACEA,aAAa,EACbC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,mBAAmB,EACnBC,mBAAmB,QACd,eAAe;;AAEtB;AAAA,IACKC,kBAAkB,0BAAlBA,kBA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AACH,OAAO,CAAE0C,SAAS,IAAK;QACtCA,SAAS,CAAC7C,KAAK,CAAC,CAAC,CAAC4C,IAAI,CAAC,CAAC;MAC1B,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;AACA;EACSG,IAAIA,CAACzD,IAAyB,EAAQ;IAC3C,IAAIA,IAAI,EAAE;MACR,MAAMuD,SAAS,GAAG,IAAI,CAACvC,WAAW,CAACwC,GAAG,CAACxD,IAAI,CAAC;MAC5CuD,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEE,IAAI,CAAC,CAAC;IACnB,CAAC,MACI;MACH,IAAI,CAACzC,WAAW,CAACH,OAAO,CAAE0C,SAAS,IAAK;QACtCA,SAAS,CAACE,IAAI,CAAC,CAAC;MAClB,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;AACA;EACSC,OAAOA,CAAA,EAAS;IACrB,IAAI,CAAChD,KAAK,CAAC,CAAC;IACZ,IAAI,CAACJ,MAAM,GAAG,IAAI;EACpB;AACF;AAEA,SAASb,iBAAiB,EAAED,kBAAkB"}
|
|
1
|
+
{"version":3,"names":["AnimationClip","AnimationMixer","Box3","LoopRepeat","NumberKeyframeTrack","VectorKeyframeTrack","EMarkAnimationType","KeyframeAnimation","target","options","_classCallCheck","_defineProperty","Map","_target","type","_options$duration","duration","_options$enable","enable","_type","_duration","_enable","_mixer","setupAnimations","_createClass","key","get","set","value","reset","_this","stopAllAction","_animationClips","forEach","clip","uncacheClip","_animations","clear","_this$_target","_this2","types","Array","isArray","_this$getBoxSize","getBoxSize","height","positionY","position","y","tracks","createKeyframeTracks","animationClip","concat","action","clipAction","setLoop","Infinity","clampWhenFinished","mesh","_Box3$setFromObject","setFromObject","max","min","width","x","trackParams","Bounce","_trackParams$position","_trackParams$height","push","Pulse","Rotate","Math","PI","Flash","console","error","update","delta","play","animation","stop","destroy"],"sources":["../../../src/business/Mark/KeyframeAnimation.ts"],"sourcesContent":["import type {\n AnimationAction,\n Group,\n KeyframeTrack,\n} from '@anov/3d-core'\nimport {\n AnimationClip,\n AnimationMixer,\n Box3,\n LoopRepeat,\n NumberKeyframeTrack,\n VectorKeyframeTrack,\n} from '@anov/3d-core'\n\n// 动画类型\nenum EMarkAnimationType {\n Bounce = 'bounce', // 上下弹跳\n Pulse = 'pulse', // 缩放\n Rotate = 'rotate', // 旋转\n Flash = 'flash', // 闪烁\n}\n\ninterface AnimationOption {\n enable: boolean\n type: EMarkAnimationType | EMarkAnimationType[]\n duration: number\n}\n\nclass KeyframeAnimation {\n private _target: Group\n\n private _duration: number\n private _type: EMarkAnimationType | EMarkAnimationType[]\n private _enable: boolean\n private _mixer: AnimationMixer\n private _animations: Map<EMarkAnimationType, AnimationAction> = new Map()\n private _animationClips: Map<EMarkAnimationType, AnimationClip> = new Map()\n\n constructor(target: Group, options: AnimationOption) {\n this._target = target\n const { type, duration = 1, enable = true } = options\n this._type = type\n this._duration = duration\n this._enable = enable\n this._mixer = new AnimationMixer(target)\n\n this.setupAnimations()\n }\n\n /**\n * 获取动画混合器\n */\n public get mixer(): AnimationMixer {\n return this._mixer\n }\n\n public get duration(): number {\n return this._duration\n }\n\n public set duration(value: number) {\n if (this._duration === value)\n return\n this._duration = value\n this.reset()\n this.setupAnimations()\n }\n\n public get type() {\n return this._type\n }\n\n public set type(value: EMarkAnimationType | EMarkAnimationType[]) {\n this._type = value\n this.reset()\n this.setupAnimations()\n }\n\n public get enable(): boolean {\n return this._enable\n }\n\n /**\n * 重置所有动画\n */\n public reset(): void {\n this._mixer.stopAllAction()\n\n this._animationClips.forEach((clip) => {\n this._mixer.uncacheClip(clip)\n })\n\n this._animations.clear()\n this._animationClips.clear()\n }\n\n /**\n * 设置动画\n */\n private setupAnimations(): void {\n if (!this.enable)\n return\n\n const types = Array.isArray(this.type)\n ? this.type\n : [this.type]\n\n // 获取Mesh的高度、位置\n const { height } = this.getBoxSize(this._target)\n const positionY = this._target?.position.y\n\n types.forEach((type) => {\n const tracks = this.createKeyframeTracks(type, this._duration, { position: positionY, height: height / 2 })\n\n const animationClip = new AnimationClip(\n `${type}`,\n this.duration,\n tracks,\n )\n\n this._animationClips.set(type, animationClip)\n const action = this._mixer.clipAction(animationClip)\n\n // 配置动画Action\n action\n .setLoop(LoopRepeat, Infinity)\n .clampWhenFinished = true\n\n this._animations.set(type, action)\n })\n }\n\n private getBoxSize(mesh) {\n // mesh.updateWorldMatrix(true, true)\n const { max, min } = new Box3().setFromObject(mesh)\n return { width: max.x - min.x, height: max.y - min.y }\n }\n\n /**\n * 创建关键帧轨道\n */\n private createKeyframeTracks(\n type: EMarkAnimationType,\n duration: number,\n trackParams: { height: number; position: number },\n ): KeyframeTrack[] {\n const tracks: KeyframeTrack[] = []\n\n switch (type) {\n case EMarkAnimationType.Bounce:\n // eslint-disable-next-line no-case-declarations\n const { position = 0, height = 0 } = trackParams\n tracks.push(\n new VectorKeyframeTrack(\n '.position',\n [0, duration / 2, duration],\n [0, position, 0, 0, position + height, 0, 0, position, 0],\n ),\n )\n break\n\n case EMarkAnimationType.Pulse:\n tracks.push(\n new VectorKeyframeTrack(\n '.scale',\n [0, duration / 2, duration],\n [1, 1, 1, 1.2, 1.2, 1.2, 1, 1, 1],\n ),\n )\n break\n\n case EMarkAnimationType.Rotate:\n tracks.push(\n new NumberKeyframeTrack(\n '.rotation[y]',\n [0, duration],\n [0, Math.PI * 2],\n ),\n )\n break\n\n case EMarkAnimationType.Flash:\n tracks.push(\n new NumberKeyframeTrack(\n '.material.opacity',\n [0, duration / 2, duration],\n [1, 0.2, 1],\n ),\n )\n break\n\n default:\n console.error(`animation type ${type} does not exist`)\n break\n }\n\n return tracks\n }\n\n /**\n * 更新动画\n */\n public update(delta: number): void {\n if (this._mixer)\n this._mixer.update(delta)\n }\n\n /**\n * 播放动画\n */\n public play(type?: EMarkAnimationType): void {\n if (type) {\n const animation = this._animations.get(type)\n if (animation)\n animation.reset().play()\n }\n else {\n this._animations.forEach((animation) => {\n animation.reset().play()\n })\n }\n }\n\n /**\n * 停止动画\n */\n public stop(type?: EMarkAnimationType): void {\n if (type) {\n const animation = this._animations.get(type)\n animation?.stop()\n }\n else {\n this._animations.forEach((animation) => {\n animation.stop()\n })\n }\n }\n\n /**\n * 销毁资源\n */\n public destroy(): void {\n this.reset()\n this._mixer = null\n }\n}\n\nexport { KeyframeAnimation, EMarkAnimationType, AnimationOption }"],"mappings":";;;;;;;AAKA,SACEA,aAAa,EACbC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,mBAAmB,EACnBC,mBAAmB,QACd,eAAe;;AAEtB;AAAA,IACKC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA,EAAlBA,kBAAkB,SAIJ;AAAA,IASbC,iBAAiB;EAUrB,SAAAA,kBAAYC,MAAa,EAAEC,OAAwB,EAAE;IAAAC,eAAA,OAAAH,iBAAA;IAAAI,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,sBAHW,IAAIC,GAAG,CAAC,CAAC;IAAAD,eAAA,0BACP,IAAIC,GAAG,CAAC,CAAC;IAGzE,IAAI,CAACC,OAAO,GAAGL,MAAM;IACrB,IAAQM,IAAI,GAAkCL,OAAO,CAA7CK,IAAI;MAAAC,iBAAA,GAAkCN,OAAO,CAAvCO,QAAQ;MAARA,QAAQ,GAAAD,iBAAA,cAAG,CAAC,GAAAA,iBAAA;MAAAE,eAAA,GAAoBR,OAAO,CAAzBS,MAAM;MAANA,MAAM,GAAAD,eAAA,cAAG,IAAI,GAAAA,eAAA;IACzC,IAAI,CAACE,KAAK,GAAGL,IAAI;IACjB,IAAI,CAACM,SAAS,GAAGJ,QAAQ;IACzB,IAAI,CAACK,OAAO,GAAGH,MAAM;IACrB,IAAI,CAACI,MAAM,GAAG,IAAIrB,cAAc,CAACO,MAAM,CAAC;IAExC,IAAI,CAACe,eAAe,CAAC,CAAC;EAC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