Advertisement
tymonr

babylon-sprite-manager-sprites-link.js

Mar 4th, 2020
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     /**
  2.      * Applies value for 4 sprite vertices
  3.      *
  4.      * @param {number} index first vertex index also sprite index
  5.      * @param {number} offset prop offset for value
  6.      * @param {*} value value to write (into Foat32Array[])
  7.      * @example
  8.      * const posIndecies = {x:0, y: 1, z: 2};
  9.      *
  10.      * //sets x pos. you can wrap it into any function, getter/setter or whatever
  11.      * manager.applyPropForVerties(sprite.index, posIndecies.x, 42.0); //x
  12.      */
  13.     applyPropForVerties(index, offset, value) {
  14.         const apply = (vertindex) => {
  15.             const globalOffset = vertindex * BabylonSprite.vertexStrideSize;
  16.             this._vertexData[globalOffset + offset] = value;
  17.         };
  18.  
  19.         apply(index * 4 + 0);
  20.         apply(index * 4 + 1);
  21.         apply(index * 4 + 2);
  22.         apply(index * 4 + 3);
  23.  
  24.         this.dirty = true;
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement