@@ -23777,6 +23777,7 @@ THREE.Scene = function () {
23777
23777
23778
23778
this.type = 'Scene';
23779
23779
23780
+ this.background = null;
23780
23781
this.fog = null;
23781
23782
this.overrideMaterial = null;
23782
23783
@@ -23791,6 +23792,7 @@ THREE.Scene.prototype.copy = function ( source, recursive ) {
23791
23792
23792
23793
THREE.Object3D.prototype.copy.call( this, source, recursive );
23793
23794
23795
+ if ( source.background !== null ) this.background = source.background.clone();
23794
23796
if ( source.fog !== null ) this.fog = source.fog.clone();
23795
23797
if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
23796
23798
@@ -24999,6 +25001,29 @@ THREE.WebGLRenderer = function ( parameters ) {
24999
25001
25000
25002
//
25001
25003
25004
+ var backgroundCamera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
25005
+ var backgroundCamera2 = new THREE.PerspectiveCamera();
25006
+ var backgroundPlaneMesh = new THREE.Mesh(
25007
+ new THREE.PlaneBufferGeometry( 2, 2 ),
25008
+ new THREE.MeshBasicMaterial( { depthTest: false, depthWrite: false } )
25009
+ );
25010
+ var backgroundBoxShader = THREE.ShaderLib[ 'cube' ];
25011
+ var backgroundBoxMesh = new THREE.Mesh(
25012
+ new THREE.BoxBufferGeometry( 5, 5, 5 ),
25013
+ new THREE.ShaderMaterial( {
25014
+ uniforms: backgroundBoxShader.uniforms,
25015
+ vertexShader: backgroundBoxShader.vertexShader,
25016
+ fragmentShader: backgroundBoxShader.fragmentShader,
25017
+ depthTest: false,
25018
+ depthWrite: false,
25019
+ side: THREE.BackSide
25020
+ } )
25021
+ );
25022
+ objects.update( backgroundPlaneMesh );
25023
+ objects.update( backgroundBoxMesh );
25024
+
25025
+ //
25026
+
25002
25027
function getTargetPixelRatio() {
25003
25028
25004
25029
return _currentRenderTarget === null ? _pixelRatio : 1;
@@ -25658,6 +25683,12 @@ THREE.WebGLRenderer = function ( parameters ) {
25658
25683
var size = geometryAttribute.itemSize;
25659
25684
var buffer = objects.getAttributeBuffer( geometryAttribute );
25660
25685
25686
+ if ( buffer === undefined ) {
25687
+
25688
+ console.error( objects, geometryAttribute );
25689
+
25690
+ }
25691
+
25661
25692
if ( geometryAttribute instanceof THREE.InterleavedBufferAttribute ) {
25662
25693
25663
25694
var data = geometryAttribute.data;
@@ -25832,12 +25863,10 @@ THREE.WebGLRenderer = function ( parameters ) {
25832
25863
lensFlares.length = 0;
25833
25864
25834
25865
_localClippingEnabled = this.localClippingEnabled;
25835
- _clippingEnabled = _clipping.init(
25836
- this.clippingPlanes, _localClippingEnabled, camera );
25866
+ _clippingEnabled = _clipping.init( this.clippingPlanes, _localClippingEnabled, camera );
25837
25867
25838
25868
projectObject( scene, camera );
25839
25869
25840
-
25841
25870
opaqueObjects.length = opaqueObjectsLastIndex + 1;
25842
25871
transparentObjects.length = transparentObjectsLastIndex + 1;
25843
25872
@@ -25875,7 +25904,46 @@ THREE.WebGLRenderer = function ( parameters ) {
25875
25904
25876
25905
this.setRenderTarget( renderTarget );
25877
25906
25878
- if ( this.autoClear || forceClear ) {
25907
+ //
25908
+
25909
+ var needsClear = this.autoClear || forceClear;
25910
+ var background = scene.background;
25911
+
25912
+ if ( background === null ) {
25913
+
25914
+ glClearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha );
25915
+
25916
+ } else if ( background instanceof THREE.CubeTexture ) {
25917
+
25918
+ backgroundCamera2.projectionMatrix = camera.projectionMatrix;
25919
+
25920
+ backgroundCamera2.matrixWorld.extractRotation( camera.matrixWorld );
25921
+ backgroundCamera2.matrixWorldInverse.getInverse( backgroundCamera2.matrixWorld );
25922
+
25923
+ backgroundBoxMesh.material.uniforms[ "tCube" ].value = background;
25924
+ backgroundBoxMesh.modelViewMatrix.multiplyMatrices( backgroundCamera2.matrixWorldInverse, backgroundBoxMesh.matrixWorld );
25925
+
25926
+ _this.renderBufferDirect( backgroundCamera2, null, backgroundBoxMesh.geometry, backgroundBoxMesh.material, backgroundBoxMesh, null );
25927
+
25928
+ needsClear = false;
25929
+
25930
+ } else if ( background instanceof THREE.Texture ) {
25931
+
25932
+ backgroundPlaneMesh.material.map = background;
25933
+
25934
+ _this.renderBufferDirect( backgroundCamera, null, backgroundPlaneMesh.geometry, backgroundPlaneMesh.material, backgroundPlaneMesh, null );
25935
+
25936
+ needsClear = false;
25937
+
25938
+ } else if ( background instanceof THREE.Color ) {
25939
+
25940
+ glClearColor( background.r, background.g, background.b, 1 );
25941
+
25942
+ needsClear = true;
25943
+
25944
+ }
25945
+
25946
+ if ( needsClear ) {
25879
25947
25880
25948
this.clear( this.autoClearColor, this.autoClearDepth, this.autoClearStencil );
25881
25949
@@ -28749,15 +28817,15 @@ THREE.WebGLProgram = ( function () {
28749
28817
28750
28818
prefixVertex = [
28751
28819
28752
- '#define SHADER_NAME ' + material.__webglShader.name ,
28820
+ '#define SHADER_NAME RawShaderMaterial' ,
28753
28821
28754
28822
customDefines
28755
28823
28756
28824
].filter( filterEmptyLine ).join( '\n' );
28757
28825
28758
28826
prefixFragment = [
28759
28827
28760
- '#define SHADER_NAME ' + material.__webglShader.name ,
28828
+ '#define SHADER_NAME RawShaderMaterial' ,
28761
28829
28762
28830
customDefines
28763
28831
@@ -40403,7 +40471,9 @@ THREE.ArrowHelper.prototype.setColor = function ( color ) {
40403
40471
* @author mrdoob / http://mrdoob.com/
40404
40472
*/
40405
40473
40406
- THREE.BoxHelper = function ( object ) {
40474
+ THREE.BoxHelper = function ( object, color ) {
40475
+
40476
+ if ( color === undefined ) color = 0xffff00;
40407
40477
40408
40478
var indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );
40409
40479
var positions = new Float32Array( 8 * 3 );
@@ -40412,7 +40482,7 @@ THREE.BoxHelper = function ( object ) {
40412
40482
geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
40413
40483
geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
40414
40484
40415
- THREE.LineSegments.call( this, geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ) );
40485
+ THREE.LineSegments.call( this, geometry, new THREE.LineBasicMaterial( { color: color } ) );
40416
40486
40417
40487
if ( object !== undefined ) {
40418
40488
@@ -40613,7 +40683,7 @@ THREE.CameraHelper = function ( camera ) {
40613
40683
THREE.LineSegments.call( this, geometry, material );
40614
40684
40615
40685
this.camera = camera;
40616
- this.camera.updateProjectionMatrix();
40686
+ if( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix();
40617
40687
40618
40688
this.matrix = camera.matrixWorld;
40619
40689
this.matrixAutoUpdate = false;
0 commit comments