UNPKG

@vtx/cs-map

Version:

React components for Vortex

87 lines (85 loc) 5.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _cesium = require("cesium"); 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); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } var LineFlowMaterialProperty = exports["default"] = /*#__PURE__*/function () { function LineFlowMaterialProperty(options) { _classCallCheck(this, LineFlowMaterialProperty); this._definitionChanged = new _cesium.Event(); this._color = undefined; this._speed = undefined; this._percent = undefined; this._gradient = undefined; this.color = options.color; this.speed = options.speed; this.percent = options.percent; this.gradient = options.gradient; } _createClass(LineFlowMaterialProperty, [{ key: "isConstant", get: function get() { return false; } }, { key: "definitionChanged", get: function get() { return this._definitionChanged; } }, { key: "getType", value: function getType() { return _cesium.Material.LineFlowMaterialType; } }, { key: "getValue", value: function getValue(time, result) { if (!(0, _cesium.defined)(result)) { result = {}; } result.color = _cesium.Property.getValueOrDefault(this._color, time, _cesium.Color.RED, result.color); result.speed = _cesium.Property.getValueOrDefault(this._speed, time, 5.0, result.speed); result.percent = _cesium.Property.getValueOrDefault(this._percent, time, 0.1, result.percent); result.gradient = _cesium.Property.getValueOrDefault(this._gradient, time, 0.01, result.gradient); return result; } }, { key: "equals", value: function equals(other) { return this === other || other instanceof LineFlowMaterialProperty && _cesium.Property.equals(this._color, other._color) && _cesium.Property.equals(this._speed, other._speed) && _cesium.Property.equals(this._percent, other._percent) && _cesium.Property.equals(this._gradient, other._gradient); } }]); return LineFlowMaterialProperty; }(); Object.defineProperties(LineFlowMaterialProperty.prototype, { color: (0, _cesium.createPropertyDescriptor)('color'), speed: (0, _cesium.createPropertyDescriptor)('speed'), percent: (0, _cesium.createPropertyDescriptor)('percent'), gradient: (0, _cesium.createPropertyDescriptor)('gradient') }); _cesium.Material.LineFlowMaterialProperty = 'LineFlowMaterialProperty'; _cesium.Material.LineFlowMaterialType = 'LineFlowMaterialType'; _cesium.Material.LineFlowMaterialSource = "\n uniform vec4 color;\n uniform float speed;\n uniform float percent;\n uniform float gradient;\n\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float t =fract(czm_frameNumber * speed / 1000.0);\n t *= (1.0 + percent);\n float alpha = smoothstep(t- percent, t, st.s) * step(-t, -st.s);\n alpha += gradient;\n material.diffuse = color.rgb;\n material.alpha = alpha;\n return material;\n }\n "; _cesium.Material._materialCache.addMaterial(_cesium.Material.LineFlowMaterialType, { fabric: { type: _cesium.Material.LineFlowMaterialType, uniforms: { color: new _cesium.Color(1.0, 0.0, 0.0, 1.0), speed: 10.0, percent: 0.1, gradient: 0.01 }, source: _cesium.Material.LineFlowMaterialSource }, translucent: function translucent() { return true; } }); //# sourceMappingURL=LineFlowMaterialProperty.js.map