super-three 0.136.0 → 0.136.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/LICENSE +1 -1
- package/build/three.js +1634 -1608
- package/build/three.min.js +1 -1
- package/build/three.module.js +4630 -4534
- package/examples/js/animation/MMDPhysics.js +1 -1
- package/examples/js/cameras/CinematicCamera.js +2 -7
- package/examples/js/exporters/MMDExporter.js +1 -1
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/loaders/BasisTextureLoader.js +1 -0
- package/examples/js/loaders/EXRLoader.js +25 -19
- package/examples/js/loaders/GLTFLoader.js +2 -2
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -2
- package/examples/js/loaders/LDrawLoader.js +1131 -859
- package/examples/js/loaders/LUT3dlLoader.js +17 -10
- package/examples/js/loaders/LUTCubeLoader.js +3 -4
- package/examples/js/loaders/RGBELoader.js +6 -6
- package/examples/js/loaders/RGBMLoader.js +1 -1
- package/examples/js/loaders/SVGLoader.js +3 -1
- package/examples/js/loaders/VRMLLoader.js +9 -21
- package/examples/js/math/ConvexHull.js +7 -13
- package/examples/js/misc/Volume.js +2 -2
- package/examples/js/modifiers/CurveModifier.js +8 -7
- package/examples/js/modifiers/EdgeSplitModifier.js +1 -1
- package/examples/js/modifiers/SimplifyModifier.js +1 -1
- package/examples/js/objects/Reflector.js +1 -13
- package/examples/js/objects/ReflectorForSSRPass.js +0 -10
- package/examples/js/objects/Refractor.js +1 -13
- package/examples/js/objects/Water.js +1 -13
- package/examples/js/postprocessing/GlitchPass.js +4 -5
- package/examples/js/postprocessing/SMAAPass.js +2 -9
- package/examples/js/postprocessing/SSAOPass.js +9 -21
- package/examples/js/postprocessing/SavePass.js +1 -5
- package/examples/js/shaders/DigitalGlitch.js +3 -3
- package/examples/js/shaders/MMDToonShader.js +0 -1
- package/examples/js/shaders/SSAOShader.js +1 -1
- package/examples/jsm/animation/MMDPhysics.js +1 -1
- package/examples/jsm/cameras/CinematicCamera.js +2 -5
- package/examples/jsm/{WebGL.js → capabilities/WebGL.js} +2 -2
- package/examples/jsm/{renderers/webgpu → capabilities}/WebGPU.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +8 -24
- package/examples/jsm/exporters/MMDExporter.js +1 -1
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/libs/lil-gui.module.min.js +2 -2
- package/examples/jsm/loaders/BasisTextureLoader.js +7 -0
- package/examples/jsm/loaders/EXRLoader.js +22 -19
- package/examples/jsm/loaders/GLTFLoader.js +1 -3
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -4
- package/examples/jsm/loaders/LDrawLoader.js +1147 -885
- package/examples/jsm/loaders/LUT3dlLoader.js +17 -12
- package/examples/jsm/loaders/LUTCubeLoader.js +3 -5
- package/examples/jsm/loaders/RGBELoader.js +7 -8
- package/examples/jsm/loaders/RGBMLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +6 -1
- package/examples/jsm/loaders/VRMLLoader.js +9 -22
- package/examples/jsm/math/ConvexHull.js +7 -13
- package/examples/jsm/misc/Volume.js +2 -2
- package/examples/jsm/modifiers/CurveModifier.js +9 -8
- package/examples/jsm/modifiers/EdgeSplitModifier.js +1 -1
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/node-editor/NodeEditor.js +21 -22
- package/examples/jsm/nodes/utils/ColorSpaceNode.js +4 -13
- package/examples/jsm/objects/Lensflare.js +4 -4
- package/examples/jsm/objects/Reflector.js +1 -16
- package/examples/jsm/objects/ReflectorForSSRPass.js +0 -12
- package/examples/jsm/objects/Refractor.js +1 -16
- package/examples/jsm/objects/Water.js +1 -16
- package/examples/jsm/postprocessing/GlitchPass.js +7 -6
- package/examples/jsm/postprocessing/SMAAPass.js +2 -11
- package/examples/jsm/postprocessing/SSAOPass.js +13 -25
- package/examples/jsm/postprocessing/SavePass.js +1 -3
- package/examples/jsm/renderers/nodes/Nodes.js +2 -0
- package/examples/jsm/renderers/nodes/ShaderNode.js +58 -31
- package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +9 -46
- package/examples/jsm/renderers/nodes/inputs/TextureNode.js +5 -10
- package/examples/jsm/renderers/nodes/math/MathNode.js +2 -1
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +3 -5
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +1 -2
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +10 -4
- package/examples/jsm/shaders/DigitalGlitch.js +3 -3
- package/examples/jsm/shaders/MMDToonShader.js +0 -1
- package/examples/jsm/shaders/SSAOShader.js +1 -1
- package/examples/jsm/utils/LDrawUtils.js +195 -0
- package/examples/jsm/webxr/VRButton.js +24 -0
- package/examples/jsm/webxr/XREstimatedLight.js +2 -0
- package/package.json +4 -1
- package/src/animation/AnimationMixer.js +1 -0
- package/src/cameras/CubeCamera.js +2 -0
- package/src/constants.js +3 -16
- package/src/extras/ImageUtils.js +63 -0
- package/src/extras/PMREMGenerator.js +32 -82
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/materials/Material.js +4 -4
- package/src/math/Color.js +1 -1
- package/src/math/Quaternion.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +0 -2
- package/src/renderers/WebGLRenderer.js +1 -67
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +10 -3
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +1 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +8 -7
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -3
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -3
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +2 -2
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -4
- package/src/renderers/webgl/WebGLCubeUVMaps.js +29 -16
- package/src/renderers/webgl/WebGLMorphtargets.js +12 -0
- package/src/renderers/webgl/WebGLProgram.js +4 -16
- package/src/renderers/webgl/WebGLPrograms.js +8 -47
- package/src/renderers/webgl/WebGLState.js +81 -0
- package/src/renderers/webgl/WebGLTextures.js +75 -22
- package/src/renderers/webgl/WebGLUtils.js +86 -28
- package/src/renderers/webxr/WebXRManager.js +3 -3
- package/src/textures/Texture.js +2 -1
- package/src/textures/VideoTexture.js +1 -3
- package/examples/js/WebGL.js +0 -90
- package/examples/js/utils/RoughnessMipmapper.js +0 -268
- package/examples/jsm/utils/RoughnessMipmapper.js +0 -288
|
@@ -1,10 +1,10 @@
|
|
|
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,
|
|
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, RGBIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort565Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, sRGBEncoding, _SRGBAFormat } from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
function WebGLUtils( gl, extensions, capabilities ) {
|
|
4
4
|
|
|
5
5
|
const isWebGL2 = capabilities.isWebGL2;
|
|
6
6
|
|
|
7
|
-
function convert( p ) {
|
|
7
|
+
function convert( p, encoding = null ) {
|
|
8
8
|
|
|
9
9
|
let extension;
|
|
10
10
|
|
|
@@ -39,7 +39,6 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if ( p === AlphaFormat ) return gl.ALPHA;
|
|
42
|
-
if ( p === RGBFormat ) return gl.RGB;
|
|
43
42
|
if ( p === RGBAFormat ) return gl.RGBA;
|
|
44
43
|
if ( p === LuminanceFormat ) return gl.LUMINANCE;
|
|
45
44
|
if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
|
|
@@ -47,6 +46,24 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
47
46
|
if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
|
|
48
47
|
if ( p === RedFormat ) return gl.RED;
|
|
49
48
|
|
|
49
|
+
// WebGL 1 sRGB fallback
|
|
50
|
+
|
|
51
|
+
if ( p === _SRGBAFormat ) {
|
|
52
|
+
|
|
53
|
+
extension = extensions.get( 'EXT_sRGB' );
|
|
54
|
+
|
|
55
|
+
if ( extension !== null ) {
|
|
56
|
+
|
|
57
|
+
return extension.SRGB_ALPHA_EXT;
|
|
58
|
+
|
|
59
|
+
} else {
|
|
60
|
+
|
|
61
|
+
return null;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
50
67
|
// WebGL2 formats.
|
|
51
68
|
|
|
52
69
|
if ( p === RedIntegerFormat ) return gl.RED_INTEGER;
|
|
@@ -55,28 +72,51 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
55
72
|
if ( p === RGBIntegerFormat ) return gl.RGB_INTEGER;
|
|
56
73
|
if ( p === RGBAIntegerFormat ) return gl.RGBA_INTEGER;
|
|
57
74
|
|
|
58
|
-
|
|
59
|
-
p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
|
|
75
|
+
// S3TC
|
|
60
76
|
|
|
61
|
-
|
|
77
|
+
if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
|
|
62
78
|
|
|
63
|
-
if (
|
|
79
|
+
if ( encoding === sRGBEncoding ) {
|
|
80
|
+
|
|
81
|
+
extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' );
|
|
82
|
+
|
|
83
|
+
if ( extension !== null ) {
|
|
84
|
+
|
|
85
|
+
if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_SRGB_S3TC_DXT1_EXT;
|
|
86
|
+
if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
|
|
87
|
+
if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
|
|
88
|
+
if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
|
|
89
|
+
|
|
90
|
+
} else {
|
|
64
91
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
|
92
|
+
return null;
|
|
93
|
+
|
|
94
|
+
}
|
|
69
95
|
|
|
70
96
|
} else {
|
|
71
97
|
|
|
72
|
-
|
|
98
|
+
extension = extensions.get( 'WEBGL_compressed_texture_s3tc' );
|
|
99
|
+
|
|
100
|
+
if ( extension !== null ) {
|
|
101
|
+
|
|
102
|
+
if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;
|
|
103
|
+
if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
|
104
|
+
if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
|
105
|
+
if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
|
106
|
+
|
|
107
|
+
} else {
|
|
108
|
+
|
|
109
|
+
return null;
|
|
110
|
+
|
|
111
|
+
}
|
|
73
112
|
|
|
74
113
|
}
|
|
75
114
|
|
|
76
115
|
}
|
|
77
116
|
|
|
78
|
-
|
|
79
|
-
|
|
117
|
+
// PVRTC
|
|
118
|
+
|
|
119
|
+
if ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format || p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) {
|
|
80
120
|
|
|
81
121
|
extension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );
|
|
82
122
|
|
|
@@ -95,6 +135,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
95
135
|
|
|
96
136
|
}
|
|
97
137
|
|
|
138
|
+
// ETC1
|
|
139
|
+
|
|
98
140
|
if ( p === RGB_ETC1_Format ) {
|
|
99
141
|
|
|
100
142
|
extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
|
|
@@ -111,37 +153,51 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
111
153
|
|
|
112
154
|
}
|
|
113
155
|
|
|
156
|
+
// ETC2
|
|
157
|
+
|
|
114
158
|
if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
115
159
|
|
|
116
160
|
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
117
161
|
|
|
118
162
|
if ( extension !== null ) {
|
|
119
163
|
|
|
120
|
-
if ( p === RGB_ETC2_Format ) return extension.COMPRESSED_RGB8_ETC2;
|
|
121
|
-
if ( p === RGBA_ETC2_EAC_Format ) return extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
164
|
+
if ( p === RGB_ETC2_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
165
|
+
if ( p === RGBA_ETC2_EAC_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
166
|
+
|
|
167
|
+
} else {
|
|
168
|
+
|
|
169
|
+
return null;
|
|
122
170
|
|
|
123
171
|
}
|
|
124
172
|
|
|
125
173
|
}
|
|
126
174
|
|
|
175
|
+
// ASTC
|
|
176
|
+
|
|
127
177
|
if ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format ||
|
|
128
178
|
p === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format ||
|
|
129
179
|
p === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format ||
|
|
130
180
|
p === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format ||
|
|
131
|
-
p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format
|
|
132
|
-
p === SRGB8_ALPHA8_ASTC_4x4_Format || p === SRGB8_ALPHA8_ASTC_5x4_Format || p === SRGB8_ALPHA8_ASTC_5x5_Format ||
|
|
133
|
-
p === SRGB8_ALPHA8_ASTC_6x5_Format || p === SRGB8_ALPHA8_ASTC_6x6_Format || p === SRGB8_ALPHA8_ASTC_8x5_Format ||
|
|
134
|
-
p === SRGB8_ALPHA8_ASTC_8x6_Format || p === SRGB8_ALPHA8_ASTC_8x8_Format || p === SRGB8_ALPHA8_ASTC_10x5_Format ||
|
|
135
|
-
p === SRGB8_ALPHA8_ASTC_10x6_Format || p === SRGB8_ALPHA8_ASTC_10x8_Format || p === SRGB8_ALPHA8_ASTC_10x10_Format ||
|
|
136
|
-
p === SRGB8_ALPHA8_ASTC_12x10_Format || p === SRGB8_ALPHA8_ASTC_12x12_Format ) {
|
|
181
|
+
p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ) {
|
|
137
182
|
|
|
138
183
|
extension = extensions.get( 'WEBGL_compressed_texture_astc' );
|
|
139
184
|
|
|
140
185
|
if ( extension !== null ) {
|
|
141
186
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return
|
|
187
|
+
if ( p === RGBA_ASTC_4x4_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
|
|
188
|
+
if ( p === RGBA_ASTC_5x4_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
|
|
189
|
+
if ( p === RGBA_ASTC_5x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
|
|
190
|
+
if ( p === RGBA_ASTC_6x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
|
|
191
|
+
if ( p === RGBA_ASTC_6x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
|
|
192
|
+
if ( p === RGBA_ASTC_8x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
|
|
193
|
+
if ( p === RGBA_ASTC_8x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
|
|
194
|
+
if ( p === RGBA_ASTC_8x8_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
|
|
195
|
+
if ( p === RGBA_ASTC_10x5_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
|
|
196
|
+
if ( p === RGBA_ASTC_10x6_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
|
|
197
|
+
if ( p === RGBA_ASTC_10x8_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
|
|
198
|
+
if ( p === RGBA_ASTC_10x10_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
|
|
199
|
+
if ( p === RGBA_ASTC_12x10_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
|
|
200
|
+
if ( p === RGBA_ASTC_12x12_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
|
|
145
201
|
|
|
146
202
|
} else {
|
|
147
203
|
|
|
@@ -151,15 +207,15 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
151
207
|
|
|
152
208
|
}
|
|
153
209
|
|
|
210
|
+
// BPTC
|
|
211
|
+
|
|
154
212
|
if ( p === RGBA_BPTC_Format ) {
|
|
155
213
|
|
|
156
214
|
extension = extensions.get( 'EXT_texture_compression_bptc' );
|
|
157
215
|
|
|
158
216
|
if ( extension !== null ) {
|
|
159
217
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return p;
|
|
218
|
+
if ( p === RGBA_BPTC_Format ) return ( encoding === sRGBEncoding ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
|
|
163
219
|
|
|
164
220
|
} else {
|
|
165
221
|
|
|
@@ -169,6 +225,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
169
225
|
|
|
170
226
|
}
|
|
171
227
|
|
|
228
|
+
//
|
|
229
|
+
|
|
172
230
|
if ( p === UnsignedInt248Type ) {
|
|
173
231
|
|
|
174
232
|
if ( isWebGL2 ) return gl.UNSIGNED_INT_24_8;
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
DepthFormat,
|
|
13
13
|
DepthStencilFormat,
|
|
14
14
|
RGBAFormat,
|
|
15
|
-
|
|
15
|
+
sRGBEncoding,
|
|
16
16
|
UnsignedByteType,
|
|
17
17
|
UnsignedShortType,
|
|
18
18
|
UnsignedInt248Type,
|
|
@@ -290,7 +290,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
const projectionlayerInit = {
|
|
293
|
-
colorFormat: (
|
|
293
|
+
colorFormat: ( renderer.outputEncoding === sRGBEncoding ) ? gl.SRGB8_ALPHA8 : gl.RGBA8,
|
|
294
294
|
depthFormat: glDepthFormat,
|
|
295
295
|
scaleFactor: framebufferScaleFactor
|
|
296
296
|
};
|
|
@@ -322,7 +322,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
322
322
|
glProjLayer.textureWidth,
|
|
323
323
|
glProjLayer.textureHeight,
|
|
324
324
|
{
|
|
325
|
-
format:
|
|
325
|
+
format: RGBAFormat,
|
|
326
326
|
type: UnsignedByteType,
|
|
327
327
|
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
|
|
328
328
|
stencilBuffer: attributes.stencil,
|
package/src/textures/Texture.js
CHANGED
|
@@ -70,7 +70,8 @@ class Texture extends EventDispatcher {
|
|
|
70
70
|
this.version = 0;
|
|
71
71
|
this.onUpdate = null;
|
|
72
72
|
|
|
73
|
-
this.isRenderTargetTexture = false;
|
|
73
|
+
this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not
|
|
74
|
+
this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
|
|
74
75
|
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinearFilter } from '../constants.js';
|
|
2
2
|
import { Texture } from './Texture.js';
|
|
3
3
|
|
|
4
4
|
class VideoTexture extends Texture {
|
|
@@ -7,8 +7,6 @@ class VideoTexture extends Texture {
|
|
|
7
7
|
|
|
8
8
|
super( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
|
|
9
9
|
|
|
10
|
-
this.format = format !== undefined ? format : RGBFormat;
|
|
11
|
-
|
|
12
10
|
this.minFilter = minFilter !== undefined ? minFilter : LinearFilter;
|
|
13
11
|
this.magFilter = magFilter !== undefined ? magFilter : LinearFilter;
|
|
14
12
|
|
package/examples/js/WebGL.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
( function () {
|
|
2
|
-
|
|
3
|
-
class WEBGL {
|
|
4
|
-
|
|
5
|
-
static isWebGLAvailable() {
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
|
|
9
|
-
const canvas = document.createElement( 'canvas' );
|
|
10
|
-
return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
|
|
11
|
-
|
|
12
|
-
} catch ( e ) {
|
|
13
|
-
|
|
14
|
-
return false;
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static isWebGL2Available() {
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
|
|
24
|
-
const canvas = document.createElement( 'canvas' );
|
|
25
|
-
return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
|
|
26
|
-
|
|
27
|
-
} catch ( e ) {
|
|
28
|
-
|
|
29
|
-
return false;
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static getWebGLErrorMessage() {
|
|
36
|
-
|
|
37
|
-
return this.getErrorMessage( 1 );
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static getWebGL2ErrorMessage() {
|
|
42
|
-
|
|
43
|
-
return this.getErrorMessage( 2 );
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static getErrorMessage( version ) {
|
|
48
|
-
|
|
49
|
-
const names = {
|
|
50
|
-
1: 'WebGL',
|
|
51
|
-
2: 'WebGL 2'
|
|
52
|
-
};
|
|
53
|
-
const contexts = {
|
|
54
|
-
1: window.WebGLRenderingContext,
|
|
55
|
-
2: window.WebGL2RenderingContext
|
|
56
|
-
};
|
|
57
|
-
let message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
|
|
58
|
-
const element = document.createElement( 'div' );
|
|
59
|
-
element.id = 'webglmessage';
|
|
60
|
-
element.style.fontFamily = 'monospace';
|
|
61
|
-
element.style.fontSize = '13px';
|
|
62
|
-
element.style.fontWeight = 'normal';
|
|
63
|
-
element.style.textAlign = 'center';
|
|
64
|
-
element.style.background = '#fff';
|
|
65
|
-
element.style.color = '#000';
|
|
66
|
-
element.style.padding = '1.5em';
|
|
67
|
-
element.style.width = '400px';
|
|
68
|
-
element.style.margin = '5em auto 0';
|
|
69
|
-
|
|
70
|
-
if ( contexts[ version ] ) {
|
|
71
|
-
|
|
72
|
-
message = message.replace( '$0', 'graphics card' );
|
|
73
|
-
|
|
74
|
-
} else {
|
|
75
|
-
|
|
76
|
-
message = message.replace( '$0', 'browser' );
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
message = message.replace( '$1', names[ version ] );
|
|
81
|
-
element.innerHTML = message;
|
|
82
|
-
return element;
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
THREE.WEBGL = WEBGL;
|
|
89
|
-
|
|
90
|
-
} )();
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
( function () {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This class generates custom mipmaps for a roughness map by encoding the lost variation in the
|
|
5
|
-
* normal map mip levels as increased roughness in the corresponding roughness mip levels. This
|
|
6
|
-
* helps with rendering accuracy for MeshStandardMaterial, and also helps with anti-aliasing when
|
|
7
|
-
* using PMREM. If the normal map is larger than the roughness map, the roughness map will be
|
|
8
|
-
* enlarged to match the dimensions of the normal map.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const _mipmapMaterial = _getMipmapMaterial();
|
|
12
|
-
|
|
13
|
-
const _mesh = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), _mipmapMaterial );
|
|
14
|
-
|
|
15
|
-
const _flatCamera = new THREE.OrthographicCamera( 0, 1, 0, 1, 0, 1 );
|
|
16
|
-
|
|
17
|
-
let _tempTarget = null;
|
|
18
|
-
let _renderer = null;
|
|
19
|
-
|
|
20
|
-
class RoughnessMipmapper {
|
|
21
|
-
|
|
22
|
-
constructor( renderer ) {
|
|
23
|
-
|
|
24
|
-
_renderer = renderer;
|
|
25
|
-
|
|
26
|
-
_renderer.compile( _mesh, _flatCamera );
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
generateMipmaps( material ) {
|
|
31
|
-
|
|
32
|
-
if ( 'roughnessMap' in material === false ) return;
|
|
33
|
-
const {
|
|
34
|
-
roughnessMap,
|
|
35
|
-
normalMap
|
|
36
|
-
} = material;
|
|
37
|
-
if ( roughnessMap === null || normalMap === null || ! roughnessMap.generateMipmaps || material.userData.roughnessUpdated ) return;
|
|
38
|
-
material.userData.roughnessUpdated = true;
|
|
39
|
-
let width = Math.max( roughnessMap.image.width, normalMap.image.width );
|
|
40
|
-
let height = Math.max( roughnessMap.image.height, normalMap.image.height );
|
|
41
|
-
if ( ! THREE.MathUtils.isPowerOfTwo( width ) || ! THREE.MathUtils.isPowerOfTwo( height ) ) return;
|
|
42
|
-
|
|
43
|
-
const oldTarget = _renderer.getRenderTarget();
|
|
44
|
-
|
|
45
|
-
const autoClear = _renderer.autoClear;
|
|
46
|
-
_renderer.autoClear = false;
|
|
47
|
-
|
|
48
|
-
if ( _tempTarget === null || _tempTarget.width !== width || _tempTarget.height !== height ) {
|
|
49
|
-
|
|
50
|
-
if ( _tempTarget !== null ) _tempTarget.dispose();
|
|
51
|
-
_tempTarget = new THREE.WebGLRenderTarget( width, height, {
|
|
52
|
-
depthBuffer: false
|
|
53
|
-
} );
|
|
54
|
-
_tempTarget.scissorTest = true;
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const newRoughnessTexture = new THREE.FramebufferTexture( width, height, roughnessMap.format );
|
|
59
|
-
newRoughnessTexture.wrapS = roughnessMap.wrapS;
|
|
60
|
-
newRoughnessTexture.wrapT = roughnessMap.wrapT;
|
|
61
|
-
newRoughnessTexture.minFilter = roughnessMap.minFilter;
|
|
62
|
-
newRoughnessTexture.magFilter = roughnessMap.magFilter;
|
|
63
|
-
material.roughnessMap = newRoughnessTexture;
|
|
64
|
-
if ( material.metalnessMap == roughnessMap ) material.metalnessMap = material.roughnessMap;
|
|
65
|
-
if ( material.aoMap == roughnessMap ) material.aoMap = material.roughnessMap; // Copy UV transform parameters
|
|
66
|
-
|
|
67
|
-
material.roughnessMap.offset.copy( roughnessMap.offset );
|
|
68
|
-
material.roughnessMap.repeat.copy( roughnessMap.repeat );
|
|
69
|
-
material.roughnessMap.center.copy( roughnessMap.center );
|
|
70
|
-
material.roughnessMap.rotation = roughnessMap.rotation;
|
|
71
|
-
material.roughnessMap.image = roughnessMap.image; // required for USDZExporter, see #22741
|
|
72
|
-
|
|
73
|
-
material.roughnessMap.matrixAutoUpdate = roughnessMap.matrixAutoUpdate;
|
|
74
|
-
material.roughnessMap.matrix.copy( roughnessMap.matrix );
|
|
75
|
-
_mipmapMaterial.uniforms.roughnessMap.value = roughnessMap;
|
|
76
|
-
_mipmapMaterial.uniforms.normalMap.value = normalMap;
|
|
77
|
-
const position = new THREE.Vector2( 0, 0 );
|
|
78
|
-
const texelSize = _mipmapMaterial.uniforms.texelSize.value;
|
|
79
|
-
|
|
80
|
-
for ( let mip = 0; width >= 1 && height >= 1; ++ mip, width /= 2, height /= 2 ) {
|
|
81
|
-
|
|
82
|
-
// Rendering to a mip level is not allowed in webGL1. Instead we must set
|
|
83
|
-
// up a secondary texture to write the result to, then copy it back to the
|
|
84
|
-
// proper mipmap level.
|
|
85
|
-
texelSize.set( 1.0 / width, 1.0 / height );
|
|
86
|
-
if ( mip == 0 ) texelSize.set( 0.0, 0.0 );
|
|
87
|
-
|
|
88
|
-
_tempTarget.viewport.set( position.x, position.y, width, height );
|
|
89
|
-
|
|
90
|
-
_tempTarget.scissor.set( position.x, position.y, width, height );
|
|
91
|
-
|
|
92
|
-
_renderer.setRenderTarget( _tempTarget );
|
|
93
|
-
|
|
94
|
-
_renderer.render( _mesh, _flatCamera );
|
|
95
|
-
|
|
96
|
-
_renderer.copyFramebufferToTexture( position, material.roughnessMap, mip );
|
|
97
|
-
|
|
98
|
-
_mipmapMaterial.uniforms.roughnessMap.value = material.roughnessMap;
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
roughnessMap.dispose();
|
|
103
|
-
|
|
104
|
-
_renderer.setRenderTarget( oldTarget );
|
|
105
|
-
|
|
106
|
-
_renderer.autoClear = autoClear;
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
dispose() {
|
|
111
|
-
|
|
112
|
-
_mipmapMaterial.dispose();
|
|
113
|
-
|
|
114
|
-
_mesh.geometry.dispose();
|
|
115
|
-
|
|
116
|
-
if ( _tempTarget != null ) _tempTarget.dispose();
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function _getMipmapMaterial() {
|
|
123
|
-
|
|
124
|
-
const shaderMaterial = new THREE.RawShaderMaterial( {
|
|
125
|
-
uniforms: {
|
|
126
|
-
roughnessMap: {
|
|
127
|
-
value: null
|
|
128
|
-
},
|
|
129
|
-
normalMap: {
|
|
130
|
-
value: null
|
|
131
|
-
},
|
|
132
|
-
texelSize: {
|
|
133
|
-
value: new THREE.Vector2( 1, 1 )
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
vertexShader:
|
|
137
|
-
/* glsl */
|
|
138
|
-
`
|
|
139
|
-
precision mediump float;
|
|
140
|
-
precision mediump int;
|
|
141
|
-
|
|
142
|
-
attribute vec3 position;
|
|
143
|
-
attribute vec2 uv;
|
|
144
|
-
|
|
145
|
-
varying vec2 vUv;
|
|
146
|
-
|
|
147
|
-
void main() {
|
|
148
|
-
|
|
149
|
-
vUv = uv;
|
|
150
|
-
|
|
151
|
-
gl_Position = vec4( position, 1.0 );
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
`,
|
|
155
|
-
fragmentShader:
|
|
156
|
-
/* glsl */
|
|
157
|
-
`
|
|
158
|
-
precision mediump float;
|
|
159
|
-
precision mediump int;
|
|
160
|
-
|
|
161
|
-
varying vec2 vUv;
|
|
162
|
-
|
|
163
|
-
uniform sampler2D roughnessMap;
|
|
164
|
-
uniform sampler2D normalMap;
|
|
165
|
-
uniform vec2 texelSize;
|
|
166
|
-
|
|
167
|
-
#define ENVMAP_TYPE_CUBE_UV
|
|
168
|
-
|
|
169
|
-
vec4 envMapTexelToLinear( vec4 a ) { return a; }
|
|
170
|
-
|
|
171
|
-
#include <cube_uv_reflection_fragment>
|
|
172
|
-
|
|
173
|
-
float roughnessToVariance( float roughness ) {
|
|
174
|
-
|
|
175
|
-
float variance = 0.0;
|
|
176
|
-
|
|
177
|
-
if ( roughness >= r1 ) {
|
|
178
|
-
|
|
179
|
-
variance = ( r0 - roughness ) * ( v1 - v0 ) / ( r0 - r1 ) + v0;
|
|
180
|
-
|
|
181
|
-
} else if ( roughness >= r4 ) {
|
|
182
|
-
|
|
183
|
-
variance = ( r1 - roughness ) * ( v4 - v1 ) / ( r1 - r4 ) + v1;
|
|
184
|
-
|
|
185
|
-
} else if ( roughness >= r5 ) {
|
|
186
|
-
|
|
187
|
-
variance = ( r4 - roughness ) * ( v5 - v4 ) / ( r4 - r5 ) + v4;
|
|
188
|
-
|
|
189
|
-
} else {
|
|
190
|
-
|
|
191
|
-
float roughness2 = roughness * roughness;
|
|
192
|
-
|
|
193
|
-
variance = 1.79 * roughness2 * roughness2;
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return variance;
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
float varianceToRoughness( float variance ) {
|
|
202
|
-
|
|
203
|
-
float roughness = 0.0;
|
|
204
|
-
|
|
205
|
-
if ( variance >= v1 ) {
|
|
206
|
-
|
|
207
|
-
roughness = ( v0 - variance ) * ( r1 - r0 ) / ( v0 - v1 ) + r0;
|
|
208
|
-
|
|
209
|
-
} else if ( variance >= v4 ) {
|
|
210
|
-
|
|
211
|
-
roughness = ( v1 - variance ) * ( r4 - r1 ) / ( v1 - v4 ) + r1;
|
|
212
|
-
|
|
213
|
-
} else if ( variance >= v5 ) {
|
|
214
|
-
|
|
215
|
-
roughness = ( v4 - variance ) * ( r5 - r4 ) / ( v4 - v5 ) + r4;
|
|
216
|
-
|
|
217
|
-
} else {
|
|
218
|
-
|
|
219
|
-
roughness = pow( 0.559 * variance, 0.25 ); // 0.559 = 1.0 / 1.79
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return roughness;
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
void main() {
|
|
228
|
-
|
|
229
|
-
gl_FragColor = texture2D( roughnessMap, vUv, - 1.0 );
|
|
230
|
-
|
|
231
|
-
if ( texelSize.x == 0.0 ) return;
|
|
232
|
-
|
|
233
|
-
float roughness = gl_FragColor.g;
|
|
234
|
-
|
|
235
|
-
float variance = roughnessToVariance( roughness );
|
|
236
|
-
|
|
237
|
-
vec3 avgNormal;
|
|
238
|
-
|
|
239
|
-
for ( float x = - 1.0; x < 2.0; x += 2.0 ) {
|
|
240
|
-
|
|
241
|
-
for ( float y = - 1.0; y < 2.0; y += 2.0 ) {
|
|
242
|
-
|
|
243
|
-
vec2 uv = vUv + vec2( x, y ) * 0.25 * texelSize;
|
|
244
|
-
|
|
245
|
-
avgNormal += normalize( texture2D( normalMap, uv, - 1.0 ).xyz - 0.5 );
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
variance += 1.0 - 0.25 * length( avgNormal );
|
|
252
|
-
|
|
253
|
-
gl_FragColor.g = varianceToRoughness( variance );
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
`,
|
|
257
|
-
blending: THREE.NoBlending,
|
|
258
|
-
depthTest: false,
|
|
259
|
-
depthWrite: false
|
|
260
|
-
} );
|
|
261
|
-
shaderMaterial.type = 'RoughnessMipmapper';
|
|
262
|
-
return shaderMaterial;
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
THREE.RoughnessMipmapper = RoughnessMipmapper;
|
|
267
|
-
|
|
268
|
-
} )();
|