super-three 0.167.0 → 0.169.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/build/three.cjs +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +13 -8
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +34 -33
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -9,6 +9,7 @@ class WebGPUBindingUtils {
|
|
|
9
9
|
constructor( backend ) {
|
|
10
10
|
|
|
11
11
|
this.backend = backend;
|
|
12
|
+
this.bindGroupLayoutCache = new WeakMap();
|
|
12
13
|
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -95,9 +96,15 @@ class WebGPUBindingUtils {
|
|
|
95
96
|
|
|
96
97
|
} else if ( type === FloatType ) {
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
if ( this.backend.hasFeature( 'float32-filterable' ) ) {
|
|
99
100
|
|
|
100
|
-
|
|
101
|
+
texture.sampleType = GPUTextureSampleType.Float;
|
|
102
|
+
|
|
103
|
+
} else {
|
|
104
|
+
|
|
105
|
+
texture.sampleType = GPUTextureSampleType.UnfilterableFloat;
|
|
106
|
+
|
|
107
|
+
}
|
|
101
108
|
|
|
102
109
|
}
|
|
103
110
|
|
|
@@ -107,7 +114,7 @@ class WebGPUBindingUtils {
|
|
|
107
114
|
|
|
108
115
|
texture.viewDimension = GPUTextureViewDimension.Cube;
|
|
109
116
|
|
|
110
|
-
} else if ( binding.texture.isDataArrayTexture ) {
|
|
117
|
+
} else if ( binding.texture.isDataArrayTexture || binding.texture.isCompressedArrayTexture ) {
|
|
111
118
|
|
|
112
119
|
texture.viewDimension = GPUTextureViewDimension.TwoDArray;
|
|
113
120
|
|
|
@@ -135,12 +142,20 @@ class WebGPUBindingUtils {
|
|
|
135
142
|
|
|
136
143
|
createBindings( bindGroup ) {
|
|
137
144
|
|
|
138
|
-
const backend = this
|
|
145
|
+
const { backend, bindGroupLayoutCache } = this;
|
|
139
146
|
const bindingsData = backend.get( bindGroup );
|
|
140
147
|
|
|
141
148
|
// setup (static) binding layout and (dynamic) binding group
|
|
142
149
|
|
|
143
|
-
|
|
150
|
+
let bindLayoutGPU = bindGroupLayoutCache.get( bindGroup.bindingsReference );
|
|
151
|
+
|
|
152
|
+
if ( bindLayoutGPU === undefined ) {
|
|
153
|
+
|
|
154
|
+
bindLayoutGPU = this.createBindingsLayout( bindGroup );
|
|
155
|
+
bindGroupLayoutCache.set( bindGroup.bindingsReference, bindLayoutGPU );
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
144
159
|
const bindGroupGPU = this.createBindGroup( bindGroup, bindLayoutGPU );
|
|
145
160
|
|
|
146
161
|
bindingsData.layout = bindLayoutGPU;
|
|
@@ -219,37 +234,46 @@ class WebGPUBindingUtils {
|
|
|
219
234
|
|
|
220
235
|
const textureData = backend.get( binding.texture );
|
|
221
236
|
|
|
222
|
-
let
|
|
237
|
+
let resourceGPU;
|
|
238
|
+
|
|
239
|
+
if ( textureData.externalTexture !== undefined ) {
|
|
223
240
|
|
|
224
|
-
|
|
241
|
+
resourceGPU = device.importExternalTexture( { source: textureData.externalTexture } );
|
|
225
242
|
|
|
226
|
-
|
|
243
|
+
} else {
|
|
227
244
|
|
|
228
|
-
|
|
245
|
+
const mipLevelCount = binding.store ? 1 : textureData.texture.mipLevelCount;
|
|
246
|
+
const propertyName = `view-${ textureData.texture.width }-${ textureData.texture.height }-${ mipLevelCount }`;
|
|
229
247
|
|
|
230
|
-
|
|
248
|
+
resourceGPU = textureData[ propertyName ];
|
|
231
249
|
|
|
232
|
-
|
|
250
|
+
if ( resourceGPU === undefined ) {
|
|
233
251
|
|
|
234
|
-
|
|
252
|
+
const aspectGPU = GPUTextureAspect.All;
|
|
235
253
|
|
|
236
|
-
|
|
254
|
+
let dimensionViewGPU;
|
|
237
255
|
|
|
238
|
-
|
|
256
|
+
if ( binding.isSampledCubeTexture ) {
|
|
239
257
|
|
|
240
|
-
|
|
258
|
+
dimensionViewGPU = GPUTextureViewDimension.Cube;
|
|
241
259
|
|
|
242
|
-
|
|
260
|
+
} else if ( binding.isSampledTexture3D ) {
|
|
243
261
|
|
|
244
|
-
|
|
262
|
+
dimensionViewGPU = GPUTextureViewDimension.ThreeD;
|
|
245
263
|
|
|
246
|
-
|
|
264
|
+
} else if ( binding.texture.isDataArrayTexture || binding.texture.isCompressedArrayTexture ) {
|
|
247
265
|
|
|
248
|
-
|
|
266
|
+
dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
|
|
267
|
+
|
|
268
|
+
} else {
|
|
249
269
|
|
|
250
|
-
|
|
270
|
+
dimensionViewGPU = GPUTextureViewDimension.TwoD;
|
|
251
271
|
|
|
252
|
-
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
resourceGPU = textureData[ propertyName ] = textureData.texture.createView( { aspect: aspectGPU, dimension: dimensionViewGPU, mipLevelCount } );
|
|
275
|
+
|
|
276
|
+
}
|
|
253
277
|
|
|
254
278
|
}
|
|
255
279
|
|
|
@@ -328,5 +328,6 @@ export const GPUFeatureName = {
|
|
|
328
328
|
BGRA8UNormStorage: 'bgra8unorm-storage',
|
|
329
329
|
Float32Filterable: 'float32-filterable',
|
|
330
330
|
ClipDistances: 'clip-distances',
|
|
331
|
-
DualSourceBlending: 'dual-source-blending'
|
|
331
|
+
DualSourceBlending: 'dual-source-blending',
|
|
332
|
+
Subgroups: 'subgroups'
|
|
332
333
|
};
|
|
@@ -123,7 +123,7 @@ class WebGPUPipelineUtils {
|
|
|
123
123
|
const sampleCount = this._getSampleCount( renderObject.context );
|
|
124
124
|
|
|
125
125
|
const pipelineDescriptor = {
|
|
126
|
-
label:
|
|
126
|
+
label: `renderPipeline_${ material.name || material.type }_${ material.id }`,
|
|
127
127
|
vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
|
|
128
128
|
fragment: Object.assign( {}, fragmentModule, { targets } ),
|
|
129
129
|
primitive: primitiveState,
|
|
@@ -138,7 +138,7 @@ class WebGPUPipelineUtils {
|
|
|
138
138
|
},
|
|
139
139
|
multisample: {
|
|
140
140
|
count: sampleCount,
|
|
141
|
-
alphaToCoverageEnabled: material.alphaToCoverage
|
|
141
|
+
alphaToCoverageEnabled: material.alphaToCoverage && sampleCount > 1
|
|
142
142
|
},
|
|
143
143
|
layout: device.createPipelineLayout( {
|
|
144
144
|
bindGroupLayouts
|
|
@@ -168,17 +168,14 @@ class WebGPUPipelineUtils {
|
|
|
168
168
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
createBundleEncoder( renderContext
|
|
171
|
+
createBundleEncoder( renderContext ) {
|
|
172
172
|
|
|
173
173
|
const backend = this.backend;
|
|
174
174
|
const { utils, device } = backend;
|
|
175
175
|
|
|
176
|
-
const renderContextData = backend.get( renderContext );
|
|
177
|
-
const renderObjectData = backend.get( renderObject );
|
|
178
|
-
|
|
179
176
|
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext );
|
|
180
177
|
const colorFormat = utils.getCurrentColorFormat( renderContext );
|
|
181
|
-
const sampleCount = this._getSampleCount(
|
|
178
|
+
const sampleCount = this._getSampleCount( renderContext );
|
|
182
179
|
|
|
183
180
|
const descriptor = {
|
|
184
181
|
label: 'renderBundleEncoder',
|
|
@@ -187,13 +184,7 @@ class WebGPUPipelineUtils {
|
|
|
187
184
|
sampleCount
|
|
188
185
|
};
|
|
189
186
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
renderObjectData.bundleEncoder = bundleEncoder;
|
|
193
|
-
renderContextData.currentSets = { attributes: {} };
|
|
194
|
-
renderContextData._renderBundleViewport = renderContext.width + '_' + renderContext.height;
|
|
195
|
-
|
|
196
|
-
return bundleEncoder;
|
|
187
|
+
return device.createRenderBundleEncoder( descriptor );
|
|
197
188
|
|
|
198
189
|
}
|
|
199
190
|
|
|
@@ -280,11 +271,11 @@ class WebGPUPipelineUtils {
|
|
|
280
271
|
switch ( blending ) {
|
|
281
272
|
|
|
282
273
|
case NormalBlending:
|
|
283
|
-
setBlend( GPUBlendFactor.
|
|
274
|
+
setBlend( GPUBlendFactor.One, GPUBlendFactor.OneMinusSrcAlpha, GPUBlendFactor.One, GPUBlendFactor.OneMinusSrcAlpha );
|
|
284
275
|
break;
|
|
285
276
|
|
|
286
277
|
case AdditiveBlending:
|
|
287
|
-
setBlend( GPUBlendFactor.
|
|
278
|
+
setBlend( GPUBlendFactor.One, GPUBlendFactor.One, GPUBlendFactor.One, GPUBlendFactor.One );
|
|
288
279
|
break;
|
|
289
280
|
|
|
290
281
|
case SubtractiveBlending:
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import DataMap from '../../common/DataMap.js';
|
|
1
2
|
import { GPUTextureViewDimension, GPUIndexFormat, GPUFilterMode, GPUPrimitiveTopology, GPULoadOp, GPUStoreOp } from './WebGPUConstants.js';
|
|
2
3
|
|
|
3
|
-
class WebGPUTexturePassUtils {
|
|
4
|
+
class WebGPUTexturePassUtils extends DataMap {
|
|
4
5
|
|
|
5
6
|
constructor( device ) {
|
|
6
7
|
|
|
8
|
+
super();
|
|
9
|
+
|
|
7
10
|
this.device = device;
|
|
8
11
|
|
|
9
12
|
const mipmapVertexSource = `
|
|
@@ -99,6 +102,7 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
99
102
|
if ( pipeline === undefined ) {
|
|
100
103
|
|
|
101
104
|
pipeline = this.device.createRenderPipeline( {
|
|
105
|
+
label: `mipmap-${ format }`,
|
|
102
106
|
vertex: {
|
|
103
107
|
module: this.mipmapVertexShaderModule,
|
|
104
108
|
entryPoint: 'main'
|
|
@@ -130,6 +134,7 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
130
134
|
if ( pipeline === undefined ) {
|
|
131
135
|
|
|
132
136
|
pipeline = this.device.createRenderPipeline( {
|
|
137
|
+
label: `flipY-${ format }`,
|
|
133
138
|
vertex: {
|
|
134
139
|
module: this.mipmapVertexShaderModule,
|
|
135
140
|
entryPoint: 'main'
|
|
@@ -226,9 +231,33 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
226
231
|
|
|
227
232
|
generateMipmaps( textureGPU, textureGPUDescriptor, baseArrayLayer = 0 ) {
|
|
228
233
|
|
|
229
|
-
const
|
|
234
|
+
const textureData = this.get( textureGPU );
|
|
235
|
+
|
|
236
|
+
if ( textureData.useCount === undefined ) {
|
|
237
|
+
|
|
238
|
+
textureData.useCount = 0;
|
|
239
|
+
textureData.layers = [];
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const passes = textureData.layers[ baseArrayLayer ] || this._mipmapCreateBundles( textureGPU, textureGPUDescriptor, baseArrayLayer );
|
|
230
244
|
|
|
231
245
|
const commandEncoder = this.device.createCommandEncoder( {} );
|
|
246
|
+
|
|
247
|
+
this._mipmapRunBundles( commandEncoder, passes );
|
|
248
|
+
|
|
249
|
+
this.device.queue.submit( [ commandEncoder.finish() ] );
|
|
250
|
+
|
|
251
|
+
if ( textureData.useCount !== 0 ) textureData.layers[ baseArrayLayer ] = passes;
|
|
252
|
+
|
|
253
|
+
textureData.useCount ++;
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
_mipmapCreateBundles( textureGPU, textureGPUDescriptor, baseArrayLayer ) {
|
|
258
|
+
|
|
259
|
+
const pipeline = this.getTransferPipeline( textureGPUDescriptor.format );
|
|
260
|
+
|
|
232
261
|
const bindGroupLayout = pipeline.getBindGroupLayout( 0 ); // @TODO: Consider making this static.
|
|
233
262
|
|
|
234
263
|
let srcView = textureGPU.createView( {
|
|
@@ -238,6 +267,8 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
238
267
|
baseArrayLayer
|
|
239
268
|
} );
|
|
240
269
|
|
|
270
|
+
const passes = [];
|
|
271
|
+
|
|
241
272
|
for ( let i = 1; i < textureGPUDescriptor.mipLevelCount; i ++ ) {
|
|
242
273
|
|
|
243
274
|
const bindGroup = this.device.createBindGroup( {
|
|
@@ -258,25 +289,51 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
258
289
|
baseArrayLayer
|
|
259
290
|
} );
|
|
260
291
|
|
|
261
|
-
const
|
|
292
|
+
const passDescriptor = {
|
|
262
293
|
colorAttachments: [ {
|
|
263
294
|
view: dstView,
|
|
264
295
|
loadOp: GPULoadOp.Clear,
|
|
265
296
|
storeOp: GPUStoreOp.Store,
|
|
266
297
|
clearValue: [ 0, 0, 0, 0 ]
|
|
267
298
|
} ]
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
const passEncoder = this.device.createRenderBundleEncoder( {
|
|
302
|
+
colorFormats: [ textureGPUDescriptor.format ]
|
|
268
303
|
} );
|
|
269
304
|
|
|
270
305
|
passEncoder.setPipeline( pipeline );
|
|
271
306
|
passEncoder.setBindGroup( 0, bindGroup );
|
|
272
307
|
passEncoder.draw( 4, 1, 0, 0 );
|
|
273
|
-
|
|
308
|
+
|
|
309
|
+
passes.push( {
|
|
310
|
+
renderBundles: [ passEncoder.finish() ],
|
|
311
|
+
passDescriptor
|
|
312
|
+
} );
|
|
274
313
|
|
|
275
314
|
srcView = dstView;
|
|
276
315
|
|
|
277
316
|
}
|
|
278
317
|
|
|
279
|
-
|
|
318
|
+
return passes;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
_mipmapRunBundles( commandEncoder, passes ) {
|
|
323
|
+
|
|
324
|
+
const levels = passes.length;
|
|
325
|
+
|
|
326
|
+
for ( let i = 0; i < levels; i ++ ) {
|
|
327
|
+
|
|
328
|
+
const pass = passes[ i ];
|
|
329
|
+
|
|
330
|
+
const passEncoder = commandEncoder.beginRenderPass( pass.passDescriptor );
|
|
331
|
+
|
|
332
|
+
passEncoder.executeBundles( pass.renderBundles );
|
|
333
|
+
|
|
334
|
+
passEncoder.end();
|
|
335
|
+
|
|
336
|
+
}
|
|
280
337
|
|
|
281
338
|
}
|
|
282
339
|
|
|
@@ -122,6 +122,8 @@ class WebGPUTextureUtils {
|
|
|
122
122
|
const dimension = this._getDimension( texture );
|
|
123
123
|
const format = texture.internalFormat || options.format || getFormat( texture, backend.device );
|
|
124
124
|
|
|
125
|
+
textureData.format = format;
|
|
126
|
+
|
|
125
127
|
let sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
|
|
126
128
|
|
|
127
129
|
sampleCount = backend.utils.getSampleCount( sampleCount );
|
|
@@ -136,7 +138,7 @@ class WebGPUTextureUtils {
|
|
|
136
138
|
|
|
137
139
|
}
|
|
138
140
|
|
|
139
|
-
if ( texture.isCompressedTexture !== true ) {
|
|
141
|
+
if ( texture.isCompressedTexture !== true && texture.isCompressedArrayTexture !== true ) {
|
|
140
142
|
|
|
141
143
|
usage |= GPUTextureUsage.RENDER_ATTACHMENT;
|
|
142
144
|
|
|
@@ -237,7 +239,13 @@ class WebGPUTextureUtils {
|
|
|
237
239
|
|
|
238
240
|
} else {
|
|
239
241
|
|
|
240
|
-
|
|
242
|
+
const depth = texture.image.depth || 1;
|
|
243
|
+
|
|
244
|
+
for ( let i = 0; i < depth; i ++ ) {
|
|
245
|
+
|
|
246
|
+
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i );
|
|
247
|
+
|
|
248
|
+
}
|
|
241
249
|
|
|
242
250
|
}
|
|
243
251
|
|
|
@@ -258,7 +266,7 @@ class WebGPUTextureUtils {
|
|
|
258
266
|
depthOrArrayLayers: 1
|
|
259
267
|
},
|
|
260
268
|
sampleCount: backend.utils.getSampleCount( backend.renderer.samples ),
|
|
261
|
-
format:
|
|
269
|
+
format: backend.utils.getPreferredCanvasFormat(),
|
|
262
270
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
|
|
263
271
|
} );
|
|
264
272
|
|
|
@@ -335,7 +343,7 @@ class WebGPUTextureUtils {
|
|
|
335
343
|
|
|
336
344
|
}
|
|
337
345
|
|
|
338
|
-
} else if ( texture.isCompressedTexture ) {
|
|
346
|
+
} else if ( texture.isCompressedTexture || texture.isCompressedArrayTexture ) {
|
|
339
347
|
|
|
340
348
|
this._copyCompressedBufferToTexture( texture.mipmaps, textureData.texture, textureDescriptorGPU );
|
|
341
349
|
|
|
@@ -363,7 +371,7 @@ class WebGPUTextureUtils {
|
|
|
363
371
|
|
|
364
372
|
}
|
|
365
373
|
|
|
366
|
-
async copyTextureToBuffer( texture, x, y, width, height ) {
|
|
374
|
+
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
367
375
|
|
|
368
376
|
const device = this.backend.device;
|
|
369
377
|
|
|
@@ -387,7 +395,7 @@ class WebGPUTextureUtils {
|
|
|
387
395
|
encoder.copyTextureToBuffer(
|
|
388
396
|
{
|
|
389
397
|
texture: textureGPU,
|
|
390
|
-
origin: { x, y },
|
|
398
|
+
origin: { x, y, z: faceIndex },
|
|
391
399
|
},
|
|
392
400
|
{
|
|
393
401
|
buffer: readBuffer,
|
|
@@ -599,6 +607,7 @@ class WebGPUTextureUtils {
|
|
|
599
607
|
const device = this.backend.device;
|
|
600
608
|
|
|
601
609
|
const blockData = this._getBlockData( textureDescriptorGPU.format );
|
|
610
|
+
const isTextureArray = textureDescriptorGPU.size.depthOrArrayLayers > 1;
|
|
602
611
|
|
|
603
612
|
for ( let i = 0; i < mipmaps.length; i ++ ) {
|
|
604
613
|
|
|
@@ -606,25 +615,33 @@ class WebGPUTextureUtils {
|
|
|
606
615
|
|
|
607
616
|
const width = mipmap.width;
|
|
608
617
|
const height = mipmap.height;
|
|
618
|
+
const depth = isTextureArray ? textureDescriptorGPU.size.depthOrArrayLayers : 1;
|
|
609
619
|
|
|
610
620
|
const bytesPerRow = Math.ceil( width / blockData.width ) * blockData.byteLength;
|
|
621
|
+
const bytesPerImage = bytesPerRow * Math.ceil( height / blockData.height );
|
|
622
|
+
|
|
623
|
+
for ( let j = 0; j < depth; j ++ ) {
|
|
624
|
+
|
|
625
|
+
device.queue.writeTexture(
|
|
626
|
+
{
|
|
627
|
+
texture: textureGPU,
|
|
628
|
+
mipLevel: i,
|
|
629
|
+
origin: { x: 0, y: 0, z: j }
|
|
630
|
+
},
|
|
631
|
+
mipmap.data,
|
|
632
|
+
{
|
|
633
|
+
offset: j * bytesPerImage,
|
|
634
|
+
bytesPerRow,
|
|
635
|
+
rowsPerImage: Math.ceil( height / blockData.height )
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
width: Math.ceil( width / blockData.width ) * blockData.width,
|
|
639
|
+
height: Math.ceil( height / blockData.height ) * blockData.height,
|
|
640
|
+
depthOrArrayLayers: 1
|
|
641
|
+
}
|
|
642
|
+
);
|
|
611
643
|
|
|
612
|
-
|
|
613
|
-
{
|
|
614
|
-
texture: textureGPU,
|
|
615
|
-
mipLevel: i
|
|
616
|
-
},
|
|
617
|
-
mipmap.data,
|
|
618
|
-
{
|
|
619
|
-
offset: 0,
|
|
620
|
-
bytesPerRow
|
|
621
|
-
},
|
|
622
|
-
{
|
|
623
|
-
width: Math.ceil( width / blockData.width ) * blockData.width,
|
|
624
|
-
height: Math.ceil( height / blockData.width ) * blockData.width,
|
|
625
|
-
depthOrArrayLayers: 1
|
|
626
|
-
}
|
|
627
|
-
);
|
|
644
|
+
}
|
|
628
645
|
|
|
629
646
|
}
|
|
630
647
|
|
|
@@ -777,9 +794,9 @@ class WebGPUTextureUtils {
|
|
|
777
794
|
if ( format === GPUTextureFormat.RG16Sint ) return Int16Array;
|
|
778
795
|
if ( format === GPUTextureFormat.RGBA16Uint ) return Uint16Array;
|
|
779
796
|
if ( format === GPUTextureFormat.RGBA16Sint ) return Int16Array;
|
|
780
|
-
if ( format === GPUTextureFormat.R16Float ) return
|
|
781
|
-
if ( format === GPUTextureFormat.RG16Float ) return
|
|
782
|
-
if ( format === GPUTextureFormat.RGBA16Float ) return
|
|
797
|
+
if ( format === GPUTextureFormat.R16Float ) return Uint16Array;
|
|
798
|
+
if ( format === GPUTextureFormat.RG16Float ) return Uint16Array;
|
|
799
|
+
if ( format === GPUTextureFormat.RGBA16Float ) return Uint16Array;
|
|
783
800
|
|
|
784
801
|
|
|
785
802
|
if ( format === GPUTextureFormat.R32Uint ) return Uint32Array;
|
|
@@ -837,7 +854,7 @@ export function getFormat( texture, device = null ) {
|
|
|
837
854
|
|
|
838
855
|
formatGPU = GPUTextureFormat.BGRA8Unorm;
|
|
839
856
|
|
|
840
|
-
} else if ( texture.isCompressedTexture === true ) {
|
|
857
|
+
} else if ( texture.isCompressedTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
841
858
|
|
|
842
859
|
switch ( format ) {
|
|
843
860
|
|
|
@@ -32,7 +32,7 @@ class WebGPUUtils {
|
|
|
32
32
|
|
|
33
33
|
getTextureFormatGPU( texture ) {
|
|
34
34
|
|
|
35
|
-
return this.backend.get( texture ).
|
|
35
|
+
return this.backend.get( texture ).format;
|
|
36
36
|
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -47,7 +47,7 @@ class WebGPUUtils {
|
|
|
47
47
|
|
|
48
48
|
} else {
|
|
49
49
|
|
|
50
|
-
format =
|
|
50
|
+
format = this.getPreferredCanvasFormat(); // default context format
|
|
51
51
|
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -109,6 +109,23 @@ class WebGPUUtils {
|
|
|
109
109
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
getPreferredCanvasFormat() {
|
|
113
|
+
|
|
114
|
+
// TODO: Remove this check when Quest 34.5 is out
|
|
115
|
+
// https://github.com/mrdoob/three.js/pull/29221/files#r1731833949
|
|
116
|
+
|
|
117
|
+
if ( navigator.userAgent.includes( 'Quest' ) ) {
|
|
118
|
+
|
|
119
|
+
return GPUTextureFormat.BGRA8Unorm;
|
|
120
|
+
|
|
121
|
+
} else {
|
|
122
|
+
|
|
123
|
+
return navigator.gpu.getPreferredCanvasFormat();
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
112
129
|
}
|
|
113
130
|
|
|
114
131
|
export default WebGPUUtils;
|
|
@@ -551,18 +551,31 @@ class WebXRManager extends EventDispatcher {
|
|
|
551
551
|
camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
|
|
552
552
|
camera.matrixWorldInverse.copy( camera.matrixWorld ).invert();
|
|
553
553
|
|
|
554
|
-
//
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
554
|
+
// Check if the projection uses an infinite far plane.
|
|
555
|
+
if ( projL[ 10 ] === - 1.0 ) {
|
|
556
|
+
|
|
557
|
+
// Use the projection matrix from the left eye.
|
|
558
|
+
// The camera offset is sufficient to include the view volumes
|
|
559
|
+
// of both eyes (assuming symmetric projections).
|
|
560
|
+
camera.projectionMatrix.copy( cameraL.projectionMatrix );
|
|
561
|
+
camera.projectionMatrixInverse.copy( cameraL.projectionMatrixInverse );
|
|
562
|
+
|
|
563
|
+
} else {
|
|
564
|
+
|
|
565
|
+
// Find the union of the frustum values of the cameras and scale
|
|
566
|
+
// the values so that the near plane's position does not change in world space,
|
|
567
|
+
// although must now be relative to the new union camera.
|
|
568
|
+
const near2 = near + zOffset;
|
|
569
|
+
const far2 = far + zOffset;
|
|
570
|
+
const left2 = left - xOffset;
|
|
571
|
+
const right2 = right + ( ipd - xOffset );
|
|
572
|
+
const top2 = topFov * far / far2 * near2;
|
|
573
|
+
const bottom2 = bottomFov * far / far2 * near2;
|
|
574
|
+
|
|
575
|
+
camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
|
|
576
|
+
camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
|
|
577
|
+
|
|
578
|
+
}
|
|
566
579
|
|
|
567
580
|
}
|
|
568
581
|
|
|
@@ -592,15 +605,18 @@ class WebXRManager extends EventDispatcher {
|
|
|
592
605
|
|
|
593
606
|
if ( session === null ) return;
|
|
594
607
|
|
|
608
|
+
let depthNear = camera.near;
|
|
609
|
+
let depthFar = camera.far;
|
|
610
|
+
|
|
595
611
|
if ( depthSensing.texture !== null ) {
|
|
596
612
|
|
|
597
|
-
|
|
598
|
-
|
|
613
|
+
if ( depthSensing.depthNear > 0 ) depthNear = depthSensing.depthNear;
|
|
614
|
+
if ( depthSensing.depthFar > 0 ) depthFar = depthSensing.depthFar;
|
|
599
615
|
|
|
600
616
|
}
|
|
601
617
|
|
|
602
|
-
cameraXR.near = cameraR.near = cameraL.near =
|
|
603
|
-
cameraXR.far = cameraR.far = cameraL.far =
|
|
618
|
+
cameraXR.near = cameraR.near = cameraL.near = depthNear;
|
|
619
|
+
cameraXR.far = cameraR.far = cameraL.far = depthFar;
|
|
604
620
|
|
|
605
621
|
if ( _currentDepthNear !== cameraXR.near || _currentDepthFar !== cameraXR.far ) {
|
|
606
622
|
|
|
@@ -614,15 +630,6 @@ class WebXRManager extends EventDispatcher {
|
|
|
614
630
|
_currentDepthNear = cameraXR.near;
|
|
615
631
|
_currentDepthFar = cameraXR.far;
|
|
616
632
|
|
|
617
|
-
cameraL.near = _currentDepthNear;
|
|
618
|
-
cameraL.far = _currentDepthFar;
|
|
619
|
-
cameraR.near = _currentDepthNear;
|
|
620
|
-
cameraR.far = _currentDepthFar;
|
|
621
|
-
|
|
622
|
-
cameraL.updateProjectionMatrix();
|
|
623
|
-
cameraR.updateProjectionMatrix();
|
|
624
|
-
camera.updateProjectionMatrix();
|
|
625
|
-
|
|
626
633
|
}
|
|
627
634
|
|
|
628
635
|
const cameras = cameraXR.cameras;
|
package/src/utils.js
CHANGED
|
@@ -117,4 +117,36 @@ function probeAsync( gl, sync, interval ) {
|
|
|
117
117
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
function toNormalizedProjectionMatrix( projectionMatrix ) {
|
|
121
|
+
|
|
122
|
+
const m = projectionMatrix.elements;
|
|
123
|
+
|
|
124
|
+
// Convert [-1, 1] to [0, 1] projection matrix
|
|
125
|
+
m[ 2 ] = 0.5 * m[ 2 ] + 0.5 * m[ 3 ];
|
|
126
|
+
m[ 6 ] = 0.5 * m[ 6 ] + 0.5 * m[ 7 ];
|
|
127
|
+
m[ 10 ] = 0.5 * m[ 10 ] + 0.5 * m[ 11 ];
|
|
128
|
+
m[ 14 ] = 0.5 * m[ 14 ] + 0.5 * m[ 15 ];
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function toReversedProjectionMatrix( projectionMatrix ) {
|
|
133
|
+
|
|
134
|
+
const m = projectionMatrix.elements;
|
|
135
|
+
const isPerspectiveMatrix = m[ 11 ] === - 1;
|
|
136
|
+
|
|
137
|
+
// Reverse [0, 1] projection matrix
|
|
138
|
+
if ( isPerspectiveMatrix ) {
|
|
139
|
+
|
|
140
|
+
m[ 10 ] = - m[ 10 ] - 1;
|
|
141
|
+
m[ 14 ] = - m[ 14 ];
|
|
142
|
+
|
|
143
|
+
} else {
|
|
144
|
+
|
|
145
|
+
m[ 10 ] = - m[ 10 ];
|
|
146
|
+
m[ 14 ] = - m[ 14 ] + 1;
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, createCanvasElement, warnOnce, probeAsync, toNormalizedProjectionMatrix, toReversedProjectionMatrix };
|