From a0f221e2d52915abb92f32757c9887dab95aebc1 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Fri, 16 Feb 2018 12:43:58 +0100 Subject: [PATCH] Update: CC - Demo New - Entity Loaded (tuby5lj4di.js) 553 bytes modified --- tuby5lj4di.js | 80 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 26 deletions(-) diff --git a/tuby5lj4di.js b/tuby5lj4di.js index b994881..5a69e47 100644 --- a/tuby5lj4di.js +++ b/tuby5lj4di.js @@ -154,10 +154,10 @@ GameLib.CustomCode.prototype.generateAnimationVectors = function(attributeData) var i; - this.updateInformation = []; - + this.updateInformation = []; + for (i = 0; i < this.offsetAttribute.count; i++) { - + this.updateInformation.push( { offset : { @@ -186,39 +186,67 @@ GameLib.CustomCode.prototype.generateAnimationVectors = function(attributeData) } } ); - - } -}.bind(this); -/** - * Performs the actual update to our instanced geometry - */ -GameLib.CustomCode.prototype.updateAttributeArrays = function(alpha) { - console.log('animation : ' + alpha); + } }.bind(this); /** * Load the next animation */ GameLib.CustomCode.prototype.loadNext = function() { - - this.currentIndex++ - - if (this.currentIndex > this.maxIndex) { - this.currentIndex = 0; - }; - - var attributeData = this.generateAttributeData(this.currentIndex, 128, 128); - this.generateAnimationVectors(attributeData); - - /** - * Notify our render component that we are ready to start animating - */ - this.beforeRender.startAnimation = true; - + this.currentIndex++ + + if (this.currentIndex > this.maxIndex) { + this.currentIndex = 0; + } + + var attributeData = this.generateAttributeData(this.currentIndex, 128, 128); + + this.generateAnimationVectors(attributeData); + + /** + * Notify our render component that we are ready to start animating + */ + this.beforeRender.startAnimation = true; + }.bind(this); +/** + * Performs the actual update to our instanced geometry + */ +GameLib.CustomCode.prototype.updateAttributeArrays = function(alpha) { + + console.log('animation : ' + alpha); + + var i, offset, scale; + + for (i = 0; i < this.updateInformation.length; i++) { + + offset = this.updateInformation[i].offset; + scale = this.updateInformation[i].scale; + + this.offsetAttribute.setXYZ( + i, + offset.current.lerp( + offset.target, + alpha + ) + ); + + this.scaleAttribute.setXYZ( + i, + scale.current.lerp( + scale.target, + alpha + ) + ); + + } + +}.bind(this); + + this.buildInstancedGeometry(0); this.beforeRender.entityLoaded = this;