65 lines
No EOL
2.4 KiB
JavaScript
65 lines
No EOL
2.4 KiB
JavaScript
(function () {
|
|
print("Testing Azure Function Call");
|
|
var FUNCTION_URL = "https://sendanentity.azurewebsites.net/api/HttpTriggerJS/";
|
|
var _this;
|
|
var textDisplayEntityID = "{67f692c0-068b-4da1-83d9-a636f3ab39d4}";
|
|
|
|
AzureFunctionObject = function () {
|
|
_this = this;
|
|
}
|
|
|
|
AzureFunctionObject.prototype = {
|
|
preload: function (entityID) {
|
|
_this.entityID = entityID;
|
|
},
|
|
clickDownOnEntity: function () {
|
|
print("Requesting heart count");
|
|
var req = new XMLHttpRequest();
|
|
req.open("GET", FUNCTION_URL + "?user=MissLiviRose");
|
|
req.onreadystatechange = function () {
|
|
if (req.readyState === 4) {
|
|
if (req.status === 200) {
|
|
print(JSON.stringify(req.response));
|
|
var text = "You have: " + JSON.parse(req.response) + " hearts";
|
|
print("Success! " + text);
|
|
var property = {"text" : text};
|
|
Entities.editEntity(textDisplayEntityID, property);
|
|
var hearts = CreateHeartParticleEffect(JSON.parse(req.response));
|
|
}
|
|
else {
|
|
print(req.status);
|
|
}
|
|
}
|
|
}
|
|
req.send("");
|
|
},
|
|
reqListener: function() {
|
|
var property = {text: "I heard something! " + Math.random()};
|
|
Entities.editEntity(textDisplayEntityID, property);
|
|
}
|
|
};
|
|
|
|
var CreateHeartParticleEffect = function(count) {
|
|
|
|
var heartsProperties = {
|
|
type : "ParticleEffect",
|
|
isEmitting: true,
|
|
position: Entities.getEntityProperties(_this.entityID).position,
|
|
lifetime : count/2,
|
|
"maxParticles" : count,
|
|
"textures" : "https://hifi-content.s3.amazonaws.com/liv/Particles/HeartParticle.png",
|
|
"emitRate" : 2,
|
|
"lifespan" : 0.5,
|
|
"accelerationSpread" : "{x: 0.5, y:1, z:0.5}",
|
|
"emitAcceleration" : "{x: -0.5, y:2.5, z:0.5}",
|
|
"particleRadius" : 0.1,
|
|
"radiusStart" : 0.1,
|
|
"radiusFinish" : 0.1
|
|
};
|
|
return Entities.addEntity(heartsProperties);
|
|
|
|
}
|
|
|
|
return new AzureFunctionObject();
|
|
|
|
}) |