@plastic-software/three 0.178.0 → 0.180.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 +1 -1
- package/build/three.cjs +950 -230
- package/build/three.core.js +754 -138
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +197 -96
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +99 -25
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +4586 -1499
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +4544 -1499
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +2 -3
- package/examples/jsm/capabilities/WebGPU.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/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- 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/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- 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 +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- 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/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- 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/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +14 -5
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +23 -20
- 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 +7 -6
- 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 +51 -41
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +180 -65
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/boxBlur.js +64 -0
- package/examples/jsm/tsl/display/hashBlur.js +15 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- 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 +2 -0
- package/src/Three.TSL.js +98 -24
- package/src/animation/AnimationClip.js +17 -2
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +2 -2
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/lib/earcut.js +1 -1
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/FileLoader.js +25 -2
- package/src/loaders/ImageBitmapLoader.js +23 -0
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/Material.js +12 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/NodeMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +86 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/ColorManagement.js +7 -1
- package/src/math/Frustum.js +19 -8
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +4 -0
- package/src/nodes/TSL.js +4 -0
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +142 -16
- 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/Normal.js +11 -11
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +19 -4
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Texture3DNode.js +13 -0
- package/src/nodes/accessors/TextureNode.js +83 -19
- package/src/nodes/code/FunctionCallNode.js +19 -0
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +6 -2
- package/src/nodes/core/ContextNode.js +44 -1
- package/src/nodes/core/Node.js +30 -22
- package/src/nodes/core/NodeBuilder.js +71 -32
- package/src/nodes/core/NodeFrame.js +1 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/StackNode.js +71 -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 +79 -14
- package/src/nodes/core/VarNode.js +83 -15
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/PassNode.js +148 -2
- 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 +94 -4
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +1 -1
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +19 -3
- package/src/nodes/math/MathNode.js +72 -60
- package/src/nodes/math/OperatorNode.js +26 -25
- package/src/nodes/tsl/TSLCore.js +477 -142
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/JoinNode.js +3 -1
- package/src/nodes/utils/MemberNode.js +58 -7
- package/src/nodes/utils/RTTNode.js +10 -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 +6 -4
- package/src/objects/LOD.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +21 -31
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +19 -1
- package/src/renderers/common/Bindings.js +21 -18
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderObject.js +14 -2
- package/src/renderers/common/Renderer.js +55 -32
- package/src/renderers/common/SampledTexture.js +4 -72
- package/src/renderers/common/Sampler.js +91 -0
- package/src/renderers/common/Storage3DTexture.js +21 -0
- package/src/renderers/common/StorageArrayTexture.js +21 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +52 -14
- package/src/renderers/common/TimestampQueryPool.js +3 -3
- package/src/renderers/common/XRManager.js +51 -17
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- 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 +21 -11
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -18
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +207 -146
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +112 -19
- 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 +87 -44
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +169 -99
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +10 -19
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +120 -84
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +86 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +12 -2
- package/src/textures/VideoTexture.js +27 -2
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -32,6 +32,15 @@ class Sampler extends Binding {
|
|
|
32
32
|
*/
|
|
33
33
|
this.version = texture ? texture.version : 0;
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* The binding's generation which is an additional version
|
|
37
|
+
* qualifier.
|
|
38
|
+
*
|
|
39
|
+
* @type {?number}
|
|
40
|
+
* @default null
|
|
41
|
+
*/
|
|
42
|
+
this.generation = null;
|
|
43
|
+
|
|
35
44
|
/**
|
|
36
45
|
* This flag can be used for type testing.
|
|
37
46
|
*
|
|
@@ -43,6 +52,88 @@ class Sampler extends Binding {
|
|
|
43
52
|
|
|
44
53
|
}
|
|
45
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Sets the texture of this sampler.
|
|
57
|
+
* @param {?Texture} value - The texture to set.
|
|
58
|
+
*/
|
|
59
|
+
set texture( value ) {
|
|
60
|
+
|
|
61
|
+
if ( this._texture === value ) return;
|
|
62
|
+
|
|
63
|
+
const onDispose = () => {
|
|
64
|
+
|
|
65
|
+
this._texture = null;
|
|
66
|
+
this.generation = null;
|
|
67
|
+
this.version = 0;
|
|
68
|
+
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
if ( this._texture ) {
|
|
72
|
+
|
|
73
|
+
this._texture.removeEventListener( 'dispose', onDispose );
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this._texture = value;
|
|
78
|
+
|
|
79
|
+
this.generation = null;
|
|
80
|
+
this.version = 0;
|
|
81
|
+
|
|
82
|
+
if ( this._texture ) {
|
|
83
|
+
|
|
84
|
+
this._texture.addEventListener( 'dispose', onDispose );
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Gets the texture of this sampler.
|
|
92
|
+
* @return {?Texture} The texture.
|
|
93
|
+
*/
|
|
94
|
+
get texture() {
|
|
95
|
+
|
|
96
|
+
return this._texture;
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Updates the binding.
|
|
102
|
+
*
|
|
103
|
+
* @return {boolean} Whether the texture has been updated and must be
|
|
104
|
+
* uploaded to the GPU.
|
|
105
|
+
*/
|
|
106
|
+
update() {
|
|
107
|
+
|
|
108
|
+
const { texture, version } = this;
|
|
109
|
+
|
|
110
|
+
if ( version !== texture.version ) {
|
|
111
|
+
|
|
112
|
+
this.version = texture.version;
|
|
113
|
+
|
|
114
|
+
return true;
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return false;
|
|
119
|
+
|
|
120
|
+
}
|
|
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
|
+
|
|
46
137
|
}
|
|
47
138
|
|
|
48
139
|
export default Sampler;
|
|
@@ -74,6 +74,27 @@ class Storage3DTexture extends Texture {
|
|
|
74
74
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Sets the size of the storage 3d texture.
|
|
79
|
+
*
|
|
80
|
+
* @param {number} width - The new width of the storage texture.
|
|
81
|
+
* @param {number} height - The new height of the storage texture.
|
|
82
|
+
* @param {number} depth - The new depth of the storage texture.
|
|
83
|
+
*/
|
|
84
|
+
setSize( width, height, depth ) {
|
|
85
|
+
|
|
86
|
+
if ( this.image.width !== width || this.image.height !== height || this.image.depth !== depth ) {
|
|
87
|
+
|
|
88
|
+
this.image.width = width;
|
|
89
|
+
this.image.height = height;
|
|
90
|
+
this.image.depth = depth;
|
|
91
|
+
|
|
92
|
+
this.dispose();
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
77
98
|
}
|
|
78
99
|
|
|
79
100
|
export default Storage3DTexture;
|
|
@@ -58,6 +58,27 @@ class StorageArrayTexture extends Texture {
|
|
|
58
58
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Sets the size of the storage array texture.
|
|
63
|
+
*
|
|
64
|
+
* @param {number} width - The new width of the storage texture.
|
|
65
|
+
* @param {number} height - The new height of the storage texture.
|
|
66
|
+
* @param {number} depth - The new depth of the storage texture.
|
|
67
|
+
*/
|
|
68
|
+
setSize( width, height, depth ) {
|
|
69
|
+
|
|
70
|
+
if ( this.image.width !== width || this.image.height !== height || this.image.depth !== depth ) {
|
|
71
|
+
|
|
72
|
+
this.image.width = width;
|
|
73
|
+
this.image.height = height;
|
|
74
|
+
this.image.depth = depth;
|
|
75
|
+
|
|
76
|
+
this.dispose();
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
61
82
|
}
|
|
62
83
|
|
|
63
84
|
export default StorageArrayTexture;
|
|
@@ -54,6 +54,25 @@ class StorageTexture extends Texture {
|
|
|
54
54
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Sets the size of the storage texture.
|
|
59
|
+
*
|
|
60
|
+
* @param {number} width - The new width of the storage texture.
|
|
61
|
+
* @param {number} height - The new height of the storage texture.
|
|
62
|
+
*/
|
|
63
|
+
setSize( width, height ) {
|
|
64
|
+
|
|
65
|
+
if ( this.image.width !== width || this.image.height !== height ) {
|
|
66
|
+
|
|
67
|
+
this.image.width = width;
|
|
68
|
+
this.image.height = height;
|
|
69
|
+
|
|
70
|
+
this.dispose();
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
57
76
|
}
|
|
58
77
|
|
|
59
78
|
export default StorageTexture;
|
|
@@ -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,9 +384,25 @@ class Textures extends DataMap {
|
|
|
366
384
|
|
|
367
385
|
if ( image.image !== undefined ) image = image.image;
|
|
368
386
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
387
|
+
if ( ( typeof HTMLVideoElement !== 'undefined' ) && ( image instanceof HTMLVideoElement ) ) {
|
|
388
|
+
|
|
389
|
+
target.width = image.videoWidth || 1;
|
|
390
|
+
target.height = image.videoHeight || 1;
|
|
391
|
+
target.depth = 1;
|
|
392
|
+
|
|
393
|
+
} else if ( image instanceof VideoFrame ) {
|
|
394
|
+
|
|
395
|
+
target.width = image.displayWidth || 1;
|
|
396
|
+
target.height = image.displayHeight || 1;
|
|
397
|
+
target.depth = 1;
|
|
398
|
+
|
|
399
|
+
} else {
|
|
400
|
+
|
|
401
|
+
target.width = image.width || 1;
|
|
402
|
+
target.height = image.height || 1;
|
|
403
|
+
target.depth = texture.isCubeTexture ? 6 : ( image.depth || 1 );
|
|
404
|
+
|
|
405
|
+
}
|
|
372
406
|
|
|
373
407
|
} else {
|
|
374
408
|
|
|
@@ -392,21 +426,25 @@ class Textures extends DataMap {
|
|
|
392
426
|
|
|
393
427
|
let mipLevelCount;
|
|
394
428
|
|
|
395
|
-
if ( texture.
|
|
429
|
+
if ( texture.mipmaps.length > 0 ) {
|
|
430
|
+
|
|
431
|
+
mipLevelCount = texture.mipmaps.length;
|
|
396
432
|
|
|
397
|
-
|
|
433
|
+
} else {
|
|
398
434
|
|
|
399
|
-
|
|
435
|
+
if ( texture.isCompressedTexture === true ) {
|
|
400
436
|
|
|
401
|
-
|
|
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
|
|
402
440
|
|
|
403
441
|
mipLevelCount = 1;
|
|
404
442
|
|
|
405
|
-
}
|
|
443
|
+
} else {
|
|
406
444
|
|
|
407
|
-
|
|
445
|
+
mipLevelCount = Math.floor( Math.log2( Math.max( width, height ) ) ) + 1;
|
|
408
446
|
|
|
409
|
-
|
|
447
|
+
}
|
|
410
448
|
|
|
411
449
|
}
|
|
412
450
|
|
|
@@ -415,14 +453,14 @@ class Textures extends DataMap {
|
|
|
415
453
|
}
|
|
416
454
|
|
|
417
455
|
/**
|
|
418
|
-
* Returns `true` if the given texture
|
|
456
|
+
* Returns `true` if the given texture makes use of mipmapping.
|
|
419
457
|
*
|
|
420
458
|
* @param {Texture} texture - The texture.
|
|
421
459
|
* @return {boolean} Whether mipmaps are required or not.
|
|
422
460
|
*/
|
|
423
461
|
needsMipmaps( texture ) {
|
|
424
462
|
|
|
425
|
-
return texture.
|
|
463
|
+
return texture.generateMipmaps === true || texture.mipmaps.length > 0;
|
|
426
464
|
|
|
427
465
|
}
|
|
428
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,21 @@ 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
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Whether the device supports binding gl objects.
|
|
176
|
+
*
|
|
177
|
+
* @private
|
|
178
|
+
* @type {boolean}
|
|
179
|
+
* @readonly
|
|
180
|
+
*/
|
|
181
|
+
this._supportsGlBinding = typeof XRWebGLBinding !== 'undefined';
|
|
173
182
|
|
|
174
183
|
this._frameBufferTargets = null;
|
|
175
184
|
|
|
@@ -351,13 +360,16 @@ class XRManager extends EventDispatcher {
|
|
|
351
360
|
this._xrFrame = null;
|
|
352
361
|
|
|
353
362
|
/**
|
|
354
|
-
* 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
|
|
355
367
|
*
|
|
356
368
|
* @private
|
|
357
369
|
* @type {boolean}
|
|
358
370
|
* @readonly
|
|
359
371
|
*/
|
|
360
|
-
this.
|
|
372
|
+
this._supportsLayers = ( this._supportsGlBinding && 'createProjectionLayer' in XRWebGLBinding.prototype ); // eslint-disable-line compat/compat
|
|
361
373
|
|
|
362
374
|
/**
|
|
363
375
|
* Whether the usage of multiview has been requested by the application or not.
|
|
@@ -578,6 +590,27 @@ class XRManager extends EventDispatcher {
|
|
|
578
590
|
|
|
579
591
|
}
|
|
580
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
|
+
|
|
581
614
|
/**
|
|
582
615
|
* Returns the current XR frame.
|
|
583
616
|
*
|
|
@@ -808,7 +841,7 @@ class XRManager extends EventDispatcher {
|
|
|
808
841
|
layer.renderTarget.isXRRenderTarget = this._session !== null;
|
|
809
842
|
layer.renderTarget._hasExternalTextures = layer.renderTarget.isXRRenderTarget;
|
|
810
843
|
|
|
811
|
-
if ( layer.renderTarget.isXRRenderTarget && this.
|
|
844
|
+
if ( layer.renderTarget.isXRRenderTarget && this._sessionUsesLayers ) {
|
|
812
845
|
|
|
813
846
|
layer.xrlayer.transform = new XRRigidTransform( layer.plane.getWorldPosition( translationObject ), layer.plane.getWorldQuaternion( quaternionObject ) );
|
|
814
847
|
|
|
@@ -915,9 +948,9 @@ class XRManager extends EventDispatcher {
|
|
|
915
948
|
|
|
916
949
|
//
|
|
917
950
|
|
|
918
|
-
if ( this.
|
|
951
|
+
if ( this._supportsLayers === true ) {
|
|
919
952
|
|
|
920
|
-
// default path using
|
|
953
|
+
// default path using XRProjectionLayer
|
|
921
954
|
|
|
922
955
|
let depthFormat = null;
|
|
923
956
|
let depthType = null;
|
|
@@ -945,11 +978,10 @@ class XRManager extends EventDispatcher {
|
|
|
945
978
|
|
|
946
979
|
}
|
|
947
980
|
|
|
948
|
-
|
|
949
|
-
const glProjLayer =
|
|
981
|
+
this._glBinding = this.getBinding();
|
|
982
|
+
const glProjLayer = this._glBinding.createProjectionLayer( projectionlayerInit );
|
|
950
983
|
const layersArray = [ glProjLayer ];
|
|
951
984
|
|
|
952
|
-
this._glBinding = glBinding;
|
|
953
985
|
this._glProjLayer = glProjLayer;
|
|
954
986
|
|
|
955
987
|
renderer.setPixelRatio( 1 );
|
|
@@ -977,11 +1009,11 @@ class XRManager extends EventDispatcher {
|
|
|
977
1009
|
this._xrRenderTarget._hasExternalTextures = true;
|
|
978
1010
|
this._xrRenderTarget.depth = this._useMultiview ? 2 : 1;
|
|
979
1011
|
|
|
980
|
-
this.
|
|
1012
|
+
this._sessionUsesLayers = session.enabledFeatures.includes( 'layers' );
|
|
981
1013
|
|
|
982
1014
|
this._referenceSpace = await session.requestReferenceSpace( this.getReferenceSpaceType() );
|
|
983
1015
|
|
|
984
|
-
if ( this.
|
|
1016
|
+
if ( this._sessionUsesLayers ) {
|
|
985
1017
|
|
|
986
1018
|
// switch layers to native
|
|
987
1019
|
for ( const layer of this._layers ) {
|
|
@@ -1095,9 +1127,11 @@ class XRManager extends EventDispatcher {
|
|
|
1095
1127
|
|
|
1096
1128
|
}
|
|
1097
1129
|
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1130
|
+
// inherit camera layers and enable eye layers (1 = left, 2 = right)
|
|
1131
|
+
cameraXR.layers.mask = camera.layers.mask | 0b110;
|
|
1132
|
+
cameraL.layers.mask = cameraXR.layers.mask & 0b011;
|
|
1133
|
+
cameraR.layers.mask = cameraXR.layers.mask & 0b101;
|
|
1134
|
+
|
|
1101
1135
|
|
|
1102
1136
|
const parent = camera.parent;
|
|
1103
1137
|
const cameras = cameraXR.cameras;
|
|
@@ -1348,7 +1382,7 @@ function onSessionEnd() {
|
|
|
1348
1382
|
this._xrRenderTarget = null;
|
|
1349
1383
|
|
|
1350
1384
|
// switch layers back to emulated
|
|
1351
|
-
if ( this.
|
|
1385
|
+
if ( this._sessionUsesLayers === true ) {
|
|
1352
1386
|
|
|
1353
1387
|
for ( const layer of this._layers ) {
|
|
1354
1388
|
|
|
@@ -1550,7 +1584,7 @@ function onAnimationFrame( time, frame ) {
|
|
|
1550
1584
|
|
|
1551
1585
|
let viewport;
|
|
1552
1586
|
|
|
1553
|
-
if ( this.
|
|
1587
|
+
if ( this._supportsLayers === true ) {
|
|
1554
1588
|
|
|
1555
1589
|
const glSubImage = this._glBinding.getViewSubImage( this._glProjLayer, view );
|
|
1556
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
|
|
|
@@ -45,18 +45,6 @@ class NodeSampledTexture extends SampledTexture {
|
|
|
45
45
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
/**
|
|
49
|
-
* Overwrites the default to additionally check if the node value has changed.
|
|
50
|
-
*
|
|
51
|
-
* @param {number} generation - The generation.
|
|
52
|
-
* @return {boolean} Whether an update is required or not.
|
|
53
|
-
*/
|
|
54
|
-
needsBindingsUpdate( generation ) {
|
|
55
|
-
|
|
56
|
-
return this.textureNode.value !== this.texture || super.needsBindingsUpdate( generation );
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
48
|
/**
|
|
61
49
|
* Updates the binding.
|
|
62
50
|
*
|
|
@@ -65,17 +65,19 @@ export default /* glsl */`
|
|
|
65
65
|
|
|
66
66
|
#endif
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
#if NUM_RECT_AREA_LIGHTS > 0
|
|
68
|
+
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
*/
|
|
72
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
75
73
|
|
|
76
|
-
|
|
74
|
+
return step( depth, compare );
|
|
77
75
|
|
|
78
|
-
|
|
76
|
+
#else
|
|
77
|
+
|
|
78
|
+
return step( compare, depth );
|
|
79
|
+
|
|
80
|
+
#endif
|
|
79
81
|
|
|
80
82
|
}
|
|
81
83
|
|
|
@@ -85,17 +87,25 @@ export default /* glsl */`
|
|
|
85
87
|
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
float VSMShadow
|
|
90
|
+
float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
|
|
89
91
|
|
|
90
92
|
float occlusion = 1.0;
|
|
91
93
|
|
|
92
94
|
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
97
|
+
|
|
98
|
+
float hard_shadow = step( distribution.x, compare );
|
|
99
|
+
|
|
100
|
+
#else
|
|
101
|
+
|
|
102
|
+
float hard_shadow = step( compare, distribution.x );
|
|
103
|
+
|
|
104
|
+
#endif
|
|
95
105
|
|
|
96
|
-
if (hard_shadow != 1.0 ) {
|
|
106
|
+
if ( hard_shadow != 1.0 ) {
|
|
97
107
|
|
|
98
|
-
float distance = compare - distribution.x
|
|
108
|
+
float distance = compare - distribution.x;
|
|
99
109
|
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
100
110
|
float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
|
|
101
111
|
softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
|
|
@@ -81,8 +81,17 @@ void main() {
|
|
|
81
81
|
|
|
82
82
|
#include <logdepthbuf_fragment>
|
|
83
83
|
|
|
84
|
-
// Higher precision equivalent of gl_FragCoord.z
|
|
85
|
-
|
|
84
|
+
// Higher precision equivalent of gl_FragCoord.z
|
|
85
|
+
|
|
86
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
87
|
+
|
|
88
|
+
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
|
89
|
+
|
|
90
|
+
#else
|
|
91
|
+
|
|
92
|
+
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
|
93
|
+
|
|
94
|
+
#endif
|
|
86
95
|
|
|
87
96
|
#if DEPTH_PACKING == 3200
|
|
88
97
|
|
|
@@ -92,7 +92,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
95
|
-
const
|
|
95
|
+
const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has( 'EXT_clip_control' );
|
|
96
96
|
|
|
97
97
|
const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
98
98
|
const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
|
|
@@ -120,7 +120,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
|
120
120
|
|
|
121
121
|
precision: precision,
|
|
122
122
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
123
|
-
|
|
123
|
+
reversedDepthBuffer: reversedDepthBuffer,
|
|
124
124
|
|
|
125
125
|
maxTextures: maxTextures,
|
|
126
126
|
maxVertexTextures: maxVertexTextures,
|