Skip to content

Commit

Permalink
Merge pull request #76 from AleziaKurdis/AppDomainMapper-Avatars
Browse files Browse the repository at this point in the history
domainMapper application: Add display of avatars present in the domain.
  • Loading branch information
ksuprynowicz authored Apr 9, 2024
2 parents a29cddb + a065ff9 commit ae8b3d6
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 9 deletions.
93 changes: 85 additions & 8 deletions applications/domainMapper/app-domainMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,16 @@
"shape": "Cube",
"parentID": domainMapID,
"grab": {"grabbable": false },
"dimensions": {"x": DOMAIN_MAP_SIZE * (properties.dimensions.x/DOMAIN_SIZE), "y": DOMAIN_MAP_SIZE * (properties.dimensions.y/DOMAIN_SIZE), "z": DOMAIN_MAP_SIZE * (properties.dimensions.z/DOMAIN_SIZE)},
"localPosition": {"x": (DOMAIN_MAP_SIZE/2) * (properties.position.x/(DOMAIN_SIZE/2)), "y": (DOMAIN_MAP_SIZE/2) * (properties.position.y/(DOMAIN_SIZE/2)), "z": (DOMAIN_MAP_SIZE/2) * (properties.position.z/(DOMAIN_SIZE/2)) },
"dimensions": {
"x": DOMAIN_MAP_SIZE * (properties.dimensions.x/DOMAIN_SIZE),
"y": DOMAIN_MAP_SIZE * (properties.dimensions.y/DOMAIN_SIZE),
"z": DOMAIN_MAP_SIZE * (properties.dimensions.z/DOMAIN_SIZE)
},
"localPosition": {
"x": (DOMAIN_MAP_SIZE/2) * (properties.position.x/(DOMAIN_SIZE/2)),
"y": (DOMAIN_MAP_SIZE/2) * (properties.position.y/(DOMAIN_SIZE/2)),
"z": (DOMAIN_MAP_SIZE/2) * (properties.position.z/(DOMAIN_SIZE/2))
},
"localRotation": properties.rotation,
"color": color,
"alpha": 0.1,
Expand All @@ -341,8 +349,16 @@
"shape": "Cube",
"parentID": domainMapID,
"grab": {"grabbable": false },
"dimensions": {"x": DOMAIN_MAP_SIZE * (properties.dimensions.x/DOMAIN_SIZE), "y": DOMAIN_MAP_SIZE * (properties.dimensions.y/DOMAIN_SIZE), "z": DOMAIN_MAP_SIZE * (properties.dimensions.z/DOMAIN_SIZE)},
"localPosition": {"x": (DOMAIN_MAP_SIZE/2) * (properties.position.x/(DOMAIN_SIZE/2)), "y": (DOMAIN_MAP_SIZE/2) * (properties.position.y/(DOMAIN_SIZE/2)), "z": (DOMAIN_MAP_SIZE/2) * (properties.position.z/(DOMAIN_SIZE/2)) },
"dimensions": {
"x": DOMAIN_MAP_SIZE * (properties.dimensions.x/DOMAIN_SIZE),
"y": DOMAIN_MAP_SIZE * (properties.dimensions.y/DOMAIN_SIZE),
"z": DOMAIN_MAP_SIZE * (properties.dimensions.z/DOMAIN_SIZE)
},
"localPosition": {
"x": (DOMAIN_MAP_SIZE/2) * (properties.position.x/(DOMAIN_SIZE/2)),
"y": (DOMAIN_MAP_SIZE/2) * (properties.position.y/(DOMAIN_SIZE/2)),
"z": (DOMAIN_MAP_SIZE/2) * (properties.position.z/(DOMAIN_SIZE/2))
},
"localRotation": properties.rotation,
"color": color,
"alpha": 1,
Expand All @@ -368,9 +384,9 @@
"grab": {"grabbable": false },
"dimensions": {"x": 4, "y": 0.1, "z": 0.01},
"localPosition": {
"x": (DOMAIN_MAP_SIZE/2) * (properties.position.x/(DOMAIN_SIZE/2)),
"y": ((DOMAIN_MAP_SIZE/2) * (properties.position.y/(DOMAIN_SIZE/2))) + ((DOMAIN_MAP_SIZE * (properties.dimensions.y/DOMAIN_SIZE))/2) + lineHight,
"z": (DOMAIN_MAP_SIZE/2) * (properties.position.z/(DOMAIN_SIZE/2))
"x": (DOMAIN_MAP_SIZE/2) * (properties.position.x/(DOMAIN_SIZE/2)),
"y": ((DOMAIN_MAP_SIZE/2) * (properties.position.y/(DOMAIN_SIZE/2))) + ((DOMAIN_MAP_SIZE * (properties.dimensions.y/DOMAIN_SIZE))/2) + lineHight,
"z": (DOMAIN_MAP_SIZE/2) * (properties.position.z/(DOMAIN_SIZE/2))
},
"text": properties.name,
"lineHeight": lineHight,
Expand All @@ -387,7 +403,68 @@
}, "local");
}
}


