Skip to content

Commit ac1053e

Browse files
committed
Renderer: Deprecate some async methods.
1 parent 69317a8 commit ac1053e

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/renderers/common/Renderer.js

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,16 +2024,12 @@ class Renderer {
20242024
* @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
20252025
* @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
20262026
* @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
2027-
* @return {Promise} A Promise that resolves when the clear operation has been executed.
2028-
* Only returned when the renderer has not been initialized.
20292027
*/
20302028
clear( color = true, depth = true, stencil = true ) {
20312029

20322030
if ( this._initialized === false ) {
20332031

2034-
warn( 'Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead.' );
2035-
2036-
return this.clearAsync( color, depth, stencil );
2032+
throw new Error( 'Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.' );
20372033

20382034
}
20392035

@@ -2074,52 +2070,44 @@ class Renderer {
20742070

20752071
/**
20762072
* Performs a manual clear operation of the color buffer. This method ignores `autoClear` properties.
2077-
*
2078-
* @return {Promise} A Promise that resolves when the clear operation has been executed.
2079-
* Only returned when the renderer has not been initialized.
20802073
*/
20812074
clearColor() {
20822075

2083-
return this.clear( true, false, false );
2076+
this.clear( true, false, false );
20842077

20852078
}
20862079

20872080
/**
20882081
* Performs a manual clear operation of the depth buffer. This method ignores `autoClear` properties.
2089-
*
2090-
* @return {Promise} A Promise that resolves when the clear operation has been executed.
2091-
* Only returned when the renderer has not been initialized.
20922082
*/
20932083
clearDepth() {
20942084

2095-
return this.clear( false, true, false );
2085+
this.clear( false, true, false );
20962086

20972087
}
20982088

20992089
/**
21002090
* Performs a manual clear operation of the stencil buffer. This method ignores `autoClear` properties.
2101-
*
2102-
* @return {Promise} A Promise that resolves when the clear operation has been executed.
2103-
* Only returned when the renderer has not been initialized.
21042091
*/
21052092
clearStencil() {
21062093

2107-
return this.clear( false, false, true );
2094+
this.clear( false, false, true );
21082095

21092096
}
21102097

21112098
/**
21122099
* Async version of {@link Renderer#clear}.
21132100
*
21142101
* @async
2102+
* @deprecated
21152103
* @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
21162104
* @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
21172105
* @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
21182106
* @return {Promise} A Promise that resolves when the clear operation has been executed.
21192107
*/
21202108
async clearAsync( color = true, depth = true, stencil = true ) {
21212109

2122-
if ( this._initialized === false ) await this.init();
2110+
warnOnce( 'Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
21232111

21242112
this.clear( color, depth, stencil );
21252113

@@ -2129,35 +2117,44 @@ class Renderer {
21292117
* Async version of {@link Renderer#clearColor}.
21302118
*
21312119
* @async
2120+
* @deprecated
21322121
* @return {Promise} A Promise that resolves when the clear operation has been executed.
21332122
*/
21342123
async clearColorAsync() {
21352124

2136-
this.clearAsync( true, false, false );
2125+
warnOnce( 'Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
2126+
2127+
this.clear( true, false, false );
21372128

21382129
}
21392130

21402131
/**
21412132
* Async version of {@link Renderer#clearDepth}.
21422133
*
21432134
* @async
2135+
* @deprecated
21442136
* @return {Promise} A Promise that resolves when the clear operation has been executed.
21452137
*/
21462138
async clearDepthAsync() {
21472139

2148-
this.clearAsync( false, true, false );
2140+
warnOnce( 'Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
2141+
2142+
this.clear( false, true, false );
21492143

21502144
}
21512145

21522146
/**
21532147
* Async version of {@link Renderer#clearStencil}.
21542148
*
21552149
* @async
2150+
* @deprecated
21562151
* @return {Promise} A Promise that resolves when the clear operation has been executed.
21572152
*/
21582153
async clearStencilAsync() {
21592154

2160-
this.clearAsync( false, false, true );
2155+
warnOnce( 'Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
2156+
2157+
this.clear( false, false, true );
21612158

21622159
}
21632160

@@ -2606,14 +2603,15 @@ class Renderer {
26062603
* (which can cause noticeable lags due to decode and GPU upload overhead).
26072604
*
26082605
* @async
2606+
* @deprecated
26092607
* @param {Texture} texture - The texture.
26102608
* @return {Promise} A Promise that resolves when the texture has been initialized.
26112609
*/
26122610
async initTextureAsync( texture ) {
26132611

2614-
if ( this._initialized === false ) await this.init();
2612+
warnOnce( 'Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
26152613

2616-
this._textures.updateTexture( texture );
2614+
this.initTexture( texture );
26172615

26182616
}
26192617

@@ -2629,7 +2627,7 @@ class Renderer {
26292627

26302628
if ( this._initialized === false ) {
26312629

2632-
warn( 'Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead.' );
2630+
throw new Error( 'Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.' );
26332631

26342632
}
26352633

0 commit comments

Comments
 (0)