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
|
@@ -30,14 +30,75 @@ class LatheGeometry extends BufferGeometry {
|
|
|
30
30
|
const indices = [];
|
|
31
31
|
const vertices = [];
|
|
32
32
|
const uvs = [];
|
|
33
|
+
const initNormals = [];
|
|
34
|
+
const normals = [];
|
|
33
35
|
|
|
34
36
|
// helper variables
|
|
35
37
|
|
|
36
38
|
const inverseSegments = 1.0 / segments;
|
|
37
39
|
const vertex = new Vector3();
|
|
38
40
|
const uv = new Vector2();
|
|
41
|
+
const normal = new Vector3();
|
|
42
|
+
const curNormal = new Vector3();
|
|
43
|
+
const prevNormal = new Vector3();
|
|
44
|
+
let dx = 0;
|
|
45
|
+
let dy = 0;
|
|
39
46
|
|
|
40
|
-
//
|
|
47
|
+
// pre-compute normals for initial "meridian"
|
|
48
|
+
|
|
49
|
+
for ( let j = 0; j <= ( points.length - 1 ); j ++ ) {
|
|
50
|
+
|
|
51
|
+
switch ( j ) {
|
|
52
|
+
|
|
53
|
+
case 0: // special handling for 1st vertex on path
|
|
54
|
+
|
|
55
|
+
dx = points[ j + 1 ].x - points[ j ].x;
|
|
56
|
+
dy = points[ j + 1 ].y - points[ j ].y;
|
|
57
|
+
|
|
58
|
+
normal.x = dy * 1.0;
|
|
59
|
+
normal.y = - dx;
|
|
60
|
+
normal.z = dy * 0.0;
|
|
61
|
+
|
|
62
|
+
prevNormal.copy( normal );
|
|
63
|
+
|
|
64
|
+
normal.normalize();
|
|
65
|
+
|
|
66
|
+
initNormals.push( normal.x, normal.y, normal.z );
|
|
67
|
+
|
|
68
|
+
break;
|
|
69
|
+
|
|
70
|
+
case ( points.length - 1 ): // special handling for last Vertex on path
|
|
71
|
+
|
|
72
|
+
initNormals.push( prevNormal.x, prevNormal.y, prevNormal.z );
|
|
73
|
+
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
default: // default handling for all vertices in between
|
|
77
|
+
|
|
78
|
+
dx = points[ j + 1 ].x - points[ j ].x;
|
|
79
|
+
dy = points[ j + 1 ].y - points[ j ].y;
|
|
80
|
+
|
|
81
|
+
normal.x = dy * 1.0;
|
|
82
|
+
normal.y = - dx;
|
|
83
|
+
normal.z = dy * 0.0;
|
|
84
|
+
|
|
85
|
+
curNormal.copy( normal );
|
|
86
|
+
|
|
87
|
+
normal.x += prevNormal.x;
|
|
88
|
+
normal.y += prevNormal.y;
|
|
89
|
+
normal.z += prevNormal.z;
|
|
90
|
+
|
|
91
|
+
normal.normalize();
|
|
92
|
+
|
|
93
|
+
initNormals.push( normal.x, normal.y, normal.z );
|
|
94
|
+
|
|
95
|
+
prevNormal.copy( curNormal );
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// generate vertices, uvs and normals
|
|
41
102
|
|
|
42
103
|
for ( let i = 0; i <= segments; i ++ ) {
|
|
43
104
|
|
|
@@ -63,6 +124,13 @@ class LatheGeometry extends BufferGeometry {
|
|
|
63
124
|
|
|
64
125
|
uvs.push( uv.x, uv.y );
|
|
65
126
|
|
|
127
|
+
// normal
|
|
128
|
+
|
|
129
|
+
const x = initNormals[ 3 * j + 0 ] * sin;
|
|
130
|
+
const y = initNormals[ 3 * j + 1 ];
|
|
131
|
+
const z = initNormals[ 3 * j + 0 ] * cos;
|
|
132
|
+
|
|
133
|
+
normals.push( x, y, z );
|
|
66
134
|
|
|
67
135
|
}
|
|
68
136
|
|
|
@@ -95,52 +163,7 @@ class LatheGeometry extends BufferGeometry {
|
|
|
95
163
|
this.setIndex( indices );
|
|
96
164
|
this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
|
97
165
|
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
|
|
98
|
-
|
|
99
|
-
// generate normals
|
|
100
|
-
|
|
101
|
-
this.computeVertexNormals();
|
|
102
|
-
|
|
103
|
-
// if the geometry is closed, we need to average the normals along the seam.
|
|
104
|
-
// because the corresponding vertices are identical (but still have different UVs).
|
|
105
|
-
|
|
106
|
-
if ( phiLength === Math.PI * 2 ) {
|
|
107
|
-
|
|
108
|
-
const normals = this.attributes.normal.array;
|
|
109
|
-
const n1 = new Vector3();
|
|
110
|
-
const n2 = new Vector3();
|
|
111
|
-
const n = new Vector3();
|
|
112
|
-
|
|
113
|
-
// this is the buffer offset for the last line of vertices
|
|
114
|
-
|
|
115
|
-
const base = segments * points.length * 3;
|
|
116
|
-
|
|
117
|
-
for ( let i = 0, j = 0; i < points.length; i ++, j += 3 ) {
|
|
118
|
-
|
|
119
|
-
// select the normal of the vertex in the first line
|
|
120
|
-
|
|
121
|
-
n1.x = normals[ j + 0 ];
|
|
122
|
-
n1.y = normals[ j + 1 ];
|
|
123
|
-
n1.z = normals[ j + 2 ];
|
|
124
|
-
|
|
125
|
-
// select the normal of the vertex in the last line
|
|
126
|
-
|
|
127
|
-
n2.x = normals[ base + j + 0 ];
|
|
128
|
-
n2.y = normals[ base + j + 1 ];
|
|
129
|
-
n2.z = normals[ base + j + 2 ];
|
|
130
|
-
|
|
131
|
-
// average normals
|
|
132
|
-
|
|
133
|
-
n.addVectors( n1, n2 ).normalize();
|
|
134
|
-
|
|
135
|
-
// assign the new values to both normals
|
|
136
|
-
|
|
137
|
-
normals[ j + 0 ] = normals[ base + j + 0 ] = n.x;
|
|
138
|
-
normals[ j + 1 ] = normals[ base + j + 1 ] = n.y;
|
|
139
|
-
normals[ j + 2 ] = normals[ base + j + 2 ] = n.z;
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
}
|
|
166
|
+
this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
|
|
144
167
|
|
|
145
168
|
}
|
|
146
169
|
|
|
@@ -13,7 +13,7 @@ const _camera = /*@__PURE__*/ new Camera();
|
|
|
13
13
|
* - shows frustum, line of sight and up of the camera
|
|
14
14
|
* - suitable for fast updates
|
|
15
15
|
* - based on frustum visualization in lightgl.js shadowmap example
|
|
16
|
-
*
|
|
16
|
+
* https://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
class CameraHelper extends LineSegments {
|
|
@@ -84,6 +84,12 @@ class FileLoader extends Loader {
|
|
|
84
84
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
if ( typeof ReadableStream === 'undefined' || response.body.getReader === undefined ) {
|
|
88
|
+
|
|
89
|
+
return response;
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
87
93
|
const callbacks = loading[ url ];
|
|
88
94
|
const reader = response.body.getReader();
|
|
89
95
|
const contentLength = response.headers.get( 'Content-Length' );
|
|
@@ -92,7 +98,7 @@ class FileLoader extends Loader {
|
|
|
92
98
|
let loaded = 0;
|
|
93
99
|
|
|
94
100
|
// periodically read data into the new stream tracking while download progress
|
|
95
|
-
|
|
101
|
+
const stream = new ReadableStream( {
|
|
96
102
|
start( controller ) {
|
|
97
103
|
|
|
98
104
|
readData();
|
|
@@ -130,6 +136,8 @@ class FileLoader extends Loader {
|
|
|
130
136
|
|
|
131
137
|
} );
|
|
132
138
|
|
|
139
|
+
return new Response( stream );
|
|
140
|
+
|
|
133
141
|
} else {
|
|
134
142
|
|
|
135
143
|
throw Error( `fetch for "${response.url}" responded with ${response.status}: ${response.statusText}` );
|
|
@@ -137,9 +145,7 @@ class FileLoader extends Loader {
|
|
|
137
145
|
}
|
|
138
146
|
|
|
139
147
|
} )
|
|
140
|
-
.then(
|
|
141
|
-
|
|
142
|
-
const response = new Response( stream );
|
|
148
|
+
.then( response => {
|
|
143
149
|
|
|
144
150
|
switch ( this.responseType ) {
|
|
145
151
|
|
|
@@ -188,14 +194,21 @@ class FileLoader extends Loader {
|
|
|
188
194
|
|
|
189
195
|
}
|
|
190
196
|
|
|
191
|
-
this.manager.itemEnd( url );
|
|
192
|
-
|
|
193
197
|
} )
|
|
194
198
|
.catch( err => {
|
|
195
199
|
|
|
196
200
|
// Abort errors and other errors are handled the same
|
|
197
201
|
|
|
198
202
|
const callbacks = loading[ url ];
|
|
203
|
+
|
|
204
|
+
if ( callbacks === undefined ) {
|
|
205
|
+
|
|
206
|
+
// When onLoad was called and url was deleted in `loading`
|
|
207
|
+
this.manager.itemError( url );
|
|
208
|
+
throw err;
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
199
212
|
delete loading[ url ];
|
|
200
213
|
|
|
201
214
|
for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
|
|
@@ -206,6 +219,10 @@ class FileLoader extends Loader {
|
|
|
206
219
|
}
|
|
207
220
|
|
|
208
221
|
this.manager.itemError( url );
|
|
222
|
+
|
|
223
|
+
} )
|
|
224
|
+
.finally( () => {
|
|
225
|
+
|
|
209
226
|
this.manager.itemEnd( url );
|
|
210
227
|
|
|
211
228
|
} );
|
package/src/math/Color.js
CHANGED
|
@@ -298,44 +298,6 @@ class Color {
|
|
|
298
298
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
copyGammaToLinear( color, gammaFactor = 2.0 ) {
|
|
302
|
-
|
|
303
|
-
this.r = Math.pow( color.r, gammaFactor );
|
|
304
|
-
this.g = Math.pow( color.g, gammaFactor );
|
|
305
|
-
this.b = Math.pow( color.b, gammaFactor );
|
|
306
|
-
|
|
307
|
-
return this;
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
copyLinearToGamma( color, gammaFactor = 2.0 ) {
|
|
312
|
-
|
|
313
|
-
const safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;
|
|
314
|
-
|
|
315
|
-
this.r = Math.pow( color.r, safeInverse );
|
|
316
|
-
this.g = Math.pow( color.g, safeInverse );
|
|
317
|
-
this.b = Math.pow( color.b, safeInverse );
|
|
318
|
-
|
|
319
|
-
return this;
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
convertGammaToLinear( gammaFactor ) {
|
|
324
|
-
|
|
325
|
-
this.copyGammaToLinear( this, gammaFactor );
|
|
326
|
-
|
|
327
|
-
return this;
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
convertLinearToGamma( gammaFactor ) {
|
|
332
|
-
|
|
333
|
-
this.copyLinearToGamma( this, gammaFactor );
|
|
334
|
-
|
|
335
|
-
return this;
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
301
|
copySRGBToLinear( color ) {
|
|
340
302
|
|
|
341
303
|
this.r = SRGBToLinear( color.r );
|
package/src/math/Ray.js
CHANGED
|
@@ -100,7 +100,7 @@ class Ray {
|
|
|
100
100
|
|
|
101
101
|
distanceSqToSegment( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {
|
|
102
102
|
|
|
103
|
-
// from
|
|
103
|
+
// from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h
|
|
104
104
|
// It returns the min distance between the ray and the segment
|
|
105
105
|
// defined by v0 and v1
|
|
106
106
|
// It can also set two optional targets :
|
|
@@ -399,7 +399,7 @@ class Ray {
|
|
|
399
399
|
|
|
400
400
|
// Compute the offset origin, edges, and normal.
|
|
401
401
|
|
|
402
|
-
// from
|
|
402
|
+
// from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
|
|
403
403
|
|
|
404
404
|
_edge1.subVectors( b, a );
|
|
405
405
|
_edge2.subVectors( c, a );
|
package/src/math/Sphere.js
CHANGED
|
@@ -193,7 +193,16 @@ class Sphere {
|
|
|
193
193
|
// 1) Enclose the farthest point on the other sphere into this sphere.
|
|
194
194
|
// 2) Enclose the opposite point of the farthest point into this sphere.
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
if ( this.center.equals( sphere.center ) === true ) {
|
|
197
|
+
|
|
198
|
+
_toFarthestPoint.set( 0, 0, 1 ).multiplyScalar( sphere.radius );
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
} else {
|
|
202
|
+
|
|
203
|
+
_toFarthestPoint.subVectors( sphere.center, this.center ).normalize().multiplyScalar( sphere.radius );
|
|
204
|
+
|
|
205
|
+
}
|
|
197
206
|
|
|
198
207
|
this.expandByPoint( _v1.copy( sphere.center ).add( _toFarthestPoint ) );
|
|
199
208
|
this.expandByPoint( _v1.copy( sphere.center ).sub( _toFarthestPoint ) );
|
package/src/objects/Skeleton.js
CHANGED
|
@@ -178,6 +178,7 @@ class Skeleton {
|
|
|
178
178
|
boneMatrices.set( this.boneMatrices ); // copy current values
|
|
179
179
|
|
|
180
180
|
const boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );
|
|
181
|
+
boneTexture.needsUpdate = true;
|
|
181
182
|
|
|
182
183
|
this.boneMatrices = boneMatrices;
|
|
183
184
|
this.boneTexture = boneTexture;
|
|
@@ -111,7 +111,6 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
111
111
|
|
|
112
112
|
// physically based shading
|
|
113
113
|
|
|
114
|
-
this.gammaFactor = 2.0; // for backwards compatibility
|
|
115
114
|
this.outputEncoding = LinearEncoding;
|
|
116
115
|
|
|
117
116
|
// physical lights
|
|
@@ -306,7 +305,7 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
306
305
|
clipping = new WebGLClipping( properties );
|
|
307
306
|
programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
|
|
308
307
|
materials = new WebGLMaterials( properties );
|
|
309
|
-
renderLists = new WebGLRenderLists(
|
|
308
|
+
renderLists = new WebGLRenderLists();
|
|
310
309
|
renderStates = new WebGLRenderStates( extensions, capabilities );
|
|
311
310
|
background = new WebGLBackground( _this, cubemaps, state, objects, _premultipliedAlpha );
|
|
312
311
|
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
@@ -572,6 +571,7 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
572
571
|
cubeuvmaps.dispose();
|
|
573
572
|
objects.dispose();
|
|
574
573
|
bindingStates.dispose();
|
|
574
|
+
programCache.dispose();
|
|
575
575
|
|
|
576
576
|
xr.dispose();
|
|
577
577
|
|
|
@@ -656,6 +656,12 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
656
656
|
|
|
657
657
|
} );
|
|
658
658
|
|
|
659
|
+
if ( material.isShaderMaterial ) {
|
|
660
|
+
|
|
661
|
+
programCache.releaseShaderCache( material );
|
|
662
|
+
|
|
663
|
+
}
|
|
664
|
+
|
|
659
665
|
}
|
|
660
666
|
|
|
661
667
|
}
|
|
@@ -1408,6 +1414,7 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
1408
1414
|
materialProperties.numIntersection = parameters.numClipIntersection;
|
|
1409
1415
|
materialProperties.vertexAlphas = parameters.vertexAlphas;
|
|
1410
1416
|
materialProperties.vertexTangents = parameters.vertexTangents;
|
|
1417
|
+
materialProperties.toneMapping = parameters.toneMapping;
|
|
1411
1418
|
|
|
1412
1419
|
}
|
|
1413
1420
|
|
|
@@ -1426,6 +1433,7 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
1426
1433
|
const morphTargets = !! geometry.morphAttributes.position;
|
|
1427
1434
|
const morphNormals = !! geometry.morphAttributes.normal;
|
|
1428
1435
|
const morphTargetsCount = !! geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0;
|
|
1436
|
+
const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
|
|
1429
1437
|
|
|
1430
1438
|
const materialProperties = properties.get( material );
|
|
1431
1439
|
const lights = currentRenderState.state.lights;
|
|
@@ -1507,6 +1515,10 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
1507
1515
|
|
|
1508
1516
|
needsProgramChange = true;
|
|
1509
1517
|
|
|
1518
|
+
} else if ( materialProperties.toneMapping !== toneMapping ) {
|
|
1519
|
+
|
|
1520
|
+
needsProgramChange = true;
|
|
1521
|
+
|
|
1510
1522
|
} else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) {
|
|
1511
1523
|
|
|
1512
1524
|
needsProgramChange = true;
|
|
@@ -2069,25 +2081,20 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
2069
2081
|
|
|
2070
2082
|
this.copyFramebufferToTexture = function ( position, texture, level = 0 ) {
|
|
2071
2083
|
|
|
2072
|
-
|
|
2073
|
-
const width = Math.floor( texture.image.width * levelScale );
|
|
2074
|
-
const height = Math.floor( texture.image.height * levelScale );
|
|
2075
|
-
|
|
2076
|
-
let glFormat = utils.convert( texture.format );
|
|
2077
|
-
|
|
2078
|
-
if ( capabilities.isWebGL2 ) {
|
|
2084
|
+
if ( texture.isFramebufferTexture !== true ) {
|
|
2079
2085
|
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
if ( glFormat === _gl.RGB ) glFormat = _gl.RGB8;
|
|
2084
|
-
if ( glFormat === _gl.RGBA ) glFormat = _gl.RGBA8;
|
|
2086
|
+
console.error( 'THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.' );
|
|
2087
|
+
return;
|
|
2085
2088
|
|
|
2086
2089
|
}
|
|
2087
2090
|
|
|
2091
|
+
const levelScale = Math.pow( 2, - level );
|
|
2092
|
+
const width = Math.floor( texture.image.width * levelScale );
|
|
2093
|
+
const height = Math.floor( texture.image.height * levelScale );
|
|
2094
|
+
|
|
2088
2095
|
textures.setTexture2D( texture, 0 );
|
|
2089
2096
|
|
|
2090
|
-
_gl.
|
|
2097
|
+
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height );
|
|
2091
2098
|
|
|
2092
2099
|
state.unbindTexture();
|
|
2093
2100
|
|
|
@@ -2237,7 +2244,7 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
2237
2244
|
|
|
2238
2245
|
if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
|
|
2239
2246
|
|
|
2240
|
-
__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
|
|
2247
|
+
__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
|
|
2241
2248
|
|
|
2242
2249
|
}
|
|
2243
2250
|
|
|
@@ -5,7 +5,7 @@ export default /* glsl */`
|
|
|
5
5
|
uniform float bumpScale;
|
|
6
6
|
|
|
7
7
|
// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
|
|
8
|
-
//
|
|
8
|
+
// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf
|
|
9
9
|
|
|
10
10
|
// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)
|
|
11
11
|
|
|
@@ -89,11 +89,7 @@ export default /* glsl */`
|
|
|
89
89
|
|
|
90
90
|
float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );
|
|
91
91
|
|
|
92
|
-
vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );
|
|
93
|
-
|
|
94
|
-
vec2 f = fract( uv );
|
|
95
|
-
|
|
96
|
-
uv += 0.5 - f;
|
|
92
|
+
vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;
|
|
97
93
|
|
|
98
94
|
if ( face > 2.0 ) {
|
|
99
95
|
|
|
@@ -117,25 +113,7 @@ export default /* glsl */`
|
|
|
117
113
|
|
|
118
114
|
uv *= texelSize;
|
|
119
115
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
uv.x += texelSize;
|
|
123
|
-
|
|
124
|
-
vec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
|
|
125
|
-
|
|
126
|
-
uv.y += texelSize;
|
|
127
|
-
|
|
128
|
-
vec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
|
|
129
|
-
|
|
130
|
-
uv.x -= texelSize;
|
|
131
|
-
|
|
132
|
-
vec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
|
|
133
|
-
|
|
134
|
-
vec3 tm = mix( tl, tr, f.x );
|
|
135
|
-
|
|
136
|
-
vec3 bm = mix( bl, br, f.x );
|
|
137
|
-
|
|
138
|
-
return mix( tm, bm, f.y );
|
|
116
|
+
return texture2D( envMap, uv ).rgb;
|
|
139
117
|
|
|
140
118
|
}
|
|
141
119
|
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
|
-
// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/
|
|
3
2
|
|
|
4
3
|
vec4 LinearToLinear( in vec4 value ) {
|
|
5
4
|
return value;
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
|
|
9
|
-
return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
|
|
13
|
-
return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
|
|
14
|
-
}
|
|
15
|
-
|
|
16
7
|
vec4 sRGBToLinear( in vec4 value ) {
|
|
17
8
|
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
|
|
18
9
|
}
|
|
@@ -21,42 +12,4 @@ vec4 LinearTosRGB( in vec4 value ) {
|
|
|
21
12
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
22
13
|
}
|
|
23
14
|
|
|
24
|
-
vec4 RGBEToLinear( in vec4 value ) {
|
|
25
|
-
return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
vec4 LinearToRGBE( in vec4 value ) {
|
|
29
|
-
float maxComponent = max( max( value.r, value.g ), value.b );
|
|
30
|
-
float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
|
|
31
|
-
return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
|
|
32
|
-
// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
|
|
36
|
-
vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
|
|
37
|
-
return vec4( value.rgb * value.a * maxRange, 1.0 );
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
|
|
41
|
-
float maxRGB = max( value.r, max( value.g, value.b ) );
|
|
42
|
-
float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
|
|
43
|
-
M = ceil( M * 255.0 ) / 255.0;
|
|
44
|
-
return vec4( value.rgb / ( M * maxRange ), M );
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
|
|
48
|
-
vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
|
|
49
|
-
return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
|
|
53
|
-
float maxRGB = max( value.r, max( value.g, value.b ) );
|
|
54
|
-
float D = max( maxRange / maxRGB, 1.0 );
|
|
55
|
-
// NOTE: The implementation with min causes the shader to not compile on
|
|
56
|
-
// a common Alcatel A502DL in Chrome 78/Android 8.1. Some research suggests
|
|
57
|
-
// that the chipset is Mediatek MT6739 w/ IMG PowerVR GE8100 GPU.
|
|
58
|
-
// D = min( floor( D ) / 255.0, 1.0 );
|
|
59
|
-
D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
|
|
60
|
-
return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
|
|
61
|
-
}
|
|
62
15
|
`;
|
|
@@ -22,6 +22,26 @@ struct PhysicalMaterial {
|
|
|
22
22
|
|
|
23
23
|
// temporary
|
|
24
24
|
vec3 clearcoatSpecular = vec3( 0.0 );
|
|
25
|
+
vec3 sheenSpecular = vec3( 0.0 );
|
|
26
|
+
|
|
27
|
+
// This is a curve-fit approxmation to the "Charlie sheen" BRDF integrated over the hemisphere from
|
|
28
|
+
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF". The analysis can be found
|
|
29
|
+
// in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
|
30
|
+
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {
|
|
31
|
+
|
|
32
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
33
|
+
|
|
34
|
+
float r2 = roughness * roughness;
|
|
35
|
+
|
|
36
|
+
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|
37
|
+
|
|
38
|
+
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|
39
|
+
|
|
40
|
+
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|
41
|
+
|
|
42
|
+
return saturate( DG * RECIPROCAL_PI );
|
|
43
|
+
|
|
44
|
+
}
|
|
25
45
|
|
|
26
46
|
// Analytical approximation of the DFG LUT, one half of the
|
|
27
47
|
// split-sum approximation used in indirect specular lighting.
|
|
@@ -133,7 +153,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC
|
|
|
133
153
|
|
|
134
154
|
#ifdef USE_SHEEN
|
|
135
155
|
|
|
136
|
-
|
|
156
|
+
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
|
|
137
157
|
|
|
138
158
|
#endif
|
|
139
159
|
|
|
@@ -157,6 +177,12 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
157
177
|
|
|
158
178
|
#endif
|
|
159
179
|
|
|
180
|
+
#ifdef USE_SHEEN
|
|
181
|
+
|
|
182
|
+
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
|
|
183
|
+
|
|
184
|
+
#endif
|
|
185
|
+
|
|
160
186
|
// Both indirect specular and indirect diffuse light accumulate here
|
|
161
187
|
|
|
162
188
|
vec3 singleScattering = vec3( 0.0 );
|
|
@@ -13,7 +13,7 @@ vec3 LinearToneMapping( vec3 color ) {
|
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// source: https://www.cs.utah.edu
|
|
16
|
+
// source: https://www.cs.utah.edu/docs/techreports/2002/pdf/UUCS-02-001.pdf
|
|
17
17
|
vec3 ReinhardToneMapping( vec3 color ) {
|
|
18
18
|
|
|
19
19
|
color *= toneMappingExposure;
|
|
@@ -175,6 +175,16 @@ void main() {
|
|
|
175
175
|
|
|
176
176
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
177
177
|
|
|
178
|
+
#ifdef USE_SHEEN
|
|
179
|
+
|
|
180
|
+
// Sheen energy compensation approximation calculation can be found at the end of
|
|
181
|
+
// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
|
182
|
+
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
183
|
+
|
|
184
|
+
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
|
|
185
|
+
|
|
186
|
+
#endif
|
|
187
|
+
|
|
178
188
|
#ifdef USE_CLEARCOAT
|
|
179
189
|
|
|
180
190
|
float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
|
|
@@ -52,10 +52,8 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
52
52
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/* eslint-disable no-undef */
|
|
56
55
|
const isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ) ||
|
|
57
56
|
( typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext );
|
|
58
|
-
/* eslint-enable no-undef */
|
|
59
57
|
|
|
60
58
|
let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
|
|
61
59
|
const maxPrecision = getMaxPrecision( precision );
|
|
@@ -84,6 +84,7 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
|
|
|
84
84
|
const texture = new DataTexture2DArray( buffer, width, height, numberOfMorphTargets );
|
|
85
85
|
texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower)
|
|
86
86
|
texture.type = FloatType;
|
|
87
|
+
texture.needsUpdate = true;
|
|
87
88
|
|
|
88
89
|
// fill buffer
|
|
89
90
|
|