diff --git a/src/Core/Style.js b/src/Core/Style.js index 1a3619cc1f..3b06c8162e 100644 --- a/src/Core/Style.js +++ b/src/Core/Style.js @@ -167,20 +167,22 @@ function defineStyleProperty(style, category, name, value, defaultValue) { * type of feature and what is needed (fill, stroke or draw a point, etc.) as well as where to get its * properties and its coordinates (for base_altitude). * - * @property {Coordinates} worldCoord @private Coordinates of the FeatureGeometry in world system. - * @property {Coordinates} localCoordinates @private Are the coordinates systeme origin local or global. - * @property {boolean} isProjected @private Are the coordinates already been projected. - * @property {FeatureGeometry} geometry @private - * @property {Object} globals Style type (fill, stroke, point, text and or icon) to consider. As - * well as the zoom. - * @property {Object} collection The FeatureCollection on which the FeatureGeomatry is attached - * @property {Coordinates} coordinates The coordinates (in world crs) of the last vertice set with + * @property {Object} globals Style type (fill, stroke, point, text and or icon) to consider it also + * contains the current zoom. + * @property {Object} collection The FeatureCollection to which the FeatureGeometry is attached + * @property {Coordinates} coordinates The coordinates (in world space) of the last vertice (x, y, z) set with * setLocalCoordinatesFromArray(). + * private properties: + * @property {Coordinates} worldCoord @private Coordinates object to store coordinates in world space. + * @property {Coordinates} localCoordinates @private Coordinates object to store coordinates in local space. + * @property {boolean} worldCoordsComputed @private Have the world coordinates already been computed + * from the local coordinates? + * @property {FeatureGeometry} geometry @private The FeatureGeometry to compute the style. */ export class StyleContext { #worldCoord = new Coordinates('EPSG:4326', 0, 0, 0); #localCoordinates = new Coordinates('EPSG:4326', 0, 0, 0); - #isProjected = true; + #worldCoordsComputed = true; #geometry = {}; /** * @constructor @@ -199,7 +201,7 @@ export class StyleContext { } setLocalCoordinatesFromArray(vertices, offset) { - this.#isProjected = false; + this.#worldCoordsComputed = false; return this.#localCoordinates.setFromArray(vertices, offset); } @@ -208,8 +210,8 @@ export class StyleContext { } get coordinates() { - if (!this.#isProjected) { - this.#isProjected = true; + if (!this.#worldCoordsComputed) { + this.#worldCoordsComputed = true; this.#worldCoord.copy(this.#localCoordinates).applyMatrix4(this.collection.matrixWorld); if (this.#localCoordinates.crs == 'EPSG:4978') { return this.#worldCoord.as('EPSG:4326', this.#worldCoord);