@plastic-software/three 0.179.0 → 0.180.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +167 -107
- package/build/three.core.js +112 -20
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +56 -90
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +30 -5
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2896 -1048
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2896 -1048
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +7 -7
- package/examples/jsm/controls/DragControls.js +6 -56
- package/examples/jsm/controls/FirstPersonControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +0 -8
- package/examples/jsm/exporters/GLTFExporter.js +30 -22
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/GLTFLoader.js +9 -5
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +112 -32
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/TTFLoader.js +4 -4
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +2 -2
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
- package/examples/jsm/transpiler/TSLEncoder.js +2 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
- package/examples/jsm/tsl/display/BloomNode.js +3 -3
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
- package/examples/jsm/tsl/display/GTAONode.js +8 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +47 -35
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +180 -65
- package/examples/jsm/tsl/display/TRAANode.js +1 -1
- package/examples/jsm/tsl/display/boxBlur.js +64 -0
- package/examples/jsm/tsl/display/hashBlur.js +15 -18
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +29 -4
- package/src/animation/AnimationClip.js +17 -2
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +2 -2
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/lib/earcut.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/materials/Material.js +12 -0
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +81 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
- package/src/math/ColorManagement.js +7 -1
- package/src/nodes/Nodes.js +3 -0
- package/src/nodes/TSL.js +3 -0
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +133 -7
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +2 -2
- package/src/nodes/accessors/InstanceNode.js +3 -1
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +1 -1
- package/src/nodes/accessors/Texture3DNode.js +13 -0
- package/src/nodes/accessors/TextureNode.js +71 -19
- package/src/nodes/code/FunctionCallNode.js +19 -0
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/AssignNode.js +4 -3
- package/src/nodes/core/ContextNode.js +24 -0
- package/src/nodes/core/Node.js +16 -20
- package/src/nodes/core/NodeBuilder.js +48 -14
- package/src/nodes/core/NodeFrame.js +1 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +1 -2
- package/src/nodes/core/StackNode.js +29 -4
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +16 -9
- package/src/nodes/core/VarNode.js +0 -21
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/PassNode.js +1 -1
- package/src/nodes/display/ScreenNode.js +42 -13
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +42 -12
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
- package/src/nodes/lighting/LightsNode.js +1 -1
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +18 -2
- package/src/nodes/math/MathNode.js +3 -15
- package/src/nodes/math/OperatorNode.js +4 -3
- package/src/nodes/tsl/TSLCore.js +432 -152
- package/src/nodes/utils/JoinNode.js +3 -1
- package/src/nodes/utils/MemberNode.js +58 -7
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +51 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +2 -2
- package/src/objects/LOD.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +1 -10
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +19 -1
- package/src/renderers/common/Bindings.js +2 -0
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderObject.js +14 -2
- package/src/renderers/common/Renderer.js +39 -19
- package/src/renderers/common/SampledTexture.js +1 -1
- package/src/renderers/common/Sampler.js +25 -13
- package/src/renderers/common/Textures.js +34 -12
- package/src/renderers/common/TimestampQueryPool.js +3 -3
- package/src/renderers/common/XRManager.js +35 -19
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -15
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +1 -1
- package/src/renderers/webgl/WebGLTextures.js +1 -0
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +186 -135
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +110 -17
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +35 -31
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +124 -34
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +9 -18
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +114 -25
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
- package/src/renderers/webxr/WebXRManager.js +39 -24
- package/src/textures/ExternalTexture.js +15 -4
- package/src/textures/Source.js +1 -1
- package/src/textures/VideoTexture.js +0 -3
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -18,17 +18,6 @@ class Sampler extends Binding {
|
|
|
18
18
|
|
|
19
19
|
super( name );
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* This function is called when the texture is disposed.
|
|
23
|
-
* @type {function}
|
|
24
|
-
* @private
|
|
25
|
-
*/
|
|
26
|
-
this._onDisposeTexture = () => {
|
|
27
|
-
|
|
28
|
-
this.texture = null;
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
21
|
/**
|
|
33
22
|
* The texture the sampler is referring to.
|
|
34
23
|
*
|
|
@@ -71,9 +60,17 @@ class Sampler extends Binding {
|
|
|
71
60
|
|
|
72
61
|
if ( this._texture === value ) return;
|
|
73
62
|
|
|
63
|
+
const onDispose = () => {
|
|
64
|
+
|
|
65
|
+
this._texture = null;
|
|
66
|
+
this.generation = null;
|
|
67
|
+
this.version = 0;
|
|
68
|
+
|
|
69
|
+
};
|
|
70
|
+
|
|
74
71
|
if ( this._texture ) {
|
|
75
72
|
|
|
76
|
-
this._texture.removeEventListener( 'dispose',
|
|
73
|
+
this._texture.removeEventListener( 'dispose', onDispose );
|
|
77
74
|
|
|
78
75
|
}
|
|
79
76
|
|
|
@@ -84,7 +81,7 @@ class Sampler extends Binding {
|
|
|
84
81
|
|
|
85
82
|
if ( this._texture ) {
|
|
86
83
|
|
|
87
|
-
this._texture.addEventListener( 'dispose',
|
|
84
|
+
this._texture.addEventListener( 'dispose', onDispose );
|
|
88
85
|
|
|
89
86
|
}
|
|
90
87
|
|
|
@@ -122,6 +119,21 @@ class Sampler extends Binding {
|
|
|
122
119
|
|
|
123
120
|
}
|
|
124
121
|
|
|
122
|
+
|
|
123
|
+
clone() {
|
|
124
|
+
|
|
125
|
+
const clonedSampler = super.clone();
|
|
126
|
+
|
|
127
|
+
// fix dispose handler for cloned instances
|
|
128
|
+
// TODO: Find better solution, see #31747
|
|
129
|
+
|
|
130
|
+
clonedSampler._texture = null;
|
|
131
|
+
clonedSampler.texture = this.texture;
|
|
132
|
+
|
|
133
|
+
return clonedSampler;
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
export default Sampler;
|
|
@@ -2,7 +2,8 @@ import DataMap from './DataMap.js';
|
|
|
2
2
|
|
|
3
3
|
import { Vector3 } from '../../math/Vector3.js';
|
|
4
4
|
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
5
|
-
import { DepthStencilFormat, DepthFormat, UnsignedIntType, UnsignedInt248Type, UnsignedByteType } from '../../constants.js';
|
|
5
|
+
import { DepthStencilFormat, DepthFormat, UnsignedIntType, UnsignedInt248Type, UnsignedByteType, SRGBTransfer } from '../../constants.js';
|
|
6
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
7
|
|
|
7
8
|
const _size = /*@__PURE__*/ new Vector3();
|
|
8
9
|
|
|
@@ -178,6 +179,7 @@ class Textures extends DataMap {
|
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
this.delete( renderTarget );
|
|
182
|
+
this.backend.delete( renderTarget );
|
|
181
183
|
|
|
182
184
|
};
|
|
183
185
|
|
|
@@ -240,9 +242,15 @@ class Textures extends DataMap {
|
|
|
240
242
|
options.needsMipmaps = this.needsMipmaps( texture );
|
|
241
243
|
options.levels = options.needsMipmaps ? this.getMipLevels( texture, width, height ) : 1;
|
|
242
244
|
|
|
245
|
+
// TODO: Uniformly handle mipmap definitions
|
|
246
|
+
// Normal textures and compressed cube textures define base level + mips with their mipmap array
|
|
247
|
+
// Uncompressed cube textures use their mipmap array only for mips (no base level)
|
|
248
|
+
|
|
249
|
+
if ( texture.isCubeTexture && texture.mipmaps.length > 0 ) options.levels ++;
|
|
250
|
+
|
|
243
251
|
//
|
|
244
252
|
|
|
245
|
-
if ( isRenderTarget || texture.isStorageTexture === true ) {
|
|
253
|
+
if ( isRenderTarget || texture.isStorageTexture === true || texture.isExternalTexture === true ) {
|
|
246
254
|
|
|
247
255
|
backend.createSampler( texture );
|
|
248
256
|
backend.createTexture( texture, options );
|
|
@@ -300,6 +308,8 @@ class Textures extends DataMap {
|
|
|
300
308
|
|
|
301
309
|
if ( options.needsMipmaps && texture.mipmaps.length === 0 ) backend.generateMipmaps( texture );
|
|
302
310
|
|
|
311
|
+
if ( texture.onUpdate ) texture.onUpdate( texture );
|
|
312
|
+
|
|
303
313
|
}
|
|
304
314
|
|
|
305
315
|
} else {
|
|
@@ -326,6 +336,14 @@ class Textures extends DataMap {
|
|
|
326
336
|
|
|
327
337
|
this.info.memory.textures ++;
|
|
328
338
|
|
|
339
|
+
//
|
|
340
|
+
|
|
341
|
+
if ( texture.isVideoTexture && ColorManagement.getTransfer( texture.colorSpace ) !== SRGBTransfer ) {
|
|
342
|
+
|
|
343
|
+
console.warn( 'WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.' );
|
|
344
|
+
|
|
345
|
+
}
|
|
346
|
+
|
|
329
347
|
// dispose
|
|
330
348
|
|
|
331
349
|
const onDispose = () => {
|
|
@@ -366,7 +384,7 @@ class Textures extends DataMap {
|
|
|
366
384
|
|
|
367
385
|
if ( image.image !== undefined ) image = image.image;
|
|
368
386
|
|
|
369
|
-
if ( image instanceof HTMLVideoElement ) {
|
|
387
|
+
if ( ( typeof HTMLVideoElement !== 'undefined' ) && ( image instanceof HTMLVideoElement ) ) {
|
|
370
388
|
|
|
371
389
|
target.width = image.videoWidth || 1;
|
|
372
390
|
target.height = image.videoHeight || 1;
|
|
@@ -408,21 +426,25 @@ class Textures extends DataMap {
|
|
|
408
426
|
|
|
409
427
|
let mipLevelCount;
|
|
410
428
|
|
|
411
|
-
if ( texture.
|
|
429
|
+
if ( texture.mipmaps.length > 0 ) {
|
|
430
|
+
|
|
431
|
+
mipLevelCount = texture.mipmaps.length;
|
|
412
432
|
|
|
413
|
-
|
|
433
|
+
} else {
|
|
414
434
|
|
|
415
|
-
|
|
435
|
+
if ( texture.isCompressedTexture === true ) {
|
|
416
436
|
|
|
417
|
-
|
|
437
|
+
// it is not possible to compute mipmaps for compressed textures. So
|
|
438
|
+
// when no mipmaps are defined in "texture.mipmaps", force a texture
|
|
439
|
+
// level of 1
|
|
418
440
|
|
|
419
441
|
mipLevelCount = 1;
|
|
420
442
|
|
|
421
|
-
}
|
|
443
|
+
} else {
|
|
422
444
|
|
|
423
|
-
|
|
445
|
+
mipLevelCount = Math.floor( Math.log2( Math.max( width, height ) ) ) + 1;
|
|
424
446
|
|
|
425
|
-
|
|
447
|
+
}
|
|
426
448
|
|
|
427
449
|
}
|
|
428
450
|
|
|
@@ -431,14 +453,14 @@ class Textures extends DataMap {
|
|
|
431
453
|
}
|
|
432
454
|
|
|
433
455
|
/**
|
|
434
|
-
* Returns `true` if the given texture
|
|
456
|
+
* Returns `true` if the given texture makes use of mipmapping.
|
|
435
457
|
*
|
|
436
458
|
* @param {Texture} texture - The texture.
|
|
437
459
|
* @return {boolean} Whether mipmaps are required or not.
|
|
438
460
|
*/
|
|
439
461
|
needsMipmaps( texture ) {
|
|
440
462
|
|
|
441
|
-
return texture.
|
|
463
|
+
return texture.generateMipmaps === true || texture.mipmaps.length > 0;
|
|
442
464
|
|
|
443
465
|
}
|
|
444
466
|
|
|
@@ -70,13 +70,13 @@ class TimestampQueryPool {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Allocate queries for a specific
|
|
73
|
+
* Allocate queries for a specific uid.
|
|
74
74
|
*
|
|
75
75
|
* @abstract
|
|
76
|
-
* @param {
|
|
76
|
+
* @param {string} uid - A unique identifier for the render context.
|
|
77
77
|
* @returns {?number}
|
|
78
78
|
*/
|
|
79
|
-
allocateQueriesForContext( /*
|
|
79
|
+
allocateQueriesForContext( /* uid */ ) {}
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Resolve all timestamps and return data (or process them).
|
|
@@ -164,12 +164,12 @@ class XRManager extends EventDispatcher {
|
|
|
164
164
|
this._layers = [];
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
|
-
* Whether the
|
|
167
|
+
* Whether the XR session uses layers.
|
|
168
168
|
*
|
|
169
169
|
* @type {boolean}
|
|
170
170
|
* @default false
|
|
171
171
|
*/
|
|
172
|
-
this.
|
|
172
|
+
this._sessionUsesLayers = false;
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Whether the device supports binding gl objects.
|
|
@@ -360,13 +360,16 @@ class XRManager extends EventDispatcher {
|
|
|
360
360
|
this._xrFrame = null;
|
|
361
361
|
|
|
362
362
|
/**
|
|
363
|
-
* Whether
|
|
363
|
+
* Whether the browser supports the APIs necessary to use XRProjectionLayers.
|
|
364
|
+
*
|
|
365
|
+
* Note: this does not represent XRSession explicitly requesting
|
|
366
|
+
* `'layers'` as a feature - see `_sessionUsesLayers` and #30112
|
|
364
367
|
*
|
|
365
368
|
* @private
|
|
366
369
|
* @type {boolean}
|
|
367
370
|
* @readonly
|
|
368
371
|
*/
|
|
369
|
-
this.
|
|
372
|
+
this._supportsLayers = ( this._supportsGlBinding && 'createProjectionLayer' in XRWebGLBinding.prototype ); // eslint-disable-line compat/compat
|
|
370
373
|
|
|
371
374
|
/**
|
|
372
375
|
* Whether the usage of multiview has been requested by the application or not.
|
|
@@ -587,6 +590,27 @@ class XRManager extends EventDispatcher {
|
|
|
587
590
|
|
|
588
591
|
}
|
|
589
592
|
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Returns the current XR binding.
|
|
596
|
+
*
|
|
597
|
+
* Creates a new binding if needed and the browser is
|
|
598
|
+
* capable of doing so.
|
|
599
|
+
*
|
|
600
|
+
* @return {?XRWebGLBinding} The XR binding. Returns `null` if one cannot be created.
|
|
601
|
+
*/
|
|
602
|
+
getBinding() {
|
|
603
|
+
|
|
604
|
+
if ( this._glBinding === null && this._supportsGlBinding ) {
|
|
605
|
+
|
|
606
|
+
this._glBinding = new XRWebGLBinding( this._session, this._gl );
|
|
607
|
+
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
return this._glBinding;
|
|
611
|
+
|
|
612
|
+
}
|
|
613
|
+
|
|
590
614
|
/**
|
|
591
615
|
* Returns the current XR frame.
|
|
592
616
|
*
|
|
@@ -817,7 +841,7 @@ class XRManager extends EventDispatcher {
|
|
|
817
841
|
layer.renderTarget.isXRRenderTarget = this._session !== null;
|
|
818
842
|
layer.renderTarget._hasExternalTextures = layer.renderTarget.isXRRenderTarget;
|
|
819
843
|
|
|
820
|
-
if ( layer.renderTarget.isXRRenderTarget && this.
|
|
844
|
+
if ( layer.renderTarget.isXRRenderTarget && this._sessionUsesLayers ) {
|
|
821
845
|
|
|
822
846
|
layer.xrlayer.transform = new XRRigidTransform( layer.plane.getWorldPosition( translationObject ), layer.plane.getWorldQuaternion( quaternionObject ) );
|
|
823
847
|
|
|
@@ -924,16 +948,7 @@ class XRManager extends EventDispatcher {
|
|
|
924
948
|
|
|
925
949
|
//
|
|
926
950
|
|
|
927
|
-
if ( this.
|
|
928
|
-
|
|
929
|
-
const glBinding = new XRWebGLBinding( session, gl );
|
|
930
|
-
this._glBinding = glBinding;
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
//
|
|
935
|
-
|
|
936
|
-
if ( this._useLayers === true ) {
|
|
951
|
+
if ( this._supportsLayers === true ) {
|
|
937
952
|
|
|
938
953
|
// default path using XRProjectionLayer
|
|
939
954
|
|
|
@@ -963,6 +978,7 @@ class XRManager extends EventDispatcher {
|
|
|
963
978
|
|
|
964
979
|
}
|
|
965
980
|
|
|
981
|
+
this._glBinding = this.getBinding();
|
|
966
982
|
const glProjLayer = this._glBinding.createProjectionLayer( projectionlayerInit );
|
|
967
983
|
const layersArray = [ glProjLayer ];
|
|
968
984
|
|
|
@@ -993,11 +1009,11 @@ class XRManager extends EventDispatcher {
|
|
|
993
1009
|
this._xrRenderTarget._hasExternalTextures = true;
|
|
994
1010
|
this._xrRenderTarget.depth = this._useMultiview ? 2 : 1;
|
|
995
1011
|
|
|
996
|
-
this.
|
|
1012
|
+
this._sessionUsesLayers = session.enabledFeatures.includes( 'layers' );
|
|
997
1013
|
|
|
998
1014
|
this._referenceSpace = await session.requestReferenceSpace( this.getReferenceSpaceType() );
|
|
999
1015
|
|
|
1000
|
-
if ( this.
|
|
1016
|
+
if ( this._sessionUsesLayers ) {
|
|
1001
1017
|
|
|
1002
1018
|
// switch layers to native
|
|
1003
1019
|
for ( const layer of this._layers ) {
|
|
@@ -1366,7 +1382,7 @@ function onSessionEnd() {
|
|
|
1366
1382
|
this._xrRenderTarget = null;
|
|
1367
1383
|
|
|
1368
1384
|
// switch layers back to emulated
|
|
1369
|
-
if ( this.
|
|
1385
|
+
if ( this._sessionUsesLayers === true ) {
|
|
1370
1386
|
|
|
1371
1387
|
for ( const layer of this._layers ) {
|
|
1372
1388
|
|
|
@@ -1568,7 +1584,7 @@ function onAnimationFrame( time, frame ) {
|
|
|
1568
1584
|
|
|
1569
1585
|
let viewport;
|
|
1570
1586
|
|
|
1571
|
-
if ( this.
|
|
1587
|
+
if ( this._supportsLayers === true ) {
|
|
1572
1588
|
|
|
1573
1589
|
const glSubImage = this._glBinding.getViewSubImage( this._glProjLayer, view );
|
|
1574
1590
|
viewport = glSubImage.viewport;
|
|
@@ -126,7 +126,7 @@ class NodeBuilderState {
|
|
|
126
126
|
|
|
127
127
|
if ( shared !== true ) {
|
|
128
128
|
|
|
129
|
-
const bindingsGroup = new BindGroup( instanceGroup.name, [], instanceGroup.index, instanceGroup );
|
|
129
|
+
const bindingsGroup = new BindGroup( instanceGroup.name, [], instanceGroup.index, instanceGroup.bindingsReference );
|
|
130
130
|
bindings.push( bindingsGroup );
|
|
131
131
|
|
|
132
132
|
for ( const instanceBinding of instanceGroup.bindings ) {
|
|
@@ -146,9 +146,9 @@ class NodeLibrary {
|
|
|
146
146
|
/**
|
|
147
147
|
* Adds a node class definition for the given type to the provided type library.
|
|
148
148
|
*
|
|
149
|
-
* @param {
|
|
149
|
+
* @param {Node.constructor} nodeClass - The node class definition.
|
|
150
150
|
* @param {number|string} type - The object type.
|
|
151
|
-
* @param {Map} library - The type library.
|
|
151
|
+
* @param {Map<number|string,Node.constructor>} library - The type library.
|
|
152
152
|
*/
|
|
153
153
|
addType( nodeClass, type, library ) {
|
|
154
154
|
|
|
@@ -169,9 +169,9 @@ class NodeLibrary {
|
|
|
169
169
|
/**
|
|
170
170
|
* Adds a node class definition for the given class definition to the provided type library.
|
|
171
171
|
*
|
|
172
|
-
* @param {
|
|
173
|
-
* @param {
|
|
174
|
-
* @param {WeakMap} library - The type library.
|
|
172
|
+
* @param {Node.constructor} nodeClass - The node class definition.
|
|
173
|
+
* @param {Node.constructor} baseClass - The class definition.
|
|
174
|
+
* @param {WeakMap<Node.constructor, Node.constructor>} library - The type library.
|
|
175
175
|
*/
|
|
176
176
|
addClass( nodeClass, baseClass, library ) {
|
|
177
177
|
|
|
@@ -65,19 +65,11 @@ export default /* glsl */`
|
|
|
65
65
|
|
|
66
66
|
#endif
|
|
67
67
|
|
|
68
|
-
/*
|
|
69
|
-
#if NUM_RECT_AREA_LIGHTS > 0
|
|
70
|
-
|
|
71
|
-
// TODO (abelnation): create uniforms for area light shadows
|
|
72
|
-
|
|
73
|
-
#endif
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
68
|
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
77
69
|
|
|
78
70
|
float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
|
|
79
71
|
|
|
80
|
-
#ifdef
|
|
72
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
81
73
|
|
|
82
74
|
return step( depth, compare );
|
|
83
75
|
|
|
@@ -95,25 +87,25 @@ export default /* glsl */`
|
|
|
95
87
|
|
|
96
88
|
}
|
|
97
89
|
|
|
98
|
-
float VSMShadow
|
|
90
|
+
float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
|
|
99
91
|
|
|
100
92
|
float occlusion = 1.0;
|
|
101
93
|
|
|
102
94
|
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
103
95
|
|
|
104
|
-
#ifdef
|
|
96
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
105
97
|
|
|
106
|
-
float hard_shadow = step( distribution.x, compare );
|
|
98
|
+
float hard_shadow = step( distribution.x, compare );
|
|
107
99
|
|
|
108
100
|
#else
|
|
109
101
|
|
|
110
|
-
float hard_shadow = step( compare
|
|
102
|
+
float hard_shadow = step( compare, distribution.x );
|
|
111
103
|
|
|
112
104
|
#endif
|
|
113
105
|
|
|
114
|
-
if (hard_shadow != 1.0 ) {
|
|
106
|
+
if ( hard_shadow != 1.0 ) {
|
|
115
107
|
|
|
116
|
-
float distance = compare - distribution.x
|
|
108
|
+
float distance = compare - distribution.x;
|
|
117
109
|
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
118
110
|
float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
|
|
119
111
|
softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
|
|
@@ -663,8 +663,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
663
663
|
|
|
664
664
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
665
665
|
|
|
666
|
-
parameters.logarithmicDepthBuffer ? '#define
|
|
667
|
-
parameters.reversedDepthBuffer ? '#define
|
|
666
|
+
parameters.logarithmicDepthBuffer ? '#define USE_LOGARITHMIC_DEPTH_BUFFER' : '',
|
|
667
|
+
parameters.reversedDepthBuffer ? '#define USE_REVERSED_DEPTH_BUFFER' : '',
|
|
668
668
|
|
|
669
669
|
'uniform mat4 modelMatrix;',
|
|
670
670
|
'uniform mat4 modelViewMatrix;',
|
|
@@ -839,8 +839,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
839
839
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
840
840
|
parameters.decodeVideoTextureEmissive ? '#define DECODE_VIDEO_TEXTURE_EMISSIVE' : '',
|
|
841
841
|
|
|
842
|
-
parameters.logarithmicDepthBuffer ? '#define
|
|
843
|
-
parameters.reversedDepthBuffer ? '#define
|
|
842
|
+
parameters.logarithmicDepthBuffer ? '#define USE_LOGARITHMIC_DEPTH_BUFFER' : '',
|
|
843
|
+
parameters.reversedDepthBuffer ? '#define USE_REVERSED_DEPTH_BUFFER' : '',
|
|
844
844
|
|
|
845
845
|
'uniform mat4 modelViewMatrix;',
|
|
846
846
|
'uniform mat4 viewMatrix;',
|
|
@@ -85,7 +85,7 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
|
85
85
|
// Set GL state for depth map.
|
|
86
86
|
_state.setBlending( NoBlending );
|
|
87
87
|
|
|
88
|
-
if ( _state.buffers.depth.getReversed() ) {
|
|
88
|
+
if ( _state.buffers.depth.getReversed() === true ) {
|
|
89
89
|
|
|
90
90
|
_state.buffers.color.setClear( 0, 0, 0, 0 );
|
|
91
91
|
|
|
@@ -201,6 +201,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
201
201
|
if ( glFormat === _gl.RGB ) {
|
|
202
202
|
|
|
203
203
|
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
|
|
204
|
+
if ( glType === _gl.UNSIGNED_INT_10F_11F_11F_REV ) internalFormat = _gl.R11F_G11F_B10F;
|
|
204
205
|
|
|
205
206
|
}
|
|
206
207
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, NoColorSpace, SRGBTransfer, UnsignedInt5999Type, RGBFormat } from '../../constants.js';
|
|
1
|
+
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, NoColorSpace, SRGBTransfer, UnsignedInt5999Type, RGBFormat, UnsignedInt101111Type } from '../../constants.js';
|
|
2
2
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
3
3
|
|
|
4
4
|
function WebGLUtils( gl, extensions ) {
|
|
@@ -13,6 +13,7 @@ function WebGLUtils( gl, extensions ) {
|
|
|
13
13
|
if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
|
|
14
14
|
if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
|
|
15
15
|
if ( p === UnsignedInt5999Type ) return gl.UNSIGNED_INT_5_9_9_9_REV;
|
|
16
|
+
if ( p === UnsignedInt101111Type ) return gl.UNSIGNED_INT_10F_11F_11F_REV;
|
|
16
17
|
|
|
17
18
|
if ( p === ByteType ) return gl.BYTE;
|
|
18
19
|
if ( p === ShortType ) return gl.SHORT;
|
|
@@ -181,7 +182,7 @@ function WebGLUtils( gl, extensions ) {
|
|
|
181
182
|
|
|
182
183
|
if ( extension !== null ) {
|
|
183
184
|
|
|
184
|
-
if ( p ===
|
|
185
|
+
if ( p === RED_RGTC1_Format ) return extension.COMPRESSED_RED_RGTC1_EXT;
|
|
185
186
|
if ( p === SIGNED_RED_RGTC1_Format ) return extension.COMPRESSED_SIGNED_RED_RGTC1_EXT;
|
|
186
187
|
if ( p === RED_GREEN_RGTC2_Format ) return extension.COMPRESSED_RED_GREEN_RGTC2_EXT;
|
|
187
188
|
if ( p === SIGNED_RED_GREEN_RGTC2_Format ) return extension.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
|