Exemple #1
0
var createTexture = function ( size ) {
    var texture = new Texture();
    texture.setTextureSize( size.width, size.height );
    texture.setMinFilter( 'LINEAR' );
    texture.setMagFilter( 'LINEAR' );
    return texture;
};
Exemple #2
0
var createTextureRtt = function ( rttSize ) {
    var rttTexture = new Texture();
    rttTexture.setTextureSize( rttSize[ 0 ], rttSize[ 1 ] );
    rttTexture.setMinFilter( 'LINEAR' );
    rttTexture.setMagFilter( 'LINEAR' );
    return rttTexture;
};
        _createTexture: function(name, divisor, type, filter) {
            var texture = new Texture();
            texture.setTextureSize(1, 1);
            texture.setInternalFormatType(type);

            // not always necessary to have 4 channels, might be interesting to set it in pass
            texture.setInternalFormat(Texture.RGBA);

            texture.setMinFilter(filter);
            texture.setMagFilter(filter);

            texture.divisor = divisor;
            texture.setName(name);

            return texture;
        },
Exemple #4
0
 drawText: function () {
     if ( this._geometry !== undefined ) {
         this._matrixTransform.removeChild( this._geometry );
         // The text could be dynamic, so we need to remove GL objects
         this._geometry.releaseGLObjects();
     }
     if ( !this._text ) return;
     this.setTextProperties();
     this._canvas.width = this._context.measureText( this._text ).width;
     this._canvas.height = this._fontSize * 2;
     // For devices not supporting NPOT textures
     if ( this._forcePowerOfTwo ) {
         this._canvas.width = this._nextPowerOfTwo( this._canvas.width );
         this._canvas.height = this._nextPowerOfTwo( this._canvas.height );
     }
     // We need to set the text properties again, as the canvas size cold change.
     this.setTextProperties();
     this._context.clearRect( 0, 0, this._canvas.width, this._canvas.height );
     this._context.fillText( this._text, this._textX, this._textY );
     // Right now we set the pivot point to center, to assure the bounding box is correct when rendering billboards.
     // TODO: Possibility to set different pivot point so we can have missing alignments.
     var aspectRatio = this._canvas.width / this._canvas.height;
     var quadWidth = this._charactherSize * aspectRatio;
     this._geometry = Shape.createTexturedQuadGeometry( -quadWidth / 2, -this._charactherSize / 2, 0, quadWidth, 0, 0, 0, this._charactherSize, 0 );
     // create a texture to attach the canvas2D
     var texture = new Texture();
     texture.setTextureSize( this._canvas.width, this._canvas.height );
     texture.setMinFilter( 'LINEAR' );
     texture.setMagFilter( 'LINEAR' );
     texture.setImage( this._canvas );
     // Transparency stuff
     var stateset = this._geometry.getOrCreateStateSet();
     stateset.setTextureAttributeAndModes( 0, texture );
     stateset.setRenderingHint( 'TRANSPARENT_BIN' );
     stateset.setAttributeAndModes( new BlendFunc( BlendFunc.ONE, BlendFunc.ONE_MINUS_SRC_ALPHA ) );
     this._matrixTransform.addChild( this._geometry );
     this.dirtyBound();
 },