1 line
38 KiB
Plaintext
1 line
38 KiB
Plaintext
|
{"version":3,"file":"createPolylineGeometry.js","sources":["../../../../Source/Core/PolylineGeometry.js","../../../../Source/WorkersES6/createPolylineGeometry.js"],"sourcesContent":["import ArcType from \"./ArcType.js\";\nimport arrayRemoveDuplicates from \"./arrayRemoveDuplicates.js\";\nimport BoundingSphere from \"./BoundingSphere.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport Color from \"./Color.js\";\nimport ComponentDatatype from \"./ComponentDatatype.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport Ellipsoid from \"./Ellipsoid.js\";\nimport Geometry from \"./Geometry.js\";\nimport GeometryAttribute from \"./GeometryAttribute.js\";\nimport GeometryAttributes from \"./GeometryAttributes.js\";\nimport GeometryType from \"./GeometryType.js\";\nimport IndexDatatype from \"./IndexDatatype.js\";\nimport CesiumMath from \"./Math.js\";\nimport PolylinePipeline from \"./PolylinePipeline.js\";\nimport PrimitiveType from \"./PrimitiveType.js\";\nimport VertexFormat from \"./VertexFormat.js\";\n\nconst scratchInterpolateColorsArray = [];\n\nfunction interpolateColors(p0, p1, color0, color1, numPoints) {\n const colors = scratchInterpolateColorsArray;\n colors.length = numPoints;\n let i;\n\n const r0 = color0.red;\n const g0 = color0.green;\n const b0 = color0.blue;\n const a0 = color0.alpha;\n\n const r1 = color1.red;\n const g1 = color1.green;\n const b1 = color1.blue;\n const a1 = color1.alpha;\n\n if (Color.equals(color0, color1)) {\n for (i = 0; i < numPoints; i++) {\n colors[i] = Color.clone(color0);\n }\n return colors;\n }\n\n const redPerVertex = (r1 - r0) / numPoints;\n const greenPerVertex = (g1 - g0) / numPoints;\n const bluePerVertex = (b1 - b0) / numPoints;\n const alphaPerVertex = (a1 - a0) / numPoints;\n\n for (i = 0; i < numPoints; i++) {\n colors[i] = new Color(\n r0 + i * redPerVertex,\n g0 + i * greenPerVertex,\n b0 + i * bluePerVertex,\n a0 + i * alphaPerVertex\n );\n }\n\n return colors;\n}\n\n/**\n * A description of a polyline modeled as a line strip; the first two positions define a line segment,\n * and each additional position defines a line segment from the previous position. The polyline is capable of\n * displaying with a material.\n *\n * @alias PolylineGeometry\n * @constructor\n *\n * @param {Object} options Object with the following properties:\n * @param {Cartesian3[]} options.positions An array of {@link Cartesian3} defining the positions in the polyline as a line strip.\n * @param {Number} [options.width=1.0] The width in pixels.\n * @param {Color[]} [options.colors] An Array of {@link Color} defining the per vertex or per segment colors.\n * @param {Boolean} [options.colorsPerVertex=false] A boolean that determines whether the colors will be flat across each segment of the line or interpolated across the vertices.\n * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polyline segments must follow.\n * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.arcType is not ArcType.NONE. Determines the number of positions in the buffer.\n * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.\n * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference.\n *\n * @exception {DeveloperError} At least two positions are required.\n * @exception {DeveloperError} width must be greater than or equal to one.\n * @exception {DeveloperError} colors has an invalid length.\n *\n * @see PolylineGeometry#createGeometry\n *\n * @demo {@link https://sandcastle.cesium.com/index.html?src=Polyline.html|Cesium Sandcastle Polyline Demo}\n *\n * @example\n * // A polyline with two connected line segments\n * const polyline = new Cesium.PolylineGeometry({\n * positions : Cesium.Cartesian3.fromDegreesArray([\n * 0.0, 0.0,\n * 5.0, 0.0,\n
|