super-three 0.161.0 → 0.163.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.cjs +822 -1332
- package/build/three.module.js +820 -1328
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/DragControls.js +91 -30
- package/examples/jsm/controls/OrbitControls.js +32 -6
- package/examples/jsm/controls/TransformControls.js +9 -9
- package/examples/jsm/exporters/GLTFExporter.js +30 -3
- package/examples/jsm/exporters/USDZExporter.js +15 -0
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/interactive/InteractiveGroup.js +15 -25
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +32 -14
- package/examples/jsm/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3DMLoader.js +13 -21
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/EXRLoader.js +89 -19
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +6 -0
- package/examples/jsm/loaders/KTX2Loader.js +2 -6
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/VOXLoader.js +9 -2
- package/examples/jsm/loaders/VRMLLoader.js +6 -2
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
- package/examples/jsm/nodes/Nodes.js +15 -8
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
- package/examples/jsm/nodes/accessors/MorphNode.js +20 -10
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
- package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
- package/examples/jsm/nodes/code/CodeNode.js +6 -0
- package/examples/jsm/nodes/core/AssignNode.js +68 -12
- package/examples/jsm/nodes/core/Node.js +67 -6
- package/examples/jsm/nodes/core/NodeBuilder.js +23 -24
- package/examples/jsm/nodes/core/NodeFrame.js +8 -8
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
- package/examples/jsm/nodes/display/PassNode.js +17 -1
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
- package/examples/jsm/nodes/fog/FogNode.js +13 -3
- package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
- package/examples/jsm/nodes/materials/NodeMaterial.js +70 -17
- package/examples/jsm/nodes/math/CondNode.js +42 -7
- package/examples/jsm/nodes/math/MathNode.js +20 -0
- package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
- package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +2 -0
- package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
- package/examples/jsm/objects/QuadMesh.js +7 -23
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAOPass.js +0 -3
- package/examples/jsm/renderers/common/Animation.js +3 -0
- package/examples/jsm/renderers/common/Background.js +3 -3
- package/examples/jsm/renderers/common/ClippingContext.js +165 -0
- package/examples/jsm/renderers/common/Info.js +11 -19
- package/examples/jsm/renderers/common/PostProcessing.js +12 -4
- package/examples/jsm/renderers/common/RenderContext.js +3 -1
- package/examples/jsm/renderers/common/RenderContexts.js +2 -13
- package/examples/jsm/renderers/common/RenderObject.js +46 -3
- package/examples/jsm/renderers/common/RenderObjects.js +2 -0
- package/examples/jsm/renderers/common/Renderer.js +113 -39
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
- package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +3 -13
- package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
- package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +6 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +174 -30
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +136 -11
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +8 -2
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +90 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +67 -37
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +20 -43
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +32 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +94 -20
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/SkeletonUtils.js +14 -3
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/examples/jsm/webxr/VRButton.js +13 -5
- package/examples/jsm/webxr/XRButton.js +0 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
- package/package.json +4 -3
- package/src/Three.Legacy.js +20 -0
- package/src/Three.js +0 -2
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +4 -7
- package/src/core/BufferAttribute.js +0 -11
- package/src/core/BufferGeometry.js +23 -29
- package/src/core/Object3D.js +21 -7
- package/src/core/Raycaster.js +18 -4
- package/src/core/RenderTarget.js +44 -21
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/curves/EllipseCurve.js +2 -2
- package/src/helpers/SpotLightHelper.js +18 -1
- package/src/loaders/DataTextureLoader.js +0 -4
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +4 -1
- package/src/materials/Material.js +2 -1
- package/src/materials/MeshBasicMaterial.js +3 -0
- package/src/materials/MeshLambertMaterial.js +3 -0
- package/src/materials/MeshPhongMaterial.js +3 -0
- package/src/materials/MeshStandardMaterial.js +3 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/math/Quaternion.js +13 -12
- package/src/math/Spherical.js +4 -5
- package/src/math/Vector3.js +7 -7
- package/src/objects/BatchedMesh.js +4 -3
- package/src/objects/InstancedMesh.js +63 -0
- package/src/objects/Mesh.js +0 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -10
- package/src/renderers/WebGLRenderer.js +70 -136
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +3 -2
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBackground.js +18 -0
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLCapabilities.js +2 -12
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +4 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLLights.js +6 -32
- package/src/renderers/webgl/WebGLMaterials.js +26 -4
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -210
- package/src/renderers/webgl/WebGLProgram.js +30 -48
- package/src/renderers/webgl/WebGLPrograms.js +5 -14
- package/src/renderers/webgl/WebGLRenderStates.js +8 -6
- package/src/renderers/webgl/WebGLState.js +21 -75
- package/src/renderers/webgl/WebGLTextures.js +143 -275
- package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
- package/src/renderers/webgl/WebGLUtils.js +6 -57
- package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/scenes/Scene.js +14 -0
- package/src/textures/Texture.js +6 -24
- package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
|
@@ -273,40 +273,50 @@ export default /* glsl */`
|
|
|
273
273
|
|
|
274
274
|
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
float shadow = 1.0;
|
|
277
277
|
|
|
278
278
|
// for point lights, the uniform @vShadowCoord is re-purposed to hold
|
|
279
279
|
// the vector from the light to the world-space position of the fragment.
|
|
280
280
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
281
|
+
|
|
282
|
+
float lightToPositionLength = length( lightToPosition );
|
|
281
283
|
|
|
282
|
-
|
|
283
|
-
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
|
|
284
|
-
dp += shadowBias;
|
|
284
|
+
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
|
285
285
|
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
// dp = normalized distance from light to fragment position
|
|
287
|
+
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
|
|
288
|
+
dp += shadowBias;
|
|
288
289
|
|
|
289
|
-
|
|
290
|
+
// bd3D = base direction 3D
|
|
291
|
+
vec3 bd3D = normalize( lightToPosition );
|
|
290
292
|
|
|
291
|
-
vec2
|
|
293
|
+
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
292
294
|
|
|
293
|
-
|
|
294
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
295
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
296
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
297
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
298
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
299
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
300
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
301
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
302
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
303
|
-
) * ( 1.0 / 9.0 );
|
|
295
|
+
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
304
296
|
|
|
305
|
-
|
|
297
|
+
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
306
298
|
|
|
307
|
-
|
|
299
|
+
shadow = (
|
|
300
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
301
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
302
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
303
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
304
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
305
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
306
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
307
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
308
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
309
|
+
) * ( 1.0 / 9.0 );
|
|
308
310
|
|
|
309
|
-
|
|
311
|
+
#else // no percentage-closer filtering
|
|
312
|
+
|
|
313
|
+
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
314
|
+
|
|
315
|
+
#endif
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return shadow;
|
|
310
320
|
|
|
311
321
|
}
|
|
312
322
|
|
|
@@ -165,5 +165,28 @@ vec3 AgXToneMapping( vec3 color ) {
|
|
|
165
165
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
// https://modelviewer.dev/examples/tone-mapping
|
|
169
|
+
|
|
170
|
+
vec3 NeutralToneMapping( vec3 color ) {
|
|
171
|
+
float startCompression = 0.8 - 0.04;
|
|
172
|
+
float desaturation = 0.15;
|
|
173
|
+
|
|
174
|
+
color *= toneMappingExposure;
|
|
175
|
+
|
|
176
|
+
float x = min(color.r, min(color.g, color.b));
|
|
177
|
+
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|
178
|
+
color -= offset;
|
|
179
|
+
|
|
180
|
+
float peak = max(color.r, max(color.g, color.b));
|
|
181
|
+
if (peak < startCompression) return color;
|
|
182
|
+
|
|
183
|
+
float d = 1. - startCompression;
|
|
184
|
+
float newPeak = 1. - d * d / (peak + d - startCompression);
|
|
185
|
+
color *= newPeak / peak;
|
|
186
|
+
|
|
187
|
+
float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
|
|
188
|
+
return mix(color, newPeak * vec3(1, 1, 1), g);
|
|
189
|
+
}
|
|
190
|
+
|
|
168
191
|
vec3 CustomToneMapping( vec3 color ) { return color; }
|
|
169
192
|
`;
|
|
@@ -65,6 +65,7 @@ import map_particle_fragment from './ShaderChunk/map_particle_fragment.glsl.js';
|
|
|
65
65
|
import map_particle_pars_fragment from './ShaderChunk/map_particle_pars_fragment.glsl.js';
|
|
66
66
|
import metalnessmap_fragment from './ShaderChunk/metalnessmap_fragment.glsl.js';
|
|
67
67
|
import metalnessmap_pars_fragment from './ShaderChunk/metalnessmap_pars_fragment.glsl.js';
|
|
68
|
+
import morphinstance_vertex from './ShaderChunk/morphinstance_vertex.glsl.js';
|
|
68
69
|
import morphcolor_vertex from './ShaderChunk/morphcolor_vertex.glsl.js';
|
|
69
70
|
import morphnormal_vertex from './ShaderChunk/morphnormal_vertex.glsl.js';
|
|
70
71
|
import morphtarget_pars_vertex from './ShaderChunk/morphtarget_pars_vertex.glsl.js';
|
|
@@ -192,6 +193,7 @@ export const ShaderChunk = {
|
|
|
192
193
|
map_particle_pars_fragment: map_particle_pars_fragment,
|
|
193
194
|
metalnessmap_fragment: metalnessmap_fragment,
|
|
194
195
|
metalnessmap_pars_fragment: metalnessmap_pars_fragment,
|
|
196
|
+
morphinstance_vertex: morphinstance_vertex,
|
|
195
197
|
morphcolor_vertex: morphcolor_vertex,
|
|
196
198
|
morphnormal_vertex: morphnormal_vertex,
|
|
197
199
|
morphtarget_pars_vertex: morphtarget_pars_vertex,
|
|
@@ -30,6 +30,7 @@ export const fragment = /* glsl */`
|
|
|
30
30
|
uniform float flipEnvMap;
|
|
31
31
|
uniform float backgroundBlurriness;
|
|
32
32
|
uniform float backgroundIntensity;
|
|
33
|
+
uniform mat3 backgroundRotation;
|
|
33
34
|
|
|
34
35
|
varying vec3 vWorldDirection;
|
|
35
36
|
|
|
@@ -39,11 +40,11 @@ void main() {
|
|
|
39
40
|
|
|
40
41
|
#ifdef ENVMAP_TYPE_CUBE
|
|
41
42
|
|
|
42
|
-
vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
43
|
+
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
43
44
|
|
|
44
45
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
45
46
|
|
|
46
|
-
vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
|
|
47
|
+
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|
47
48
|
|
|
48
49
|
#else
|
|
49
50
|
|
|
@@ -93,7 +93,7 @@ const ShaderLib = {
|
|
|
93
93
|
emissive: { value: /*@__PURE__*/ new Color( 0x000000 ) },
|
|
94
94
|
roughness: { value: 1.0 },
|
|
95
95
|
metalness: { value: 0.0 },
|
|
96
|
-
envMapIntensity: { value: 1 }
|
|
96
|
+
envMapIntensity: { value: 1 }
|
|
97
97
|
}
|
|
98
98
|
] ),
|
|
99
99
|
|
|
@@ -232,7 +232,8 @@ const ShaderLib = {
|
|
|
232
232
|
envMap: { value: null },
|
|
233
233
|
flipEnvMap: { value: - 1 },
|
|
234
234
|
backgroundBlurriness: { value: 0 },
|
|
235
|
-
backgroundIntensity: { value: 1 }
|
|
235
|
+
backgroundIntensity: { value: 1 },
|
|
236
|
+
backgroundRotation: { value: /*@__PURE__*/ new Matrix3() }
|
|
236
237
|
},
|
|
237
238
|
|
|
238
239
|
vertexShader: ShaderChunk.backgroundCube_vert,
|
|
@@ -86,13 +86,22 @@ export function cloneUniformsGroups( src ) {
|
|
|
86
86
|
|
|
87
87
|
export function getUnlitUniformColorSpace( renderer ) {
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
90
|
+
|
|
91
|
+
if ( currentRenderTarget === null ) {
|
|
90
92
|
|
|
91
93
|
// https://github.com/mrdoob/three.js/pull/23937#issuecomment-1111067398
|
|
92
94
|
return renderer.outputColorSpace;
|
|
93
95
|
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
// https://github.com/mrdoob/three.js/issues/27868
|
|
99
|
+
if ( currentRenderTarget.isXRRenderTarget === true ) {
|
|
100
|
+
|
|
101
|
+
return currentRenderTarget.texture.colorSpace;
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
return ColorManagement.workingColorSpace;
|
|
97
106
|
|
|
98
107
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
function WebGLAttributes( gl
|
|
2
|
-
|
|
3
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
1
|
+
function WebGLAttributes( gl ) {
|
|
4
2
|
|
|
5
3
|
const buffers = new WeakMap();
|
|
6
4
|
|
|
@@ -27,15 +25,7 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
27
25
|
|
|
28
26
|
if ( attribute.isFloat16BufferAttribute ) {
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type = gl.HALF_FLOAT;
|
|
33
|
-
|
|
34
|
-
} else {
|
|
35
|
-
|
|
36
|
-
throw new Error( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' );
|
|
37
|
-
|
|
38
|
-
}
|
|
28
|
+
type = gl.HALF_FLOAT;
|
|
39
29
|
|
|
40
30
|
} else {
|
|
41
31
|
|
|
@@ -103,17 +93,9 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
103
93
|
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
104
94
|
|
|
105
95
|
const range = updateRanges[ i ];
|
|
106
|
-
if ( isWebGL2 ) {
|
|
107
|
-
|
|
108
|
-
gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
|
|
109
|
-
array, range.start, range.count );
|
|
110
|
-
|
|
111
|
-
} else {
|
|
112
96
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
97
|
+
gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
|
|
98
|
+
array, range.start, range.count );
|
|
117
99
|
|
|
118
100
|
}
|
|
119
101
|
|
|
@@ -124,17 +106,8 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
124
106
|
// @deprecated, r159
|
|
125
107
|
if ( updateRange.count !== - 1 ) {
|
|
126
108
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
130
|
-
array, updateRange.offset, updateRange.count );
|
|
131
|
-
|
|
132
|
-
} else {
|
|
133
|
-
|
|
134
|
-
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
135
|
-
array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );
|
|
136
|
-
|
|
137
|
-
}
|
|
109
|
+
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
110
|
+
array, updateRange.offset, updateRange.count );
|
|
138
111
|
|
|
139
112
|
updateRange.count = - 1; // reset range
|
|
140
113
|
|
|
@@ -4,11 +4,15 @@ import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
|
|
|
4
4
|
import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
|
|
5
5
|
import { Color } from '../../math/Color.js';
|
|
6
6
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
7
|
+
import { Euler } from '../../math/Euler.js';
|
|
8
|
+
import { Matrix4 } from '../../math/Matrix4.js';
|
|
7
9
|
import { Mesh } from '../../objects/Mesh.js';
|
|
8
10
|
import { ShaderLib } from '../shaders/ShaderLib.js';
|
|
9
11
|
import { cloneUniforms, getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
|
|
10
12
|
|
|
11
13
|
const _rgb = { r: 0, b: 0, g: 0 };
|
|
14
|
+
const _e1 = /*@__PURE__*/ new Euler();
|
|
15
|
+
const _m1 = /*@__PURE__*/ new Matrix4();
|
|
12
16
|
|
|
13
17
|
function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha, premultipliedAlpha ) {
|
|
14
18
|
|
|
@@ -105,10 +109,24 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
105
109
|
|
|
106
110
|
}
|
|
107
111
|
|
|
112
|
+
_e1.copy( scene.backgroundRotation );
|
|
113
|
+
|
|
114
|
+
// accommodate left-handed frame
|
|
115
|
+
_e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
|
|
116
|
+
|
|
117
|
+
if ( background.isCubeTexture && background.isRenderTargetTexture === false ) {
|
|
118
|
+
|
|
119
|
+
// environment maps which are not cube render targets or PMREMs follow a different convention
|
|
120
|
+
_e1.y *= - 1;
|
|
121
|
+
_e1.z *= - 1;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
108
125
|
boxMesh.material.uniforms.envMap.value = background;
|
|
109
126
|
boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
110
127
|
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
111
128
|
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
129
|
+
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );
|
|
112
130
|
boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
|
|
113
131
|
|
|
114
132
|
if ( currentBackground !== background ||
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { IntType } from '../../constants.js';
|
|
2
2
|
|
|
3
|
-
function WebGLBindingStates( gl,
|
|
3
|
+
function WebGLBindingStates( gl, attributes ) {
|
|
4
4
|
|
|
5
5
|
const maxVertexAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );
|
|
6
6
|
|
|
7
|
-
const extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' );
|
|
8
|
-
const vaoAvailable = capabilities.isWebGL2 || extension !== null;
|
|
9
|
-
|
|
10
7
|
const bindingStates = {};
|
|
11
8
|
|
|
12
9
|
const defaultState = createBindingState( null );
|
|
@@ -17,38 +14,18 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
17
14
|
|
|
18
15
|
let updateBuffers = false;
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const state = getBindingState( geometry, program, material );
|
|
23
|
-
|
|
24
|
-
if ( currentState !== state ) {
|
|
25
|
-
|
|
26
|
-
currentState = state;
|
|
27
|
-
bindVertexArrayObject( currentState.object );
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
updateBuffers = needsUpdate( object, geometry, program, index );
|
|
32
|
-
|
|
33
|
-
if ( updateBuffers ) saveCache( object, geometry, program, index );
|
|
34
|
-
|
|
35
|
-
} else {
|
|
36
|
-
|
|
37
|
-
const wireframe = ( material.wireframe === true );
|
|
17
|
+
const state = getBindingState( geometry, program, material );
|
|
38
18
|
|
|
39
|
-
|
|
40
|
-
currentState.program !== program.id ||
|
|
41
|
-
currentState.wireframe !== wireframe ) {
|
|
19
|
+
if ( currentState !== state ) {
|
|
42
20
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
currentState.wireframe = wireframe;
|
|
21
|
+
currentState = state;
|
|
22
|
+
bindVertexArrayObject( currentState.object );
|
|
46
23
|
|
|
47
|
-
|
|
24
|
+
}
|
|
48
25
|
|
|
49
|
-
|
|
26
|
+
updateBuffers = needsUpdate( object, geometry, program, index );
|
|
50
27
|
|
|
51
|
-
|
|
28
|
+
if ( updateBuffers ) saveCache( object, geometry, program, index );
|
|
52
29
|
|
|
53
30
|
if ( index !== null ) {
|
|
54
31
|
|
|
@@ -74,25 +51,19 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
74
51
|
|
|
75
52
|
function createVertexArrayObject() {
|
|
76
53
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return extension.createVertexArrayOES();
|
|
54
|
+
return gl.createVertexArray();
|
|
80
55
|
|
|
81
56
|
}
|
|
82
57
|
|
|
83
58
|
function bindVertexArrayObject( vao ) {
|
|
84
59
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return extension.bindVertexArrayOES( vao );
|
|
60
|
+
return gl.bindVertexArray( vao );
|
|
88
61
|
|
|
89
62
|
}
|
|
90
63
|
|
|
91
64
|
function deleteVertexArrayObject( vao ) {
|
|
92
65
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return extension.deleteVertexArrayOES( vao );
|
|
66
|
+
return gl.deleteVertexArray( vao );
|
|
96
67
|
|
|
97
68
|
}
|
|
98
69
|
|
|
@@ -290,9 +261,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
290
261
|
|
|
291
262
|
if ( attributeDivisors[ attribute ] !== meshPerAttribute ) {
|
|
292
263
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
extension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );
|
|
264
|
+
gl.vertexAttribDivisor( attribute, meshPerAttribute );
|
|
296
265
|
attributeDivisors[ attribute ] = meshPerAttribute;
|
|
297
266
|
|
|
298
267
|
}
|
|
@@ -333,12 +302,6 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
333
302
|
|
|
334
303
|
function setupVertexAttributes( object, material, program, geometry ) {
|
|
335
304
|
|
|
336
|
-
if ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) {
|
|
337
|
-
|
|
338
|
-
if ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return;
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
|
|
342
305
|
initAttributes();
|
|
343
306
|
|
|
344
307
|
const geometryAttributes = geometry.attributes;
|
|
@@ -377,9 +340,9 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
377
340
|
const type = attribute.type;
|
|
378
341
|
const bytesPerElement = attribute.bytesPerElement;
|
|
379
342
|
|
|
380
|
-
// check for integer attributes
|
|
343
|
+
// check for integer attributes
|
|
381
344
|
|
|
382
|
-
const integer = (
|
|
345
|
+
const integer = ( type === gl.INT || type === gl.UNSIGNED_INT || geometryAttribute.gpuType === IntType );
|
|
383
346
|
|
|
384
347
|
if ( geometryAttribute.isInterleavedBufferAttribute ) {
|
|
385
348
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
function WebGLBufferRenderer( gl, extensions, info
|
|
2
|
-
|
|
3
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
1
|
+
function WebGLBufferRenderer( gl, extensions, info ) {
|
|
4
2
|
|
|
5
3
|
let mode;
|
|
6
4
|
|
|
@@ -22,28 +20,7 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
|
|
|
22
20
|
|
|
23
21
|
if ( primcount === 0 ) return;
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if ( isWebGL2 ) {
|
|
28
|
-
|
|
29
|
-
extension = gl;
|
|
30
|
-
methodName = 'drawArraysInstanced';
|
|
31
|
-
|
|
32
|
-
} else {
|
|
33
|
-
|
|
34
|
-
extension = extensions.get( 'ANGLE_instanced_arrays' );
|
|
35
|
-
methodName = 'drawArraysInstancedANGLE';
|
|
36
|
-
|
|
37
|
-
if ( extension === null ) {
|
|
38
|
-
|
|
39
|
-
console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
|
|
40
|
-
return;
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
extension[ methodName ]( mode, start, count, primcount );
|
|
23
|
+
gl.drawArraysInstanced( mode, start, count, primcount );
|
|
47
24
|
|
|
48
25
|
info.update( count, mode, primcount );
|
|
49
26
|
|
|
@@ -54,6 +31,7 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
|
|
|
54
31
|
if ( drawCount === 0 ) return;
|
|
55
32
|
|
|
56
33
|
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
34
|
+
|
|
57
35
|
if ( extension === null ) {
|
|
58
36
|
|
|
59
37
|
for ( let i = 0; i < drawCount; i ++ ) {
|
|
@@ -52,8 +52,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
52
52
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl.constructor.name === 'WebGL2RenderingContext';
|
|
56
|
-
|
|
57
55
|
let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
|
|
58
56
|
const maxPrecision = getMaxPrecision( precision );
|
|
59
57
|
|
|
@@ -64,8 +62,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
64
62
|
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
const drawBuffers = isWebGL2 || extensions.has( 'WEBGL_draw_buffers' );
|
|
68
|
-
|
|
69
65
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
70
66
|
|
|
71
67
|
const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
@@ -79,16 +75,12 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
79
75
|
const maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );
|
|
80
76
|
|
|
81
77
|
const vertexTextures = maxVertexTextures > 0;
|
|
82
|
-
const floatFragmentTextures = isWebGL2 || extensions.has( 'OES_texture_float' );
|
|
83
|
-
const floatVertexTextures = vertexTextures && floatFragmentTextures;
|
|
84
78
|
|
|
85
|
-
const maxSamples =
|
|
79
|
+
const maxSamples = gl.getParameter( gl.MAX_SAMPLES );
|
|
86
80
|
|
|
87
81
|
return {
|
|
88
82
|
|
|
89
|
-
isWebGL2:
|
|
90
|
-
|
|
91
|
-
drawBuffers: drawBuffers,
|
|
83
|
+
isWebGL2: true, // keeping this for backwards compatibility
|
|
92
84
|
|
|
93
85
|
getMaxAnisotropy: getMaxAnisotropy,
|
|
94
86
|
getMaxPrecision: getMaxPrecision,
|
|
@@ -107,8 +99,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
107
99
|
maxFragmentUniforms: maxFragmentUniforms,
|
|
108
100
|
|
|
109
101
|
vertexTextures: vertexTextures,
|
|
110
|
-
floatFragmentTextures: floatFragmentTextures,
|
|
111
|
-
floatVertexTextures: floatVertexTextures,
|
|
112
102
|
|
|
113
103
|
maxSamples: maxSamples
|
|
114
104
|
|