diff --git a/docs/api/en/renderers/webgl/WebGLShader.html b/docs/api/en/renderers/webgl/WebGLShader.html index 92f4079e5745f820d0d6e566579d7a1f94e8217b..f62f7214431b3faac4201ba934724a0195fa02a1 100644 --- a/docs/api/en/renderers/webgl/WebGLShader.html +++ b/docs/api/en/renderers/webgl/WebGLShader.html @@ -15,7 +15,7 @@
- var gl = renderer.context;
+ var gl = renderer.getContext();
var glVertexShader = new THREE.WebGLShader( gl, gl.VERTEX_SHADER, vertexSourceCode );
var glFragmentShader = new THREE.WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentSourceCode );
diff --git a/examples/jsm/loaders/BasisTextureLoader.js b/examples/jsm/loaders/BasisTextureLoader.js
index 5459f888d365efef17940f8f98e39f199d56627f..23255c59ce76e773fbe22c5f7bc421b95b221880 100644
--- a/examples/jsm/loaders/BasisTextureLoader.js
+++ b/examples/jsm/loaders/BasisTextureLoader.js
@@ -82,7 +82,7 @@ BasisTextureLoader.prototype = {
detectSupport: function ( renderer ) {
- var context = renderer.context;
+ var context = renderer.getContext();
var config = this.workerConfig;
config.etcSupported = !! context.getExtension( 'WEBGL_compressed_texture_etc1' );
diff --git a/examples/jsm/postprocessing/BloomPass.js b/examples/jsm/postprocessing/BloomPass.js
index d2554b387234ca782737bf8c0968b088eee2bff0..26b61caf1f1582d47037be1dd18272173b1cb399 100644
--- a/examples/jsm/postprocessing/BloomPass.js
+++ b/examples/jsm/postprocessing/BloomPass.js
@@ -90,7 +90,7 @@ BloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
- if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST );
+ if ( maskActive ) renderer.getContext().disable( renderer.getContext().STENCIL_TEST ); // avoid direct gl calls
// Render quad with blured scene into texture (convolution pass 1)
@@ -119,7 +119,7 @@ BloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
this.copyUniforms[ "tDiffuse" ].value = this.renderTargetY.texture;
- if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
+ if ( maskActive ) renderer.getContext().enable( renderer.getContext().STENCIL_TEST ); // avoid direct gl calls
renderer.setRenderTarget( readBuffer );
if ( this.clear ) renderer.clear();
diff --git a/examples/jsm/postprocessing/EffectComposer.js b/examples/jsm/postprocessing/EffectComposer.js
index 5096d6da3d0dae43ef81b08a6d6c8c9fd6ef1468..2b92cec9c85aa9ff8401eb4551843cb90d61a544 100644
--- a/examples/jsm/postprocessing/EffectComposer.js
+++ b/examples/jsm/postprocessing/EffectComposer.js
@@ -147,13 +147,13 @@ Object.assign( EffectComposer.prototype, {
if ( maskActive ) {
- var context = this.renderer.context;
+ var context = this.renderer.getContext();
- context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
+ context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff ); // avoid direct gl calls
this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime );
- context.stencilFunc( context.EQUAL, 1, 0xffffffff );
+ context.stencilFunc( context.EQUAL, 1, 0xffffffff ); // avoid direct gl calls
}
diff --git a/examples/jsm/postprocessing/MaskPass.js b/examples/jsm/postprocessing/MaskPass.js
index 0f6a4e6af4b1b062f81cca19c243035d23cd7662..6d4a86334ca5a28ab9a5a48cc916730b6df9f276 100644
--- a/examples/jsm/postprocessing/MaskPass.js
+++ b/examples/jsm/postprocessing/MaskPass.js
@@ -25,7 +25,7 @@ MaskPass.prototype = Object.assign( Object.create( Pass.prototype ), {
render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
- var context = renderer.context;
+ var context = renderer.getContext();
var state = renderer.state;
// don't update color or depth
diff --git a/examples/jsm/postprocessing/OutlinePass.js b/examples/jsm/postprocessing/OutlinePass.js
index a59e11481247af01bb585f6fcad4144d3f929298..05ba31ed3d97a90d6143d17e574ea50b757cfc3d 100644
--- a/examples/jsm/postprocessing/OutlinePass.js
+++ b/examples/jsm/postprocessing/OutlinePass.js
@@ -280,7 +280,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
renderer.autoClear = false;
- if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST );
+ if ( maskActive ) renderer.getContext().disable( renderer.getContext().STENCIL_TEST );
renderer.setClearColor( 0xffffff, 1 );
@@ -382,7 +382,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
this.overlayMaterial.uniforms[ "usePatternTexture" ].value = this.usePatternTexture;
- if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
+ if ( maskActive ) renderer.getContext().enable( renderer.getContext().STENCIL_TEST );
renderer.setRenderTarget( readBuffer );
this.fsQuad.render( renderer );
diff --git a/examples/jsm/postprocessing/UnrealBloomPass.js b/examples/jsm/postprocessing/UnrealBloomPass.js
index 730260057763e5629e544c430d653472b333b295..1ea9e273f234fe2e15051427c4255bd26787cb05 100644
--- a/examples/jsm/postprocessing/UnrealBloomPass.js
+++ b/examples/jsm/postprocessing/UnrealBloomPass.js
@@ -206,7 +206,7 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
renderer.setClearColor( this.clearColor, 0 );
- if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST );
+ if ( maskActive ) renderer.getContext().disable( renderer.getContext().STENCIL_TEST );
// Render input to screen
@@ -271,7 +271,7 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
this.fsQuad.material = this.materialCopy;
this.copyUniforms[ "tDiffuse" ].value = this.renderTargetsHorizontal[ 0 ].texture;
- if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
+ if ( maskActive ) renderer.getContext().enable( renderer.getContext().STENCIL_TEST );
if ( this.renderToScreen ) {
diff --git a/examples/jsm/renderers/WebGLDeferredRenderer.js b/examples/jsm/renderers/WebGLDeferredRenderer.js
index 05980c962a65d48145853bce82ae031c31692bb3..60193c1c7ffaa424bc13aa0e789f20b36ec42ba5 100644
--- a/examples/jsm/renderers/WebGLDeferredRenderer.js
+++ b/examples/jsm/renderers/WebGLDeferredRenderer.js
@@ -159,7 +159,7 @@ var WebGLDeferredRenderer = function ( parameters ) {
_this.renderer = parameters.renderer !== undefined ? parameters.renderer : new WebGLRenderer();
_this.domElement = _this.renderer.domElement;
- _context = _this.renderer.context;
+ _context = _this.renderer.getContext();
_state = _this.renderer.state;
_width = parameters.width !== undefined ? parameters.width : _this.renderer.getSize( new Vector2() ).width;
diff --git a/examples/webgl_shaders_ocean2.html b/examples/webgl_shaders_ocean2.html
index 03c52e593fa969cfeb365a9e44bfa9107915d282..ba1c84c20d76c3fd04e77edcd3b919c8a4c97adf 100644
--- a/examples/webgl_shaders_ocean2.html
+++ b/examples/webgl_shaders_ocean2.html
@@ -36,8 +36,8 @@
this.ms_Renderer = new THREE.WebGLRenderer();
this.ms_Renderer.setPixelRatio( window.devicePixelRatio );
- this.ms_Renderer.context.getExtension( 'OES_texture_float' );
- this.ms_Renderer.context.getExtension( 'OES_texture_float_linear' );
+ this.ms_Renderer.getContext().getExtension( 'OES_texture_float' );
+ this.ms_Renderer.getContext().getExtension( 'OES_texture_float_linear' );
document.body.appendChild( this.ms_Renderer.domElement );
diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js
index 326b7b50764a5f8eef9cc5fc13b727c7026fc648..a8e20bb92f7e57f4ae22edb23efb633f31a702a8 100644
--- a/src/Three.Legacy.js
+++ b/src/Three.Legacy.js
@@ -1548,8 +1548,17 @@ Object.defineProperties( WebGLRenderer.prototype, {
console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.' );
+ }
+ },
+ context: {
+ get: function () {
+
+ console.warn( 'THREE.WebGLRenderer: .context has been removed. Use .getContext() instead.' );
+ return this.getContext();
+
}
}
+
} );
Object.defineProperties( WebGLShadowMap.prototype, {
diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js
index accb337f9206e3385eedc825c354ebf2b8dce1f5..548d755a406494683d70a7984a2365c42720bd21 100644
--- a/src/renderers/WebGLRenderer.js
+++ b/src/renderers/WebGLRenderer.js
@@ -76,7 +76,6 @@ function WebGLRenderer( parameters ) {
// public properties
this.domElement = _canvas;
- this.context = null;
// Debug configuration container
this.debug = {
@@ -299,7 +298,6 @@ function WebGLRenderer( parameters ) {
info.programs = programCache.programs;
- _this.context = _gl;
_this.capabilities = capabilities;
_this.extensions = extensions;
_this.properties = properties;
diff --git a/src/renderers/webgl/WebGLProgram.js b/src/renderers/webgl/WebGLProgram.js
index 0379afc14cff562ebdeedc4f8609288fa04fd3ed..d8ae626dc67b45e5cf74303a7e3e1247d76d1d06 100644
--- a/src/renderers/webgl/WebGLProgram.js
+++ b/src/renderers/webgl/WebGLProgram.js
@@ -238,7 +238,7 @@ function unrollLoops( string ) {
function WebGLProgram( renderer, extensions, code, material, shader, parameters, capabilities ) {
- var gl = renderer.context;
+ var gl = renderer.getContext();
var defines = material.defines;
diff --git a/src/renderers/webvr/WebXRManager.js b/src/renderers/webvr/WebXRManager.js
index ca60590871ec553e8dc7a5a7504e1d5731917eb1..f785e63354bbcfc681c4da9ff068652a9d74e9f7 100644
--- a/src/renderers/webvr/WebXRManager.js
+++ b/src/renderers/webvr/WebXRManager.js
@@ -15,7 +15,7 @@ function WebXRManager( renderer ) {
var scope = this;
- var gl = renderer.context;
+ var gl = renderer.getContext();
var session = null;