webgl-operate icon indicating copy to clipboard operation
webgl-operate copied to clipboard

TextureCube.data ignores clearOnUndefined

Open lukaswagner opened this issue 4 years ago • 0 comments

The parameter is used e.g. by resize to indicate that empty data should be assigned in order to actually change the buffer size. Instead, nothing happens since no data is passed. This results in resize not resizing the texture.

Expected usage of resize:

this._texture.resize(this._resolution, true, true);

This does not resize the texture, as the buffers are unaffected.

Workaround for resizing a TextureCube - manually setting new buffers:

this._texture.resize(this._resolution, true, false);
const size = 4 * this._resolution * this._resolution; // for RGBA tex
this._texture.data({
    clearOnUndefined: true,
    positiveX: new Uint8Array(size),
    negativeX: new Uint8Array(size),
    positiveY: new Uint8Array(size),
    negativeY: new Uint8Array(size),
    positiveZ: new Uint8Array(size),
    negativeZ: new Uint8Array(size),
}, 0, false, true);

lukaswagner avatar Jun 16 '20 11:06 lukaswagner