Skip to content

Commit acc17c6

Browse files
s-rigaudSamuel Rigaud
andauthored
Docs: improve Promise typing (#30317)
Co-authored-by: Samuel Rigaud <[email protected]>
1 parent 86c3bd3 commit acc17c6

File tree

5 files changed

+47
-4
lines changed

5 files changed

+47
-4
lines changed

src/nodes/code/ScriptableNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ class ScriptableNode extends Node {
416416
*
417417
* @param {String} name - The function name.
418418
* @param {...Any} params - A list of parameters.
419-
* @return {Any} The result of the function call.
419+
* @return {Promise<Any>} The result of the function call.
420420
*/
421421
async callAsync( name, ...params ) {
422422

src/renderers/common/Pipelines.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ class Pipelines extends DataMap {
343343
* @param {ProgrammableStage} stageVertex - The programmable stage representing the vertex shader.
344344
* @param {ProgrammableStage} stageFragment - The programmable stage representing the fragment shader.
345345
* @param {String} cacheKey - The cache key.
346-
* @param {Array} promises - An array of compilation promises which is only relevant in context of `Renderer.compileAsync()`.
346+
* @param {Array<Promise>?} promises - An array of compilation promises which is only relevant in context of `Renderer.compileAsync()`.
347347
* @return {ComputePipeline} The compute pipeline.
348348
*/
349349
_getRenderPipeline( renderObject, stageVertex, stageFragment, cacheKey, promises ) {

src/renderers/common/Renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ class Renderer {
795795
* @param {Object3D} scene - The scene or 3D object to precompile.
796796
* @param {Camera} camera - The camera that is used to render the scene.
797797
* @param {Scene} targetScene - If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added.
798-
* @return {Promise} A Promise that resolves when the compile has been finished.
798+
* @return {Promise<Array>} A Promise that resolves when the compile has been finished.
799799
*/
800800
async compileAsync( scene, camera, targetScene = null ) {
801801

@@ -2187,7 +2187,7 @@ class Renderer {
21872187
*
21882188
* @async
21892189
* @param {Node|Array<Node>} computeNodes - The compute node(s).
2190-
* @return {Promise?} A Promise that resolve when the compute has finished.
2190+
* @return {Promise} A Promise that resolve when the compute has finished.
21912191
*/
21922192
async computeAsync( computeNodes ) {
21932193

src/renderers/common/extras/PMREMGenerator.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class PMREMGenerator {
135135
* @param {Number} [far=100] - The far plane distance.
136136
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
137137
* @return {RenderTarget} The resulting PMREM.
138+
* @see fromSceneAsync
138139
*/
139140
fromScene( scene, sigma = 0, near = 0.1, far = 100, renderTarget = null ) {
140141

@@ -175,6 +176,21 @@ class PMREMGenerator {
175176

176177
}
177178

179+
/**
180+
* Generates a PMREM from a supplied Scene, which can be faster than using an
181+
* image if networking bandwidth is low. Optional sigma specifies a blur radius
182+
* in radians to be applied to the scene before PMREM generation. Optional near
183+
* and far planes ensure the scene is rendered in its entirety (the cubeCamera
184+
* is placed at the origin).
185+
*
186+
* @param {Scene} scene - The scene to be captured.
187+
* @param {Number} [sigma=0] - The blur radius in radians.
188+
* @param {Number} [near=0.1] - The near plane distance.
189+
* @param {Number} [far=100] - The far plane distance.
190+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
191+
* @return {Promise<RenderTarget>} The resulting PMREM.
192+
* @see fromScene
193+
*/
178194
async fromSceneAsync( scene, sigma = 0, near = 0.1, far = 100, renderTarget = null ) {
179195

180196
if ( this._hasInitialized === false ) await this._renderer.init();
@@ -191,6 +207,7 @@ class PMREMGenerator {
191207
* @param {Texture} equirectangular - The equirectangular texture to be converted.
192208
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
193209
* @return {RenderTarget} The resulting PMREM.
210+
* @see fromEquirectangularAsync
194211
*/
195212
fromEquirectangular( equirectangular, renderTarget = null ) {
196213

@@ -212,6 +229,16 @@ class PMREMGenerator {
212229

213230
}
214231

232+
/**
233+
* Generates a PMREM from an equirectangular texture, which can be either LDR
234+
* or HDR. The ideal input image size is 1k (1024 x 512),
235+
* as this matches best with the 256 x 256 cubemap output.
236+
*
237+
* @param {Texture} equirectangular - The equirectangular texture to be converted.
238+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
239+
* @return {Promise<RenderTarget>} The resulting PMREM.
240+
* @see fromEquirectangular
241+
*/
215242
async fromEquirectangularAsync( equirectangular, renderTarget = null ) {
216243

217244
if ( this._hasInitialized === false ) await this._renderer.init();
@@ -228,6 +255,7 @@ class PMREMGenerator {
228255
* @param {Texture} cubemap - The cubemap texture to be converted.
229256
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
230257
* @return {RenderTarget} The resulting PMREM.
258+
* @see fromCubemapAsync
231259
*/
232260
fromCubemap( cubemap, renderTarget = null ) {
233261

@@ -249,6 +277,16 @@ class PMREMGenerator {
249277

250278
}
251279

280+
/**
281+
* Generates a PMREM from an cubemap texture, which can be either LDR
282+
* or HDR. The ideal input cube size is 256 x 256,
283+
* with the 256 x 256 cubemap output.
284+
*
285+
* @param {Texture} cubemap - The cubemap texture to be converted.
286+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
287+
* @return {Promise<RenderTarget>} The resulting PMREM.
288+
* @see fromCubemap
289+
*/
252290
async fromCubemapAsync( cubemap, renderTarget = null ) {
253291

254292
if ( this._hasInitialized === false ) await this._renderer.init();
@@ -260,6 +298,8 @@ class PMREMGenerator {
260298
/**
261299
* Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
262300
* your texture's network fetch for increased concurrency.
301+
*
302+
* @returns {Promise}
263303
*/
264304
async compileCubemapShader() {
265305

@@ -275,6 +315,8 @@ class PMREMGenerator {
275315
/**
276316
* Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
277317
* your texture's network fetch for increased concurrency.
318+
*
319+
* @returns {Promise}
278320
*/
279321
async compileEquirectangularShader() {
280322

src/renderers/webgpu/WebGPUBackend.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ class WebGPUBackend extends Backend {
764764
*
765765
* @async
766766
* @param {RenderContext} renderContext - The render context.
767+
* @return {Promise} A Promise that resolves when the occlusion query results have been processed.
767768
*/
768769
async resolveOccludedAsync( renderContext ) {
769770

0 commit comments

Comments
 (0)