super-three 0.173.3 → 0.173.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +577 -64
- package/build/three.core.js +15 -0
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +563 -65
- package/build/three.module.min.js +1 -1
- package/package.json +1 -1
package/build/three.cjs
CHANGED
|
@@ -29857,6 +29857,21 @@ class ObjectLoader extends Loader {
|
|
|
29857
29857
|
geometry = bufferGeometryLoader.parse( data );
|
|
29858
29858
|
break;
|
|
29859
29859
|
|
|
29860
|
+
case 'Geometry':
|
|
29861
|
+
|
|
29862
|
+
if ( 'THREE' in window && 'LegacyJSONLoader' in THREE ) {
|
|
29863
|
+
|
|
29864
|
+
var geometryLoader = new THREE.LegacyJSONLoader();
|
|
29865
|
+
geometry = geometryLoader.parse( data, this.resourcePath ).geometry;
|
|
29866
|
+
|
|
29867
|
+
|
|
29868
|
+
} else {
|
|
29869
|
+
|
|
29870
|
+
console.error( 'THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".' );
|
|
29871
|
+
|
|
29872
|
+
}
|
|
29873
|
+
break;
|
|
29874
|
+
|
|
29860
29875
|
default:
|
|
29861
29876
|
|
|
29862
29877
|
if ( data.type in Geometries ) {
|
|
@@ -38792,7 +38807,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
38792
38807
|
if ( boxMesh === undefined ) {
|
|
38793
38808
|
|
|
38794
38809
|
boxMesh = new Mesh(
|
|
38795
|
-
new BoxGeometry(
|
|
38810
|
+
new BoxGeometry( 10000, 10000, 10000 ),
|
|
38796
38811
|
new ShaderMaterial( {
|
|
38797
38812
|
name: 'BackgroundCubeMaterial',
|
|
38798
38813
|
uniforms: cloneUniforms( ShaderLib.backgroundCube.uniforms ),
|
|
@@ -41703,6 +41718,103 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
|
|
|
41703
41718
|
|
|
41704
41719
|
}
|
|
41705
41720
|
|
|
41721
|
+
/**
|
|
41722
|
+
* @author fernandojsg / http://fernandojsg.com
|
|
41723
|
+
* @author Takahiro https://github.com/takahirox
|
|
41724
|
+
*/
|
|
41725
|
+
|
|
41726
|
+
class WebGLMultiview {
|
|
41727
|
+
|
|
41728
|
+
constructor( renderer, extensions, gl ) {
|
|
41729
|
+
|
|
41730
|
+
this.renderer = renderer;
|
|
41731
|
+
|
|
41732
|
+
this.DEFAULT_NUMVIEWS = 2;
|
|
41733
|
+
this.maxNumViews = 0;
|
|
41734
|
+
this.gl = gl;
|
|
41735
|
+
|
|
41736
|
+
this.extensions = extensions;
|
|
41737
|
+
|
|
41738
|
+
this.available = this.extensions.has( 'OCULUS_multiview' );
|
|
41739
|
+
|
|
41740
|
+
if ( this.available ) {
|
|
41741
|
+
|
|
41742
|
+
const extension = this.extensions.get( 'OCULUS_multiview' );
|
|
41743
|
+
|
|
41744
|
+
this.maxNumViews = this.gl.getParameter( extension.MAX_VIEWS_OVR );
|
|
41745
|
+
|
|
41746
|
+
this.mat4 = [];
|
|
41747
|
+
this.mat3 = [];
|
|
41748
|
+
this.cameraArray = [];
|
|
41749
|
+
|
|
41750
|
+
for ( var i = 0; i < this.maxNumViews; i ++ ) {
|
|
41751
|
+
|
|
41752
|
+
this.mat4[ i ] = new Matrix4();
|
|
41753
|
+
this.mat3[ i ] = new Matrix3();
|
|
41754
|
+
|
|
41755
|
+
}
|
|
41756
|
+
|
|
41757
|
+
}
|
|
41758
|
+
|
|
41759
|
+
}
|
|
41760
|
+
|
|
41761
|
+
//
|
|
41762
|
+
getCameraArray( camera ) {
|
|
41763
|
+
|
|
41764
|
+
if ( camera.isArrayCamera ) return camera.cameras;
|
|
41765
|
+
|
|
41766
|
+
this.cameraArray[ 0 ] = camera;
|
|
41767
|
+
|
|
41768
|
+
return this.cameraArray;
|
|
41769
|
+
|
|
41770
|
+
}
|
|
41771
|
+
|
|
41772
|
+
updateCameraProjectionMatricesUniform( camera, uniforms ) {
|
|
41773
|
+
|
|
41774
|
+
var cameras = this.getCameraArray( camera );
|
|
41775
|
+
|
|
41776
|
+
for ( var i = 0; i < cameras.length; i ++ ) {
|
|
41777
|
+
|
|
41778
|
+
this.mat4[ i ].copy( cameras[ i ].projectionMatrix );
|
|
41779
|
+
|
|
41780
|
+
}
|
|
41781
|
+
|
|
41782
|
+
uniforms.setValue( this.gl, 'projectionMatrices', this.mat4 );
|
|
41783
|
+
|
|
41784
|
+
}
|
|
41785
|
+
|
|
41786
|
+
updateCameraViewMatricesUniform( camera, uniforms ) {
|
|
41787
|
+
|
|
41788
|
+
var cameras = this.getCameraArray( camera );
|
|
41789
|
+
|
|
41790
|
+
for ( var i = 0; i < cameras.length; i ++ ) {
|
|
41791
|
+
|
|
41792
|
+
this.mat4[ i ].copy( cameras[ i ].matrixWorldInverse );
|
|
41793
|
+
|
|
41794
|
+
}
|
|
41795
|
+
|
|
41796
|
+
uniforms.setValue( this.gl, 'viewMatrices', this.mat4 );
|
|
41797
|
+
|
|
41798
|
+
}
|
|
41799
|
+
|
|
41800
|
+
updateObjectMatricesUniforms( object, camera, uniforms ) {
|
|
41801
|
+
|
|
41802
|
+
var cameras = this.getCameraArray( camera );
|
|
41803
|
+
|
|
41804
|
+
for ( var i = 0; i < cameras.length; i ++ ) {
|
|
41805
|
+
|
|
41806
|
+
this.mat4[ i ].multiplyMatrices( cameras[ i ].matrixWorldInverse, object.matrixWorld );
|
|
41807
|
+
this.mat3[ i ].getNormalMatrix( this.mat4[ i ] );
|
|
41808
|
+
|
|
41809
|
+
}
|
|
41810
|
+
|
|
41811
|
+
uniforms.setValue( this.gl, 'modelViewMatrices', this.mat4 );
|
|
41812
|
+
uniforms.setValue( this.gl, 'normalMatrices', this.mat3 );
|
|
41813
|
+
|
|
41814
|
+
}
|
|
41815
|
+
|
|
41816
|
+
}
|
|
41817
|
+
|
|
41706
41818
|
function WebGLObjects( gl, geometries, attributes, info ) {
|
|
41707
41819
|
|
|
41708
41820
|
let updateMap = new WeakMap();
|
|
@@ -43454,6 +43566,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
43454
43566
|
let prefixVertex, prefixFragment;
|
|
43455
43567
|
let versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\n' : '';
|
|
43456
43568
|
|
|
43569
|
+
const numMultiviewViews = parameters.numMultiviewViews;
|
|
43570
|
+
|
|
43457
43571
|
if ( parameters.isRawShaderMaterial ) {
|
|
43458
43572
|
|
|
43459
43573
|
prefixVertex = [
|
|
@@ -43841,6 +43955,53 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
43841
43955
|
'#define textureCubeGradEXT textureGrad'
|
|
43842
43956
|
].join( '\n' ) + '\n' + prefixFragment;
|
|
43843
43957
|
|
|
43958
|
+
// Multiview
|
|
43959
|
+
|
|
43960
|
+
if ( numMultiviewViews > 0 ) {
|
|
43961
|
+
|
|
43962
|
+
// TODO: fix light transforms here?
|
|
43963
|
+
|
|
43964
|
+
prefixVertex = [
|
|
43965
|
+
'#extension GL_OVR_multiview : require',
|
|
43966
|
+
'layout(num_views = ' + numMultiviewViews + ') in;',
|
|
43967
|
+
'#define VIEW_ID gl_ViewID_OVR'
|
|
43968
|
+
].join( '\n' ) + '\n' + prefixVertex;
|
|
43969
|
+
|
|
43970
|
+
prefixVertex = prefixVertex.replace(
|
|
43971
|
+
[
|
|
43972
|
+
'uniform mat4 modelViewMatrix;',
|
|
43973
|
+
'uniform mat4 projectionMatrix;',
|
|
43974
|
+
'uniform mat4 viewMatrix;',
|
|
43975
|
+
'uniform mat3 normalMatrix;'
|
|
43976
|
+
].join( '\n' ),
|
|
43977
|
+
[
|
|
43978
|
+
'uniform mat4 modelViewMatrices[' + numMultiviewViews + '];',
|
|
43979
|
+
'uniform mat4 projectionMatrices[' + numMultiviewViews + '];',
|
|
43980
|
+
'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
|
|
43981
|
+
'uniform mat3 normalMatrices[' + numMultiviewViews + '];',
|
|
43982
|
+
|
|
43983
|
+
'#define modelViewMatrix modelViewMatrices[VIEW_ID]',
|
|
43984
|
+
'#define projectionMatrix projectionMatrices[VIEW_ID]',
|
|
43985
|
+
'#define viewMatrix viewMatrices[VIEW_ID]',
|
|
43986
|
+
'#define normalMatrix normalMatrices[VIEW_ID]'
|
|
43987
|
+
].join( '\n' )
|
|
43988
|
+
);
|
|
43989
|
+
|
|
43990
|
+
prefixFragment = [
|
|
43991
|
+
'#extension GL_OVR_multiview : require',
|
|
43992
|
+
'#define VIEW_ID gl_ViewID_OVR'
|
|
43993
|
+
].join( '\n' ) + '\n' + prefixFragment;
|
|
43994
|
+
|
|
43995
|
+
prefixFragment = prefixFragment.replace(
|
|
43996
|
+
'uniform mat4 viewMatrix;',
|
|
43997
|
+
[
|
|
43998
|
+
'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
|
|
43999
|
+
'#define viewMatrix viewMatrices[VIEW_ID]'
|
|
44000
|
+
].join( '\n' )
|
|
44001
|
+
);
|
|
44002
|
+
|
|
44003
|
+
}
|
|
44004
|
+
|
|
43844
44005
|
}
|
|
43845
44006
|
|
|
43846
44007
|
const vertexGlsl = versionString + prefixVertex + vertexShader;
|
|
@@ -44033,6 +44194,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
44033
44194
|
this.program = program;
|
|
44034
44195
|
this.vertexShader = glVertexShader;
|
|
44035
44196
|
this.fragmentShader = glFragmentShader;
|
|
44197
|
+
this.numMultiviewViews = numMultiviewViews;
|
|
44036
44198
|
|
|
44037
44199
|
return this;
|
|
44038
44200
|
|
|
@@ -44265,6 +44427,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
44265
44427
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
44266
44428
|
const reverseDepthBuffer = renderer.state.buffers.depth.getReversed();
|
|
44267
44429
|
|
|
44430
|
+
const numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
|
|
44431
|
+
|
|
44268
44432
|
const IS_INSTANCEDMESH = object.isInstancedMesh === true;
|
|
44269
44433
|
const IS_BATCHEDMESH = object.isBatchedMesh === true;
|
|
44270
44434
|
|
|
@@ -44354,6 +44518,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
44354
44518
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
44355
44519
|
|
|
44356
44520
|
supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
|
|
44521
|
+
numMultiviewViews: numMultiviewViews,
|
|
44357
44522
|
outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
|
|
44358
44523
|
alphaToCoverage: !! material.alphaToCoverage,
|
|
44359
44524
|
|
|
@@ -44718,6 +44883,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
44718
44883
|
_programLayers.enable( 20 );
|
|
44719
44884
|
if ( parameters.alphaToCoverage )
|
|
44720
44885
|
_programLayers.enable( 21 );
|
|
44886
|
+
if ( parameters.numMultiviewViews )
|
|
44887
|
+
_programLayers.enable( 21 );
|
|
44721
44888
|
|
|
44722
44889
|
array.push( _programLayers.mask );
|
|
44723
44890
|
|
|
@@ -47515,6 +47682,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
47515
47682
|
|
|
47516
47683
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
47517
47684
|
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
47685
|
+
const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
|
|
47518
47686
|
|
|
47519
47687
|
const _imageDimensions = new Vector2();
|
|
47520
47688
|
const _videoTextures = new WeakMap();
|
|
@@ -47522,6 +47690,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
47522
47690
|
|
|
47523
47691
|
const _sources = new WeakMap(); // maps WebglTexture objects to instances of Source
|
|
47524
47692
|
|
|
47693
|
+
let _deferredUploads = [];
|
|
47694
|
+
let _deferTextureUploads = false;
|
|
47695
|
+
|
|
47525
47696
|
// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,
|
|
47526
47697
|
// also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")!
|
|
47527
47698
|
// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).
|
|
@@ -48036,8 +48207,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
48036
48207
|
|
|
48037
48208
|
} else {
|
|
48038
48209
|
|
|
48039
|
-
uploadTexture( textureProperties, texture, slot )
|
|
48040
|
-
|
|
48210
|
+
if ( uploadTexture( textureProperties, texture, slot ) ) {
|
|
48211
|
+
|
|
48212
|
+
return;
|
|
48213
|
+
|
|
48214
|
+
}
|
|
48041
48215
|
|
|
48042
48216
|
}
|
|
48043
48217
|
|
|
@@ -48246,8 +48420,45 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
48246
48420
|
|
|
48247
48421
|
}
|
|
48248
48422
|
|
|
48423
|
+
function setDeferTextureUploads( deferFlag ) {
|
|
48424
|
+
|
|
48425
|
+
_deferTextureUploads = deferFlag;
|
|
48426
|
+
|
|
48427
|
+
}
|
|
48428
|
+
|
|
48429
|
+
function runDeferredUploads() {
|
|
48430
|
+
|
|
48431
|
+
const previousDeferSetting = _deferTextureUploads;
|
|
48432
|
+
_deferTextureUploads = false;
|
|
48433
|
+
|
|
48434
|
+
for ( const upload of _deferredUploads ) {
|
|
48435
|
+
|
|
48436
|
+
uploadTexture( upload.textureProperties, upload.texture, upload.slot );
|
|
48437
|
+
upload.texture.isPendingDeferredUpload = false;
|
|
48438
|
+
|
|
48439
|
+
}
|
|
48440
|
+
|
|
48441
|
+
_deferredUploads = [];
|
|
48442
|
+
|
|
48443
|
+
_deferTextureUploads = previousDeferSetting;
|
|
48444
|
+
|
|
48445
|
+
}
|
|
48446
|
+
|
|
48249
48447
|
function uploadTexture( textureProperties, texture, slot ) {
|
|
48250
48448
|
|
|
48449
|
+
if ( _deferTextureUploads ) {
|
|
48450
|
+
|
|
48451
|
+
if ( ! texture.isPendingDeferredUpload ) {
|
|
48452
|
+
|
|
48453
|
+
texture.isPendingDeferredUpload = true;
|
|
48454
|
+
_deferredUploads.push( { textureProperties: textureProperties, texture: texture, slot: slot } );
|
|
48455
|
+
|
|
48456
|
+
}
|
|
48457
|
+
|
|
48458
|
+
return false;
|
|
48459
|
+
|
|
48460
|
+
}
|
|
48461
|
+
|
|
48251
48462
|
let textureType = _gl.TEXTURE_2D;
|
|
48252
48463
|
|
|
48253
48464
|
if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
|
|
@@ -48677,6 +48888,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
48677
48888
|
}
|
|
48678
48889
|
|
|
48679
48890
|
textureProperties.__version = texture.version;
|
|
48891
|
+
return true;
|
|
48680
48892
|
|
|
48681
48893
|
}
|
|
48682
48894
|
|
|
@@ -48935,7 +49147,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
48935
49147
|
const width = Math.max( 1, renderTarget.width >> level );
|
|
48936
49148
|
const height = Math.max( 1, renderTarget.height >> level );
|
|
48937
49149
|
|
|
48938
|
-
if (
|
|
49150
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
49151
|
+
|
|
49152
|
+
state.texStorage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.numViews );
|
|
49153
|
+
|
|
49154
|
+
} else if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
|
|
48939
49155
|
|
|
48940
49156
|
state.texImage3D( textureTarget, level, glInternalFormat, width, height, renderTarget.depth, 0, glFormat, glType, null );
|
|
48941
49157
|
|
|
@@ -48949,13 +49165,31 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
48949
49165
|
|
|
48950
49166
|
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
48951
49167
|
|
|
48952
|
-
|
|
49168
|
+
const multisampled = useMultisampledRTT( renderTarget );
|
|
49169
|
+
|
|
49170
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
49171
|
+
|
|
49172
|
+
if ( multisampled ) {
|
|
48953
49173
|
|
|
48954
|
-
|
|
49174
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, 0, getRenderTargetSamples( renderTarget ), 0, renderTarget.numViews );
|
|
49175
|
+
|
|
49176
|
+
} else {
|
|
49177
|
+
|
|
49178
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, 0, 0, renderTarget.numViews );
|
|
49179
|
+
|
|
49180
|
+
}
|
|
48955
49181
|
|
|
48956
49182
|
} else if ( textureTarget === _gl.TEXTURE_2D || ( textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ) ) { // see #24753
|
|
48957
49183
|
|
|
48958
|
-
|
|
49184
|
+
if ( multisampled ) {
|
|
49185
|
+
|
|
49186
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, textureProperties.__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
|
|
49187
|
+
|
|
49188
|
+
} else {
|
|
49189
|
+
|
|
49190
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, textureProperties.__webglTexture, level );
|
|
49191
|
+
|
|
49192
|
+
}
|
|
48959
49193
|
|
|
48960
49194
|
}
|
|
48961
49195
|
|
|
@@ -48968,7 +49202,59 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
48968
49202
|
|
|
48969
49203
|
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
|
|
48970
49204
|
|
|
48971
|
-
if ( renderTarget.
|
|
49205
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
49206
|
+
|
|
49207
|
+
const useMultisample = useMultisampledRTT( renderTarget );
|
|
49208
|
+
const numViews = renderTarget.numViews;
|
|
49209
|
+
|
|
49210
|
+
const depthTexture = renderTarget.depthTexture;
|
|
49211
|
+
let glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
49212
|
+
let glDepthAttachment = _gl.DEPTH_ATTACHMENT;
|
|
49213
|
+
|
|
49214
|
+
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
49215
|
+
|
|
49216
|
+
if ( depthTexture.type === FloatType ) {
|
|
49217
|
+
|
|
49218
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
49219
|
+
|
|
49220
|
+
} else if ( depthTexture.type === UnsignedInt248Type ) {
|
|
49221
|
+
|
|
49222
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
49223
|
+
glDepthAttachment = _gl.DEPTH_STENCIL_ATTACHMENT;
|
|
49224
|
+
|
|
49225
|
+
}
|
|
49226
|
+
|
|
49227
|
+
// we're defaulting to _gl.DEPTH_COMPONENT24 so don't assign here
|
|
49228
|
+
// or else DeepScan will complain
|
|
49229
|
+
|
|
49230
|
+
// else if ( depthTexture.type === UnsignedIntType ) {
|
|
49231
|
+
|
|
49232
|
+
// glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
49233
|
+
|
|
49234
|
+
// }
|
|
49235
|
+
|
|
49236
|
+
}
|
|
49237
|
+
|
|
49238
|
+
let depthStencilTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
|
|
49239
|
+
if ( depthStencilTexture === undefined ) {
|
|
49240
|
+
|
|
49241
|
+
depthStencilTexture = _gl.createTexture();
|
|
49242
|
+
_gl.bindTexture( _gl.TEXTURE_2D_ARRAY, depthStencilTexture );
|
|
49243
|
+
_gl.texStorage3D( _gl.TEXTURE_2D_ARRAY, 1, glInternalFormat, renderTarget.width, renderTarget.height, numViews );
|
|
49244
|
+
|
|
49245
|
+
}
|
|
49246
|
+
|
|
49247
|
+
if ( useMultisample ) {
|
|
49248
|
+
|
|
49249
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, getRenderTargetSamples( renderTarget ), 0, numViews );
|
|
49250
|
+
|
|
49251
|
+
} else {
|
|
49252
|
+
|
|
49253
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, 0, numViews );
|
|
49254
|
+
|
|
49255
|
+
}
|
|
49256
|
+
|
|
49257
|
+
} else if ( renderTarget.depthBuffer ) {
|
|
48972
49258
|
|
|
48973
49259
|
// retrieve the depth attachment types
|
|
48974
49260
|
const depthTexture = renderTarget.depthTexture;
|
|
@@ -49058,38 +49344,85 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
49058
49344
|
|
|
49059
49345
|
}
|
|
49060
49346
|
|
|
49061
|
-
|
|
49347
|
+
if ( renderTarget.depthTexture.image.depth != 1 ) {
|
|
49348
|
+
|
|
49349
|
+
setTexture2DArray( renderTarget.depthTexture, 0 );
|
|
49350
|
+
|
|
49351
|
+
} else {
|
|
49352
|
+
|
|
49353
|
+
setTexture2D( renderTarget.depthTexture, 0 );
|
|
49354
|
+
|
|
49355
|
+
}
|
|
49062
49356
|
|
|
49063
49357
|
const webglDepthTexture = textureProperties.__webglTexture;
|
|
49064
49358
|
const samples = getRenderTargetSamples( renderTarget );
|
|
49065
49359
|
|
|
49066
|
-
if ( renderTarget.
|
|
49360
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
49067
49361
|
|
|
49068
|
-
|
|
49362
|
+
const useMultisample = useMultisampledRTT( renderTarget );
|
|
49363
|
+
const numViews = renderTarget.numViews;
|
|
49069
49364
|
|
|
49070
|
-
|
|
49365
|
+
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
49071
49366
|
|
|
49072
|
-
|
|
49367
|
+
if ( useMultisample ) {
|
|
49073
49368
|
|
|
49074
|
-
|
|
49369
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
|
|
49075
49370
|
|
|
49076
|
-
|
|
49371
|
+
} else {
|
|
49372
|
+
|
|
49373
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
|
|
49374
|
+
|
|
49375
|
+
}
|
|
49077
49376
|
|
|
49078
|
-
|
|
49377
|
+
} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
|
|
49079
49378
|
|
|
49080
|
-
|
|
49379
|
+
if ( useMultisample ) {
|
|
49081
49380
|
|
|
49082
|
-
|
|
49381
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
|
|
49382
|
+
|
|
49383
|
+
} else {
|
|
49384
|
+
|
|
49385
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
|
|
49386
|
+
|
|
49387
|
+
}
|
|
49083
49388
|
|
|
49084
49389
|
} else {
|
|
49085
49390
|
|
|
49086
|
-
|
|
49391
|
+
throw new Error( 'Unknown depthTexture format' );
|
|
49087
49392
|
|
|
49088
49393
|
}
|
|
49089
49394
|
|
|
49090
49395
|
} else {
|
|
49091
49396
|
|
|
49092
|
-
|
|
49397
|
+
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
49398
|
+
|
|
49399
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
49400
|
+
|
|
49401
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
|
|
49402
|
+
|
|
49403
|
+
} else {
|
|
49404
|
+
|
|
49405
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
|
|
49406
|
+
|
|
49407
|
+
}
|
|
49408
|
+
|
|
49409
|
+
} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
|
|
49410
|
+
|
|
49411
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
49412
|
+
|
|
49413
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
|
|
49414
|
+
|
|
49415
|
+
} else {
|
|
49416
|
+
|
|
49417
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
|
|
49418
|
+
|
|
49419
|
+
}
|
|
49420
|
+
|
|
49421
|
+
} else {
|
|
49422
|
+
|
|
49423
|
+
throw new Error( 'Unknown depthTexture format' );
|
|
49424
|
+
|
|
49425
|
+
}
|
|
49093
49426
|
|
|
49094
49427
|
}
|
|
49095
49428
|
|
|
@@ -49404,6 +49737,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
49404
49737
|
|
|
49405
49738
|
}
|
|
49406
49739
|
|
|
49740
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
49741
|
+
|
|
49742
|
+
glTextureType = _gl.TEXTURE_2D_ARRAY;
|
|
49743
|
+
|
|
49744
|
+
}
|
|
49745
|
+
|
|
49407
49746
|
state.bindTexture( glTextureType, textureProperties.__webglTexture );
|
|
49408
49747
|
setTextureParameters( glTextureType, texture );
|
|
49409
49748
|
|
|
@@ -49433,9 +49772,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
49433
49772
|
|
|
49434
49773
|
// Setup depth and stencil buffers
|
|
49435
49774
|
|
|
49436
|
-
if ( renderTarget.depthBuffer ) {
|
|
49775
|
+
if ( renderTarget.depthBuffer || renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
49437
49776
|
|
|
49438
|
-
setupDepthRenderbuffer( renderTarget );
|
|
49777
|
+
this.setupDepthRenderbuffer( renderTarget );
|
|
49439
49778
|
|
|
49440
49779
|
}
|
|
49441
49780
|
|
|
@@ -49680,12 +50019,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
49680
50019
|
this.setTexture3D = setTexture3D;
|
|
49681
50020
|
this.setTextureCube = setTextureCube;
|
|
49682
50021
|
this.rebindTextures = rebindTextures;
|
|
50022
|
+
this.uploadTexture = uploadTexture;
|
|
49683
50023
|
this.setupRenderTarget = setupRenderTarget;
|
|
49684
50024
|
this.updateRenderTargetMipmap = updateRenderTargetMipmap;
|
|
49685
50025
|
this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
|
|
50026
|
+
this.setupDepthTexture = setupDepthTexture;
|
|
49686
50027
|
this.setupDepthRenderbuffer = setupDepthRenderbuffer;
|
|
49687
50028
|
this.setupFrameBufferTexture = setupFrameBufferTexture;
|
|
49688
50029
|
this.useMultisampledRTT = useMultisampledRTT;
|
|
50030
|
+
this.runDeferredUploads = runDeferredUploads;
|
|
50031
|
+
this.setDeferTextureUploads = setDeferTextureUploads;
|
|
49689
50032
|
|
|
49690
50033
|
}
|
|
49691
50034
|
|
|
@@ -49898,6 +50241,39 @@ function WebGLUtils( gl, extensions ) {
|
|
|
49898
50241
|
|
|
49899
50242
|
}
|
|
49900
50243
|
|
|
50244
|
+
/**
|
|
50245
|
+
* @author fernandojsg / http://fernandojsg.com
|
|
50246
|
+
* @author Takahiro https://github.com/takahirox
|
|
50247
|
+
*/
|
|
50248
|
+
|
|
50249
|
+
|
|
50250
|
+
class WebGLMultiviewRenderTarget extends WebGLRenderTarget {
|
|
50251
|
+
|
|
50252
|
+
constructor( width, height, numViews, options = {} ) {
|
|
50253
|
+
|
|
50254
|
+
super( width, height, options );
|
|
50255
|
+
|
|
50256
|
+
this.depthBuffer = false;
|
|
50257
|
+
this.stencilBuffer = false;
|
|
50258
|
+
|
|
50259
|
+
this.numViews = numViews;
|
|
50260
|
+
|
|
50261
|
+
}
|
|
50262
|
+
|
|
50263
|
+
copy( source ) {
|
|
50264
|
+
|
|
50265
|
+
super.copy( source );
|
|
50266
|
+
|
|
50267
|
+
this.numViews = source.numViews;
|
|
50268
|
+
|
|
50269
|
+
return this;
|
|
50270
|
+
|
|
50271
|
+
}
|
|
50272
|
+
|
|
50273
|
+
}
|
|
50274
|
+
|
|
50275
|
+
WebGLMultiviewRenderTarget.prototype.isWebGLMultiviewRenderTarget = true;
|
|
50276
|
+
|
|
49901
50277
|
const _occlusion_vertex = `
|
|
49902
50278
|
void main() {
|
|
49903
50279
|
|
|
@@ -50004,7 +50380,7 @@ class WebXRDepthSensing {
|
|
|
50004
50380
|
|
|
50005
50381
|
class WebXRManager extends EventDispatcher {
|
|
50006
50382
|
|
|
50007
|
-
constructor( renderer, gl ) {
|
|
50383
|
+
constructor( renderer, gl, extensions, useMultiview ) {
|
|
50008
50384
|
|
|
50009
50385
|
super();
|
|
50010
50386
|
|
|
@@ -50013,6 +50389,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
50013
50389
|
let session = null;
|
|
50014
50390
|
|
|
50015
50391
|
let framebufferScaleFactor = 1.0;
|
|
50392
|
+
var poseTarget = null;
|
|
50016
50393
|
|
|
50017
50394
|
let referenceSpace = null;
|
|
50018
50395
|
let referenceSpaceType = 'local-floor';
|
|
@@ -50021,6 +50398,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
50021
50398
|
let customReferenceSpace = null;
|
|
50022
50399
|
|
|
50023
50400
|
let pose = null;
|
|
50401
|
+
var layers = [];
|
|
50402
|
+
|
|
50024
50403
|
let glBinding = null;
|
|
50025
50404
|
let glProjLayer = null;
|
|
50026
50405
|
let glBaseLayer = null;
|
|
@@ -50054,11 +50433,18 @@ class WebXRManager extends EventDispatcher {
|
|
|
50054
50433
|
let _currentDepthFar = null;
|
|
50055
50434
|
|
|
50056
50435
|
//
|
|
50057
|
-
|
|
50058
50436
|
this.cameraAutoUpdate = true;
|
|
50437
|
+
this.layersEnabled = false;
|
|
50059
50438
|
this.enabled = false;
|
|
50060
50439
|
|
|
50061
50440
|
this.isPresenting = false;
|
|
50441
|
+
this.isMultiview = false;
|
|
50442
|
+
|
|
50443
|
+
this.getCameraPose = function ( ) {
|
|
50444
|
+
|
|
50445
|
+
return pose;
|
|
50446
|
+
|
|
50447
|
+
};
|
|
50062
50448
|
|
|
50063
50449
|
this.getController = function ( index ) {
|
|
50064
50450
|
|
|
@@ -50227,6 +50613,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
50227
50613
|
|
|
50228
50614
|
};
|
|
50229
50615
|
|
|
50616
|
+
this.getRenderTarget = function () {
|
|
50617
|
+
|
|
50618
|
+
return newRenderTarget;
|
|
50619
|
+
|
|
50620
|
+
};
|
|
50621
|
+
|
|
50230
50622
|
this.getFrame = function () {
|
|
50231
50623
|
|
|
50232
50624
|
return xrFrame;
|
|
@@ -50311,12 +50703,20 @@ class WebXRManager extends EventDispatcher {
|
|
|
50311
50703
|
|
|
50312
50704
|
}
|
|
50313
50705
|
|
|
50706
|
+
scope.isMultiview = useMultiview && extensions.has( 'OCULUS_multiview' );
|
|
50707
|
+
|
|
50314
50708
|
const projectionlayerInit = {
|
|
50315
50709
|
colorFormat: gl.RGBA8,
|
|
50316
50710
|
depthFormat: glDepthFormat,
|
|
50317
50711
|
scaleFactor: framebufferScaleFactor
|
|
50318
50712
|
};
|
|
50319
50713
|
|
|
50714
|
+
if ( scope.isMultiview ) {
|
|
50715
|
+
|
|
50716
|
+
projectionlayerInit.textureType = 'texture-array';
|
|
50717
|
+
|
|
50718
|
+
}
|
|
50719
|
+
|
|
50320
50720
|
glBinding = new XRWebGLBinding( session, gl );
|
|
50321
50721
|
|
|
50322
50722
|
glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
|
|
@@ -50326,18 +50726,32 @@ class WebXRManager extends EventDispatcher {
|
|
|
50326
50726
|
renderer.setPixelRatio( 1 );
|
|
50327
50727
|
renderer.setSize( glProjLayer.textureWidth, glProjLayer.textureHeight, false );
|
|
50328
50728
|
|
|
50329
|
-
|
|
50330
|
-
|
|
50331
|
-
|
|
50332
|
-
|
|
50333
|
-
|
|
50334
|
-
|
|
50335
|
-
|
|
50336
|
-
|
|
50337
|
-
|
|
50338
|
-
|
|
50339
|
-
|
|
50340
|
-
|
|
50729
|
+
const renderTargetOptions = {
|
|
50730
|
+
format: RGBAFormat,
|
|
50731
|
+
type: UnsignedByteType,
|
|
50732
|
+
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
|
|
50733
|
+
stencilBuffer: attributes.stencil,
|
|
50734
|
+
colorSpace: renderer.outputColorSpace,
|
|
50735
|
+
samples: attributes.antialias ? 4 : 0,
|
|
50736
|
+
resolveDepthBuffer: ( glProjLayer.ignoreDepthValues === false )
|
|
50737
|
+
};
|
|
50738
|
+
|
|
50739
|
+
if ( scope.isMultiview ) {
|
|
50740
|
+
|
|
50741
|
+
const extension = extensions.get( 'OCULUS_multiview' );
|
|
50742
|
+
|
|
50743
|
+
this.maxNumViews = gl.getParameter( extension.MAX_VIEWS_OVR );
|
|
50744
|
+
|
|
50745
|
+
newRenderTarget = new WebGLMultiviewRenderTarget( glProjLayer.textureWidth, glProjLayer.textureHeight, 2, renderTargetOptions );
|
|
50746
|
+
|
|
50747
|
+
} else {
|
|
50748
|
+
|
|
50749
|
+
newRenderTarget = new WebGLRenderTarget(
|
|
50750
|
+
glProjLayer.textureWidth,
|
|
50751
|
+
glProjLayer.textureHeight,
|
|
50752
|
+
renderTargetOptions );
|
|
50753
|
+
|
|
50754
|
+
}
|
|
50341
50755
|
|
|
50342
50756
|
}
|
|
50343
50757
|
|
|
@@ -50366,7 +50780,28 @@ class WebXRManager extends EventDispatcher {
|
|
|
50366
50780
|
return session.environmentBlendMode;
|
|
50367
50781
|
|
|
50368
50782
|
}
|
|
50783
|
+
};
|
|
50784
|
+
|
|
50785
|
+
this.addLayer = function(layer) {
|
|
50786
|
+
if (!window.XRWebGLBinding || !this.layersEnabled || !session) { return; }
|
|
50787
|
+
|
|
50788
|
+
layers.push( layer );
|
|
50789
|
+
this.updateLayers();
|
|
50790
|
+
};
|
|
50791
|
+
|
|
50792
|
+
this.removeLayer = function(layer) {
|
|
50793
|
+
|
|
50794
|
+
layers.splice( layers.indexOf(layer), 1 );
|
|
50795
|
+
if (!window.XRWebGLBinding || !this.layersEnabled || !session) { return; }
|
|
50796
|
+
|
|
50797
|
+
this.updateLayers();
|
|
50798
|
+
};
|
|
50799
|
+
|
|
50800
|
+
this.updateLayers = function() {
|
|
50801
|
+
var layersCopy = layers.map(function (x) { return x; });
|
|
50369
50802
|
|
|
50803
|
+
layersCopy.unshift( session.renderState.layers[0] );
|
|
50804
|
+
session.updateRenderState( { layers: layersCopy } );
|
|
50370
50805
|
};
|
|
50371
50806
|
|
|
50372
50807
|
this.getDepthTexture = function () {
|
|
@@ -50535,6 +50970,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
50535
50970
|
|
|
50536
50971
|
}
|
|
50537
50972
|
|
|
50973
|
+
this.setPoseTarget = function ( object ) {
|
|
50974
|
+
|
|
50975
|
+
if ( object !== undefined ) poseTarget = object;
|
|
50976
|
+
|
|
50977
|
+
};
|
|
50978
|
+
|
|
50538
50979
|
this.updateCamera = function ( camera ) {
|
|
50539
50980
|
|
|
50540
50981
|
if ( session === null ) return;
|
|
@@ -50570,8 +51011,9 @@ class WebXRManager extends EventDispatcher {
|
|
|
50570
51011
|
cameraR.layers.mask = camera.layers.mask | 0b100;
|
|
50571
51012
|
cameraXR.layers.mask = cameraL.layers.mask | cameraR.layers.mask;
|
|
50572
51013
|
|
|
50573
|
-
const parent = camera.parent;
|
|
50574
51014
|
const cameras = cameraXR.cameras;
|
|
51015
|
+
var object = poseTarget || camera;
|
|
51016
|
+
const parent = object.parent;
|
|
50575
51017
|
|
|
50576
51018
|
updateCamera( cameraXR, parent );
|
|
50577
51019
|
|
|
@@ -50595,28 +51037,28 @@ class WebXRManager extends EventDispatcher {
|
|
|
50595
51037
|
|
|
50596
51038
|
}
|
|
50597
51039
|
|
|
50598
|
-
|
|
50599
|
-
|
|
50600
|
-
updateUserCamera( camera, cameraXR, parent );
|
|
51040
|
+
updateUserCamera( camera, cameraXR, object );
|
|
50601
51041
|
|
|
50602
51042
|
};
|
|
50603
51043
|
|
|
50604
|
-
function updateUserCamera( camera, cameraXR,
|
|
51044
|
+
function updateUserCamera( camera, cameraXR, object ) {
|
|
50605
51045
|
|
|
50606
|
-
|
|
51046
|
+
cameraXR.matrixWorld.decompose( cameraXR.position, cameraXR.quaternion, cameraXR.scale );
|
|
51047
|
+
|
|
51048
|
+
if ( object.parent === null ) {
|
|
50607
51049
|
|
|
50608
|
-
|
|
51050
|
+
object.matrix.copy( cameraXR.matrixWorld );
|
|
50609
51051
|
|
|
50610
51052
|
} else {
|
|
50611
51053
|
|
|
50612
|
-
|
|
50613
|
-
|
|
50614
|
-
|
|
51054
|
+
object.matrix.copy( object.parent.matrixWorld );
|
|
51055
|
+
object.matrix.invert();
|
|
51056
|
+
object.matrix.multiply( cameraXR.matrixWorld );
|
|
50615
51057
|
|
|
50616
51058
|
}
|
|
50617
51059
|
|
|
50618
|
-
|
|
50619
|
-
|
|
51060
|
+
object.matrix.decompose( object.position, object.quaternion, object.scale );
|
|
51061
|
+
object.updateMatrixWorld( true );
|
|
50620
51062
|
|
|
50621
51063
|
camera.projectionMatrix.copy( cameraXR.projectionMatrix );
|
|
50622
51064
|
camera.projectionMatrixInverse.copy( cameraXR.projectionMatrixInverse );
|
|
@@ -51828,6 +52270,7 @@ class WebGLRenderer {
|
|
|
51828
52270
|
powerPreference = 'default',
|
|
51829
52271
|
failIfMajorPerformanceCaveat = false,
|
|
51830
52272
|
reverseDepthBuffer = false,
|
|
52273
|
+
multiviewStereo = false,
|
|
51831
52274
|
} = parameters;
|
|
51832
52275
|
|
|
51833
52276
|
this.isWebGLRenderer = true;
|
|
@@ -52035,6 +52478,7 @@ class WebGLRenderer {
|
|
|
52035
52478
|
let extensions, capabilities, state, info;
|
|
52036
52479
|
let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
|
|
52037
52480
|
let programCache, materials, renderLists, renderStates, clipping, shadowMap;
|
|
52481
|
+
let multiview;
|
|
52038
52482
|
|
|
52039
52483
|
let background, morphtargets, bufferRenderer, indexedBufferRenderer;
|
|
52040
52484
|
|
|
@@ -52073,6 +52517,7 @@ class WebGLRenderer {
|
|
|
52073
52517
|
renderLists = new WebGLRenderLists();
|
|
52074
52518
|
renderStates = new WebGLRenderStates( extensions );
|
|
52075
52519
|
background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
|
|
52520
|
+
multiview = new WebGLMultiview( _this, extensions, _gl );
|
|
52076
52521
|
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
52077
52522
|
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
|
|
52078
52523
|
|
|
@@ -53009,11 +53454,21 @@ class WebGLRenderer {
|
|
|
53009
53454
|
|
|
53010
53455
|
if ( _renderBackground ) background.render( scene );
|
|
53011
53456
|
|
|
53012
|
-
|
|
53457
|
+
if ( xr.enabled && xr.isMultiview ) {
|
|
53013
53458
|
|
|
53014
|
-
|
|
53459
|
+
textures.setDeferTextureUploads( true );
|
|
53015
53460
|
|
|
53016
|
-
renderScene( currentRenderList, scene,
|
|
53461
|
+
renderScene( currentRenderList, scene, camera, camera.cameras[ 0 ].viewport );
|
|
53462
|
+
|
|
53463
|
+
} else {
|
|
53464
|
+
|
|
53465
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
53466
|
+
|
|
53467
|
+
const camera2 = cameras[ i ];
|
|
53468
|
+
|
|
53469
|
+
renderScene( currentRenderList, scene, camera2, camera2.viewport );
|
|
53470
|
+
|
|
53471
|
+
}
|
|
53017
53472
|
|
|
53018
53473
|
}
|
|
53019
53474
|
|
|
@@ -53539,6 +53994,7 @@ class WebGLRenderer {
|
|
|
53539
53994
|
materialProperties.vertexAlphas = parameters.vertexAlphas;
|
|
53540
53995
|
materialProperties.vertexTangents = parameters.vertexTangents;
|
|
53541
53996
|
materialProperties.toneMapping = parameters.toneMapping;
|
|
53997
|
+
materialProperties.numMultiviewViews = parameters.numMultiviewViews;
|
|
53542
53998
|
|
|
53543
53999
|
}
|
|
53544
54000
|
|
|
@@ -53570,6 +54026,8 @@ class WebGLRenderer {
|
|
|
53570
54026
|
|
|
53571
54027
|
}
|
|
53572
54028
|
|
|
54029
|
+
const numMultiviewViews = _currentRenderTarget && _currentRenderTarget.isWebGLMultiviewRenderTarget ? _currentRenderTarget.numViews : 0;
|
|
54030
|
+
|
|
53573
54031
|
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
53574
54032
|
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
53575
54033
|
|
|
@@ -53697,6 +54155,10 @@ class WebGLRenderer {
|
|
|
53697
54155
|
|
|
53698
54156
|
needsProgramChange = true;
|
|
53699
54157
|
|
|
54158
|
+
} else if ( materialProperties.numMultiviewViews !== numMultiviewViews ) {
|
|
54159
|
+
|
|
54160
|
+
needsProgramChange = true;
|
|
54161
|
+
|
|
53700
54162
|
}
|
|
53701
54163
|
|
|
53702
54164
|
} else {
|
|
@@ -53743,24 +54205,33 @@ class WebGLRenderer {
|
|
|
53743
54205
|
|
|
53744
54206
|
// common camera uniforms
|
|
53745
54207
|
|
|
53746
|
-
|
|
54208
|
+
if ( program.numMultiviewViews > 0 ) {
|
|
53747
54209
|
|
|
53748
|
-
|
|
54210
|
+
multiview.updateCameraProjectionMatricesUniform( camera, p_uniforms );
|
|
54211
|
+
multiview.updateCameraViewMatricesUniform( camera, p_uniforms );
|
|
53749
54212
|
|
|
53750
|
-
|
|
54213
|
+
} else {
|
|
53751
54214
|
|
|
53752
|
-
|
|
53753
|
-
toReversedProjectionMatrix( _currentProjectionMatrix );
|
|
54215
|
+
const reverseDepthBuffer = state.buffers.depth.getReversed();
|
|
53754
54216
|
|
|
53755
|
-
|
|
54217
|
+
if ( reverseDepthBuffer ) {
|
|
53756
54218
|
|
|
53757
|
-
|
|
54219
|
+
_currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
53758
54220
|
|
|
53759
|
-
|
|
54221
|
+
toNormalizedProjectionMatrix( _currentProjectionMatrix );
|
|
54222
|
+
toReversedProjectionMatrix( _currentProjectionMatrix );
|
|
53760
54223
|
|
|
53761
|
-
|
|
54224
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
|
|
54225
|
+
|
|
54226
|
+
} else {
|
|
54227
|
+
|
|
54228
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
53762
54229
|
|
|
53763
|
-
|
|
54230
|
+
}
|
|
54231
|
+
|
|
54232
|
+
p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
54233
|
+
|
|
54234
|
+
}
|
|
53764
54235
|
|
|
53765
54236
|
const uCamPos = p_uniforms.map.cameraPosition;
|
|
53766
54237
|
|
|
@@ -53922,8 +54393,17 @@ class WebGLRenderer {
|
|
|
53922
54393
|
|
|
53923
54394
|
// common matrices
|
|
53924
54395
|
|
|
53925
|
-
|
|
53926
|
-
|
|
54396
|
+
if ( program.numMultiviewViews > 0 ) {
|
|
54397
|
+
|
|
54398
|
+
multiview.updateObjectMatricesUniforms( object, camera, p_uniforms );
|
|
54399
|
+
|
|
54400
|
+
} else {
|
|
54401
|
+
|
|
54402
|
+
p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
|
|
54403
|
+
p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
|
|
54404
|
+
|
|
54405
|
+
}
|
|
54406
|
+
|
|
53927
54407
|
p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
|
|
53928
54408
|
|
|
53929
54409
|
// UBOs
|
|
@@ -53973,6 +54453,32 @@ class WebGLRenderer {
|
|
|
53973
54453
|
|
|
53974
54454
|
}
|
|
53975
54455
|
|
|
54456
|
+
this.setTexture2D = ( function () {
|
|
54457
|
+
|
|
54458
|
+
var warned = false;
|
|
54459
|
+
|
|
54460
|
+
// backwards compatibility: peel texture.texture
|
|
54461
|
+
return function setTexture2D( texture, slot ) {
|
|
54462
|
+
|
|
54463
|
+
if ( texture && texture.isWebGLRenderTarget ) {
|
|
54464
|
+
|
|
54465
|
+
if ( ! warned ) {
|
|
54466
|
+
|
|
54467
|
+
console.warn( "THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead." );
|
|
54468
|
+
warned = true;
|
|
54469
|
+
|
|
54470
|
+
}
|
|
54471
|
+
|
|
54472
|
+
texture = texture.texture;
|
|
54473
|
+
|
|
54474
|
+
}
|
|
54475
|
+
|
|
54476
|
+
textures.setTexture2D( texture, slot );
|
|
54477
|
+
|
|
54478
|
+
};
|
|
54479
|
+
|
|
54480
|
+
}() );
|
|
54481
|
+
|
|
53976
54482
|
this.getActiveCubeFace = function () {
|
|
53977
54483
|
|
|
53978
54484
|
return _currentActiveCubeFace;
|
|
@@ -54001,7 +54507,7 @@ class WebGLRenderer {
|
|
|
54001
54507
|
|
|
54002
54508
|
renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
|
|
54003
54509
|
|
|
54004
|
-
if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
|
|
54510
|
+
if ( ! renderTargetProperties.__autoAllocateDepthBuffer && ( ! _currentRenderTarget || ! _currentRenderTarget.isWebGLMultiviewRenderTarget ) ) {
|
|
54005
54511
|
|
|
54006
54512
|
// The multisample_render_to_texture extension doesn't work properly if there
|
|
54007
54513
|
// are midframe flushes and an external depth buffer. Disable use of the extension.
|
|
@@ -54027,6 +54533,13 @@ class WebGLRenderer {
|
|
|
54027
54533
|
const _scratchFrameBuffer = _gl.createFramebuffer();
|
|
54028
54534
|
this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
|
|
54029
54535
|
|
|
54536
|
+
// Render to base layer instead of canvas in WebXR
|
|
54537
|
+
if ( renderTarget === null && this.xr.isPresenting ) {
|
|
54538
|
+
|
|
54539
|
+
renderTarget = this.xr.getRenderTarget();
|
|
54540
|
+
|
|
54541
|
+
}
|
|
54542
|
+
|
|
54030
54543
|
_currentRenderTarget = renderTarget;
|
|
54031
54544
|
_currentActiveCubeFace = activeCubeFace;
|
|
54032
54545
|
_currentActiveMipmapLevel = activeMipmapLevel;
|