super-three 0.173.3 → 0.173.5
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 +783 -270
- package/build/three.core.js +174 -159
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +610 -112
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +90 -90
- package/build/three.webgpu.nodes.js +90 -90
- package/package.json +1 -1
- package/src/renderers/webxr/WebXRManager.js +2 -2
package/build/three.module.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2010-2025 Three.js Authors
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { Color, Matrix3, Vector2, mergeUniforms, Vector3, CubeUVReflectionMapping, Mesh, BoxGeometry, ShaderMaterial, cloneUniforms, BackSide, ColorManagement, SRGBTransfer, PlaneGeometry, FrontSide, getUnlitUniformColorSpace, Euler, Matrix4, IntType, RGBAFormat, HalfFloatType, UnsignedByteType, FloatType, Plane, EquirectangularReflectionMapping, EquirectangularRefractionMapping, WebGLCubeRenderTarget, CubeReflectionMapping, CubeRefractionMapping, PerspectiveCamera, NoToneMapping, MeshBasicMaterial, BufferGeometry, BufferAttribute, WebGLRenderTarget, NoBlending, OrthographicCamera, LinearFilter, LinearSRGBColorSpace, warnOnce, arrayNeedsUint32, Uint32BufferAttribute, Uint16BufferAttribute, Vector4, DataArrayTexture, LessEqualCompare, Texture, DepthTexture, Data3DTexture, CubeTexture, GLSL3, CustomToneMapping, NeutralToneMapping, AgXToneMapping, ACESFilmicToneMapping, CineonToneMapping, ReinhardToneMapping, LinearToneMapping, PCFShadowMap, PCFSoftShadowMap, VSMShadowMap, LinearTransfer, AddOperation, MixOperation, MultiplyOperation, ObjectSpaceNormalMap, TangentSpaceNormalMap, NormalBlending, DoubleSide, UniformsUtils, Layers, Frustum, MeshDepthMaterial, RGBADepthPacking, MeshDistanceMaterial, NearestFilter, LessEqualDepth, AddEquation, SubtractEquation, ReverseSubtractEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, CullFaceNone, CullFaceBack, CullFaceFront, NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessDepth, AlwaysDepth, NeverDepth, MinEquation, MaxEquation, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapNearestFilter, LinearMipmapLinearFilter, NeverCompare, AlwaysCompare, LessCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, NoColorSpace, DepthStencilFormat, getByteLength, UnsignedIntType, UnsignedInt248Type, UnsignedShortType,
|
|
6
|
+
import { Color, Matrix3, Vector2, mergeUniforms, Vector3, CubeUVReflectionMapping, Mesh, BoxGeometry, ShaderMaterial, cloneUniforms, BackSide, ColorManagement, SRGBTransfer, PlaneGeometry, FrontSide, getUnlitUniformColorSpace, Euler, Matrix4, IntType, RGBAFormat, HalfFloatType, UnsignedByteType, FloatType, Plane, EquirectangularReflectionMapping, EquirectangularRefractionMapping, WebGLCubeRenderTarget, CubeReflectionMapping, CubeRefractionMapping, PerspectiveCamera, NoToneMapping, MeshBasicMaterial, BufferGeometry, BufferAttribute, WebGLRenderTarget, NoBlending, OrthographicCamera, LinearFilter, LinearSRGBColorSpace, warnOnce, arrayNeedsUint32, Uint32BufferAttribute, Uint16BufferAttribute, Vector4, DataArrayTexture, LessEqualCompare, Texture, DepthTexture, Data3DTexture, CubeTexture, GLSL3, CustomToneMapping, NeutralToneMapping, AgXToneMapping, ACESFilmicToneMapping, CineonToneMapping, ReinhardToneMapping, LinearToneMapping, PCFShadowMap, PCFSoftShadowMap, VSMShadowMap, LinearTransfer, AddOperation, MixOperation, MultiplyOperation, ObjectSpaceNormalMap, TangentSpaceNormalMap, NormalBlending, DoubleSide, UniformsUtils, Layers, Frustum, MeshDepthMaterial, RGBADepthPacking, MeshDistanceMaterial, NearestFilter, LessEqualDepth, AddEquation, SubtractEquation, ReverseSubtractEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, CullFaceNone, CullFaceBack, CullFaceFront, NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessDepth, AlwaysDepth, NeverDepth, MinEquation, MaxEquation, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapNearestFilter, LinearMipmapLinearFilter, NeverCompare, AlwaysCompare, LessCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, NoColorSpace, DepthStencilFormat, getByteLength, DepthFormat, UnsignedIntType, UnsignedInt248Type, UnsignedShortType, createElementNS, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedInt5999Type, ByteType, ShortType, AlphaFormat, RGBFormat, LuminanceFormat, LuminanceAlphaFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, EventDispatcher, ArrayCamera, WebXRController, RAD2DEG, createCanvasElement, SRGBColorSpace, REVISION, toNormalizedProjectionMatrix, toReversedProjectionMatrix, probeAsync, WebGLCoordinateSystem } from './three.core.js';
|
|
7
7
|
export { AdditiveAnimationBlendMode, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxHelper, BufferGeometryLoader, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CircleGeometry, Clock, ColorKeyframeTrack, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, Controls, CubeCamera, CubeTextureLoader, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceFrontBack, Curve, CurvePath, CylinderGeometry, Cylindrical, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualStencilFunc, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, Fog, FogExp2, FramebufferTexture, GLBufferAttribute, GLSL1, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, MOUSE, Material, MaterialLoader, MathUtils, Matrix2, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NeverStencilFunc, NormalAnimationBlendMode, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, OctahedronGeometry, Path, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RGBDepthPacking, RGBIntegerFormat, RGDepthPacking, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RenderTarget, RenderTarget3D, RenderTargetArray, ReplaceStencilOp, RingGeometry, Scene, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, TOUCH, TetrahedronGeometry, TextureLoader, TextureUtils, TimestampQuery, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, VectorKeyframeTrack, VideoFrameTexture, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroSlopeEnding, ZeroStencilOp } from './three.core.js';
|
|
8
8
|
|
|
9
9
|
function WebGLAnimation() {
|
|
@@ -748,7 +748,7 @@ const UniformsLib = {
|
|
|
748
748
|
|
|
749
749
|
envMap: { value: null },
|
|
750
750
|
envMapRotation: { value: /*@__PURE__*/ new Matrix3() },
|
|
751
|
-
flipEnvMap: { value: -
|
|
751
|
+
flipEnvMap: { value: -1 },
|
|
752
752
|
reflectivity: { value: 1.0 }, // basic, lambert, phong
|
|
753
753
|
ior: { value: 1.5 }, // physical
|
|
754
754
|
refractionRatio: { value: 0.98 }, // basic, lambert, phong
|
|
@@ -1169,7 +1169,7 @@ const ShaderLib = {
|
|
|
1169
1169
|
|
|
1170
1170
|
uniforms: {
|
|
1171
1171
|
envMap: { value: null },
|
|
1172
|
-
flipEnvMap: { value: -
|
|
1172
|
+
flipEnvMap: { value: -1 },
|
|
1173
1173
|
backgroundBlurriness: { value: 0 },
|
|
1174
1174
|
backgroundIntensity: { value: 1 },
|
|
1175
1175
|
backgroundRotation: { value: /*@__PURE__*/ new Matrix3() }
|
|
@@ -1184,7 +1184,7 @@ const ShaderLib = {
|
|
|
1184
1184
|
|
|
1185
1185
|
uniforms: {
|
|
1186
1186
|
tCube: { value: null },
|
|
1187
|
-
tFlip: { value: -
|
|
1187
|
+
tFlip: { value: -1 },
|
|
1188
1188
|
opacity: { value: 1.0 }
|
|
1189
1189
|
},
|
|
1190
1190
|
|
|
@@ -1378,7 +1378,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
1378
1378
|
if ( boxMesh === undefined ) {
|
|
1379
1379
|
|
|
1380
1380
|
boxMesh = new Mesh(
|
|
1381
|
-
new BoxGeometry(
|
|
1381
|
+
new BoxGeometry( 10000, 10000, 10000 ),
|
|
1382
1382
|
new ShaderMaterial( {
|
|
1383
1383
|
name: 'BackgroundCubeMaterial',
|
|
1384
1384
|
uniforms: cloneUniforms( ShaderLib.backgroundCube.uniforms ),
|
|
@@ -1418,18 +1418,18 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
1418
1418
|
_e1$1.copy( scene.backgroundRotation );
|
|
1419
1419
|
|
|
1420
1420
|
// accommodate left-handed frame
|
|
1421
|
-
_e1$1.x *= -
|
|
1421
|
+
_e1$1.x *= -1; _e1$1.y *= -1; _e1$1.z *= -1;
|
|
1422
1422
|
|
|
1423
1423
|
if ( background.isCubeTexture && background.isRenderTargetTexture === false ) {
|
|
1424
1424
|
|
|
1425
1425
|
// environment maps which are not cube render targets or PMREMs follow a different convention
|
|
1426
|
-
_e1$1.y *= -
|
|
1427
|
-
_e1$1.z *= -
|
|
1426
|
+
_e1$1.y *= -1;
|
|
1427
|
+
_e1$1.z *= -1;
|
|
1428
1428
|
|
|
1429
1429
|
}
|
|
1430
1430
|
|
|
1431
1431
|
boxMesh.material.uniforms.envMap.value = background;
|
|
1432
|
-
boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? -
|
|
1432
|
+
boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? -1 : 1;
|
|
1433
1433
|
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
1434
1434
|
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
1435
1435
|
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1$1.makeRotationFromEuler( _e1$1 ) );
|
|
@@ -2693,9 +2693,9 @@ const _axisDirections = [
|
|
|
2693
2693
|
/*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
|
|
2694
2694
|
/*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
|
|
2695
2695
|
/*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
|
|
2696
|
-
/*@__PURE__*/ new Vector3( -
|
|
2697
|
-
/*@__PURE__*/ new Vector3( 1, 1, -
|
|
2698
|
-
/*@__PURE__*/ new Vector3( -
|
|
2696
|
+
/*@__PURE__*/ new Vector3( -1, 1, -1 ),
|
|
2697
|
+
/*@__PURE__*/ new Vector3( 1, 1, -1 ),
|
|
2698
|
+
/*@__PURE__*/ new Vector3( -1, 1, 1 ),
|
|
2699
2699
|
/*@__PURE__*/ new Vector3( 1, 1, 1 ) ];
|
|
2700
2700
|
|
|
2701
2701
|
/**
|
|
@@ -2963,8 +2963,8 @@ class PMREMGenerator {
|
|
|
2963
2963
|
const fov = 90;
|
|
2964
2964
|
const aspect = 1;
|
|
2965
2965
|
const cubeCamera = new PerspectiveCamera( fov, aspect, near, far );
|
|
2966
|
-
const upSign = [ 1, -
|
|
2967
|
-
const forwardSign = [ 1, 1, 1, -
|
|
2966
|
+
const upSign = [ 1, -1, 1, 1, 1, 1 ];
|
|
2967
|
+
const forwardSign = [ 1, 1, 1, -1, -1, -1 ];
|
|
2968
2968
|
const renderer = this._renderer;
|
|
2969
2969
|
|
|
2970
2970
|
const originalAutoClear = renderer.autoClear;
|
|
@@ -3063,7 +3063,7 @@ class PMREMGenerator {
|
|
|
3063
3063
|
|
|
3064
3064
|
}
|
|
3065
3065
|
|
|
3066
|
-
this._cubemapMaterial.uniforms.flipEnvMap.value = ( texture.isRenderTargetTexture === false ) ? -
|
|
3066
|
+
this._cubemapMaterial.uniforms.flipEnvMap.value = ( texture.isRenderTargetTexture === false ) ? -1 : 1;
|
|
3067
3067
|
|
|
3068
3068
|
} else {
|
|
3069
3069
|
|
|
@@ -3282,7 +3282,7 @@ function _createPlanes( lodMax ) {
|
|
|
3282
3282
|
for ( let face = 0; face < cubeFaces; face ++ ) {
|
|
3283
3283
|
|
|
3284
3284
|
const x = ( face % 3 ) * 2 / 3 - 1;
|
|
3285
|
-
const y = face > 2 ? 0 : -
|
|
3285
|
+
const y = face > 2 ? 0 : -1;
|
|
3286
3286
|
const coordinates = [
|
|
3287
3287
|
x, y, 0,
|
|
3288
3288
|
x + 2 / 3, y, 0,
|
|
@@ -3481,7 +3481,7 @@ function _getCubemapMaterial() {
|
|
|
3481
3481
|
|
|
3482
3482
|
uniforms: {
|
|
3483
3483
|
'envMap': { value: null },
|
|
3484
|
-
'flipEnvMap': { value: -
|
|
3484
|
+
'flipEnvMap': { value: -1 }
|
|
3485
3485
|
},
|
|
3486
3486
|
|
|
3487
3487
|
vertexShader: _getCommonVertexShader(),
|
|
@@ -4289,6 +4289,103 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
|
|
|
4289
4289
|
|
|
4290
4290
|
}
|
|
4291
4291
|
|
|
4292
|
+
/**
|
|
4293
|
+
* @author fernandojsg / http://fernandojsg.com
|
|
4294
|
+
* @author Takahiro https://github.com/takahirox
|
|
4295
|
+
*/
|
|
4296
|
+
|
|
4297
|
+
class WebGLMultiview {
|
|
4298
|
+
|
|
4299
|
+
constructor( renderer, extensions, gl ) {
|
|
4300
|
+
|
|
4301
|
+
this.renderer = renderer;
|
|
4302
|
+
|
|
4303
|
+
this.DEFAULT_NUMVIEWS = 2;
|
|
4304
|
+
this.maxNumViews = 0;
|
|
4305
|
+
this.gl = gl;
|
|
4306
|
+
|
|
4307
|
+
this.extensions = extensions;
|
|
4308
|
+
|
|
4309
|
+
this.available = this.extensions.has( 'OCULUS_multiview' );
|
|
4310
|
+
|
|
4311
|
+
if ( this.available ) {
|
|
4312
|
+
|
|
4313
|
+
const extension = this.extensions.get( 'OCULUS_multiview' );
|
|
4314
|
+
|
|
4315
|
+
this.maxNumViews = this.gl.getParameter( extension.MAX_VIEWS_OVR );
|
|
4316
|
+
|
|
4317
|
+
this.mat4 = [];
|
|
4318
|
+
this.mat3 = [];
|
|
4319
|
+
this.cameraArray = [];
|
|
4320
|
+
|
|
4321
|
+
for ( var i = 0; i < this.maxNumViews; i ++ ) {
|
|
4322
|
+
|
|
4323
|
+
this.mat4[ i ] = new Matrix4();
|
|
4324
|
+
this.mat3[ i ] = new Matrix3();
|
|
4325
|
+
|
|
4326
|
+
}
|
|
4327
|
+
|
|
4328
|
+
}
|
|
4329
|
+
|
|
4330
|
+
}
|
|
4331
|
+
|
|
4332
|
+
//
|
|
4333
|
+
getCameraArray( camera ) {
|
|
4334
|
+
|
|
4335
|
+
if ( camera.isArrayCamera ) return camera.cameras;
|
|
4336
|
+
|
|
4337
|
+
this.cameraArray[ 0 ] = camera;
|
|
4338
|
+
|
|
4339
|
+
return this.cameraArray;
|
|
4340
|
+
|
|
4341
|
+
}
|
|
4342
|
+
|
|
4343
|
+
updateCameraProjectionMatricesUniform( camera, uniforms ) {
|
|
4344
|
+
|
|
4345
|
+
var cameras = this.getCameraArray( camera );
|
|
4346
|
+
|
|
4347
|
+
for ( var i = 0; i < cameras.length; i ++ ) {
|
|
4348
|
+
|
|
4349
|
+
this.mat4[ i ].copy( cameras[ i ].projectionMatrix );
|
|
4350
|
+
|
|
4351
|
+
}
|
|
4352
|
+
|
|
4353
|
+
uniforms.setValue( this.gl, 'projectionMatrices', this.mat4 );
|
|
4354
|
+
|
|
4355
|
+
}
|
|
4356
|
+
|
|
4357
|
+
updateCameraViewMatricesUniform( camera, uniforms ) {
|
|
4358
|
+
|
|
4359
|
+
var cameras = this.getCameraArray( camera );
|
|
4360
|
+
|
|
4361
|
+
for ( var i = 0; i < cameras.length; i ++ ) {
|
|
4362
|
+
|
|
4363
|
+
this.mat4[ i ].copy( cameras[ i ].matrixWorldInverse );
|
|
4364
|
+
|
|
4365
|
+
}
|
|
4366
|
+
|
|
4367
|
+
uniforms.setValue( this.gl, 'viewMatrices', this.mat4 );
|
|
4368
|
+
|
|
4369
|
+
}
|
|
4370
|
+
|
|
4371
|
+
updateObjectMatricesUniforms( object, camera, uniforms ) {
|
|
4372
|
+
|
|
4373
|
+
var cameras = this.getCameraArray( camera );
|
|
4374
|
+
|
|
4375
|
+
for ( var i = 0; i < cameras.length; i ++ ) {
|
|
4376
|
+
|
|
4377
|
+
this.mat4[ i ].multiplyMatrices( cameras[ i ].matrixWorldInverse, object.matrixWorld );
|
|
4378
|
+
this.mat3[ i ].getNormalMatrix( this.mat4[ i ] );
|
|
4379
|
+
|
|
4380
|
+
}
|
|
4381
|
+
|
|
4382
|
+
uniforms.setValue( this.gl, 'modelViewMatrices', this.mat4 );
|
|
4383
|
+
uniforms.setValue( this.gl, 'normalMatrices', this.mat3 );
|
|
4384
|
+
|
|
4385
|
+
}
|
|
4386
|
+
|
|
4387
|
+
}
|
|
4388
|
+
|
|
4292
4389
|
function WebGLObjects( gl, geometries, attributes, info ) {
|
|
4293
4390
|
|
|
4294
4391
|
let updateMap = new WeakMap();
|
|
@@ -6040,6 +6137,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
6040
6137
|
let prefixVertex, prefixFragment;
|
|
6041
6138
|
let versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\n' : '';
|
|
6042
6139
|
|
|
6140
|
+
const numMultiviewViews = parameters.numMultiviewViews;
|
|
6141
|
+
|
|
6043
6142
|
if ( parameters.isRawShaderMaterial ) {
|
|
6044
6143
|
|
|
6045
6144
|
prefixVertex = [
|
|
@@ -6427,6 +6526,53 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
6427
6526
|
'#define textureCubeGradEXT textureGrad'
|
|
6428
6527
|
].join( '\n' ) + '\n' + prefixFragment;
|
|
6429
6528
|
|
|
6529
|
+
// Multiview
|
|
6530
|
+
|
|
6531
|
+
if ( numMultiviewViews > 0 ) {
|
|
6532
|
+
|
|
6533
|
+
// TODO: fix light transforms here?
|
|
6534
|
+
|
|
6535
|
+
prefixVertex = [
|
|
6536
|
+
'#extension GL_OVR_multiview : require',
|
|
6537
|
+
'layout(num_views = ' + numMultiviewViews + ') in;',
|
|
6538
|
+
'#define VIEW_ID gl_ViewID_OVR'
|
|
6539
|
+
].join( '\n' ) + '\n' + prefixVertex;
|
|
6540
|
+
|
|
6541
|
+
prefixVertex = prefixVertex.replace(
|
|
6542
|
+
[
|
|
6543
|
+
'uniform mat4 modelViewMatrix;',
|
|
6544
|
+
'uniform mat4 projectionMatrix;',
|
|
6545
|
+
'uniform mat4 viewMatrix;',
|
|
6546
|
+
'uniform mat3 normalMatrix;'
|
|
6547
|
+
].join( '\n' ),
|
|
6548
|
+
[
|
|
6549
|
+
'uniform mat4 modelViewMatrices[' + numMultiviewViews + '];',
|
|
6550
|
+
'uniform mat4 projectionMatrices[' + numMultiviewViews + '];',
|
|
6551
|
+
'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
|
|
6552
|
+
'uniform mat3 normalMatrices[' + numMultiviewViews + '];',
|
|
6553
|
+
|
|
6554
|
+
'#define modelViewMatrix modelViewMatrices[VIEW_ID]',
|
|
6555
|
+
'#define projectionMatrix projectionMatrices[VIEW_ID]',
|
|
6556
|
+
'#define viewMatrix viewMatrices[VIEW_ID]',
|
|
6557
|
+
'#define normalMatrix normalMatrices[VIEW_ID]'
|
|
6558
|
+
].join( '\n' )
|
|
6559
|
+
);
|
|
6560
|
+
|
|
6561
|
+
prefixFragment = [
|
|
6562
|
+
'#extension GL_OVR_multiview : require',
|
|
6563
|
+
'#define VIEW_ID gl_ViewID_OVR'
|
|
6564
|
+
].join( '\n' ) + '\n' + prefixFragment;
|
|
6565
|
+
|
|
6566
|
+
prefixFragment = prefixFragment.replace(
|
|
6567
|
+
'uniform mat4 viewMatrix;',
|
|
6568
|
+
[
|
|
6569
|
+
'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
|
|
6570
|
+
'#define viewMatrix viewMatrices[VIEW_ID]'
|
|
6571
|
+
].join( '\n' )
|
|
6572
|
+
);
|
|
6573
|
+
|
|
6574
|
+
}
|
|
6575
|
+
|
|
6430
6576
|
}
|
|
6431
6577
|
|
|
6432
6578
|
const vertexGlsl = versionString + prefixVertex + vertexShader;
|
|
@@ -6619,6 +6765,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
6619
6765
|
this.program = program;
|
|
6620
6766
|
this.vertexShader = glVertexShader;
|
|
6621
6767
|
this.fragmentShader = glFragmentShader;
|
|
6768
|
+
this.numMultiviewViews = numMultiviewViews;
|
|
6622
6769
|
|
|
6623
6770
|
return this;
|
|
6624
6771
|
|
|
@@ -6851,6 +6998,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
6851
6998
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
6852
6999
|
const reverseDepthBuffer = renderer.state.buffers.depth.getReversed();
|
|
6853
7000
|
|
|
7001
|
+
const numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
|
|
7002
|
+
|
|
6854
7003
|
const IS_INSTANCEDMESH = object.isInstancedMesh === true;
|
|
6855
7004
|
const IS_BATCHEDMESH = object.isBatchedMesh === true;
|
|
6856
7005
|
|
|
@@ -6940,6 +7089,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
6940
7089
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
6941
7090
|
|
|
6942
7091
|
supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
|
|
7092
|
+
numMultiviewViews: numMultiviewViews,
|
|
6943
7093
|
outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
|
|
6944
7094
|
alphaToCoverage: !! material.alphaToCoverage,
|
|
6945
7095
|
|
|
@@ -7304,6 +7454,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
7304
7454
|
_programLayers.enable( 20 );
|
|
7305
7455
|
if ( parameters.alphaToCoverage )
|
|
7306
7456
|
_programLayers.enable( 21 );
|
|
7457
|
+
if ( parameters.numMultiviewViews )
|
|
7458
|
+
_programLayers.enable( 21 );
|
|
7307
7459
|
|
|
7308
7460
|
array.push( _programLayers.mask );
|
|
7309
7461
|
|
|
@@ -7851,18 +8003,18 @@ function WebGLLights( extensions ) {
|
|
|
7851
8003
|
version: 0,
|
|
7852
8004
|
|
|
7853
8005
|
hash: {
|
|
7854
|
-
directionalLength: -
|
|
7855
|
-
pointLength: -
|
|
7856
|
-
spotLength: -
|
|
7857
|
-
rectAreaLength: -
|
|
7858
|
-
hemiLength: -
|
|
7859
|
-
|
|
7860
|
-
numDirectionalShadows: -
|
|
7861
|
-
numPointShadows: -
|
|
7862
|
-
numSpotShadows: -
|
|
7863
|
-
numSpotMaps: -
|
|
7864
|
-
|
|
7865
|
-
numLightProbes: -
|
|
8006
|
+
directionalLength: -1,
|
|
8007
|
+
pointLength: -1,
|
|
8008
|
+
spotLength: -1,
|
|
8009
|
+
rectAreaLength: -1,
|
|
8010
|
+
hemiLength: -1,
|
|
8011
|
+
|
|
8012
|
+
numDirectionalShadows: -1,
|
|
8013
|
+
numPointShadows: -1,
|
|
8014
|
+
numSpotShadows: -1,
|
|
8015
|
+
numSpotMaps: -1,
|
|
8016
|
+
|
|
8017
|
+
numLightProbes: -1
|
|
7866
8018
|
},
|
|
7867
8019
|
|
|
7868
8020
|
ambient: [ 0, 0, 0 ],
|
|
@@ -8403,7 +8555,7 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
|
8403
8555
|
fullScreenTri.setAttribute(
|
|
8404
8556
|
'position',
|
|
8405
8557
|
new BufferAttribute(
|
|
8406
|
-
new Float32Array( [ -
|
|
8558
|
+
new Float32Array( [ -1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5 ] ),
|
|
8407
8559
|
3
|
|
8408
8560
|
)
|
|
8409
8561
|
);
|
|
@@ -8836,7 +8988,7 @@ function WebGLState( gl, extensions ) {
|
|
|
8836
8988
|
locked = false;
|
|
8837
8989
|
|
|
8838
8990
|
currentColorMask = null;
|
|
8839
|
-
currentColorClear.set( -
|
|
8991
|
+
currentColorClear.set( -1, 0, 0, 0 ); // set to invalid state
|
|
8840
8992
|
|
|
8841
8993
|
}
|
|
8842
8994
|
|
|
@@ -9165,12 +9317,12 @@ function WebGLState( gl, extensions ) {
|
|
|
9165
9317
|
let version = 0;
|
|
9166
9318
|
const glVersion = gl.getParameter( gl.VERSION );
|
|
9167
9319
|
|
|
9168
|
-
if ( glVersion.indexOf( 'WebGL' ) !== -
|
|
9320
|
+
if ( glVersion.indexOf( 'WebGL' ) !== -1 ) {
|
|
9169
9321
|
|
|
9170
9322
|
version = parseFloat( /^WebGL (\d)/.exec( glVersion )[ 1 ] );
|
|
9171
9323
|
lineWidthAvailable = ( version >= 1.0 );
|
|
9172
9324
|
|
|
9173
|
-
} else if ( glVersion.indexOf( 'OpenGL ES' ) !== -
|
|
9325
|
+
} else if ( glVersion.indexOf( 'OpenGL ES' ) !== -1 ) {
|
|
9174
9326
|
|
|
9175
9327
|
version = parseFloat( /^OpenGL ES (\d)/.exec( glVersion )[ 1 ] );
|
|
9176
9328
|
lineWidthAvailable = ( version >= 2.0 );
|
|
@@ -10101,6 +10253,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
10101
10253
|
|
|
10102
10254
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
10103
10255
|
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
10256
|
+
const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
|
|
10104
10257
|
|
|
10105
10258
|
const _imageDimensions = new Vector2();
|
|
10106
10259
|
const _videoTextures = new WeakMap();
|
|
@@ -10108,6 +10261,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
10108
10261
|
|
|
10109
10262
|
const _sources = new WeakMap(); // maps WebglTexture objects to instances of Source
|
|
10110
10263
|
|
|
10264
|
+
let _deferredUploads = [];
|
|
10265
|
+
let _deferTextureUploads = false;
|
|
10266
|
+
|
|
10111
10267
|
// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,
|
|
10112
10268
|
// also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")!
|
|
10113
10269
|
// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).
|
|
@@ -10622,8 +10778,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
10622
10778
|
|
|
10623
10779
|
} else {
|
|
10624
10780
|
|
|
10625
|
-
uploadTexture( textureProperties, texture, slot )
|
|
10626
|
-
|
|
10781
|
+
if ( uploadTexture( textureProperties, texture, slot ) ) {
|
|
10782
|
+
|
|
10783
|
+
return;
|
|
10784
|
+
|
|
10785
|
+
}
|
|
10627
10786
|
|
|
10628
10787
|
}
|
|
10629
10788
|
|
|
@@ -10832,8 +10991,45 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
10832
10991
|
|
|
10833
10992
|
}
|
|
10834
10993
|
|
|
10994
|
+
function setDeferTextureUploads( deferFlag ) {
|
|
10995
|
+
|
|
10996
|
+
_deferTextureUploads = deferFlag;
|
|
10997
|
+
|
|
10998
|
+
}
|
|
10999
|
+
|
|
11000
|
+
function runDeferredUploads() {
|
|
11001
|
+
|
|
11002
|
+
const previousDeferSetting = _deferTextureUploads;
|
|
11003
|
+
_deferTextureUploads = false;
|
|
11004
|
+
|
|
11005
|
+
for ( const upload of _deferredUploads ) {
|
|
11006
|
+
|
|
11007
|
+
uploadTexture( upload.textureProperties, upload.texture, upload.slot );
|
|
11008
|
+
upload.texture.isPendingDeferredUpload = false;
|
|
11009
|
+
|
|
11010
|
+
}
|
|
11011
|
+
|
|
11012
|
+
_deferredUploads = [];
|
|
11013
|
+
|
|
11014
|
+
_deferTextureUploads = previousDeferSetting;
|
|
11015
|
+
|
|
11016
|
+
}
|
|
11017
|
+
|
|
10835
11018
|
function uploadTexture( textureProperties, texture, slot ) {
|
|
10836
11019
|
|
|
11020
|
+
if ( _deferTextureUploads ) {
|
|
11021
|
+
|
|
11022
|
+
if ( ! texture.isPendingDeferredUpload ) {
|
|
11023
|
+
|
|
11024
|
+
texture.isPendingDeferredUpload = true;
|
|
11025
|
+
_deferredUploads.push( { textureProperties: textureProperties, texture: texture, slot: slot } );
|
|
11026
|
+
|
|
11027
|
+
}
|
|
11028
|
+
|
|
11029
|
+
return false;
|
|
11030
|
+
|
|
11031
|
+
}
|
|
11032
|
+
|
|
10837
11033
|
let textureType = _gl.TEXTURE_2D;
|
|
10838
11034
|
|
|
10839
11035
|
if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
|
|
@@ -11263,6 +11459,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
11263
11459
|
}
|
|
11264
11460
|
|
|
11265
11461
|
textureProperties.__version = texture.version;
|
|
11462
|
+
return true;
|
|
11266
11463
|
|
|
11267
11464
|
}
|
|
11268
11465
|
|
|
@@ -11521,7 +11718,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
11521
11718
|
const width = Math.max( 1, renderTarget.width >> level );
|
|
11522
11719
|
const height = Math.max( 1, renderTarget.height >> level );
|
|
11523
11720
|
|
|
11524
|
-
if (
|
|
11721
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
11722
|
+
|
|
11723
|
+
state.texStorage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.numViews );
|
|
11724
|
+
|
|
11725
|
+
} else if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
|
|
11525
11726
|
|
|
11526
11727
|
state.texImage3D( textureTarget, level, glInternalFormat, width, height, renderTarget.depth, 0, glFormat, glType, null );
|
|
11527
11728
|
|
|
@@ -11535,13 +11736,31 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
11535
11736
|
|
|
11536
11737
|
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
11537
11738
|
|
|
11538
|
-
|
|
11739
|
+
const multisampled = useMultisampledRTT( renderTarget );
|
|
11740
|
+
|
|
11741
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
11742
|
+
|
|
11743
|
+
if ( multisampled ) {
|
|
11539
11744
|
|
|
11540
|
-
|
|
11745
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, 0, getRenderTargetSamples( renderTarget ), 0, renderTarget.numViews );
|
|
11746
|
+
|
|
11747
|
+
} else {
|
|
11748
|
+
|
|
11749
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, 0, 0, renderTarget.numViews );
|
|
11750
|
+
|
|
11751
|
+
}
|
|
11541
11752
|
|
|
11542
11753
|
} else if ( textureTarget === _gl.TEXTURE_2D || ( textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ) ) { // see #24753
|
|
11543
11754
|
|
|
11544
|
-
|
|
11755
|
+
if ( multisampled ) {
|
|
11756
|
+
|
|
11757
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, textureProperties.__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
|
|
11758
|
+
|
|
11759
|
+
} else {
|
|
11760
|
+
|
|
11761
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, textureProperties.__webglTexture, level );
|
|
11762
|
+
|
|
11763
|
+
}
|
|
11545
11764
|
|
|
11546
11765
|
}
|
|
11547
11766
|
|
|
@@ -11554,7 +11773,59 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
11554
11773
|
|
|
11555
11774
|
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
|
|
11556
11775
|
|
|
11557
|
-
if ( renderTarget.
|
|
11776
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
11777
|
+
|
|
11778
|
+
const useMultisample = useMultisampledRTT( renderTarget );
|
|
11779
|
+
const numViews = renderTarget.numViews;
|
|
11780
|
+
|
|
11781
|
+
const depthTexture = renderTarget.depthTexture;
|
|
11782
|
+
let glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
11783
|
+
let glDepthAttachment = _gl.DEPTH_ATTACHMENT;
|
|
11784
|
+
|
|
11785
|
+
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
11786
|
+
|
|
11787
|
+
if ( depthTexture.type === FloatType ) {
|
|
11788
|
+
|
|
11789
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
11790
|
+
|
|
11791
|
+
} else if ( depthTexture.type === UnsignedInt248Type ) {
|
|
11792
|
+
|
|
11793
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
11794
|
+
glDepthAttachment = _gl.DEPTH_STENCIL_ATTACHMENT;
|
|
11795
|
+
|
|
11796
|
+
}
|
|
11797
|
+
|
|
11798
|
+
// we're defaulting to _gl.DEPTH_COMPONENT24 so don't assign here
|
|
11799
|
+
// or else DeepScan will complain
|
|
11800
|
+
|
|
11801
|
+
// else if ( depthTexture.type === UnsignedIntType ) {
|
|
11802
|
+
|
|
11803
|
+
// glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
11804
|
+
|
|
11805
|
+
// }
|
|
11806
|
+
|
|
11807
|
+
}
|
|
11808
|
+
|
|
11809
|
+
let depthStencilTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
|
|
11810
|
+
if ( depthStencilTexture === undefined ) {
|
|
11811
|
+
|
|
11812
|
+
depthStencilTexture = _gl.createTexture();
|
|
11813
|
+
_gl.bindTexture( _gl.TEXTURE_2D_ARRAY, depthStencilTexture );
|
|
11814
|
+
_gl.texStorage3D( _gl.TEXTURE_2D_ARRAY, 1, glInternalFormat, renderTarget.width, renderTarget.height, numViews );
|
|
11815
|
+
|
|
11816
|
+
}
|
|
11817
|
+
|
|
11818
|
+
if ( useMultisample ) {
|
|
11819
|
+
|
|
11820
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, getRenderTargetSamples( renderTarget ), 0, numViews );
|
|
11821
|
+
|
|
11822
|
+
} else {
|
|
11823
|
+
|
|
11824
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, 0, numViews );
|
|
11825
|
+
|
|
11826
|
+
}
|
|
11827
|
+
|
|
11828
|
+
} else if ( renderTarget.depthBuffer ) {
|
|
11558
11829
|
|
|
11559
11830
|
// retrieve the depth attachment types
|
|
11560
11831
|
const depthTexture = renderTarget.depthTexture;
|
|
@@ -11644,38 +11915,85 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
11644
11915
|
|
|
11645
11916
|
}
|
|
11646
11917
|
|
|
11647
|
-
|
|
11918
|
+
if ( renderTarget.depthTexture.image.depth != 1 ) {
|
|
11919
|
+
|
|
11920
|
+
setTexture2DArray( renderTarget.depthTexture, 0 );
|
|
11921
|
+
|
|
11922
|
+
} else {
|
|
11923
|
+
|
|
11924
|
+
setTexture2D( renderTarget.depthTexture, 0 );
|
|
11925
|
+
|
|
11926
|
+
}
|
|
11648
11927
|
|
|
11649
11928
|
const webglDepthTexture = textureProperties.__webglTexture;
|
|
11650
11929
|
const samples = getRenderTargetSamples( renderTarget );
|
|
11651
11930
|
|
|
11652
|
-
if ( renderTarget.
|
|
11931
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
11653
11932
|
|
|
11654
|
-
|
|
11933
|
+
const useMultisample = useMultisampledRTT( renderTarget );
|
|
11934
|
+
const numViews = renderTarget.numViews;
|
|
11655
11935
|
|
|
11656
|
-
|
|
11936
|
+
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
11657
11937
|
|
|
11658
|
-
|
|
11938
|
+
if ( useMultisample ) {
|
|
11659
11939
|
|
|
11660
|
-
|
|
11940
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
|
|
11661
11941
|
|
|
11662
|
-
|
|
11942
|
+
} else {
|
|
11943
|
+
|
|
11944
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
|
|
11945
|
+
|
|
11946
|
+
}
|
|
11663
11947
|
|
|
11664
|
-
|
|
11948
|
+
} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
|
|
11665
11949
|
|
|
11666
|
-
|
|
11950
|
+
if ( useMultisample ) {
|
|
11667
11951
|
|
|
11668
|
-
|
|
11952
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
|
|
11953
|
+
|
|
11954
|
+
} else {
|
|
11955
|
+
|
|
11956
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
|
|
11957
|
+
|
|
11958
|
+
}
|
|
11669
11959
|
|
|
11670
11960
|
} else {
|
|
11671
11961
|
|
|
11672
|
-
|
|
11962
|
+
throw new Error( 'Unknown depthTexture format' );
|
|
11673
11963
|
|
|
11674
11964
|
}
|
|
11675
11965
|
|
|
11676
11966
|
} else {
|
|
11677
11967
|
|
|
11678
|
-
|
|
11968
|
+
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
11969
|
+
|
|
11970
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
11971
|
+
|
|
11972
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
|
|
11973
|
+
|
|
11974
|
+
} else {
|
|
11975
|
+
|
|
11976
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
|
|
11977
|
+
|
|
11978
|
+
}
|
|
11979
|
+
|
|
11980
|
+
} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
|
|
11981
|
+
|
|
11982
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
11983
|
+
|
|
11984
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
|
|
11985
|
+
|
|
11986
|
+
} else {
|
|
11987
|
+
|
|
11988
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
|
|
11989
|
+
|
|
11990
|
+
}
|
|
11991
|
+
|
|
11992
|
+
} else {
|
|
11993
|
+
|
|
11994
|
+
throw new Error( 'Unknown depthTexture format' );
|
|
11995
|
+
|
|
11996
|
+
}
|
|
11679
11997
|
|
|
11680
11998
|
}
|
|
11681
11999
|
|
|
@@ -11990,6 +12308,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
11990
12308
|
|
|
11991
12309
|
}
|
|
11992
12310
|
|
|
12311
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
12312
|
+
|
|
12313
|
+
glTextureType = _gl.TEXTURE_2D_ARRAY;
|
|
12314
|
+
|
|
12315
|
+
}
|
|
12316
|
+
|
|
11993
12317
|
state.bindTexture( glTextureType, textureProperties.__webglTexture );
|
|
11994
12318
|
setTextureParameters( glTextureType, texture );
|
|
11995
12319
|
|
|
@@ -12019,9 +12343,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
12019
12343
|
|
|
12020
12344
|
// Setup depth and stencil buffers
|
|
12021
12345
|
|
|
12022
|
-
if ( renderTarget.depthBuffer ) {
|
|
12346
|
+
if ( renderTarget.depthBuffer || renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
12023
12347
|
|
|
12024
|
-
setupDepthRenderbuffer( renderTarget );
|
|
12348
|
+
this.setupDepthRenderbuffer( renderTarget );
|
|
12025
12349
|
|
|
12026
12350
|
}
|
|
12027
12351
|
|
|
@@ -12266,12 +12590,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
12266
12590
|
this.setTexture3D = setTexture3D;
|
|
12267
12591
|
this.setTextureCube = setTextureCube;
|
|
12268
12592
|
this.rebindTextures = rebindTextures;
|
|
12593
|
+
this.uploadTexture = uploadTexture;
|
|
12269
12594
|
this.setupRenderTarget = setupRenderTarget;
|
|
12270
12595
|
this.updateRenderTargetMipmap = updateRenderTargetMipmap;
|
|
12271
12596
|
this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
|
|
12597
|
+
this.setupDepthTexture = setupDepthTexture;
|
|
12272
12598
|
this.setupDepthRenderbuffer = setupDepthRenderbuffer;
|
|
12273
12599
|
this.setupFrameBufferTexture = setupFrameBufferTexture;
|
|
12274
12600
|
this.useMultisampledRTT = useMultisampledRTT;
|
|
12601
|
+
this.runDeferredUploads = runDeferredUploads;
|
|
12602
|
+
this.setDeferTextureUploads = setDeferTextureUploads;
|
|
12275
12603
|
|
|
12276
12604
|
}
|
|
12277
12605
|
|
|
@@ -12484,6 +12812,39 @@ function WebGLUtils( gl, extensions ) {
|
|
|
12484
12812
|
|
|
12485
12813
|
}
|
|
12486
12814
|
|
|
12815
|
+
/**
|
|
12816
|
+
* @author fernandojsg / http://fernandojsg.com
|
|
12817
|
+
* @author Takahiro https://github.com/takahirox
|
|
12818
|
+
*/
|
|
12819
|
+
|
|
12820
|
+
|
|
12821
|
+
class WebGLMultiviewRenderTarget extends WebGLRenderTarget {
|
|
12822
|
+
|
|
12823
|
+
constructor( width, height, numViews, options = {} ) {
|
|
12824
|
+
|
|
12825
|
+
super( width, height, options );
|
|
12826
|
+
|
|
12827
|
+
this.depthBuffer = false;
|
|
12828
|
+
this.stencilBuffer = false;
|
|
12829
|
+
|
|
12830
|
+
this.numViews = numViews;
|
|
12831
|
+
|
|
12832
|
+
}
|
|
12833
|
+
|
|
12834
|
+
copy( source ) {
|
|
12835
|
+
|
|
12836
|
+
super.copy( source );
|
|
12837
|
+
|
|
12838
|
+
this.numViews = source.numViews;
|
|
12839
|
+
|
|
12840
|
+
return this;
|
|
12841
|
+
|
|
12842
|
+
}
|
|
12843
|
+
|
|
12844
|
+
}
|
|
12845
|
+
|
|
12846
|
+
WebGLMultiviewRenderTarget.prototype.isWebGLMultiviewRenderTarget = true;
|
|
12847
|
+
|
|
12487
12848
|
const _occlusion_vertex = `
|
|
12488
12849
|
void main() {
|
|
12489
12850
|
|
|
@@ -12590,7 +12951,7 @@ class WebXRDepthSensing {
|
|
|
12590
12951
|
|
|
12591
12952
|
class WebXRManager extends EventDispatcher {
|
|
12592
12953
|
|
|
12593
|
-
constructor( renderer, gl ) {
|
|
12954
|
+
constructor( renderer, gl, extensions, useMultiview ) {
|
|
12594
12955
|
|
|
12595
12956
|
super();
|
|
12596
12957
|
|
|
@@ -12599,6 +12960,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
12599
12960
|
let session = null;
|
|
12600
12961
|
|
|
12601
12962
|
let framebufferScaleFactor = 1.0;
|
|
12963
|
+
var poseTarget = null;
|
|
12602
12964
|
|
|
12603
12965
|
let referenceSpace = null;
|
|
12604
12966
|
let referenceSpaceType = 'local-floor';
|
|
@@ -12607,6 +12969,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
12607
12969
|
let customReferenceSpace = null;
|
|
12608
12970
|
|
|
12609
12971
|
let pose = null;
|
|
12972
|
+
var layers = [];
|
|
12973
|
+
|
|
12610
12974
|
let glBinding = null;
|
|
12611
12975
|
let glProjLayer = null;
|
|
12612
12976
|
let glBaseLayer = null;
|
|
@@ -12640,11 +13004,18 @@ class WebXRManager extends EventDispatcher {
|
|
|
12640
13004
|
let _currentDepthFar = null;
|
|
12641
13005
|
|
|
12642
13006
|
//
|
|
12643
|
-
|
|
12644
13007
|
this.cameraAutoUpdate = true;
|
|
13008
|
+
this.layersEnabled = false;
|
|
12645
13009
|
this.enabled = false;
|
|
12646
13010
|
|
|
12647
13011
|
this.isPresenting = false;
|
|
13012
|
+
this.isMultiview = false;
|
|
13013
|
+
|
|
13014
|
+
this.getCameraPose = function ( ) {
|
|
13015
|
+
|
|
13016
|
+
return pose;
|
|
13017
|
+
|
|
13018
|
+
};
|
|
12648
13019
|
|
|
12649
13020
|
this.getController = function ( index ) {
|
|
12650
13021
|
|
|
@@ -12697,7 +13068,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
12697
13068
|
|
|
12698
13069
|
const controllerIndex = controllerInputSources.indexOf( event.inputSource );
|
|
12699
13070
|
|
|
12700
|
-
if ( controllerIndex === -
|
|
13071
|
+
if ( controllerIndex === -1 ) {
|
|
12701
13072
|
|
|
12702
13073
|
return;
|
|
12703
13074
|
|
|
@@ -12744,6 +13115,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
12744
13115
|
|
|
12745
13116
|
// restore framebuffer/rendering state
|
|
12746
13117
|
|
|
13118
|
+
scope.isPresenting = false;
|
|
13119
|
+
|
|
12747
13120
|
renderer.setRenderTarget( initialRenderTarget );
|
|
12748
13121
|
|
|
12749
13122
|
glBaseLayer = null;
|
|
@@ -12756,8 +13129,6 @@ class WebXRManager extends EventDispatcher {
|
|
|
12756
13129
|
|
|
12757
13130
|
animation.stop();
|
|
12758
13131
|
|
|
12759
|
-
scope.isPresenting = false;
|
|
12760
|
-
|
|
12761
13132
|
renderer.setPixelRatio( currentPixelRatio );
|
|
12762
13133
|
renderer.setSize( currentSize.width, currentSize.height, false );
|
|
12763
13134
|
|
|
@@ -12813,6 +13184,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
12813
13184
|
|
|
12814
13185
|
};
|
|
12815
13186
|
|
|
13187
|
+
this.getRenderTarget = function () {
|
|
13188
|
+
|
|
13189
|
+
return newRenderTarget;
|
|
13190
|
+
|
|
13191
|
+
};
|
|
13192
|
+
|
|
12816
13193
|
this.getFrame = function () {
|
|
12817
13194
|
|
|
12818
13195
|
return xrFrame;
|
|
@@ -12897,12 +13274,20 @@ class WebXRManager extends EventDispatcher {
|
|
|
12897
13274
|
|
|
12898
13275
|
}
|
|
12899
13276
|
|
|
13277
|
+
scope.isMultiview = useMultiview && extensions.has( 'OCULUS_multiview' );
|
|
13278
|
+
|
|
12900
13279
|
const projectionlayerInit = {
|
|
12901
13280
|
colorFormat: gl.RGBA8,
|
|
12902
13281
|
depthFormat: glDepthFormat,
|
|
12903
13282
|
scaleFactor: framebufferScaleFactor
|
|
12904
13283
|
};
|
|
12905
13284
|
|
|
13285
|
+
if ( scope.isMultiview ) {
|
|
13286
|
+
|
|
13287
|
+
projectionlayerInit.textureType = 'texture-array';
|
|
13288
|
+
|
|
13289
|
+
}
|
|
13290
|
+
|
|
12906
13291
|
glBinding = new XRWebGLBinding( session, gl );
|
|
12907
13292
|
|
|
12908
13293
|
glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
|
|
@@ -12912,18 +13297,32 @@ class WebXRManager extends EventDispatcher {
|
|
|
12912
13297
|
renderer.setPixelRatio( 1 );
|
|
12913
13298
|
renderer.setSize( glProjLayer.textureWidth, glProjLayer.textureHeight, false );
|
|
12914
13299
|
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
13300
|
+
const renderTargetOptions = {
|
|
13301
|
+
format: RGBAFormat,
|
|
13302
|
+
type: UnsignedByteType,
|
|
13303
|
+
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
|
|
13304
|
+
stencilBuffer: attributes.stencil,
|
|
13305
|
+
colorSpace: renderer.outputColorSpace,
|
|
13306
|
+
samples: attributes.antialias ? 4 : 0,
|
|
13307
|
+
resolveDepthBuffer: ( glProjLayer.ignoreDepthValues === false )
|
|
13308
|
+
};
|
|
13309
|
+
|
|
13310
|
+
if ( scope.isMultiview ) {
|
|
13311
|
+
|
|
13312
|
+
const extension = extensions.get( 'OCULUS_multiview' );
|
|
13313
|
+
|
|
13314
|
+
this.maxNumViews = gl.getParameter( extension.MAX_VIEWS_OVR );
|
|
13315
|
+
|
|
13316
|
+
newRenderTarget = new WebGLMultiviewRenderTarget( glProjLayer.textureWidth, glProjLayer.textureHeight, 2, renderTargetOptions );
|
|
13317
|
+
|
|
13318
|
+
} else {
|
|
13319
|
+
|
|
13320
|
+
newRenderTarget = new WebGLRenderTarget(
|
|
13321
|
+
glProjLayer.textureWidth,
|
|
13322
|
+
glProjLayer.textureHeight,
|
|
13323
|
+
renderTargetOptions );
|
|
13324
|
+
|
|
13325
|
+
}
|
|
12927
13326
|
|
|
12928
13327
|
}
|
|
12929
13328
|
|
|
@@ -12952,7 +13351,28 @@ class WebXRManager extends EventDispatcher {
|
|
|
12952
13351
|
return session.environmentBlendMode;
|
|
12953
13352
|
|
|
12954
13353
|
}
|
|
13354
|
+
};
|
|
13355
|
+
|
|
13356
|
+
this.addLayer = function(layer) {
|
|
13357
|
+
if (!window.XRWebGLBinding || !this.layersEnabled || !session) { return; }
|
|
12955
13358
|
|
|
13359
|
+
layers.push( layer );
|
|
13360
|
+
this.updateLayers();
|
|
13361
|
+
};
|
|
13362
|
+
|
|
13363
|
+
this.removeLayer = function(layer) {
|
|
13364
|
+
|
|
13365
|
+
layers.splice( layers.indexOf(layer), 1 );
|
|
13366
|
+
if (!window.XRWebGLBinding || !this.layersEnabled || !session) { return; }
|
|
13367
|
+
|
|
13368
|
+
this.updateLayers();
|
|
13369
|
+
};
|
|
13370
|
+
|
|
13371
|
+
this.updateLayers = function() {
|
|
13372
|
+
var layersCopy = layers.map(function (x) { return x; });
|
|
13373
|
+
|
|
13374
|
+
layersCopy.unshift( session.renderState.layers[0] );
|
|
13375
|
+
session.updateRenderState( { layers: layersCopy } );
|
|
12956
13376
|
};
|
|
12957
13377
|
|
|
12958
13378
|
this.getDepthTexture = function () {
|
|
@@ -12987,7 +13407,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
12987
13407
|
|
|
12988
13408
|
let controllerIndex = controllerInputSources.indexOf( inputSource );
|
|
12989
13409
|
|
|
12990
|
-
if ( controllerIndex === -
|
|
13410
|
+
if ( controllerIndex === -1 ) {
|
|
12991
13411
|
|
|
12992
13412
|
// Assign input source a controller that currently has no input source
|
|
12993
13413
|
|
|
@@ -13011,7 +13431,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
13011
13431
|
|
|
13012
13432
|
// If all controllers do currently receive input we ignore new ones
|
|
13013
13433
|
|
|
13014
|
-
if ( controllerIndex === -
|
|
13434
|
+
if ( controllerIndex === -1 ) break;
|
|
13015
13435
|
|
|
13016
13436
|
}
|
|
13017
13437
|
|
|
@@ -13078,7 +13498,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
13078
13498
|
camera.matrixWorldInverse.copy( camera.matrixWorld ).invert();
|
|
13079
13499
|
|
|
13080
13500
|
// Check if the projection uses an infinite far plane.
|
|
13081
|
-
if ( projL[ 10 ] === -
|
|
13501
|
+
if ( projL[ 10 ] === -1 ) {
|
|
13082
13502
|
|
|
13083
13503
|
// Use the projection matrix from the left eye.
|
|
13084
13504
|
// The camera offset is sufficient to include the view volumes
|
|
@@ -13121,6 +13541,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
13121
13541
|
|
|
13122
13542
|
}
|
|
13123
13543
|
|
|
13544
|
+
this.setPoseTarget = function ( object ) {
|
|
13545
|
+
|
|
13546
|
+
if ( object !== undefined ) poseTarget = object;
|
|
13547
|
+
|
|
13548
|
+
};
|
|
13549
|
+
|
|
13124
13550
|
this.updateCamera = function ( camera ) {
|
|
13125
13551
|
|
|
13126
13552
|
if ( session === null ) return;
|
|
@@ -13156,8 +13582,9 @@ class WebXRManager extends EventDispatcher {
|
|
|
13156
13582
|
cameraR.layers.mask = camera.layers.mask | 0b100;
|
|
13157
13583
|
cameraXR.layers.mask = cameraL.layers.mask | cameraR.layers.mask;
|
|
13158
13584
|
|
|
13159
|
-
const parent = camera.parent;
|
|
13160
13585
|
const cameras = cameraXR.cameras;
|
|
13586
|
+
var object = poseTarget || camera;
|
|
13587
|
+
const parent = object.parent;
|
|
13161
13588
|
|
|
13162
13589
|
updateCamera( cameraXR, parent );
|
|
13163
13590
|
|
|
@@ -13181,28 +13608,28 @@ class WebXRManager extends EventDispatcher {
|
|
|
13181
13608
|
|
|
13182
13609
|
}
|
|
13183
13610
|
|
|
13184
|
-
|
|
13185
|
-
|
|
13186
|
-
updateUserCamera( camera, cameraXR, parent );
|
|
13611
|
+
updateUserCamera( camera, cameraXR, object );
|
|
13187
13612
|
|
|
13188
13613
|
};
|
|
13189
13614
|
|
|
13190
|
-
function updateUserCamera( camera, cameraXR,
|
|
13615
|
+
function updateUserCamera( camera, cameraXR, object ) {
|
|
13191
13616
|
|
|
13192
|
-
|
|
13617
|
+
cameraXR.matrixWorld.decompose( cameraXR.position, cameraXR.quaternion, cameraXR.scale );
|
|
13618
|
+
|
|
13619
|
+
if ( object.parent === null ) {
|
|
13193
13620
|
|
|
13194
|
-
|
|
13621
|
+
object.matrix.copy( cameraXR.matrixWorld );
|
|
13195
13622
|
|
|
13196
13623
|
} else {
|
|
13197
13624
|
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13625
|
+
object.matrix.copy( object.parent.matrixWorld );
|
|
13626
|
+
object.matrix.invert();
|
|
13627
|
+
object.matrix.multiply( cameraXR.matrixWorld );
|
|
13201
13628
|
|
|
13202
13629
|
}
|
|
13203
13630
|
|
|
13204
|
-
|
|
13205
|
-
|
|
13631
|
+
object.matrix.decompose( object.position, object.quaternion, object.scale );
|
|
13632
|
+
object.updateMatrixWorld( true );
|
|
13206
13633
|
|
|
13207
13634
|
camera.projectionMatrix.copy( cameraXR.projectionMatrix );
|
|
13208
13635
|
camera.projectionMatrixInverse.copy( cameraXR.projectionMatrixInverse );
|
|
@@ -13579,7 +14006,7 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
13579
14006
|
|
|
13580
14007
|
if ( material.side === BackSide ) {
|
|
13581
14008
|
|
|
13582
|
-
uniforms.bumpScale.value *= -
|
|
14009
|
+
uniforms.bumpScale.value *= -1;
|
|
13583
14010
|
|
|
13584
14011
|
}
|
|
13585
14012
|
|
|
@@ -13646,19 +14073,19 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
13646
14073
|
_e1.copy( envMapRotation );
|
|
13647
14074
|
|
|
13648
14075
|
// accommodate left-handed frame
|
|
13649
|
-
_e1.x *= -
|
|
14076
|
+
_e1.x *= -1; _e1.y *= -1; _e1.z *= -1;
|
|
13650
14077
|
|
|
13651
14078
|
if ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) {
|
|
13652
14079
|
|
|
13653
14080
|
// environment maps which are not cube render targets or PMREMs follow a different convention
|
|
13654
|
-
_e1.y *= -
|
|
13655
|
-
_e1.z *= -
|
|
14081
|
+
_e1.y *= -1;
|
|
14082
|
+
_e1.z *= -1;
|
|
13656
14083
|
|
|
13657
14084
|
}
|
|
13658
14085
|
|
|
13659
14086
|
uniforms.envMapRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );
|
|
13660
14087
|
|
|
13661
|
-
uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? -
|
|
14088
|
+
uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? -1 : 1;
|
|
13662
14089
|
|
|
13663
14090
|
uniforms.reflectivity.value = material.reflectivity;
|
|
13664
14091
|
uniforms.ior.value = material.ior;
|
|
@@ -14081,7 +14508,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
14081
14508
|
|
|
14082
14509
|
for ( let i = 0; i < maxBindingPoints; i ++ ) {
|
|
14083
14510
|
|
|
14084
|
-
if ( allocatedBindingPoints.indexOf( i ) === -
|
|
14511
|
+
if ( allocatedBindingPoints.indexOf( i ) === -1 ) {
|
|
14085
14512
|
|
|
14086
14513
|
allocatedBindingPoints.push( i );
|
|
14087
14514
|
return i;
|
|
@@ -14414,6 +14841,7 @@ class WebGLRenderer {
|
|
|
14414
14841
|
powerPreference = 'default',
|
|
14415
14842
|
failIfMajorPerformanceCaveat = false,
|
|
14416
14843
|
reverseDepthBuffer = false,
|
|
14844
|
+
multiviewStereo = false,
|
|
14417
14845
|
} = parameters;
|
|
14418
14846
|
|
|
14419
14847
|
this.isWebGLRenderer = true;
|
|
@@ -14503,7 +14931,7 @@ class WebGLRenderer {
|
|
|
14503
14931
|
let _currentActiveCubeFace = 0;
|
|
14504
14932
|
let _currentActiveMipmapLevel = 0;
|
|
14505
14933
|
let _currentRenderTarget = null;
|
|
14506
|
-
let _currentMaterialId = -
|
|
14934
|
+
let _currentMaterialId = -1;
|
|
14507
14935
|
|
|
14508
14936
|
let _currentCamera = null;
|
|
14509
14937
|
|
|
@@ -14621,6 +15049,7 @@ class WebGLRenderer {
|
|
|
14621
15049
|
let extensions, capabilities, state, info;
|
|
14622
15050
|
let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
|
|
14623
15051
|
let programCache, materials, renderLists, renderStates, clipping, shadowMap;
|
|
15052
|
+
let multiview;
|
|
14624
15053
|
|
|
14625
15054
|
let background, morphtargets, bufferRenderer, indexedBufferRenderer;
|
|
14626
15055
|
|
|
@@ -14659,6 +15088,7 @@ class WebGLRenderer {
|
|
|
14659
15088
|
renderLists = new WebGLRenderLists();
|
|
14660
15089
|
renderStates = new WebGLRenderStates( extensions );
|
|
14661
15090
|
background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
|
|
15091
|
+
multiview = new WebGLMultiview( _this, extensions, _gl );
|
|
14662
15092
|
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
14663
15093
|
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
|
|
14664
15094
|
|
|
@@ -15595,11 +16025,21 @@ class WebGLRenderer {
|
|
|
15595
16025
|
|
|
15596
16026
|
if ( _renderBackground ) background.render( scene );
|
|
15597
16027
|
|
|
15598
|
-
|
|
16028
|
+
if ( xr.enabled && xr.isMultiview ) {
|
|
16029
|
+
|
|
16030
|
+
textures.setDeferTextureUploads( true );
|
|
16031
|
+
|
|
16032
|
+
renderScene( currentRenderList, scene, camera, camera.cameras[ 0 ].viewport );
|
|
16033
|
+
|
|
16034
|
+
} else {
|
|
16035
|
+
|
|
16036
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
15599
16037
|
|
|
15600
|
-
|
|
16038
|
+
const camera2 = cameras[ i ];
|
|
15601
16039
|
|
|
15602
|
-
|
|
16040
|
+
renderScene( currentRenderList, scene, camera2, camera2.viewport );
|
|
16041
|
+
|
|
16042
|
+
}
|
|
15603
16043
|
|
|
15604
16044
|
}
|
|
15605
16045
|
|
|
@@ -15634,7 +16074,7 @@ class WebGLRenderer {
|
|
|
15634
16074
|
// _gl.finish();
|
|
15635
16075
|
|
|
15636
16076
|
bindingStates.resetDefaultState();
|
|
15637
|
-
_currentMaterialId = -
|
|
16077
|
+
_currentMaterialId = -1;
|
|
15638
16078
|
_currentCamera = null;
|
|
15639
16079
|
|
|
15640
16080
|
renderStateStack.pop();
|
|
@@ -16125,6 +16565,7 @@ class WebGLRenderer {
|
|
|
16125
16565
|
materialProperties.vertexAlphas = parameters.vertexAlphas;
|
|
16126
16566
|
materialProperties.vertexTangents = parameters.vertexTangents;
|
|
16127
16567
|
materialProperties.toneMapping = parameters.toneMapping;
|
|
16568
|
+
materialProperties.numMultiviewViews = parameters.numMultiviewViews;
|
|
16128
16569
|
|
|
16129
16570
|
}
|
|
16130
16571
|
|
|
@@ -16156,6 +16597,8 @@ class WebGLRenderer {
|
|
|
16156
16597
|
|
|
16157
16598
|
}
|
|
16158
16599
|
|
|
16600
|
+
const numMultiviewViews = _currentRenderTarget && _currentRenderTarget.isWebGLMultiviewRenderTarget ? _currentRenderTarget.numViews : 0;
|
|
16601
|
+
|
|
16159
16602
|
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
16160
16603
|
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
16161
16604
|
|
|
@@ -16283,6 +16726,10 @@ class WebGLRenderer {
|
|
|
16283
16726
|
|
|
16284
16727
|
needsProgramChange = true;
|
|
16285
16728
|
|
|
16729
|
+
} else if ( materialProperties.numMultiviewViews !== numMultiviewViews ) {
|
|
16730
|
+
|
|
16731
|
+
needsProgramChange = true;
|
|
16732
|
+
|
|
16286
16733
|
}
|
|
16287
16734
|
|
|
16288
16735
|
} else {
|
|
@@ -16329,24 +16776,33 @@ class WebGLRenderer {
|
|
|
16329
16776
|
|
|
16330
16777
|
// common camera uniforms
|
|
16331
16778
|
|
|
16332
|
-
|
|
16779
|
+
if ( program.numMultiviewViews > 0 ) {
|
|
16333
16780
|
|
|
16334
|
-
|
|
16781
|
+
multiview.updateCameraProjectionMatricesUniform( camera, p_uniforms );
|
|
16782
|
+
multiview.updateCameraViewMatricesUniform( camera, p_uniforms );
|
|
16335
16783
|
|
|
16336
|
-
|
|
16784
|
+
} else {
|
|
16337
16785
|
|
|
16338
|
-
|
|
16339
|
-
toReversedProjectionMatrix( _currentProjectionMatrix );
|
|
16786
|
+
const reverseDepthBuffer = state.buffers.depth.getReversed();
|
|
16340
16787
|
|
|
16341
|
-
|
|
16788
|
+
if ( reverseDepthBuffer ) {
|
|
16342
16789
|
|
|
16343
|
-
|
|
16790
|
+
_currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
16344
16791
|
|
|
16345
|
-
|
|
16792
|
+
toNormalizedProjectionMatrix( _currentProjectionMatrix );
|
|
16793
|
+
toReversedProjectionMatrix( _currentProjectionMatrix );
|
|
16346
16794
|
|
|
16347
|
-
|
|
16795
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
|
|
16796
|
+
|
|
16797
|
+
} else {
|
|
16798
|
+
|
|
16799
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
16800
|
+
|
|
16801
|
+
}
|
|
16802
|
+
|
|
16803
|
+
p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
16348
16804
|
|
|
16349
|
-
|
|
16805
|
+
}
|
|
16350
16806
|
|
|
16351
16807
|
const uCamPos = p_uniforms.map.cameraPosition;
|
|
16352
16808
|
|
|
@@ -16450,7 +16906,7 @@ class WebGLRenderer {
|
|
|
16450
16906
|
|
|
16451
16907
|
m_uniforms.envMap.value = envMap;
|
|
16452
16908
|
|
|
16453
|
-
m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? -
|
|
16909
|
+
m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? -1 : 1;
|
|
16454
16910
|
|
|
16455
16911
|
}
|
|
16456
16912
|
|
|
@@ -16508,8 +16964,17 @@ class WebGLRenderer {
|
|
|
16508
16964
|
|
|
16509
16965
|
// common matrices
|
|
16510
16966
|
|
|
16511
|
-
|
|
16512
|
-
|
|
16967
|
+
if ( program.numMultiviewViews > 0 ) {
|
|
16968
|
+
|
|
16969
|
+
multiview.updateObjectMatricesUniforms( object, camera, p_uniforms );
|
|
16970
|
+
|
|
16971
|
+
} else {
|
|
16972
|
+
|
|
16973
|
+
p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
|
|
16974
|
+
p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
|
|
16975
|
+
|
|
16976
|
+
}
|
|
16977
|
+
|
|
16513
16978
|
p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
|
|
16514
16979
|
|
|
16515
16980
|
// UBOs
|
|
@@ -16559,6 +17024,32 @@ class WebGLRenderer {
|
|
|
16559
17024
|
|
|
16560
17025
|
}
|
|
16561
17026
|
|
|
17027
|
+
this.setTexture2D = ( function () {
|
|
17028
|
+
|
|
17029
|
+
var warned = false;
|
|
17030
|
+
|
|
17031
|
+
// backwards compatibility: peel texture.texture
|
|
17032
|
+
return function setTexture2D( texture, slot ) {
|
|
17033
|
+
|
|
17034
|
+
if ( texture && texture.isWebGLRenderTarget ) {
|
|
17035
|
+
|
|
17036
|
+
if ( ! warned ) {
|
|
17037
|
+
|
|
17038
|
+
console.warn( "THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead." );
|
|
17039
|
+
warned = true;
|
|
17040
|
+
|
|
17041
|
+
}
|
|
17042
|
+
|
|
17043
|
+
texture = texture.texture;
|
|
17044
|
+
|
|
17045
|
+
}
|
|
17046
|
+
|
|
17047
|
+
textures.setTexture2D( texture, slot );
|
|
17048
|
+
|
|
17049
|
+
};
|
|
17050
|
+
|
|
17051
|
+
}() );
|
|
17052
|
+
|
|
16562
17053
|
this.getActiveCubeFace = function () {
|
|
16563
17054
|
|
|
16564
17055
|
return _currentActiveCubeFace;
|
|
@@ -16587,7 +17078,7 @@ class WebGLRenderer {
|
|
|
16587
17078
|
|
|
16588
17079
|
renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
|
|
16589
17080
|
|
|
16590
|
-
if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
|
|
17081
|
+
if ( ! renderTargetProperties.__autoAllocateDepthBuffer && ( ! _currentRenderTarget || ! _currentRenderTarget.isWebGLMultiviewRenderTarget ) ) {
|
|
16591
17082
|
|
|
16592
17083
|
// The multisample_render_to_texture extension doesn't work properly if there
|
|
16593
17084
|
// are midframe flushes and an external depth buffer. Disable use of the extension.
|
|
@@ -16613,6 +17104,13 @@ class WebGLRenderer {
|
|
|
16613
17104
|
const _scratchFrameBuffer = _gl.createFramebuffer();
|
|
16614
17105
|
this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
|
|
16615
17106
|
|
|
17107
|
+
// Render to base layer instead of canvas in WebXR
|
|
17108
|
+
if ( renderTarget === null && this.xr.isPresenting ) {
|
|
17109
|
+
|
|
17110
|
+
renderTarget = this.xr.getRenderTarget();
|
|
17111
|
+
|
|
17112
|
+
}
|
|
17113
|
+
|
|
16616
17114
|
_currentRenderTarget = renderTarget;
|
|
16617
17115
|
_currentActiveCubeFace = activeCubeFace;
|
|
16618
17116
|
_currentActiveMipmapLevel = activeMipmapLevel;
|
|
@@ -16759,7 +17257,7 @@ class WebGLRenderer {
|
|
|
16759
17257
|
|
|
16760
17258
|
}
|
|
16761
17259
|
|
|
16762
|
-
_currentMaterialId = -
|
|
17260
|
+
_currentMaterialId = -1; // reset current material to ensure correct uniform bindings
|
|
16763
17261
|
|
|
16764
17262
|
};
|
|
16765
17263
|
|