Skip to content

Commit

Permalink
Test version of new roboscape (#48)
Browse files Browse the repository at this point in the history
* roboscape 2

* index
  • Loading branch information
gsteinLTU authored Oct 17, 2023
1 parent d915e97 commit ec91093
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Extensions currently included in this repository:

- [🤖 RoboScape Online](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/RoboScapeOnline/index.js%22]) - Networked robotics simulation in the browser! (WIP)

- [🤖 RoboScape Online (beta)](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/RoboScapeOnline2/index.js%22]) - Networked robotics simulation in the browser! (WIP)

- [TimeSync](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/TimeSync/index.js%22]) - calculate time sync info from the NetsBlox server

- [TuneScope](https://dev.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/TuneScope/index.js%22]) - Music Notation, Instruments, Drums, Tones, Chords, Tracks, from the University of Virginia (Glen Bull)
Expand Down
Binary file not shown.
Binary file added extensions/RoboScapeOnline2/assets/sphere.glb
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions extensions/RoboScapeOnline2/extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"customName": "🤖 RoboScape Online (beta)",
"description": "Networked robotics simulation in the browser! (WIP)",
"useDev": false
}
220 changes: 220 additions & 0 deletions extensions/RoboScapeOnline2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/**
* The following file is generated through a build script. Manually modifying it is an at-your-own-risk activity and your changes will likely be overridden.
*/

