4, cesium initialization position

cesium position initialization

cesium initialization position, that is, when you first load the 3d page, the camera is pointing (or some other place need to be initialized.)

Man of few words said, directly on the case, do not understand, please add the following study group to discuss together.

1     viewer.scene.camera.flyTo({
2         destination: new Cesium.Cartesian3.fromDegrees(118.16029, 30.15988, 29600.209),
3         orientation: {
4             heading: Cesium.Math.toRadians(0),
5             pitch: Cesium.Math.toRadians(-90),
6             roll: Cesium.Math.toRadians(0)
7         },
8         duration: 3.0
9     })

Flyto which is a method you fly to a certain location.

118.16029, 30.15988, 29600.209 number three are your longitude, latitude location as well as elevation.
heading: Cesium.Math.toRadians (0), 
Pitch: Cesium.Math.toRadians (-90), 
roll: Cesium.Math.toRadians (0) Look at the following document explains:
duration: 3.0 What this means is that you fly to this location used time is 3 seconds. 


Incidental conversion method
  // latitude and longitude coordinates of the current model is assumed as {114, 30, 1000} azimuth {heading: 30, pitch: 20 , roll: 10} are calculated angle 
 2 // 1. The matrix computing world coordinates, azimuth 
 3 Cesium.Cartesian3.fromDegrees position = var (114, 30, 1000); 
 . 4 Cesium.Math.toRadians var = heading (30); 
 . 5 Pitch = var Cesium.Math.toRadians (20 is); 
 . 6 var = Cesium.Math roll. toRadians (10); 
 . 7 = var headingPitchRoll new new Cesium.HeadingPitchRoll (heading, Pitch, roll); 
 . 8   
 . 9 var m = Cesium.Transforms.headingPitchRollToFixedFrame (position, headingPitchRoll, Cesium.Ellipsoid.WGS84, Cesium.Transforms.eastNorthUpToFixedFrame, new new Cesium .Matrix4 ()); 
10 the console.log (m); 
. 11   
12 is required azimuth // 2. The matrix
// 13 obtained above we do testing m matrix 
24 // angle obtained
A transformation matrix calculation at the center of 14 @ 
15 = var M1 Cesium.Transforms.eastNorthUpToFixedFrame (Cesium.Matrix4.getTranslation (m, new new Cesium.Cartesian3 ()), Cesium.Ellipsoid.WGS84, new new Cesium.Matrix4 ()); 
16 // matrix division 
. 17 M3 = var Cesium.Matrix4.multiply (Cesium.Matrix4.inverse (M1, new new Cesium.Matrix4 ()), m, new new Cesium.Matrix4 ()); 
18 is a rotation matrix to obtain // 
19 var mat3 Cesium.Matrix4.getRotation = (M3, new new Cesium.Matrix3 ()); 
20 is computing the quaternion // 
21 is Q = var Cesium.Quaternion.fromRotationMatrix (MAT3); 
22 is // calculated rotation angle (radian) 
23 is HPR = var Cesium.HeadingPitchRoll.fromQuaternion (Q); 
25 = var heading Cesium.Math.toDegrees (hpr.heading);
26         var pitch = Cesium.Math.toDegrees(hpr.pitch);
27         var roll = Cesium.Math.toDegrees(hpr.roll);
28         console.log('heading : ' + heading, 'pitch : ' + pitch, 'roll : ' + roll);
Related study group: 854 184 700; there are issues could be discussed together.

Guess you like

Origin www.cnblogs.com/yaosusu/p/11482282.html