Skip to content

Commit

Permalink
updated controls to not go under the plane
Browse files Browse the repository at this point in the history
added a bit more damping to controls
minor clean up of code
  • Loading branch information
Morten Skov Jørgensen committed Dec 5, 2016
1 parent c7c2d66 commit 8c702e0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions 3dmap-master/control.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
camera.position.y = 1254;

controls = new THREE.OrbitControls( camera, renderer.domElement );

controls.dampingFactor = 1.75;
controls.maxPolarAngle = Math.PI/2;

let lookAt = null;
let position = new THREE.Vector3();
controls.addEventListener('change',function(e){
Expand Down
5 changes: 3 additions & 2 deletions 3dmap-master/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@
controls = new THREE.OrbitControls( camera, renderer.domElement );

controls.enableDamping = true;
controls.dampingFactor = 0.25;
controls.dampingFactor = 0.5;
controls.enableZoom = true;
controls.maxPolarAngle = Math.PI/2;

//adding sun/moon object
var sunGeometry = new THREE.SphereGeometry( 400, 32, 32 );
Expand Down Expand Up @@ -443,7 +444,7 @@
}



controls.update();
//animate camera
if(pathCamera && autoCamAnimation){
let time = Date.now()
Expand Down
3 changes: 0 additions & 3 deletions 3dmap-master/js/WSClient/wsClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,7 @@ var controlClient = (function(){

connection.onmessage = function(message) {
msg = JSON.parse(message.data);
console.log(msg);
if(msg.type === "setup"){
console.log("setup type")
clientId = msg.id;
if(controlCallback){
controlCallback(null);
Expand All @@ -342,7 +340,6 @@ var controlClient = (function(){

return {
setup: function(isClient, callback){
console.log("cc setup");
controlCallback = callback;
if(connection && connection.readyState==1){
connection.send(JSON.stringify({type: "SETUP", data: {isClient : isClient}}));
Expand Down
5 changes: 5 additions & 0 deletions 3dmap-master/js/interaction/userInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,23 @@ var interaction = (function(){
let lookAt = null;
let position = new THREE.Vector3();
controls.addEventListener('change',function(e){

if(connectedToCameraControlServer){
//let matrix = e.target.object.matrix;
/*
position = e.target.object.position;
e.target.object.getWorldDirection(lookAt);
lookAt = new THREE.Vector3(0,0, -1);
lookAt.applyMatrix4( camera.matrixWorld );
controlClient.sendControls(position, lookAt);
*/
}
});

controlClient.setup(false, function(position, lookAt){

if(!connectedToCameraControlServer){

connectedToCameraControlServer=true;
}

Expand Down
6 changes: 1 addition & 5 deletions 3dmap-master/js/mapData/dataLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ var mapData = (function(){
},50);
getRoads();
//setting up a websocket to event server
if(cityName=="ringe"){
console.log('ringe');
}else{
console.log('der');
}

setupVanillaSocket();
//for testing events - can be removed when done
//addTestEvent();
Expand Down
3 changes: 0 additions & 3 deletions WSServer/controls/controlService.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ function setupWSServer() {
clients.splice(index, 1);

}else if(obj.type == 'controls'){
console.log("gotten");
console.log(obj.data.position);
console.log(obj.data.lookAt);
clients.forEach(function(client){
if(client.id !== obj.id ){
sendCameraToClient(client, obj.data.position, obj.data.lookAt);
Expand Down

0 comments on commit 8c702e0

Please sign in to comment.