@plastic-software/three 0.179.0 → 0.181.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 +1108 -591
- package/build/three.core.js +616 -345
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +488 -250
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +37 -6
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +6576 -2152
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +6575 -2151
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +8 -8
- package/examples/jsm/controls/DragControls.js +7 -57
- package/examples/jsm/controls/FirstPersonControls.js +3 -3
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -10
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +33 -25
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +9 -2
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +6 -10
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/RectAreaLightTexturesLib.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/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +3 -3
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +14 -8
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +136 -49
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +22 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TTFLoader.js +4 -4
- package/examples/jsm/loaders/UltraHDRLoader.js +2 -2
- 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 +3 -3
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +1 -1
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
- package/examples/jsm/transpiler/TSLEncoder.js +9 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +28 -4
- package/examples/jsm/tsl/display/BloomNode.js +7 -3
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +446 -90
- package/examples/jsm/tsl/display/GTAONode.js +53 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +49 -35
- package/examples/jsm/tsl/display/OutlineNode.js +13 -2
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +182 -65
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +124 -7
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/hashBlur.js +16 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -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/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +4 -2
- package/src/Three.TSL.js +36 -5
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/AnimationClip.js +20 -4
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +7 -6
- package/src/animation/PropertyBinding.js +12 -11
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +10 -10
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +3 -2
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +268 -55
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +8 -8
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +3 -2
- package/src/loaders/ImageBitmapLoader.js +5 -4
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/Loader.js +3 -3
- package/src/loaders/LoadingManager.js +25 -3
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +16 -3
- package/src/materials/MeshBasicMaterial.js +1 -0
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +62 -22
- package/src/materials/nodes/PointsNodeMaterial.js +81 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +3 -2
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +9 -3
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +7 -7
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +68 -66
- package/src/math/Spherical.js +1 -1
- package/src/nodes/Nodes.js +4 -1
- package/src/nodes/TSL.js +4 -1
- 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 +5 -4
- package/src/nodes/accessors/InstanceNode.js +25 -5
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +5 -4
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +18 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +3 -2
- package/src/nodes/accessors/SceneNode.js +2 -1
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +14 -1
- package/src/nodes/accessors/TextureNode.js +130 -44
- package/src/nodes/code/FunctionCallNode.js +24 -4
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +1 -0
- package/src/nodes/core/AssignNode.js +4 -3
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +29 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +40 -7
- package/src/nodes/core/Node.js +152 -31
- package/src/nodes/core/NodeBuilder.js +183 -35
- package/src/nodes/core/NodeFrame.js +21 -21
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +17 -91
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +43 -16
- 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 +18 -10
- package/src/nodes/core/VarNode.js +70 -33
- package/src/nodes/core/VaryingNode.js +3 -2
- package/src/nodes/display/BlendModes.js +5 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/NormalMapNode.js +2 -1
- package/src/nodes/display/PassNode.js +52 -11
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +44 -14
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- 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/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhysicalLightingModel.js +3 -2
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +17 -5
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +6 -6
- package/src/nodes/lighting/LightsNode.js +3 -4
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ShadowFilterNode.js +2 -0
- package/src/nodes/lighting/ShadowNode.js +75 -8
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +24 -7
- package/src/nodes/math/MathNode.js +25 -19
- package/src/nodes/math/OperatorNode.js +7 -5
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +5 -2
- package/src/nodes/tsl/TSLCore.js +460 -159
- package/src/nodes/utils/DebugNode.js +2 -1
- package/src/nodes/utils/EventNode.js +36 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +20 -24
- package/src/nodes/utils/MemberNode.js +59 -7
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +13 -3
- package/src/nodes/utils/ReflectorNode.js +58 -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/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +4 -3
- package/src/renderers/WebGLRenderer.js +48 -41
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +108 -27
- package/src/renderers/common/Background.js +2 -1
- package/src/renderers/common/Bindings.js +58 -2
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +6 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +16 -2
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +473 -245
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +9 -1
- package/src/renderers/common/Sampler.js +50 -12
- package/src/renderers/common/StorageTexture.js +9 -1
- package/src/renderers/common/Textures.js +121 -45
- package/src/renderers/common/TimestampQueryPool.js +65 -3
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +42 -22
- package/src/renderers/common/extras/PMREMGenerator.js +160 -65
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +9 -7
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- 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/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLCapabilities.js +2 -1
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +15 -14
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -2
- package/src/renderers/webgl/WebGLState.js +15 -14
- package/src/renderers/webgl/WebGLTextures.js +19 -14
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +199 -167
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +181 -25
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +7 -6
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +169 -19
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +51 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +153 -123
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +142 -50
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +53 -34
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +260 -99
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +32 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
- package/src/renderers/webxr/WebXRManager.js +42 -26
- package/src/textures/ExternalTexture.js +15 -4
- package/src/textures/Source.js +3 -2
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +2 -3
- package/src/utils.js +67 -3
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -5,6 +5,7 @@ import { Color } from '../../math/Color.js';
|
|
|
5
5
|
*
|
|
6
6
|
* If not state object is provided, the function creates one.
|
|
7
7
|
*
|
|
8
|
+
* @private
|
|
8
9
|
* @function
|
|
9
10
|
* @param {Renderer} renderer - The renderer.
|
|
10
11
|
* @param {Object} [state={}] - The state.
|
|
@@ -36,6 +37,7 @@ export function saveRendererState( renderer, state = {} ) {
|
|
|
36
37
|
*
|
|
37
38
|
* If not state object is provided, the function creates one.
|
|
38
39
|
*
|
|
40
|
+
* @private
|
|
39
41
|
* @function
|
|
40
42
|
* @param {Renderer} renderer - The renderer.
|
|
41
43
|
* @param {Object} [state={}] - The state.
|
|
@@ -57,6 +59,7 @@ export function resetRendererState( renderer, state ) {
|
|
|
57
59
|
/**
|
|
58
60
|
* Restores the state of the given renderer from the given state object.
|
|
59
61
|
*
|
|
62
|
+
* @private
|
|
60
63
|
* @function
|
|
61
64
|
* @param {Renderer} renderer - The renderer.
|
|
62
65
|
* @param {Object} state - The state to restore.
|
|
@@ -81,6 +84,7 @@ export function restoreRendererState( renderer, state ) {
|
|
|
81
84
|
*
|
|
82
85
|
* If not state object is provided, the function creates one.
|
|
83
86
|
*
|
|
87
|
+
* @private
|
|
84
88
|
* @function
|
|
85
89
|
* @param {Scene} scene - The scene.
|
|
86
90
|
* @param {Object} [state={}] - The state.
|
|
@@ -102,6 +106,7 @@ export function saveSceneState( scene, state = {} ) {
|
|
|
102
106
|
*
|
|
103
107
|
* If not state object is provided, the function creates one.
|
|
104
108
|
*
|
|
109
|
+
* @private
|
|
105
110
|
* @function
|
|
106
111
|
* @param {Scene} scene - The scene.
|
|
107
112
|
* @param {Object} [state={}] - The state.
|
|
@@ -122,6 +127,7 @@ export function resetSceneState( scene, state ) {
|
|
|
122
127
|
/**
|
|
123
128
|
* Restores the state of the given scene from the given state object.
|
|
124
129
|
*
|
|
130
|
+
* @private
|
|
125
131
|
* @function
|
|
126
132
|
* @param {Scene} scene - The scene.
|
|
127
133
|
* @param {Object} state - The state to restore.
|
|
@@ -139,6 +145,7 @@ export function restoreSceneState( scene, state ) {
|
|
|
139
145
|
*
|
|
140
146
|
* If not state object is provided, the function creates one.
|
|
141
147
|
*
|
|
148
|
+
* @private
|
|
142
149
|
* @function
|
|
143
150
|
* @param {Renderer} renderer - The renderer.
|
|
144
151
|
* @param {Scene} scene - The scene.
|
|
@@ -160,6 +167,7 @@ export function saveRendererAndSceneState( renderer, scene, state = {} ) {
|
|
|
160
167
|
*
|
|
161
168
|
* If not state object is provided, the function creates one.
|
|
162
169
|
*
|
|
170
|
+
* @private
|
|
163
171
|
* @function
|
|
164
172
|
* @param {Renderer} renderer - The renderer.
|
|
165
173
|
* @param {Scene} scene - The scene.
|
|
@@ -178,6 +186,7 @@ export function resetRendererAndSceneState( renderer, scene, state ) {
|
|
|
178
186
|
/**
|
|
179
187
|
* Restores the state of the given renderer and scene from the given state object.
|
|
180
188
|
*
|
|
189
|
+
* @private
|
|
181
190
|
* @function
|
|
182
191
|
* @param {Renderer} renderer - The renderer.
|
|
183
192
|
* @param {Scene} scene - The scene.
|
|
@@ -6,7 +6,7 @@ let _id = 0;
|
|
|
6
6
|
* Represents a sampled texture binding type.
|
|
7
7
|
*
|
|
8
8
|
* @private
|
|
9
|
-
* @augments
|
|
9
|
+
* @augments Sampler
|
|
10
10
|
*/
|
|
11
11
|
class SampledTexture extends Sampler {
|
|
12
12
|
|
|
@@ -35,6 +35,14 @@ class SampledTexture extends Sampler {
|
|
|
35
35
|
*/
|
|
36
36
|
this.store = false;
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The mip level to bind for storage textures.
|
|
40
|
+
*
|
|
41
|
+
* @type {number}
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
44
|
+
this.mipLevel = 0;
|
|
45
|
+
|
|
38
46
|
/**
|
|
39
47
|
* This flag can be used for type testing.
|
|
40
48
|
*
|
|
@@ -19,21 +19,27 @@ class Sampler extends Binding {
|
|
|
19
19
|
super( name );
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* The texture the sampler is referring to.
|
|
23
|
+
*
|
|
24
24
|
* @private
|
|
25
|
+
* @type {?Texture}
|
|
25
26
|
*/
|
|
26
|
-
this.
|
|
27
|
-
|
|
28
|
-
this.texture = null;
|
|
29
|
-
|
|
30
|
-
};
|
|
27
|
+
this._texture = null;
|
|
31
28
|
|
|
32
29
|
/**
|
|
33
|
-
*
|
|
30
|
+
* An event listener which is added to {@link texture}'s dispose event.
|
|
34
31
|
*
|
|
35
|
-
* @
|
|
32
|
+
* @private
|
|
33
|
+
* @type {Function}
|
|
36
34
|
*/
|
|
35
|
+
this._onTextureDispose = () => {
|
|
36
|
+
|
|
37
|
+
this.generation = null;
|
|
38
|
+
this.version = 0;
|
|
39
|
+
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Assignment to the texture via a setter must occur after "_onTextureDispose" is initialized.
|
|
37
43
|
this.texture = texture;
|
|
38
44
|
|
|
39
45
|
/**
|
|
@@ -52,6 +58,14 @@ class Sampler extends Binding {
|
|
|
52
58
|
*/
|
|
53
59
|
this.generation = null;
|
|
54
60
|
|
|
61
|
+
/**
|
|
62
|
+
* The binding's sampler key.
|
|
63
|
+
*
|
|
64
|
+
* @type {string}
|
|
65
|
+
* @default ''
|
|
66
|
+
*/
|
|
67
|
+
this.samplerKey = '';
|
|
68
|
+
|
|
55
69
|
/**
|
|
56
70
|
* This flag can be used for type testing.
|
|
57
71
|
*
|
|
@@ -65,7 +79,8 @@ class Sampler extends Binding {
|
|
|
65
79
|
|
|
66
80
|
/**
|
|
67
81
|
* Sets the texture of this sampler.
|
|
68
|
-
*
|
|
82
|
+
*
|
|
83
|
+
* @param {Texture} value - The texture to set.
|
|
69
84
|
*/
|
|
70
85
|
set texture( value ) {
|
|
71
86
|
|
|
@@ -73,7 +88,7 @@ class Sampler extends Binding {
|
|
|
73
88
|
|
|
74
89
|
if ( this._texture ) {
|
|
75
90
|
|
|
76
|
-
this._texture.removeEventListener( 'dispose', this.
|
|
91
|
+
this._texture.removeEventListener( 'dispose', this._onTextureDispose );
|
|
77
92
|
|
|
78
93
|
}
|
|
79
94
|
|
|
@@ -84,7 +99,7 @@ class Sampler extends Binding {
|
|
|
84
99
|
|
|
85
100
|
if ( this._texture ) {
|
|
86
101
|
|
|
87
|
-
this._texture.addEventListener( 'dispose', this.
|
|
102
|
+
this._texture.addEventListener( 'dispose', this._onTextureDispose );
|
|
88
103
|
|
|
89
104
|
}
|
|
90
105
|
|
|
@@ -122,6 +137,29 @@ class Sampler extends Binding {
|
|
|
122
137
|
|
|
123
138
|
}
|
|
124
139
|
|
|
140
|
+
|
|
141
|
+
clone() {
|
|
142
|
+
|
|
143
|
+
const clonedSampler = super.clone();
|
|
144
|
+
|
|
145
|
+
// fix dispose handler for cloned instances
|
|
146
|
+
// TODO: Find better solution, see #31747
|
|
147
|
+
|
|
148
|
+
clonedSampler._texture = null;
|
|
149
|
+
|
|
150
|
+
clonedSampler._onTextureDispose = () => {
|
|
151
|
+
|
|
152
|
+
clonedSampler.generation = null;
|
|
153
|
+
clonedSampler.version = 0;
|
|
154
|
+
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
clonedSampler.texture = this.texture;
|
|
158
|
+
|
|
159
|
+
return clonedSampler;
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
125
163
|
}
|
|
126
164
|
|
|
127
165
|
export default Sampler;
|
|
@@ -52,8 +52,16 @@ class StorageTexture extends Texture {
|
|
|
52
52
|
*/
|
|
53
53
|
this.isStorageTexture = true;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* When `true`, mipmaps will be auto-generated after compute writes.
|
|
57
|
+
* When `false`, mipmaps must be written manually via compute shaders.
|
|
58
|
+
*
|
|
59
|
+
* @type {boolean}
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
this.mipmapsAutoUpdate = true;
|
|
56
63
|
|
|
64
|
+
}
|
|
57
65
|
/**
|
|
58
66
|
* Sets the size of the storage texture.
|
|
59
67
|
*
|
|
@@ -2,7 +2,9 @@ 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';
|
|
7
|
+
import { warn } from '../../utils.js';
|
|
6
8
|
|
|
7
9
|
const _size = /*@__PURE__*/ new Vector3();
|
|
8
10
|
|
|
@@ -83,6 +85,7 @@ class Textures extends DataMap {
|
|
|
83
85
|
depthTexture.image.width = mipWidth;
|
|
84
86
|
depthTexture.image.height = mipHeight;
|
|
85
87
|
depthTexture.image.depth = size.depth;
|
|
88
|
+
depthTexture.renderTarget = renderTarget;
|
|
86
89
|
depthTexture.isArrayTexture = renderTarget.multiview === true && size.depth > 1;
|
|
87
90
|
|
|
88
91
|
depthTextureMips[ activeMipmapLevel ] = depthTexture;
|
|
@@ -161,27 +164,13 @@ class Textures extends DataMap {
|
|
|
161
164
|
|
|
162
165
|
// dispose
|
|
163
166
|
|
|
164
|
-
|
|
167
|
+
renderTargetData.onDispose = () => {
|
|
165
168
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
for ( let i = 0; i < textures.length; i ++ ) {
|
|
169
|
-
|
|
170
|
-
this._destroyTexture( textures[ i ] );
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if ( depthTexture ) {
|
|
175
|
-
|
|
176
|
-
this._destroyTexture( depthTexture );
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
this.delete( renderTarget );
|
|
169
|
+
this._destroyRenderTarget( renderTarget );
|
|
181
170
|
|
|
182
171
|
};
|
|
183
172
|
|
|
184
|
-
renderTarget.addEventListener( 'dispose', onDispose );
|
|
173
|
+
renderTarget.addEventListener( 'dispose', renderTargetData.onDispose );
|
|
185
174
|
|
|
186
175
|
}
|
|
187
176
|
|
|
@@ -207,7 +196,6 @@ class Textures extends DataMap {
|
|
|
207
196
|
|
|
208
197
|
// it's an update
|
|
209
198
|
|
|
210
|
-
backend.destroySampler( texture );
|
|
211
199
|
backend.destroyTexture( texture );
|
|
212
200
|
|
|
213
201
|
}
|
|
@@ -240,32 +228,33 @@ class Textures extends DataMap {
|
|
|
240
228
|
options.needsMipmaps = this.needsMipmaps( texture );
|
|
241
229
|
options.levels = options.needsMipmaps ? this.getMipLevels( texture, width, height ) : 1;
|
|
242
230
|
|
|
231
|
+
// TODO: Uniformly handle mipmap definitions
|
|
232
|
+
// Normal textures and compressed cube textures define base level + mips with their mipmap array
|
|
233
|
+
// Uncompressed cube textures use their mipmap array only for mips (no base level)
|
|
234
|
+
|
|
235
|
+
if ( texture.isCubeTexture && texture.mipmaps.length > 0 ) options.levels ++;
|
|
236
|
+
|
|
243
237
|
//
|
|
244
238
|
|
|
245
|
-
if ( isRenderTarget || texture.isStorageTexture === true ) {
|
|
239
|
+
if ( isRenderTarget || texture.isStorageTexture === true || texture.isExternalTexture === true ) {
|
|
246
240
|
|
|
247
|
-
backend.createSampler( texture );
|
|
248
241
|
backend.createTexture( texture, options );
|
|
249
242
|
|
|
250
243
|
textureData.generation = texture.version;
|
|
251
244
|
|
|
252
245
|
} else {
|
|
253
246
|
|
|
254
|
-
const needsCreate = textureData.initialized !== true;
|
|
255
|
-
|
|
256
|
-
if ( needsCreate ) backend.createSampler( texture );
|
|
257
|
-
|
|
258
247
|
if ( texture.version > 0 ) {
|
|
259
248
|
|
|
260
249
|
const image = texture.image;
|
|
261
250
|
|
|
262
251
|
if ( image === undefined ) {
|
|
263
252
|
|
|
264
|
-
|
|
253
|
+
warn( 'Renderer: Texture marked for update but image is undefined.' );
|
|
265
254
|
|
|
266
255
|
} else if ( image.complete === false ) {
|
|
267
256
|
|
|
268
|
-
|
|
257
|
+
warn( 'Renderer: Texture marked for update but image is incomplete.' );
|
|
269
258
|
|
|
270
259
|
} else {
|
|
271
260
|
|
|
@@ -298,7 +287,15 @@ class Textures extends DataMap {
|
|
|
298
287
|
|
|
299
288
|
if ( texture.source.dataReady === true ) backend.updateTexture( texture, options );
|
|
300
289
|
|
|
301
|
-
|
|
290
|
+
const skipAutoGeneration = texture.isStorageTexture === true && texture.mipmapsAutoUpdate === false;
|
|
291
|
+
|
|
292
|
+
if ( options.needsMipmaps && texture.mipmaps.length === 0 && ! skipAutoGeneration ) {
|
|
293
|
+
|
|
294
|
+
backend.generateMipmaps( texture );
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if ( texture.onUpdate ) texture.onUpdate( texture );
|
|
302
299
|
|
|
303
300
|
}
|
|
304
301
|
|
|
@@ -326,17 +323,23 @@ class Textures extends DataMap {
|
|
|
326
323
|
|
|
327
324
|
this.info.memory.textures ++;
|
|
328
325
|
|
|
329
|
-
//
|
|
326
|
+
//
|
|
327
|
+
|
|
328
|
+
if ( texture.isVideoTexture && ColorManagement.getTransfer( texture.colorSpace ) !== SRGBTransfer ) {
|
|
330
329
|
|
|
331
|
-
|
|
330
|
+
warn( 'WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.' );
|
|
332
331
|
|
|
333
|
-
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// dispose
|
|
335
|
+
|
|
336
|
+
textureData.onDispose = () => {
|
|
334
337
|
|
|
335
338
|
this._destroyTexture( texture );
|
|
336
339
|
|
|
337
340
|
};
|
|
338
341
|
|
|
339
|
-
texture.addEventListener( 'dispose', onDispose );
|
|
342
|
+
texture.addEventListener( 'dispose', textureData.onDispose );
|
|
340
343
|
|
|
341
344
|
}
|
|
342
345
|
|
|
@@ -346,6 +349,24 @@ class Textures extends DataMap {
|
|
|
346
349
|
|
|
347
350
|
}
|
|
348
351
|
|
|
352
|
+
/**
|
|
353
|
+
* Updates the sampler for the given texture. This method has no effect
|
|
354
|
+
* for the WebGL backend since it has no concept of samplers. Texture
|
|
355
|
+
* parameters are configured with the `texParameter()` command for each
|
|
356
|
+
* texture.
|
|
357
|
+
*
|
|
358
|
+
* In WebGPU, samplers are objects like textures and it's possible to share
|
|
359
|
+
* them when the texture parameters match.
|
|
360
|
+
*
|
|
361
|
+
* @param {Texture} texture - The texture to update the sampler for.
|
|
362
|
+
* @return {string} The current sampler key.
|
|
363
|
+
*/
|
|
364
|
+
updateSampler( texture ) {
|
|
365
|
+
|
|
366
|
+
return this.backend.updateSampler( texture );
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
349
370
|
/**
|
|
350
371
|
* Computes the size of the given texture and writes the result
|
|
351
372
|
* into the target vector. This vector is also returned by the
|
|
@@ -366,13 +387,13 @@ class Textures extends DataMap {
|
|
|
366
387
|
|
|
367
388
|
if ( image.image !== undefined ) image = image.image;
|
|
368
389
|
|
|
369
|
-
if ( image instanceof HTMLVideoElement ) {
|
|
390
|
+
if ( ( typeof HTMLVideoElement !== 'undefined' ) && ( image instanceof HTMLVideoElement ) ) {
|
|
370
391
|
|
|
371
392
|
target.width = image.videoWidth || 1;
|
|
372
393
|
target.height = image.videoHeight || 1;
|
|
373
394
|
target.depth = 1;
|
|
374
395
|
|
|
375
|
-
} else if ( image instanceof VideoFrame ) {
|
|
396
|
+
} else if ( ( typeof VideoFrame !== 'undefined' ) && ( image instanceof VideoFrame ) ) {
|
|
376
397
|
|
|
377
398
|
target.width = image.displayWidth || 1;
|
|
378
399
|
target.height = image.displayHeight || 1;
|
|
@@ -408,21 +429,25 @@ class Textures extends DataMap {
|
|
|
408
429
|
|
|
409
430
|
let mipLevelCount;
|
|
410
431
|
|
|
411
|
-
if ( texture.
|
|
432
|
+
if ( texture.mipmaps.length > 0 ) {
|
|
412
433
|
|
|
413
|
-
|
|
434
|
+
mipLevelCount = texture.mipmaps.length;
|
|
414
435
|
|
|
415
|
-
|
|
436
|
+
} else {
|
|
416
437
|
|
|
417
|
-
|
|
438
|
+
if ( texture.isCompressedTexture === true ) {
|
|
439
|
+
|
|
440
|
+
// it is not possible to compute mipmaps for compressed textures. So
|
|
441
|
+
// when no mipmaps are defined in "texture.mipmaps", force a texture
|
|
442
|
+
// level of 1
|
|
418
443
|
|
|
419
444
|
mipLevelCount = 1;
|
|
420
445
|
|
|
421
|
-
}
|
|
446
|
+
} else {
|
|
422
447
|
|
|
423
|
-
|
|
448
|
+
mipLevelCount = Math.floor( Math.log2( Math.max( width, height ) ) ) + 1;
|
|
424
449
|
|
|
425
|
-
|
|
450
|
+
}
|
|
426
451
|
|
|
427
452
|
}
|
|
428
453
|
|
|
@@ -431,14 +456,54 @@ class Textures extends DataMap {
|
|
|
431
456
|
}
|
|
432
457
|
|
|
433
458
|
/**
|
|
434
|
-
* Returns `true` if the given texture
|
|
459
|
+
* Returns `true` if the given texture makes use of mipmapping.
|
|
435
460
|
*
|
|
436
461
|
* @param {Texture} texture - The texture.
|
|
437
462
|
* @return {boolean} Whether mipmaps are required or not.
|
|
438
463
|
*/
|
|
439
464
|
needsMipmaps( texture ) {
|
|
440
465
|
|
|
441
|
-
return texture.
|
|
466
|
+
return texture.generateMipmaps === true || texture.mipmaps.length > 0;
|
|
467
|
+
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Frees internal resources when the given render target isn't
|
|
472
|
+
* required anymore.
|
|
473
|
+
*
|
|
474
|
+
* @param {RenderTarget} renderTarget - The render target to destroy.
|
|
475
|
+
*/
|
|
476
|
+
_destroyRenderTarget( renderTarget ) {
|
|
477
|
+
|
|
478
|
+
if ( this.has( renderTarget ) === true ) {
|
|
479
|
+
|
|
480
|
+
const renderTargetData = this.get( renderTarget );
|
|
481
|
+
|
|
482
|
+
const textures = renderTargetData.textures;
|
|
483
|
+
const depthTexture = renderTargetData.depthTexture;
|
|
484
|
+
|
|
485
|
+
//
|
|
486
|
+
|
|
487
|
+
renderTarget.removeEventListener( 'dispose', renderTargetData.onDispose );
|
|
488
|
+
|
|
489
|
+
//
|
|
490
|
+
|
|
491
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
492
|
+
|
|
493
|
+
this._destroyTexture( textures[ i ] );
|
|
494
|
+
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if ( depthTexture ) {
|
|
498
|
+
|
|
499
|
+
this._destroyTexture( depthTexture );
|
|
500
|
+
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
this.delete( renderTarget );
|
|
504
|
+
this.backend.delete( renderTarget );
|
|
505
|
+
|
|
506
|
+
}
|
|
442
507
|
|
|
443
508
|
}
|
|
444
509
|
|
|
@@ -452,8 +517,19 @@ class Textures extends DataMap {
|
|
|
452
517
|
|
|
453
518
|
if ( this.has( texture ) === true ) {
|
|
454
519
|
|
|
455
|
-
this.
|
|
456
|
-
|
|
520
|
+
const textureData = this.get( texture );
|
|
521
|
+
|
|
522
|
+
//
|
|
523
|
+
|
|
524
|
+
texture.removeEventListener( 'dispose', textureData.onDispose );
|
|
525
|
+
|
|
526
|
+
// if a texture is not ready for use, it falls back to a default texture so it's possible
|
|
527
|
+
// to use it for rendering. If a texture in this state is disposed, it's important to
|
|
528
|
+
// not destroy/delete the underlying GPU texture object since it is cached and shared with
|
|
529
|
+
// other textures.
|
|
530
|
+
|
|
531
|
+
const isDefaultTexture = textureData.isDefaultTexture;
|
|
532
|
+
this.backend.destroyTexture( texture, isDefaultTexture );
|
|
457
533
|
|
|
458
534
|
this.delete( texture );
|
|
459
535
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { warn } from '../../utils.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Abstract base class of a timestamp query pool.
|
|
3
5
|
*
|
|
@@ -59,6 +61,13 @@ class TimestampQueryPool {
|
|
|
59
61
|
*/
|
|
60
62
|
this.lastValue = 0;
|
|
61
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Stores all timestamp frames.
|
|
66
|
+
*
|
|
67
|
+
* @type {Array<number>}
|
|
68
|
+
*/
|
|
69
|
+
this.frames = [];
|
|
70
|
+
|
|
62
71
|
/**
|
|
63
72
|
* TODO
|
|
64
73
|
*
|
|
@@ -67,16 +76,69 @@ class TimestampQueryPool {
|
|
|
67
76
|
*/
|
|
68
77
|
this.pendingResolve = false;
|
|
69
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Stores the latest timestamp for each render context.
|
|
81
|
+
*
|
|
82
|
+
* @type {Map<string, number>}
|
|
83
|
+
*/
|
|
84
|
+
this.timestamps = new Map();
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns all timestamp frames.
|
|
90
|
+
*
|
|
91
|
+
* @return {Array<number>} The timestamp frames.
|
|
92
|
+
*/
|
|
93
|
+
getTimestampFrames() {
|
|
94
|
+
|
|
95
|
+
return this.frames;
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Returns the timestamp for a given render context.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} uid - A unique identifier for the render context.
|
|
103
|
+
* @return {?number} The timestamp, or undefined if not available.
|
|
104
|
+
*/
|
|
105
|
+
getTimestamp( uid ) {
|
|
106
|
+
|
|
107
|
+
let timestamp = this.timestamps.get( uid );
|
|
108
|
+
|
|
109
|
+
if ( timestamp === undefined ) {
|
|
110
|
+
|
|
111
|
+
warn( `TimestampQueryPool: No timestamp available for uid ${ uid }.` );
|
|
112
|
+
|
|
113
|
+
timestamp = 0;
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return timestamp;
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Returns whether a timestamp is available for a given render context.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} uid - A unique identifier for the render context.
|
|
125
|
+
* @return {boolean} True if a timestamp is available, false otherwise.
|
|
126
|
+
*/
|
|
127
|
+
hasTimestamp( uid ) {
|
|
128
|
+
|
|
129
|
+
return this.timestamps.has( uid );
|
|
130
|
+
|
|
70
131
|
}
|
|
71
132
|
|
|
72
133
|
/**
|
|
73
|
-
* Allocate queries for a specific
|
|
134
|
+
* Allocate queries for a specific uid.
|
|
74
135
|
*
|
|
75
136
|
* @abstract
|
|
76
|
-
* @param {
|
|
137
|
+
* @param {string} uid - A unique identifier for the render context.
|
|
138
|
+
* @param {number} frameId - The current frame identifier.
|
|
77
139
|
* @returns {?number}
|
|
78
140
|
*/
|
|
79
|
-
allocateQueriesForContext( /*
|
|
141
|
+
allocateQueriesForContext( /* uid, frameId */ ) {}
|
|
80
142
|
|
|
81
143
|
/**
|
|
82
144
|
* Resolve all timestamps and return data (or process them).
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import UniformBuffer from './UniformBuffer.js';
|
|
2
2
|
import { GPU_CHUNK_BYTES } from './Constants.js';
|
|
3
|
+
import { error } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This class represents a uniform buffer binding but with
|
|
@@ -208,7 +209,7 @@ class UniformsGroup extends UniformBuffer {
|
|
|
208
209
|
if ( uniform.isMatrix3Uniform ) return this.updateMatrix3( uniform );
|
|
209
210
|
if ( uniform.isMatrix4Uniform ) return this.updateMatrix4( uniform );
|
|
210
211
|
|
|
211
|
-
|
|
212
|
+
error( 'WebGPUUniformsGroup: Unsupported uniform type.', uniform );
|
|
212
213
|
|
|
213
214
|
}
|
|
214
215
|
|