content/hifi-content/lincoln/img/EntityScript.js
2022-02-14 02:04:11 +01:00

58 lines
No EOL
1.7 KiB
JavaScript

(function() {
var _this;
var soundInjector = null;
// var RANGE = 5.0;
// var AUDIO_RANGE = 0.5 * RANGE;
// var cameraAxis = Quat.getFront(Camera.getOrientation());
// var audioPosition = Vec3.sum(Camera.getPosition(), Vec3.multiply(AUDIO_RANGE, cameraAxis));
// TODO: Fix audio location
var audioOptions = { volume: 0.9, position: Camera.getPosition()};
var bassSound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/lincoln/RIDE01.wav");
var RUNNING_ANIMATION_PROPERTIES = {
"url":"https://hifi-content.s3.amazonaws.com/ozan/dev/props/drum_set/cymbal_anim/cymbal_anim.fbx",
"fps":30,
"currentFrame":0,
"running":true,
"loop":false,
"firstFrame":0,
"lastFrame":10,
"hold":0
};
function playAudio(clip) {
soundInjector = Audio.playSound(clip, audioOptions);
}
Cymbal = function() {
_this = this;
};
Cymbal.prototype = {
entityID: null,
preload: function(entityID) {
_this.entityID = entityID;
},
clickReleaseOnEntity: function(entityID, mouseEvent) {
if (mouseEvent.isLeftButton) {
Entities.editEntity(_this.entityID, {
animation: RUNNING_ANIMATION_PROPERTIES
});
playAudio(bassSound);
}
},
collisionWithEntity: function(me, otherEntity) {
print("Collided!")
//print(me, otherEntity)
//print("Obj 1: " + myID + "Obj 2: " + otherID + "Collision: " + Collision)
//playAudio(bassSound);
}
};
return new Cymbal();
});