super-three 0.156.0 → 0.157.1
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 +753 -277
- package/build/three.js +753 -277
- package/build/three.min.js +2 -2
- package/build/three.module.js +750 -276
- package/build/three.module.min.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +17 -0
- package/examples/jsm/controls/DragControls.js +3 -2
- package/examples/jsm/csm/CSMShader.js +25 -21
- package/examples/jsm/exporters/EXRExporter.js +102 -24
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lights/LightProbeGenerator.js +37 -3
- package/examples/jsm/lines/LineMaterial.js +90 -156
- package/examples/jsm/loaders/3DMLoader.js +378 -104
- package/examples/jsm/loaders/GLTFLoader.js +1 -1
- package/examples/jsm/loaders/LDrawLoader.js +22 -16
- package/examples/jsm/loaders/RGBELoader.js +1 -1
- package/examples/jsm/loaders/USDZLoader.js +215 -12
- package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
- package/examples/jsm/nodes/Nodes.js +5 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +2 -2
- package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +2 -2
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +6 -5
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +7 -9
- package/examples/jsm/nodes/accessors/MaterialNode.js +34 -46
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +9 -9
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
- package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
- package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
- package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +12 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +1 -1
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
- package/examples/jsm/nodes/code/CodeNode.js +1 -1
- package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionNode.js +18 -7
- package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
- package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
- package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/BypassNode.js +1 -1
- package/examples/jsm/nodes/core/CacheNode.js +1 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/ContextNode.js +2 -2
- package/examples/jsm/nodes/core/IndexNode.js +1 -1
- package/examples/jsm/nodes/core/InputNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +28 -13
- package/examples/jsm/nodes/core/NodeBuilder.js +3 -17
- package/examples/jsm/nodes/core/NodeFrame.js +37 -14
- package/examples/jsm/nodes/core/OutputStructNode.js +8 -4
- package/examples/jsm/nodes/core/PropertyNode.js +3 -3
- package/examples/jsm/nodes/core/StackNode.js +1 -1
- package/examples/jsm/nodes/core/StructTypeNode.js +1 -1
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +3 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -1
- package/examples/jsm/nodes/core/VaryingNode.js +1 -1
- package/examples/jsm/nodes/core/constants.js +1 -1
- package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
- package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
- package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
- package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
- package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
- package/examples/jsm/nodes/fog/FogNode.js +2 -2
- package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AONode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
- package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/NodeMaterial.js +27 -26
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/math/CondNode.js +1 -1
- package/examples/jsm/nodes/math/HashNode.js +8 -9
- package/examples/jsm/nodes/math/MathNode.js +2 -2
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +81 -28
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
- package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
- package/examples/jsm/nodes/utils/JoinNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +11 -11
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/OscNode.js +2 -2
- package/examples/jsm/nodes/utils/PackingNode.js +2 -2
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
- package/examples/jsm/nodes/utils/SetNode.js +62 -0
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +1 -1
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
- package/examples/jsm/objects/Sky.js +1 -3
- package/examples/jsm/postprocessing/OutputPass.js +3 -2
- package/examples/jsm/renderers/common/Background.js +2 -2
- package/examples/jsm/renderers/common/Bindings.js +3 -5
- package/examples/jsm/renderers/common/Pipelines.js +7 -7
- package/examples/jsm/renderers/common/RenderContext.js +3 -0
- package/examples/jsm/renderers/common/RenderObject.js +40 -16
- package/examples/jsm/renderers/common/RenderObjects.js +8 -14
- package/examples/jsm/renderers/common/Renderer.js +40 -13
- package/examples/jsm/renderers/common/SampledTexture.js +4 -2
- package/examples/jsm/renderers/common/StorageTexture.js +19 -0
- package/examples/jsm/renderers/common/Textures.js +14 -9
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +20 -10
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +0 -6
- package/examples/jsm/renderers/common/nodes/Nodes.js +51 -24
- package/examples/jsm/renderers/webgl/WebGLBackend.js +100 -5
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +92 -6
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +13 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +3 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +14 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +5 -5
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +6 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
- package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +197 -167
- package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +4 -4
- package/examples/jsm/shaders/OutputShader.js +2 -2
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
- package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
- package/package.json +1 -1
- package/src/Three.js +0 -2
- package/src/animation/AnimationUtils.js +3 -20
- package/src/animation/KeyframeTrack.js +8 -8
- package/src/cameras/Camera.js +1 -5
- package/src/cameras/CubeCamera.js +14 -8
- package/src/constants.js +7 -1
- package/src/core/RenderTarget.js +16 -7
- package/src/extras/core/CurvePath.js +4 -1
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +6 -0
- package/src/materials/Material.js +8 -8
- package/src/math/Color.js +1 -5
- package/src/math/ColorManagement.js +82 -60
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLMultiviewRenderTarget.js +35 -0
- package/src/renderers/WebGLRenderer.js +78 -22
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +5 -4
- package/src/renderers/webgl/WebGLLights.js +14 -3
- package/src/renderers/webgl/WebGLMultiview.js +100 -0
- package/src/renderers/webgl/WebGLProgram.js +84 -5
- package/src/renderers/webgl/WebGLPrograms.js +11 -2
- package/src/renderers/webgl/WebGLTextures.js +214 -26
- package/src/renderers/webgl/WebGLUtils.js +21 -23
- package/src/renderers/webxr/WebXRManager.js +36 -12
- package/src/scenes/Fog.js +1 -0
- package/src/scenes/FogExp2.js +1 -0
- package/src/textures/Source.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
- package/src/lights/AmbientLightProbe.js +0 -21
- package/src/lights/HemisphereLightProbe.js +0 -30
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace,
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer } from '../../constants.js';
|
|
2
2
|
import * as MathUtils from '../../math/MathUtils.js';
|
|
3
3
|
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
4
4
|
import { createElementNS } from '../../utils.js';
|
|
5
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
5
6
|
|
|
6
7
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
7
8
|
|
|
@@ -12,12 +13,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
12
13
|
const maxSamples = capabilities.maxSamples;
|
|
13
14
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
14
15
|
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
16
|
+
const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
|
|
15
17
|
|
|
16
18
|
const _videoTextures = new WeakMap();
|
|
17
19
|
let _canvas;
|
|
18
20
|
|
|
19
21
|
const _sources = new WeakMap(); // maps WebglTexture objects to instances of Source
|
|
20
22
|
|
|
23
|
+
let _deferredUploads = [];
|
|
24
|
+
let _deferTextureUploads = false;
|
|
25
|
+
|
|
21
26
|
// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,
|
|
22
27
|
// also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")!
|
|
23
28
|
// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).
|
|
@@ -178,9 +183,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
178
183
|
|
|
179
184
|
if ( glFormat === _gl.RGBA ) {
|
|
180
185
|
|
|
186
|
+
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
187
|
+
|
|
181
188
|
if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
|
|
182
189
|
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
|
|
183
|
-
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = (
|
|
190
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
|
|
184
191
|
if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
|
|
185
192
|
if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;
|
|
186
193
|
|
|
@@ -483,8 +490,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
483
490
|
|
|
484
491
|
} else {
|
|
485
492
|
|
|
486
|
-
uploadTexture( textureProperties, texture, slot )
|
|
487
|
-
|
|
493
|
+
if ( uploadTexture( textureProperties, texture, slot ) ) {
|
|
494
|
+
|
|
495
|
+
return;
|
|
496
|
+
|
|
497
|
+
}
|
|
488
498
|
|
|
489
499
|
}
|
|
490
500
|
|
|
@@ -717,8 +727,45 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
717
727
|
|
|
718
728
|
}
|
|
719
729
|
|
|
730
|
+
function setDeferTextureUploads( deferFlag ) {
|
|
731
|
+
|
|
732
|
+
_deferTextureUploads = deferFlag;
|
|
733
|
+
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
function runDeferredUploads() {
|
|
737
|
+
|
|
738
|
+
const previousDeferSetting = _deferTextureUploads;
|
|
739
|
+
_deferTextureUploads = false;
|
|
740
|
+
|
|
741
|
+
for ( const upload of _deferredUploads ) {
|
|
742
|
+
|
|
743
|
+
uploadTexture( upload.textureProperties, upload.texture, upload.slot );
|
|
744
|
+
upload.texture.isPendingDeferredUpload = false;
|
|
745
|
+
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
_deferredUploads = [];
|
|
749
|
+
|
|
750
|
+
_deferTextureUploads = previousDeferSetting;
|
|
751
|
+
|
|
752
|
+
}
|
|
753
|
+
|
|
720
754
|
function uploadTexture( textureProperties, texture, slot ) {
|
|
721
755
|
|
|
756
|
+
if ( _deferTextureUploads ) {
|
|
757
|
+
|
|
758
|
+
if ( ! texture.isPendingDeferredUpload ) {
|
|
759
|
+
|
|
760
|
+
texture.isPendingDeferredUpload = true;
|
|
761
|
+
_deferredUploads.push( { textureProperties: textureProperties, texture: texture, slot: slot } );
|
|
762
|
+
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
return false;
|
|
766
|
+
|
|
767
|
+
}
|
|
768
|
+
|
|
722
769
|
let textureType = _gl.TEXTURE_2D;
|
|
723
770
|
|
|
724
771
|
if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
|
|
@@ -735,10 +782,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
735
782
|
|
|
736
783
|
state.activeTexture( _gl.TEXTURE0 + slot );
|
|
737
784
|
|
|
785
|
+
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
786
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
|
|
787
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
788
|
+
|
|
738
789
|
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
739
790
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
740
791
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
741
|
-
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
|
|
792
|
+
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
742
793
|
|
|
743
794
|
const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;
|
|
744
795
|
let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
|
|
@@ -1131,6 +1182,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1131
1182
|
}
|
|
1132
1183
|
|
|
1133
1184
|
textureProperties.__version = texture.version;
|
|
1185
|
+
return true;
|
|
1134
1186
|
|
|
1135
1187
|
}
|
|
1136
1188
|
|
|
@@ -1149,10 +1201,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1149
1201
|
|
|
1150
1202
|
state.activeTexture( _gl.TEXTURE0 + slot );
|
|
1151
1203
|
|
|
1204
|
+
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
1205
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
|
|
1206
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
1207
|
+
|
|
1152
1208
|
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
1153
1209
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
1154
1210
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
1155
|
-
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
|
|
1211
|
+
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
1156
1212
|
|
|
1157
1213
|
const isCompressed = ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture );
|
|
1158
1214
|
const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );
|
|
@@ -1356,7 +1412,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1356
1412
|
const width = Math.max( 1, renderTarget.width >> level );
|
|
1357
1413
|
const height = Math.max( 1, renderTarget.height >> level );
|
|
1358
1414
|
|
|
1359
|
-
if (
|
|
1415
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
1416
|
+
|
|
1417
|
+
state.texStorage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.numViews );
|
|
1418
|
+
|
|
1419
|
+
} else if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
|
|
1360
1420
|
|
|
1361
1421
|
state.texImage3D( textureTarget, level, glInternalFormat, width, height, renderTarget.depth, 0, glFormat, glType, null );
|
|
1362
1422
|
|
|
@@ -1370,13 +1430,31 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1370
1430
|
|
|
1371
1431
|
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
1372
1432
|
|
|
1373
|
-
|
|
1433
|
+
const multisampled = useMultisampledRTT( renderTarget );
|
|
1434
|
+
|
|
1435
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
1436
|
+
|
|
1437
|
+
if ( multisampled ) {
|
|
1374
1438
|
|
|
1375
|
-
|
|
1439
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ), 0, renderTarget.numViews );
|
|
1440
|
+
|
|
1441
|
+
} else {
|
|
1442
|
+
|
|
1443
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( texture ).__webglTexture, 0, 0, renderTarget.numViews );
|
|
1444
|
+
|
|
1445
|
+
}
|
|
1376
1446
|
|
|
1377
1447
|
} else if ( textureTarget === _gl.TEXTURE_2D || ( textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ) ) { // see #24753
|
|
1378
1448
|
|
|
1379
|
-
|
|
1449
|
+
if ( multisampled ) {
|
|
1450
|
+
|
|
1451
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
|
|
1452
|
+
|
|
1453
|
+
} else {
|
|
1454
|
+
|
|
1455
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, level );
|
|
1456
|
+
|
|
1457
|
+
}
|
|
1380
1458
|
|
|
1381
1459
|
}
|
|
1382
1460
|
|
|
@@ -1390,9 +1468,61 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1390
1468
|
|
|
1391
1469
|
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
|
|
1392
1470
|
|
|
1393
|
-
if ( renderTarget.
|
|
1471
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
1394
1472
|
|
|
1395
|
-
|
|
1473
|
+
const useMultisample = useMultisampledRTT( renderTarget );
|
|
1474
|
+
const numViews = renderTarget.numViews;
|
|
1475
|
+
|
|
1476
|
+
const depthTexture = renderTarget.depthTexture;
|
|
1477
|
+
let glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
1478
|
+
let glDepthAttachment = _gl.DEPTH_ATTACHMENT;
|
|
1479
|
+
|
|
1480
|
+
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
1481
|
+
|
|
1482
|
+
if ( depthTexture.type === FloatType ) {
|
|
1483
|
+
|
|
1484
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
1485
|
+
|
|
1486
|
+
} else if ( depthTexture.type === UnsignedInt248Type ) {
|
|
1487
|
+
|
|
1488
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
1489
|
+
glDepthAttachment = _gl.DEPTH_STENCIL_ATTACHMENT;
|
|
1490
|
+
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
// we're defaulting to _gl.DEPTH_COMPONENT24 so don't assign here
|
|
1494
|
+
// or else DeepScan will complain
|
|
1495
|
+
|
|
1496
|
+
// else if ( depthTexture.type === UnsignedIntType ) {
|
|
1497
|
+
|
|
1498
|
+
// glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
1499
|
+
|
|
1500
|
+
// }
|
|
1501
|
+
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
let depthStencilTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
|
|
1505
|
+
if ( depthStencilTexture === undefined ) {
|
|
1506
|
+
|
|
1507
|
+
depthStencilTexture = _gl.createTexture();
|
|
1508
|
+
_gl.bindTexture( _gl.TEXTURE_2D_ARRAY, depthStencilTexture );
|
|
1509
|
+
_gl.texStorage3D( _gl.TEXTURE_2D_ARRAY, 1, glInternalFormat, renderTarget.width, renderTarget.height, numViews );
|
|
1510
|
+
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
if ( useMultisample ) {
|
|
1514
|
+
|
|
1515
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, getRenderTargetSamples( renderTarget ), 0, numViews );
|
|
1516
|
+
|
|
1517
|
+
} else {
|
|
1518
|
+
|
|
1519
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, 0, numViews );
|
|
1520
|
+
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
} else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
1524
|
+
|
|
1525
|
+
let glInternalFormat = ( isWebGL2 === true ) ? _gl.DEPTH_COMPONENT24 : _gl.DEPTH_COMPONENT16;
|
|
1396
1526
|
|
|
1397
1527
|
if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
|
|
1398
1528
|
|
|
@@ -1514,37 +1644,85 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1514
1644
|
}
|
|
1515
1645
|
|
|
1516
1646
|
setTexture2D( renderTarget.depthTexture, 0 );
|
|
1647
|
+
if ( renderTarget.depthTexture.image.depth != 1 ) {
|
|
1648
|
+
|
|
1649
|
+
setTexture2DArray( renderTarget.depthTexture, 0 );
|
|
1650
|
+
|
|
1651
|
+
} else {
|
|
1652
|
+
|
|
1653
|
+
setTexture2D( renderTarget.depthTexture, 0 );
|
|
1654
|
+
|
|
1655
|
+
}
|
|
1517
1656
|
|
|
1518
1657
|
const webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
|
|
1519
1658
|
const samples = getRenderTargetSamples( renderTarget );
|
|
1520
1659
|
|
|
1521
|
-
if ( renderTarget.
|
|
1660
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
1522
1661
|
|
|
1523
|
-
|
|
1662
|
+
const useMultisample = useMultisampledRTT( renderTarget );
|
|
1663
|
+
const numViews = renderTarget.numViews;
|
|
1524
1664
|
|
|
1525
|
-
|
|
1665
|
+
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
1526
1666
|
|
|
1527
|
-
|
|
1667
|
+
if ( useMultisample ) {
|
|
1528
1668
|
|
|
1529
|
-
|
|
1669
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
|
|
1530
1670
|
|
|
1531
|
-
|
|
1671
|
+
} else {
|
|
1532
1672
|
|
|
1533
|
-
|
|
1673
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
|
|
1534
1674
|
|
|
1535
|
-
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
|
|
1536
1678
|
|
|
1537
|
-
|
|
1679
|
+
if ( useMultisample ) {
|
|
1680
|
+
|
|
1681
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
|
|
1682
|
+
|
|
1683
|
+
} else {
|
|
1684
|
+
|
|
1685
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
|
|
1686
|
+
|
|
1687
|
+
}
|
|
1538
1688
|
|
|
1539
1689
|
} else {
|
|
1540
1690
|
|
|
1541
|
-
|
|
1691
|
+
throw new Error( 'Unknown depthTexture format' );
|
|
1542
1692
|
|
|
1543
1693
|
}
|
|
1544
1694
|
|
|
1545
1695
|
} else {
|
|
1546
1696
|
|
|
1547
|
-
|
|
1697
|
+
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
1698
|
+
|
|
1699
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1700
|
+
|
|
1701
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
|
|
1702
|
+
|
|
1703
|
+
} else {
|
|
1704
|
+
|
|
1705
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
|
|
1706
|
+
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
|
|
1710
|
+
|
|
1711
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1712
|
+
|
|
1713
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
|
|
1714
|
+
|
|
1715
|
+
} else {
|
|
1716
|
+
|
|
1717
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
|
|
1718
|
+
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
} else {
|
|
1722
|
+
|
|
1723
|
+
throw new Error( 'Unknown depthTexture format' );
|
|
1724
|
+
|
|
1725
|
+
}
|
|
1548
1726
|
|
|
1549
1727
|
}
|
|
1550
1728
|
|
|
@@ -1823,6 +2001,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1823
2001
|
|
|
1824
2002
|
}
|
|
1825
2003
|
|
|
2004
|
+
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
2005
|
+
|
|
2006
|
+
glTextureType = _gl.TEXTURE_2D_ARRAY;
|
|
2007
|
+
|
|
2008
|
+
}
|
|
2009
|
+
|
|
1826
2010
|
state.bindTexture( glTextureType, textureProperties.__webglTexture );
|
|
1827
2011
|
setTextureParameters( glTextureType, texture, supportsMips );
|
|
1828
2012
|
|
|
@@ -1852,9 +2036,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1852
2036
|
|
|
1853
2037
|
// Setup depth and stencil buffers
|
|
1854
2038
|
|
|
1855
|
-
if ( renderTarget.depthBuffer ) {
|
|
2039
|
+
if ( renderTarget.depthBuffer || renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
1856
2040
|
|
|
1857
|
-
setupDepthRenderbuffer( renderTarget );
|
|
2041
|
+
this.setupDepthRenderbuffer( renderTarget );
|
|
1858
2042
|
|
|
1859
2043
|
}
|
|
1860
2044
|
|
|
@@ -2033,7 +2217,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2033
2217
|
|
|
2034
2218
|
// sRGB
|
|
2035
2219
|
|
|
2036
|
-
if ( colorSpace
|
|
2220
|
+
if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
|
|
2037
2221
|
|
|
2038
2222
|
if ( isWebGL2 === false ) {
|
|
2039
2223
|
|
|
@@ -2090,12 +2274,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2090
2274
|
this.setTexture3D = setTexture3D;
|
|
2091
2275
|
this.setTextureCube = setTextureCube;
|
|
2092
2276
|
this.rebindTextures = rebindTextures;
|
|
2277
|
+
this.uploadTexture = uploadTexture;
|
|
2093
2278
|
this.setupRenderTarget = setupRenderTarget;
|
|
2094
2279
|
this.updateRenderTargetMipmap = updateRenderTargetMipmap;
|
|
2095
2280
|
this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
|
|
2281
|
+
this.setupDepthTexture = setupDepthTexture;
|
|
2096
2282
|
this.setupDepthRenderbuffer = setupDepthRenderbuffer;
|
|
2097
2283
|
this.setupFrameBufferTexture = setupFrameBufferTexture;
|
|
2098
2284
|
this.useMultisampledRTT = useMultisampledRTT;
|
|
2285
|
+
this.runDeferredUploads = runDeferredUploads;
|
|
2286
|
+
this.setDeferTextureUploads = setDeferTextureUploads;
|
|
2099
2287
|
|
|
2100
2288
|
}
|
|
2101
2289
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { 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, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, _SRGBAFormat, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format,
|
|
2
|
-
|
|
3
|
-
const LinearTransferFunction = 0;
|
|
4
|
-
const SRGBTransferFunction = 1;
|
|
1
|
+
import { 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, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, _SRGBAFormat, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, NoColorSpace, SRGBTransfer } from '../../constants.js';
|
|
2
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
5
3
|
|
|
6
4
|
function WebGLUtils( gl, extensions, capabilities ) {
|
|
7
5
|
|
|
@@ -11,7 +9,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
11
9
|
|
|
12
10
|
let extension;
|
|
13
11
|
|
|
14
|
-
const
|
|
12
|
+
const transfer = ColorManagement.getTransfer( colorSpace );
|
|
15
13
|
|
|
16
14
|
if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
|
|
17
15
|
if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
|
|
@@ -79,7 +77,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
79
77
|
|
|
80
78
|
if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
|
|
81
79
|
|
|
82
|
-
if (
|
|
80
|
+
if ( transfer === SRGBTransfer ) {
|
|
83
81
|
|
|
84
82
|
extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' );
|
|
85
83
|
|
|
@@ -164,8 +162,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
164
162
|
|
|
165
163
|
if ( extension !== null ) {
|
|
166
164
|
|
|
167
|
-
if ( p === RGB_ETC2_Format ) return (
|
|
168
|
-
if ( p === RGBA_ETC2_EAC_Format ) return (
|
|
165
|
+
if ( p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
166
|
+
if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
169
167
|
|
|
170
168
|
} else {
|
|
171
169
|
|
|
@@ -187,20 +185,20 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
187
185
|
|
|
188
186
|
if ( extension !== null ) {
|
|
189
187
|
|
|
190
|
-
if ( p === RGBA_ASTC_4x4_Format ) return (
|
|
191
|
-
if ( p === RGBA_ASTC_5x4_Format ) return (
|
|
192
|
-
if ( p === RGBA_ASTC_5x5_Format ) return (
|
|
193
|
-
if ( p === RGBA_ASTC_6x5_Format ) return (
|
|
194
|
-
if ( p === RGBA_ASTC_6x6_Format ) return (
|
|
195
|
-
if ( p === RGBA_ASTC_8x5_Format ) return (
|
|
196
|
-
if ( p === RGBA_ASTC_8x6_Format ) return (
|
|
197
|
-
if ( p === RGBA_ASTC_8x8_Format ) return (
|
|
198
|
-
if ( p === RGBA_ASTC_10x5_Format ) return (
|
|
199
|
-
if ( p === RGBA_ASTC_10x6_Format ) return (
|
|
200
|
-
if ( p === RGBA_ASTC_10x8_Format ) return (
|
|
201
|
-
if ( p === RGBA_ASTC_10x10_Format ) return (
|
|
202
|
-
if ( p === RGBA_ASTC_12x10_Format ) return (
|
|
203
|
-
if ( p === RGBA_ASTC_12x12_Format ) return (
|
|
188
|
+
if ( p === RGBA_ASTC_4x4_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
|
|
189
|
+
if ( p === RGBA_ASTC_5x4_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
|
|
190
|
+
if ( p === RGBA_ASTC_5x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
|
|
191
|
+
if ( p === RGBA_ASTC_6x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
|
|
192
|
+
if ( p === RGBA_ASTC_6x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
|
|
193
|
+
if ( p === RGBA_ASTC_8x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
|
|
194
|
+
if ( p === RGBA_ASTC_8x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
|
|
195
|
+
if ( p === RGBA_ASTC_8x8_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
|
|
196
|
+
if ( p === RGBA_ASTC_10x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
|
|
197
|
+
if ( p === RGBA_ASTC_10x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
|
|
198
|
+
if ( p === RGBA_ASTC_10x8_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
|
|
199
|
+
if ( p === RGBA_ASTC_10x10_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
|
|
200
|
+
if ( p === RGBA_ASTC_12x10_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
|
|
201
|
+
if ( p === RGBA_ASTC_12x12_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
|
|
204
202
|
|
|
205
203
|
} else {
|
|
206
204
|
|
|
@@ -218,7 +216,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
218
216
|
|
|
219
217
|
if ( extension !== null ) {
|
|
220
218
|
|
|
221
|
-
if ( p === RGBA_BPTC_Format ) return (
|
|
219
|
+
if ( p === RGBA_BPTC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
|
|
222
220
|
if ( p === RGB_BPTC_SIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
|
|
223
221
|
if ( p === RGB_BPTC_UNSIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
|
|
224
222
|
|
|
@@ -5,6 +5,7 @@ import { Vector3 } from '../../math/Vector3.js';
|
|
|
5
5
|
import { Vector4 } from '../../math/Vector4.js';
|
|
6
6
|
import { RAD2DEG } from '../../math/MathUtils.js';
|
|
7
7
|
import { WebGLAnimation } from '../webgl/WebGLAnimation.js';
|
|
8
|
+
import { WebGLMultiviewRenderTarget } from '../WebGLMultiviewRenderTarget.js';
|
|
8
9
|
import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
|
|
9
10
|
import { WebXRController } from './WebXRController.js';
|
|
10
11
|
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
@@ -12,7 +13,7 @@ import { DepthFormat, DepthStencilFormat, RGBAFormat, UnsignedByteType, Unsigned
|
|
|
12
13
|
|
|
13
14
|
class WebXRManager extends EventDispatcher {
|
|
14
15
|
|
|
15
|
-
constructor( renderer, gl ) {
|
|
16
|
+
constructor( renderer, gl, extensions, useMultiview ) {
|
|
16
17
|
|
|
17
18
|
super();
|
|
18
19
|
|
|
@@ -68,6 +69,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
68
69
|
this.enabled = false;
|
|
69
70
|
|
|
70
71
|
this.isPresenting = false;
|
|
72
|
+
this.isMultiview = false;
|
|
71
73
|
|
|
72
74
|
this.getCameraPose = function ( ) {
|
|
73
75
|
|
|
@@ -311,29 +313,51 @@ class WebXRManager extends EventDispatcher {
|
|
|
311
313
|
|
|
312
314
|
}
|
|
313
315
|
|
|
316
|
+
scope.isMultiview = useMultiview && extensions.has( 'OCULUS_multiview' );
|
|
317
|
+
|
|
314
318
|
const projectionlayerInit = {
|
|
315
319
|
colorFormat: gl.RGBA8,
|
|
316
320
|
depthFormat: glDepthFormat,
|
|
317
321
|
scaleFactor: framebufferScaleFactor
|
|
318
322
|
};
|
|
319
323
|
|
|
324
|
+
if ( scope.isMultiview ) {
|
|
325
|
+
|
|
326
|
+
projectionlayerInit.textureType = 'texture-array';
|
|
327
|
+
|
|
328
|
+
}
|
|
329
|
+
|
|
320
330
|
glBinding = new XRWebGLBinding( session, gl );
|
|
321
331
|
|
|
322
332
|
glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
|
|
323
333
|
|
|
324
334
|
session.updateRenderState( { layers: [ glProjLayer ] } );
|
|
325
335
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
const renderTargetOptions = {
|
|
337
|
+
format: RGBAFormat,
|
|
338
|
+
type: UnsignedByteType,
|
|
339
|
+
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
|
|
340
|
+
stencilBuffer: attributes.stencil,
|
|
341
|
+
colorSpace: renderer.outputColorSpace,
|
|
342
|
+
samples: attributes.antialias ? 4 : 0
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
if ( scope.isMultiview ) {
|
|
346
|
+
|
|
347
|
+
const extension = extensions.get( 'OCULUS_multiview' );
|
|
348
|
+
|
|
349
|
+
this.maxNumViews = gl.getParameter( extension.MAX_VIEWS_OVR );
|
|
350
|
+
|
|
351
|
+
newRenderTarget = new WebGLMultiviewRenderTarget( glProjLayer.textureWidth, glProjLayer.textureHeight, 2, renderTargetOptions );
|
|
352
|
+
|
|
353
|
+
} else {
|
|
354
|
+
|
|
355
|
+
newRenderTarget = new WebGLRenderTarget(
|
|
356
|
+
glProjLayer.textureWidth,
|
|
357
|
+
glProjLayer.textureHeight,
|
|
358
|
+
renderTargetOptions );
|
|
359
|
+
|
|
360
|
+
}
|
|
337
361
|
|
|
338
362
|
const renderTargetProperties = renderer.properties.get( newRenderTarget );
|
|
339
363
|
renderTargetProperties.__ignoreDepthValues = glProjLayer.ignoreDepthValues;
|
package/src/scenes/Fog.js
CHANGED
package/src/scenes/FogExp2.js
CHANGED
package/src/textures/Source.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ImageUtils } from '../extras/ImageUtils.js';
|
|
2
2
|
import * as MathUtils from '../math/MathUtils.js';
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let _sourceId = 0;
|
|
5
5
|
|
|
6
6
|
class Source {
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ class Source {
|
|
|
9
9
|
|
|
10
10
|
this.isSource = true;
|
|
11
11
|
|
|
12
|
-
Object.defineProperty( this, 'id', { value:
|
|
12
|
+
Object.defineProperty( this, 'id', { value: _sourceId ++ } );
|
|
13
13
|
|
|
14
14
|
this.uuid = MathUtils.generateUUID();
|
|
15
15
|
|