super-three 0.177.0 → 0.181.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 +1994 -749
- package/build/three.core.js +1358 -506
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +631 -247
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +113 -33
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +9571 -3424
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +9397 -3426
- 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 +2 -3
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +0 -27
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +9 -9
- 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 +62 -15
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- 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 +683 -299
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- 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 +11 -13
- 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/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- 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 +4 -4
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +4 -4
- 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 +233 -34
- 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 +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/UltraHDRLoader.js +2 -2
- 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 +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/LensflareMesh.js +3 -3
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/physics/RapierPhysics.js +95 -16
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- 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/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 +11 -2
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +247 -104
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +196 -92
- package/examples/jsm/transpiler/Transpiler.js +17 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +812 -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 +11 -6
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- 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 +55 -43
- package/examples/jsm/tsl/display/OutlineNode.js +13 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -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 +578 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/hashBlur.js +18 -20
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +22 -2
- 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 +5 -2
- package/src/Three.TSL.js +112 -32
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +4 -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 +8 -7
- package/src/animation/PropertyBinding.js +12 -11
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +2 -2
- package/src/cameras/PerspectiveCamera.js +2 -2
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +13 -5
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/BufferGeometry.js +10 -10
- package/src/core/Clock.js +2 -8
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +4 -3
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- 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 +279 -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/Path.js +22 -22
- 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 +42 -12
- 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/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 +29 -5
- package/src/loaders/ImageBitmapLoader.js +32 -8
- package/src/loaders/ImageLoader.js +56 -9
- package/src/loaders/Loader.js +17 -3
- package/src/loaders/LoadingManager.js +45 -0
- 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 +2 -1
- 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 -10
- package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +3 -3
- package/src/materials/nodes/NodeMaterial.js +90 -27
- package/src/materials/nodes/PointsNodeMaterial.js +86 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +89 -3
- 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/Frustum.js +25 -9
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- 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 +55 -34
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +69 -67
- package/src/math/Spherical.js +3 -3
- package/src/nodes/Nodes.js +6 -4
- package/src/nodes/TSL.js +9 -4
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +31 -25
- 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 +5 -4
- package/src/nodes/accessors/InstanceNode.js +25 -5
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +97 -30
- package/src/nodes/accessors/Object3DNode.js +2 -2
- package/src/nodes/accessors/Position.js +25 -9
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +20 -4
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +3 -2
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +23 -1
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +14 -1
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +142 -44
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/code/FunctionCallNode.js +24 -4
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +13 -0
- package/src/nodes/core/AssignNode.js +6 -2
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +48 -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} +36 -17
- package/src/nodes/core/Node.js +167 -34
- package/src/nodes/core/NodeBuilder.js +404 -120
- 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 -88
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +77 -30
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +80 -14
- package/src/nodes/core/VarNode.js +142 -16
- package/src/nodes/core/VaryingNode.js +9 -6
- package/src/nodes/display/BlendModes.js +7 -6
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/FrontFacingNode.js +35 -7
- package/src/nodes/display/NormalMapNode.js +20 -50
- package/src/nodes/display/PassNode.js +206 -17
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +44 -40
- 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 +94 -4
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +19 -18
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +81 -25
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +29 -3
- package/src/nodes/lighting/EnvironmentNode.js +11 -11
- package/src/nodes/lighting/LightsNode.js +7 -8
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +3 -1
- package/src/nodes/lighting/ShadowNode.js +77 -10
- 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 +25 -27
- package/src/nodes/math/MathNode.js +106 -65
- package/src/nodes/math/OperatorNode.js +28 -43
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +6 -2
- package/src/nodes/tsl/TSLCore.js +546 -186
- package/src/nodes/utils/DebugNode.js +3 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +119 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +20 -41
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MemberNode.js +59 -7
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +33 -6
- package/src/nodes/utils/ReflectorNode.js +68 -10
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +6 -4
- 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 +77 -66
- 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 +4 -3
- package/src/renderers/common/Bindings.js +76 -19
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.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 +61 -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 +84 -5
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +486 -255
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +8 -68
- package/src/renderers/common/Sampler.js +117 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +27 -0
- package/src/renderers/common/Textures.js +138 -46
- package/src/renderers/common/TimestampQueryPool.js +65 -3
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +63 -24
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +161 -66
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +9 -7
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- 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 +21 -11
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +4 -3
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +25 -18
- package/src/renderers/webgl/WebGLPrograms.js +9 -6
- package/src/renderers/webgl/WebGLShadowMap.js +13 -2
- package/src/renderers/webgl/WebGLState.js +17 -16
- package/src/renderers/webgl/WebGLTextures.js +38 -21
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +245 -182
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +184 -30
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +9 -8
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +171 -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 +205 -128
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +198 -121
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +8 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +49 -33
- package/src/renderers/webgpu/utils/WebGPUConstants.js +14 -3
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -37
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +266 -158
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +32 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +24 -19
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +89 -13
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +14 -3
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +29 -2
- package/src/utils.js +67 -3
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
- package/examples/jsm/tsl/display/TRAAPassNode.js +0 -452
- package/src/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -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
|
+
//
|
|
330
327
|
|
|
331
|
-
|
|
328
|
+
if ( texture.isVideoTexture && ColorManagement.getTransfer( texture.colorSpace ) !== SRGBTransfer ) {
|
|
332
329
|
|
|
333
|
-
|
|
330
|
+
warn( 'WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.' );
|
|
331
|
+
|
|
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,9 +387,25 @@ class Textures extends DataMap {
|
|
|
366
387
|
|
|
367
388
|
if ( image.image !== undefined ) image = image.image;
|
|
368
389
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
390
|
+
if ( ( typeof HTMLVideoElement !== 'undefined' ) && ( image instanceof HTMLVideoElement ) ) {
|
|
391
|
+
|
|
392
|
+
target.width = image.videoWidth || 1;
|
|
393
|
+
target.height = image.videoHeight || 1;
|
|
394
|
+
target.depth = 1;
|
|
395
|
+
|
|
396
|
+
} else if ( ( typeof VideoFrame !== 'undefined' ) && ( image instanceof VideoFrame ) ) {
|
|
397
|
+
|
|
398
|
+
target.width = image.displayWidth || 1;
|
|
399
|
+
target.height = image.displayHeight || 1;
|
|
400
|
+
target.depth = 1;
|
|
401
|
+
|
|
402
|
+
} else {
|
|
403
|
+
|
|
404
|
+
target.width = image.width || 1;
|
|
405
|
+
target.height = image.height || 1;
|
|
406
|
+
target.depth = texture.isCubeTexture ? 6 : ( image.depth || 1 );
|
|
407
|
+
|
|
408
|
+
}
|
|
372
409
|
|
|
373
410
|
} else {
|
|
374
411
|
|
|
@@ -392,21 +429,25 @@ class Textures extends DataMap {
|
|
|
392
429
|
|
|
393
430
|
let mipLevelCount;
|
|
394
431
|
|
|
395
|
-
if ( texture.
|
|
432
|
+
if ( texture.mipmaps.length > 0 ) {
|
|
396
433
|
|
|
397
|
-
|
|
434
|
+
mipLevelCount = texture.mipmaps.length;
|
|
398
435
|
|
|
399
|
-
|
|
436
|
+
} else {
|
|
400
437
|
|
|
401
|
-
|
|
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
|
|
402
443
|
|
|
403
444
|
mipLevelCount = 1;
|
|
404
445
|
|
|
405
|
-
}
|
|
446
|
+
} else {
|
|
406
447
|
|
|
407
|
-
|
|
448
|
+
mipLevelCount = Math.floor( Math.log2( Math.max( width, height ) ) ) + 1;
|
|
408
449
|
|
|
409
|
-
|
|
450
|
+
}
|
|
410
451
|
|
|
411
452
|
}
|
|
412
453
|
|
|
@@ -415,14 +456,54 @@ class Textures extends DataMap {
|
|
|
415
456
|
}
|
|
416
457
|
|
|
417
458
|
/**
|
|
418
|
-
* Returns `true` if the given texture
|
|
459
|
+
* Returns `true` if the given texture makes use of mipmapping.
|
|
419
460
|
*
|
|
420
461
|
* @param {Texture} texture - The texture.
|
|
421
462
|
* @return {boolean} Whether mipmaps are required or not.
|
|
422
463
|
*/
|
|
423
464
|
needsMipmaps( texture ) {
|
|
424
465
|
|
|
425
|
-
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
|
+
}
|
|
426
507
|
|
|
427
508
|
}
|
|
428
509
|
|
|
@@ -436,8 +517,19 @@ class Textures extends DataMap {
|
|
|
436
517
|
|
|
437
518
|
if ( this.has( texture ) === true ) {
|
|
438
519
|
|
|
439
|
-
this.
|
|
440
|
-
|
|
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 );
|
|
441
533
|
|
|
442
534
|
this.delete( texture );
|
|
443
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
|
|
|
@@ -16,6 +16,7 @@ import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
|
16
16
|
import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
|
|
17
17
|
import { MeshBasicMaterial } from '../../materials/MeshBasicMaterial.js';
|
|
18
18
|
import { Mesh } from '../../objects/Mesh.js';
|
|
19
|
+
import { warn } from '../../utils.js';
|
|
19
20
|
|
|
20
21
|
const _cameraLPos = /*@__PURE__*/ new Vector3();
|
|
21
22
|
const _cameraRPos = /*@__PURE__*/ new Vector3();
|
|
@@ -164,12 +165,21 @@ class XRManager extends EventDispatcher {
|
|
|
164
165
|
this._layers = [];
|
|
165
166
|
|
|
166
167
|
/**
|
|
167
|
-
* Whether the
|
|
168
|
+
* Whether the XR session uses layers.
|
|
168
169
|
*
|
|
169
170
|
* @type {boolean}
|
|
170
171
|
* @default false
|
|
171
172
|
*/
|
|
172
|
-
this.
|
|
173
|
+
this._sessionUsesLayers = false;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Whether the device supports binding gl objects.
|
|
177
|
+
*
|
|
178
|
+
* @private
|
|
179
|
+
* @type {boolean}
|
|
180
|
+
* @readonly
|
|
181
|
+
*/
|
|
182
|
+
this._supportsGlBinding = typeof XRWebGLBinding !== 'undefined';
|
|
173
183
|
|
|
174
184
|
this._frameBufferTargets = null;
|
|
175
185
|
|
|
@@ -351,13 +361,16 @@ class XRManager extends EventDispatcher {
|
|
|
351
361
|
this._xrFrame = null;
|
|
352
362
|
|
|
353
363
|
/**
|
|
354
|
-
* Whether
|
|
364
|
+
* Whether the browser supports the APIs necessary to use XRProjectionLayers.
|
|
365
|
+
*
|
|
366
|
+
* Note: this does not represent XRSession explicitly requesting
|
|
367
|
+
* `'layers'` as a feature - see `_sessionUsesLayers` and #30112
|
|
355
368
|
*
|
|
356
369
|
* @private
|
|
357
370
|
* @type {boolean}
|
|
358
371
|
* @readonly
|
|
359
372
|
*/
|
|
360
|
-
this.
|
|
373
|
+
this._supportsLayers = ( this._supportsGlBinding && 'createProjectionLayer' in XRWebGLBinding.prototype ); // eslint-disable-line compat/compat
|
|
361
374
|
|
|
362
375
|
/**
|
|
363
376
|
* Whether the usage of multiview has been requested by the application or not.
|
|
@@ -494,7 +507,7 @@ class XRManager extends EventDispatcher {
|
|
|
494
507
|
|
|
495
508
|
if ( this.isPresenting === true ) {
|
|
496
509
|
|
|
497
|
-
|
|
510
|
+
warn( 'XRManager: Cannot change framebuffer scale while presenting.' );
|
|
498
511
|
|
|
499
512
|
}
|
|
500
513
|
|
|
@@ -524,7 +537,7 @@ class XRManager extends EventDispatcher {
|
|
|
524
537
|
|
|
525
538
|
if ( this.isPresenting === true ) {
|
|
526
539
|
|
|
527
|
-
|
|
540
|
+
warn( 'XRManager: Cannot change reference space type while presenting.' );
|
|
528
541
|
|
|
529
542
|
}
|
|
530
543
|
|
|
@@ -578,6 +591,27 @@ class XRManager extends EventDispatcher {
|
|
|
578
591
|
|
|
579
592
|
}
|
|
580
593
|
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Returns the current XR binding.
|
|
597
|
+
*
|
|
598
|
+
* Creates a new binding if needed and the browser is
|
|
599
|
+
* capable of doing so.
|
|
600
|
+
*
|
|
601
|
+
* @return {?XRWebGLBinding} The XR binding. Returns `null` if one cannot be created.
|
|
602
|
+
*/
|
|
603
|
+
getBinding() {
|
|
604
|
+
|
|
605
|
+
if ( this._glBinding === null && this._supportsGlBinding ) {
|
|
606
|
+
|
|
607
|
+
this._glBinding = new XRWebGLBinding( this._session, this._gl );
|
|
608
|
+
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
return this._glBinding;
|
|
612
|
+
|
|
613
|
+
}
|
|
614
|
+
|
|
581
615
|
/**
|
|
582
616
|
* Returns the current XR frame.
|
|
583
617
|
*
|
|
@@ -641,7 +675,7 @@ class XRManager extends EventDispatcher {
|
|
|
641
675
|
resolveStencilBuffer: false
|
|
642
676
|
} );
|
|
643
677
|
|
|
644
|
-
renderTarget.
|
|
678
|
+
renderTarget._autoAllocateDepthBuffer = true;
|
|
645
679
|
|
|
646
680
|
const material = new MeshBasicMaterial( { color: 0xffffff, side: FrontSide } );
|
|
647
681
|
material.map = renderTarget.texture;
|
|
@@ -732,7 +766,7 @@ class XRManager extends EventDispatcher {
|
|
|
732
766
|
resolveStencilBuffer: false
|
|
733
767
|
} );
|
|
734
768
|
|
|
735
|
-
renderTarget.
|
|
769
|
+
renderTarget._autoAllocateDepthBuffer = true;
|
|
736
770
|
|
|
737
771
|
const material = new MeshBasicMaterial( { color: 0xffffff, side: BackSide } );
|
|
738
772
|
material.map = renderTarget.texture;
|
|
@@ -806,9 +840,9 @@ class XRManager extends EventDispatcher {
|
|
|
806
840
|
for ( const layer of this._layers ) {
|
|
807
841
|
|
|
808
842
|
layer.renderTarget.isXRRenderTarget = this._session !== null;
|
|
809
|
-
layer.renderTarget.
|
|
843
|
+
layer.renderTarget._hasExternalTextures = layer.renderTarget.isXRRenderTarget;
|
|
810
844
|
|
|
811
|
-
if ( layer.renderTarget.isXRRenderTarget && this.
|
|
845
|
+
if ( layer.renderTarget.isXRRenderTarget && this._sessionUsesLayers ) {
|
|
812
846
|
|
|
813
847
|
layer.xrlayer.transform = new XRRigidTransform( layer.plane.getWorldPosition( translationObject ), layer.plane.getWorldQuaternion( quaternionObject ) );
|
|
814
848
|
|
|
@@ -915,9 +949,9 @@ class XRManager extends EventDispatcher {
|
|
|
915
949
|
|
|
916
950
|
//
|
|
917
951
|
|
|
918
|
-
if ( this.
|
|
952
|
+
if ( this._supportsLayers === true ) {
|
|
919
953
|
|
|
920
|
-
// default path using
|
|
954
|
+
// default path using XRProjectionLayer
|
|
921
955
|
|
|
922
956
|
let depthFormat = null;
|
|
923
957
|
let depthType = null;
|
|
@@ -945,11 +979,10 @@ class XRManager extends EventDispatcher {
|
|
|
945
979
|
|
|
946
980
|
}
|
|
947
981
|
|
|
948
|
-
|
|
949
|
-
const glProjLayer =
|
|
982
|
+
this._glBinding = this.getBinding();
|
|
983
|
+
const glProjLayer = this._glBinding.createProjectionLayer( projectionlayerInit );
|
|
950
984
|
const layersArray = [ glProjLayer ];
|
|
951
985
|
|
|
952
|
-
this._glBinding = glBinding;
|
|
953
986
|
this._glProjLayer = glProjLayer;
|
|
954
987
|
|
|
955
988
|
renderer.setPixelRatio( 1 );
|
|
@@ -974,14 +1007,14 @@ class XRManager extends EventDispatcher {
|
|
|
974
1007
|
multiview: this._useMultiview
|
|
975
1008
|
} );
|
|
976
1009
|
|
|
977
|
-
this._xrRenderTarget.
|
|
1010
|
+
this._xrRenderTarget._hasExternalTextures = true;
|
|
978
1011
|
this._xrRenderTarget.depth = this._useMultiview ? 2 : 1;
|
|
979
1012
|
|
|
980
|
-
this.
|
|
1013
|
+
this._sessionUsesLayers = session.enabledFeatures.includes( 'layers' );
|
|
981
1014
|
|
|
982
1015
|
this._referenceSpace = await session.requestReferenceSpace( this.getReferenceSpaceType() );
|
|
983
1016
|
|
|
984
|
-
if ( this.
|
|
1017
|
+
if ( this._sessionUsesLayers ) {
|
|
985
1018
|
|
|
986
1019
|
// switch layers to native
|
|
987
1020
|
for ( const layer of this._layers ) {
|
|
@@ -1008,7 +1041,7 @@ class XRManager extends EventDispatcher {
|
|
|
1008
1041
|
// fallback to XRWebGLLayer
|
|
1009
1042
|
|
|
1010
1043
|
const layerInit = {
|
|
1011
|
-
antialias: renderer.
|
|
1044
|
+
antialias: renderer.currentSamples > 0,
|
|
1012
1045
|
alpha: true,
|
|
1013
1046
|
depth: renderer.depth,
|
|
1014
1047
|
stencil: renderer.stencil,
|
|
@@ -1036,6 +1069,7 @@ class XRManager extends EventDispatcher {
|
|
|
1036
1069
|
}
|
|
1037
1070
|
);
|
|
1038
1071
|
|
|
1072
|
+
this._xrRenderTarget._isOpaqueFramebuffer = true;
|
|
1039
1073
|
this._referenceSpace = await session.requestReferenceSpace( this.getReferenceSpaceType() );
|
|
1040
1074
|
|
|
1041
1075
|
}
|
|
@@ -1094,9 +1128,11 @@ class XRManager extends EventDispatcher {
|
|
|
1094
1128
|
|
|
1095
1129
|
}
|
|
1096
1130
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1131
|
+
// inherit camera layers and enable eye layers (1 = left, 2 = right)
|
|
1132
|
+
cameraXR.layers.mask = camera.layers.mask | 0b110;
|
|
1133
|
+
cameraL.layers.mask = cameraXR.layers.mask & 0b011;
|
|
1134
|
+
cameraR.layers.mask = cameraXR.layers.mask & 0b101;
|
|
1135
|
+
|
|
1100
1136
|
|
|
1101
1137
|
const parent = camera.parent;
|
|
1102
1138
|
const cameras = cameraXR.cameras;
|
|
@@ -1345,9 +1381,12 @@ function onSessionEnd() {
|
|
|
1345
1381
|
|
|
1346
1382
|
this._session = null;
|
|
1347
1383
|
this._xrRenderTarget = null;
|
|
1384
|
+
this._glBinding = null;
|
|
1385
|
+
this._glBaseLayer = null;
|
|
1386
|
+
this._glProjLayer = null;
|
|
1348
1387
|
|
|
1349
1388
|
// switch layers back to emulated
|
|
1350
|
-
if ( this.
|
|
1389
|
+
if ( this._sessionUsesLayers === true ) {
|
|
1351
1390
|
|
|
1352
1391
|
for ( const layer of this._layers ) {
|
|
1353
1392
|
|
|
@@ -1549,7 +1588,7 @@ function onAnimationFrame( time, frame ) {
|
|
|
1549
1588
|
|
|
1550
1589
|
let viewport;
|
|
1551
1590
|
|
|
1552
|
-
if ( this.
|
|
1591
|
+
if ( this._supportsLayers === true ) {
|
|
1553
1592
|
|
|
1554
1593
|
const glSubImage = this._glBinding.getViewSubImage( this._glProjLayer, view );
|
|
1555
1594
|
viewport = glSubImage.viewport;
|
|
@@ -34,10 +34,11 @@ class XRRenderTarget extends RenderTarget {
|
|
|
34
34
|
* are defined by external textures. This flag is
|
|
35
35
|
* set to `true` when using the WebXR Layers API.
|
|
36
36
|
*
|
|
37
|
+
* @private
|
|
37
38
|
* @type {boolean}
|
|
38
39
|
* @default false
|
|
39
40
|
*/
|
|
40
|
-
this.
|
|
41
|
+
this._hasExternalTextures = false;
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Whether a depth buffer should automatically be allocated
|
|
@@ -50,10 +51,25 @@ class XRRenderTarget extends RenderTarget {
|
|
|
50
51
|
*
|
|
51
52
|
* Reference: {@link https://www.w3.org/TR/webxrlayers-1/#dom-xrprojectionlayer-ignoredepthvalues}.
|
|
52
53
|
*
|
|
54
|
+
* @private
|
|
53
55
|
* @type {boolean}
|
|
54
56
|
* @default true
|
|
55
57
|
*/
|
|
56
|
-
this.
|
|
58
|
+
this._autoAllocateDepthBuffer = true;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether this render target is associated with a XRWebGLLayer.
|
|
62
|
+
*
|
|
63
|
+
* A XRWebGLLayer points to an opaque framebuffer. Basically,
|
|
64
|
+
* this means that you don't have access to its bound color,
|
|
65
|
+
* stencil and depth buffers. We need to handle this framebuffer
|
|
66
|
+
* differently since its textures are always bound.
|
|
67
|
+
*
|
|
68
|
+
* @private
|
|
69
|
+
* @type {boolean}
|
|
70
|
+
* @default false
|
|
71
|
+
* */
|
|
72
|
+
this._isOpaqueFramebuffer = false;
|
|
57
73
|
|
|
58
74
|
}
|
|
59
75
|
|
|
@@ -61,8 +77,9 @@ class XRRenderTarget extends RenderTarget {
|
|
|
61
77
|
|
|
62
78
|
super.copy( source );
|
|
63
79
|
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
80
|
+
this._hasExternalTextures = source._hasExternalTextures;
|
|
81
|
+
this._autoAllocateDepthBuffer = source._autoAllocateDepthBuffer;
|
|
82
|
+
this._isOpaqueFramebuffer = source._isOpaqueFramebuffer;
|
|
66
83
|
|
|
67
84
|
return this;
|
|
68
85
|
|