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

Commit

Permalink
HARP-14465: Fix label placement precision issues.
Browse files Browse the repository at this point in the history
POI and text positions, which use world coordinates (in contrast to tile coordinates used
by meshes), were being decoded into a single precision buffer, hence losing precision.

Signed-off-by: Andres Mandado <andres.mandado-almajano@here.com>
  • Loading branch information
atomicsulfate committed Mar 18, 2021
1 parent 2f287ed commit 62bc81c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 33 deletions.
7 changes: 1 addition & 6 deletions @here/harp-datasource-protocol/lib/DecodedTile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,11 @@ export interface TextGeometry {
* Structured clone compliant version of a `three.js` geometry object with points of interest (POIs)
* to be rendered. It is composed of buffers with metadata for POI objects.
*/
export interface PoiGeometry {
positions: BufferAttribute;
texts: number[];
export interface PoiGeometry extends TextGeometry {
/**
* Names of the image texture or the name of the POI as indices into the array `stringCatalog`.
*/
imageTextures?: number[];
technique?: number;
stringCatalog: Array<string | undefined>;
objInfos?: AttributeMap[];
// Angle in degrees from north clockwise specifying the directions the icons can be shifted.
offsetDirections?: number[];
}
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-mapview/lib/geometry/TileGeometryCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ export class TileGeometryCreator {
}

const positions = new THREE.BufferAttribute(
new Float32Array(text.positions.buffer),
new Float64Array(text.positions.buffer),
text.positions.itemCount
);

Expand Down
2 changes: 1 addition & 1 deletion @here/harp-mapview/lib/poi/PoiManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class PoiManager {
}

const positions = new THREE.BufferAttribute(
new Float32Array(poiGeometry.positions.buffer),
new Float64Array(poiGeometry.positions.buffer),
poiGeometry.positions.itemCount
);

Expand Down
41 changes: 16 additions & 25 deletions @here/harp-vectortile-datasource/lib/VectorTileDataEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ export class VectorTileDataEmitter {
positions: {
name: "position",
type: "float",
buffer: new Float32Array(aLine).buffer,
buffer: new Float64Array(aLine).buffer,
itemCount: 3
},
texts: [0],
Expand Down Expand Up @@ -1706,43 +1706,34 @@ export class VectorTileDataEmitter {
if (technique === undefined) {
return;
}

const positionElements = new Float32Array(meshBuffers.positions);

if (meshBuffers.texts.length > 0 && isTextTechnique(technique)) {
this.m_textGeometries.push({
if (meshBuffers.texts.length > 0) {
const geometry: TextGeometry = {
positions: {
name: "position",
type: "float",
buffer: positionElements.buffer as ArrayBuffer,
buffer: new Float64Array(meshBuffers.positions).buffer,
itemCount: 3
},
texts: meshBuffers.texts,
technique: techniqueIdx,
stringCatalog: meshBuffers.stringCatalog,
objInfos: meshBuffers.objInfos
});
return;
}
};

if (meshBuffers.texts.length > 0 && isPoiTechnique(technique)) {
this.m_poiGeometries.push({
positions: {
name: "position",
type: "float",
buffer: positionElements.buffer as ArrayBuffer,
itemCount: 3
},
texts: meshBuffers.texts,
technique: techniqueIdx,
stringCatalog: meshBuffers.stringCatalog,
imageTextures: meshBuffers.imageTextures,
objInfos: meshBuffers.objInfos,
offsetDirections: meshBuffers.offsetDirections
});
if (isTextTechnique(technique)) {
this.m_textGeometries.push(geometry);
} else {
assert(isPoiTechnique(technique));
const poiGeometry = geometry as PoiGeometry;
poiGeometry.imageTextures = meshBuffers.imageTextures;
poiGeometry.offsetDirections = meshBuffers.offsetDirections;
this.m_poiGeometries.push(poiGeometry);
}
return;
}

const positionElements = new Float32Array(meshBuffers.positions);

if (meshBuffers.groups.length === 0) {
// create a default group containing all the vertices in the position attribute.

Expand Down

0 comments on commit 62bc81c

Please sign in to comment.