UNPKG

@vtx/cs-map

Version:

React components for Vortex

92 lines (89 loc) 5.02 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 ODLineLayer = /*#__PURE__*/function () { function ODLineLayer(viewer, linData) { _classCallCheck(this, ODLineLayer); if (!(0, _cesium.defined)(viewer)) { throw new _cesium.DeveloperError('viewer is required'); } this.viewer = viewer; this.primitive = null; this.loadLinesData(this.viewer, linData); } _createClass(ODLineLayer, [{ key: "loadLinesData", value: function loadLinesData(viewer, linData) { var busLines = []; // linData.forEach(i => { // // let points = [] // i.forEach(c => { // points.push(c[0], c[1]) // }); // // points.push(points[0], points[1]) // // busLines.push({ // positions: linData, // color: new Color(0.5, 0.6, 0.0, 1.0), // }); // }) busLines.push({ positions: linData, color: new _cesium.Color(0.5, 0.6, 0.0, 1.0) }); this.addLineDatas(busLines, viewer); } }, { key: "addLineDatas", value: function addLineDatas(busLines, viewer) { var _this = this; var scene = viewer.scene; busLines.forEach(function (line) { _this.primitive = new _cesium.Primitive({ geometryInstances: new _cesium.GeometryInstance({ geometry: new _cesium.PolylineGeometry({ positions: _cesium.Cartesian3.fromDegreesArray(line.positions), width: 5 }) }), appearance: new _cesium.PolylineMaterialAppearance({ material: new _cesium.Material({ fabric: { type: 'ODLineMaterial', uniforms: { color_0: line.color, colorImage: _cesium.Color.AQUA, totoalFrameCount_1: 400 }, source: "\n uniform float totoalFrameCount_1;\n uniform vec4 color_0;\n uniform vec4 colorImage;\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float t = mod(czm_frameNumber, totoalFrameCount_1) / totoalFrameCount_1;\n t *= 1.03;\n float alpha = smoothstep(t - 0.1, t, st.s) * step(-t, -st.s);\n alpha += 0.1;\n alpha *= step(-0.4, -abs(0.5-st.t));\n // material.diffuse = color_0.rgb;\n material.diffuse = (colorImage.rgb+color_0.rgb);\n material.alpha = alpha;\n return material;\n }\n " }, translucent: true }), faceForward: false, closed: false }) }); console.log(_this.primitive, 'this.primitive'); scene.primitives.add(_this.primitive); }); } }, { key: "destroy", value: function destroy() { this.primitive && this.viewer.scene.primitives.remove(this.primitive); } }]); return ODLineLayer; }(); var _default = exports["default"] = ODLineLayer; //# sourceMappingURL=ODLineLayer.js.map