Hi,
I want some suggestion related to auto rotation in VR mode. i include terrain provider and when i go into VR mode, after fwe seconds auto rotation changes the view.
plz help me to disable the auto rotation in VR mode.
Thanks in advance.
Hi,
I want some suggestion related to auto rotation in VR mode. i include terrain provider and when i go into VR mode, after fwe seconds auto rotation changes the view.
plz help me to disable the auto rotation in VR mode.
Thanks in advance.
Hello,
I don’t know of anything in Cesium that would cause the camera to rotate automatically. It could be a bug, but I wasn’t able to reproduce it. Can you paste a code sample that reproduces the problem?
Thanks,
Hannah
hello hannah,
Thanks for ur reply.
Here is my code check it in VR mode. It causes problem with camera angle. and can u tell me how to disable the axis rotation.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Configure viewer to add a button enabling look at a mobile device with cardboard.">
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
require.config({
baseUrl : '../../../Source',
waitSeconds : 60
});
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer', {
baseLayerPicker : false,
homeButton : false,
navigationHelpButton : false,
timeline : false,
animation : false,
selectionIndiactor : false,
scene3DOnly : true,
bottomContainer : false,
geocoder : false,
vrButton : true
});
// Click the VR button in the bottom right of the screen to switch to VR mode.
var camera = viewer.camera;
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(79.06666666, 30.73388888, 50)
});
var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
url : ‘https://assets.agi.com/stk-terrain/world’,
requestWaterMask : true,
destination : camera,
requestVertexNormals : true
});
viewer.terrainProvider = cesiumTerrainProviderMeshes;
var scene = viewer.scene;
var canvas = viewer.canvas;
canvas.setAttribute('tabindex', '0'); // needed to put focus on the canvas
canvas.onclick = function() {
canvas.focus();
};
var ellipsoid = scene.globe.ellipsoid;
// disable the default event handlers
scene.screenSpaceCameraController.enableRotate = false;
scene.screenSpaceCameraController.enableTranslate = false;
scene.screenSpaceCameraController.enableZoom = false;
scene.screenSpaceCameraController.enableTilt = false;
scene.screenSpaceCameraController.enableLook = false;
scene.screenSpaceCameraController.inertiaSpin = 0.0;
scene.screenSpaceCameraController.inertiaTranslate = 0.0;
var startMousePosition;
var mousePosition;
var flags = {
looking : false,
moveForward : false,
moveBackward : false,
moveUp : false,
moveDown : false,
moveLeft : false,
moveRight : false
};
var handler = new Cesium.ScreenSpaceEventHandler(canvas);
handler.setInputAction(function(movement) {
flags.looking = true;
mousePosition = startMousePosition = Cesium.Cartesian3.clone(movement.position);
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
handler.setInputAction(function(movement) {
mousePosition = movement.endPosition;
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
handler.setInputAction(function(position) {
flags.looking = false;
}, Cesium.ScreenSpaceEventType.LEFT_UP);
function getFlagForKeyCode(keyCode) {
switch (keyCode) {
case 38:
return 'moveForward';
case 40:
return 'moveBackward';
case 33:
return 'moveUp';
case 34:
return 'moveDown';
case 39:
return 'moveRight';
case 37:
return 'moveLeft';
default:
return undefined;
}
}
function onKey(e){
if(e.keyCode == 227){
return 'moveForward'}
}
document.addEventListener('keydown', function(e) {
var flagName = getFlagForKeyCode(e.keyCode);
if (typeof flagName !== 'undefined') {
flags[flagName] = true;
}
}, false);
document.addEventListener('keyup', function(e) {
var flagName = getFlagForKeyCode(e.keyCode);
if (typeof flagName !== 'undefined') {
flags[flagName] = false;
}
}, false);
viewer.clock.onTick.addEventListener(function(clock) {
var camera = viewer.camera;
if (flags.looking) {
var width = canvas.clientWidth;
var height = canvas.clientHeight;
// Coordinate (0.0, 0.0) will be where the mouse was clicked.
var x = (mousePosition.x - startMousePosition.x) / width;
var y = -(mousePosition.y - startMousePosition.y) / height;
var lookFactor = 0.05;
camera.lookRight(x * lookFactor);
camera.lookUp(y * lookFactor);
}
// Change movement speed based on the distance of the camera to the surface of the ellipsoid.
var cameraHeight = ellipsoid.cartesianToCartographic(camera.position).height;
var moveRate = cameraHeight / 100.0;
if (flags.moveForward) {
camera.moveForward(moveRate);
}
if (flags.moveBackward) {
camera.moveBackward(moveRate);
}
if (flags.moveUp) {
camera.moveUp(moveRate);
}
if (flags.moveDown) {
camera.moveDown(moveRate);
}
if (flags.moveLeft) {
camera.moveLeft(moveRate);
}
if (flags.moveRight) {
camera.moveRight(moveRate);
}
});
window.addEventListener('keydown', onkey, true);
//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>
hi hannah
i asked this question earlier.
can u help me with this issue?
Thanks!!
Sorry I missed your question before.
I don’t understand what you’re trying to do with the clock ontick event. I’m guessing that is why your camera is moving.
-Hannah