Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function extrudePolygons(d) {
const { data, height } = d;
const { position, normal, uv, indices } = extrudePolygon(
// polygons same with coordinates of MultiPolygon type geometry in GeoJSON
// See http://wiki.geojson.org/GeoJSON_draft_version_6#MultiPolygon
data,
// Options of extrude
{
// Can be a constant value, or a function.
// Default to be 1.
depth: height
}
);
return { position, normal, uv, indices };
}
}
polylines.push(polyline);
}
this._maskOutlinePoints = new Float32Array(maskOutlinePoints);
if (!(config.outlineHeight > 0 && config.outlineThickness > 0)) {
this._rootNode.remove(this._outlineMesh);
this._advancedRenderer.render();
return;
}
this._rootNode.add(this._outlineMesh);
let {indices, position, normal, uv} = extrudePolyline(polylines, {
// TODO Configuration
lineWidth: config.outlineThickness, depth: config.outlineHeight,
smoothSide: true
});
if (this._outlineMesh.geometry) {
this._outlineMesh.geometry.dispose(this._renderer);
}
let geo = this._outlineMesh.geometry = new Geometry();
geo.attributes.position.value = position;
geo.attributes.normal.value = normal;
geo.attributes.texcoord0.value = uv;
geo.indices = indices;
geo.generateTangents();
geo.updateBoundingBox();
geo.dirty();
export function getExtrudeGeometryParams(polygon, height, layer, center) {
const datas = getPolygonPositions(polygon, layer, center);
const shapes = datas;
//Possible later use of geojson
if (!shapes) return null;
height = layer.distanceToVector3(height, height).x;
const { position, normal, uv, indices } = extrudePolygon(shapes, {
depth: height
});
return {
position, normal, uv, indices
};
}
export function getExtrudeLineGeometry(lineString, lineWidth = 1, depth = 1, layer, center) {
const positions = getLinePosition(lineString, layer, center).positionsV;
const ps = [];
for (let i = 0, len = positions.length; i < len; i++) {
const p = positions[i];
ps.push([p.x, p.y]);
}
const {
indices,
position,
normal
} = extrudePolyline([ps], {
lineWidth,
depth
});
const geometry = new THREE.BufferGeometry();
addAttribute(geometry, 'position', new THREE.Float32BufferAttribute(position, 3));
addAttribute(geometry, 'normal', new THREE.Float32BufferAttribute(normal, 3));
geometry.setIndex(new THREE.Uint32BufferAttribute(indices, 1));
return geometry;
}
export function getExtrudeLineParams(lineString, lineWidth = 1, depth = 1, layer, center) {
const positions = getLinePosition(lineString, layer, center).positionsV;
const ps = [];
for (let i = 0, len = positions.length; i < len; i++) {
const p = positions[i];
ps.push([p.x, p.y]);
}
const {
indices,
position,
normal
} = extrudePolyline([ps], {
lineWidth: lineWidth,
depth: depth
});
return {
position: position,
normal: normal,
indices: indices
};
}