Plugin for automatically re-orienting and re-centering the tileset to make it visible
near the origin and facing the right direction. If lat/lon are provided the
tileset is placed at that geographic location; otherwise the plugin tries to determine
if the tileset is on the globe surface and estimates the coordinates. If no coordinates
can be determined the tileset is oriented so the given up axis aligns to three.js' +Y.
import { TilesRenderer } from '3d-tiles-renderer/three';
import { ReorientationPlugin } from '3d-tiles-renderer/three/plugins';
// scene, camera and renderer are initialized here
const URL = 'https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize_tileset.json';
const tiles = new TilesRenderer( URL );
// this dataset is stored -Z up
tiles.registerPlugin( new ReorientationPlugin( { up: '-z' } ) );
tiles.setCamera( camera );
tiles.setResolutionFromRenderer( camera, renderer );
scene.add( tiles.group );
camera.position.set( 20, 10, 20 );
renderer.setAnimationLoop( () => {
camera.updateMatrixWorld();
tiles.update();
renderer.render( scene, camera );
} );On this page
Methods
new ReorientationPlugin(
options?: {
// Latitude in radians of the surface point to orient to (requires `lon`).
lat: number | null = null,
// Longitude in radians of the surface point to orient to (requires `lat`).
lon: number | null = null,
// Height in metres above the ellipsoid surface.
height: number = 0,
// Axis to orient toward three.js +Y when no lat/lon is available. Valid values are `±x`, `±y`, `±z`.
up: string = '+z',
// Whether to reposition the tileset to the origin.
recenter: boolean = true,
// Azimuth rotation in radians.
azimuth: number = 0,
// Elevation rotation in radians.
elevation: number = 0,
// Roll rotation in radians.
roll: number = 0
}
)transformLatLonHeightToOrigin(
// Latitude in radians.
lat: number,
// Longitude in radians.
lon: number,
// Height in metres above the ellipsoid surface.
height: number = 0,
// Azimuth rotation in radians.
azimuth: number = 0,
// Elevation rotation in radians.
elevation: number = 0,
// Roll rotation in radians.
roll: number = 0
): voidCenters the tileset such that the given coordinates are positioned at the origin with X facing west and Z facing north.