Display stars and the moon¶
Sample for adding stars and the moon in the space
sun_moon_star.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Display stars and the moon</title>
<meta property="og:description" content="Sample for adding stars and the moon in the space" />
<script src="./v0.10.1/mapray.min.js"></script>
<script src="./v0.10.1/maprayui.min.js"></script>
<link rel="stylesheet" href="./v0.10.1/mapray.css">
<style>
body {margin: 0; padding: 0;}
html, body, div#mapray-container { height: 100%; }
</style>
</head>
<body>
<div id="mapray-container"></div>
</body>
</html>
<script>
const cloudApi = new mapray.cloud.CloudApiV2({
tokenType: mapray.cloud.CloudApi.TokenType.ACCESS_TOKEN,
token: "<YOUR_MAPRAY_ACCESS_TOKEN>"
});
const uiviewer = new maprayui.StandardUIViewer( "mapray-container", {
dem_provider: new mapray.StandardDemProvider( cloudApi.getDefaultDemAsResource() ),
atmosphere: new mapray.Atmosphere(),
sun_visualizer: new mapray.SunVisualizer( 32 ),
moon_visualizer: new mapray.MoonVisualizer( 'https://resource.mapray.com/assets/images/moon.jpg' ),
star_visualizer: new mapray.StarVisualizer( 'https://resource.mapray.com/assets/data/star75.json', 'https://resource.mapray.com/assets/images/starmap_512n2.jpg' ),
} );
uiviewer.setCameraPosition({
longitude: 142.0,
latitude: 20.0,
height: 2500000
});
uiviewer.setLookAtPosition({
longitude: 137.65906432922944,
latitude: 36.294572127536995,
height: 1200000
});
// The positions of the Sun and the Moon can be specified in the GOCS coordinate system.
const sun_xy_degree = 135.0;
const sun_z_degree = 36.0;
uiviewer.viewer.sun.setSunDirection( [ Math.cos(Math.PI/180.0 * sun_xy_degree), Math.sin(Math.PI/180.0 * sun_xy_degree), Math.sin(Math.PI/180.0 * sun_z_degree) ] );
const moon_xy_degree = -45.0;
const moon_z_degree = 36.0;
uiviewer.viewer.moon.setMoonDirection( [ Math.cos(Math.PI/180.0 * moon_xy_degree), Math.sin(Math.PI/180.0 * moon_xy_degree), Math.sin(Math.PI/180.0 * moon_z_degree) ] );
uiviewer.viewer.moonVisualizer.setRadius(5);
</script>
Info
このサンプルコードは、<YOUR_MAPRAY_ACCESS_TOKEN>を、あなたのMapray CloudアカウントのOrganization Tokenに置き換えるまで、期待通りに動作しません。