|
35 | 35 | shadows : true,
|
36 | 36 | shouldAnimate : true
|
37 | 37 | });
|
38 |
| -viewer.scene.globe.depthTestAgainstTerrain = true; |
| 38 | +var scene = viewer.scene; |
| 39 | +scene.globe.depthTestAgainstTerrain = true; |
39 | 40 |
|
40 | 41 | var longitude = -2.1480545852753163;
|
41 | 42 | var latitude = 0.7688240036937101;
|
|
49 | 50 | }
|
50 | 51 | });
|
51 | 52 |
|
| 53 | +viewer.trackedEntity = entity; |
| 54 | + |
52 | 55 | var point = viewer.entities.add({
|
53 |
| - position : new Cesium.CallbackProperty(updatePosition, false), |
54 | 56 | point : {
|
55 | 57 | pixelSize : 10,
|
56 | 58 | color : Cesium.Color.YELLOW,
|
|
70 | 72 | var objectsToExclude = [point];
|
71 | 73 | var cartographic = new Cesium.Cartographic();
|
72 | 74 |
|
73 |
| -function updatePosition(time, result) { |
| 75 | +if (scene.sampleHeightSupported) { |
| 76 | + scene.postRender.addEventListener(updatePosition); |
| 77 | +} else { |
| 78 | + console.log('This browser does not support sampleHeight.'); |
| 79 | +} |
| 80 | + |
| 81 | +function updatePosition(scene, time) { |
74 | 82 | var offset = (time.secondsOfDay % duration) / duration;
|
75 | 83 | cartographic.longitude = longitude - range + offset * range * 2.0;
|
76 | 84 | cartographic.latitude = latitude;
|
77 | 85 |
|
78 |
| - var height = viewer.scene.sampleHeight(cartographic, objectsToExclude); |
| 86 | + var height = scene.sampleHeight(cartographic, objectsToExclude); |
79 | 87 |
|
80 | 88 | if (Cesium.defined(height)) {
|
81 | 89 | cartographic.height = height;
|
|
86 | 94 | point.label.show = false;
|
87 | 95 | }
|
88 | 96 |
|
89 |
| - return Cesium.Cartographic.toCartesian(cartographic, Cesium.Ellipsoid.WGS84, result); |
| 97 | + point.position = Cesium.Cartographic.toCartesian(cartographic, Cesium.Ellipsoid.WGS84); |
90 | 98 | }
|
91 |
| -viewer.trackedEntity = entity; |
92 | 99 | //Sandcastle_End
|
93 | 100 | Sandcastle.finishedLoading();
|
94 | 101 | }
|
|
0 commit comments