content/hifi-content/elisalj/hack_week/fullZebra.js
2022-02-13 23:16:46 +01:00

48 lines
No EOL
1.7 KiB
JavaScript

///
/// fullZebra.js
/// A script to reset zebra to default states
///
/// Author: Elisa Lupin-Jimenez
/// Copyright High Fidelity 2017
///
/// Licensed under the Apache 2.0 License
/// See accompanying license file or http://apache.org/
///
/// All assets are under CC Attribution Non-Commerical
/// http://creativecommons.org/licenses/
///
(function() {
var sound;
var DEFAULT_SIZE = {x: 0.5444, y: 0.8658, z: 0.8925};
var DEFAULT_ANIMATION = "https://hifi-content.s3.amazonaws.com/elisalj/hack_week/zebra_simple_large.fbx";
var zebraProps;
this.preload = function(entityID) {
print("loading zebra filling script");
sound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/elisalj/hack_week/zebra-sounds/zebra5.wav");
zebraProps = Entities.getEntityProperties(entityID, ["position", "dimensions", "animation"]);
};
var gotTooBig = function() {
print("zebra munched");
if (zebraProps.dimensions.x > 1) {
print("oh no zebra is too full");
Audio.playSound(sound, { position: zebraProps.position, volume: 0.80, loop: false });
zebraProps.animation.url = "https://hifi-content.s3.amazonaws.com/elisalj/hack_week/zebra_done.fbx";
zebraProps.animation.loop = false;
Entities.editEntity(zebraProps.id, zebraProps);
Script.setTimeout(function() {
zebraProps.dimensions = DEFAULT_SIZE;
zebraProps.animation.url = DEFAULT_ANIMATION;
zebraProps.animation.loop = true;
Entities.editEntity(zebraProps.id, zebraProps);
}, 2000);
}
};
})