super-three 0.135.0 → 0.136.0
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.js +527 -332
- package/build/three.min.js +1 -1
- package/build/three.module.js +752 -370
- package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
- package/examples/js/animation/CCDIKSolver.js +0 -1
- package/examples/js/animation/MMDPhysics.js +1 -3
- package/examples/js/controls/ArcballControls.js +38 -52
- package/examples/js/controls/TransformControls.js +24 -1
- package/examples/js/curves/CurveExtras.js +0 -2
- package/examples/js/effects/AsciiEffect.js +2 -9
- package/examples/js/exporters/GLTFExporter.js +1 -1
- package/examples/js/geometries/TeapotGeometry.js +0 -1
- package/examples/js/interactive/SelectionBox.js +2 -0
- package/examples/js/interactive/SelectionHelper.js +22 -7
- package/examples/js/lights/RectAreaLightUniformsLib.js +4 -0
- package/examples/js/loaders/AMFLoader.js +0 -2
- package/examples/js/loaders/ColladaLoader.js +1 -2
- package/examples/js/loaders/EXRLoader.js +185 -262
- package/examples/js/loaders/FBXLoader.js +3 -4
- package/examples/js/loaders/GLTFLoader.js +2 -2
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -8
- package/examples/js/loaders/KTX2Loader.js +11 -2
- package/examples/js/loaders/KTXLoader.js +1 -1
- package/examples/js/loaders/LDrawLoader.js +26 -30
- package/examples/js/loaders/LUT3dlLoader.js +2 -0
- package/examples/js/loaders/LUTCubeLoader.js +2 -0
- package/examples/js/loaders/MMDLoader.js +0 -1
- package/examples/js/loaders/NRRDLoader.js +9 -2
- package/examples/js/loaders/OBJLoader.js +0 -2
- package/examples/js/loaders/PLYLoader.js +1 -1
- package/examples/js/loaders/RGBELoader.js +0 -15
- package/examples/js/loaders/RGBMLoader.js +55 -5
- package/examples/js/loaders/SVGLoader.js +2 -2
- package/examples/js/loaders/VOXLoader.js +1 -0
- package/examples/js/loaders/VRMLLoader.js +2 -1
- package/examples/js/math/ImprovedNoise.js +1 -1
- package/examples/js/misc/GPUComputationRenderer.js +3 -1
- package/examples/js/objects/Lensflare.js +2 -10
- package/examples/js/objects/Reflector.js +7 -0
- package/examples/js/objects/Refractor.js +7 -0
- package/examples/js/objects/Sky.js +1 -1
- package/examples/js/objects/Water.js +2 -2
- package/examples/js/objects/Water2.js +4 -7
- package/examples/js/postprocessing/GlitchPass.js +3 -1
- package/examples/js/postprocessing/SSAOPass.js +1 -0
- package/examples/js/shaders/ConvolutionShader.js +0 -1
- package/examples/js/shaders/FXAAShader.js +1 -1
- package/examples/js/shaders/FilmShader.js +1 -1
- package/examples/js/shaders/GammaCorrectionShader.js +1 -1
- package/examples/js/shaders/HorizontalBlurShader.js +1 -2
- package/examples/js/shaders/SSRShader.js +1 -1
- package/examples/js/shaders/SSRrShader.js +1 -1
- package/examples/js/shaders/VerticalBlurShader.js +1 -2
- package/examples/js/utils/GeometryUtils.js +1 -1
- package/examples/js/utils/RoughnessMipmapper.js +18 -29
- package/examples/jsm/animation/CCDIKSolver.js +0 -1
- package/examples/jsm/animation/MMDPhysics.js +0 -2
- package/examples/jsm/controls/ArcballControls.js +27 -56
- package/examples/jsm/controls/TransformControls.js +24 -1
- package/examples/jsm/curves/CurveExtras.js +0 -2
- package/examples/jsm/effects/AsciiEffect.js +2 -9
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +0 -1
- package/examples/jsm/interactive/SelectionBox.js +1 -0
- package/examples/jsm/interactive/SelectionHelper.js +19 -7
- package/examples/jsm/libs/flow.module.js +256 -136
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +7 -0
- package/examples/jsm/loaders/AMFLoader.js +0 -2
- package/examples/jsm/loaders/ColladaLoader.js +1 -2
- package/examples/jsm/loaders/EXRLoader.js +184 -293
- package/examples/jsm/loaders/FBXLoader.js +3 -4
- package/examples/jsm/loaders/GLTFLoader.js +2 -2
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -14
- package/examples/jsm/loaders/KTX2Loader.js +13 -4
- package/examples/jsm/loaders/KTXLoader.js +1 -1
- package/examples/jsm/loaders/LDrawLoader.js +23 -24
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -0
- package/examples/jsm/loaders/LUTCubeLoader.js +2 -0
- package/examples/jsm/loaders/MMDLoader.js +0 -1
- package/examples/jsm/loaders/NRRDLoader.js +10 -2
- package/examples/jsm/loaders/OBJLoader.js +0 -2
- package/examples/jsm/loaders/PLYLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +0 -20
- package/examples/jsm/loaders/RGBMLoader.js +61 -7
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TDSLoader.js +30 -9
- package/examples/jsm/loaders/VOXLoader.js +1 -0
- package/examples/jsm/loaders/VRMLLoader.js +2 -1
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/misc/GPUComputationRenderer.js +3 -1
- package/examples/jsm/node-editor/NodeEditor.js +23 -22
- package/examples/jsm/node-editor/examples/rim.json +1 -1
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +48 -9
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +2 -2
- package/examples/jsm/nodes/materials/nodes/StandardNode.js +1 -0
- package/examples/jsm/nodes/math/MathNode.js +12 -0
- package/examples/jsm/nodes/misc/BumpMapNode.js +1 -1
- package/examples/jsm/nodes/misc/TextureCubeUVNode.js +1 -4
- package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -116
- package/examples/jsm/objects/Lensflare.js +3 -14
- package/examples/jsm/objects/Reflector.js +7 -0
- package/examples/jsm/objects/Refractor.js +7 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/Water.js +2 -2
- package/examples/jsm/objects/Water2.js +4 -8
- package/examples/jsm/postprocessing/GlitchPass.js +3 -1
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -0
- package/examples/jsm/renderers/nodes/Nodes.js +1 -0
- package/examples/jsm/renderers/nodes/ShaderNode.js +7 -6
- package/examples/jsm/renderers/nodes/core/InputNode.js +1 -1
- package/examples/jsm/renderers/nodes/core/NodeBuilder.js +1 -1
- package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +26 -31
- package/examples/jsm/renderers/nodes/functions/BSDFs.js +2 -2
- package/examples/jsm/renderers/nodes/functions/PhysicalMaterialFunctions.js +27 -0
- package/examples/jsm/renderers/nodes/inputs/TextureNode.js +1 -1
- package/examples/jsm/renderers/nodes/math/MathNode.js +5 -3
- package/examples/jsm/renderers/nodes/math/OperatorNode.js +2 -2
- package/examples/jsm/renderers/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +14 -14
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +7 -6
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +42 -61
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +0 -1
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +30 -4
- package/examples/jsm/shaders/ConvolutionShader.js +0 -1
- package/examples/jsm/shaders/FXAAShader.js +1 -1
- package/examples/jsm/shaders/FilmShader.js +1 -1
- package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
- package/examples/jsm/shaders/HorizontalBlurShader.js +1 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SSRrShader.js +1 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +1 -2
- package/examples/jsm/utils/GeometryUtils.js +1 -1
- package/examples/jsm/utils/RoughnessMipmapper.js +19 -32
- package/examples/jsm/utils/WorkerPool.js +11 -11
- package/package.json +15 -9
- package/src/Three.Legacy.js +12 -0
- package/src/Three.js +1 -2
- package/src/constants.js +1 -7
- package/src/core/Object3D.js +1 -1
- package/src/extras/PMREMGenerator.js +19 -110
- package/src/extras/core/Interpolations.js +1 -1
- package/src/geometries/LatheGeometry.js +70 -47
- package/src/helpers/CameraHelper.js +1 -1
- package/src/loaders/FileLoader.js +23 -6
- package/src/math/Color.js +0 -38
- package/src/math/Ray.js +2 -2
- package/src/math/Sphere.js +10 -1
- package/src/objects/Skeleton.js +1 -0
- package/src/renderers/WebGLRenderer.js +23 -16
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +2 -24
- package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -47
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +27 -1
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +10 -0
- package/src/renderers/webgl/WebGLCapabilities.js +0 -2
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -0
- package/src/renderers/webgl/WebGLProgram.js +2 -19
- package/src/renderers/webgl/WebGLPrograms.js +191 -35
- package/src/renderers/webgl/WebGLRenderLists.js +4 -14
- package/src/renderers/webgl/WebGLShaderCache.js +120 -0
- package/src/renderers/webgl/WebGLState.js +45 -0
- package/src/renderers/webgl/WebGLTextures.js +195 -26
- package/src/renderers/webxr/WebXRManager.js +10 -3
- package/src/scenes/Scene.js +1 -1
- package/src/textures/DataTexture.js +0 -2
- package/src/textures/DataTexture2DArray.js +0 -2
- package/src/textures/DataTexture3D.js +0 -2
- package/src/textures/FramebufferTexture.js +25 -0
- package/src/utils.js +1 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping } from '../../constants.js';
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, sRGBEncoding } from '../../constants.js';
|
|
2
2
|
import * as MathUtils from '../../math/MathUtils.js';
|
|
3
3
|
import { createElementNS } from '../../utils.js';
|
|
4
4
|
|
|
@@ -130,7 +130,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
130
130
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
function getInternalFormat( internalFormatName, glFormat, glType
|
|
133
|
+
function getInternalFormat( internalFormatName, glFormat, glType, encoding ) {
|
|
134
134
|
|
|
135
135
|
if ( isWebGL2 === false ) return glFormat;
|
|
136
136
|
|
|
@@ -164,9 +164,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
164
164
|
|
|
165
165
|
if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
|
|
166
166
|
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
|
|
167
|
-
|
|
168
|
-
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8;
|
|
169
|
-
|
|
167
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( encoding === sRGBEncoding ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
|
|
170
168
|
|
|
171
169
|
}
|
|
172
170
|
|
|
@@ -183,18 +181,20 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
183
181
|
|
|
184
182
|
function getMipLevels( texture, image, supportsMips ) {
|
|
185
183
|
|
|
186
|
-
if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true ) {
|
|
187
|
-
|
|
188
|
-
// generated mipmaps via gl.generateMipmap()
|
|
184
|
+
if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
189
185
|
|
|
190
186
|
return Math.log2( Math.max( image.width, image.height ) ) + 1;
|
|
191
187
|
|
|
192
|
-
} else if ( texture.mipmaps.length > 0 ) {
|
|
188
|
+
} else if ( texture.mipmaps !== undefined && texture.mipmaps.length > 0 ) {
|
|
193
189
|
|
|
194
190
|
// user-defined mipmaps
|
|
195
191
|
|
|
196
192
|
return texture.mipmaps.length;
|
|
197
193
|
|
|
194
|
+
} else if ( texture.isCompressedTexture && Array.isArray( texture.image ) ) {
|
|
195
|
+
|
|
196
|
+
return image.mipmaps.length;
|
|
197
|
+
|
|
198
198
|
} else {
|
|
199
199
|
|
|
200
200
|
// texture without mipmaps (only base level)
|
|
@@ -563,6 +563,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
563
563
|
let mipmap;
|
|
564
564
|
const mipmaps = texture.mipmaps;
|
|
565
565
|
|
|
566
|
+
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
|
|
567
|
+
const allocateMemory = ( textureProperties.__version === undefined );
|
|
568
|
+
const levels = getMipLevels( texture, image, supportsMips );
|
|
569
|
+
|
|
566
570
|
if ( texture.isDepthTexture ) {
|
|
567
571
|
|
|
568
572
|
// populate depth texture with dummy data
|
|
@@ -639,7 +643,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
639
643
|
|
|
640
644
|
//
|
|
641
645
|
|
|
642
|
-
|
|
646
|
+
if ( useTexStorage && allocateMemory ) {
|
|
647
|
+
|
|
648
|
+
state.texStorage2D( _gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height );
|
|
649
|
+
|
|
650
|
+
} else {
|
|
651
|
+
|
|
652
|
+
state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
|
|
653
|
+
|
|
654
|
+
}
|
|
643
655
|
|
|
644
656
|
} else if ( texture.isDataTexture ) {
|
|
645
657
|
|
|
@@ -649,10 +661,25 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
649
661
|
|
|
650
662
|
if ( mipmaps.length > 0 && supportsMips ) {
|
|
651
663
|
|
|
664
|
+
if ( useTexStorage && allocateMemory ) {
|
|
665
|
+
|
|
666
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
|
|
667
|
+
|
|
668
|
+
}
|
|
669
|
+
|
|
652
670
|
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
653
671
|
|
|
654
672
|
mipmap = mipmaps[ i ];
|
|
655
|
-
|
|
673
|
+
|
|
674
|
+
if ( useTexStorage ) {
|
|
675
|
+
|
|
676
|
+
state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
677
|
+
|
|
678
|
+
} else {
|
|
679
|
+
|
|
680
|
+
state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
681
|
+
|
|
682
|
+
}
|
|
656
683
|
|
|
657
684
|
}
|
|
658
685
|
|
|
@@ -660,12 +687,32 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
660
687
|
|
|
661
688
|
} else {
|
|
662
689
|
|
|
663
|
-
|
|
690
|
+
if ( useTexStorage ) {
|
|
691
|
+
|
|
692
|
+
if ( allocateMemory ) {
|
|
693
|
+
|
|
694
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height );
|
|
695
|
+
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
|
|
699
|
+
|
|
700
|
+
} else {
|
|
701
|
+
|
|
702
|
+
state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );
|
|
703
|
+
|
|
704
|
+
}
|
|
664
705
|
|
|
665
706
|
}
|
|
666
707
|
|
|
667
708
|
} else if ( texture.isCompressedTexture ) {
|
|
668
709
|
|
|
710
|
+
if ( useTexStorage && allocateMemory ) {
|
|
711
|
+
|
|
712
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
|
|
713
|
+
|
|
714
|
+
}
|
|
715
|
+
|
|
669
716
|
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
670
717
|
|
|
671
718
|
mipmap = mipmaps[ i ];
|
|
@@ -674,7 +721,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
674
721
|
|
|
675
722
|
if ( glFormat !== null ) {
|
|
676
723
|
|
|
677
|
-
|
|
724
|
+
if ( useTexStorage ) {
|
|
725
|
+
|
|
726
|
+
state.compressedTexSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
|
|
727
|
+
|
|
728
|
+
} else {
|
|
729
|
+
|
|
730
|
+
state.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
|
|
731
|
+
|
|
732
|
+
}
|
|
678
733
|
|
|
679
734
|
} else {
|
|
680
735
|
|
|
@@ -684,7 +739,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
684
739
|
|
|
685
740
|
} else {
|
|
686
741
|
|
|
687
|
-
|
|
742
|
+
if ( useTexStorage ) {
|
|
743
|
+
|
|
744
|
+
state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
745
|
+
|
|
746
|
+
} else {
|
|
747
|
+
|
|
748
|
+
state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
749
|
+
|
|
750
|
+
}
|
|
688
751
|
|
|
689
752
|
}
|
|
690
753
|
|
|
@@ -692,11 +755,51 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
692
755
|
|
|
693
756
|
} else if ( texture.isDataTexture2DArray ) {
|
|
694
757
|
|
|
695
|
-
|
|
758
|
+
if ( useTexStorage ) {
|
|
759
|
+
|
|
760
|
+
if ( allocateMemory ) {
|
|
761
|
+
|
|
762
|
+
state.texStorage3D( _gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, image.width, image.height, image.depth );
|
|
763
|
+
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
767
|
+
|
|
768
|
+
} else {
|
|
769
|
+
|
|
770
|
+
state.texImage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
|
|
771
|
+
|
|
772
|
+
}
|
|
696
773
|
|
|
697
774
|
} else if ( texture.isDataTexture3D ) {
|
|
698
775
|
|
|
699
|
-
|
|
776
|
+
if ( useTexStorage ) {
|
|
777
|
+
|
|
778
|
+
if ( allocateMemory ) {
|
|
779
|
+
|
|
780
|
+
state.texStorage3D( _gl.TEXTURE_3D, levels, glInternalFormat, image.width, image.height, image.depth );
|
|
781
|
+
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
state.texSubImage3D( _gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
785
|
+
|
|
786
|
+
} else {
|
|
787
|
+
|
|
788
|
+
state.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
|
|
789
|
+
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
} else if ( texture.isFramebufferTexture ) {
|
|
793
|
+
|
|
794
|
+
if ( useTexStorage && allocateMemory ) {
|
|
795
|
+
|
|
796
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height );
|
|
797
|
+
|
|
798
|
+
} else {
|
|
799
|
+
|
|
800
|
+
state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
|
|
801
|
+
|
|
802
|
+
}
|
|
700
803
|
|
|
701
804
|
} else {
|
|
702
805
|
|
|
@@ -706,10 +809,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
706
809
|
// if there are no manual mipmaps
|
|
707
810
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
708
811
|
|
|
709
|
-
const levels = getMipLevels( texture, image, supportsMips );
|
|
710
|
-
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
|
|
711
|
-
const allocateMemory = ( textureProperties.__version === undefined );
|
|
712
|
-
|
|
713
812
|
if ( mipmaps.length > 0 && supportsMips ) {
|
|
714
813
|
|
|
715
814
|
if ( useTexStorage && allocateMemory ) {
|
|
@@ -809,12 +908,22 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
809
908
|
glType = utils.convert( texture.type ),
|
|
810
909
|
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
811
910
|
|
|
911
|
+
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
|
|
912
|
+
const allocateMemory = ( textureProperties.__version === undefined );
|
|
913
|
+
let levels = getMipLevels( texture, image, supportsMips );
|
|
914
|
+
|
|
812
915
|
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
|
|
813
916
|
|
|
814
917
|
let mipmaps;
|
|
815
918
|
|
|
816
919
|
if ( isCompressed ) {
|
|
817
920
|
|
|
921
|
+
if ( useTexStorage && allocateMemory ) {
|
|
922
|
+
|
|
923
|
+
state.texStorage2D( _gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, image.width, image.height );
|
|
924
|
+
|
|
925
|
+
}
|
|
926
|
+
|
|
818
927
|
for ( let i = 0; i < 6; i ++ ) {
|
|
819
928
|
|
|
820
929
|
mipmaps = cubeImage[ i ].mipmaps;
|
|
@@ -827,7 +936,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
827
936
|
|
|
828
937
|
if ( glFormat !== null ) {
|
|
829
938
|
|
|
830
|
-
|
|
939
|
+
if ( useTexStorage ) {
|
|
940
|
+
|
|
941
|
+
state.compressedTexSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
|
|
942
|
+
|
|
943
|
+
} else {
|
|
944
|
+
|
|
945
|
+
state.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
|
|
946
|
+
|
|
947
|
+
}
|
|
831
948
|
|
|
832
949
|
} else {
|
|
833
950
|
|
|
@@ -837,7 +954,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
837
954
|
|
|
838
955
|
} else {
|
|
839
956
|
|
|
840
|
-
|
|
957
|
+
if ( useTexStorage ) {
|
|
958
|
+
|
|
959
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
960
|
+
|
|
961
|
+
} else {
|
|
962
|
+
|
|
963
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
964
|
+
|
|
965
|
+
}
|
|
841
966
|
|
|
842
967
|
}
|
|
843
968
|
|
|
@@ -849,30 +974,74 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
849
974
|
|
|
850
975
|
mipmaps = texture.mipmaps;
|
|
851
976
|
|
|
977
|
+
if ( useTexStorage && allocateMemory ) {
|
|
978
|
+
|
|
979
|
+
// TODO: Uniformly handle mipmap definitions
|
|
980
|
+
// Normal textures and compressed cube textures define base level + mips with their mipmap array
|
|
981
|
+
// Uncompressed cube textures use their mipmap array only for mips (no base level)
|
|
982
|
+
|
|
983
|
+
if ( mipmaps.length > 0 ) levels ++;
|
|
984
|
+
|
|
985
|
+
state.texStorage2D( _gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, cubeImage[ 0 ].width, cubeImage[ 0 ].height );
|
|
986
|
+
|
|
987
|
+
}
|
|
988
|
+
|
|
852
989
|
for ( let i = 0; i < 6; i ++ ) {
|
|
853
990
|
|
|
854
991
|
if ( isDataTexture ) {
|
|
855
992
|
|
|
856
|
-
|
|
993
|
+
if ( useTexStorage ) {
|
|
994
|
+
|
|
995
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, cubeImage[ i ].width, cubeImage[ i ].height, glFormat, glType, cubeImage[ i ].data );
|
|
996
|
+
|
|
997
|
+
} else {
|
|
998
|
+
|
|
999
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );
|
|
1000
|
+
|
|
1001
|
+
}
|
|
857
1002
|
|
|
858
1003
|
for ( let j = 0; j < mipmaps.length; j ++ ) {
|
|
859
1004
|
|
|
860
1005
|
const mipmap = mipmaps[ j ];
|
|
861
1006
|
const mipmapImage = mipmap.image[ i ].image;
|
|
862
1007
|
|
|
863
|
-
|
|
1008
|
+
if ( useTexStorage ) {
|
|
1009
|
+
|
|
1010
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data );
|
|
1011
|
+
|
|
1012
|
+
} else {
|
|
1013
|
+
|
|
1014
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );
|
|
1015
|
+
|
|
1016
|
+
}
|
|
864
1017
|
|
|
865
1018
|
}
|
|
866
1019
|
|
|
867
1020
|
} else {
|
|
868
1021
|
|
|
869
|
-
|
|
1022
|
+
if ( useTexStorage ) {
|
|
1023
|
+
|
|
1024
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[ i ] );
|
|
1025
|
+
|
|
1026
|
+
} else {
|
|
1027
|
+
|
|
1028
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );
|
|
1029
|
+
|
|
1030
|
+
}
|
|
870
1031
|
|
|
871
1032
|
for ( let j = 0; j < mipmaps.length; j ++ ) {
|
|
872
1033
|
|
|
873
1034
|
const mipmap = mipmaps[ j ];
|
|
874
1035
|
|
|
875
|
-
|
|
1036
|
+
if ( useTexStorage ) {
|
|
1037
|
+
|
|
1038
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[ i ] );
|
|
1039
|
+
|
|
1040
|
+
} else {
|
|
1041
|
+
|
|
1042
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );
|
|
1043
|
+
|
|
1044
|
+
}
|
|
876
1045
|
|
|
877
1046
|
}
|
|
878
1047
|
|
|
@@ -266,7 +266,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
266
266
|
|
|
267
267
|
newRenderTarget = new WebGLRenderTarget(
|
|
268
268
|
glBaseLayer.framebufferWidth,
|
|
269
|
-
glBaseLayer.framebufferHeight
|
|
269
|
+
glBaseLayer.framebufferHeight,
|
|
270
|
+
{
|
|
271
|
+
format: RGBAFormat,
|
|
272
|
+
type: UnsignedByteType,
|
|
273
|
+
encoding: renderer.outputEncoding
|
|
274
|
+
}
|
|
270
275
|
);
|
|
271
276
|
|
|
272
277
|
} else {
|
|
@@ -278,7 +283,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
278
283
|
|
|
279
284
|
if ( attributes.depth ) {
|
|
280
285
|
|
|
281
|
-
glDepthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.
|
|
286
|
+
glDepthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;
|
|
282
287
|
depthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat;
|
|
283
288
|
depthType = attributes.stencil ? UnsignedInt248Type : UnsignedShortType;
|
|
284
289
|
|
|
@@ -308,6 +313,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
308
313
|
stencilBuffer: attributes.stencil,
|
|
309
314
|
ignoreDepth: glProjLayer.ignoreDepthValues,
|
|
310
315
|
useRenderToTexture: hasMultisampledRenderToTexture,
|
|
316
|
+
encoding: renderer.outputEncoding
|
|
311
317
|
} );
|
|
312
318
|
|
|
313
319
|
} else {
|
|
@@ -321,6 +327,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
321
327
|
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
|
|
322
328
|
stencilBuffer: attributes.stencil,
|
|
323
329
|
ignoreDepth: glProjLayer.ignoreDepthValues,
|
|
330
|
+
encoding: renderer.outputEncoding
|
|
324
331
|
} );
|
|
325
332
|
|
|
326
333
|
}
|
|
@@ -328,7 +335,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
328
335
|
}
|
|
329
336
|
|
|
330
337
|
// Set foveation to maximum.
|
|
331
|
-
this.setFoveation( 0 );
|
|
338
|
+
this.setFoveation( 1.0 );
|
|
332
339
|
|
|
333
340
|
referenceSpace = await session.requestReferenceSpace( referenceSpaceType );
|
|
334
341
|
|
package/src/scenes/Scene.js
CHANGED
|
@@ -18,7 +18,7 @@ class Scene extends Object3D {
|
|
|
18
18
|
|
|
19
19
|
if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
|
|
20
20
|
|
|
21
|
-
__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
|
|
21
|
+
__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
|
|
22
22
|
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Texture } from './Texture.js';
|
|
2
|
+
import { NearestFilter } from '../constants.js';
|
|
3
|
+
|
|
4
|
+
class FramebufferTexture extends Texture {
|
|
5
|
+
|
|
6
|
+
constructor( width, height, format ) {
|
|
7
|
+
|
|
8
|
+
super( { width, height } );
|
|
9
|
+
|
|
10
|
+
this.format = format;
|
|
11
|
+
|
|
12
|
+
this.magFilter = NearestFilter;
|
|
13
|
+
this.minFilter = NearestFilter;
|
|
14
|
+
|
|
15
|
+
this.generateMipmaps = false;
|
|
16
|
+
|
|
17
|
+
this.needsUpdate = true;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
FramebufferTexture.prototype.isFramebufferTexture = true;
|
|
24
|
+
|
|
25
|
+
export { FramebufferTexture };
|
package/src/utils.js
CHANGED
|
@@ -54,40 +54,4 @@ function createElementNS( name ) {
|
|
|
54
54
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
* cyrb53 hash for string from: https://stackoverflow.com/a/52171480
|
|
59
|
-
*
|
|
60
|
-
* Public Domain, @bryc - https://stackoverflow.com/users/815680/bryc
|
|
61
|
-
*
|
|
62
|
-
* It is roughly similar to the well-known MurmurHash/xxHash algorithms. It uses a combination
|
|
63
|
-
* of multiplication and Xorshift to generate the hash, but not as thorough. As a result it's
|
|
64
|
-
* faster than either would be in JavaScript and significantly simpler to implement. Keep in
|
|
65
|
-
* mind this is not a secure algorithm, if privacy/security is a concern, this is not for you.
|
|
66
|
-
*
|
|
67
|
-
* @param {string} str
|
|
68
|
-
* @param {number} seed, default 0
|
|
69
|
-
* @returns number
|
|
70
|
-
*/
|
|
71
|
-
function hashString( str, seed = 0 ) {
|
|
72
|
-
|
|
73
|
-
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
|
|
74
|
-
|
|
75
|
-
for ( let i = 0, ch; i < str.length; i ++ ) {
|
|
76
|
-
|
|
77
|
-
ch = str.charCodeAt( i );
|
|
78
|
-
|
|
79
|
-
h1 = Math.imul( h1 ^ ch, 2654435761 );
|
|
80
|
-
|
|
81
|
-
h2 = Math.imul( h2 ^ ch, 1597334677 );
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
h1 = Math.imul( h1 ^ ( h1 >>> 16 ), 2246822507 ) ^ Math.imul( h2 ^ ( h2 >>> 13 ), 3266489909 );
|
|
86
|
-
|
|
87
|
-
h2 = Math.imul( h2 ^ ( h2 >>> 16 ), 2246822507 ) ^ Math.imul( h1 ^ ( h1 >>> 13 ), 3266489909 );
|
|
88
|
-
|
|
89
|
-
return 4294967296 * ( 2097151 & h2 ) + ( h1 >>> 0 );
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export { arrayMin, arrayMax, getTypedArray, createElementNS, hashString };
|
|
57
|
+
export { arrayMin, arrayMax, getTypedArray, createElementNS };
|