-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* roboscape 2 * index
- Loading branch information
Showing
9 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: </label><input list="roboscapedialog-join-rooms-list" class="inset"/></div> | ||
<div><label>Password: </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: </label><input list="roboscapedialog-new-environment-list" id="roboscapedialog-new-environment" class="inset"/></div> | ||
<div><label>Password: </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(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters