Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
MAPSJS-2783: Address review comments.
Browse files Browse the repository at this point in the history
- Use explict list of texture property names for techniques.
- Add map property to fill technique so that technique can be used
for overlays in jsapi.

Signed-off-by: Andres Mandado <[email protected]>
  • Loading branch information
atomicsulfate committed Apr 22, 2021
1 parent 07d766d commit 9a1cec8
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
3 changes: 2 additions & 1 deletion @here/harp-datasource-protocol/lib/TechniqueDescriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ const fillTechniqueDescriptor = mergeTechniqueDescriptor<FillTechnique>(
color: { scope: AttrScope.TechniqueRendering, automatic: true },
opacity: { scope: AttrScope.TechniqueRendering, automatic: true },
transparent: { scope: AttrScope.TechniqueRendering, automatic: true },
lineWidth: AttrScope.TechniqueRendering
lineWidth: AttrScope.TechniqueRendering,
map: { scope: AttrScope.TechniqueRendering, automatic: true }
}
}
);
Expand Down
14 changes: 14 additions & 0 deletions @here/harp-datasource-protocol/lib/TechniqueParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,20 @@ export interface FillTechniqueParams extends BaseTechniqueParams, PolygonalTechn
* Width of the lines. Currently limited to the [0, 1] range.
*/
lineWidth?: DynamicProperty<number>;

/*
* URL or texture buffer that should be used as color map. See:
* https://threejs.org/docs/#api/en/materials/MeshBasicMaterial.map
*/
map?: DynamicProperty<string | TextureBuffer>;
mapProperties?: DynamicProperty<TextureProperties>;

/**
* Whether and how texture coordinates should be generated. No texture coordinates are
* generated if `undefined`.
* Should be set if a `map` is assigned.
*/
textureCoordinateType?: TextureCoordinateType;
}

/**
Expand Down
28 changes: 17 additions & 11 deletions @here/harp-datasource-protocol/lib/Techniques.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,21 +429,27 @@ export function needsVertexNormals(technique: Technique): boolean {
);
}

/**
* Type guard to check if an object is an instance of a technique with textures.
*/
export function supportsTextures(
technique: Technique
): technique is FillTechnique | StandardTechnique | ExtrudedPolygonTechnique | TerrainTechnique {
return (
isFillTechnique(technique) ||
isStandardTechnique(technique) ||
isExtrudedPolygonTechnique(technique) ||
isTerrainTechnique(technique)
);
}

/**
* Get the texture coordinate type if the technique supports it.
*/
export function textureCoordinateType(technique: Technique): TextureCoordinateType | undefined {
if (isStandardTechnique(technique)) {
return technique.textureCoordinateType;
} else if (isExtrudedPolygonTechnique(technique)) {
return technique.textureCoordinateType;
} else if (isTerrainTechnique(technique)) {
return technique.textureCoordinateType;
} else if (isShaderTechnique(technique)) {
return technique.textureCoordinateType;
} else {
return undefined;
}
return supportsTextures(technique) || isShaderTechnique(technique)
? technique.textureCoordinateType
: undefined;
}

/**
Expand Down
9 changes: 2 additions & 7 deletions @here/harp-mapview/lib/DecodedTileHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import {
isExtrudedLineTechnique,
isExtrudedPolygonTechnique,
isShaderTechnique,
isStandardTechnique,
isTerrainTechnique,
isTextureBuffer,
parseStringEncodedColor,
ShaderTechnique,
supportsTextures,
Technique,
TEXTURE_PROPERTY_KEYS,
TextureBuffer,
Expand Down Expand Up @@ -260,11 +259,7 @@ export function createMaterial(

material.depthTest = isExtrudedPolygonTechnique(technique) && technique.depthTest !== false;

if (
isStandardTechnique(technique) ||
isTerrainTechnique(technique) ||
isExtrudedPolygonTechnique(technique)
) {
if (supportsTextures(technique)) {
TEXTURE_PROPERTY_KEYS.forEach((texturePropertyName: string) =>
createTexture(material, texturePropertyName, options, textureReadyCallback)
);
Expand Down
10 changes: 8 additions & 2 deletions @here/harp-mapview/lib/MapMaterialAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ColorUtils, Expr, getPropertyValue, Value } from "@here/harp-datasource-protocol";
import {
ColorUtils,
Expr,
getPropertyValue,
TEXTURE_PROPERTY_KEYS,
Value
} from "@here/harp-datasource-protocol";
import { disableBlending, enableBlending, RawShaderMaterial } from "@here/harp-materials";
import * as THREE from "three";

Expand Down Expand Up @@ -36,7 +42,7 @@ export interface StyledProperties {
}

function isTextureProperty(propertyName: string): boolean {
return propertyName === "map" || propertyName.endsWith("Map");
return TEXTURE_PROPERTY_KEYS.includes(propertyName);
}

/**
Expand Down

0 comments on commit 9a1cec8

Please sign in to comment.