@kepler.gl/effects 3.3.0-alpha.21 → 3.3.0-alpha.22
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/animation-utils.d.ts +4 -0
- package/dist/cjs/animation-utils.js +85 -0
- package/dist/cjs/animation-utils.js.map +1 -0
- package/dist/cjs/effect.js +12 -2
- package/dist/cjs/effect.js.map +1 -1
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/effect.d.ts +2 -1
- package/dist/esm/animation-utils.js +77 -0
- package/dist/esm/animation-utils.js.map +1 -0
- package/dist/esm/effect.js +12 -2
- package/dist/esm/effect.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Effect, EffectAnimation, EffectParameterDescription } from '@kepler.gl/types';
|
|
2
|
+
export declare function getAnimatableEffectParameters(effect: Pick<Effect, 'getParameterDescriptions'>): EffectParameterDescription[];
|
|
3
|
+
/** Validate optional endpoints without creating animations for missing or invalid values. */
|
|
4
|
+
export declare function validateEffectAnimation(animation: unknown, descriptions: EffectParameterDescription[]): EffectAnimation | undefined;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getAnimatableEffectParameters = getAnimatableEffectParameters;
|
|
8
|
+
exports.validateEffectAnimation = validateEffectAnimation;
|
|
9
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
11
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
12
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
+
// SPDX-License-Identifier: MIT
|
|
14
|
+
// Copyright contributors to the kepler.gl project
|
|
15
|
+
|
|
16
|
+
var NON_ANIMATABLE_PARAMETERS = new Set(['timestamp', 'animateHeight', 'heightEnd', 'linearEasing']);
|
|
17
|
+
function isAnimatableParameter(description) {
|
|
18
|
+
var name = description.name,
|
|
19
|
+
type = description.type,
|
|
20
|
+
min = description.min,
|
|
21
|
+
max = description.max,
|
|
22
|
+
defaultValue = description.defaultValue;
|
|
23
|
+
if (name.startsWith('_') || NON_ANIMATABLE_PARAMETERS.has(name) || !Number.isFinite(min) || !Number.isFinite(max) || min > max) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (type === 'array' || type === 'color') {
|
|
27
|
+
return Array.isArray(defaultValue) && defaultValue.length > 0 && defaultValue.every(Number.isFinite);
|
|
28
|
+
}
|
|
29
|
+
return type === undefined || type === 'number';
|
|
30
|
+
}
|
|
31
|
+
function getAnimatableEffectParameters(effect) {
|
|
32
|
+
return effect.getParameterDescriptions().filter(isAnimatableParameter);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Validate optional endpoints without creating animations for missing or invalid values. */
|
|
36
|
+
function validateEffectAnimation(animation, descriptions) {
|
|
37
|
+
if (!animation || (0, _typeof2["default"])(animation) !== 'object' || Array.isArray(animation)) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
var result = {};
|
|
41
|
+
var _iterator = _createForOfIteratorHelper(descriptions.filter(isAnimatableParameter)),
|
|
42
|
+
_step;
|
|
43
|
+
try {
|
|
44
|
+
var _loop = function _loop() {
|
|
45
|
+
var description = _step.value;
|
|
46
|
+
var name = description.name,
|
|
47
|
+
type = description.type,
|
|
48
|
+
min = description.min,
|
|
49
|
+
max = description.max,
|
|
50
|
+
defaultValue = description.defaultValue;
|
|
51
|
+
if (!Object.prototype.hasOwnProperty.call(animation, name)) return 0; // continue
|
|
52
|
+
var entry = animation[name];
|
|
53
|
+
if (!entry || (0, _typeof2["default"])(entry) !== 'object' || Array.isArray(entry)) return 0; // continue
|
|
54
|
+
if (entry.easing !== 'linear' && entry.easing !== 'easeInOut') return 0; // continue
|
|
55
|
+
var clampValue = function clampValue(value) {
|
|
56
|
+
return Math.max(min, Math.min(max, value));
|
|
57
|
+
};
|
|
58
|
+
if (type === 'array' || type === 'color') {
|
|
59
|
+
if (!Array.isArray(entry.endValue) || entry.endValue.length !== defaultValue.length || !Array.from(entry.endValue).every(Number.isFinite)) {
|
|
60
|
+
return 0; // continue
|
|
61
|
+
}
|
|
62
|
+
result[name] = {
|
|
63
|
+
endValue: entry.endValue.map(clampValue),
|
|
64
|
+
easing: entry.easing
|
|
65
|
+
};
|
|
66
|
+
} else if (typeof entry.endValue === 'number' && Number.isFinite(entry.endValue)) {
|
|
67
|
+
result[name] = {
|
|
68
|
+
endValue: clampValue(entry.endValue),
|
|
69
|
+
easing: entry.easing
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
_ret;
|
|
74
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
75
|
+
_ret = _loop();
|
|
76
|
+
if (_ret === 0) continue;
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
_iterator.e(err);
|
|
80
|
+
} finally {
|
|
81
|
+
_iterator.f();
|
|
82
|
+
}
|
|
83
|
+
return Object.keys(result).length ? result : undefined;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=animation-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-utils.js","names":["NON_ANIMATABLE_PARAMETERS","Set","isAnimatableParameter","description","name","type","min","max","defaultValue","startsWith","has","Number","isFinite","Array","isArray","length","every","undefined","getAnimatableEffectParameters","effect","getParameterDescriptions","filter","validateEffectAnimation","animation","descriptions","_typeof2","result","_iterator","_createForOfIteratorHelper","_step","_loop","value","Object","prototype","hasOwnProperty","call","entry","easing","clampValue","Math","endValue","from","map","_ret","s","n","done","err","e","f","keys"],"sources":["../../src/animation-utils.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport type {Effect, EffectAnimation, EffectParameterDescription} from '@kepler.gl/types';\n\nconst NON_ANIMATABLE_PARAMETERS = new Set([\n 'timestamp',\n 'animateHeight',\n 'heightEnd',\n 'linearEasing'\n]);\n\nfunction isAnimatableParameter(description: EffectParameterDescription): boolean {\n const {name, type, min, max, defaultValue} = description;\n if (\n name.startsWith('_') ||\n NON_ANIMATABLE_PARAMETERS.has(name) ||\n !Number.isFinite(min) ||\n !Number.isFinite(max) ||\n min > max\n ) {\n return false;\n }\n if (type === 'array' || type === 'color') {\n return (\n Array.isArray(defaultValue) && defaultValue.length > 0 && defaultValue.every(Number.isFinite)\n );\n }\n return type === undefined || type === 'number';\n}\n\nexport function getAnimatableEffectParameters(\n effect: Pick<Effect, 'getParameterDescriptions'>\n): EffectParameterDescription[] {\n return effect.getParameterDescriptions().filter(isAnimatableParameter);\n}\n\n/** Validate optional endpoints without creating animations for missing or invalid values. */\nexport function validateEffectAnimation(\n animation: unknown,\n descriptions: EffectParameterDescription[]\n): EffectAnimation | undefined {\n if (!animation || typeof animation !== 'object' || Array.isArray(animation)) {\n return undefined;\n }\n\n const result: EffectAnimation = {};\n for (const description of descriptions.filter(isAnimatableParameter)) {\n const {name, type, min, max, defaultValue} = description;\n if (!Object.prototype.hasOwnProperty.call(animation, name)) continue;\n const entry = (animation as Record<string, {endValue?: unknown; easing?: unknown}>)[name];\n if (!entry || typeof entry !== 'object' || Array.isArray(entry)) continue;\n if (entry.easing !== 'linear' && entry.easing !== 'easeInOut') continue;\n\n const clampValue = (value: number) => Math.max(min, Math.min(max, value));\n if (type === 'array' || type === 'color') {\n if (\n !Array.isArray(entry.endValue) ||\n entry.endValue.length !== (defaultValue as number[]).length ||\n !Array.from(entry.endValue).every(Number.isFinite)\n ) {\n continue;\n }\n result[name] = {endValue: entry.endValue.map(clampValue), easing: entry.easing};\n } else if (typeof entry.endValue === 'number' && Number.isFinite(entry.endValue)) {\n result[name] = {endValue: clampValue(entry.endValue), easing: entry.easing};\n }\n }\n return Object.keys(result).length ? result : undefined;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;;AAIA,IAAMA,yBAAyB,GAAG,IAAIC,GAAG,CAAC,CACxC,WAAW,EACX,eAAe,EACf,WAAW,EACX,cAAc,CACf,CAAC;AAEF,SAASC,qBAAqBA,CAACC,WAAuC,EAAW;EAC/E,IAAOC,IAAI,GAAkCD,WAAW,CAAjDC,IAAI;IAAEC,IAAI,GAA4BF,WAAW,CAA3CE,IAAI;IAAEC,GAAG,GAAuBH,WAAW,CAArCG,GAAG;IAAEC,GAAG,GAAkBJ,WAAW,CAAhCI,GAAG;IAAEC,YAAY,GAAIL,WAAW,CAA3BK,YAA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AAI,CAAC,GAAG;YAACoC,QAAQ,EAAEF,UAAU,CAACF,KAAK,CAACI,QAAQ,CAAC;YAAEH,MAAM,EAAED,KAAK,CAACC;UAAM,CAAC;QAC7E;MACF,CAAC;MAAAM,IAAA;IApBD,KAAAhB,SAAA,CAAAiB,CAAA,MAAAf,KAAA,GAAAF,SAAA,CAAAkB,CAAA,IAAAC,IAAA;MAAAH,IAAA,GAAAb,KAAA;MAAA,IAAAa,IAAA,QAE8D;IAAS;EAkBtE,SAAAI,GAAA;IAAApB,SAAA,CAAAqB,CAAA,CAAAD,GAAA;EAAA;IAAApB,SAAA,CAAAsB,CAAA;EAAA;EACD,OAAOjB,MAAM,CAACkB,IAAI,CAACxB,MAAM,CAAC,CAACX,MAAM,GAAGW,MAAM,GAAGT,SAAS;AACxD","ignoreList":[]}
|
package/dist/cjs/effect.js
CHANGED
|
@@ -11,6 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var _utils = require("@kepler.gl/utils");
|
|
12
12
|
var _commonUtils = require("@kepler.gl/common-utils");
|
|
13
13
|
var _constants = require("@kepler.gl/constants");
|
|
14
|
+
var _animationUtils = require("./animation-utils");
|
|
14
15
|
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; }
|
|
15
16
|
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) { (0, _defineProperty2["default"])(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; } // SPDX-License-Identifier: MIT
|
|
16
17
|
// Copyright contributors to the kepler.gl project
|
|
@@ -24,6 +25,7 @@ var Effect = exports.Effect = /*#__PURE__*/function () {
|
|
|
24
25
|
(0, _defineProperty2["default"])(this, "isEnabled", void 0);
|
|
25
26
|
// effect specific parameters for a deck.gl effect (uniforms)
|
|
26
27
|
(0, _defineProperty2["default"])(this, "parameters", void 0);
|
|
28
|
+
(0, _defineProperty2["default"])(this, "animation", void 0);
|
|
27
29
|
// runtime props
|
|
28
30
|
(0, _defineProperty2["default"])(this, "isConfigActive", void 0);
|
|
29
31
|
(0, _defineProperty2["default"])(this, "isJsonEditorActive", void 0);
|
|
@@ -37,6 +39,8 @@ var Effect = exports.Effect = /*#__PURE__*/function () {
|
|
|
37
39
|
this.isJsonEditorActive = _props.isJsonEditorActive;
|
|
38
40
|
this._uiConfig = _constants.LIGHT_AND_SHADOW_EFFECT.type === this.type ? _constants.LIGHT_AND_SHADOW_EFFECT.parameters : ((_POSTPROCESSING_EFFEC = _constants.POSTPROCESSING_EFFECTS[this.type]) === null || _POSTPROCESSING_EFFEC === void 0 ? void 0 : _POSTPROCESSING_EFFEC.parameters) || [];
|
|
39
41
|
this.parameters = (0, _utils.validateEffectParameters)(_props.parameters, this._uiConfig);
|
|
42
|
+
this.animation = (0, _animationUtils.validateEffectAnimation)(_props.animation, this._uiConfig);
|
|
43
|
+
if (!this.animation) delete this.animation;
|
|
40
44
|
this.deckEffect = null;
|
|
41
45
|
this._initializeEffect();
|
|
42
46
|
}
|
|
@@ -56,14 +60,16 @@ var Effect = exports.Effect = /*#__PURE__*/function () {
|
|
|
56
60
|
value: function getDefaultProps() {
|
|
57
61
|
var _props$isEnabled, _props$isConfigActive, _props$isJsonEditorAc;
|
|
58
62
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
59
|
-
return {
|
|
63
|
+
return _objectSpread({
|
|
60
64
|
id: props.id || "e_".concat((0, _commonUtils.generateHashId)(6)),
|
|
61
65
|
type: props.type || _constants.DEFAULT_POST_PROCESSING_EFFECT_TYPE,
|
|
62
66
|
isEnabled: (_props$isEnabled = props.isEnabled) !== null && _props$isEnabled !== void 0 ? _props$isEnabled : true,
|
|
63
67
|
isConfigActive: (_props$isConfigActive = props.isConfigActive) !== null && _props$isConfigActive !== void 0 ? _props$isConfigActive : true,
|
|
64
68
|
isJsonEditorActive: (_props$isJsonEditorAc = props.isJsonEditorActive) !== null && _props$isJsonEditorAc !== void 0 ? _props$isJsonEditorAc : false,
|
|
65
69
|
parameters: _objectSpread({}, props.parameters)
|
|
66
|
-
}
|
|
70
|
+
}, props.animation ? {
|
|
71
|
+
animation: props.animation
|
|
72
|
+
} : {});
|
|
67
73
|
}
|
|
68
74
|
}, {
|
|
69
75
|
key: "setProps",
|
|
@@ -75,6 +81,10 @@ var Effect = exports.Effect = /*#__PURE__*/function () {
|
|
|
75
81
|
this.isConfigActive = (_props$isConfigActive2 = props.isConfigActive) !== null && _props$isConfigActive2 !== void 0 ? _props$isConfigActive2 : this.isConfigActive;
|
|
76
82
|
this.isJsonEditorActive = (_props$isJsonEditorAc2 = props.isJsonEditorActive) !== null && _props$isJsonEditorAc2 !== void 0 ? _props$isJsonEditorAc2 : this.isJsonEditorActive;
|
|
77
83
|
this.parameters = _objectSpread(_objectSpread({}, this.parameters), (0, _utils.validateEffectParameters)(props.parameters, this._uiConfig));
|
|
84
|
+
if (Object.prototype.hasOwnProperty.call(props, 'animation')) {
|
|
85
|
+
this.animation = (0, _animationUtils.validateEffectAnimation)(props.animation, this._uiConfig);
|
|
86
|
+
if (!this.animation) delete this.animation;
|
|
87
|
+
}
|
|
78
88
|
}
|
|
79
89
|
}, {
|
|
80
90
|
key: "isValidToSave",
|
package/dist/cjs/effect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.js","names":["_utils","require","_commonUtils","_constants","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","Effect","exports","_POSTPROCESSING_EFFEC","props","undefined","_classCallCheck2","id","concat","generateHashId","_props","getDefaultProps","type","isEnabled","isConfigActive","isJsonEditorActive","_uiConfig","LIGHT_AND_SHADOW_EFFECT","parameters","POSTPROCESSING_EFFECTS","validateEffectParameters","deckEffect","_initializeEffect","_createClass2","key","value","clone","constructor","_props$isEnabled","_props$isConfigActive","_props$isJsonEditorAc","DEFAULT_POST_PROCESSING_EFFECT_TYPE","setProps","_props$id","_props$type","_props$isEnabled2","_props$isConfigActive2","_props$isJsonEditorAc2","isValidToSave","Boolean","getParameterDescriptions","_default"],"sources":["../../src/effect.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {validateEffectParameters} from '@kepler.gl/utils';\nimport {generateHashId} from '@kepler.gl/common-utils';\nimport {\n Effect as EffectInterface,\n EffectProps,\n EffectPropsPartial,\n EffectParameterDescription\n} from '@kepler.gl/types';\nimport {\n DEFAULT_POST_PROCESSING_EFFECT_TYPE,\n POSTPROCESSING_EFFECTS,\n LIGHT_AND_SHADOW_EFFECT\n} from '@kepler.gl/constants';\n\nexport class Effect implements EffectInterface {\n id: string;\n type: string;\n isEnabled: boolean;\n // effect specific parameters for a deck.gl effect (uniforms)\n parameters: {[key: string]: any};\n // runtime props\n isConfigActive: boolean;\n isJsonEditorActive: boolean;\n deckEffect: any;\n _uiConfig: EffectParameterDescription[];\n\n constructor(props: EffectPropsPartial = {}) {\n this.id = props.id || `e_${generateHashId(6)}`;\n\n const _props = this.getDefaultProps(props);\n this.type = _props.type;\n this.isEnabled = _props.isEnabled;\n this.isConfigActive = _props.isConfigActive;\n this.isJsonEditorActive = _props.isJsonEditorActive;\n\n this._uiConfig =\n LIGHT_AND_SHADOW_EFFECT.type === this.type\n ? LIGHT_AND_SHADOW_EFFECT.parameters\n : POSTPROCESSING_EFFECTS[this.type]?.parameters || [];\n this.parameters = validateEffectParameters(_props.parameters, this._uiConfig);\n\n this.deckEffect = null;\n this._initializeEffect();\n }\n\n _initializeEffect() {\n // implemented in subclasses\n }\n\n clone(): Effect {\n const props = this.getDefaultProps(this);\n return new (this.constructor as new (props: EffectPropsPartial) => this)(props);\n }\n\n getDefaultProps(props: EffectPropsPartial = {}): EffectProps {\n return {\n id: props.id || `e_${generateHashId(6)}`,\n type: props.type || DEFAULT_POST_PROCESSING_EFFECT_TYPE,\n isEnabled: props.isEnabled ?? true,\n isConfigActive: props.isConfigActive ?? true,\n isJsonEditorActive: props.isJsonEditorActive ?? false,\n parameters: {...props.parameters}\n };\n }\n\n setProps(props: EffectPropsPartial) {\n this.id = props.id ?? this.id;\n this.type = props.type ?? this.type;\n this.isEnabled = props.isEnabled ?? this.isEnabled;\n this.isConfigActive = props.isConfigActive ?? this.isConfigActive;\n this.isJsonEditorActive = props.isJsonEditorActive ?? this.isJsonEditorActive;\n this.parameters = {\n ...this.parameters,\n ...validateEffectParameters(props.parameters, this._uiConfig)\n };\n }\n\n isValidToSave() {\n return Boolean(this.type && this.id && this.deckEffect);\n }\n\n /**\n * Effect specific list of configurable parameters.\n * @returns All parameters are in preffered order.\n */\n getParameterDescriptions() {\n return this._uiConfig || [];\n }\n}\n\nexport default Effect;\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;
|
|
1
|
+
{"version":3,"file":"effect.js","names":["_utils","require","_commonUtils","_constants","_animationUtils","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","Effect","exports","_POSTPROCESSING_EFFEC","props","undefined","_classCallCheck2","id","concat","generateHashId","_props","getDefaultProps","type","isEnabled","isConfigActive","isJsonEditorActive","_uiConfig","LIGHT_AND_SHADOW_EFFECT","parameters","POSTPROCESSING_EFFECTS","validateEffectParameters","animation","validateEffectAnimation","deckEffect","_initializeEffect","_createClass2","key","value","clone","constructor","_props$isEnabled","_props$isConfigActive","_props$isJsonEditorAc","DEFAULT_POST_PROCESSING_EFFECT_TYPE","setProps","_props$id","_props$type","_props$isEnabled2","_props$isConfigActive2","_props$isJsonEditorAc2","prototype","hasOwnProperty","call","isValidToSave","Boolean","getParameterDescriptions","_default"],"sources":["../../src/effect.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {validateEffectParameters} from '@kepler.gl/utils';\nimport {generateHashId} from '@kepler.gl/common-utils';\nimport {\n Effect as EffectInterface,\n EffectProps,\n EffectPropsPartial,\n EffectParameterDescription,\n EffectAnimation\n} from '@kepler.gl/types';\nimport {\n DEFAULT_POST_PROCESSING_EFFECT_TYPE,\n POSTPROCESSING_EFFECTS,\n LIGHT_AND_SHADOW_EFFECT\n} from '@kepler.gl/constants';\nimport {validateEffectAnimation} from './animation-utils';\n\nexport class Effect implements EffectInterface {\n id: string;\n type: string;\n isEnabled: boolean;\n // effect specific parameters for a deck.gl effect (uniforms)\n parameters: {[key: string]: any};\n animation?: EffectAnimation;\n // runtime props\n isConfigActive: boolean;\n isJsonEditorActive: boolean;\n deckEffect: any;\n _uiConfig: EffectParameterDescription[];\n\n constructor(props: EffectPropsPartial = {}) {\n this.id = props.id || `e_${generateHashId(6)}`;\n\n const _props = this.getDefaultProps(props);\n this.type = _props.type;\n this.isEnabled = _props.isEnabled;\n this.isConfigActive = _props.isConfigActive;\n this.isJsonEditorActive = _props.isJsonEditorActive;\n\n this._uiConfig =\n LIGHT_AND_SHADOW_EFFECT.type === this.type\n ? LIGHT_AND_SHADOW_EFFECT.parameters\n : POSTPROCESSING_EFFECTS[this.type]?.parameters || [];\n this.parameters = validateEffectParameters(_props.parameters, this._uiConfig);\n this.animation = validateEffectAnimation(_props.animation, this._uiConfig);\n if (!this.animation) delete this.animation;\n\n this.deckEffect = null;\n this._initializeEffect();\n }\n\n _initializeEffect() {\n // implemented in subclasses\n }\n\n clone(): Effect {\n const props = this.getDefaultProps(this);\n return new (this.constructor as new (props: EffectPropsPartial) => this)(props);\n }\n\n getDefaultProps(props: EffectPropsPartial = {}): EffectProps {\n return {\n id: props.id || `e_${generateHashId(6)}`,\n type: props.type || DEFAULT_POST_PROCESSING_EFFECT_TYPE,\n isEnabled: props.isEnabled ?? true,\n isConfigActive: props.isConfigActive ?? true,\n isJsonEditorActive: props.isJsonEditorActive ?? false,\n parameters: {...props.parameters},\n ...(props.animation ? {animation: props.animation} : {})\n };\n }\n\n setProps(props: EffectPropsPartial) {\n this.id = props.id ?? this.id;\n this.type = props.type ?? this.type;\n this.isEnabled = props.isEnabled ?? this.isEnabled;\n this.isConfigActive = props.isConfigActive ?? this.isConfigActive;\n this.isJsonEditorActive = props.isJsonEditorActive ?? this.isJsonEditorActive;\n this.parameters = {\n ...this.parameters,\n ...validateEffectParameters(props.parameters, this._uiConfig)\n };\n if (Object.prototype.hasOwnProperty.call(props, 'animation')) {\n this.animation = validateEffectAnimation(props.animation, this._uiConfig);\n if (!this.animation) delete this.animation;\n }\n }\n\n isValidToSave() {\n return Boolean(this.type && this.id && this.deckEffect);\n }\n\n /**\n * Effect specific list of configurable parameters.\n * @returns All parameters are in preffered order.\n */\n getParameterDescriptions() {\n return this._uiConfig || [];\n }\n}\n\nexport default Effect;\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,UAAA,GAAAF,OAAA;AAKA,IAAAG,eAAA,GAAAH,OAAA;AAA0D,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,W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ANGED
|
@@ -22,7 +22,20 @@ Object.defineProperty(exports, "createEffect", {
|
|
|
22
22
|
return _utils.createEffect;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
+
Object.defineProperty(exports, "getAnimatableEffectParameters", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _animationUtils.getAnimatableEffectParameters;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "validateEffectAnimation", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _animationUtils.validateEffectAnimation;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
25
37
|
var _effect = _interopRequireDefault(require("./effect"));
|
|
26
38
|
var _utils = require("./utils");
|
|
39
|
+
var _animationUtils = require("./animation-utils");
|
|
27
40
|
var _shadowCompositing = require("./shader-passes/shadow-compositing");
|
|
28
41
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_effect","_interopRequireDefault","require","_utils","_shadowCompositing"],"sources":["../../src/index.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nexport {default as Effect} from './effect';\nexport {createEffect} from './utils';\nexport {DeckShadowCompositingEffect} from './shader-passes/shadow-compositing';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_effect","_interopRequireDefault","require","_utils","_animationUtils","_shadowCompositing"],"sources":["../../src/index.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nexport {default as Effect} from './effect';\nexport {createEffect} from './utils';\nexport {getAnimatableEffectParameters, validateEffectAnimation} from './animation-utils';\nexport {DeckShadowCompositingEffect} from './shader-passes/shadow-compositing';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA","ignoreList":[]}
|
package/dist/effect.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect as EffectInterface, EffectProps, EffectPropsPartial, EffectParameterDescription } from '@kepler.gl/types';
|
|
1
|
+
import { Effect as EffectInterface, EffectProps, EffectPropsPartial, EffectParameterDescription, EffectAnimation } from '@kepler.gl/types';
|
|
2
2
|
export declare class Effect implements EffectInterface {
|
|
3
3
|
id: string;
|
|
4
4
|
type: string;
|
|
@@ -6,6 +6,7 @@ export declare class Effect implements EffectInterface {
|
|
|
6
6
|
parameters: {
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
};
|
|
9
|
+
animation?: EffectAnimation;
|
|
9
10
|
isConfigActive: boolean;
|
|
10
11
|
isJsonEditorActive: boolean;
|
|
11
12
|
deckEffect: any;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
// SPDX-License-Identifier: MIT
|
|
6
|
+
// Copyright contributors to the kepler.gl project
|
|
7
|
+
|
|
8
|
+
var NON_ANIMATABLE_PARAMETERS = new Set(['timestamp', 'animateHeight', 'heightEnd', 'linearEasing']);
|
|
9
|
+
function isAnimatableParameter(description) {
|
|
10
|
+
var name = description.name,
|
|
11
|
+
type = description.type,
|
|
12
|
+
min = description.min,
|
|
13
|
+
max = description.max,
|
|
14
|
+
defaultValue = description.defaultValue;
|
|
15
|
+
if (name.startsWith('_') || NON_ANIMATABLE_PARAMETERS.has(name) || !Number.isFinite(min) || !Number.isFinite(max) || min > max) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (type === 'array' || type === 'color') {
|
|
19
|
+
return Array.isArray(defaultValue) && defaultValue.length > 0 && defaultValue.every(Number.isFinite);
|
|
20
|
+
}
|
|
21
|
+
return type === undefined || type === 'number';
|
|
22
|
+
}
|
|
23
|
+
export function getAnimatableEffectParameters(effect) {
|
|
24
|
+
return effect.getParameterDescriptions().filter(isAnimatableParameter);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Validate optional endpoints without creating animations for missing or invalid values. */
|
|
28
|
+
export function validateEffectAnimation(animation, descriptions) {
|
|
29
|
+
if (!animation || _typeof(animation) !== 'object' || Array.isArray(animation)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
var result = {};
|
|
33
|
+
var _iterator = _createForOfIteratorHelper(descriptions.filter(isAnimatableParameter)),
|
|
34
|
+
_step;
|
|
35
|
+
try {
|
|
36
|
+
var _loop = function _loop() {
|
|
37
|
+
var description = _step.value;
|
|
38
|
+
var name = description.name,
|
|
39
|
+
type = description.type,
|
|
40
|
+
min = description.min,
|
|
41
|
+
max = description.max,
|
|
42
|
+
defaultValue = description.defaultValue;
|
|
43
|
+
if (!Object.prototype.hasOwnProperty.call(animation, name)) return 0; // continue
|
|
44
|
+
var entry = animation[name];
|
|
45
|
+
if (!entry || _typeof(entry) !== 'object' || Array.isArray(entry)) return 0; // continue
|
|
46
|
+
if (entry.easing !== 'linear' && entry.easing !== 'easeInOut') return 0; // continue
|
|
47
|
+
var clampValue = function clampValue(value) {
|
|
48
|
+
return Math.max(min, Math.min(max, value));
|
|
49
|
+
};
|
|
50
|
+
if (type === 'array' || type === 'color') {
|
|
51
|
+
if (!Array.isArray(entry.endValue) || entry.endValue.length !== defaultValue.length || !Array.from(entry.endValue).every(Number.isFinite)) {
|
|
52
|
+
return 0; // continue
|
|
53
|
+
}
|
|
54
|
+
result[name] = {
|
|
55
|
+
endValue: entry.endValue.map(clampValue),
|
|
56
|
+
easing: entry.easing
|
|
57
|
+
};
|
|
58
|
+
} else if (typeof entry.endValue === 'number' && Number.isFinite(entry.endValue)) {
|
|
59
|
+
result[name] = {
|
|
60
|
+
endValue: clampValue(entry.endValue),
|
|
61
|
+
easing: entry.easing
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
_ret;
|
|
66
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
67
|
+
_ret = _loop();
|
|
68
|
+
if (_ret === 0) continue;
|
|
69
|
+
}
|
|
70
|
+
} catch (err) {
|
|
71
|
+
_iterator.e(err);
|
|
72
|
+
} finally {
|
|
73
|
+
_iterator.f();
|
|
74
|
+
}
|
|
75
|
+
return Object.keys(result).length ? result : undefined;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=animation-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-utils.js","names":["NON_ANIMATABLE_PARAMETERS","Set","isAnimatableParameter","description","name","type","min","max","defaultValue","startsWith","has","Number","isFinite","Array","isArray","length","every","undefined","getAnimatableEffectParameters","effect","getParameterDescriptions","filter","validateEffectAnimation","animation","descriptions","_typeof","result","_iterator","_createForOfIteratorHelper","_step","_loop","value","Object","prototype","hasOwnProperty","call","entry","easing","clampValue","Math","endValue","from","map","_ret","s","n","done","err","e","f","keys"],"sources":["../../src/animation-utils.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport type {Effect, EffectAnimation, EffectParameterDescription} from '@kepler.gl/types';\n\nconst NON_ANIMATABLE_PARAMETERS = new Set([\n 'timestamp',\n 'animateHeight',\n 'heightEnd',\n 'linearEasing'\n]);\n\nfunction isAnimatableParameter(description: EffectParameterDescription): boolean {\n const {name, type, min, max, defaultValue} = description;\n if (\n name.startsWith('_') ||\n NON_ANIMATABLE_PARAMETERS.has(name) ||\n !Number.isFinite(min) ||\n !Number.isFinite(max) ||\n min > max\n ) {\n return false;\n }\n if (type === 'array' || type === 'color') {\n return (\n Array.isArray(defaultValue) && defaultValue.length > 0 && defaultValue.every(Number.isFinite)\n );\n }\n return type === undefined || type === 'number';\n}\n\nexport function getAnimatableEffectParameters(\n effect: Pick<Effect, 'getParameterDescriptions'>\n): EffectParameterDescription[] {\n return effect.getParameterDescriptions().filter(isAnimatableParameter);\n}\n\n/** Validate optional endpoints without creating animations for missing or invalid values. */\nexport function validateEffectAnimation(\n animation: unknown,\n descriptions: EffectParameterDescription[]\n): EffectAnimation | undefined {\n if (!animation || typeof animation !== 'object' || Array.isArray(animation)) {\n return undefined;\n }\n\n const result: EffectAnimation = {};\n for (const description of descriptions.filter(isAnimatableParameter)) {\n const {name, type, min, max, defaultValue} = description;\n if (!Object.prototype.hasOwnProperty.call(animation, name)) continue;\n const entry = (animation as Record<string, {endValue?: unknown; easing?: unknown}>)[name];\n if (!entry || typeof entry !== 'object' || Array.isArray(entry)) continue;\n if (entry.easing !== 'linear' && entry.easing !== 'easeInOut') continue;\n\n const clampValue = (value: number) => Math.max(min, Math.min(max, value));\n if (type === 'array' || type === 'color') {\n if (\n !Array.isArray(entry.endValue) ||\n entry.endValue.length !== (defaultValue as number[]).length ||\n !Array.from(entry.endValue).every(Number.isFinite)\n ) {\n continue;\n }\n result[name] = {endValue: entry.endValue.map(clampValue), easing: entry.easing};\n } else if (typeof entry.endValue === 'number' && Number.isFinite(entry.endValue)) {\n result[name] = {endValue: clampValue(entry.endValue), easing: entry.easing};\n }\n }\n return Object.keys(result).length ? result : undefined;\n}\n"],"mappings":";;;;AAAA;AACA;;AAIA,IAAMA,yBAAyB,GAAG,IAAIC,GAAG,CAAC,CACxC,WAAW,EACX,eAAe,EACf,WAAW,EACX,cAAc,CACf,CAAC;AAEF,SAASC,qBAAqBA,CAACC,WAAuC,EAAW;EAC/E,IAAOC,IAAI,GAAkCD,WAAW,CAAjDC,IAAI;IAAEC,IAAI,GAA4BF,WAAW,CAA3CE,IAAI;IAAEC,GAAG,GAAuBH,WAAW,CAArCG,GAAG;IAAEC,GAAG,GAAkBJ,WAAW,CAAhCI,GAAG;IAAEC,YAAY,GAAIL,WAAW,CAA3BK,YAAY;EACzC,IACEJ,IAAI,CAACK,UAAU,CAAC,GAAG,CAAC,IACpBT,yBAAyB,CAACU,GAAG,CAACN,IAAI,CAAC,IACnC,CAACO,MAAM,CAACC,QAAQ,CAACN,GAAG,CAAC,IACrB,CAACK,MAAM,CAACC,QAAQ,CAACL,GAAG,CAAC,IACrBD,GAAG,GAAGC,GAAG,EACT;IACA,OAAO,KAAK;EACd;EACA,IAAIF,IAAI,KAAK,OAAO,IAAIA,IAAI,KAAK,OAAO,EAAE;IACxC,OACEQ,KAAK,CAACC,OAAO,CAACN,YAAY,CAAC,IAAIA,YAAY,CAACO,MAAM,GAAG,CAAC,IAAIP,YAAY,CAACQ,KAAK,CAACL,MAAM,CAACC,QAAQ,CAAC;EAEjG;EACA,OAAO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MAAM,GAAGT,SAAS;AACxD","ignoreList":[]}
|
package/dist/esm/effect.js
CHANGED
|
@@ -9,6 +9,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
9
9
|
import { validateEffectParameters } from '@kepler.gl/utils';
|
|
10
10
|
import { generateHashId } from '@kepler.gl/common-utils';
|
|
11
11
|
import { DEFAULT_POST_PROCESSING_EFFECT_TYPE, POSTPROCESSING_EFFECTS, LIGHT_AND_SHADOW_EFFECT } from '@kepler.gl/constants';
|
|
12
|
+
import { validateEffectAnimation } from './animation-utils';
|
|
12
13
|
export var Effect = /*#__PURE__*/function () {
|
|
13
14
|
function Effect() {
|
|
14
15
|
var _POSTPROCESSING_EFFEC;
|
|
@@ -19,6 +20,7 @@ export var Effect = /*#__PURE__*/function () {
|
|
|
19
20
|
_defineProperty(this, "isEnabled", void 0);
|
|
20
21
|
// effect specific parameters for a deck.gl effect (uniforms)
|
|
21
22
|
_defineProperty(this, "parameters", void 0);
|
|
23
|
+
_defineProperty(this, "animation", void 0);
|
|
22
24
|
// runtime props
|
|
23
25
|
_defineProperty(this, "isConfigActive", void 0);
|
|
24
26
|
_defineProperty(this, "isJsonEditorActive", void 0);
|
|
@@ -32,6 +34,8 @@ export var Effect = /*#__PURE__*/function () {
|
|
|
32
34
|
this.isJsonEditorActive = _props.isJsonEditorActive;
|
|
33
35
|
this._uiConfig = LIGHT_AND_SHADOW_EFFECT.type === this.type ? LIGHT_AND_SHADOW_EFFECT.parameters : ((_POSTPROCESSING_EFFEC = POSTPROCESSING_EFFECTS[this.type]) === null || _POSTPROCESSING_EFFEC === void 0 ? void 0 : _POSTPROCESSING_EFFEC.parameters) || [];
|
|
34
36
|
this.parameters = validateEffectParameters(_props.parameters, this._uiConfig);
|
|
37
|
+
this.animation = validateEffectAnimation(_props.animation, this._uiConfig);
|
|
38
|
+
if (!this.animation) delete this.animation;
|
|
35
39
|
this.deckEffect = null;
|
|
36
40
|
this._initializeEffect();
|
|
37
41
|
}
|
|
@@ -51,14 +55,16 @@ export var Effect = /*#__PURE__*/function () {
|
|
|
51
55
|
value: function getDefaultProps() {
|
|
52
56
|
var _props$isEnabled, _props$isConfigActive, _props$isJsonEditorAc;
|
|
53
57
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
54
|
-
return {
|
|
58
|
+
return _objectSpread({
|
|
55
59
|
id: props.id || "e_".concat(generateHashId(6)),
|
|
56
60
|
type: props.type || DEFAULT_POST_PROCESSING_EFFECT_TYPE,
|
|
57
61
|
isEnabled: (_props$isEnabled = props.isEnabled) !== null && _props$isEnabled !== void 0 ? _props$isEnabled : true,
|
|
58
62
|
isConfigActive: (_props$isConfigActive = props.isConfigActive) !== null && _props$isConfigActive !== void 0 ? _props$isConfigActive : true,
|
|
59
63
|
isJsonEditorActive: (_props$isJsonEditorAc = props.isJsonEditorActive) !== null && _props$isJsonEditorAc !== void 0 ? _props$isJsonEditorAc : false,
|
|
60
64
|
parameters: _objectSpread({}, props.parameters)
|
|
61
|
-
}
|
|
65
|
+
}, props.animation ? {
|
|
66
|
+
animation: props.animation
|
|
67
|
+
} : {});
|
|
62
68
|
}
|
|
63
69
|
}, {
|
|
64
70
|
key: "setProps",
|
|
@@ -70,6 +76,10 @@ export var Effect = /*#__PURE__*/function () {
|
|
|
70
76
|
this.isConfigActive = (_props$isConfigActive2 = props.isConfigActive) !== null && _props$isConfigActive2 !== void 0 ? _props$isConfigActive2 : this.isConfigActive;
|
|
71
77
|
this.isJsonEditorActive = (_props$isJsonEditorAc2 = props.isJsonEditorActive) !== null && _props$isJsonEditorAc2 !== void 0 ? _props$isJsonEditorAc2 : this.isJsonEditorActive;
|
|
72
78
|
this.parameters = _objectSpread(_objectSpread({}, this.parameters), validateEffectParameters(props.parameters, this._uiConfig));
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(props, 'animation')) {
|
|
80
|
+
this.animation = validateEffectAnimation(props.animation, this._uiConfig);
|
|
81
|
+
if (!this.animation) delete this.animation;
|
|
82
|
+
}
|
|
73
83
|
}
|
|
74
84
|
}, {
|
|
75
85
|
key: "isValidToSave",
|
package/dist/esm/effect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.js","names":["validateEffectParameters","generateHashId","DEFAULT_POST_PROCESSING_EFFECT_TYPE","POSTPROCESSING_EFFECTS","LIGHT_AND_SHADOW_EFFECT","Effect","_POSTPROCESSING_EFFEC","props","arguments","length","undefined","_classCallCheck","_defineProperty","id","concat","_props","getDefaultProps","type","isEnabled","isConfigActive","isJsonEditorActive","_uiConfig","parameters","deckEffect","_initializeEffect","_createClass","key","value","clone","constructor","_props$isEnabled","_props$isConfigActive","_props$isJsonEditorAc","_objectSpread","setProps","_props$id","_props$type","_props$isEnabled2","_props$isConfigActive2","_props$isJsonEditorAc2","isValidToSave","Boolean","getParameterDescriptions"],"sources":["../../src/effect.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {validateEffectParameters} from '@kepler.gl/utils';\nimport {generateHashId} from '@kepler.gl/common-utils';\nimport {\n Effect as EffectInterface,\n EffectProps,\n EffectPropsPartial,\n EffectParameterDescription\n} from '@kepler.gl/types';\nimport {\n DEFAULT_POST_PROCESSING_EFFECT_TYPE,\n POSTPROCESSING_EFFECTS,\n LIGHT_AND_SHADOW_EFFECT\n} from '@kepler.gl/constants';\n\nexport class Effect implements EffectInterface {\n id: string;\n type: string;\n isEnabled: boolean;\n // effect specific parameters for a deck.gl effect (uniforms)\n parameters: {[key: string]: any};\n // runtime props\n isConfigActive: boolean;\n isJsonEditorActive: boolean;\n deckEffect: any;\n _uiConfig: EffectParameterDescription[];\n\n constructor(props: EffectPropsPartial = {}) {\n this.id = props.id || `e_${generateHashId(6)}`;\n\n const _props = this.getDefaultProps(props);\n this.type = _props.type;\n this.isEnabled = _props.isEnabled;\n this.isConfigActive = _props.isConfigActive;\n this.isJsonEditorActive = _props.isJsonEditorActive;\n\n this._uiConfig =\n LIGHT_AND_SHADOW_EFFECT.type === this.type\n ? LIGHT_AND_SHADOW_EFFECT.parameters\n : POSTPROCESSING_EFFECTS[this.type]?.parameters || [];\n this.parameters = validateEffectParameters(_props.parameters, this._uiConfig);\n\n this.deckEffect = null;\n this._initializeEffect();\n }\n\n _initializeEffect() {\n // implemented in subclasses\n }\n\n clone(): Effect {\n const props = this.getDefaultProps(this);\n return new (this.constructor as new (props: EffectPropsPartial) => this)(props);\n }\n\n getDefaultProps(props: EffectPropsPartial = {}): EffectProps {\n return {\n id: props.id || `e_${generateHashId(6)}`,\n type: props.type || DEFAULT_POST_PROCESSING_EFFECT_TYPE,\n isEnabled: props.isEnabled ?? true,\n isConfigActive: props.isConfigActive ?? true,\n isJsonEditorActive: props.isJsonEditorActive ?? false,\n parameters: {...props.parameters}\n };\n }\n\n setProps(props: EffectPropsPartial) {\n this.id = props.id ?? this.id;\n this.type = props.type ?? this.type;\n this.isEnabled = props.isEnabled ?? this.isEnabled;\n this.isConfigActive = props.isConfigActive ?? this.isConfigActive;\n this.isJsonEditorActive = props.isJsonEditorActive ?? this.isJsonEditorActive;\n this.parameters = {\n ...this.parameters,\n ...validateEffectParameters(props.parameters, this._uiConfig)\n };\n }\n\n isValidToSave() {\n return Boolean(this.type && this.id && this.deckEffect);\n }\n\n /**\n * Effect specific list of configurable parameters.\n * @returns All parameters are in preffered order.\n */\n getParameterDescriptions() {\n return this._uiConfig || [];\n }\n}\n\nexport default Effect;\n"],"mappings":";;;;;AAAA;AACA;;AAEA,SAAQA,wBAAwB,QAAO,kBAAkB;AACzD,SAAQC,cAAc,QAAO,yBAAyB;
|
|
1
|
+
{"version":3,"file":"effect.js","names":["validateEffectParameters","generateHashId","DEFAULT_POST_PROCESSING_EFFECT_TYPE","POSTPROCESSING_EFFECTS","LIGHT_AND_SHADOW_EFFECT","validateEffectAnimation","Effect","_POSTPROCESSING_EFFEC","props","arguments","length","undefined","_classCallCheck","_defineProperty","id","concat","_props","getDefaultProps","type","isEnabled","isConfigActive","isJsonEditorActive","_uiConfig","parameters","animation","deckEffect","_initializeEffect","_createClass","key","value","clone","constructor","_props$isEnabled","_props$isConfigActive","_props$isJsonEditorAc","_objectSpread","setProps","_props$id","_props$type","_props$isEnabled2","_props$isConfigActive2","_props$isJsonEditorAc2","Object","prototype","hasOwnProperty","call","isValidToSave","Boolean","getParameterDescriptions"],"sources":["../../src/effect.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {validateEffectParameters} from '@kepler.gl/utils';\nimport {generateHashId} from '@kepler.gl/common-utils';\nimport {\n Effect as EffectInterface,\n EffectProps,\n EffectPropsPartial,\n EffectParameterDescription,\n EffectAnimation\n} from '@kepler.gl/types';\nimport {\n DEFAULT_POST_PROCESSING_EFFECT_TYPE,\n POSTPROCESSING_EFFECTS,\n LIGHT_AND_SHADOW_EFFECT\n} from '@kepler.gl/constants';\nimport {validateEffectAnimation} from './animation-utils';\n\nexport class Effect implements EffectInterface {\n id: string;\n type: string;\n isEnabled: boolean;\n // effect specific parameters for a deck.gl effect (uniforms)\n parameters: {[key: string]: any};\n animation?: EffectAnimation;\n // runtime props\n isConfigActive: boolean;\n isJsonEditorActive: boolean;\n deckEffect: any;\n _uiConfig: EffectParameterDescription[];\n\n constructor(props: EffectPropsPartial = {}) {\n this.id = props.id || `e_${generateHashId(6)}`;\n\n const _props = this.getDefaultProps(props);\n this.type = _props.type;\n this.isEnabled = _props.isEnabled;\n this.isConfigActive = _props.isConfigActive;\n this.isJsonEditorActive = _props.isJsonEditorActive;\n\n this._uiConfig =\n LIGHT_AND_SHADOW_EFFECT.type === this.type\n ? LIGHT_AND_SHADOW_EFFECT.parameters\n : POSTPROCESSING_EFFECTS[this.type]?.parameters || [];\n this.parameters = validateEffectParameters(_props.parameters, this._uiConfig);\n this.animation = validateEffectAnimation(_props.animation, this._uiConfig);\n if (!this.animation) delete this.animation;\n\n this.deckEffect = null;\n this._initializeEffect();\n }\n\n _initializeEffect() {\n // implemented in subclasses\n }\n\n clone(): Effect {\n const props = this.getDefaultProps(this);\n return new (this.constructor as new (props: EffectPropsPartial) => this)(props);\n }\n\n getDefaultProps(props: EffectPropsPartial = {}): EffectProps {\n return {\n id: props.id || `e_${generateHashId(6)}`,\n type: props.type || DEFAULT_POST_PROCESSING_EFFECT_TYPE,\n isEnabled: props.isEnabled ?? true,\n isConfigActive: props.isConfigActive ?? true,\n isJsonEditorActive: props.isJsonEditorActive ?? false,\n parameters: {...props.parameters},\n ...(props.animation ? {animation: props.animation} : {})\n };\n }\n\n setProps(props: EffectPropsPartial) {\n this.id = props.id ?? this.id;\n this.type = props.type ?? this.type;\n this.isEnabled = props.isEnabled ?? this.isEnabled;\n this.isConfigActive = props.isConfigActive ?? this.isConfigActive;\n this.isJsonEditorActive = props.isJsonEditorActive ?? this.isJsonEditorActive;\n this.parameters = {\n ...this.parameters,\n ...validateEffectParameters(props.parameters, this._uiConfig)\n };\n if (Object.prototype.hasOwnProperty.call(props, 'animation')) {\n this.animation = validateEffectAnimation(props.animation, this._uiConfig);\n if (!this.animation) delete this.animation;\n }\n }\n\n isValidToSave() {\n return Boolean(this.type && this.id && this.deckEffect);\n }\n\n /**\n * Effect specific list of configurable parameters.\n * @returns All parameters are in preffered order.\n */\n getParameterDescriptions() {\n return this._uiConfig || [];\n }\n}\n\nexport default Effect;\n"],"mappings":";;;;;AAAA;AACA;;AAEA,SAAQA,wBAAwB,QAAO,kBAAkB;AACzD,SAAQC,cAAc,QAAO,yBAAyB;AAQtD,SACEC,mCAAmC,EACnCC,sBAAsB,EACtBC,uBAAuB,QAClB,sBAAsB;AAC7B,SAAQC,uBAAuB,QAAO,mBAAmB;AAEzD,WAAaC,MAAM;EAajB,SAAAA,OAAA,EAA4C;IAAA,IAAAC,qBAAA;IAAA,IAAhCC,KAAyB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IA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AO,IAAI,CAAC1B,SAAS,IAAI,EAAE;IAC7B;EAAC;AAAA;AAGH,eAAehB,MAAM","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
export { default as Effect } from './effect';
|
|
5
5
|
export { createEffect } from './utils';
|
|
6
|
+
export { getAnimatableEffectParameters, validateEffectAnimation } from './animation-utils';
|
|
6
7
|
export { DeckShadowCompositingEffect } from './shader-passes/shadow-compositing';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","Effect","createEffect","DeckShadowCompositingEffect"],"sources":["../../src/index.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nexport {default as Effect} from './effect';\nexport {createEffect} from './utils';\nexport {DeckShadowCompositingEffect} from './shader-passes/shadow-compositing';\n"],"mappings":"AAAA;AACA;;AAEA,SAAQA,OAAO,IAAIC,MAAM,QAAO,UAAU;AAC1C,SAAQC,YAAY,QAAO,SAAS;AACpC,SAAQC,2BAA2B,QAAO,oCAAoC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","Effect","createEffect","getAnimatableEffectParameters","validateEffectAnimation","DeckShadowCompositingEffect"],"sources":["../../src/index.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nexport {default as Effect} from './effect';\nexport {createEffect} from './utils';\nexport {getAnimatableEffectParameters, validateEffectAnimation} from './animation-utils';\nexport {DeckShadowCompositingEffect} from './shader-passes/shadow-compositing';\n"],"mappings":"AAAA;AACA;;AAEA,SAAQA,OAAO,IAAIC,MAAM,QAAO,UAAU;AAC1C,SAAQC,YAAY,QAAO,SAAS;AACpC,SAAQC,6BAA6B,EAAEC,uBAAuB,QAAO,mBAAmB;AACxF,SAAQC,2BAA2B,QAAO,oCAAoC","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kepler.gl/effects",
|
|
3
3
|
"author": "Shan He <shan@uber.com>",
|
|
4
|
-
"version": "3.3.0-alpha.
|
|
4
|
+
"version": "3.3.0-alpha.22",
|
|
5
5
|
"description": "kepler.gl viaual effects",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/cjs/index.js",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@deck.gl/core": "^9.4.1",
|
|
32
|
-
"@kepler.gl/common-utils": "3.3.0-alpha.
|
|
33
|
-
"@kepler.gl/constants": "3.3.0-alpha.
|
|
34
|
-
"@kepler.gl/types": "3.3.0-alpha.
|
|
35
|
-
"@kepler.gl/utils": "3.3.0-alpha.
|
|
32
|
+
"@kepler.gl/common-utils": "3.3.0-alpha.22",
|
|
33
|
+
"@kepler.gl/constants": "3.3.0-alpha.22",
|
|
34
|
+
"@kepler.gl/types": "3.3.0-alpha.22",
|
|
35
|
+
"@kepler.gl/utils": "3.3.0-alpha.22",
|
|
36
36
|
"@luma.gl/core": "^9.4.2",
|
|
37
37
|
"@luma.gl/effects": "^9.4.2",
|
|
38
38
|
"@luma.gl/engine": "^9.4.2",
|