mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
show simple overlay for script testing
This commit is contained in:
parent
8724f0d0d9
commit
3c330d0c48
1 changed files with 43 additions and 0 deletions
|
@ -22,14 +22,56 @@ var button = toolbar.addButton({
|
||||||
});
|
});
|
||||||
|
|
||||||
var isShowingOverlays = false;
|
var isShowingOverlays = false;
|
||||||
|
var currentOverlays = [];
|
||||||
|
|
||||||
|
function hideOverlays() {
|
||||||
|
// enumerate the overlays and remove them
|
||||||
|
while (currentOverlays.length) {
|
||||||
|
// shift the element to remove it from the current overlays array when it is removed
|
||||||
|
Overlays.deleteOverlay(currentOverlays.shift());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var OVERLAY_SIZE = 0.25;
|
||||||
|
|
||||||
|
function showOverlays() {
|
||||||
|
var identifiers = AvatarList.getAvatarIdentifiers();
|
||||||
|
|
||||||
|
for (i = 0; i < identifiers.length; ++i) {
|
||||||
|
// get the position for this avatar
|
||||||
|
var avatar = AvatarList.getAvatar(identifiers[i]);
|
||||||
|
var avatarPosition = avatar && avatar.position;
|
||||||
|
|
||||||
|
if (!avatarPosition) {
|
||||||
|
// we don't have a valid position for this avatar, skip it
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the overlay above this avatar
|
||||||
|
var newOverlay = Overlays.addOverlay("cube", {
|
||||||
|
position: avatarPosition,
|
||||||
|
size: 0.25,
|
||||||
|
color: { red: 0, green: 0, blue: 255},
|
||||||
|
alpha: 1,
|
||||||
|
solid: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// push this overlay to our array of overlays
|
||||||
|
currentOverlays.push(newOverlay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handle clicks on the toolbar button
|
// handle clicks on the toolbar button
|
||||||
function buttonClicked(){
|
function buttonClicked(){
|
||||||
if (isShowingOverlays) {
|
if (isShowingOverlays) {
|
||||||
hideOverlays();
|
hideOverlays();
|
||||||
|
isShowingOverlays = false;
|
||||||
} else {
|
} else {
|
||||||
showOverlays();
|
showOverlays();
|
||||||
|
isShowingOverlays = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.writeProperty('buttonState', isShowingOverlays ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
button.clicked.connect(buttonClicked);
|
button.clicked.connect(buttonClicked);
|
||||||
|
@ -37,4 +79,5 @@ button.clicked.connect(buttonClicked);
|
||||||
// remove the toolbar button when script is stopped
|
// remove the toolbar button when script is stopped
|
||||||
Script.scriptEnding.connect(function() {
|
Script.scriptEnding.connect(function() {
|
||||||
toolbar.removeButton('ignore');
|
toolbar.removeButton('ignore');
|
||||||
|
hideOverlays();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue