Skip to content

Commit

Permalink
Merge pull request #128 from vpython/bruce_fixes_nov_15_20
Browse files Browse the repository at this point in the history
Bruce fixes for nov-15-2020
  • Loading branch information
sspickle committed Nov 15, 2020
2 parents 6d5b631 + 1123841 commit 9e6782f
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 64 deletions.
26 changes: 20 additions & 6 deletions labextension/vpython/src/glowcommlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ export function createWebsocket(msg, serviceUrl) {
var uri = msg.content.data.wsuri
var url;

url = serviceUrl + port + uri;
if (document.location.hostname.includes("localhost")){
url = "ws://localhost:" + port + uri;
}
else {
url = serviceUrl + port + uri;
}
ws = new WebSocket(url);
ws.binaryType = "arraybuffer";

Expand Down Expand Up @@ -612,11 +617,20 @@ function o2vec3(p) {
function handler(data) {
"use strict";

/*
console.log('---------------')
for (var d in data) {
for (var i in data[d]) console.log(i, JSON.stringify(data[d][i]))
}
/*
// Debugging what is sent from server:
let found = false
for (let d in data) {
for (const i in data[d]) {
if (!found) {
found = true
console.log('================')
}
if (found) {
console.log(i, JSON.stringify(data[d][i]))
}
}
}
*/

if (data.cmds !== undefined && data.cmds.length > 0) handle_cmds(data.cmds)
Expand Down
1 change: 1 addition & 0 deletions vpython/rate_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def _sleep(dt):
return
tend = _clock()+dt
while _clock() < tend:
print (tend- _clock(),tend)
pass

class simulateDelay:
Expand Down
5 changes: 3 additions & 2 deletions vpython/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ def adjust_up(oldaxis, newaxis, up, save_oldaxis): # adjust up when axis is chan
return save_oldaxis
if save_oldaxis is not None:
# Restore saved oldaxis now that newaxis is nonzero
oldaxis = save_oldaxis
oldaxis._x = save_oldaxis._x # avoid creating a new vector
oldaxis._y = save_oldaxis._y
oldaxis._z = save_oldaxis._z
save_oldaxis = None
if newaxis.dot(up) != 0: # axis and up not orthogonal
angle = oldaxis.diff_angle(newaxis)
Expand All @@ -318,7 +320,6 @@ def adjust_up(oldaxis, newaxis, up, save_oldaxis): # adjust up when axis is chan
oldaxis._x = newaxis._x # avoid creating a new vector
oldaxis._y = newaxis._y
oldaxis._z = newaxis._z
return save_oldaxis

def adjust_axis(oldup, newup, axis, save_oldup): # adjust axis when up is changed
if abs(newup._x) + abs(newup._y) + abs(newup._z) == 0:
Expand Down

0 comments on commit 9e6782f

Please sign in to comment.