testing doll animation

This commit is contained in:
ericrius1 2015-09-28 16:51:23 -07:00
parent 45281f8aae
commit 5e28462e2a
3 changed files with 39 additions and 42 deletions

View file

@ -15,26 +15,14 @@
(function() {
Script.include("../../utilities.js");
Script.include("../../libraries/utils.js");
var _this;
// this is the "constructor" for the entity as a JS object we don't do much here
var Doll = function() {
_this = this;
this.screamSounds = [SoundCache.getSound("https://hifi-public.s3.amazonaws.com/sounds/KenDoll_1%2303.wav")];
};
Doll.prototype = {
startAnimationSetting: JSON.stringify({
running: true,
fps: 30,
loop: false,
// firstFrame: 1,
// lastFrame: 65,
startAutomatically: true
}),
stopAnimationSetting: JSON.stringify({
running: false,
frameIndex: 1,
lastFrame: 10000
}),
audioInjector: null,
isGrabbed: false,
setLeftHand: function() {
@ -46,41 +34,50 @@
},
startNearGrab: function() {
if (this.isGrabbed === false) {
// if (this.isGrabbed === false) {
print("START GRAB")
Entities.editEntity(this.entityID, {
animationURL: "https://hifi-public.s3.amazonaws.com/models/Bboys/zombie_scream.fbx",
animationFrameIndex: 0
});
Entities.editEntity(this.entityID, {
animationURL: "https://hifi-public.s3.amazonaws.com/models/Bboys/zombie_scream.fbx",
animationSettings: this.startAnimationSetting
});
Entities.editEntity(_this.entityID, {
animationIsPlaying: true
})
var position = Entities.getEntityProperties(this.entityID, "position").position;
this.audioInjector = Audio.playSound(this.screamSounds[randInt(0, this.screamSounds.length)], {
position: position,
volume: 0.1
});
var position = Entities.getEntityProperties(this.entityID, "position").position;
this.audioInjector = Audio.playSound(this.screamSounds[randInt(0, this.screamSounds.length)], {
position: position,
volume: 0.1
});
this.isGrabbed = true;
this.initialHand = this.hand;
}
this.isGrabbed = true;
this.initialHand = this.hand;
},
continueNearGrab: function() {
var props = Entities.getEntityProperties(this.entityID, "position");
var props = Entities.getEntityProperties(this.entityID, ["position", "animationFrameIndex"]);
var audioOptions = {
position: props.position
};
this.audioInjector.options = audioOptions;
// print("ANIMATION FRAME INDEX " + props.animationFrameIndex)
},
releaseGrab: function() {
if (this.isGrabbed === true && this.hand === this.initialHand) {
print("RELEASE GRAB")
this.audioInjector.stop();
Entities.editEntity(this.entityID, {
animationSettings: this.stopAnimationSetting,
animationIsPlaying: false,
animationURL: "http://hifi-public.s3.amazonaws.com/models/Bboys/bboy2/bboy2.fbx",
// animationSettings: this.stopAnimationSetting,
animationFrameIndex: 0
});
Entities.editEntity(this.entityID, {
animationURL: "http://hifi-public.s3.amazonaws.com/models/Bboys/bboy2/bboy2.fbx"
});
this.isGrabbed = false;
var frameIndex = Entities.getEntityProperties(this.entityID, {})
@ -92,6 +89,7 @@
// it gives us a chance to set our local JavaScript object up. In this case it means:
// * remembering our entityID, so we can access it in cases where we're called without an entityID
this.entityID = entityID;
this.lastFrame = 80;
},
};
// entity scripts always need to return a newly constructed object of our type

View file

@ -25,11 +25,11 @@ deleteAllToys();
createAllToys();
function createAllToys() {
createBlocks({
x: 548.3,
y: 495.55,
z: 504.4
});
// createBlocks({
// x: 548.3,
// y: 495.55,
// z: 504.4
// });
createSprayCan({
x: 549.7,
@ -661,9 +661,9 @@ function createBlocks(position) {
});
//customKey, id, data
setEntityCustomData(resetKey, entity, {
resetMe: true
});
// setEntityCustomData(resetKey, entity, {
// resetMe: true
// });
}
}
}

View file

@ -13,7 +13,7 @@
x: 0,
y: 0,
z: 0
}
};
// if the trigger value goes below this while held, the can will stop spraying. if it goes above, it will spray
var DISABLE_SPRAY_THRESHOLD = 0.7;
@ -98,7 +98,6 @@
}
this.disableStream = function() {
print("DEKETE STEREAAAM")
Entities.deleteEntity(this.paintStream);
this.paintStream = null;
this.sprayInjector.stop();