Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions repast.simphony.server/web/static/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ var runner = (function() {



function initSocket() {
function initSocket(port) {
//var socket = io.connect('http://localhost:5000');
socket = new WebSocket('ws://localhost:5000/simphony/simsocket');
socket = new WebSocket('ws://localhost:' + port + '/simphony/simsocket');

socket.onmessage = function(evt) {
if (evt.data instanceof Blob) {
Expand Down Expand Up @@ -331,7 +331,7 @@ $(document).ready(function () {
//$("#start").prop('disabled', true);
//$("#step").prop('disabled', true);

initSocket();
initSocket(location.port);

$("#init").on('click', () => {
runner.next = runner.initClicked;
Expand Down
16 changes: 12 additions & 4 deletions repast.simphony.server/web/static/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,25 @@ function getElementPosition(element) {
}

class SpriteCreator {
constructor(texture_file, scale) {
//include the size property so that the display will respect agent's size, not the icon's one
constructor(texture_file, scale, size) {
this.promise = textureLoader.load('textures/' + texture_file).then(this.onLoad.bind(this)).catch( (err ) => {
console.log(err);
});
this.scale = scale;
this.size = size;
}

onLoad(texture) {
this.material = new THREE.SpriteMaterial({ map: texture });
this.img_width = texture.image.width;
this.img_height = texture.image.height;
//if size is not null, then consider it has sprite's width and height, otherwise consider the icon's ones
if(!this.size){
this.img_width = texture.image.width;
this.img_height = texture.image.height;
}
else{
this.img_width = this.img_height = this.size;
}
}

create() {
Expand Down Expand Up @@ -274,7 +282,7 @@ export class Display2D {
let lay = display_msg.layers[i];
let creator = null;
if (lay.icon != "") {
creator = new SpriteCreator(lay.icon, lay.scale);
creator = new SpriteCreator(lay.icon, lay.scale, lay.size); //include the size property
promises.push(creator.promise);
} else {
let shape_color = new THREE.Color(lay.color[0], lay.color[1], lay.color[2]);
Expand Down