@plastic-software/three 0.181.3 → 0.182.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/build/three.cjs +1192 -522
- package/build/three.core.js +345 -219
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +864 -328
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +15 -3
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3660 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3659 -1544
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +6 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -0
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/inspector/Inspector.js +53 -9
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +2 -2
- package/examples/jsm/inspector/tabs/Parameters.js +2 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +948 -13
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +0 -2
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KTX2Loader.js +16 -0
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/PCDLoader.js +1 -0
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +110 -137
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +2 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/SkyMesh.js +13 -3
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +3 -1
- package/examples/jsm/physics/RapierPhysics.js +3 -1
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +191 -58
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -0
- package/examples/jsm/tsl/display/BloomNode.js +11 -1
- package/examples/jsm/tsl/display/GTAONode.js +3 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -1
- package/examples/jsm/tsl/display/SSGINode.js +7 -19
- package/examples/jsm/tsl/display/SSRNode.js +1 -1
- package/examples/jsm/tsl/display/SSSNode.js +4 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/TRAANode.js +265 -114
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +14 -12
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +14 -2
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/constants.js +61 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Raycaster.js +2 -2
- package/src/extras/PMREMGenerator.js +3 -10
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/helpers/PointLightHelper.js +1 -1
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +0 -3
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +3 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +59 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
- package/src/math/Matrix4.js +40 -40
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +0 -2
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +69 -29
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +2 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SkinningNode.js +15 -2
- package/src/nodes/accessors/StorageBufferNode.js +4 -2
- package/src/nodes/accessors/Tangent.js +1 -11
- package/src/nodes/accessors/Texture3DNode.js +26 -1
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/NodeBuilder.js +56 -14
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +5 -5
- package/src/nodes/core/ParameterNode.js +1 -2
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +56 -8
- package/src/nodes/core/StructNode.js +1 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/UniformNode.js +19 -4
- package/src/nodes/core/VarNode.js +46 -21
- package/src/nodes/display/NormalMapNode.js +37 -2
- package/src/nodes/display/PassNode.js +77 -7
- package/src/nodes/display/ScreenNode.js +1 -0
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +102 -43
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -3
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +141 -140
- package/src/nodes/lighting/ShadowFilterNode.js +53 -37
- package/src/nodes/lighting/ShadowNode.js +53 -19
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/tsl/TSLCore.js +4 -4
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/ReflectorNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/UVUtils.js +26 -0
- package/src/objects/BatchedMesh.js +5 -2
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +145 -33
- package/src/renderers/common/Backend.js +8 -0
- package/src/renderers/common/Background.js +19 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +7 -7
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/Geometries.js +12 -0
- package/src/renderers/common/RenderContexts.js +8 -1
- package/src/renderers/common/RenderObject.js +14 -1
- package/src/renderers/common/Renderer.js +53 -35
- package/src/renderers/common/Textures.js +1 -1
- package/src/renderers/common/UniformsGroup.js +1 -0
- package/src/renderers/common/XRManager.js +1 -0
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +90 -51
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +194 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +3 -3
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +43 -107
- package/src/renderers/webgl/WebGLPrograms.js +35 -45
- package/src/renderers/webgl/WebGLShadowMap.js +188 -25
- package/src/renderers/webgl/WebGLState.js +20 -20
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +79 -13
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +59 -7
- package/src/renderers/webgl-fallback/utils/WebGLState.js +18 -3
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +61 -4
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +65 -23
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +354 -186
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +20 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +40 -17
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +7 -5
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +1 -1
- package/src/utils.js +13 -1
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { warnOnce, warn } from '../../../utils.js';
|
|
1
|
+
import { error, warnOnce, warn } from '../../../utils.js';
|
|
2
2
|
import TimestampQueryPool from '../../common/TimestampQueryPool.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -122,9 +122,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
|
|
|
122
122
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
} catch (
|
|
125
|
+
} catch ( e ) {
|
|
126
126
|
|
|
127
|
-
error( 'Error in beginQuery:',
|
|
127
|
+
error( 'Error in beginQuery:', e );
|
|
128
128
|
this.activeQuery = null;
|
|
129
129
|
this.queryStates.set( baseOffset, 'inactive' );
|
|
130
130
|
|
|
@@ -165,9 +165,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
|
|
|
165
165
|
this.queryStates.set( baseOffset, 'ended' );
|
|
166
166
|
this.activeQuery = null;
|
|
167
167
|
|
|
168
|
-
} catch (
|
|
168
|
+
} catch ( e ) {
|
|
169
169
|
|
|
170
|
-
error( 'Error in endQuery:',
|
|
170
|
+
error( 'Error in endQuery:', e );
|
|
171
171
|
// Reset state on error
|
|
172
172
|
this.queryStates.set( baseOffset, 'inactive' );
|
|
173
173
|
this.activeQuery = null;
|
|
@@ -258,9 +258,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
|
|
|
258
258
|
|
|
259
259
|
return totalDuration;
|
|
260
260
|
|
|
261
|
-
} catch (
|
|
261
|
+
} catch ( e ) {
|
|
262
262
|
|
|
263
|
-
error( 'Error resolving queries:',
|
|
263
|
+
error( 'Error resolving queries:', e );
|
|
264
264
|
return this.lastValue;
|
|
265
265
|
|
|
266
266
|
} finally {
|
|
@@ -346,9 +346,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
|
|
|
346
346
|
const elapsed = this.gl.getQueryParameter( query, this.gl.QUERY_RESULT );
|
|
347
347
|
resolve( Number( elapsed ) / 1e6 ); // Convert nanoseconds to milliseconds
|
|
348
348
|
|
|
349
|
-
} catch (
|
|
349
|
+
} catch ( e ) {
|
|
350
350
|
|
|
351
|
-
error( 'Error checking query:',
|
|
351
|
+
error( 'Error checking query:', e );
|
|
352
352
|
resolve( this.lastValue );
|
|
353
353
|
|
|
354
354
|
}
|
|
@@ -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, RGBFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBTransfer, NoColorSpace, UnsignedInt101111Type } 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, R11_EAC_Format, SIGNED_R11_EAC_Format, RG11_EAC_Format, SIGNED_RG11_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, RGBFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBTransfer, NoColorSpace, UnsignedInt101111Type } from '../../../constants.js';
|
|
2
2
|
import { ColorManagement } from '../../../math/ColorManagement.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -154,7 +154,7 @@ class WebGLUtils {
|
|
|
154
154
|
|
|
155
155
|
// ETC
|
|
156
156
|
|
|
157
|
-
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
157
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format || p === R11_EAC_Format || p === SIGNED_R11_EAC_Format || p === RG11_EAC_Format || p === SIGNED_RG11_EAC_Format ) {
|
|
158
158
|
|
|
159
159
|
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
160
160
|
|
|
@@ -162,6 +162,10 @@ class WebGLUtils {
|
|
|
162
162
|
|
|
163
163
|
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
164
164
|
if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
165
|
+
if ( p === R11_EAC_Format ) return extension.COMPRESSED_R11_EAC;
|
|
166
|
+
if ( p === SIGNED_R11_EAC_Format ) return extension.COMPRESSED_SIGNED_R11_EAC;
|
|
167
|
+
if ( p === RG11_EAC_Format ) return extension.COMPRESSED_RG11_EAC;
|
|
168
|
+
if ( p === SIGNED_RG11_EAC_Format ) return extension.COMPRESSED_SIGNED_RG11_EAC;
|
|
165
169
|
|
|
166
170
|
} else {
|
|
167
171
|
|
|
@@ -204,6 +204,8 @@ class WebGPUBackend extends Backend {
|
|
|
204
204
|
|
|
205
205
|
device.lost.then( ( info ) => {
|
|
206
206
|
|
|
207
|
+
if ( info.reason === 'destroyed' ) return;
|
|
208
|
+
|
|
207
209
|
const deviceLossInfo = {
|
|
208
210
|
api: 'WebGPU',
|
|
209
211
|
message: info.message || 'Unknown reason',
|
|
@@ -519,7 +521,7 @@ class WebGPUBackend extends Backend {
|
|
|
519
521
|
|
|
520
522
|
const depthTextureData = this.get( renderContext.depthTexture );
|
|
521
523
|
const options = {};
|
|
522
|
-
if ( renderContext.depthTexture.isArrayTexture ) {
|
|
524
|
+
if ( renderContext.depthTexture.isArrayTexture || renderContext.depthTexture.isCubeTexture ) {
|
|
523
525
|
|
|
524
526
|
options.dimension = GPUTextureViewDimension.TwoD;
|
|
525
527
|
options.arrayLayerCount = 1;
|
|
@@ -1600,8 +1602,14 @@ class WebGPUBackend extends Backend {
|
|
|
1600
1602
|
if ( indirect !== null ) {
|
|
1601
1603
|
|
|
1602
1604
|
const buffer = this.get( indirect ).buffer;
|
|
1605
|
+
const indirectOffset = renderObject.getIndirectOffset();
|
|
1606
|
+
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1607
|
+
|
|
1608
|
+
for ( let i = 0; i < indirectOffsets.length; i ++ ) {
|
|
1603
1609
|
|
|
1604
|
-
|
|
1610
|
+
passEncoderGPU.drawIndexedIndirect( buffer, indirectOffsets[ i ] );
|
|
1611
|
+
|
|
1612
|
+
}
|
|
1605
1613
|
|
|
1606
1614
|
} else {
|
|
1607
1615
|
|
|
@@ -1620,8 +1628,15 @@ class WebGPUBackend extends Backend {
|
|
|
1620
1628
|
if ( indirect !== null ) {
|
|
1621
1629
|
|
|
1622
1630
|
const buffer = this.get( indirect ).buffer;
|
|
1631
|
+
const indirectOffset = renderObject.getIndirectOffset();
|
|
1632
|
+
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1633
|
+
|
|
1634
|
+
for ( let i = 0; i < indirectOffsets.length; i ++ ) {
|
|
1635
|
+
|
|
1636
|
+
passEncoderGPU.drawIndirect( buffer, indirectOffsets[ i ] );
|
|
1637
|
+
|
|
1638
|
+
}
|
|
1623
1639
|
|
|
1624
|
-
passEncoderGPU.drawIndirect( buffer, 0 );
|
|
1625
1640
|
|
|
1626
1641
|
} else {
|
|
1627
1642
|
|
|
@@ -1652,7 +1667,9 @@ class WebGPUBackend extends Backend {
|
|
|
1652
1667
|
|
|
1653
1668
|
data[ 0 ] = i;
|
|
1654
1669
|
|
|
1655
|
-
const
|
|
1670
|
+
const { layoutGPU } = bindingsData.layout;
|
|
1671
|
+
|
|
1672
|
+
const bindGroupIndex = this.bindingUtils.createBindGroupIndex( data, layoutGPU );
|
|
1656
1673
|
|
|
1657
1674
|
indexesGPU.push( bindGroupIndex );
|
|
1658
1675
|
|
|
@@ -2144,6 +2161,17 @@ class WebGPUBackend extends Backend {
|
|
|
2144
2161
|
|
|
2145
2162
|
}
|
|
2146
2163
|
|
|
2164
|
+
/**
|
|
2165
|
+
* Delete data associated with the current bind group.
|
|
2166
|
+
*
|
|
2167
|
+
* @param {BindGroup} bindGroup - The bind group.
|
|
2168
|
+
*/
|
|
2169
|
+
deleteBindGroupData( bindGroup ) {
|
|
2170
|
+
|
|
2171
|
+
this.bindingUtils.deleteBindGroupData( bindGroup );
|
|
2172
|
+
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2147
2175
|
// attributes
|
|
2148
2176
|
|
|
2149
2177
|
/**
|
|
@@ -2473,8 +2501,37 @@ class WebGPUBackend extends Backend {
|
|
|
2473
2501
|
|
|
2474
2502
|
dispose() {
|
|
2475
2503
|
|
|
2504
|
+
this.bindingUtils.dispose();
|
|
2476
2505
|
this.textureUtils.dispose();
|
|
2477
2506
|
|
|
2507
|
+
if ( this.occludedResolveCache ) {
|
|
2508
|
+
|
|
2509
|
+
for ( const buffer of this.occludedResolveCache.values() ) {
|
|
2510
|
+
|
|
2511
|
+
buffer.destroy();
|
|
2512
|
+
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
this.occludedResolveCache.clear();
|
|
2516
|
+
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
if ( this.timestampQueryPool ) {
|
|
2520
|
+
|
|
2521
|
+
for ( const queryPool of Object.values( this.timestampQueryPool ) ) {
|
|
2522
|
+
|
|
2523
|
+
if ( queryPool !== null ) queryPool.dispose();
|
|
2524
|
+
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
if ( this.parameters.device === undefined && this.device !== null ) {
|
|
2530
|
+
|
|
2531
|
+
this.device.destroy();
|
|
2532
|
+
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2478
2535
|
}
|
|
2479
2536
|
|
|
2480
2537
|
}
|
|
@@ -40,7 +40,7 @@ class WebGPURenderer extends Renderer {
|
|
|
40
40
|
* @property {boolean} [forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not.
|
|
41
41
|
* @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported.
|
|
42
42
|
* @property {number} [outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
|
|
43
|
-
* @property {number} [
|
|
43
|
+
* @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best
|
|
44
44
|
* quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
|
|
45
45
|
*/
|
|
46
46
|
|
|
@@ -19,8 +19,7 @@ import ExpressionNode from '../../../nodes/code/ExpressionNode.js';
|
|
|
19
19
|
import { FloatType, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter } from '../../../constants.js';
|
|
20
20
|
import { warn, error } from '../../../utils.js';
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
const GPUShaderStage = ( typeof self !== 'undefined' ) ? self.GPUShaderStage : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
|
22
|
+
import { GPUShaderStage } from '../utils/WebGPUConstants.js';
|
|
24
23
|
|
|
25
24
|
const accessNames = {
|
|
26
25
|
[ NodeAccess.READ_ONLY ]: 'read',
|
|
@@ -35,9 +34,9 @@ const wrapNames = {
|
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
const gpuShaderStageLib = {
|
|
38
|
-
'vertex': GPUShaderStage
|
|
39
|
-
'fragment': GPUShaderStage
|
|
40
|
-
'compute': GPUShaderStage
|
|
37
|
+
'vertex': GPUShaderStage.VERTEX,
|
|
38
|
+
'fragment': GPUShaderStage.FRAGMENT,
|
|
39
|
+
'compute': GPUShaderStage.COMPUTE
|
|
41
40
|
};
|
|
42
41
|
|
|
43
42
|
const supports = {
|
|
@@ -129,7 +128,13 @@ const wgslMethods = {
|
|
|
129
128
|
equals_bvec3: 'tsl_equals_bvec3',
|
|
130
129
|
equals_bvec4: 'tsl_equals_bvec4',
|
|
131
130
|
inversesqrt: 'inverseSqrt',
|
|
132
|
-
bitcast: 'bitcast<f32>'
|
|
131
|
+
bitcast: 'bitcast<f32>',
|
|
132
|
+
floatpack_snorm_2x16: 'pack2x16snorm',
|
|
133
|
+
floatpack_unorm_2x16: 'pack2x16unorm',
|
|
134
|
+
floatpack_float16_2x16: 'pack2x16float',
|
|
135
|
+
floatunpack_snorm_2x16: 'unpack2x16snorm',
|
|
136
|
+
floatunpack_unorm_2x16: 'unpack2x16unorm',
|
|
137
|
+
floatunpack_float16_2x16: 'unpack2x16float'
|
|
133
138
|
};
|
|
134
139
|
|
|
135
140
|
//
|
|
@@ -286,7 +291,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
286
291
|
*/
|
|
287
292
|
generateWrapFunction( texture ) {
|
|
288
293
|
|
|
289
|
-
const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${ texture.isData3DTexture ? '3d' : '2d' }T`;
|
|
294
|
+
const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${ texture.is3DTexture || texture.isData3DTexture ? '3d' : '2d' }T`;
|
|
290
295
|
|
|
291
296
|
let nodeCode = wgslCodeCache[ functionName ];
|
|
292
297
|
|
|
@@ -295,7 +300,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
295
300
|
const includes = [];
|
|
296
301
|
|
|
297
302
|
// For 3D textures, use vec3f; for texture arrays, keep vec2f since array index is separate
|
|
298
|
-
const coordType = texture.isData3DTexture ? 'vec3f' : 'vec2f';
|
|
303
|
+
const coordType = texture.is3DTexture || texture.isData3DTexture ? 'vec3f' : 'vec2f';
|
|
299
304
|
let code = `fn ${ functionName }( coord : ${ coordType } ) -> ${ coordType } {\n\n\treturn ${ coordType }(\n`;
|
|
300
305
|
|
|
301
306
|
const addWrapSnippet = ( wrap, axis ) => {
|
|
@@ -334,7 +339,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
334
339
|
|
|
335
340
|
addWrapSnippet( texture.wrapT, 'y' );
|
|
336
341
|
|
|
337
|
-
if ( texture.isData3DTexture ) {
|
|
342
|
+
if ( texture.is3DTexture || texture.isData3DTexture ) {
|
|
338
343
|
|
|
339
344
|
code += ',\n';
|
|
340
345
|
addWrapSnippet( texture.wrapR, 'z' );
|
|
@@ -392,7 +397,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
392
397
|
const { primarySamples } = this.renderer.backend.utils.getTextureSampleData( texture );
|
|
393
398
|
const isMultisampled = primarySamples > 1;
|
|
394
399
|
|
|
395
|
-
if ( texture.isData3DTexture ) {
|
|
400
|
+
if ( texture.is3DTexture || texture.isData3DTexture ) {
|
|
396
401
|
|
|
397
402
|
dimensionType = 'vec3<u32>';
|
|
398
403
|
|
|
@@ -418,7 +423,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
418
423
|
|
|
419
424
|
textureData.dimensionsSnippet[ levelSnippet ] = textureDimensionNode;
|
|
420
425
|
|
|
421
|
-
if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
426
|
+
if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.is3DTexture || texture.isData3DTexture ) {
|
|
422
427
|
|
|
423
428
|
textureData.arrayLayerCount = new VarNode(
|
|
424
429
|
new ExpressionNode(
|
|
@@ -488,7 +493,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
488
493
|
const wrapFunction = this.generateWrapFunction( texture );
|
|
489
494
|
const textureDimension = this.generateTextureDimension( texture, textureProperty, levelSnippet );
|
|
490
495
|
|
|
491
|
-
const vecType = texture.isData3DTexture ? 'vec3' : 'vec2';
|
|
496
|
+
const vecType = texture.is3DTexture || texture.isData3DTexture ? 'vec3' : 'vec2';
|
|
492
497
|
|
|
493
498
|
if ( offsetSnippet ) {
|
|
494
499
|
|
|
@@ -797,7 +802,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
797
802
|
const name = node.name;
|
|
798
803
|
const type = node.type;
|
|
799
804
|
|
|
800
|
-
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
805
|
+
if ( type === 'texture' || type === 'cubeTexture' || type === 'cubeDepthTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
801
806
|
|
|
802
807
|
return name;
|
|
803
808
|
|
|
@@ -923,7 +928,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
923
928
|
|
|
924
929
|
const bindings = this.getBindGroupArray( groupName, shaderStage );
|
|
925
930
|
|
|
926
|
-
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
931
|
+
if ( type === 'texture' || type === 'cubeTexture' || type === 'cubeDepthTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
927
932
|
|
|
928
933
|
let texture = null;
|
|
929
934
|
|
|
@@ -941,7 +946,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
941
946
|
|
|
942
947
|
}
|
|
943
948
|
|
|
944
|
-
} else if ( type === 'cubeTexture' ) {
|
|
949
|
+
} else if ( type === 'cubeTexture' || type === 'cubeDepthTexture' ) {
|
|
945
950
|
|
|
946
951
|
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, group, access );
|
|
947
952
|
|
|
@@ -974,10 +979,21 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
974
979
|
|
|
975
980
|
} else if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
|
|
976
981
|
|
|
977
|
-
const
|
|
982
|
+
const sharedData = this.getSharedDataFromNode( node );
|
|
978
983
|
|
|
979
|
-
|
|
980
|
-
|
|
984
|
+
let buffer = sharedData.buffer;
|
|
985
|
+
|
|
986
|
+
if ( buffer === undefined ) {
|
|
987
|
+
|
|
988
|
+
const bufferClass = type === 'buffer' ? NodeUniformBuffer : NodeStorageBuffer;
|
|
989
|
+
|
|
990
|
+
buffer = new bufferClass( node, group );
|
|
991
|
+
|
|
992
|
+
sharedData.buffer = buffer;
|
|
993
|
+
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
buffer.setVisibility( buffer.getVisibility() | gpuShaderStageLib[ shaderStage ] );
|
|
981
997
|
|
|
982
998
|
bindings.push( buffer );
|
|
983
999
|
|
|
@@ -1698,7 +1714,7 @@ ${ flowData.code }
|
|
|
1698
1714
|
const groupName = uniform.groupNode.name;
|
|
1699
1715
|
const uniformIndexes = this.bindingsIndexes[ groupName ];
|
|
1700
1716
|
|
|
1701
|
-
if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
|
|
1717
|
+
if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'cubeDepthTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
|
|
1702
1718
|
|
|
1703
1719
|
const texture = uniform.node.value;
|
|
1704
1720
|
|
|
@@ -1728,7 +1744,11 @@ ${ flowData.code }
|
|
|
1728
1744
|
|
|
1729
1745
|
}
|
|
1730
1746
|
|
|
1731
|
-
if ( texture.isCubeTexture === true ) {
|
|
1747
|
+
if ( texture.isCubeTexture === true && texture.isDepthTexture === true ) {
|
|
1748
|
+
|
|
1749
|
+
textureType = 'texture_depth_cube';
|
|
1750
|
+
|
|
1751
|
+
} else if ( texture.isCubeTexture === true ) {
|
|
1732
1752
|
|
|
1733
1753
|
textureType = 'texture_cube<f32>';
|
|
1734
1754
|
|
|
@@ -1820,9 +1840,7 @@ ${ flowData.code }
|
|
|
1820
1840
|
|
|
1821
1841
|
}
|
|
1822
1842
|
|
|
1823
|
-
|
|
1824
|
-
code += bufferSnippets.join( '\n' );
|
|
1825
|
-
code += structSnippets.join( '\n' );
|
|
1843
|
+
const code = [ ...bindingSnippets, ...bufferSnippets, ...structSnippets ].join( '\n' );
|
|
1826
1844
|
|
|
1827
1845
|
return code;
|
|
1828
1846
|
|
|
@@ -1980,6 +1998,30 @@ ${ flowData.code }
|
|
|
1980
1998
|
|
|
1981
1999
|
}
|
|
1982
2000
|
|
|
2001
|
+
/**
|
|
2002
|
+
* Returns the float packing method name for a given numeric encoding.
|
|
2003
|
+
*
|
|
2004
|
+
* @param {string} encoding - The numeric encoding that describes how the float values are mapped to the integer range.
|
|
2005
|
+
* @returns {string} The resolve WGSL float packing method name.
|
|
2006
|
+
*/
|
|
2007
|
+
getFloatPackingMethod( encoding ) {
|
|
2008
|
+
|
|
2009
|
+
return this.getMethod( `floatpack_${ encoding }_2x16` );
|
|
2010
|
+
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
/**
|
|
2014
|
+
* Returns the float unpacking method name for a given numeric encoding.
|
|
2015
|
+
*
|
|
2016
|
+
* @param {string} encoding - The numeric encoding that describes how the integer values are mapped to the float range.
|
|
2017
|
+
* @returns {string} The resolve WGSL float unpacking method name.
|
|
2018
|
+
*/
|
|
2019
|
+
getFloatUnpackingMethod( encoding ) {
|
|
2020
|
+
|
|
2021
|
+
return this.getMethod( `floatunpack_${ encoding }_2x16` );
|
|
2022
|
+
|
|
2023
|
+
}
|
|
2024
|
+
|
|
1983
2025
|
/**
|
|
1984
2026
|
* Returns the native snippet for a ternary operation.
|
|
1985
2027
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GPUInputStepMode } from './WebGPUConstants.js';
|
|
2
2
|
|
|
3
3
|
import { Float16BufferAttribute } from '../../../core/BufferAttribute.js';
|
|
4
|
-
import { error } from '../../../utils.js';
|
|
4
|
+
import { isTypedArray, error } from '../../../utils.js';
|
|
5
5
|
|
|
6
6
|
const typedArraysToVertexFormatPrefix = new Map( [
|
|
7
7
|
[ Int8Array, [ 'sint8', 'snorm8' ]],
|
|
@@ -174,7 +174,6 @@ class WebGPUAttributeUtils {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
|
|
177
|
-
const isTypedArray = this._isTypedArray( array );
|
|
178
177
|
const updateRanges = bufferAttribute.updateRanges;
|
|
179
178
|
|
|
180
179
|
if ( updateRanges.length === 0 ) {
|
|
@@ -190,7 +189,8 @@ class WebGPUAttributeUtils {
|
|
|
190
189
|
|
|
191
190
|
} else {
|
|
192
191
|
|
|
193
|
-
const
|
|
192
|
+
const isTyped = isTypedArray( array );
|
|
193
|
+
const byteOffsetFactor = isTyped ? 1 : array.BYTES_PER_ELEMENT;
|
|
194
194
|
|
|
195
195
|
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
196
196
|
|
|
@@ -211,7 +211,7 @@ class WebGPUAttributeUtils {
|
|
|
211
211
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
const bufferOffset = dataOffset * (
|
|
214
|
+
const bufferOffset = dataOffset * ( isTyped ? array.BYTES_PER_ELEMENT : 1 ); // bufferOffset is always in bytes
|
|
215
215
|
|
|
216
216
|
device.queue.writeBuffer(
|
|
217
217
|
buffer,
|
|
@@ -415,19 +415,6 @@ class WebGPUAttributeUtils {
|
|
|
415
415
|
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
/**
|
|
419
|
-
* Returns `true` if the given array is a typed array.
|
|
420
|
-
*
|
|
421
|
-
* @private
|
|
422
|
-
* @param {any} array - The array.
|
|
423
|
-
* @return {boolean} Whether the given array is a typed array or not.
|
|
424
|
-
*/
|
|
425
|
-
_isTypedArray( array ) {
|
|
426
|
-
|
|
427
|
-
return ArrayBuffer.isView( array ) && ! ( array instanceof DataView );
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
418
|
/**
|
|
432
419
|
* Utility method for handling interleaved buffer attributes correctly.
|
|
433
420
|
* To process them, their `InterleavedBuffer` is returned.
|