Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (extrusionAnimationEnabled) {
extrudedObjects.push({
object: depthPassMesh,
materialFeature: true
});
}
setDepthPrePassStencil(depthPassMesh, object as THREE.Mesh);
}
this.registerTileObject(tile, object, technique.kind);
objects.push(object);
// Add the extruded building edges as a separate geometry.
if (isExtrudedPolygonTechnique(technique) && srcGeometry.edgeIndex !== undefined) {
const edgeGeometry = new THREE.BufferGeometry();
edgeGeometry.setAttribute("position", bufferGeometry.getAttribute("position"));
const colorAttribute = bufferGeometry.getAttribute("color");
if (colorAttribute !== undefined) {
edgeGeometry.setAttribute("color", colorAttribute);
}
const extrusionAttribute = bufferGeometry.getAttribute("extrusionAxis");
if (extrusionAttribute !== undefined) {
edgeGeometry.setAttribute("extrusionAxis", extrusionAttribute);
}
const normalAttribute = bufferGeometry.getAttribute("normal");
if (normalAttribute !== undefined) {
edgeGeometry.setAttribute("normal", normalAttribute);
private getTextureCoordinateType(technique: Technique): TextureCoordinateType | undefined {
// Set TileSpace coordinate type to generate texture coordinates for the displacement map
// used in elevation overlay.
if (
(isFillTechnique(technique) ||
isSolidLineTechnique(technique) ||
isExtrudedPolygonTechnique(technique)) &&
this.m_enableElevationOverlay
) {
return TextureCoordinateType.TileSpace;
}
return textureCoordinateType(technique);
}
private getPolygonFadingParams(
displayZoomLevel: number,
technique: FillTechnique | ExtrudedPolygonTechnique
): PolygonFadingParameters {
let color: string | number | undefined;
let colorMix = EdgeMaterial.DEFAULT_COLOR_MIX;
if (technique.lineColor !== undefined) {
color = getPropertyValue(technique.lineColor, displayZoomLevel);
if (isExtrudedPolygonTechnique(technique)) {
const extrudedPolygonTechnique = technique as ExtrudedPolygonTechnique;
colorMix =
extrudedPolygonTechnique.lineColorMix !== undefined
? extrudedPolygonTechnique.lineColorMix
: EdgeMaterial.DEFAULT_COLOR_MIX;
}
}
const fadeNear =
technique.fadeNear !== undefined
? getPropertyValue(technique.fadeNear, displayZoomLevel)
: FadingFeature.DEFAULT_FADE_NEAR;
const fadeFar =
technique.fadeFar !== undefined
? getPropertyValue(technique.fadeFar, displayZoomLevel)
: FadingFeature.DEFAULT_FADE_FAR;
groups
} = meshBuffers;
const featureStride = texCoordType !== undefined ? 4 : 2;
const vertexStride = featureStride + 2;
const isSpherical = this.m_decodeInfo.targetProjection.type === ProjectionType.Spherical;
const edgeWidth = isExtruded
? extrudedPolygonTechnique.lineWidth || 0.0
: isFilled
? fillTechnique.lineWidth || 0.0
: 0.0;
const hasEdges = edgeWidth > 0.0;
let color: THREE.Color | undefined;
if (isExtrudedPolygonTechnique(technique)) {
if (getOptionValue(technique.vertexColors, false)) {
let colorValue = evaluateTechniqueAttr(context, technique.color);
if (colorValue === undefined) {
const featureColor = context.env.lookup("color");
if (this.isColorStringValid(featureColor)) {
colorValue = String(featureColor);
}
}
if (colorValue === undefined) {
colorValue = evaluateTechniqueAttr(
context,
technique.defaultColor,
0x000000
);
}
const material = new Constructor(settings);
if (technique.id !== undefined) {
material.name = technique.id;
}
if (isExtrudedPolygonTechnique(technique)) {
material.flatShading = true;
}
material.depthTest = isExtrudedPolygonTechnique(technique) && technique.depthTest !== false;
if (
isStandardTechnique(technique) ||
isTerrainTechnique(technique) ||
isExtrudedPolygonTechnique(technique)
) {
TEXTURE_PROPERTY_KEYS.forEach((texturePropertyName: string) => {
const textureProperty = (technique as any)[texturePropertyName];
if (textureProperty === undefined) {
return;
}
const onLoad = (texture: THREE.Texture) => {
const properties = (technique as any)[
texturePropertyName + "Properties"
] as TextureProperties;
if (properties !== undefined) {
if (properties.wrapS !== undefined) {
texture.wrapS = toWrappingMode(properties.wrapS);
}
if (properties.wrapT !== undefined) {
if (technique === undefined) {
return;
}
const techniqueIndex = technique._index;
if (techniqueIndex === undefined) {
throw new Error(
"OmvDecodedTileEmitter#processPolygonFeature: " +
"Internal error - No technique index"
);
}
const polygons: Ring[][] = [];
const isExtruded = isExtrudedPolygonTechnique(technique);
const isFilled = isFillTechnique(technique);
const isPolygon = isExtruded || isFilled || isStandardTechnique(technique);
const computeTexCoords = this.getComputeTexCoordsFunc(technique);
const vertexStride = computeTexCoords !== undefined ? 4 : 2;
for (const polygon of geometry) {
const rings: Ring[] = [];
for (const outline of polygon.rings) {
const ringContour: number[] = [];
for (const coord of outline) {
ringContour.push(coord.x, coord.y);
if (computeTexCoords !== undefined) {
const { u, v } = computeTexCoords(coord, extents);