super-three 0.160.1 → 0.161.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/LICENSE +1 -1
- package/build/three.cjs +379 -108
- package/build/three.module.js +380 -108
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +5 -1
- package/examples/jsm/capabilities/WebGPU.js +13 -9
- package/examples/jsm/controls/OrbitControls.js +102 -13
- package/examples/jsm/curves/NURBSUtils.js +59 -4
- package/examples/jsm/curves/NURBSVolume.js +62 -0
- package/examples/jsm/exporters/USDZExporter.js +8 -7
- package/examples/jsm/helpers/TextureHelper.js +3 -3
- package/examples/jsm/loaders/3DMLoader.js +44 -43
- package/examples/jsm/loaders/DDSLoader.js +1 -0
- package/examples/jsm/loaders/KTX2Loader.js +20 -5
- package/examples/jsm/loaders/LUT3dlLoader.js +78 -46
- package/examples/jsm/loaders/LUTCubeLoader.js +81 -67
- package/examples/jsm/loaders/LUTImageLoader.js +3 -2
- package/examples/jsm/loaders/MaterialXLoader.js +115 -16
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
- package/examples/jsm/misc/Timer.js +13 -4
- package/examples/jsm/nodes/Nodes.js +16 -5
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +5 -3
- package/examples/jsm/nodes/accessors/CameraNode.js +9 -4
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +12 -1
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +27 -0
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +56 -3
- package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +23 -18
- package/examples/jsm/nodes/core/NodeFrame.js +16 -8
- package/examples/jsm/nodes/core/constants.js +1 -0
- package/examples/jsm/nodes/display/AfterImageNode.js +148 -0
- package/examples/jsm/nodes/display/AnamorphicNode.js +148 -0
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +3 -0
- package/examples/jsm/nodes/display/GaussianBlurNode.js +33 -13
- package/examples/jsm/nodes/display/PassNode.js +3 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +46 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -4
- package/examples/jsm/nodes/display/ViewportNode.js +0 -2
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +4 -4
- package/examples/jsm/nodes/fog/FogNode.js +2 -1
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +13 -5
- package/examples/jsm/nodes/lighting/LightingContextNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +1 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +18 -30
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +6 -4
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +1 -7
- package/examples/jsm/nodes/math/MathNode.js +12 -2
- package/examples/jsm/nodes/math/MathUtils.js +15 -0
- package/examples/jsm/nodes/math/OperatorNode.js +13 -5
- package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +10 -1
- package/examples/jsm/nodes/utils/ArrayElementNode.js +6 -0
- package/examples/jsm/nodes/utils/JoinNode.js +2 -2
- package/examples/jsm/nodes/utils/LoopNode.js +3 -3
- package/examples/jsm/nodes/utils/ReflectorNode.js +227 -0
- package/examples/jsm/nodes/utils/RotateNode.js +68 -0
- package/examples/jsm/nodes/utils/RotateUVNode.js +1 -9
- package/examples/jsm/nodes/utils/SplitNode.js +4 -4
- package/examples/jsm/objects/GroundedSkybox.js +50 -0
- package/examples/jsm/objects/QuadMesh.js +8 -2
- package/examples/jsm/objects/Water2.js +8 -8
- package/examples/jsm/postprocessing/GTAOPass.js +11 -1
- package/examples/jsm/renderers/common/Backend.js +14 -0
- package/examples/jsm/renderers/common/Bindings.js +1 -1
- package/examples/jsm/renderers/common/DataMap.js +1 -1
- package/examples/jsm/renderers/common/Info.js +25 -1
- package/examples/jsm/renderers/common/Pipelines.js +8 -8
- package/examples/jsm/renderers/common/PostProcessing.js +2 -2
- package/examples/jsm/renderers/common/ProgrammableStage.js +3 -1
- package/examples/jsm/renderers/common/RenderObject.js +2 -0
- package/examples/jsm/renderers/common/Renderer.js +238 -22
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +25 -5
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +2 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +4 -2
- package/examples/jsm/renderers/webgl/WebGLBackend.js +631 -270
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +37 -30
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +89 -8
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +197 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +377 -11
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +2 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -21
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +289 -102
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +7 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +56 -39
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +9 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +38 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +85 -12
- package/examples/jsm/transpiler/AST.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +23 -27
- package/examples/jsm/utils/SortUtils.js +2 -0
- package/examples/jsm/webxr/ARButton.js +12 -2
- package/examples/jsm/webxr/VRButton.js +12 -2
- package/examples/jsm/webxr/XRButton.js +12 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +3 -1
- package/package.json +2 -2
- package/src/audio/Audio.js +1 -3
- package/src/cameras/PerspectiveCamera.js +35 -0
- package/src/constants.js +1 -2
- package/src/core/BufferAttribute.js +2 -1
- package/src/core/InterleavedBuffer.js +2 -1
- package/src/core/InterleavedBufferAttribute.js +20 -0
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/Triangle.js +0 -30
- package/src/objects/BatchedMesh.js +6 -7
- package/src/objects/SkinnedMesh.js +0 -8
- package/src/renderers/WebGLRenderer.js +5 -1
- package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +56 -11
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +15 -7
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -1
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +1 -1
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +30 -3
- package/src/renderers/webgl/WebGLPrograms.js +19 -11
- package/src/renderers/webgl/WebGLTextures.js +90 -16
- package/src/renderers/webxr/WebXRDepthSensing.js +105 -0
- package/src/renderers/webxr/WebXRManager.js +46 -0
- package/src/textures/Source.js +1 -0
- package/build/three.js +0 -54519
- package/build/three.min.js +0 -7
- package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
|
@@ -141,7 +141,7 @@ function getToneMappingFunction( functionName, toneMapping ) {
|
|
|
141
141
|
function generateExtensions( parameters ) {
|
|
142
142
|
|
|
143
143
|
const chunks = [
|
|
144
|
-
( parameters.extensionDerivatives || !! parameters.envMapCubeUVHeight || parameters.bumpMap || parameters.normalMapTangentSpace || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',
|
|
144
|
+
( parameters.extensionDerivatives || !! parameters.envMapCubeUVHeight || parameters.bumpMap || parameters.normalMapTangentSpace || parameters.clearcoatNormalMap || parameters.flatShading || parameters.alphaToCoverage || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',
|
|
145
145
|
( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',
|
|
146
146
|
( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '',
|
|
147
147
|
( parameters.extensionShaderTextureLOD || parameters.envMap || parameters.transmission ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''
|
|
@@ -154,7 +154,8 @@ function generateExtensions( parameters ) {
|
|
|
154
154
|
function generateVertexExtensions( parameters ) {
|
|
155
155
|
|
|
156
156
|
const chunks = [
|
|
157
|
-
parameters.extensionClipCullDistance ? '#extension GL_ANGLE_clip_cull_distance : require' : ''
|
|
157
|
+
parameters.extensionClipCullDistance ? '#extension GL_ANGLE_clip_cull_distance : require' : '',
|
|
158
|
+
parameters.extensionMultiDraw ? '#extension GL_ANGLE_multi_draw : require' : '',
|
|
158
159
|
];
|
|
159
160
|
|
|
160
161
|
return chunks.filter( filterEmptyLine ).join( '\n' );
|
|
@@ -313,7 +314,30 @@ function loopReplacer( match, start, end, snippet ) {
|
|
|
313
314
|
|
|
314
315
|
function generatePrecision( parameters ) {
|
|
315
316
|
|
|
316
|
-
let precisionstring =
|
|
317
|
+
let precisionstring = `precision ${parameters.precision} float;
|
|
318
|
+
precision ${parameters.precision} int;
|
|
319
|
+
precision ${parameters.precision} sampler2D;
|
|
320
|
+
precision ${parameters.precision} samplerCube;
|
|
321
|
+
`;
|
|
322
|
+
|
|
323
|
+
if ( parameters.isWebGL2 ) {
|
|
324
|
+
|
|
325
|
+
precisionstring += `precision ${parameters.precision} sampler3D;
|
|
326
|
+
precision ${parameters.precision} sampler2DArray;
|
|
327
|
+
precision ${parameters.precision} sampler2DShadow;
|
|
328
|
+
precision ${parameters.precision} samplerCubeShadow;
|
|
329
|
+
precision ${parameters.precision} sampler2DArrayShadow;
|
|
330
|
+
precision ${parameters.precision} isampler2D;
|
|
331
|
+
precision ${parameters.precision} isampler3D;
|
|
332
|
+
precision ${parameters.precision} isamplerCube;
|
|
333
|
+
precision ${parameters.precision} isampler2DArray;
|
|
334
|
+
precision ${parameters.precision} usampler2D;
|
|
335
|
+
precision ${parameters.precision} usampler3D;
|
|
336
|
+
precision ${parameters.precision} usamplerCube;
|
|
337
|
+
precision ${parameters.precision} usampler2DArray;
|
|
338
|
+
`;
|
|
339
|
+
|
|
340
|
+
}
|
|
317
341
|
|
|
318
342
|
if ( parameters.precision === 'highp' ) {
|
|
319
343
|
|
|
@@ -744,6 +768,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
744
768
|
parameters.useFog && parameters.fog ? '#define USE_FOG' : '',
|
|
745
769
|
parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '',
|
|
746
770
|
|
|
771
|
+
parameters.alphaToCoverage ? '#define ALPHA_TO_COVERAGE' : '',
|
|
747
772
|
parameters.map ? '#define USE_MAP' : '',
|
|
748
773
|
parameters.matcap ? '#define USE_MATCAP' : '',
|
|
749
774
|
parameters.envMap ? '#define USE_ENVMAP' : '',
|
|
@@ -992,6 +1017,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
992
1017
|
console.error(
|
|
993
1018
|
'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' +
|
|
994
1019
|
'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
|
|
1020
|
+
'Material Name: ' + self.name + '\n' +
|
|
1021
|
+
'Material Type: ' + self.type + '\n\n' +
|
|
995
1022
|
'Program Info Log: ' + programLog + '\n' +
|
|
996
1023
|
vertexErrors + '\n' +
|
|
997
1024
|
fragmentErrors
|
|
@@ -10,6 +10,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
10
10
|
|
|
11
11
|
const _programLayers = new Layers();
|
|
12
12
|
const _customShaders = new WebGLShaderCache();
|
|
13
|
+
const _activeChannels = new Set();
|
|
13
14
|
const programs = [];
|
|
14
15
|
|
|
15
16
|
const IS_WEBGL2 = capabilities.isWebGL2;
|
|
@@ -38,6 +39,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
38
39
|
|
|
39
40
|
function getChannel( value ) {
|
|
40
41
|
|
|
42
|
+
_activeChannels.add( value );
|
|
43
|
+
|
|
41
44
|
if ( value === 0 ) return 'uv';
|
|
42
45
|
|
|
43
46
|
return `uv${ value }`;
|
|
@@ -160,10 +163,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
160
163
|
|
|
161
164
|
const HAS_EXTENSIONS = !! material.extensions;
|
|
162
165
|
|
|
163
|
-
const HAS_ATTRIBUTE_UV1 = !! geometry.attributes.uv1;
|
|
164
|
-
const HAS_ATTRIBUTE_UV2 = !! geometry.attributes.uv2;
|
|
165
|
-
const HAS_ATTRIBUTE_UV3 = !! geometry.attributes.uv3;
|
|
166
|
-
|
|
167
166
|
let toneMapping = NoToneMapping;
|
|
168
167
|
|
|
169
168
|
if ( material.toneMapped ) {
|
|
@@ -203,6 +202,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
203
202
|
supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
|
|
204
203
|
numMultiviewViews: numMultiviewViews,
|
|
205
204
|
outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
|
|
205
|
+
alphaToCoverage: !! material.alphaToCoverage,
|
|
206
206
|
|
|
207
207
|
map: HAS_MAP,
|
|
208
208
|
matcap: HAS_MATCAP,
|
|
@@ -248,7 +248,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
248
248
|
|
|
249
249
|
gradientMap: HAS_GRADIENTMAP,
|
|
250
250
|
|
|
251
|
-
opaque: material.transparent === false && material.blending === NormalBlending,
|
|
251
|
+
opaque: material.transparent === false && material.blending === NormalBlending && material.alphaToCoverage === false,
|
|
252
252
|
|
|
253
253
|
alphaMap: HAS_ALPHAMAP,
|
|
254
254
|
alphaTest: HAS_ALPHATEST,
|
|
@@ -295,15 +295,12 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
295
295
|
vertexTangents: !! geometry.attributes.tangent && ( HAS_NORMALMAP || HAS_ANISOTROPY ),
|
|
296
296
|
vertexColors: material.vertexColors,
|
|
297
297
|
vertexAlphas: material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4,
|
|
298
|
-
vertexUv1s: HAS_ATTRIBUTE_UV1,
|
|
299
|
-
vertexUv2s: HAS_ATTRIBUTE_UV2,
|
|
300
|
-
vertexUv3s: HAS_ATTRIBUTE_UV3,
|
|
301
298
|
|
|
302
299
|
pointsUvs: object.isPoints === true && !! geometry.attributes.uv && ( HAS_MAP || HAS_ALPHAMAP ),
|
|
303
300
|
|
|
304
301
|
fog: !! fog,
|
|
305
302
|
useFog: material.fog === true,
|
|
306
|
-
fogExp2: ( fog && fog.isFogExp2 ),
|
|
303
|
+
fogExp2: ( !! fog && fog.isFogExp2 ),
|
|
307
304
|
|
|
308
305
|
flatShading: material.flatShading === true,
|
|
309
306
|
|
|
@@ -359,7 +356,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
359
356
|
extensionFragDepth: HAS_EXTENSIONS && material.extensions.fragDepth === true,
|
|
360
357
|
extensionDrawBuffers: HAS_EXTENSIONS && material.extensions.drawBuffers === true,
|
|
361
358
|
extensionShaderTextureLOD: HAS_EXTENSIONS && material.extensions.shaderTextureLOD === true,
|
|
362
|
-
extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance && extensions.has( 'WEBGL_clip_cull_distance' ),
|
|
359
|
+
extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance === true && extensions.has( 'WEBGL_clip_cull_distance' ),
|
|
360
|
+
extensionMultiDraw: HAS_EXTENSIONS && material.extensions.multiDraw === true && extensions.has( 'WEBGL_multi_draw' ),
|
|
363
361
|
|
|
364
362
|
rendererExtensionFragDepth: IS_WEBGL2 || extensions.has( 'EXT_frag_depth' ),
|
|
365
363
|
rendererExtensionDrawBuffers: IS_WEBGL2 || extensions.has( 'WEBGL_draw_buffers' ),
|
|
@@ -370,6 +368,14 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
370
368
|
|
|
371
369
|
};
|
|
372
370
|
|
|
371
|
+
// the usage of getChannel() determines the active texture channels for this shader
|
|
372
|
+
|
|
373
|
+
parameters.vertexUv1s = _activeChannels.has( 1 );
|
|
374
|
+
parameters.vertexUv2s = _activeChannels.has( 2 );
|
|
375
|
+
parameters.vertexUv3s = _activeChannels.has( 3 );
|
|
376
|
+
|
|
377
|
+
_activeChannels.clear();
|
|
378
|
+
|
|
373
379
|
return parameters;
|
|
374
380
|
|
|
375
381
|
}
|
|
@@ -555,8 +561,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
555
561
|
_programLayers.enable( 18 );
|
|
556
562
|
if ( parameters.decodeVideoTexture )
|
|
557
563
|
_programLayers.enable( 19 );
|
|
558
|
-
if ( parameters.
|
|
564
|
+
if ( parameters.alphaToCoverage )
|
|
559
565
|
_programLayers.enable( 20 );
|
|
566
|
+
if ( parameters.numMultiviewViews )
|
|
567
|
+
_programLayers.enable( 21 );
|
|
560
568
|
|
|
561
569
|
array.push( _programLayers.mask );
|
|
562
570
|
|
|
@@ -574,6 +574,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
574
574
|
|
|
575
575
|
function setTextureParameters( textureType, texture, supportsMips ) {
|
|
576
576
|
|
|
577
|
+
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
|
|
578
|
+
( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
|
|
579
|
+
texture.minFilter === LinearFilter || texture.minFilter === LinearMipmapNearestFilter || texture.minFilter === NearestMipmapLinearFilter || texture.minFilter === LinearMipmapLinearFilter ) ) {
|
|
580
|
+
|
|
581
|
+
console.warn( 'THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.' );
|
|
582
|
+
|
|
583
|
+
}
|
|
584
|
+
|
|
577
585
|
if ( supportsMips ) {
|
|
578
586
|
|
|
579
587
|
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
@@ -804,6 +812,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
804
812
|
|
|
805
813
|
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
|
|
806
814
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
815
|
+
const dataReady = source.dataReady;
|
|
807
816
|
const levels = getMipLevels( texture, image, supportsMips );
|
|
808
817
|
|
|
809
818
|
if ( texture.isDepthTexture ) {
|
|
@@ -916,7 +925,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
916
925
|
|
|
917
926
|
if ( useTexStorage ) {
|
|
918
927
|
|
|
919
|
-
|
|
928
|
+
if ( dataReady ) {
|
|
929
|
+
|
|
930
|
+
state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
931
|
+
|
|
932
|
+
}
|
|
920
933
|
|
|
921
934
|
} else {
|
|
922
935
|
|
|
@@ -938,7 +951,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
938
951
|
|
|
939
952
|
}
|
|
940
953
|
|
|
941
|
-
|
|
954
|
+
if ( dataReady ) {
|
|
955
|
+
|
|
956
|
+
state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
|
|
957
|
+
|
|
958
|
+
}
|
|
942
959
|
|
|
943
960
|
} else {
|
|
944
961
|
|
|
@@ -968,7 +985,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
968
985
|
|
|
969
986
|
if ( useTexStorage ) {
|
|
970
987
|
|
|
971
|
-
|
|
988
|
+
if ( dataReady ) {
|
|
989
|
+
|
|
990
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
|
|
991
|
+
|
|
992
|
+
}
|
|
972
993
|
|
|
973
994
|
} else {
|
|
974
995
|
|
|
@@ -986,7 +1007,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
986
1007
|
|
|
987
1008
|
if ( useTexStorage ) {
|
|
988
1009
|
|
|
989
|
-
|
|
1010
|
+
if ( dataReady ) {
|
|
1011
|
+
|
|
1012
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, glType, mipmap.data );
|
|
1013
|
+
|
|
1014
|
+
}
|
|
990
1015
|
|
|
991
1016
|
} else {
|
|
992
1017
|
|
|
@@ -1016,7 +1041,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1016
1041
|
|
|
1017
1042
|
if ( useTexStorage ) {
|
|
1018
1043
|
|
|
1019
|
-
|
|
1044
|
+
if ( dataReady ) {
|
|
1045
|
+
|
|
1046
|
+
state.compressedTexSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
|
|
1047
|
+
|
|
1048
|
+
}
|
|
1020
1049
|
|
|
1021
1050
|
} else {
|
|
1022
1051
|
|
|
@@ -1034,7 +1063,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1034
1063
|
|
|
1035
1064
|
if ( useTexStorage ) {
|
|
1036
1065
|
|
|
1037
|
-
|
|
1066
|
+
if ( dataReady ) {
|
|
1067
|
+
|
|
1068
|
+
state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
1069
|
+
|
|
1070
|
+
}
|
|
1038
1071
|
|
|
1039
1072
|
} else {
|
|
1040
1073
|
|
|
@@ -1058,7 +1091,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1058
1091
|
|
|
1059
1092
|
}
|
|
1060
1093
|
|
|
1061
|
-
|
|
1094
|
+
if ( dataReady ) {
|
|
1095
|
+
|
|
1096
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
1097
|
+
|
|
1098
|
+
}
|
|
1062
1099
|
|
|
1063
1100
|
} else {
|
|
1064
1101
|
|
|
@@ -1076,7 +1113,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1076
1113
|
|
|
1077
1114
|
}
|
|
1078
1115
|
|
|
1079
|
-
|
|
1116
|
+
if ( dataReady ) {
|
|
1117
|
+
|
|
1118
|
+
state.texSubImage3D( _gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
1119
|
+
|
|
1120
|
+
}
|
|
1080
1121
|
|
|
1081
1122
|
} else {
|
|
1082
1123
|
|
|
@@ -1131,7 +1172,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1131
1172
|
|
|
1132
1173
|
if ( useTexStorage ) {
|
|
1133
1174
|
|
|
1134
|
-
|
|
1175
|
+
if ( dataReady ) {
|
|
1176
|
+
|
|
1177
|
+
state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, glFormat, glType, mipmap );
|
|
1178
|
+
|
|
1179
|
+
}
|
|
1135
1180
|
|
|
1136
1181
|
} else {
|
|
1137
1182
|
|
|
@@ -1153,7 +1198,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1153
1198
|
|
|
1154
1199
|
}
|
|
1155
1200
|
|
|
1156
|
-
|
|
1201
|
+
if ( dataReady ) {
|
|
1202
|
+
|
|
1203
|
+
state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, glFormat, glType, image );
|
|
1204
|
+
|
|
1205
|
+
}
|
|
1157
1206
|
|
|
1158
1207
|
} else {
|
|
1159
1208
|
|
|
@@ -1235,6 +1284,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1235
1284
|
|
|
1236
1285
|
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
|
|
1237
1286
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
1287
|
+
const dataReady = source.dataReady;
|
|
1238
1288
|
let levels = getMipLevels( texture, image, supportsMips );
|
|
1239
1289
|
|
|
1240
1290
|
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
|
|
@@ -1263,7 +1313,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1263
1313
|
|
|
1264
1314
|
if ( useTexStorage ) {
|
|
1265
1315
|
|
|
1266
|
-
|
|
1316
|
+
if ( dataReady ) {
|
|
1317
|
+
|
|
1318
|
+
state.compressedTexSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
|
|
1319
|
+
|
|
1320
|
+
}
|
|
1267
1321
|
|
|
1268
1322
|
} else {
|
|
1269
1323
|
|
|
@@ -1281,7 +1335,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1281
1335
|
|
|
1282
1336
|
if ( useTexStorage ) {
|
|
1283
1337
|
|
|
1284
|
-
|
|
1338
|
+
if ( dataReady ) {
|
|
1339
|
+
|
|
1340
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
1341
|
+
|
|
1342
|
+
}
|
|
1285
1343
|
|
|
1286
1344
|
} else {
|
|
1287
1345
|
|
|
@@ -1317,7 +1375,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1317
1375
|
|
|
1318
1376
|
if ( useTexStorage ) {
|
|
1319
1377
|
|
|
1320
|
-
|
|
1378
|
+
if ( dataReady ) {
|
|
1379
|
+
|
|
1380
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, cubeImage[ i ].width, cubeImage[ i ].height, glFormat, glType, cubeImage[ i ].data );
|
|
1381
|
+
|
|
1382
|
+
}
|
|
1321
1383
|
|
|
1322
1384
|
} else {
|
|
1323
1385
|
|
|
@@ -1332,7 +1394,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1332
1394
|
|
|
1333
1395
|
if ( useTexStorage ) {
|
|
1334
1396
|
|
|
1335
|
-
|
|
1397
|
+
if ( dataReady ) {
|
|
1398
|
+
|
|
1399
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data );
|
|
1400
|
+
|
|
1401
|
+
}
|
|
1336
1402
|
|
|
1337
1403
|
} else {
|
|
1338
1404
|
|
|
@@ -1346,7 +1412,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1346
1412
|
|
|
1347
1413
|
if ( useTexStorage ) {
|
|
1348
1414
|
|
|
1349
|
-
|
|
1415
|
+
if ( dataReady ) {
|
|
1416
|
+
|
|
1417
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[ i ] );
|
|
1418
|
+
|
|
1419
|
+
}
|
|
1350
1420
|
|
|
1351
1421
|
} else {
|
|
1352
1422
|
|
|
@@ -1360,7 +1430,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1360
1430
|
|
|
1361
1431
|
if ( useTexStorage ) {
|
|
1362
1432
|
|
|
1363
|
-
|
|
1433
|
+
if ( dataReady ) {
|
|
1434
|
+
|
|
1435
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[ i ] );
|
|
1436
|
+
|
|
1437
|
+
}
|
|
1364
1438
|
|
|
1365
1439
|
} else {
|
|
1366
1440
|
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
|
|
2
|
+
import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
|
|
3
|
+
import { Mesh } from '../../objects/Mesh.js';
|
|
4
|
+
import { Texture } from '../../textures/Texture.js';
|
|
5
|
+
|
|
6
|
+
const _occlusion_vertex = `
|
|
7
|
+
void main() {
|
|
8
|
+
|
|
9
|
+
gl_Position = vec4( position, 1.0 );
|
|
10
|
+
|
|
11
|
+
}`;
|
|
12
|
+
|
|
13
|
+
const _occlusion_fragment = `
|
|
14
|
+
uniform sampler2DArray depthColor;
|
|
15
|
+
uniform float depthWidth;
|
|
16
|
+
uniform float depthHeight;
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
|
|
20
|
+
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
|
|
21
|
+
|
|
22
|
+
if ( coord.x >= 1.0 ) {
|
|
23
|
+
|
|
24
|
+
gl_FragDepthEXT = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
|
25
|
+
|
|
26
|
+
} else {
|
|
27
|
+
|
|
28
|
+
gl_FragDepthEXT = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}`;
|
|
33
|
+
|
|
34
|
+
class WebXRDepthSensing {
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
|
|
38
|
+
this.texture = null;
|
|
39
|
+
this.mesh = null;
|
|
40
|
+
|
|
41
|
+
this.depthNear = 0;
|
|
42
|
+
this.depthFar = 0;
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
init( renderer, depthData, renderState ) {
|
|
47
|
+
|
|
48
|
+
if ( this.texture === null ) {
|
|
49
|
+
|
|
50
|
+
const texture = new Texture();
|
|
51
|
+
|
|
52
|
+
const texProps = renderer.properties.get( texture );
|
|
53
|
+
texProps.__webglTexture = depthData.texture;
|
|
54
|
+
|
|
55
|
+
if ( ( depthData.depthNear != renderState.depthNear ) || ( depthData.depthFar != renderState.depthFar ) ) {
|
|
56
|
+
|
|
57
|
+
this.depthNear = depthData.depthNear;
|
|
58
|
+
this.depthFar = depthData.depthFar;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.texture = texture;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
render( renderer, cameraXR ) {
|
|
69
|
+
|
|
70
|
+
if ( this.texture !== null ) {
|
|
71
|
+
|
|
72
|
+
if ( this.mesh === null ) {
|
|
73
|
+
|
|
74
|
+
const viewport = cameraXR.cameras[ 0 ].viewport;
|
|
75
|
+
const material = new ShaderMaterial( {
|
|
76
|
+
extensions: { fragDepth: true },
|
|
77
|
+
vertexShader: _occlusion_vertex,
|
|
78
|
+
fragmentShader: _occlusion_fragment,
|
|
79
|
+
uniforms: {
|
|
80
|
+
depthColor: { value: this.texture },
|
|
81
|
+
depthWidth: { value: viewport.z },
|
|
82
|
+
depthHeight: { value: viewport.w }
|
|
83
|
+
}
|
|
84
|
+
} );
|
|
85
|
+
|
|
86
|
+
this.mesh = new Mesh( new PlaneGeometry( 20, 20 ), material );
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
renderer.render( this.mesh, cameraXR );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
reset() {
|
|
97
|
+
|
|
98
|
+
this.texture = null;
|
|
99
|
+
this.mesh = null;
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { WebXRDepthSensing };
|
|
@@ -11,6 +11,7 @@ import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
|
|
|
11
11
|
import { WebXRController } from './WebXRController.js';
|
|
12
12
|
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
13
13
|
import { DepthFormat, DepthStencilFormat, RGBAFormat, UnsignedByteType, UnsignedIntType, UnsignedInt248Type } from '../../constants.js';
|
|
14
|
+
import { WebXRDepthSensing } from './WebXRDepthSensing.js';
|
|
14
15
|
|
|
15
16
|
class WebXRManager extends EventDispatcher {
|
|
16
17
|
|
|
@@ -38,7 +39,10 @@ class WebXRManager extends EventDispatcher {
|
|
|
38
39
|
let glProjLayer = null;
|
|
39
40
|
let glBaseLayer = null;
|
|
40
41
|
let xrFrame = null;
|
|
42
|
+
|
|
43
|
+
const depthSensing = new WebXRDepthSensing();
|
|
41
44
|
const attributes = gl.getContextAttributes();
|
|
45
|
+
|
|
42
46
|
let initialRenderTarget = null;
|
|
43
47
|
let newRenderTarget = null;
|
|
44
48
|
|
|
@@ -175,6 +179,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
175
179
|
_currentDepthNear = null;
|
|
176
180
|
_currentDepthFar = null;
|
|
177
181
|
|
|
182
|
+
depthSensing.reset();
|
|
183
|
+
|
|
178
184
|
// restore framebuffer/rendering state
|
|
179
185
|
|
|
180
186
|
renderer.setRenderTarget( initialRenderTarget );
|
|
@@ -582,6 +588,13 @@ class WebXRManager extends EventDispatcher {
|
|
|
582
588
|
|
|
583
589
|
if ( session === null ) return;
|
|
584
590
|
|
|
591
|
+
if ( depthSensing.texture !== null ) {
|
|
592
|
+
|
|
593
|
+
camera.near = depthSensing.depthNear;
|
|
594
|
+
camera.far = depthSensing.depthFar;
|
|
595
|
+
|
|
596
|
+
}
|
|
597
|
+
|
|
585
598
|
cameraXR.near = cameraR.near = cameraL.near = camera.near;
|
|
586
599
|
cameraXR.far = cameraR.far = cameraL.far = camera.far;
|
|
587
600
|
|
|
@@ -597,6 +610,15 @@ class WebXRManager extends EventDispatcher {
|
|
|
597
610
|
_currentDepthNear = cameraXR.near;
|
|
598
611
|
_currentDepthFar = cameraXR.far;
|
|
599
612
|
|
|
613
|
+
cameraL.near = _currentDepthNear;
|
|
614
|
+
cameraL.far = _currentDepthFar;
|
|
615
|
+
cameraR.near = _currentDepthNear;
|
|
616
|
+
cameraR.far = _currentDepthFar;
|
|
617
|
+
|
|
618
|
+
cameraL.updateProjectionMatrix();
|
|
619
|
+
cameraR.updateProjectionMatrix();
|
|
620
|
+
camera.updateProjectionMatrix();
|
|
621
|
+
|
|
600
622
|
}
|
|
601
623
|
|
|
602
624
|
const cameras = cameraXR.cameras;
|
|
@@ -699,6 +721,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
699
721
|
|
|
700
722
|
};
|
|
701
723
|
|
|
724
|
+
this.hasDepthSensing = function () {
|
|
725
|
+
|
|
726
|
+
return depthSensing.texture !== null;
|
|
727
|
+
|
|
728
|
+
};
|
|
729
|
+
|
|
702
730
|
// Animation Loop
|
|
703
731
|
|
|
704
732
|
let onAnimationFrameCallback = null;
|
|
@@ -791,6 +819,22 @@ class WebXRManager extends EventDispatcher {
|
|
|
791
819
|
|
|
792
820
|
}
|
|
793
821
|
|
|
822
|
+
//
|
|
823
|
+
|
|
824
|
+
const enabledFeatures = session.enabledFeatures;
|
|
825
|
+
|
|
826
|
+
if ( enabledFeatures && enabledFeatures.includes( 'depth-sensing' ) ) {
|
|
827
|
+
|
|
828
|
+
const depthData = glBinding.getDepthInformation( views[ 0 ] );
|
|
829
|
+
|
|
830
|
+
if ( depthData && depthData.isValid && depthData.texture ) {
|
|
831
|
+
|
|
832
|
+
depthSensing.init( renderer, depthData, session.renderState );
|
|
833
|
+
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
}
|
|
837
|
+
|
|
794
838
|
}
|
|
795
839
|
|
|
796
840
|
//
|
|
@@ -808,6 +852,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
808
852
|
|
|
809
853
|
}
|
|
810
854
|
|
|
855
|
+
depthSensing.render( renderer, cameraXR );
|
|
856
|
+
|
|
811
857
|
if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
|
|
812
858
|
|
|
813
859
|
if ( frame.detectedPlanes ) {
|