Skip to content

Commit

Permalink
Merge pull request #62 from AleziaKurdis/RoomScaleMarkerApp
Browse files Browse the repository at this point in the history
Add "Room Scale Marker" app
  • Loading branch information
ksuprynowicz authored Dec 22, 2023
2 parents 216dcda + f8fa26f commit fac661b
Show file tree
Hide file tree
Showing 5 changed files with 294 additions and 0 deletions.
9 changes: 9 additions & 0 deletions applications/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@ var metadata = { "applications":
"icon": "inventory-app/dist/inventory-i.svg",
"caption": "INVENTORY"
},
{
"isActive": true,
"directory": "roomScaleMarker",
"name": "Room Scale Marker",
"description": "Designed for enthusiasts of 'Full Body Tracking,' this application prioritizes safety and performance precision by generating a central marker (local entity). Unlike the standard chaperone system in VR, which tends to signal boundaries reactively, this central marker enhances real-world reference awareness, enabling users to plan their moves more effectively to never reach those boundaries. Perfect for dancing. This marker self-delete as soon it stop matching the reality.",
"jsfile": "roomScaleMarker/app-roomScaleMarker.js",
"icon": "roomScaleMarker/icon_inactive.png",
"caption": "RS-MARKER"
},
{
"isActive": true,
"directory": "flyAvatar",
Expand Down
104 changes: 104 additions & 0 deletions applications/roomScaleMarker/app-roomScaleMarker.js
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);
}());
Binary file added applications/roomScaleMarker/icon_active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/roomScaleMarker/icon_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
181 changes: 181 additions & 0 deletions applications/roomScaleMarker/marker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fac661b

Please sign in to comment.