updating with models in meshes folder

This commit is contained in:
Wayne Chen 2018-09-04 22:17:33 -07:00
parent 1ce6c84c08
commit af1c473a9c
8 changed files with 43 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

View file

@ -625,7 +625,7 @@
"lastEdited": 1536108160862286,
"lastEditedBy": "{4656d4a8-5e61-4230-ab34-2888d7945bd6}",
"locked": true,
"modelURL": "http://hifi-content.s3.amazonaws.com/wayne/models/oopsDialog_protocol.fbx",
"modelURL": Script.resourcesPath() + "meshes/redirect/oopsDialog_protocol.fbx",
"name": "Oops Dialog",
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
"position": {
@ -648,7 +648,7 @@
"y": 0.4957197904586792,
"z": -7.62939453125e-05
},
"script": "https://hifi-content.s3.amazonaws.com/wayne/404redirectionScripts/oopsEntityScript.js",
"script": "https://raw.githubusercontent.com/wayne-chen/hifi/404DomainRedirect/scripts/system/oopsEntityScript.js",
"scriptTimestamp": 1536102551825,
"type": "Model",
"userData": "{\"grabbableKey\":{\"grabbable\":false}}"

View file

@ -0,0 +1,41 @@
(function() {
var PROTOCOL_MISMATCH = 1;
var NOT_AUTHORIZED = 3;
this.entityID = Uuid.NULL;
this.preload = function(entityID) {
this.entityID = entityID;
};
function pingError() {
if(this.entityID === undefined) {
var entities = Entities.findEntitiesByName("Oops Dialog", MyAvatar.position, 10);
if(entities.length > 0) {
this.entityID = entities[0];
}
}
var error = location.lastDomainConnectionError;
var newModel = "";
var hostedSite = Script.resourcesPath() + "meshes/redirect";
if (error === PROTOCOL_MISMATCH) {
newModel = "oopsDialog_protocol";
} else if (error === NOT_AUTHORIZED) {
newModel = "oopsDialog_auth";
} else {
newModel = "oopsDialog_vague";
}
var props = Entities.getEntityProperties(this.entityID, ["modelURL"]);
var newModelURL = hostedSite + newModel + ".fbx";
if(props.modelURL !== newModelURL) {
var newFileURL = newModelURL + "/" + newModel + ".png";
var newTextures = {"file16": newFileURL, "file17": newFileURL};
Entities.editEntity(this.entityID, {modelURL: newModelURL, originalTextures: JSON.stringify(newTextures)});
}
};
var ping = Script.setInterval(pingError, 5000);
function cleanup() {
Script.clearInterval(ping);
};
Script.scriptEnding.connect(cleanup);
});