tweaks to animation script example

This commit is contained in:
ZappoMan 2014-05-14 13:08:32 -07:00
parent 7c44162209
commit 0a8dc78c96

View file

@ -37,9 +37,6 @@ var originalProperties = {
animationIsPlaying: true, animationIsPlaying: true,
}; };
var positionDelta = { x: 0, y: 0, z: 0 };
var modelID = Models.addModel(originalProperties); var modelID = Models.addModel(originalProperties);
print("Models.addModel()... modelID.creatorTokenID = " + modelID.creatorTokenID); print("Models.addModel()... modelID.creatorTokenID = " + modelID.creatorTokenID);
@ -47,24 +44,17 @@ var isPlaying = true;
var playPauseEveryWhile = 360; var playPauseEveryWhile = 360;
var animationFPS = 30; var animationFPS = 30;
var adjustFPSEveryWhile = 120; var adjustFPSEveryWhile = 120;
var resetFrameEveryWhile = 600;
function moveModel(deltaTime) { function moveModel(deltaTime) {
var somethingChanged = false;
//print("count =" + count);
print("(count % playPauseEveryWhile)=" + (count % playPauseEveryWhile));
if (count % playPauseEveryWhile == 0) { if (count % playPauseEveryWhile == 0) {
isPlaying = !isPlaying; isPlaying = !isPlaying;
print("isPlaying=" + isPlaying); print("isPlaying=" + isPlaying);
somethingChanged = true;
} }
print("(count % adjustFPSEveryWhile)=" + (count % adjustFPSEveryWhile));
if (count % adjustFPSEveryWhile == 0) { if (count % adjustFPSEveryWhile == 0) {
print("considering adjusting animationFPS=" + animationFPS);
if (animationFPS == 30) { if (animationFPS == 30) {
animationFPS = 10; animationFPS = 10;
} else if (animationFPS == 10) { } else if (animationFPS == 10) {
@ -75,6 +65,12 @@ print("considering adjusting animationFPS=" + animationFPS);
print("animationFPS=" + animationFPS); print("animationFPS=" + animationFPS);
isPlaying = true; isPlaying = true;
print("always start playing if we change the FPS -- isPlaying=" + isPlaying); print("always start playing if we change the FPS -- isPlaying=" + isPlaying);
somethingChanged = true;
}
if (count % resetFrameEveryWhile == 0) {
resetFrame = true;
somethingChanged = true;
} }
if (count >= moveUntil) { if (count >= moveUntil) {
@ -99,20 +95,17 @@ print("considering adjusting animationFPS=" + animationFPS);
//print("modelID.creatorTokenID = " + modelID.creatorTokenID); //print("modelID.creatorTokenID = " + modelID.creatorTokenID);
if (true) { if (somethingChanged) {
var newProperties = { var newProperties = {
//position: {
// x: originalProperties.position.x + (count * positionDelta.x),
// y: originalProperties.position.y + (count * positionDelta.y),
// z: originalProperties.position.z + (count * positionDelta.z)
//},
animationIsPlaying: isPlaying, animationIsPlaying: isPlaying,
animationFPS: animationFPS, animationFPS: animationFPS,
}; };
if (resetFrame) {
//print("modelID = " + modelID); print("resetting the frame!");
//print("newProperties.position = " + newProperties.position.x + "," + newProperties.position.y+ "," + newProperties.position.z); newProperties.animationFrameIndex = 0;
resetFrame = false;
}
Models.editModel(modelID, newProperties); Models.editModel(modelID, newProperties);
} }