tymonr icon

babylon-sprite-manager-sprites-link.js

tymonr | PRO | 03/04/20 08:02:35 PM UTC | 0 ⭐ | 510 👁️ | Never ⏰ | []
JavaScript |

770 B

|

None

|

0 👍

/

0 👎

    /**
     * Applies value for 4 sprite vertices
     *
     * @param {number} index first vertex index also sprite index
     * @param {number} offset prop offset for value
     * @param {*} value value to write (into Foat32Array[])
     * @example
     * const posIndecies = {x:0, y: 1, z: 2};
     * 
     * //sets x pos. you can wrap it into any function, getter/setter or whatever
     * manager.applyPropForVerties(sprite.index, posIndecies.x, 42.0); //x
     */
    applyPropForVerties(index, offset, value) {
        const apply = (vertindex) => {
            const globalOffset = vertindex * BabylonSprite.vertexStrideSize;
            this._vertexData[globalOffset + offset] = value;
        };
 
        apply(index * 4 + 0);
        apply(index * 4 + 1);
        apply(index * 4 + 2);
        apply(index * 4 + 3);
 
        this.dirty = true;
    }

Comments