(function () {
class RoboScapeOnline extends Extension {
constructor(ide) {
super('RoboScape Online');
}

onOpenRole() {

}

getSettings() {
return [
Extension.ExtensionSetting.createFromLocalStorage('Beeps Enabled', 'roboscape_beep', true, 'Robots can beep', 'Robots cannot beep', false),
Extension.ExtensionSetting.createFromLocalStorage('Robot ID Billboards Enabled', 'roboscape_id_billboards', true, 'Robot IDs show over heads', 'Robots IDs hidden', false),

];
}

getMenu() {
return {
'New simulation...': window.RoboScapeOnline_fns.new_sim_menu,
'Join room...': window.RoboScapeOnline_fns.join_sim_menu,
'Show 3D View': window.RoboScapeOnline_fns.show_3d_view,

};
}

getCategories() {
return [

];
}

getPalette() {
return [
new Extension.PaletteCategory(
'network',
[
new Extension.Palette.Block('roomID'),
new Extension.Palette.Block('robotsInRoom'),
],
SpriteMorph
),
new Extension.PaletteCategory(
'network',
[
new Extension.Palette.Block('roomID'),
new Extension.Palette.Block('robotsInRoom'),
],
StageMorph
),

];
}

getBlocks() {
return [
new Extension.Block(
'roomID',
'reporter',
'network',
'RoboScape room id',
[],
function () { return RoboScapeOnline_fns.room_id(); }
).for(SpriteMorph, StageMorph),
new Extension.Block(
'robotsInRoom',
'reporter',
'network',
'robots in room',
[],
function () { return RoboScapeOnline_fns.robots_in_room(); }
).for(SpriteMorph, StageMorph),

];
}

getLabelParts() {
return [

];
}

}

NetsBloxExtensions.register(RoboScapeOnline);
let path = document.currentScript.src;
path = path.substring(0, path.lastIndexOf("/"));


// Add CSS
var element = document.createElement('link');
element.setAttribute('rel', 'stylesheet');
element.setAttribute('type', 'text/css');
element.setAttribute('href', 'https://gsteinltu.github.io/PseudoMorphic/style.css');
document.head.appendChild(element);

var extraStyle = document.createElement('style');
extraStyle.innerText = `
#roboscapebuttonbar * {
margin: auto 5px;
}
`;
document.head.appendChild(extraStyle);

// Add JS
var scriptElement = document.createElement('script');

scriptElement.onload = () => {
// Create 3D view dialog for later use
{
var element = createDialog('RoboScape Online');
element.style.width = '400px';
element.style.height = '400px';
const canvas = document.createElement('canvas');
canvas.id = 'roboscape-canvas';
canvas.style.flex = '1 1 auto';
canvas.style.overflow = 'hidden';
const contentElement = element.querySelector('content');
contentElement.style.display = 'flex';
contentElement.style['flex-flow'] = 'column';
contentElement.style['justify-content'] = 'flex-end';
contentElement.appendChild(canvas);
setupDialog(element);

window.externalVariables['roboscapedialog'] = element;


const buttonbar = document.createElement('div');
buttonbar.id = 'roboscapebuttonbar';
buttonbar.style.flex = '0 1';
element.querySelector('content').appendChild(buttonbar);

const robotmenu_label = document.createElement('label');
robotmenu_label.innerText = 'Robot ID:';
buttonbar.appendChild(robotmenu_label);
const robotmenu = document.createElement('select');
robotmenu.className = 'inset';
robotmenu.onmousedown = (e) => { e.stopPropagation(); };
const nonchoice = document.createElement('option');
robotmenu.appendChild(nonchoice);
buttonbar.appendChild(robotmenu);
window.externalVariables['roboscapedialog-robotmenu'] = robotmenu;
}

// Create join dialog for later use
{
var element = document.createElement('datalist');
element.id = 'roboscapedialog-join-rooms-list';
document.body.appendChild(element);
window.externalVariables['roboscapedialog-join-rooms-list'] = element;

element = createDialog('Join a Session', false, ['Join', 'Close']);
element.querySelector('content').innerHTML += `
<div style="margin-bottom: 12px;"><label>Room ID:&nbsp;</label><input list="roboscapedialog-join-rooms-list" class="inset"/></div>
<div><label>Password:&nbsp;</label><input class="inset"/></div>
`;

setupDialog(element, false);
window.externalVariables['roboscapedialog-join'] = element;


element = document.createElement('datalist');
element.id = 'roboscapedialog-new-environment-list';
document.body.appendChild(element);
window.externalVariables['roboscapedialog-new-environment-list'] = element;

element = createDialog('Create a Session', false, ['Create', 'Edit Mode', 'Close']);
element.querySelector('content').innerHTML += `
<div style="margin-bottom: 12px;"><label>Environment:&nbsp;</label><input list="roboscapedialog-new-environment-list" id="roboscapedialog-new-environment" class="inset"/></div>
<div><label>Password:&nbsp;</label><input id="roboscapedialog-new-password" class="inset"/></div>
`;

setupDialog(element, false);
window.externalVariables['roboscapedialog-new'] = element;

}
};

scriptElement.setAttribute('src', 'https://gsteinltu.github.io/PseudoMorphic/script.js');
document.head.appendChild(scriptElement);

var scriptElement = document.createElement('script');
scriptElement.async = false;

scriptElement.onload = () => {
var loaderScriptElement = document.createElement('script');
loaderScriptElement.async = false;
loaderScriptElement.onload = () => {
var s = document.createElement('script');
s.type = "module";
s.innerHTML = `import init, {room_id, show_3d_view, join_sim_menu, new_sim_menu, robots_in_room} from '${path}/pkg/roboscapesim_client.js';
await init();
window.RoboScapeOnline_fns = {};
window.RoboScapeOnline_fns.room_id = room_id;
window.RoboScapeOnline_fns.show_3d_view = show_3d_view;
window.RoboScapeOnline_fns.join_sim_menu = join_sim_menu;
window.RoboScapeOnline_fns.new_sim_menu = new_sim_menu;
window.RoboScapeOnline_fns.robots_in_room = robots_in_room;
`;
document.body.appendChild(s);
};
loaderScriptElement.setAttribute('src', 'https://preview.babylonjs.com/loaders/babylonjs.loaders.min.js');
document.head.appendChild(loaderScriptElement);
var guiScriptElement = document.createElement('script');
guiScriptElement.async = false;
guiScriptElement.setAttribute('src', 'https://preview.babylonjs.com/gui/babylon.gui.js');
document.head.appendChild(guiScriptElement);
};
scriptElement.setAttribute('src', 'https://preview.babylonjs.com/babylon.js');
document.head.appendChild(scriptElement);
disableRetinaSupport();
})();
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ <h1>NetsBlox Extensions</h1>
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="RoboScapeOnline2" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/RoboScapeOnline2/index.js%22]" target="_blank"> 🤖 RoboScape Online (beta) </a></summary>
<p>
<input type="hidden" name="RoboScapeOnline2_script" id="RoboScapeOnline2_script" value="https://extensions.netsblox.org/extensions/RoboScapeOnline2/index.js" />
Networked robotics simulation in the browser! (WIP)
</p>
</details>

<details class="extension">
<summary><input type="checkbox" class="extensionOption" name="TimeSync" style="margin-right: 10px" hidden /><a href="https://editor.netsblox.org/?extensions=[%22https://extensions.netsblox.org/extensions/TimeSync/index.js%22]" target="_blank"> TimeSync </a></summary>
<p>
Expand Down

0 comments on commit ec91093

Please sign in to comment.