super-three 0.164.0 → 0.165.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/README.md +3 -3
- package/build/three.cjs +664 -217
- package/build/three.module.js +664 -217
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -5
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +6 -4
- package/examples/jsm/helpers/ViewHelper.js +32 -67
- package/examples/jsm/libs/tween.module.js +75 -64
- package/examples/jsm/lines/LineMaterial.js +1 -15
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/loaders/DRACOLoader.js +1 -1
- package/examples/jsm/loaders/FBXLoader.js +24 -13
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/nodes/Nodes.js +12 -11
- package/examples/jsm/nodes/accessors/BitangentNode.js +7 -83
- package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +12 -119
- package/examples/jsm/nodes/accessors/MaterialNode.js +2 -0
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +9 -101
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -100
- package/examples/jsm/nodes/accessors/ReferenceNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -31
- package/examples/jsm/nodes/accessors/{TextureStoreNode.js → StorageTextureNode.js} +19 -6
- package/examples/jsm/nodes/accessors/TangentNode.js +11 -97
- package/examples/jsm/nodes/accessors/Texture3DNode.js +100 -0
- package/examples/jsm/nodes/accessors/UVNode.js +2 -46
- package/examples/jsm/nodes/core/AttributeNode.js +15 -3
- package/examples/jsm/nodes/core/ContextNode.js +6 -0
- package/examples/jsm/nodes/core/Node.js +15 -2
- package/examples/jsm/nodes/core/NodeBuilder.js +20 -9
- package/examples/jsm/nodes/core/NodeKeywords.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +1 -5
- package/examples/jsm/nodes/core/PropertyNode.js +1 -0
- package/examples/jsm/nodes/core/VaryingNode.js +40 -9
- package/examples/jsm/nodes/display/AfterImageNode.js +14 -2
- package/examples/jsm/nodes/display/PassNode.js +3 -1
- package/examples/jsm/nodes/display/ViewportNode.js +1 -1
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +61 -17
- package/examples/jsm/nodes/functions/ToonLightingModel.js +49 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +17 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/Materials.js +3 -0
- package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +52 -0
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +21 -4
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +13 -5
- package/examples/jsm/nodes/materials/VolumeNodeMaterial.js +106 -0
- package/examples/jsm/nodes/math/HashNode.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +55 -33
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/MatcapUVNode.js +1 -1
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/common/Attributes.js +2 -0
- package/examples/jsm/renderers/common/Bindings.js +17 -0
- package/examples/jsm/renderers/common/ChainMap.js +18 -48
- package/examples/jsm/renderers/common/ClippingContext.js +4 -4
- package/examples/jsm/renderers/common/Pipelines.js +2 -2
- package/examples/jsm/renderers/common/RenderBundle.js +18 -0
- package/examples/jsm/renderers/common/RenderBundles.js +38 -0
- package/examples/jsm/renderers/common/RenderList.js +9 -0
- package/examples/jsm/renderers/common/RenderObject.js +6 -0
- package/examples/jsm/renderers/common/Renderer.js +139 -11
- package/examples/jsm/renderers/common/Uniform.js +1 -1
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +18 -4
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +6 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +17 -5
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +93 -6
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +50 -4
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +69 -11
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +10 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +6 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +62 -19
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -3
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GPUStatsPanel.js +2 -0
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/package.json +3 -2
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/constants.js +1 -1
- package/src/core/Object3D.js +2 -0
- package/src/core/Raycaster.js +6 -2
- package/src/loaders/FileLoader.js +4 -0
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/objects/BatchedMesh.js +91 -1
- package/src/renderers/WebGLRenderer.js +288 -57
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/webgl/WebGLBackground.js +6 -0
- package/src/renderers/webgl/WebGLExtensions.js +3 -1
- package/src/renderers/webgl/WebGLLights.js +9 -12
- package/src/renderers/webgl/WebGLMaterials.js +1 -5
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
- package/src/renderers/webgl/WebGLProgram.js +2 -31
- package/src/renderers/webgl/WebGLPrograms.js +14 -14
- package/src/renderers/webgl/WebGLRenderStates.js +2 -2
- package/src/renderers/webgl/WebGLTextures.js +139 -70
- package/src/renderers/webxr/WebXRDepthSensing.js +3 -3
- package/src/renderers/webxr/WebXRManager.js +6 -2
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/utils.js +30 -1
|
@@ -4,44 +4,23 @@ export default /* glsl */`
|
|
|
4
4
|
#ifndef USE_INSTANCING_MORPH
|
|
5
5
|
|
|
6
6
|
uniform float morphTargetBaseInfluence;
|
|
7
|
+
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
7
8
|
|
|
8
9
|
#endif
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
uniform sampler2DArray morphTargetsTexture;
|
|
12
|
+
uniform ivec2 morphTargetsTextureSize;
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|
17
|
+
int y = texelIndex / morphTargetsTextureSize.x;
|
|
18
|
+
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
21
|
+
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
uniform ivec2 morphTargetsTextureSize;
|
|
20
|
-
|
|
21
|
-
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|
22
|
-
|
|
23
|
-
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|
24
|
-
int y = texelIndex / morphTargetsTextureSize.x;
|
|
25
|
-
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|
26
|
-
|
|
27
|
-
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
28
|
-
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
#else
|
|
33
|
-
|
|
34
|
-
#ifndef USE_MORPHNORMALS
|
|
35
|
-
|
|
36
|
-
uniform float morphTargetInfluences[ 8 ];
|
|
37
|
-
|
|
38
|
-
#else
|
|
39
|
-
|
|
40
|
-
uniform float morphTargetInfluences[ 4 ];
|
|
41
|
-
|
|
42
|
-
#endif
|
|
43
|
-
|
|
44
|
-
#endif
|
|
23
|
+
}
|
|
45
24
|
|
|
46
25
|
#endif
|
|
47
26
|
`;
|
|
@@ -6,31 +6,11 @@ export default /* glsl */`
|
|
|
6
6
|
// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting
|
|
7
7
|
transformed *= morphTargetBaseInfluence;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
#else
|
|
18
|
-
|
|
19
|
-
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
|
|
20
|
-
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
|
|
21
|
-
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
|
|
22
|
-
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
|
|
23
|
-
|
|
24
|
-
#ifndef USE_MORPHNORMALS
|
|
25
|
-
|
|
26
|
-
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
|
|
27
|
-
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
|
|
28
|
-
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
|
|
29
|
-
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
|
|
30
|
-
|
|
31
|
-
#endif
|
|
32
|
-
|
|
33
|
-
#endif
|
|
13
|
+
}
|
|
34
14
|
|
|
35
15
|
#endif
|
|
36
16
|
`;
|
|
@@ -71,6 +71,12 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
71
71
|
|
|
72
72
|
if ( renderer.autoClear || forceClear ) {
|
|
73
73
|
|
|
74
|
+
// buffers might not be writable which is required to ensure a correct clear
|
|
75
|
+
|
|
76
|
+
state.buffers.depth.setTest( true );
|
|
77
|
+
state.buffers.depth.setMask( true );
|
|
78
|
+
state.buffers.color.setMask( true );
|
|
79
|
+
|
|
74
80
|
renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
|
|
75
81
|
|
|
76
82
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { warnOnce } from '../../utils.js';
|
|
2
|
+
|
|
1
3
|
function WebGLExtensions( gl ) {
|
|
2
4
|
|
|
3
5
|
const extensions = {};
|
|
@@ -66,7 +68,7 @@ function WebGLExtensions( gl ) {
|
|
|
66
68
|
|
|
67
69
|
if ( extension === null ) {
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
warnOnce( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
|
|
70
72
|
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -205,7 +205,7 @@ function WebGLLights( extensions ) {
|
|
|
205
205
|
const matrix4 = new Matrix4();
|
|
206
206
|
const matrix42 = new Matrix4();
|
|
207
207
|
|
|
208
|
-
function setup( lights
|
|
208
|
+
function setup( lights ) {
|
|
209
209
|
|
|
210
210
|
let r = 0, g = 0, b = 0;
|
|
211
211
|
|
|
@@ -228,9 +228,6 @@ function WebGLLights( extensions ) {
|
|
|
228
228
|
// ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
|
|
229
229
|
lights.sort( shadowCastingAndTexturingLightsFirst );
|
|
230
230
|
|
|
231
|
-
// artist-friendly light intensity scaling factor
|
|
232
|
-
const scaleFactor = ( useLegacyLights === true ) ? Math.PI : 1;
|
|
233
|
-
|
|
234
231
|
for ( let i = 0, l = lights.length; i < l; i ++ ) {
|
|
235
232
|
|
|
236
233
|
const light = lights[ i ];
|
|
@@ -243,9 +240,9 @@ function WebGLLights( extensions ) {
|
|
|
243
240
|
|
|
244
241
|
if ( light.isAmbientLight ) {
|
|
245
242
|
|
|
246
|
-
r += color.r * intensity
|
|
247
|
-
g += color.g * intensity
|
|
248
|
-
b += color.b * intensity
|
|
243
|
+
r += color.r * intensity;
|
|
244
|
+
g += color.g * intensity;
|
|
245
|
+
b += color.b * intensity;
|
|
249
246
|
|
|
250
247
|
} else if ( light.isLightProbe ) {
|
|
251
248
|
|
|
@@ -261,7 +258,7 @@ function WebGLLights( extensions ) {
|
|
|
261
258
|
|
|
262
259
|
const uniforms = cache.get( light );
|
|
263
260
|
|
|
264
|
-
uniforms.color.copy( light.color ).multiplyScalar( light.intensity
|
|
261
|
+
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
265
262
|
|
|
266
263
|
if ( light.castShadow ) {
|
|
267
264
|
|
|
@@ -292,7 +289,7 @@ function WebGLLights( extensions ) {
|
|
|
292
289
|
|
|
293
290
|
uniforms.position.setFromMatrixPosition( light.matrixWorld );
|
|
294
291
|
|
|
295
|
-
uniforms.color.copy( color ).multiplyScalar( intensity
|
|
292
|
+
uniforms.color.copy( color ).multiplyScalar( intensity );
|
|
296
293
|
uniforms.distance = distance;
|
|
297
294
|
|
|
298
295
|
uniforms.coneCos = Math.cos( light.angle );
|
|
@@ -353,7 +350,7 @@ function WebGLLights( extensions ) {
|
|
|
353
350
|
|
|
354
351
|
const uniforms = cache.get( light );
|
|
355
352
|
|
|
356
|
-
uniforms.color.copy( light.color ).multiplyScalar( light.intensity
|
|
353
|
+
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
357
354
|
uniforms.distance = light.distance;
|
|
358
355
|
uniforms.decay = light.decay;
|
|
359
356
|
|
|
@@ -386,8 +383,8 @@ function WebGLLights( extensions ) {
|
|
|
386
383
|
|
|
387
384
|
const uniforms = cache.get( light );
|
|
388
385
|
|
|
389
|
-
uniforms.skyColor.copy( light.color ).multiplyScalar( intensity
|
|
390
|
-
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity
|
|
386
|
+
uniforms.skyColor.copy( light.color ).multiplyScalar( intensity );
|
|
387
|
+
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );
|
|
391
388
|
|
|
392
389
|
state.hemi[ hemiLength ] = uniforms;
|
|
393
390
|
|
|
@@ -249,11 +249,7 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
249
249
|
if ( material.lightMap ) {
|
|
250
250
|
|
|
251
251
|
uniforms.lightMap.value = material.lightMap;
|
|
252
|
-
|
|
253
|
-
// artist-friendly light intensity scaling factor
|
|
254
|
-
const scaleFactor = ( renderer._useLegacyLights === true ) ? Math.PI : 1;
|
|
255
|
-
|
|
256
|
-
uniforms.lightMapIntensity.value = material.lightMapIntensity * scaleFactor;
|
|
252
|
+
uniforms.lightMapIntensity.value = material.lightMapIntensity;
|
|
257
253
|
|
|
258
254
|
refreshTransformUniform( material.lightMap, uniforms.lightMapTransform );
|
|
259
255
|
|
|
@@ -12,8 +12,7 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
|
|
|
12
12
|
|
|
13
13
|
const objectInfluences = object.morphTargetInfluences;
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
// into an array of data textures. Each layer represents a single morph target.
|
|
15
|
+
// the following encodes morph targets into an array of data textures. Each layer represents a single morph target.
|
|
17
16
|
|
|
18
17
|
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
19
18
|
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
@@ -524,6 +524,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
524
524
|
|
|
525
525
|
parameters.extensionClipCullDistance ? '#define USE_CLIP_DISTANCE' : '',
|
|
526
526
|
parameters.batching ? '#define USE_BATCHING' : '',
|
|
527
|
+
parameters.batchingColor ? '#define USE_BATCHING_COLOR' : '',
|
|
527
528
|
parameters.instancing ? '#define USE_INSTANCING' : '',
|
|
528
529
|
parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
|
|
529
530
|
parameters.instancingMorph ? '#define USE_INSTANCING_MORPH' : '',
|
|
@@ -620,7 +621,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
620
621
|
parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
|
|
621
622
|
parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
|
|
622
623
|
( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
|
|
623
|
-
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
|
|
624
624
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
|
|
625
625
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
|
|
626
626
|
parameters.doubleSided ? '#define DOUBLE_SIDED' : '',
|
|
@@ -633,8 +633,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
633
633
|
|
|
634
634
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
635
635
|
|
|
636
|
-
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
637
|
-
|
|
638
636
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
639
637
|
|
|
640
638
|
'uniform mat4 modelMatrix;',
|
|
@@ -701,31 +699,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
701
699
|
|
|
702
700
|
'#endif',
|
|
703
701
|
|
|
704
|
-
'#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )',
|
|
705
|
-
|
|
706
|
-
' attribute vec3 morphTarget0;',
|
|
707
|
-
' attribute vec3 morphTarget1;',
|
|
708
|
-
' attribute vec3 morphTarget2;',
|
|
709
|
-
' attribute vec3 morphTarget3;',
|
|
710
|
-
|
|
711
|
-
' #ifdef USE_MORPHNORMALS',
|
|
712
|
-
|
|
713
|
-
' attribute vec3 morphNormal0;',
|
|
714
|
-
' attribute vec3 morphNormal1;',
|
|
715
|
-
' attribute vec3 morphNormal2;',
|
|
716
|
-
' attribute vec3 morphNormal3;',
|
|
717
|
-
|
|
718
|
-
' #else',
|
|
719
|
-
|
|
720
|
-
' attribute vec3 morphTarget4;',
|
|
721
|
-
' attribute vec3 morphTarget5;',
|
|
722
|
-
' attribute vec3 morphTarget6;',
|
|
723
|
-
' attribute vec3 morphTarget7;',
|
|
724
|
-
|
|
725
|
-
' #endif',
|
|
726
|
-
|
|
727
|
-
'#endif',
|
|
728
|
-
|
|
729
702
|
'#ifdef USE_SKINNING',
|
|
730
703
|
|
|
731
704
|
' attribute vec4 skinIndex;',
|
|
@@ -801,7 +774,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
801
774
|
parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '',
|
|
802
775
|
|
|
803
776
|
parameters.vertexTangents && parameters.flatShading === false ? '#define USE_TANGENT' : '',
|
|
804
|
-
parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '',
|
|
777
|
+
parameters.vertexColors || parameters.instancingColor || parameters.batchingColor ? '#define USE_COLOR' : '',
|
|
805
778
|
parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
|
|
806
779
|
parameters.vertexUv1s ? '#define USE_UV1' : '',
|
|
807
780
|
parameters.vertexUv2s ? '#define USE_UV2' : '',
|
|
@@ -823,8 +796,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
823
796
|
|
|
824
797
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
825
798
|
|
|
826
|
-
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
827
|
-
|
|
828
799
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
829
800
|
|
|
830
801
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
@@ -194,6 +194,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
194
194
|
precision: precision,
|
|
195
195
|
|
|
196
196
|
batching: IS_BATCHEDMESH,
|
|
197
|
+
batchingColor: IS_BATCHEDMESH && object._colorsTexture !== null,
|
|
197
198
|
instancing: IS_INSTANCEDMESH,
|
|
198
199
|
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
|
|
199
200
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
@@ -339,7 +340,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
339
340
|
shadowMapType: renderer.shadowMap.type,
|
|
340
341
|
|
|
341
342
|
toneMapping: toneMapping,
|
|
342
|
-
useLegacyLights: renderer._useLegacyLights,
|
|
343
343
|
|
|
344
344
|
decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
|
|
345
345
|
|
|
@@ -513,6 +513,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
513
513
|
_programLayers.enable( 19 );
|
|
514
514
|
if ( parameters.dispersion )
|
|
515
515
|
_programLayers.enable( 20 );
|
|
516
|
+
if ( parameters.batchingColor )
|
|
517
|
+
_programLayers.enable( 21 );
|
|
516
518
|
|
|
517
519
|
array.push( _programLayers.mask );
|
|
518
520
|
_programLayers.disableAll();
|
|
@@ -537,30 +539,28 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
537
539
|
_programLayers.enable( 8 );
|
|
538
540
|
if ( parameters.shadowMapEnabled )
|
|
539
541
|
_programLayers.enable( 9 );
|
|
540
|
-
if ( parameters.useLegacyLights )
|
|
541
|
-
_programLayers.enable( 10 );
|
|
542
542
|
if ( parameters.doubleSided )
|
|
543
|
-
_programLayers.enable(
|
|
543
|
+
_programLayers.enable( 10 );
|
|
544
544
|
if ( parameters.flipSided )
|
|
545
|
-
_programLayers.enable(
|
|
545
|
+
_programLayers.enable( 11 );
|
|
546
546
|
if ( parameters.useDepthPacking )
|
|
547
|
-
_programLayers.enable(
|
|
547
|
+
_programLayers.enable( 12 );
|
|
548
548
|
if ( parameters.dithering )
|
|
549
|
-
_programLayers.enable(
|
|
549
|
+
_programLayers.enable( 13 );
|
|
550
550
|
if ( parameters.transmission )
|
|
551
|
-
_programLayers.enable(
|
|
551
|
+
_programLayers.enable( 14 );
|
|
552
552
|
if ( parameters.sheen )
|
|
553
|
-
_programLayers.enable(
|
|
553
|
+
_programLayers.enable( 15 );
|
|
554
554
|
if ( parameters.opaque )
|
|
555
|
-
_programLayers.enable(
|
|
555
|
+
_programLayers.enable( 16 );
|
|
556
556
|
if ( parameters.pointsUvs )
|
|
557
|
-
_programLayers.enable(
|
|
557
|
+
_programLayers.enable( 17 );
|
|
558
558
|
if ( parameters.decodeVideoTexture )
|
|
559
|
-
_programLayers.enable(
|
|
559
|
+
_programLayers.enable( 18 );
|
|
560
560
|
if ( parameters.alphaToCoverage )
|
|
561
|
-
_programLayers.enable(
|
|
561
|
+
_programLayers.enable( 19 );
|
|
562
562
|
if ( parameters.numMultiviewViews )
|
|
563
|
-
_programLayers.enable(
|
|
563
|
+
_programLayers.enable( 20 );
|
|
564
564
|
|
|
565
565
|
array.push( _programLayers.mask );
|
|
566
566
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedIntType,
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedIntType, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer, UnsignedShortType, UnsignedInt248Type } from '../../constants.js';
|
|
2
2
|
import { createElementNS } from '../../utils.js';
|
|
3
3
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
4
4
|
import { Vector2 } from '../../math/Vector2.js';
|
|
@@ -200,6 +200,48 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
200
200
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
function getInternalDepthFormat( useStencil, depthType ) {
|
|
204
|
+
|
|
205
|
+
let glInternalFormat;
|
|
206
|
+
if ( useStencil ) {
|
|
207
|
+
|
|
208
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
209
|
+
|
|
210
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
211
|
+
|
|
212
|
+
} else if ( depthType === FloatType ) {
|
|
213
|
+
|
|
214
|
+
glInternalFormat = _gl.DEPTH32F_STENCIL8;
|
|
215
|
+
|
|
216
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
217
|
+
|
|
218
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
219
|
+
console.warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
} else {
|
|
224
|
+
|
|
225
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
226
|
+
|
|
227
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
228
|
+
|
|
229
|
+
} else if ( depthType === FloatType ) {
|
|
230
|
+
|
|
231
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
232
|
+
|
|
233
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
234
|
+
|
|
235
|
+
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return glInternalFormat;
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
|
|
203
245
|
function getMipLevels( texture, image ) {
|
|
204
246
|
|
|
205
247
|
if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
@@ -754,23 +796,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
754
796
|
|
|
755
797
|
if ( texture.isDepthTexture ) {
|
|
756
798
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
760
|
-
|
|
761
|
-
if ( texture.type === FloatType ) {
|
|
762
|
-
|
|
763
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
764
|
-
|
|
765
|
-
} else if ( texture.type === UnsignedIntType ) {
|
|
766
|
-
|
|
767
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
768
|
-
|
|
769
|
-
} else if ( texture.type === UnsignedInt248Type ) {
|
|
770
|
-
|
|
771
|
-
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
772
|
-
|
|
773
|
-
}
|
|
799
|
+
glInternalFormat = getInternalDepthFormat( texture.format === DepthStencilFormat, texture.type );
|
|
774
800
|
|
|
775
801
|
//
|
|
776
802
|
|
|
@@ -870,7 +896,22 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
870
896
|
|
|
871
897
|
if ( dataReady ) {
|
|
872
898
|
|
|
873
|
-
|
|
899
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
900
|
+
|
|
901
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
902
|
+
|
|
903
|
+
const layerSize = mipmap.width * mipmap.height;
|
|
904
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, mipmap.data.slice( layerSize * layerIndex, layerSize * ( layerIndex + 1 ) ), 0, 0 );
|
|
905
|
+
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
texture.clearLayerUpdates();
|
|
909
|
+
|
|
910
|
+
} else {
|
|
911
|
+
|
|
912
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
|
|
913
|
+
|
|
914
|
+
}
|
|
874
915
|
|
|
875
916
|
}
|
|
876
917
|
|
|
@@ -976,7 +1017,72 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
976
1017
|
|
|
977
1018
|
if ( dataReady ) {
|
|
978
1019
|
|
|
979
|
-
|
|
1020
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
1021
|
+
|
|
1022
|
+
// When type is GL_UNSIGNED_BYTE, each of these bytes is
|
|
1023
|
+
// interpreted as one color component, depending on format. When
|
|
1024
|
+
// type is one of GL_UNSIGNED_SHORT_5_6_5,
|
|
1025
|
+
// GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, each
|
|
1026
|
+
// unsigned value is interpreted as containing all the components
|
|
1027
|
+
// for a single pixel, with the color components arranged
|
|
1028
|
+
// according to format.
|
|
1029
|
+
//
|
|
1030
|
+
// See https://registry.khronos.org/OpenGL-Refpages/es1.1/xhtml/glTexImage2D.xml
|
|
1031
|
+
let texelSize;
|
|
1032
|
+
switch ( glType ) {
|
|
1033
|
+
|
|
1034
|
+
case _gl.UNSIGNED_BYTE:
|
|
1035
|
+
switch ( glFormat ) {
|
|
1036
|
+
|
|
1037
|
+
case _gl.ALPHA:
|
|
1038
|
+
texelSize = 1;
|
|
1039
|
+
break;
|
|
1040
|
+
case _gl.LUMINANCE:
|
|
1041
|
+
texelSize = 1;
|
|
1042
|
+
break;
|
|
1043
|
+
case _gl.LUMINANCE_ALPHA:
|
|
1044
|
+
texelSize = 2;
|
|
1045
|
+
break;
|
|
1046
|
+
case _gl.RGB:
|
|
1047
|
+
texelSize = 3;
|
|
1048
|
+
break;
|
|
1049
|
+
case _gl.RGBA:
|
|
1050
|
+
texelSize = 4;
|
|
1051
|
+
break;
|
|
1052
|
+
|
|
1053
|
+
default:
|
|
1054
|
+
throw new Error( `Unknown texel size for format ${glFormat}.` );
|
|
1055
|
+
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
break;
|
|
1059
|
+
|
|
1060
|
+
case _gl.UNSIGNED_SHORT_4_4_4_4:
|
|
1061
|
+
case _gl.UNSIGNED_SHORT_5_5_5_1:
|
|
1062
|
+
case _gl.UNSIGNED_SHORT_5_6_5:
|
|
1063
|
+
texelSize = 1;
|
|
1064
|
+
break;
|
|
1065
|
+
|
|
1066
|
+
default:
|
|
1067
|
+
throw new Error( `Unknown texel size for type ${glType}.` );
|
|
1068
|
+
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
const layerSize = image.width * image.height * texelSize;
|
|
1072
|
+
|
|
1073
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
1074
|
+
|
|
1075
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, image.data.slice( layerSize * layerIndex, layerSize * ( layerIndex + 1 ) ) );
|
|
1076
|
+
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
texture.clearLayerUpdates();
|
|
1080
|
+
|
|
1081
|
+
} else {
|
|
1082
|
+
|
|
1083
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
1084
|
+
|
|
1085
|
+
}
|
|
980
1086
|
|
|
981
1087
|
}
|
|
982
1088
|
|
|
@@ -1420,7 +1526,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1420
1526
|
|
|
1421
1527
|
}
|
|
1422
1528
|
|
|
1423
|
-
|
|
1424
1529
|
// Setup storage for internal depth/stencil buffers and bind to correct framebuffer
|
|
1425
1530
|
function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
|
|
1426
1531
|
|
|
@@ -1480,66 +1585,30 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1480
1585
|
|
|
1481
1586
|
} else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
1482
1587
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
1490
|
-
|
|
1491
|
-
if ( depthTexture.type === FloatType ) {
|
|
1492
|
-
|
|
1493
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
1494
|
-
|
|
1495
|
-
} else if ( depthTexture.type === UnsignedIntType ) {
|
|
1496
|
-
|
|
1497
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
1498
|
-
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1502
|
-
|
|
1503
|
-
const samples = getRenderTargetSamples( renderTarget );
|
|
1504
|
-
|
|
1505
|
-
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1506
|
-
|
|
1507
|
-
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1508
|
-
|
|
1509
|
-
} else {
|
|
1510
|
-
|
|
1511
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1512
|
-
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
} else {
|
|
1516
|
-
|
|
1517
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1518
|
-
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
1522
|
-
|
|
1523
|
-
} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {
|
|
1588
|
+
// retrieve the depth attachment types
|
|
1589
|
+
const depthTexture = renderTarget.depthTexture;
|
|
1590
|
+
const depthType = depthTexture && depthTexture.isDepthTexture ? depthTexture.type : null;
|
|
1591
|
+
const glInternalFormat = getInternalDepthFormat( renderTarget.stencilBuffer, depthType );
|
|
1592
|
+
const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1524
1593
|
|
|
1594
|
+
// set up the attachment
|
|
1525
1595
|
const samples = getRenderTargetSamples( renderTarget );
|
|
1596
|
+
const isUseMultisampledRTT = useMultisampledRTT( renderTarget );
|
|
1597
|
+
if ( isUseMultisampledRTT ) {
|
|
1526
1598
|
|
|
1527
|
-
|
|
1599
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1528
1600
|
|
|
1529
|
-
|
|
1601
|
+
} else if ( isMultisample ) {
|
|
1530
1602
|
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );
|
|
1603
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1534
1604
|
|
|
1535
1605
|
} else {
|
|
1536
1606
|
|
|
1537
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER,
|
|
1607
|
+
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1538
1608
|
|
|
1539
1609
|
}
|
|
1540
1610
|
|
|
1541
|
-
|
|
1542
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
1611
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
|
|
1543
1612
|
|
|
1544
1613
|
} else {
|
|
1545
1614
|
|
|
@@ -65,7 +65,7 @@ class WebXRDepthSensing {
|
|
|
65
65
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
getMesh( cameraXR ) {
|
|
69
69
|
|
|
70
70
|
if ( this.texture !== null ) {
|
|
71
71
|
|
|
@@ -86,10 +86,10 @@ class WebXRDepthSensing {
|
|
|
86
86
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
renderer.render( this.mesh, cameraXR );
|
|
90
|
-
|
|
91
89
|
}
|
|
92
90
|
|
|
91
|
+
return this.mesh;
|
|
92
|
+
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
reset() {
|
|
@@ -725,6 +725,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
725
725
|
|
|
726
726
|
};
|
|
727
727
|
|
|
728
|
+
this.getDepthSensingMesh = function () {
|
|
729
|
+
|
|
730
|
+
return depthSensing.getMesh( cameraXR );
|
|
731
|
+
|
|
732
|
+
};
|
|
733
|
+
|
|
728
734
|
// Animation Loop
|
|
729
735
|
|
|
730
736
|
let onAnimationFrameCallback = null;
|
|
@@ -850,8 +856,6 @@ class WebXRManager extends EventDispatcher {
|
|
|
850
856
|
|
|
851
857
|
}
|
|
852
858
|
|
|
853
|
-
depthSensing.render( renderer, cameraXR );
|
|
854
|
-
|
|
855
859
|
if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
|
|
856
860
|
|
|
857
861
|
if ( frame.detectedPlanes ) {
|