Hi I’m stuck here. I need to keep track of my XYZ of the camera, and assign that information to a point later in the script. I found out that the coordinate system seems to change, but not on my point. I need the point to always stay in front of my camera, but when it starts with:
x: 7.654 y: 45.919 Z: 5183 and changes to: x: 852275.0892005145 y: 5767392.023641216 Z: 5223.5517142592, then I’m a little lost in what to do. I could use some help in getting it to keep the prober coordinates on the camera. Thanks.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>CameraTest</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/SceneView",
"esri/WebScene",
"esri/layers/GraphicsLayer",
"esri/Graphic",
"esri/core/watchUtils",
],
function(
Map, SceneView, WebScene, GraphicsLayer, Graphic,watchUtils
) {
var scene = new Map({
basemap: "streets",
ground: "world-elevation"
});
var view = new SceneView({
map: scene,
container: "viewDiv",
camera: {
position: [7.654, 45.919, 5183],
tilt: 80},
padding: {
top: 40
}
});
var graphicsLayer = new GraphicsLayer();
scene.add(graphicsLayer);
cameraX = view.camera.position.x
cameraY = view.camera.position.y
watchUtils.whenTrue(view, "stationary", function() {
var info = "<br> <span> the view center changed. </span> x: " +
view.camera.position.x + " y: " +
view.camera.position.y + " Z: " +
view.camera.position.z ;
displayMessage(info);
});
function displayMessage(info) {
outputMessages.innerHTML += info;
outputMessages.scrollTop = outputMessages.scrollHeight;
}
});
</script>
</head>
<body>
<div id="viewDiv">
<div id="outputMessages"></div>
<div id="titleDiv"></div>
</div>
</body>
</html>