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

MAPSJS: Support dynamic overlays using dynamic attributes. #2171

Merged
merged 6 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions @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 All @@ -256,7 +257,15 @@ const standardTechniqueDescriptor = mergeTechniqueDescriptor<StandardTechnique>(
emissive: { scope: AttrScope.TechniqueRendering, automatic: true },
emissiveIntensity: { scope: AttrScope.TechniqueRendering, automatic: true },
refractionRatio: { scope: AttrScope.TechniqueRendering, automatic: true },
normalMapType: { scope: AttrScope.TechniqueRendering, automatic: true }
normalMapType: { scope: AttrScope.TechniqueRendering, automatic: true },
map: { scope: AttrScope.TechniqueRendering, automatic: true },
normalMap: { scope: AttrScope.TechniqueRendering, automatic: true },
displacementMap: { scope: AttrScope.TechniqueRendering, automatic: true },
roughnessMap: { scope: AttrScope.TechniqueRendering, automatic: true },
emissiveMap: { scope: AttrScope.TechniqueRendering, automatic: true },
bumpMap: { scope: AttrScope.TechniqueRendering, automatic: true },
metalnessMap: { scope: AttrScope.TechniqueRendering, automatic: true },
alphaMap: { scope: AttrScope.TechniqueRendering, automatic: true }
}
}
);
Expand Down
48 changes: 31 additions & 17 deletions @here/harp-datasource-protocol/lib/TechniqueParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,58 +404,58 @@ export interface StandardTechniqueParams extends BaseTechniqueParams {
* URL or texture buffer that should be used as color map. See:
* https://threejs.org/docs/#api/en/materials/MeshStandardMaterial.map
*/
map?: string | TextureBuffer;
mapProperties?: TextureProperties;
map?: DynamicProperty<string | TextureBuffer>;
mapProperties?: DynamicProperty<TextureProperties>;

/**
* URL or texture buffer that should be used as normal map. See:
* https://threejs.org/docs/#api/en/materials/MeshStandardMaterial.normalMap
*/
normalMap?: string | TextureBuffer;
normalMapType?: number;
normalMapProperties?: TextureProperties;
normalMap?: DynamicProperty<string | TextureBuffer>;
normalMapType?: DynamicProperty<number>;
normalMapProperties?: DynamicProperty<TextureProperties>;

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

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

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

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

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

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

/**
Expand Down 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
Loading