Class: SceneTransforms

SceneTransforms

new SceneTransforms()

A function that performs scene transformations between coordinate systems related to rendering.

Methods

static convert2DToCartesian(scene, position){Cartesian3}

Convert non backprojected Cartesian coordinates to backprojected Cartesian coordinates.

Name Type Description
scene scene

The parameter scene is a scene object.

position position

The plane coordinates to be back projected.

Returns:
Type Description
Cartesian3 Cartesian3

static wgs84ToDrawingBufferCoordinates(scene, position, result){Cartesian2}

Convert the position in WGS84 coordinates to drawing buffer coordinates. When the browser zoom is not 100% or on a high-resolution display, this may result in different results than SceneTransforms.wgs84ToWindow Coordinates.

Name Type Description
scene Scene

Scene.

position Cartesian3

The location represented by WGS84 (geographic) coordinates.

result Cartesian2 optional

Optional object, used to return the input position converted to window coordinates.

Returns:
Type Description
Cartesian2 The modified result parameters, or a new Cartesian2 instance (if not provided). If the input position is close to the center of the ellipsoid, it may not be possible to define.
Example
// Output the window position of longitude/latitude (0, 0) every time the mouse moves.
var scene = widget.scene;
var ellipsoid = scene.globe.ellipsoid;
var position = SuperMap3D.Cartesian3.fromDegrees(0.0, 0.0);
var handler = new SuperMap3D.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
    console.log(SuperMap3D.SceneTransforms.wgs84ToWindowCoordinates(scene, position));
}, SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE);

static wgs84ToWindowCoordinates(scene, position, result){Cartesian2}

Convert the position in WGS84 coordinates to window coordinates. This is typically used to place HTML elements in the same screen position as objects in the scene.

Name Type Description
scene Scene

Scene.

position Cartesian3

The location represented by WGS84 (geographic) coordinates.

result Cartesian2 optional

Optional object, used to return the input position converted to window coordinates.

Returns:
Type Description
Cartesian2 The modified result parameters, or a new Cartesian2 instance (if not provided). If the input position is close to the center of the ellipsoid, it may not be possible to define.
Example
// Output the window position of longitude/latitude (0, 0) every time the mouse moves.
var scene = widget.scene;
var ellipsoid = scene.globe.ellipsoid;
var position = SuperMap3D.Cartesian3.fromDegrees(0.0, 0.0);
var handler = new SuperMap3D.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
    console.log(SuperMap3D.SceneTransforms.wgs84ToWindowCoordinates(scene, position));
}, SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE);