@anov/3d-ability 0.0.139 → 0.0.141
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 +35 -56
- 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 +146 -187
- package/dist/business/Area/Fence/FenceBase.js.map +1 -1
- package/dist/business/Area/Fence/fence_base_01.js +120 -112
- package/dist/business/Area/Fence/fence_base_01.js.map +1 -1
- package/dist/business/Area/Fence/fence_feeting_01.js +218 -130
- package/dist/business/Area/Fence/fence_feeting_01.js.map +1 -1
- package/dist/business/Area/Fence/fence_roll_01.js +140 -130
- package/dist/business/Area/Fence/fence_roll_01.js.map +1 -1
- package/dist/business/Area/FillArea/FillAreaBase.js +87 -126
- package/dist/business/Area/FillArea/FillAreaBase.js.map +1 -1
- package/dist/business/Area/FillArea/fillArea_face_01.js +72 -98
- package/dist/business/Area/FillArea/fillArea_face_01.js.map +1 -1
- package/dist/business/Area/FillArea/fillArea_line_01.js +66 -94
- package/dist/business/Area/FillArea/fillArea_line_01.js.map +1 -1
- package/dist/business/Area/index.js +267 -483
- package/dist/business/Area/index.js.map +1 -1
- package/dist/business/Area/tool.js +14 -26
- package/dist/business/Area/tool.js.map +1 -1
- package/dist/business/Base/ObjectLayer.js +21 -46
- package/dist/business/Base/ObjectLayer.js.map +1 -1
- package/dist/business/Batch/index.js +189 -234
- package/dist/business/Batch/index.js.map +1 -1
- package/dist/business/Box/index.js +52 -81
- package/dist/business/Box/index.js.map +1 -1
- package/dist/business/Cylinder/index.js +51 -79
- package/dist/business/Cylinder/index.js.map +1 -1
- package/dist/business/Flyline/bubble/CircleBubble.js +1 -9
- package/dist/business/Flyline/bubble/CircleBubble.js.map +1 -1
- package/dist/business/Flyline/bubble/index.js +7 -21
- package/dist/business/Flyline/bubble/index.js.map +1 -1
- package/dist/business/Flyline/index.js +96 -162
- package/dist/business/Flyline/index.js.map +1 -1
- package/dist/business/Flyline/line/ArcLine.js +208 -291
- package/dist/business/Flyline/line/ArcLine.js.map +1 -1
- package/dist/business/Flyline/line/index.js +8 -22
- package/dist/business/Flyline/line/index.js.map +1 -1
- package/dist/business/HeatMap/HeatMap.js +380 -467
- package/dist/business/HeatMap/HeatMap.js.map +1 -1
- package/dist/business/HeatMap/core.js +405 -525
- package/dist/business/HeatMap/core.js.map +1 -1
- package/dist/business/HeatMap/shader.js +69 -3
- package/dist/business/HeatMap/shader.js.map +1 -1
- package/dist/business/InfoPanel/index.js +201 -242
- package/dist/business/InfoPanel/index.js.map +1 -1
- package/dist/business/Line/index.js +55 -88
- package/dist/business/Line/index.js.map +1 -1
- package/dist/business/Mark/KeyframeAnimation.js +145 -176
- package/dist/business/Mark/KeyframeAnimation.js.map +1 -1
- package/dist/business/Mark/index.js +196 -294
- package/dist/business/Mark/index.js.map +1 -1
- package/dist/business/Mark/shader/tanhao.js +36 -3
- package/dist/business/Mark/shader/tanhao.js.map +1 -1
- package/dist/business/Mark/type.js +1 -1
- package/dist/business/MaterialSwitch/MaterialSwitchSystem.js +377 -551
- package/dist/business/MaterialSwitch/MaterialSwitchSystem.js.map +1 -1
- package/dist/business/MaterialSwitch/inject.js +92 -58
- package/dist/business/MaterialSwitch/inject.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/finalFade.js +74 -2
- package/dist/business/MaterialSwitch/shader/finalFade.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/ground.js +95 -16
- package/dist/business/MaterialSwitch/shader/ground.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/groundBase64.js +9 -3
- package/dist/business/MaterialSwitch/shader/groundBase64.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/realFade.js +48 -9
- package/dist/business/MaterialSwitch/shader/realFade.js.map +1 -1
- package/dist/business/Plane/index.js +51 -78
- package/dist/business/Plane/index.js.map +1 -1
- package/dist/business/Poi/index.d.ts +5 -0
- package/dist/business/Poi/index.js +256 -295
- package/dist/business/Poi/index.js.map +1 -1
- package/dist/business/Poi/link/Cylinder.js +56 -89
- package/dist/business/Poi/link/Cylinder.js.map +1 -1
- package/dist/business/Poi/link/Pyramid.js +104 -165
- package/dist/business/Poi/link/Pyramid.js.map +1 -1
- package/dist/business/Poi/link/index.d.ts +1 -1
- package/dist/business/Poi/link/index.js +54 -114
- package/dist/business/Poi/link/index.js.map +1 -1
- package/dist/business/Poi/panel/index.d.ts +124 -0
- package/dist/business/Poi/panel/index.js +474 -0
- package/dist/business/Poi/panel/index.js.map +1 -0
- package/dist/business/Poi/panel/interfaces.d.ts +67 -0
- package/dist/business/Poi/panel/interfaces.js +2 -0
- package/dist/business/Poi/panel/interfaces.js.map +1 -0
- package/dist/business/Poi/panel/utils.d.ts +72 -0
- package/dist/business/Poi/panel/utils.js +126 -0
- package/dist/business/Poi/panel/utils.js.map +1 -0
- package/dist/business/Poi/particle/DoubleCircle.js +71 -107
- package/dist/business/Poi/particle/DoubleCircle.js.map +1 -1
- package/dist/business/Poi/particle/DynamicCircle.js +75 -111
- package/dist/business/Poi/particle/DynamicCircle.js.map +1 -1
- package/dist/business/Poi/particle/SingleCircle.js +62 -98
- package/dist/business/Poi/particle/SingleCircle.js.map +1 -1
- package/dist/business/Poi/particle/index.js +49 -117
- package/dist/business/Poi/particle/index.js.map +1 -1
- package/dist/business/Poi/shader/circle.js +31 -3
- package/dist/business/Poi/shader/circle.js.map +1 -1
- package/dist/business/Poi/shader/cylinder.js +37 -3
- package/dist/business/Poi/shader/cylinder.js.map +1 -1
- package/dist/business/Poi/shader/doubleCircle.js +55 -3
- package/dist/business/Poi/shader/doubleCircle.js.map +1 -1
- package/dist/business/Poi/shader/dynamicCircle.js +67 -3
- package/dist/business/Poi/shader/dynamicCircle.js.map +1 -1
- package/dist/business/Poi/title/Border.js +7 -27
- package/dist/business/Poi/title/Border.js.map +1 -1
- package/dist/business/Poi/title/Ellipse.js +7 -27
- package/dist/business/Poi/title/Ellipse.js.map +1 -1
- package/dist/business/Poi/title/index.js +208 -292
- package/dist/business/Poi/title/index.js.map +1 -1
- package/dist/business/Poi/tools.js +22 -19
- package/dist/business/Poi/tools.js.map +1 -1
- package/dist/business/Poi/types.d.ts +3 -0
- package/dist/business/Poi/types.js.map +1 -1
- package/dist/business/Sphere/index.js +47 -72
- package/dist/business/Sphere/index.js.map +1 -1
- package/dist/business/Spline/index.js +190 -245
- package/dist/business/Spline/index.js.map +1 -1
- package/dist/business/SplitBuilding/index.js +327 -536
- package/dist/business/SplitBuilding/index.js.map +1 -1
- package/dist/business/SplitBuilding/type.js +2 -2
- package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js +218 -275
- package/dist/business/TrafficComponents/RealismTraffic/RealismTraffic.js.map +1 -1
- package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js +132 -177
- package/dist/business/TrafficComponents/StreamerTraffic/StreamerTraffic.js.map +1 -1
- package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js +51 -1
- package/dist/business/TrafficComponents/StreamerTraffic/fragmentShader.js.map +1 -1
- package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js +6 -1
- package/dist/business/TrafficComponents/StreamerTraffic/vertexShader.js.map +1 -1
- package/dist/business/TrafficComponents/base.js +32 -55
- package/dist/business/TrafficComponents/base.js.map +1 -1
- package/dist/business/TrafficComponents/utils.js +25 -24
- package/dist/business/TrafficComponents/utils.js.map +1 -1
- package/dist/business/Utils/Curve.js +40 -56
- 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 +13 -14
- package/dist/business/Utils/defineProps.js.map +1 -1
- package/dist/business/Utils/round-curve.js +127 -153
- package/dist/business/Utils/round-curve.js.map +1 -1
- package/dist/business/VideoPanel/index.js +258 -319
- package/dist/business/VideoPanel/index.js.map +1 -1
- package/dist/business/Water/index.js +78 -108
- 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 +383 -449
- package/dist/core/Camera/PerspectiveCamera/CameraExpand.js.map +1 -1
- package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js +107 -142
- package/dist/core/Camera/PerspectiveCamera/FollowOrbitControls.js.map +1 -1
- package/dist/core/Controls/FirstViewControl/index.js +84 -96
- package/dist/core/Controls/FirstViewControl/index.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/action/input.js +77 -98
- 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 +19 -28
- package/dist/core/Controls/ThirdViewControl/index.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player/animation.js +126 -155
- package/dist/core/Controls/ThirdViewControl/player/animation.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player/camera.js +47 -63
- package/dist/core/Controls/ThirdViewControl/player/camera.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player/control.js +39 -49
- package/dist/core/Controls/ThirdViewControl/player/control.js.map +1 -1
- package/dist/core/Controls/ThirdViewControl/player.js +66 -91
- package/dist/core/Controls/ThirdViewControl/player.js.map +1 -1
- package/dist/core/Controls/base.js +14 -30
- package/dist/core/Controls/base.js.map +1 -1
- package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js +92 -131
- package/dist/core/Curve/RoundedCornersCurve/RoundedCornersCurve.js.map +1 -1
- package/dist/core/Debug/PerformanceInfo/Performance.js +22 -47
- package/dist/core/Debug/PerformanceInfo/Performance.js.map +1 -1
- package/dist/core/Light/PointLight/PointLightExt.js +4 -21
- package/dist/core/Light/PointLight/PointLightExt.js.map +1 -1
- package/dist/core/Material/FinirMaterial/FinirMaterial.js +37 -57
- package/dist/core/Material/FinirMaterial/FinirMaterial.js.map +1 -1
- package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js +116 -153
- package/dist/core/Material/PristineGridMaterial/PristineGridMaterial.js.map +1 -1
- package/dist/core/Material/PristineGridMaterial/shader/fragment.js +95 -1
- package/dist/core/Material/PristineGridMaterial/shader/fragment.js.map +1 -1
- package/dist/core/Material/PristineGridMaterial/shader/vertex.js +26 -1
- package/dist/core/Material/PristineGridMaterial/shader/vertex.js.map +1 -1
- package/dist/core/Material/SurfaceMaterial/index.js +76 -172
- package/dist/core/Material/SurfaceMaterial/index.js.map +1 -1
- package/dist/core/Material/decorators.js +6 -11
- package/dist/core/Material/decorators.js.map +1 -1
- package/dist/core/PostEffects/addACESFilmicToneMappingPass.js +16 -12
- package/dist/core/PostEffects/addACESFilmicToneMappingPass.js.map +1 -1
- package/dist/core/PostEffects/addBrightnessContrastPass.js +17 -13
- package/dist/core/PostEffects/addBrightnessContrastPass.js.map +1 -1
- package/dist/core/PostEffects/bloomPass.js +17 -10
- package/dist/core/PostEffects/bloomPass.js.map +1 -1
- package/dist/core/PostEffects/bloomSelect.js +60 -43
- package/dist/core/PostEffects/bloomSelect.js.map +1 -1
- package/dist/core/PostEffects/colorifyPass.js +17 -13
- package/dist/core/PostEffects/colorifyPass.js.map +1 -1
- package/dist/core/PostEffects/index.js +28 -22
- package/dist/core/PostEffects/index.js.map +1 -1
- package/dist/core/PostEffects/outlinePass.js +37 -50
- package/dist/core/PostEffects/outlinePass.js.map +1 -1
- package/dist/core/PostEffects/postprocessing.js +14 -12
- package/dist/core/PostEffects/postprocessing.js.map +1 -1
- package/dist/core/PostEffects/saoPass.js +15 -10
- package/dist/core/PostEffects/saoPass.js.map +1 -1
- package/dist/core/PostEffects/shader/colorify.js +22 -3
- package/dist/core/PostEffects/shader/colorify.js.map +1 -1
- package/dist/core/PostEffects/shader/gammaCorrectionShader.js +27 -3
- package/dist/core/PostEffects/shader/gammaCorrectionShader.js.map +1 -1
- package/dist/core/PostEffects/shader/mapping.js +66 -3
- package/dist/core/PostEffects/shader/mapping.js.map +1 -1
- package/dist/core/PostEffects/shader/thermalMaging.js +28 -3
- package/dist/core/PostEffects/shader/thermalMaging.js.map +1 -1
- package/dist/core/SceneEffect/grow/grow.js +85 -101
- package/dist/core/SceneEffect/grow/grow.js.map +1 -1
- package/dist/core/SceneEffect/grow/style_down.js +60 -77
- package/dist/core/SceneEffect/grow/style_down.js.map +1 -1
- package/dist/core/SceneEffect/grow/style_up.js +64 -81
- 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 +51 -76
- package/dist/core/WeatherSystem/DynamicWeatherSystem.js.map +1 -1
- package/dist/core/WeatherSystem/hdr/index.js +69 -105
- package/dist/core/WeatherSystem/hdr/index.js.map +1 -1
- package/dist/core/WeatherSystem/index.js +77 -124
- package/dist/core/WeatherSystem/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/fog/index.js +52 -80
- package/dist/core/WeatherSystem/objects/fog/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/index.js +72 -84
- package/dist/core/WeatherSystem/objects/rain/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/lineRain.js +88 -118
- package/dist/core/WeatherSystem/objects/rain/lineRain.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/plane.js +116 -146
- package/dist/core/WeatherSystem/objects/rain/plane.js.map +1 -1
- package/dist/core/WeatherSystem/objects/rain/point.js +100 -148
- package/dist/core/WeatherSystem/objects/rain/point.js.map +1 -1
- package/dist/core/WeatherSystem/objects/sky/cloud.js +71 -104
- package/dist/core/WeatherSystem/objects/sky/cloud.js.map +1 -1
- package/dist/core/WeatherSystem/objects/sky/index.js +66 -84
- package/dist/core/WeatherSystem/objects/sky/index.js.map +1 -1
- package/dist/core/WeatherSystem/objects/sky/outline.js +25 -45
- package/dist/core/WeatherSystem/objects/sky/outline.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/cloud.js +74 -3
- package/dist/core/WeatherSystem/shaders/cloud.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/fog.js +103 -3
- package/dist/core/WeatherSystem/shaders/fog.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/rain.js +206 -7
- package/dist/core/WeatherSystem/shaders/rain.js.map +1 -1
- package/dist/core/WeatherSystem/shaders/sky.js +87 -3
- package/dist/core/WeatherSystem/shaders/sky.js.map +1 -1
- package/dist/core/WeatherSystem/sky/index.js +104 -135
- package/dist/core/WeatherSystem/sky/index.js.map +1 -1
- package/dist/core/WeatherSystem/utils/constant.js +44 -38
- package/dist/core/WeatherSystem/utils/constant.js.map +1 -1
- package/dist/core/WeatherSystem/utils/math.js +18 -25
- 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 +96 -141
- 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,26 +1,8 @@
|
|
|
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
1
|
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; }
|
|
3
2
|
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); }
|
|
21
3
|
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; }
|
|
22
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
23
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
5
|
+
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); }
|
|
24
6
|
/*
|
|
25
7
|
* @Descripttion:
|
|
26
8
|
* @version:
|
|
@@ -33,78 +15,63 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
33
15
|
*/
|
|
34
16
|
import ObjectLayer from "../Base/ObjectLayer";
|
|
35
17
|
import { Vector3, BufferGeometry, LineDashedMaterial, LineBasicMaterial, Line as ThreeLine } from '@anov/3d-core';
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
18
|
+
export class Line extends ObjectLayer {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super();
|
|
21
|
+
_defineProperty(this, "line", void 0);
|
|
22
|
+
this.line = this.createLine(options);
|
|
23
|
+
this.add(this.line); // 挂载到 ObjectLayer 中
|
|
24
|
+
}
|
|
25
|
+
createLine(options) {
|
|
26
|
+
const {
|
|
27
|
+
points,
|
|
28
|
+
dashed = false,
|
|
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;
|
|
47
54
|
}
|
|
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
|
-
}
|
|
95
55
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
value: function destroy() {
|
|
100
|
-
if (!this.line) return;
|
|
56
|
+
/** 更新线条 */
|
|
57
|
+
updateLine(options) {
|
|
58
|
+
if (this.line) {
|
|
101
59
|
this.remove(this.line);
|
|
102
60
|
this.line.geometry.dispose();
|
|
103
61
|
this.line.material.dispose();
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
this.line = null;
|
|
106
62
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
63
|
+
this.line = this.createLine(options);
|
|
64
|
+
this.add(this.line);
|
|
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
|
+
}
|
|
110
77
|
//# 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","constructor","options","_defineProperty","line","createLine","add","points","dashed","material","vecPoints","map","p","Array","isArray","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,OAAQ,MAAMD,IAAI,SAASL,WAAW,CAAkB;EAGtDO,WAAWA,CAACC,OAAgB,EAAE;IAC5B,KAAK,CAAC,CAAC;IAAAC,eAAA;IACP,IAAI,CAACC,IAAI,GAAG,IAAI,CAACC,UAAU,CAACH,OAAO,CAAC;IACpC,IAAI,CAACI,GAAG,CAAC,IAAI,CAACF,IAAI,CAAC,EAAC;EACtB;EAEOC,UAAUA,CAACH,OAAgB,EAAS;IACzC,MAAM;MAAEK,MAAM;MAAEC,MAAM,GAAG,KAAK;MAAEC,QAAQ,GAAG,CAAC;IAAE,CAAC,GAAGP,OAAO;IACzD,MAAMQ,SAAS,GAAGH,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,CAAS2B,OAAO,CAAC,CAAC;IAC3C;IACA,IAAI,CAAChC,IAAI,GAAG,IAAI,CAACC,UAAU,CAACH,OAAO,CAAC;IACpC,IAAI,CAACI,GAAG,CAAC,IAAI,CAACF,IAAI,CAAC;EACrB;;EAEA;EACOiC,OAAOA,CAAA,EAAG;IACf,IAAI,CAAC,IAAI,CAACjC,IAAI,EAAE;IAChB,IAAI,CAAC+B,MAAM,CAAC,IAAI,CAAC/B,IAAI,CAAC;IACtB,IAAI,CAACA,IAAI,CAACW,QAAQ,CAACqB,OAAO,CAAC,CAAC;IACvB,IAAI,CAAChC,IAAI,CAACK,QAAQ,CAAS2B,OAAO,CAAC,CAAC;IACzC;IACA,IAAI,CAAChC,IAAI,GAAG,IAAI;EAClB;AACF"}
|
|
@@ -1,10 +1,6 @@
|
|
|
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
1
|
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; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
4
|
import { AnimationClip, AnimationMixer, Box3, LoopRepeat, NumberKeyframeTrack, VectorKeyframeTrack } from '@anov/3d-core';
|
|
9
5
|
|
|
10
6
|
// 动画类型
|
|
@@ -15,9 +11,8 @@ var EMarkAnimationType = /*#__PURE__*/function (EMarkAnimationType) {
|
|
|
15
11
|
EMarkAnimationType["Flash"] = "flash";
|
|
16
12
|
return EMarkAnimationType;
|
|
17
13
|
}(EMarkAnimationType || {}); // 闪烁
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
_classCallCheck(this, KeyframeAnimation);
|
|
14
|
+
class KeyframeAnimation {
|
|
15
|
+
constructor(target, options) {
|
|
21
16
|
_defineProperty(this, "_target", void 0);
|
|
22
17
|
_defineProperty(this, "_duration", void 0);
|
|
23
18
|
_defineProperty(this, "_type", void 0);
|
|
@@ -26,11 +21,11 @@ var KeyframeAnimation = /*#__PURE__*/function () {
|
|
|
26
21
|
_defineProperty(this, "_animations", new Map());
|
|
27
22
|
_defineProperty(this, "_animationClips", new Map());
|
|
28
23
|
this._target = target;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
duration =
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
const {
|
|
25
|
+
type,
|
|
26
|
+
duration = 1,
|
|
27
|
+
enable = true
|
|
28
|
+
} = options;
|
|
34
29
|
this._type = type;
|
|
35
30
|
this._duration = duration;
|
|
36
31
|
this._enable = enable;
|
|
@@ -41,179 +36,153 @@ var KeyframeAnimation = /*#__PURE__*/function () {
|
|
|
41
36
|
/**
|
|
42
37
|
* 获取动画混合器
|
|
43
38
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.reset();
|
|
68
|
-
this.setupAnimations();
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "enable",
|
|
72
|
-
get: function get() {
|
|
73
|
-
return this._enable;
|
|
74
|
-
}
|
|
75
|
-
|
|
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
|
-
}
|
|
39
|
+
get mixer() {
|
|
40
|
+
return this._mixer;
|
|
41
|
+
}
|
|
42
|
+
get duration() {
|
|
43
|
+
return this._duration;
|
|
44
|
+
}
|
|
45
|
+
set duration(value) {
|
|
46
|
+
if (this._duration === value) return;
|
|
47
|
+
this._duration = value;
|
|
48
|
+
this.reset();
|
|
49
|
+
this.setupAnimations();
|
|
50
|
+
}
|
|
51
|
+
get type() {
|
|
52
|
+
return this._type;
|
|
53
|
+
}
|
|
54
|
+
set type(value) {
|
|
55
|
+
this._type = value;
|
|
56
|
+
this.reset();
|
|
57
|
+
this.setupAnimations();
|
|
58
|
+
}
|
|
59
|
+
get enable() {
|
|
60
|
+
return this._enable;
|
|
61
|
+
}
|
|
90
62
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
63
|
+
/**
|
|
64
|
+
* 重置所有动画
|
|
65
|
+
*/
|
|
66
|
+
reset() {
|
|
67
|
+
this._mixer.stopAllAction();
|
|
68
|
+
this._animationClips.forEach(clip => {
|
|
69
|
+
this._mixer.uncacheClip(clip);
|
|
70
|
+
});
|
|
71
|
+
this._animations.clear();
|
|
72
|
+
this._animationClips.clear();
|
|
73
|
+
}
|
|
101
74
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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);
|
|
75
|
+
/**
|
|
76
|
+
* 设置动画
|
|
77
|
+
*/
|
|
78
|
+
setupAnimations() {
|
|
79
|
+
var _this$_target;
|
|
80
|
+
if (!this.enable) return;
|
|
81
|
+
const types = Array.isArray(this.type) ? this.type : [this.type];
|
|
114
82
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
83
|
+
// 获取Mesh的高度、位置
|
|
84
|
+
const {
|
|
85
|
+
height
|
|
86
|
+
} = this.getBoxSize(this._target);
|
|
87
|
+
const positionY = (_this$_target = this._target) === null || _this$_target === void 0 ? void 0 : _this$_target.position.y;
|
|
88
|
+
types.forEach(type => {
|
|
89
|
+
const tracks = this.createKeyframeTracks(type, this._duration, {
|
|
90
|
+
position: positionY,
|
|
91
|
+
height: height / 2
|
|
118
92
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
}
|
|
93
|
+
const animationClip = new AnimationClip(`${type}`, this.duration, tracks);
|
|
94
|
+
this._animationClips.set(type, animationClip);
|
|
95
|
+
const action = this._mixer.clipAction(animationClip);
|
|
132
96
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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;
|
|
163
|
-
}
|
|
97
|
+
// 配置动画Action
|
|
98
|
+
action.setLoop(LoopRepeat, Infinity).clampWhenFinished = true;
|
|
99
|
+
this._animations.set(type, action);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
getBoxSize(mesh) {
|
|
103
|
+
// mesh.updateWorldMatrix(true, true)
|
|
104
|
+
const {
|
|
105
|
+
max,
|
|
106
|
+
min
|
|
107
|
+
} = new Box3().setFromObject(mesh);
|
|
108
|
+
return {
|
|
109
|
+
width: max.x - min.x,
|
|
110
|
+
height: max.y - min.y
|
|
111
|
+
};
|
|
112
|
+
}
|
|
164
113
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
114
|
+
/**
|
|
115
|
+
* 创建关键帧轨道
|
|
116
|
+
*/
|
|
117
|
+
createKeyframeTracks(type, duration, trackParams) {
|
|
118
|
+
const tracks = [];
|
|
119
|
+
switch (type) {
|
|
120
|
+
case EMarkAnimationType.Bounce:
|
|
121
|
+
// eslint-disable-next-line no-case-declarations
|
|
122
|
+
const {
|
|
123
|
+
position = 0,
|
|
124
|
+
height = 0
|
|
125
|
+
} = trackParams;
|
|
126
|
+
tracks.push(new VectorKeyframeTrack('.position', [0, duration / 2, duration], [0, position, 0, 0, position + height, 0, 0, position, 0]));
|
|
127
|
+
break;
|
|
128
|
+
case EMarkAnimationType.Pulse:
|
|
129
|
+
tracks.push(new VectorKeyframeTrack('.scale', [0, duration / 2, duration], [1, 1, 1, 1.2, 1.2, 1.2, 1, 1, 1]));
|
|
130
|
+
break;
|
|
131
|
+
case EMarkAnimationType.Rotate:
|
|
132
|
+
tracks.push(new NumberKeyframeTrack('.rotation[y]', [0, duration], [0, Math.PI * 2]));
|
|
133
|
+
break;
|
|
134
|
+
case EMarkAnimationType.Flash:
|
|
135
|
+
tracks.push(new NumberKeyframeTrack('.material.opacity', [0, duration / 2, duration], [1, 0.2, 1]));
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
console.error(`animation type ${type} does not exist`);
|
|
139
|
+
break;
|
|
172
140
|
}
|
|
141
|
+
return tracks;
|
|
142
|
+
}
|
|
173
143
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
}
|
|
188
|
-
}
|
|
144
|
+
/**
|
|
145
|
+
* 更新动画
|
|
146
|
+
*/
|
|
147
|
+
update(delta) {
|
|
148
|
+
if (this._mixer) this._mixer.update(delta);
|
|
149
|
+
}
|
|
189
150
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
animation.stop();
|
|
202
|
-
});
|
|
203
|
-
}
|
|
151
|
+
/**
|
|
152
|
+
* 播放动画
|
|
153
|
+
*/
|
|
154
|
+
play(type) {
|
|
155
|
+
if (type) {
|
|
156
|
+
const animation = this._animations.get(type);
|
|
157
|
+
if (animation) animation.reset().play();
|
|
158
|
+
} else {
|
|
159
|
+
this._animations.forEach(animation => {
|
|
160
|
+
animation.reset().play();
|
|
161
|
+
});
|
|
204
162
|
}
|
|
163
|
+
}
|
|
205
164
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
165
|
+
/**
|
|
166
|
+
* 停止动画
|
|
167
|
+
*/
|
|
168
|
+
stop(type) {
|
|
169
|
+
if (type) {
|
|
170
|
+
const animation = this._animations.get(type);
|
|
171
|
+
animation === null || animation === void 0 || animation.stop();
|
|
172
|
+
} else {
|
|
173
|
+
this._animations.forEach(animation => {
|
|
174
|
+
animation.stop();
|
|
175
|
+
});
|
|
214
176
|
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* 销毁资源
|
|
181
|
+
*/
|
|
182
|
+
destroy() {
|
|
183
|
+
this.reset();
|
|
184
|
+
this._mixer = null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
218
187
|
export { KeyframeAnimation, EMarkAnimationType };
|
|
219
188
|
//# sourceMappingURL=KeyframeAnimation.js.map
|
|
@@ -1 +1 @@
|
|
|
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;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C;QAClB,CAAC,CAAC;MACJ;IACF;;IAEA;AACF;AACA;EAFE;IAAAxD,GAAA;IAAAG,KAAA,EAGA,SAAAsD,QAAA,EAAuB;MACrB,IAAI,CAACrD,KAAK,CAAC,CAAC;MACZ,IAAI,CAACP,MAAM,GAAG,IAAI;IACpB;EAAC;EAAA,OAAAf,iBAAA;AAAA;AAGH,SAASA,iBAAiB,EAAED,kBAAkB"}
|
|
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,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA,EAAlBA,kBAAkB,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