var avatarIDs = AvatarManager.getAvatarsInRange({"x": 0, "y": 0, "z": 0}, FULL_DOMAIN_SCAN_RADIUS);
if (avatarIDs.length > 0) {
var avatarColor, avatarName;
for (i = 0; i < avatarIDs.length; i++) {
properties = AvatarManager.getAvatar(avatarIDs[i]);
avatarColor = {"red": 0, "green": 128, "blue": 255};
avatarName = properties.sessionDisplayName;
if (properties.sessionUUID === MyAvatar.sessionUUID) {
avatarName = "YOU";
avatarColor = {"red": 255, "green": 32, "blue": 0};
}

id = Entities.addEntity({
"name": "AVATAR - " + avatarName,
"type": "Shape",
"parentID": domainMapID,
"shape": "Sphere",
"grab": {"grabbable": false },
"dimensions": {"x": 0.003, "y": 0.003, "z": 0.003},
"localPosition": {
"x": (DOMAIN_MAP_SIZE/2) * (properties.position.x/(DOMAIN_SIZE/2)),
"y": (DOMAIN_MAP_SIZE/2) * (properties.position.y/(DOMAIN_SIZE/2)),
"z": (DOMAIN_MAP_SIZE/2) * (properties.position.z/(DOMAIN_SIZE/2))
},
"color": avatarColor,
"alpha": 0.8,
"canCastShadow": false,
"collisionless": true,
"primitiveMode": "solid"
}, "local");
makeUnlit(id);

lineHight = 0.006;
margins = 0;
id = Entities.addEntity({
"name": "Avatar Name - " + avatarName,
"type": "Text",
"parentID": domainMapID,
"grab": {"grabbable": false },
"dimensions": {"x": 4, "y": 0.01, "z": 0.01},
"localPosition": {
"x": (DOMAIN_MAP_SIZE/2) * (properties.position.x/(DOMAIN_SIZE/2)),
"y": ((DOMAIN_MAP_SIZE/2) * (properties.position.y/(DOMAIN_SIZE/2))) + lineHight,
"z": (DOMAIN_MAP_SIZE/2) * (properties.position.z/(DOMAIN_SIZE/2))
},
"text": avatarName,
"lineHeight": lineHight,
"textColor": avatarColor,
"textAlpha": 0.8,
"backgroundAlpha": 0,
"topMargin": margins,
"bottomMargin": margins,
"unlit": true,
"alignment": "center",
"billboardMode": "full",
"canCastShadow": false,
"collisionless": true
}, "local");

}
}
}

function getTheLargestAxisDimension(dimensions) {
Expand Down
2 changes: 1 addition & 1 deletion applications/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ var metadata = { "applications":
"isActive": true,
"directory": "domainMapper",
"name": "Domain Mapper",
"description": "Generate a 3D miniature representation of your domain's zones. Useful if you have many 'Places' in your domain and are trying to visualize where you can add new ones. The domain overview can also be used in parallel with the 'Create' application to help you adjust kilometers wide zones. (It refreshes every 5 seconds.)",
"description": "Generate a 3D miniature representation of your domain's zones. Useful if you have many 'Places' in your domain and are trying to visualize where you can add new ones. The domain overview can also be used in parallel with the 'Create' application to help you adjust kilometers wide zones. This tool also displays where are the avatars in the domain. (It refreshes every 5 seconds.)",
"jsfile": "domainMapper/app-domainMapper.js",
"icon": "domainMapper/icon_inactive_white.png",
"caption": "DOMAP"
Expand Down

0 comments on commit ae8b3d6

Please sign in to comment.