* Initializes common texture parameters, creates a gl texture, * tries to upload the texture for the first time if data is * already available.
(textureData)
| 127 | * already available. |
| 128 | */ |
| 129 | init(textureData) { |
| 130 | if (!this.isFramebufferTexture) { |
| 131 | this.textureHandle = this._renderer.createTexture({ |
| 132 | format: this.format, |
| 133 | dataType: this.dataType, |
| 134 | width: textureData.width, |
| 135 | height: textureData.height, |
| 136 | }); |
| 137 | } else { |
| 138 | this.textureHandle = this._renderer.createFramebufferTextureHandle(this.src); |
| 139 | } |
| 140 | |
| 141 | this._renderer.setTextureParams(this, { |
| 142 | minFilter: this.minFilter, |
| 143 | magFilter: this.magFilter, |
| 144 | wrapS: this.wrapS, |
| 145 | wrapT: this.wrapT |
| 146 | }); |
| 147 | |
| 148 | this.bindTexture(); |
| 149 | |
| 150 | if (this._shouldDeferUpload()) { |
| 151 | this._renderer.uploadTextureFromData( |
| 152 | this.textureHandle, |
| 153 | new Uint8Array(1, 1, 1, 1), |
| 154 | 1, |
| 155 | 1 |
| 156 | ); |
| 157 | } else if (!this.isFramebufferTexture) { |
| 158 | // this.update() |
| 159 | this._renderer.uploadTextureFromSource( |
| 160 | this.textureHandle, |
| 161 | textureData |
| 162 | ); |
| 163 | } |
| 164 | |
| 165 | this.unbindTexture(); |
| 166 | } |
| 167 | |
| 168 | _shouldDeferUpload() { |
| 169 | return ( |
no test coverage detected