Skip to content

Commit

Permalink
Merge pull request #12156 from jvrjsanchez/main
Browse files Browse the repository at this point in the history
Deprecation Updates for SceneTransforms Methods
  • Loading branch information
ggetz committed Aug 30, 2024
2 parents 8a6ae92 + 393fb39 commit 1669679
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Star Burst.html
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@

// Remove the star burst if the mouse exits the screen space circle.
// If the mouse is inside the circle, show the label of the billboard the mouse is hovering over.
const screenPosition = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
const screenPosition = Cesium.SceneTransforms.worldToWindowCoordinates(
scene,
starBurstState.center
);
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

##### Breaking Changes :mega:

- `SceneTransforms.wgs84ToWindowCoordinates` has been removed. Use `SceneTransforms.worldToWindowCoordinates` instead.
- `SceneTransforms.wgs84ToDrawingBufferCoordinates` has been removed. Use `SceneTransforms.worldToDrawingBufferCoordinates` instead.

- Removed `jitter` option from `VoxelPrimitive.js`, `VoxelRenderResources.js`, and related test code in `VoxelPrimitiveSpec.js`. [#11913](https://github.com/CesiumGS/cesium/issues/11913)

- Custom specular environment maps in `ImageBasedLighting` now require either a WebGL2 context or a WebGL1 context that supports the [`EXT_shader_texture_lod` extension](https://registry.khronos.org/webgl/extensions/EXT_shader_texture_lod/).
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Levi Montgomery](https://github.com/Levi-Montgomery)
- [Brandon Berisford](https://github.com/BeyondBelief96)
- [Adam Wirth](https://https://github.com/adamwirth)
- [Javier Sanchez](https://github.com/jvrjsanchez)
62 changes: 0 additions & 62 deletions packages/engine/Source/Scene/SceneTransforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Cartesian3 from "../Core/Cartesian3.js";
import Cartesian4 from "../Core/Cartesian4.js";
import Cartographic from "../Core/Cartographic.js";
import defined from "../Core/defined.js";
import deprecationWarning from "../Core/deprecationWarning.js";
import DeveloperError from "../Core/DeveloperError.js";
import CesiumMath from "../Core/Math.js";
import Matrix4 from "../Core/Matrix4.js";
Expand Down Expand Up @@ -53,33 +52,6 @@ SceneTransforms.worldToWindowCoordinates = function (scene, position, result) {
);
};

/**
* Transforms a position in WGS84 coordinates to window coordinates. This is commonly used to place an
* HTML element at the same screen position as an object in the scene.
*
* @param {Scene} scene The scene.
* @param {Cartesian3} position The position in WGS84 (world) coordinates.
* @param {Cartesian2} [result] An optional object to return the input position transformed to window coordinates.
* @returns {Cartesian2|undefined} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
*
* @example
* // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
* const scene = widget.scene;
* const ellipsoid = scene.ellipsoid;
* const position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
* const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
* handler.setInputAction(function(movement) {
* console.log(Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position));
* }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
*/
SceneTransforms.wgs84ToWindowCoordinates = function (scene, position, result) {
deprecationWarning(
"SceneTransforms.wgs84ToWindowCoordinates",
"SceneTransforms.wgs84ToWindowCoordinates has been deprecated. It will be removed in 1.21. Use SceneTransforms.worldToWindowCoordinates instead."
);
return SceneTransforms.worldToWindowCoordinates(scene, position, result);
};

const scratchCartesian4 = new Cartesian4();
const scratchEyeOffset = new Cartesian3();

Expand Down Expand Up @@ -320,40 +292,6 @@ SceneTransforms.worldToDrawingBufferCoordinates = function (
return SceneTransforms.transformWindowToDrawingBuffer(scene, result, result);
};

/**
* Transforms a position in world coordinates to drawing buffer coordinates. This may produce different
* results from SceneTransforms.wgs84ToWindowCoordinates when the browser zoom is not 100%, or on high-DPI displays.
*
* @param {Scene} scene The scene.
* @param {Cartesian3} position The position in world (WGS84 or alternative ellipsoid) coordinates.
* @param {Cartesian2} [result] An optional object to return the input position transformed to window coordinates.
* @returns {Cartesian2|undefined} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
*
* @example
* // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
* const position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
* const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
* handler.setInputAction(function(movement) {
* console.log(Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position));
* }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
*/
SceneTransforms.wgs84ToDrawingBufferCoordinates = function (
scene,
position,
result
) {
deprecationWarning(
"SceneTransforms.wgs84ToDrawingBufferCoordinates",
"SceneTransforms.wgs84ToDrawingBufferCoordinates has been deprecated. It will be removed in 1.21. Use SceneTransforms.worldToDrawingBufferCoordinates instead."
);

return SceneTransforms.worldToDrawingBufferCoordinates(
scene,
position,
result
);
};

const projectedPosition = new Cartesian3();
const positionInCartographic = new Cartographic();

Expand Down
28 changes: 14 additions & 14 deletions packages/engine/Specs/Scene/SceneTransformsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ describe(
it("throws an exception without scene", function () {
const position = Cartesian3.fromDegrees(0.0, 0.0);
expect(function () {
SceneTransforms.wgs84ToWindowCoordinates(undefined, position);
SceneTransforms.worldToWindowCoordinates(undefined, position);
}).toThrowDeveloperError();
});

it("throws an exception without position", function () {
expect(function () {
SceneTransforms.wgs84ToWindowCoordinates(scene);
SceneTransforms.worldToWindowCoordinates(scene);
}).toThrowDeveloperError();
});

Expand All @@ -61,7 +61,7 @@ describe(
// Update scene state
scene.renderForSpecs();

const windowCoordinates = SceneTransforms.wgs84ToWindowCoordinates(
const windowCoordinates = SceneTransforms.worldToWindowCoordinates(
scene,
position
);
Expand All @@ -80,7 +80,7 @@ describe(
// Update scene state
scene.renderForSpecs();

const drawingBufferCoordinates = SceneTransforms.wgs84ToDrawingBufferCoordinates(
const drawingBufferCoordinates = SceneTransforms.worldToDrawingBufferCoordinates(
scene,
position
);
Expand All @@ -105,7 +105,7 @@ describe(
// Update scene state
scene.renderForSpecs();

const windowCoordinates = SceneTransforms.wgs84ToWindowCoordinates(
const windowCoordinates = SceneTransforms.worldToWindowCoordinates(
scene,
position
);
Expand All @@ -123,7 +123,7 @@ describe(
// Update scene state
scene.renderForSpecs();

const drawingBufferCoordinates = SceneTransforms.wgs84ToDrawingBufferCoordinates(
const drawingBufferCoordinates = SceneTransforms.worldToDrawingBufferCoordinates(
scene,
position
);
Expand All @@ -138,7 +138,7 @@ describe(
const actualWindowCoordinates = new Cartesian2(0.5, 0.5);
const position = scene.camera.pickEllipsoid(actualWindowCoordinates);

const windowCoordinates = SceneTransforms.wgs84ToWindowCoordinates(
const windowCoordinates = SceneTransforms.worldToWindowCoordinates(
scene,
position
);
Expand All @@ -158,7 +158,7 @@ describe(
actualDrawingBufferCoordinates
);

const drawingBufferCoordinates = SceneTransforms.wgs84ToDrawingBufferCoordinates(
const drawingBufferCoordinates = SceneTransforms.worldToDrawingBufferCoordinates(
scene,
position
);
Expand All @@ -182,7 +182,7 @@ describe(
scene.camera.direction
);

const windowCoordinates = SceneTransforms.wgs84ToWindowCoordinates(
const windowCoordinates = SceneTransforms.worldToWindowCoordinates(
scene,
position
);
Expand All @@ -203,7 +203,7 @@ describe(
scene.camera.direction
);

const drawingBufferCoordinates = SceneTransforms.wgs84ToDrawingBufferCoordinates(
const drawingBufferCoordinates = SceneTransforms.worldToDrawingBufferCoordinates(
scene,
position
);
Expand All @@ -225,7 +225,7 @@ describe(
scene.renderForSpecs();

const position = Cartesian3.fromDegrees(0, 0);
const windowCoordinates = SceneTransforms.wgs84ToWindowCoordinates(
const windowCoordinates = SceneTransforms.worldToWindowCoordinates(
scene,
position
);
Expand Down Expand Up @@ -256,7 +256,7 @@ describe(
});

const position = Cartesian3.fromDegrees(0, 0);
const windowCoordinates = SceneTransforms.wgs84ToWindowCoordinates(
const windowCoordinates = SceneTransforms.worldToWindowCoordinates(
scene,
position
);
Expand All @@ -283,7 +283,7 @@ describe(
scene.renderForSpecs();

const position = Cartesian3.fromDegrees(0, 0);
const drawingBufferCoordinates = SceneTransforms.wgs84ToDrawingBufferCoordinates(
const drawingBufferCoordinates = SceneTransforms.worldToDrawingBufferCoordinates(
scene,
position
);
Expand All @@ -306,7 +306,7 @@ describe(
scene.renderForSpecs();

const position = Cartesian3.fromDegrees(-80, 25);
const windowCoordinates = SceneTransforms.wgs84ToWindowCoordinates(
const windowCoordinates = SceneTransforms.worldToWindowCoordinates(
scene,
position
);
Expand Down

0 comments on commit 1669679

Please sign in to comment.