Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
): void {
const renderOrderOffset = evaluateTechniqueAttr(
context,
technique.renderOrderOffset,
0
);
let lineGroup: LineGroup;
const lineGroupGeometries = linesGeometry.find(aLine => {
return (
aLine.technique === techniqueIndex && aLine.renderOrderOffset === renderOrderOffset
);
});
const hasNormalsAndUvs = uvs !== undefined;
if (lineGroupGeometries === undefined) {
lineGroup = new LineGroup(hasNormalsAndUvs, undefined, lineType === LineType.Simple);
const aLine: LinesGeometry = {
type: lineType === LineType.Complex ? GeometryType.SolidLine : GeometryType.Line,
technique: techniqueIndex,
renderOrderOffset:
renderOrderOffset !== undefined ? Number(renderOrderOffset) : undefined,
lines: lineGroup
};
const techniqueTransient = evaluateTechniqueAttr(
context,
technique.transient,
false
);
if (!techniqueTransient && this.m_gatherFeatureAttributes) {
// if this technique is transient, do not save the featureIds with the geometry
aLine.objInfos = [featureAttributes];
private static createPolygonOutlineGeometry(
geometryData: GeometryData,
techniqueIndex: number,
tileWorldExtents: number
): Geometry {
const meshBuffer = new MeshBuffer();
const { indices, featureStarts, geojsonProperties } = meshBuffer;
let contour: number[];
const holesVertices: number[][] = [];
const solidOutline = new LineGroup();
const position = new Array();
for (const polygon of geometryData.polygons) {
contour = polygon.holes.length
? polygon.vertices.slice(0, polygon.holes[0] * 3)
: polygon.vertices;
// External ring.
this.addOutlineVertices(contour, tileWorldExtents, solidOutline, position);
// Holes, if any.
if (polygon.holes.length) {
for (let i = 0; i < polygon.holes.length; i++) {
if (i === polygon.holes.length - 1) {
holesVertices[i] = polygon.vertices.slice(polygon.holes[i] * 3);
} else {
const techniques = styleSetEvaluator.getMatchingTechniques(env);
const geoCenter = webMercatorTilingScheme.getGeoBox(tileKey).center;
const worldCenter = projection.projectPoint(geoCenter, new Vector3());
// Convert the input coordinates to local world coord coordinates (i.e. projected world
// coordinates relative to the tile center in world coordinates)
const worldPoints = this.convertToLocalWorldCoordinates(
data,
geoCenter,
projection,
worldCenter
);
// Create actual line-geometry out of the data.
const lineGroup = new LineGroup();
lineGroup.add(worldCenter, worldPoints);
for (const technique of techniques) {
geometries.push(this.createLineGeometry(lineGroup, technique._index));
}
}
private static createSolidLineGeometry(
geometryData: GeometryData,
techniqueIndex: number
): Geometry {
const lineCenter = new THREE.Vector3();
const lines = new LineGroup();
const positions = new Array();
for (const line of geometryData.lines.vertices) {
lines.add(lineCenter, line);
positions.push(...line);
}
return {
type: GeometryType.SolidLine,
index: {
buffer: new Uint32Array(lines.indices).buffer,
itemCount: 1,
type: "uint32",
name: "index"
},
interleavedVertexAttributes: [
get width(): number | undefined {
assert(this.checkSetUp(), "RoIndexedBufferedGeometryLineAccessor not setup");
if (this.geometryType === GeometryType.ExtrudedLine) {
const start = this.start + this.startCapSize;
const positionArray = this.position.array as Float32Array;
return reconstructLineWidth(positionArray, start);
}
return undefined;
}
localLines.forEach(aLine => {
triangulateLine(aLine, lineWidth, positions, indices, addCircle);
featureStarts.push(start);
objInfos.push(
this.m_gatherFeatureAttributes ? env.entries : getFeatureId(env.entries)
);
});