Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit efe9c58

Browse files
committed
feat: deprecate Coordinates constructor with array and vector3
1 parent a3fb6c5 commit efe9c58

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

examples/jsm/OGC3DTilesHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function zoomToSphere(view, tile, sphere) {
4747
const distance = radius * Math.tan(fov * 2);
4848

4949
return {
50-
coord: new Coordinates('EPSG:4978', center),
50+
coord: new Coordinates('EPSG:4978').setFromVector3(center),
5151
range: distance + radius,
5252
};
5353
}

src/Controls/GlobeControls.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ class GlobeControls extends THREE.EventDispatcher {
755755
const range = this.getRange(point);
756756
if (point && range > this.minDistance) {
757757
return this.lookAtCoordinate({
758-
coord: new Coordinates('EPSG:4978', point),
758+
coord: new Coordinates('EPSG:4978').setFromVector3(point),
759759
range: range * (event.direction === 'out' ? 1 / 0.6 : 0.6),
760760
time: 1500,
761761
});
@@ -1028,7 +1028,9 @@ class GlobeControls extends THREE.EventDispatcher {
10281028
*/
10291029

10301030
getCameraCoordinate() {
1031-
return new Coordinates('EPSG:4978', this.camera.position).as('EPSG:4326');
1031+
return new Coordinates('EPSG:4978')
1032+
.setFromVector3(this.camera.position)
1033+
.as('EPSG:4326');
10321034
}
10331035

10341036
/**
@@ -1216,7 +1218,9 @@ class GlobeControls extends THREE.EventDispatcher {
12161218
return;
12171219
}
12181220

1219-
return new Coordinates('EPSG:4978', pickedPosition).as('EPSG:4326');
1221+
return new Coordinates('EPSG:4978')
1222+
.setFromVector3(pickedPosition)
1223+
.as('EPSG:4326');
12201224
}
12211225
}
12221226

src/Core/Geographic/Coordinates.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,16 @@ class Coordinates {
8686
this._normal = new THREE.Vector3();
8787

8888
if (v0.length > 0) {
89+
console.warn(
90+
'Deprecated Coordinates#constructor(string, number[]),',
91+
'use new Coordinates(string).setFromArray(number[]) instead.',
92+
);
8993
this.setFromArray(v0);
9094
} else if (v0.isVector3 || v0.isCoordinates) {
95+
console.warn(
96+
'Deprecated Coordinates#constructor(string, Vector3),',
97+
'use new Coordinates(string).setFromVector3(Vector3) instead.',
98+
);
9199
this.setFromVector3(v0);
92100
} else {
93101
this.setFromValues(v0, v1, v2);
@@ -103,6 +111,7 @@ class Coordinates {
103111
setCrs(crs) {
104112
CRS.isValid(crs);
105113
this.crs = crs;
114+
return this;
106115
}
107116

108117
/**

src/Renderer/Camera.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ class Camera {
188188
* @return {Coordinates} Coordinates object holding camera's position.
189189
*/
190190
position(crs) {
191-
return new Coordinates(this.crs, this.camera3D.position).as(crs || this.crs);
191+
return new Coordinates(this.crs)
192+
.setFromVector3(this.camera3D.position)
193+
.as(crs || this.crs);
192194
}
193195

194196
/**

src/Utils/CameraUtils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ class CameraRig extends THREE.Object3D {
154154

155155
// set rig's objects transformation from camera's position and target's position
156156
setFromPositions(view, cameraPosition) {
157-
this.setTargetFromCoordinate(view, new Coordinates(view.referenceCrs, targetPosition));
157+
this.setTargetFromCoordinate(
158+
view,
159+
new Coordinates(view.referenceCrs).setFromVector3(targetPosition),
160+
);
158161
this.target.rotation.set(0, 0, 0);
159162
this.updateMatrixWorld(true);
160163
this.camera.position.copy(cameraPosition);

utils/debug/Debug.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ function Debug(view, datDebugTool, chartDivContainer) {
177177
const size = { x: g.width * ratio, y: g.height * ratio };
178178
debugCamera.aspect = size.x / size.y;
179179
const camera = view.camera3D;
180-
const coord = new Coordinates(view.referenceCrs, camera.position).as(tileLayer.extent.crs);
180+
const coord = new Coordinates(view.referenceCrs)
181+
.setFromVector3(camera.position)
182+
.as(tileLayer.extent.crs);
181183
const extent = view.tileLayer.info.displayed.extent;
182184
displayedTilesObb.setFromExtent(extent);
183185
displayedTilesObbHelper.visible = true;

0 commit comments

Comments
 (0)