-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from AleziaKurdis/RoomScaleMarkerApp
Add "Room Scale Marker" app
- Loading branch information
Showing
5 changed files
with
294 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
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,104 @@ | ||
// | ||
// app-roomScaleMarker.js | ||
// | ||
// Created by Alezia Kurdis, December 18th 2023. | ||
// Copyright 2023 Overte e.V. | ||
// | ||
// Put a Marker on the floor to indicate the center of the room as you are doing full body tracking. | ||
// | ||
// Distributed under the Apache License, Version 2.0. | ||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | ||
// | ||
(function() { | ||
var jsMainFileName = "app-roomScaleMarker.js"; | ||
var ROOT = Script.resolvePath('').split(jsMainFileName)[0]; | ||
|
||
var APP_NAME = "RS-MARKER"; | ||
var ICON_CAPTION_COLOR = "#FFFFFF"; | ||
var APP_ICON_INACTIVE = ROOT + "icon_inactive.png"; | ||
var APP_ICON_ACTIVE = ROOT + "icon_active.png"; | ||
var appStatus = false; | ||
var channel = "overte.application.ak.roomScaleMarker"; | ||
var markerID = Uuid.NULL; | ||
|
||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); | ||
|
||
var button = tablet.addButton({ | ||
"text": APP_NAME, | ||
"icon": APP_ICON_INACTIVE, | ||
"activeIcon": APP_ICON_ACTIVE, | ||
"sortOrder": 4, | ||
"captionColor": ICON_CAPTION_COLOR | ||
}); | ||
|
||
function clicked(){ | ||
var colorCaption; | ||
if (appStatus === true) { | ||
clearMarker(); | ||
colorCaption = ICON_CAPTION_COLOR; | ||
appStatus = false; | ||
}else{ | ||
drawMarker(); | ||
colorCaption = "#000000"; | ||
appStatus = true; | ||
} | ||
|
||
button.editProperties({ | ||
"isActive": appStatus, | ||
"captionColor": colorCaption | ||
}); | ||
} | ||
|
||
button.clicked.connect(clicked); | ||
|
||
function drawMarker() { | ||
if (markerID !== Uuid.NULL) { | ||
clearMarker(); | ||
} | ||
markerID = Entities.addEntity({ | ||
"name": "ROOM SCALE MARKER", | ||
"type": "Image", | ||
"dimensions": {"x": 2, "y": 2, "z": 0.01}, | ||
"position": Vec3.sum(MyAvatar.feetPosition,{"x": 0, "y": 0.01, "z": 0}), | ||
"rotation": Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({"x": -90, "y": 0, "z": 0})), | ||
"imageURL": ROOT + "marker.svg", | ||
"emissive": true, | ||
"keepAspectRatio": false, | ||
"canCastShadow": false, | ||
"isVisibleInSecondaryCamera": false, | ||
"grab": { | ||
"grabbable": false | ||
} | ||
},"local"); | ||
Controller.actionEvent.connect(onActionEvent); | ||
} | ||
|
||
//all except 23 24 | ||
function onActionEvent(action, value) { | ||
if (action !== 23 && action !== 24) { | ||
appStatus = true; | ||
clicked(); | ||
} | ||
} | ||
|
||
function clearMarker() { | ||
if (markerID !== Uuid.NULL) { | ||
Entities.deleteEntity(markerID); | ||
markerID = Uuid.NULL; | ||
} | ||
Controller.actionEvent.disconnect(onActionEvent); | ||
} | ||
|
||
function cleanup() { | ||
|
||
if (appStatus) { | ||
clearMarker(); | ||
colorCaption = ICON_CAPTION_COLOR; | ||
appStatus = false; | ||
} | ||
|
||
tablet.removeButton(button); | ||
} | ||
|
||
Script.scriptEnding.connect(cleanup); | ||
}()); |
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.