110 lines
No EOL
3.6 KiB
JavaScript
110 lines
No EOL
3.6 KiB
JavaScript
//
|
|
// zoneEnterShowAvatarOptions.js
|
|
// (c) 2018 High Fidelity
|
|
// Licensed under the Apache 2.0 License
|
|
//
|
|
|
|
(function() {
|
|
|
|
var avatarList = [];
|
|
|
|
var AVATAR_FST_URLS = [
|
|
|
|
// Peter
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/doob/peter_rubin/socialAvatar/Altspace_Peter.fst",
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/doob/peter_rubin/socialAvatar/RecRoom_Peter.fst",
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/doob/peter_rubin/socialAvatar/FaceBook_Peter.fst",
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/doob/peter_rubin/peter_rubin.fst",
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/Simpson/fst/Chalmers.fst",
|
|
|
|
// Philip
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/doob/peter_rubin/socialAvatar/Altspace_Philip.fst",
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/doob/peter_rubin/socialAvatar/RecRoom_Philip.fst",
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/doob/peter_rubin/socialAvatar/FaceBook_Philip.fst",
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/doob/philip_rosedale/philip_rosedale_Final.fst",
|
|
"https://hifi-content.s3.amazonaws.com/jimi/avatar/Niconico/Jene_5.fst"
|
|
|
|
|
|
];
|
|
|
|
var overlayBaseProperties = {
|
|
name: 'Avatar FST Model',
|
|
animationURL : 'http://hifi-content.s3.amazonaws.com/DomainContent/AvatarStore/BodyMart/idle.fbx',
|
|
animationLoop : true,
|
|
animationRunning: true,
|
|
dimensions: {x: 0.49, y: 0.475, z: 0.18},
|
|
rotation: Quat.fromVec3Degrees({x: 0, y: 180, z: 0})
|
|
};
|
|
|
|
var BASE_POSITION = {
|
|
x: 98.6183,
|
|
y: -0.6548,
|
|
z: 32.4620
|
|
};
|
|
|
|
var overlayClickListener;
|
|
|
|
function switchToAvatar(index) {
|
|
var FST = avatarList[index].url;
|
|
MyAvatar.skeletonModelURL = FST;
|
|
}
|
|
|
|
|
|
function setUpOverlays() {
|
|
var basePosition = JSON.parse(JSON.stringify(BASE_POSITION));
|
|
for (var i = 0; i < AVATAR_FST_URLS.length; i++) {
|
|
var properties = overlayBaseProperties;
|
|
basePosition.x += 0.2;
|
|
properties.position = basePosition;
|
|
properties.url = AVATAR_FST_URLS[i];
|
|
|
|
avatarList.push({
|
|
'overlayID' : Overlays.addOverlay('model', properties),
|
|
'url' : AVATAR_FST_URLS[i]
|
|
});
|
|
}
|
|
}
|
|
|
|
function cleanUpOverlays() {
|
|
for (var i = 0; i < avatarList.length; i++) {
|
|
Overlays.deleteOverlay(avatarList[i].overlayID);
|
|
}
|
|
avatarList = [];
|
|
}
|
|
|
|
function indexOfOverlayInList(overlayID) {
|
|
var index = -1;
|
|
for (var i = 0; i < avatarList.length; i++) {
|
|
if (avatarList[i].overlayID === overlayID) {
|
|
index = i;
|
|
return index;
|
|
}
|
|
}
|
|
return index;
|
|
}
|
|
|
|
function AvatarSwitchingZone() {
|
|
|
|
}
|
|
|
|
AvatarSwitchingZone.prototype = {
|
|
enterEntity : function() {
|
|
setUpOverlays();
|
|
overlayClickListener = Overlays.mousePressOnOverlay.connect(function(overlayID, event){
|
|
var index = indexOfOverlayInList(overlayID);
|
|
if (index !== -1) {
|
|
print ("This should match");
|
|
switchToAvatar(index);
|
|
} else {
|
|
print ("Not a match");
|
|
}
|
|
});
|
|
},
|
|
leaveEntity : function() {
|
|
cleanUpOverlays();
|
|
Overlays.mousePressOnOverlay.disconnect(overlayClickListener);
|
|
}
|
|
};
|
|
|
|
return new AvatarSwitchingZone();
|
|
}); |