mirror of
https://github.com/overte-org/community-apps.git
synced 2025-04-07 09:42:08 +02:00
Add attach avatar app.
This commit is contained in:
parent
e6a3299a57
commit
2dac8d4651
5 changed files with 91 additions and 0 deletions
BIN
applications/attach-avatar-app/assets/Halo.fbx
Normal file
BIN
applications/attach-avatar-app/assets/Halo.fbx
Normal file
Binary file not shown.
BIN
applications/attach-avatar-app/assets/account-child-circle.png
Normal file
BIN
applications/attach-avatar-app/assets/account-child-circle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M12,12A1.5,1.5 0 0,1 13.5,13.5A1.5,1.5 0 0,1 12,15A1.5,1.5 0 0,1 10.5,13.5A1.5,1.5 0 0,1 12,12M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,16C12.72,16 13.4,16.15 14.04,16.5C14.68,16.8 15,17.2 15,17.67V19.41C16.34,18.81 17,18.08 17,17.2V12.8C17,12 16.5,11.35 15.45,10.8C14.4,10.26 13.25,10 12,10C10.75,10 9.6,10.26 8.55,10.8C7.5,11.35 7,12 7,12.8V17.2C7,18 7.53,18.69 8.63,19.22C9.72,19.75 10.84,20 12,20L13,19.92V17.91L12,18C11,18 10,17.8 9.05,17.39C9.17,17 9.53,16.69 10.13,16.41C10.72,16.13 11.34,16 12,16M12,4A2.5,2.5 0 0,0 9.5,6.5A2.5,2.5 0 0,0 12,9A2.5,2.5 0 0,0 14.5,6.5A2.5,2.5 0 0,0 12,4Z" /></svg>
|
After Width: | Height: | Size: 925 B |
81
applications/attach-avatar-app/attachAvatarApp.js
Normal file
81
applications/attach-avatar-app/attachAvatarApp.js
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* globals Vec3, Quat, Uuid, Camera, MyAvatar, Entities, Overlays, Script, Tablet, AvatarList, AvatarManager, Picks, PickType require ScriptDiscoveryService */
|
||||
//
|
||||
// attachAvatarApp.js
|
||||
//
|
||||
// Created by KasenVR on 2 August 2020.
|
||||
// Copyright 2020 Vircadia contributors.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var APP_NAME = "Avatar Attach App";
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
|
||||
var accountChildIcon = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="white" d="M12,2A3,3 0 0,1 15,5A3,3 0 0,1 12,8A3,3 0 0,1 9,5A3,3 0 0,1 12,2M12,9C13.63,9 15.12,9.35 16.5,10.05C17.84,10.76 18.5,11.61 18.5,12.61V18.38C18.5,19.5 17.64,20.44 15.89,21.19V19C15.89,18.05 15.03,17.38 13.31,16.97C12.75,16.84 12.31,16.78 12,16.78C11.13,16.78 10.3,16.95 9.54,17.3C8.77,17.64 8.31,18.08 8.16,18.61C9.5,19.14 10.78,19.41 12,19.41L13,19.31V21.94L12,22C10.63,22 9.33,21.72 8.11,21.19C6.36,20.44 5.5,19.5 5.5,18.38V12.61C5.5,11.61 6.16,10.76 7.5,10.05C8.88,9.35 10.38,9 12,9M12,11A2,2 0 0,0 10,13A2,2 0 0,0 12,15A2,2 0 0,0 14,13A2,2 0 0,0 12,11Z" /></svg>';;
|
||||
|
||||
var button = tablet.addButton({
|
||||
text: "ATTACH",
|
||||
icon: accountChildIcon.replace('black', 'white'),
|
||||
activeIcon: accountChildIcon
|
||||
});
|
||||
|
||||
Script.scriptEnding.connect(function(){
|
||||
tablet.removeButton(button);
|
||||
button = null;
|
||||
});
|
||||
|
||||
button.clicked.connect(togglePlatform);
|
||||
var platformID;
|
||||
|
||||
function togglePlatform() {
|
||||
|
||||
function getNearbyAvatars(origin, sessionUUIDs) {
|
||||
|
||||
var cleanAvatars = sessionUUIDs.filter(function (id) {
|
||||
if (id == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var idString = id.toString();
|
||||
|
||||
if (idString.indexOf(MyAvatar.sessionUUID) === -1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return cleanAvatars.map(function(id) {
|
||||
var avi = AvatarList.getAvatar(id);
|
||||
avi.$distance = Vec3.distance(origin, avi.position);
|
||||
return avi;
|
||||
}).sort(function(a, b) {
|
||||
return a.$distance < b.$distance ? -1 : a.$distance > b.$distance ? 1 : 0;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
var nearest = getNearbyAvatars(MyAvatar.position, AvatarList.getAvatarIdentifiers())[0];
|
||||
var platformScale = { x: 0.604 * MyAvatar.scale, y: 0.036 * MyAvatar.scale, z: 0.604 * MyAvatar.scale };
|
||||
|
||||
if(platformID) {
|
||||
Entities.deleteEntity(platformID);
|
||||
platformID = null;
|
||||
MyAvatar.setParentID("null");
|
||||
} else if (nearest != null) {
|
||||
platformID = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: Script.resolvePath("./assets/Halo.fbx"),
|
||||
position: MyAvatar.position,
|
||||
rotation: Quat.IDENTITY,
|
||||
dimensions: platformScale,
|
||||
collisionMask: 8,
|
||||
collisionless: false,
|
||||
shapeType: "box",
|
||||
parentID: nearest.sessionUUID,
|
||||
parentJointIndex: 0,
|
||||
}, "avatar"); // Make it a client entity! We want it to show up/load in other worlds without rez rights.
|
||||
MyAvatar.setParentID(platformID);
|
||||
}
|
||||
}
|
|
@ -80,5 +80,14 @@ var metadata = { "applications": [
|
|||
"icon": "nametags/assets/nametags-i.svg",
|
||||
"caption": "NAMETAGS"
|
||||
},
|
||||
{
|
||||
"isActive": true,
|
||||
"directory": "attach-avatar-app",
|
||||
"name": "Attach Avatar",
|
||||
"description": "Attaches your avatar to another avatar via a collisionless platform.",
|
||||
"jsfile": "attach-avatar-app/attachAvatarApp.js",
|
||||
"icon": "attach-avatar-app/assets/account-child-circle.png",
|
||||
"caption": "ATCH AVI"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue