Skip to content

Commit ac85ae9

Browse files
authored
Merge pull request #20859 from Mugen87/dev41
WebGLRenderer: Introduce resetState().
2 parents 5cb4571 + 0486b09 commit ac85ae9

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

docs/api/en/renderers/WebGLRenderer.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ <h3>[method:null renderBufferImmediate]( [param:Object3D object], [param:WebGLPr
428428
Renders an instance of [page:ImmediateRenderObject]. Gets called by renderObjectImmediate().
429429
</p>
430430

431+
<h3>[method:null resetState]()</h3>
432+
<p>Can be used to reset the internal WebGL state. This method is mostly relevant for applications which share a single WebGL context across multiple WebGL libraries.</p>
433+
431434
<h3>[method:null setAnimationLoop]( [param:Function callback] )</h3>
432435
<p>[page:Function callback] — The function will be called every available frame. If `null` is passed it will stop any already ongoing animation.</p>
433436
<p>A built in function that can be used instead of [link:https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame requestAnimationFrame]. For WebXR projects this function must be used.</p>

docs/api/zh/renderers/WebGLRenderer.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ <h3>[method:null renderBufferImmediate]( [param:Object3D object], [param:WebGLPr
385385
Renders an instance of [page:ImmediateRenderObject],由renderObjectImmediate对象调用。
386386
</p>
387387

388+
<h3>[method:null resetState]()</h3>
389+
<p>Can be used to reset the internal WebGL state. This method is mostly relevant for applications which share a single WebGL context across multiple WebGL libraries.</p>
390+
388391
<h3>[method:null setAnimationLoop]( [param:Function callback] )</h3>
389392
<p>[page:Function callback] — 每个可用帧都会调用的函数。 如果传入‘null’,所有正在进行的动画都会停止。</p>
390393
<p>可用来代替[link:https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame requestAnimationFrame]的内置函数. 对于WebXR项目,必须使用此函数。</p>

src/renderers/WebGLRenderer.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ export class WebGLRenderer implements Renderer {
449449
*/
450450
initTexture( texture: Texture ): void;
451451

452+
/**
453+
* Can be used to reset the internal WebGL state.
454+
*/
455+
resetState(): void;
456+
452457
/**
453458
* @deprecated
454459
*/

src/renderers/WebGLRenderer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,13 @@ function WebGLRenderer( parameters ) {
19931993

19941994
};
19951995

1996+
this.resetState = function () {
1997+
1998+
state.reset();
1999+
bindingStates.reset();
2000+
2001+
};
2002+
19962003
if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
19972004

19982005
__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef

0 commit comments

Comments
 (0)