mirror of
https://github.com/overte-org/overte.git
synced 2025-08-12 01:18:26 +02:00
Cleaned up Polaroid code
This commit is contained in:
parent
4e190434d1
commit
655a411865
4 changed files with 67 additions and 71 deletions
|
@ -30,7 +30,7 @@
|
||||||
<input type="button" id="snap-button" onclick="takeSnapshot()" />
|
<input type="button" id="snap-button" onclick="takeSnapshot()" />
|
||||||
<div id="snap-settings-right">
|
<div id="snap-settings-right">
|
||||||
<button type="image" class="blueButton" id="print-button" onclick="printToPolaroid()">
|
<button type="image" class="blueButton" id="print-button" onclick="printToPolaroid()">
|
||||||
<div id="print-icon" class="print-icon-enabled">
|
<div id="print-icon" class="print-icon print-icon-default">
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -301,30 +301,23 @@ input[type=button].naked:active {
|
||||||
outline:none;
|
outline:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.print-icon-enabled {
|
.print-icon {
|
||||||
background: url(../img/button-snap-print.svg);
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
margin: auto;
|
margin: auto;
|
||||||
width: 48px;
|
}
|
||||||
height: 48px;
|
|
||||||
|
.print-icon-default {
|
||||||
|
background: url(../img/button-snap-print.svg) no-repeat;
|
||||||
|
margin-right: -1px;
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.print-icon-loading {
|
.print-icon-loading {
|
||||||
background: url(../img/loader.gif);
|
background: url(../img/loader.gif) no-repeat;
|
||||||
background-repeat: no-repeat;
|
|
||||||
margin: auto;
|
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.print-icon-disabled {
|
|
||||||
background: url(../img/button-snap-print.svg);
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
margin: auto;
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// END polaroid styling
|
// END polaroid styling
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -311,13 +311,17 @@ function addImage(image_data, isLoggedIn, canShare, isGifLoading, isShowingPrevi
|
||||||
if (isShowingPreviousImages && isLoggedIn && image_data.story_id) {
|
if (isShowingPreviousImages && isLoggedIn && image_data.story_id) {
|
||||||
updateShareInfo(id, image_data.story_id);
|
updateShareInfo(id, image_data.story_id);
|
||||||
}
|
}
|
||||||
if(isShowingPreviousImages) {
|
if (isShowingPreviousImages) {
|
||||||
requestPrintButtonUpdate();
|
requestPrintButtonUpdate();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
img.onerror = function () {
|
img.onerror = function () {
|
||||||
img.onload = null;
|
img.onload = null;
|
||||||
img.src = image_data.errorPath;
|
img.src = image_data.errorPath;
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "snapshot",
|
||||||
|
action: "alertSnapshotLoadFailed"
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function showConfirmationMessage(selectedID, destination) {
|
function showConfirmationMessage(selectedID, destination) {
|
||||||
|
@ -718,23 +722,30 @@ function takeSnapshot() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPrintDisabled() { return document.getElementById('print-icon').className === "print-icon-disabled"; }
|
function isPrintDisabled() {
|
||||||
function isPrintProcessing() { return document.getElementById('print-icon').className === "print-icon-loading"; }
|
return document.getElementById('print-icon').className === "print-icon print-icon-default" &&
|
||||||
function isPrintEnabled() { return document.getElementById('print-icon').className === "print-icon-enabled"; }
|
document.getElementById('print-button').disabled;
|
||||||
|
}
|
||||||
|
function isPrintProcessing() {
|
||||||
|
return document.getElementById('print-icon').className === "print-icon print-icon-loading" &&
|
||||||
|
document.getElementById('print-button').disabled;
|
||||||
|
}
|
||||||
|
function isPrintEnabled() {
|
||||||
|
return document.getElementById('print-icon').className === "print-icon print-icon-default" &&
|
||||||
|
!document.getElementById('print-button').disabled;
|
||||||
|
}
|
||||||
|
|
||||||
function setPrintButtonLoading() {
|
function setPrintButtonLoading() {
|
||||||
document.getElementById('print-icon').className = "print-icon-loading";
|
document.getElementById('print-icon').className = "print-icon print-icon-loading";
|
||||||
document.getElementById('print-button').disabled = true;
|
document.getElementById('print-button').disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPrintButtonDisabled() {
|
function setPrintButtonDisabled() {
|
||||||
document.getElementById('print-icon').className = "print-icon-disabled";
|
document.getElementById('print-icon').className = "print-icon print-icon-default";
|
||||||
document.getElementById('print-button').disabled = true;
|
document.getElementById('print-button').disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPrintButtonEnabled() {
|
function setPrintButtonEnabled() {
|
||||||
document.getElementById('print-button').disabled = false;
|
document.getElementById('print-button').disabled = false;
|
||||||
document.getElementById('print-icon').className = "print-icon-enabled";
|
document.getElementById('print-icon').className = "print-icon print-icon-default";
|
||||||
}
|
}
|
||||||
|
|
||||||
function requestPrintButtonUpdate() {
|
function requestPrintButtonUpdate() {
|
||||||
|
@ -744,15 +755,12 @@ function requestPrintButtonUpdate() {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function printToPolaroid() {
|
function printToPolaroid() {
|
||||||
|
if (isPrintEnabled()) {
|
||||||
if (isPrintEnabled()) {
|
|
||||||
|
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "printToPolaroid"
|
action: "printToPolaroid"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//shareBarHelp.innerHTML = "Printed"
|
//shareBarHelp.innerHTML = "Printed"
|
||||||
//shareBarHelp.style.backgroundColor = "#000000";
|
//shareBarHelp.style.backgroundColor = "#000000";
|
||||||
//shareBarHelp.style.opacity = "0.5";
|
//shareBarHelp.style.opacity = "0.5";
|
||||||
|
@ -760,6 +768,7 @@ function printToPolaroid() {
|
||||||
setPrintButtonLoading();
|
setPrintButtonLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testInBrowser(test) {
|
function testInBrowser(test) {
|
||||||
if (test === 0) {
|
if (test === 0) {
|
||||||
showSetupInstructions();
|
showSetupInstructions();
|
||||||
|
|
|
@ -142,13 +142,13 @@ function onMessage(message) {
|
||||||
break;
|
break;
|
||||||
case 'shareSnapshotForUrl':
|
case 'shareSnapshotForUrl':
|
||||||
isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) {
|
isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) {
|
||||||
if (canShare) {
|
var isGif = fileExtensionMatches(message.data, "gif");
|
||||||
isLoggedIn = Account.isLoggedIn();
|
isLoggedIn = Account.isLoggedIn();
|
||||||
|
isUploadingPrintableStill = canShare && Account.isLoggedIn() && !isGif;
|
||||||
|
if (canShare) {
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
print('Sharing snapshot with audience "for_url":', message.data);
|
print('Sharing snapshot with audience "for_url":', message.data);
|
||||||
isUploadingPrintableStill = true;
|
Window.shareSnapshot(message.data, Settings.getValue("previousSnapshotHref"));
|
||||||
Window.shareSnapshot(message.data, Settings.getValue("previousSnapshotHref"));
|
|
||||||
var isGif = fileExtensionMatches(message.data, "gif");
|
|
||||||
if (isGif) {
|
if (isGif) {
|
||||||
numGifSnapshotUploadsPending++;
|
numGifSnapshotUploadsPending++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -156,14 +156,10 @@ function onMessage(message) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
shareAfterLogin = true;
|
shareAfterLogin = true;
|
||||||
isUploadingPrintableStill = false;
|
|
||||||
snapshotToShareAfterLogin.push({ path: message.data, href: Settings.getValue("previousSnapshotHref") });
|
snapshotToShareAfterLogin.push({ path: message.data, href: Settings.getValue("previousSnapshotHref") });
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
isUploadingPrintableStill = false;
|
|
||||||
}
|
}
|
||||||
|
updatePrintPermissions();
|
||||||
updatePrintPermissions();
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'blastToConnections':
|
case 'blastToConnections':
|
||||||
|
@ -226,13 +222,14 @@ function onMessage(message) {
|
||||||
case 'requestPrintButtonUpdate':
|
case 'requestPrintButtonUpdate':
|
||||||
updatePrintPermissions();
|
updatePrintPermissions();
|
||||||
break;
|
break;
|
||||||
case 'printToPolaroid':
|
case 'printToPolaroid':
|
||||||
|
if (Entities.canRez() || Entities.canRezTmp()) {
|
||||||
if(Entities.canRez() || Entities.canRezTmp()) {
|
|
||||||
printToPolaroid(Settings.getValue("previousStillSnapUrl"));
|
printToPolaroid(Settings.getValue("previousStillSnapUrl"));
|
||||||
removeFromStoryIDsToMaybeDelete(Settings.getValue("previousStillSnapStoryID"));
|
removeFromStoryIDsToMaybeDelete(Settings.getValue("previousStillSnapStoryID"));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 'alertSnapshotLoadFailed':
|
||||||
|
snapshotFailedToLoad = true;
|
||||||
break;
|
break;
|
||||||
case 'shareSnapshotWithEveryone':
|
case 'shareSnapshotWithEveryone':
|
||||||
isLoggedIn = Account.isLoggedIn();
|
isLoggedIn = Account.isLoggedIn();
|
||||||
|
@ -285,10 +282,9 @@ var polaroid_print_sound = SoundCache.getSound(Script.resolvePath("assets/sounds
|
||||||
var model_url = 'http://hifi-content.s3.amazonaws.com/alan/dev/Test/snapshot.fbx';
|
var model_url = 'http://hifi-content.s3.amazonaws.com/alan/dev/Test/snapshot.fbx';
|
||||||
|
|
||||||
function printToPolaroid(image_url) {
|
function printToPolaroid(image_url) {
|
||||||
|
|
||||||
var polaroid_url = image_url;
|
var polaroid_url = image_url;
|
||||||
|
|
||||||
var model_pos = Vec3.sum(MyAvatar.position, Vec3.multiply(0.75, Quat.getForward(MyAvatar.orientation)));
|
var model_pos = Vec3.sum(MyAvatar.position, Vec3.multiply(1.25, Quat.getForward(MyAvatar.orientation)));
|
||||||
|
|
||||||
var model_q1 = MyAvatar.orientation;
|
var model_q1 = MyAvatar.orientation;
|
||||||
var model_q2 = Quat.angleAxis(90, Quat.getRight(model_q1));
|
var model_q2 = Quat.angleAxis(90, Quat.getRight(model_q1));
|
||||||
|
@ -297,25 +293,26 @@ function printToPolaroid(image_url) {
|
||||||
var properties = {
|
var properties = {
|
||||||
"type": 'Model',
|
"type": 'Model',
|
||||||
"shapeType": 'box',
|
"shapeType": 'box',
|
||||||
|
|
||||||
"name": "New Snapshot",
|
"name": "New Snapshot",
|
||||||
"description": "Printed from Snaps",
|
"description": "Printed from Snaps",
|
||||||
"modelURL": model_url,
|
"modelURL": model_url,
|
||||||
|
|
||||||
"position": model_pos,
|
"position": model_pos,
|
||||||
"rotation": model_rot,
|
"rotation": model_rot,
|
||||||
|
|
||||||
"textures": JSON.stringify( { "tex.picture": polaroid_url } ),
|
"textures": JSON.stringify( { "tex.picture": polaroid_url } ),
|
||||||
|
|
||||||
"density": 200,
|
"density": 200,
|
||||||
"restitution": 0.15,
|
"restitution": 0.15,
|
||||||
"gravity": { "x": 0, "y": -1, "z": 0 },
|
"gravity": { "x": 0, "y": -4.5, "z": 0 },
|
||||||
|
|
||||||
"linear_accleration" : { "x": 0, "y": 2.0, "z": 0 },
|
"velocity": { "x": 0, "y": 3.5, "z": 0 },
|
||||||
|
"angularVelocity": { "x": -1.0, "y": 0, "z": -1.3 },
|
||||||
|
|
||||||
"dynamic": true,
|
"dynamic": true,
|
||||||
"collisionsWillMove": true,
|
"collisionsWillMove": true,
|
||||||
|
|
||||||
"userData": {
|
"userData": {
|
||||||
"grabbableKey": { "grabbable" : true }
|
"grabbableKey": { "grabbable" : true }
|
||||||
}
|
}
|
||||||
|
@ -442,7 +439,10 @@ function takeSnapshot() {
|
||||||
Settings.setValue("previousAnimatedSnapBlastingDisabled", false);
|
Settings.setValue("previousAnimatedSnapBlastingDisabled", false);
|
||||||
Settings.setValue("previousAnimatedSnapHifiSharingDisabled", false);
|
Settings.setValue("previousAnimatedSnapHifiSharingDisabled", false);
|
||||||
|
|
||||||
isUploadingPrintableStill = false;
|
// Since we are taking a snapshot, we should make the print button appear to be loading/processing
|
||||||
|
snapshotFailedToLoad = false;
|
||||||
|
isUploadingPrintableStill = true;
|
||||||
|
updatePrintPermissions();
|
||||||
|
|
||||||
// Raising the desktop for the share dialog at end will interact badly with clearOverlayWhenMoving.
|
// Raising the desktop for the share dialog at end will interact badly with clearOverlayWhenMoving.
|
||||||
// Turn it off now, before we start futzing with things (and possibly moving).
|
// Turn it off now, before we start futzing with things (and possibly moving).
|
||||||
|
@ -514,7 +514,6 @@ function isDomainOpen(id, callback) {
|
||||||
status = response.total_entries ? true : false;
|
status = response.total_entries ? true : false;
|
||||||
}
|
}
|
||||||
print("Domain open status:", status);
|
print("Domain open status:", status);
|
||||||
wasPreviousSnapshotShareable = status;
|
|
||||||
callback(status);
|
callback(status);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -677,11 +676,8 @@ function onUsernameChanged() {
|
||||||
numStillSnapshotUploadsPending++;
|
numStillSnapshotUploadsPending++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
isUploadingPrintableStill = true;
|
|
||||||
} else {
|
|
||||||
isUploadingPrintableStill = false;
|
|
||||||
}
|
}
|
||||||
|
isUploadingPrintableStill = canShare;
|
||||||
updatePrintPermissions();
|
updatePrintPermissions();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -704,19 +700,15 @@ function updatePrintPermissions() {
|
||||||
processRezPermissionChange(Entities.canRez() || Entities.canRezTmp());
|
processRezPermissionChange(Entities.canRez() || Entities.canRezTmp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var snapshotFailedToLoad = false;
|
||||||
var isUploadingPrintableStill = false;
|
var isUploadingPrintableStill = false;
|
||||||
function processRezPermissionChange(canRez) {
|
function processRezPermissionChange(canRez) {
|
||||||
|
|
||||||
print('can we rez0?' + canRez);
|
|
||||||
print('can we rez1?' + Settings.getValue("previousStillSnapUrl")) ;
|
|
||||||
print('can we rez2?' + isUploadingPrintableStill);
|
|
||||||
|
|
||||||
var action = "";
|
var action = "";
|
||||||
|
|
||||||
if(canRez) {
|
if (canRez && !snapshotFailedToLoad) {
|
||||||
if(Settings.getValue("previousStillSnapUrl")) {
|
if (Settings.getValue("previousStillSnapUrl")) {
|
||||||
action = 'setPrintButtonEnabled';
|
action = 'setPrintButtonEnabled';
|
||||||
} else if(isUploadingPrintableStill) {
|
} else if (isUploadingPrintableStill) {
|
||||||
action = 'setPrintButtonLoading';
|
action = 'setPrintButtonLoading';
|
||||||
} else {
|
} else {
|
||||||
action = 'setPrintButtonDisabled';
|
action = 'setPrintButtonDisabled';
|
||||||
|
@ -725,6 +717,8 @@ function processRezPermissionChange(canRez) {
|
||||||
action = 'setPrintButtonDisabled';
|
action = 'setPrintButtonDisabled';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print(action);
|
||||||
|
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
tablet.emitScriptEvent(JSON.stringify({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action : action
|
action : action
|
||||||
|
|
Loading…
Reference in a new issue