super-three 0.152.0 → 0.154.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 +779 -557
- package/build/three.js +779 -557
- package/build/three.min.js +2 -1
- package/build/three.module.js +770 -539
- package/build/three.module.min.js +2 -1
- package/examples/jsm/cameras/CinematicCamera.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +15 -1
- package/examples/jsm/controls/ArcballControls.js +2 -1
- package/examples/jsm/controls/FlyControls.js +25 -9
- package/examples/jsm/controls/OrbitControls.js +5 -1
- package/examples/jsm/csm/CSM.js +1 -3
- package/examples/jsm/effects/AnaglyphEffect.js +6 -20
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/effects/ParallaxBarrierEffect.js +3 -0
- package/examples/jsm/environments/RoomEnvironment.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +74 -2
- package/examples/jsm/exporters/USDZExporter.js +170 -129
- package/examples/jsm/helpers/ViewHelper.js +1 -1
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +5 -1
- package/examples/jsm/loaders/AMFLoader.js +5 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -1
- package/examples/jsm/loaders/DRACOLoader.js +2 -0
- package/examples/jsm/loaders/FBXLoader.js +9 -2
- package/examples/jsm/loaders/GLTFLoader.js +230 -94
- package/examples/jsm/loaders/KTX2Loader.js +106 -47
- package/examples/jsm/loaders/LDrawLoader.js +4 -7
- package/examples/jsm/loaders/MMDLoader.js +40 -13
- package/examples/jsm/loaders/PCDLoader.js +25 -10
- package/examples/jsm/loaders/PDBLoader.js +7 -2
- package/examples/jsm/loaders/PLYLoader.js +30 -8
- package/examples/jsm/loaders/STLLoader.js +8 -3
- package/examples/jsm/loaders/VRMLLoader.js +55 -7
- package/examples/jsm/loaders/VTKLoader.js +12 -4
- package/examples/jsm/loaders/XYZLoader.js +9 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -2
- package/examples/jsm/math/Lut.js +5 -4
- package/examples/jsm/math/MeshSurfaceSampler.js +82 -37
- package/examples/jsm/misc/GPUComputationRenderer.js +1 -0
- package/examples/jsm/misc/VolumeSlice.js +3 -1
- package/examples/jsm/nodes/Nodes.js +22 -16
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +99 -0
- package/examples/jsm/nodes/accessors/BufferNode.js +2 -2
- package/examples/jsm/nodes/accessors/CameraNode.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +7 -1
- package/examples/jsm/nodes/accessors/InstanceNode.js +29 -12
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -47
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +4 -9
- package/examples/jsm/nodes/accessors/MorphNode.js +70 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +3 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +10 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +46 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -62
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +2 -2
- package/examples/jsm/nodes/accessors/TangentNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +68 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/code/CodeNode.js +3 -0
- package/examples/jsm/nodes/code/FunctionNode.js +25 -4
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/BypassNode.js +2 -2
- package/examples/jsm/nodes/core/ContextNode.js +2 -0
- package/examples/jsm/nodes/core/IndexNode.js +66 -0
- package/examples/jsm/nodes/core/LightingModel.js +2 -1
- package/examples/jsm/nodes/core/Node.js +13 -16
- package/examples/jsm/nodes/core/NodeAttribute.js +2 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +86 -8
- package/examples/jsm/nodes/core/NodeUtils.js +10 -0
- package/examples/jsm/nodes/core/PropertyNode.js +6 -2
- package/examples/jsm/nodes/core/StackNode.js +8 -1
- package/examples/jsm/nodes/core/UniformNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -3
- package/examples/jsm/nodes/display/BlendModeNode.js +9 -9
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +7 -7
- package/examples/jsm/nodes/display/ColorSpaceNode.js +50 -49
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +24 -15
- package/examples/jsm/nodes/display/ViewportDepthNode.js +69 -0
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +34 -0
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +7 -6
- package/examples/jsm/nodes/display/ViewportTextureNode.js +33 -19
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +5 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -8
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +2 -4
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/examples/jsm/nodes/functions/PhongLightingModel.js +7 -7
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +132 -19
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/examples/jsm/nodes/functions/material/getRoughness.js +3 -3
- package/examples/jsm/nodes/geometry/RangeNode.js +33 -51
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +6 -3
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +107 -62
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightUtils.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +17 -15
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +3 -3
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +41 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +1 -14
- package/examples/jsm/nodes/materials/NodeMaterial.js +119 -29
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +3 -3
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +14 -14
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +4 -4
- package/examples/jsm/nodes/math/MathNode.js +6 -0
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +60 -33
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -3
- package/examples/jsm/nodes/utils/LoopNode.js +186 -0
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +1 -1
- package/examples/jsm/objects/GroundProjectedSkybox.js +1 -1
- package/examples/jsm/objects/Lensflare.js +3 -4
- package/examples/jsm/objects/MarchingCubes.js +5 -1
- package/examples/jsm/objects/Reflector.js +4 -1
- package/examples/jsm/objects/Refractor.js +1 -1
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/Water.js +2 -1
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/offscreen/scene.js +1 -0
- package/examples/jsm/physics/RapierPhysics.js +93 -133
- package/examples/jsm/postprocessing/AfterimagePass.js +3 -0
- package/examples/jsm/postprocessing/BloomPass.js +7 -2
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -0
- package/examples/jsm/postprocessing/EffectComposer.js +4 -1
- package/examples/jsm/postprocessing/FilmPass.js +1 -0
- package/examples/jsm/postprocessing/OutlinePass.js +8 -9
- package/examples/jsm/postprocessing/OutputPass.js +72 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +4 -3
- package/examples/jsm/postprocessing/SAOPass.js +4 -2
- package/examples/jsm/postprocessing/SMAAPass.js +5 -2
- package/examples/jsm/postprocessing/SSAARenderPass.js +5 -13
- package/examples/jsm/postprocessing/SSAOPass.js +4 -2
- package/examples/jsm/postprocessing/SSRPass.js +3 -1
- package/examples/jsm/postprocessing/SavePass.js +5 -2
- package/examples/jsm/postprocessing/ShaderPass.js +1 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +17 -4
- package/examples/jsm/postprocessing/TexturePass.js +2 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +13 -13
- package/examples/jsm/renderers/{webgpu/WebGPUAnimation.js → common/Animation.js} +2 -2
- package/examples/jsm/renderers/common/Attributes.js +75 -0
- package/examples/jsm/renderers/common/Backend.js +162 -0
- package/examples/jsm/renderers/common/Background.js +134 -0
- package/examples/jsm/renderers/common/Binding.js +11 -0
- package/examples/jsm/renderers/common/Bindings.js +169 -0
- package/examples/jsm/renderers/common/Buffer.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPUBufferUtils.js → common/BufferUtils.js} +2 -2
- package/examples/jsm/renderers/{webgpu/WebGPUWeakMap.js → common/ChainMap.js} +11 -5
- package/examples/jsm/renderers/common/ComputePipeline.js +17 -0
- package/examples/jsm/renderers/common/Constants.js +14 -0
- package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -0
- package/examples/jsm/renderers/common/DataMap.js +54 -0
- package/examples/jsm/renderers/{webgpu/WebGPUGeometries.js → common/Geometries.js} +38 -37
- package/examples/jsm/renderers/{webgpu/WebGPUInfo.js → common/Info.js} +2 -3
- package/examples/jsm/renderers/common/Pipeline.js +13 -0
- package/examples/jsm/renderers/common/Pipelines.js +321 -0
- package/examples/jsm/renderers/common/ProgrammableStage.js +18 -0
- package/examples/jsm/renderers/common/RenderContext.js +37 -0
- package/examples/jsm/renderers/common/RenderContexts.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderLists.js → common/RenderList.js} +2 -39
- package/examples/jsm/renderers/common/RenderLists.js +38 -0
- package/examples/jsm/renderers/common/RenderObject.js +113 -0
- package/examples/jsm/renderers/common/RenderObjects.js +92 -0
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderTarget.js → common/RenderTarget.js} +2 -2
- package/examples/jsm/renderers/common/Renderer.js +864 -0
- package/examples/jsm/renderers/common/SampledTexture.js +80 -0
- package/examples/jsm/renderers/common/Sampler.js +18 -0
- package/examples/jsm/renderers/common/StorageBuffer.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +206 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniform.js → common/Uniform.js} +13 -9
- package/examples/jsm/renderers/common/UniformBuffer.js +15 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniformsGroup.js → common/UniformsGroup.js} +13 -13
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodes.js → common/nodes/NodeRender.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampledTexture.js → common/nodes/NodeSampledTexture.js} +4 -4
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampler.js → common/nodes/NodeSampler.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeUniform.js → common/nodes/NodeUniform.js} +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +319 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +340 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +23 -19
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +847 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +15 -1131
- package/examples/jsm/renderers/webgpu/nodes/{WebGPUNodeBuilder.js → WGSLNodeBuilder.js} +75 -45
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeFunction.js +2 -2
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeParser.js +1 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +255 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +145 -0
- package/examples/jsm/renderers/webgpu/{constants.js → utils/WebGPUConstants.js} +6 -7
- package/examples/jsm/renderers/webgpu/{WebGPURenderPipeline.js → utils/WebGPUPipelineUtils.js} +154 -247
- package/examples/jsm/renderers/webgpu/{WebGPUTextureUtils.js → utils/WebGPUTextureMipmapUtils.js} +3 -25
- package/examples/jsm/renderers/webgpu/{WebGPUTextures.js → utils/WebGPUTextureUtils.js} +392 -505
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +92 -0
- package/examples/jsm/shaders/BleachBypassShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +1 -2
- package/examples/jsm/shaders/BokehShader2.js +3 -0
- package/examples/jsm/shaders/ColorifyShader.js +2 -0
- package/examples/jsm/shaders/ConvolutionShader.js +2 -0
- package/examples/jsm/shaders/CopyShader.js +4 -2
- package/examples/jsm/shaders/DotScreenShader.js +2 -0
- package/examples/jsm/shaders/ExposureShader.js +44 -0
- package/examples/jsm/shaders/FilmShader.js +2 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +2 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +61 -0
- package/examples/jsm/shaders/RGBShiftShader.js +2 -0
- package/examples/jsm/shaders/SepiaShader.js +2 -0
- package/examples/jsm/shaders/ToonShader.js +13 -5
- package/examples/jsm/shaders/VerticalBlurShader.js +2 -0
- package/examples/jsm/shaders/VignetteShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +5 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +17 -1
- package/examples/jsm/utils/TextureUtils.js +86 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +34 -13
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +1 -0
- package/examples/jsm/webxr/XRPlanes.js +100 -0
- package/package.json +3 -1
- package/src/Three.Legacy.js +0 -228
- package/src/audio/PositionalAudio.js +8 -0
- package/src/cameras/Camera.js +5 -0
- package/src/cameras/CubeCamera.js +76 -13
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +13 -1
- package/src/core/BufferAttribute.js +3 -25
- package/src/core/BufferGeometry.js +1 -8
- package/src/core/Object3D.js +1 -1
- package/src/extras/core/Curve.js +1 -1
- package/src/loaders/CubeTextureLoader.js +2 -0
- package/src/loaders/Loader.js +2 -0
- package/src/loaders/MaterialLoader.js +5 -0
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/materials/Material.js +13 -1
- package/src/materials/MeshPhysicalMaterial.js +32 -6
- package/src/math/Color.js +16 -11
- package/src/math/Frustum.js +16 -2
- package/src/math/MathUtils.js +16 -0
- package/src/math/Matrix3.js +26 -6
- package/src/math/Matrix4.js +74 -19
- package/src/objects/InstancedMesh.js +3 -0
- package/src/objects/Mesh.js +14 -10
- package/src/objects/Skeleton.js +1 -3
- package/src/objects/SkinnedMesh.js +36 -8
- package/src/renderers/WebGLRenderer.js +126 -21
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +26 -3
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -2
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/{output_fragment.glsl.js → opaque_fragment.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +10 -5
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +6 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +7 -1
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +6 -1
- package/src/renderers/shaders/ShaderChunk.js +10 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +12 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/points.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib.js +4 -1
- package/src/renderers/shaders/UniformsLib.js +2 -0
- package/src/renderers/webgl/WebGLBindingStates.js +13 -5
- package/src/renderers/webgl/WebGLGeometries.js +12 -0
- package/src/renderers/webgl/WebGLInfo.js +0 -1
- package/src/renderers/webgl/WebGLMaterials.js +18 -0
- package/src/renderers/webgl/WebGLObjects.js +23 -3
- package/src/renderers/webgl/WebGLProgram.js +43 -5
- package/src/renderers/webgl/WebGLPrograms.js +19 -7
- package/src/renderers/webgl/WebGLTextures.js +19 -1
- package/src/renderers/webvr/WebVRManager.js +12 -0
- package/src/renderers/webxr/WebXRManager.js +39 -99
- package/src/scenes/Scene.js +0 -14
- package/src/textures/DepthTexture.js +22 -0
- package/src/textures/FramebufferTexture.js +1 -3
- package/src/textures/Source.js +4 -0
- package/src/textures/Texture.js +1 -1
- package/examples/jsm/exporters/ColladaExporter.js +0 -725
- package/examples/jsm/geometries/LightningStrike.js +0 -1017
- package/examples/jsm/loaders/PRWMLoader.js +0 -299
- package/examples/jsm/nodes/core/InstanceIndexNode.js +0 -26
- package/examples/jsm/objects/LightningStorm.js +0 -245
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -361
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +0 -197
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +0 -190
- package/examples/jsm/renderers/webgpu/WebGPUBinding.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +0 -270
- package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +0 -43
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +0 -78
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUProperties.js +0 -44
- package/examples/jsm/renderers/webgpu/WebGPURenderObject.js +0 -40
- package/examples/jsm/renderers/webgpu/WebGPURenderObjects.js +0 -50
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +0 -274
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +0 -54
- package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +0 -75
- package/examples/jsm/renderers/webgpu/WebGPUSampler.js +0 -29
- package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +0 -20
- package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +0 -38
- package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +0 -18
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +0 -88
- package/examples/jsm/shaders/ToneMapShader.js +0 -73
- /package/src/renderers/shaders/ShaderChunk/{encodings_fragment.glsl.js → colorspace_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{encodings_pars_fragment.glsl.js → colorspace_pars_fragment.glsl.js} +0 -0
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { GPULoadOp, GPUStoreOp } from './constants.js';
|
|
2
|
-
import { Color, Mesh, BoxGeometry, BackSide } from 'three';
|
|
3
|
-
import { context, positionWorldDirection, MeshBasicNodeMaterial } from '../../nodes/Nodes.js';
|
|
4
|
-
|
|
5
|
-
let _clearAlpha;
|
|
6
|
-
const _clearColor = new Color();
|
|
7
|
-
|
|
8
|
-
class WebGPUBackground {
|
|
9
|
-
|
|
10
|
-
constructor( renderer, properties ) {
|
|
11
|
-
|
|
12
|
-
this.renderer = renderer;
|
|
13
|
-
this.properties = properties;
|
|
14
|
-
|
|
15
|
-
this.boxMesh = null;
|
|
16
|
-
this.boxMeshNode = null;
|
|
17
|
-
|
|
18
|
-
this.forceClear = false;
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
clear() {
|
|
23
|
-
|
|
24
|
-
this.forceClear = true;
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
update( scene, renderList, renderState ) {
|
|
29
|
-
|
|
30
|
-
const renderer = this.renderer;
|
|
31
|
-
const background = ( scene.isScene === true ) ? scene.backgroundNode || this.properties.get( scene ).backgroundNode || scene.background : null;
|
|
32
|
-
|
|
33
|
-
let forceClear = this.forceClear;
|
|
34
|
-
|
|
35
|
-
if ( background === null ) {
|
|
36
|
-
|
|
37
|
-
// no background settings, use clear color configuration from the renderer
|
|
38
|
-
|
|
39
|
-
_clearColor.copy( renderer._clearColor );
|
|
40
|
-
_clearAlpha = renderer._clearAlpha;
|
|
41
|
-
|
|
42
|
-
} else if ( background.isColor === true ) {
|
|
43
|
-
|
|
44
|
-
// background is an opaque color
|
|
45
|
-
|
|
46
|
-
_clearColor.copy( background );
|
|
47
|
-
_clearAlpha = 1;
|
|
48
|
-
forceClear = true;
|
|
49
|
-
|
|
50
|
-
} else if ( background.isNode === true ) {
|
|
51
|
-
|
|
52
|
-
const sceneProperties = this.properties.get( scene );
|
|
53
|
-
const backgroundNode = background;
|
|
54
|
-
|
|
55
|
-
_clearColor.copy( renderer._clearColor );
|
|
56
|
-
_clearAlpha = renderer._clearAlpha;
|
|
57
|
-
|
|
58
|
-
let boxMesh = this.boxMesh;
|
|
59
|
-
|
|
60
|
-
if ( boxMesh === null ) {
|
|
61
|
-
|
|
62
|
-
this.boxMeshNode = context( backgroundNode, {
|
|
63
|
-
// @TODO: Add Texture2D support using node context
|
|
64
|
-
getUVNode: () => positionWorldDirection
|
|
65
|
-
} );
|
|
66
|
-
|
|
67
|
-
const nodeMaterial = new MeshBasicNodeMaterial();
|
|
68
|
-
nodeMaterial.colorNode = this.boxMeshNode;
|
|
69
|
-
nodeMaterial.side = BackSide;
|
|
70
|
-
nodeMaterial.depthTest = false;
|
|
71
|
-
nodeMaterial.depthWrite = false;
|
|
72
|
-
nodeMaterial.fog = false;
|
|
73
|
-
|
|
74
|
-
this.boxMesh = boxMesh = new Mesh( new BoxGeometry( 1, 1, 1 ), nodeMaterial );
|
|
75
|
-
boxMesh.frustumCulled = false;
|
|
76
|
-
|
|
77
|
-
boxMesh.onBeforeRender = function ( renderer, scene, camera ) {
|
|
78
|
-
|
|
79
|
-
const scale = camera.far;
|
|
80
|
-
|
|
81
|
-
this.matrixWorld.makeScale( scale, scale, scale ).copyPosition( camera.matrixWorld );
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const backgroundCacheKey = backgroundNode.getCacheKey();
|
|
88
|
-
|
|
89
|
-
if ( sceneProperties.backgroundCacheKey !== backgroundCacheKey ) {
|
|
90
|
-
|
|
91
|
-
this.boxMeshNode.node = backgroundNode;
|
|
92
|
-
|
|
93
|
-
boxMesh.material.needsUpdate = true;
|
|
94
|
-
|
|
95
|
-
sceneProperties.backgroundCacheKey = backgroundCacheKey;
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
renderList.unshift( boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null );
|
|
100
|
-
|
|
101
|
-
} else {
|
|
102
|
-
|
|
103
|
-
console.error( 'THREE.WebGPURenderer: Unsupported background configuration.', background );
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// configure render pass descriptor
|
|
108
|
-
|
|
109
|
-
const colorAttachment = renderState.descriptorGPU.colorAttachments[ 0 ];
|
|
110
|
-
const depthStencilAttachment = renderState.descriptorGPU.depthStencilAttachment;
|
|
111
|
-
|
|
112
|
-
if ( renderer.autoClear === true || forceClear === true ) {
|
|
113
|
-
|
|
114
|
-
if ( renderer.autoClearColor === true ) {
|
|
115
|
-
|
|
116
|
-
_clearColor.multiplyScalar( _clearAlpha );
|
|
117
|
-
|
|
118
|
-
colorAttachment.clearValue = { r: _clearColor.r, g: _clearColor.g, b: _clearColor.b, a: _clearAlpha };
|
|
119
|
-
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
120
|
-
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
121
|
-
|
|
122
|
-
} else {
|
|
123
|
-
|
|
124
|
-
colorAttachment.loadOp = GPULoadOp.Load;
|
|
125
|
-
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if ( renderState.depth ) {
|
|
130
|
-
|
|
131
|
-
if ( renderer.autoClearDepth === true ) {
|
|
132
|
-
|
|
133
|
-
depthStencilAttachment.depthClearValue = renderer._clearDepth;
|
|
134
|
-
depthStencilAttachment.depthLoadOp = GPULoadOp.Clear;
|
|
135
|
-
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
136
|
-
|
|
137
|
-
} else {
|
|
138
|
-
|
|
139
|
-
depthStencilAttachment.depthLoadOp = GPULoadOp.Load;
|
|
140
|
-
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if ( renderState.stencil ) {
|
|
147
|
-
|
|
148
|
-
if ( renderer.autoClearStencil === true ) {
|
|
149
|
-
|
|
150
|
-
depthStencilAttachment.stencilClearValue = renderer._clearStencil;
|
|
151
|
-
depthStencilAttachment.stencilLoadOp = GPULoadOp.Clear;
|
|
152
|
-
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
153
|
-
|
|
154
|
-
} else {
|
|
155
|
-
|
|
156
|
-
depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
157
|
-
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
} else {
|
|
164
|
-
|
|
165
|
-
colorAttachment.loadOp = GPULoadOp.Load;
|
|
166
|
-
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
167
|
-
|
|
168
|
-
if ( renderState.depth ) {
|
|
169
|
-
|
|
170
|
-
depthStencilAttachment.depthLoadOp = GPULoadOp.Load;
|
|
171
|
-
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if ( renderState.stencil ) {
|
|
176
|
-
|
|
177
|
-
depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
178
|
-
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
this.forceClear = false;
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export default WebGPUBackground;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
class WebGPUBinding {
|
|
2
|
-
|
|
3
|
-
constructor( name = '' ) {
|
|
4
|
-
|
|
5
|
-
this.name = name;
|
|
6
|
-
this.visibility = null;
|
|
7
|
-
|
|
8
|
-
this.type = null; // read-only
|
|
9
|
-
|
|
10
|
-
this.isShared = false;
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
setVisibility( visibility ) {
|
|
15
|
-
|
|
16
|
-
this.visibility = visibility;
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default WebGPUBinding;
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
class WebGPUBindings {
|
|
2
|
-
|
|
3
|
-
constructor( device, info, properties, textures, renderPipelines, computePipelines, attributes, nodes ) {
|
|
4
|
-
|
|
5
|
-
this.device = device;
|
|
6
|
-
this.info = info;
|
|
7
|
-
this.properties = properties;
|
|
8
|
-
this.textures = textures;
|
|
9
|
-
this.renderPipelines = renderPipelines;
|
|
10
|
-
this.computePipelines = computePipelines;
|
|
11
|
-
this.attributes = attributes;
|
|
12
|
-
this.nodes = nodes;
|
|
13
|
-
|
|
14
|
-
this.uniformsData = new WeakMap();
|
|
15
|
-
|
|
16
|
-
this.updateMap = new WeakMap();
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get( renderObject ) {
|
|
21
|
-
|
|
22
|
-
let data = this.uniformsData.get( renderObject );
|
|
23
|
-
|
|
24
|
-
if ( data === undefined ) {
|
|
25
|
-
|
|
26
|
-
// each object defines an array of bindings (ubos, textures, samplers etc.)
|
|
27
|
-
|
|
28
|
-
const nodeBuilder = this.nodes.get( renderObject );
|
|
29
|
-
const bindings = nodeBuilder.getBindings();
|
|
30
|
-
|
|
31
|
-
// setup (static) binding layout and (dynamic) binding group
|
|
32
|
-
|
|
33
|
-
const pipeline = this.renderPipelines.get( renderObject ).pipeline;
|
|
34
|
-
|
|
35
|
-
const bindLayout = pipeline.getBindGroupLayout( 0 );
|
|
36
|
-
const bindGroup = this._createBindGroup( bindings, bindLayout );
|
|
37
|
-
|
|
38
|
-
data = {
|
|
39
|
-
layout: bindLayout,
|
|
40
|
-
group: bindGroup,
|
|
41
|
-
bindings: bindings
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
this.uniformsData.set( renderObject, data );
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return data;
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
getForCompute( computeNode ) {
|
|
53
|
-
|
|
54
|
-
let data = this.uniformsData.get( computeNode );
|
|
55
|
-
|
|
56
|
-
if ( data === undefined ) {
|
|
57
|
-
|
|
58
|
-
// each object defines an array of bindings (ubos, textures, samplers etc.)
|
|
59
|
-
|
|
60
|
-
const nodeBuilder = this.nodes.getForCompute( computeNode );
|
|
61
|
-
const bindings = nodeBuilder.getBindings();
|
|
62
|
-
|
|
63
|
-
// setup (static) binding layout and (dynamic) binding group
|
|
64
|
-
|
|
65
|
-
const pipeline = this.computePipelines.get( computeNode );
|
|
66
|
-
|
|
67
|
-
const bindLayout = pipeline.getBindGroupLayout( 0 );
|
|
68
|
-
const bindGroup = this._createBindGroup( bindings, bindLayout );
|
|
69
|
-
|
|
70
|
-
data = {
|
|
71
|
-
layout: bindLayout,
|
|
72
|
-
group: bindGroup,
|
|
73
|
-
bindings: bindings
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
this.uniformsData.set( computeNode, data );
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return data;
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
remove( object ) {
|
|
85
|
-
|
|
86
|
-
this.uniformsData.delete( object );
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
update( object ) {
|
|
91
|
-
|
|
92
|
-
const textures = this.textures;
|
|
93
|
-
|
|
94
|
-
const data = this.get( object );
|
|
95
|
-
const bindings = data.bindings;
|
|
96
|
-
|
|
97
|
-
const updateMap = this.updateMap;
|
|
98
|
-
const frame = this.info.render.frame;
|
|
99
|
-
|
|
100
|
-
let needsBindGroupRefresh = false;
|
|
101
|
-
|
|
102
|
-
// iterate over all bindings and check if buffer updates or a new binding group is required
|
|
103
|
-
|
|
104
|
-
for ( const binding of bindings ) {
|
|
105
|
-
|
|
106
|
-
const isShared = binding.isShared;
|
|
107
|
-
const isUpdated = updateMap.get( binding ) === frame;
|
|
108
|
-
|
|
109
|
-
if ( isShared && isUpdated ) continue;
|
|
110
|
-
|
|
111
|
-
if ( binding.isUniformBuffer ) {
|
|
112
|
-
|
|
113
|
-
const buffer = binding.getBuffer();
|
|
114
|
-
const needsBufferWrite = binding.update();
|
|
115
|
-
|
|
116
|
-
if ( needsBufferWrite === true ) {
|
|
117
|
-
|
|
118
|
-
const bufferGPU = binding.bufferGPU;
|
|
119
|
-
|
|
120
|
-
this.device.queue.writeBuffer( bufferGPU, 0, buffer, 0 );
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
} else if ( binding.isStorageBuffer ) {
|
|
125
|
-
|
|
126
|
-
const attribute = binding.attribute;
|
|
127
|
-
|
|
128
|
-
this.attributes.update( attribute, false, binding.usage );
|
|
129
|
-
|
|
130
|
-
} else if ( binding.isSampler ) {
|
|
131
|
-
|
|
132
|
-
const texture = binding.getTexture();
|
|
133
|
-
|
|
134
|
-
textures.updateSampler( texture );
|
|
135
|
-
|
|
136
|
-
const samplerGPU = textures.getSampler( texture );
|
|
137
|
-
|
|
138
|
-
if ( binding.samplerGPU !== samplerGPU ) {
|
|
139
|
-
|
|
140
|
-
binding.samplerGPU = samplerGPU;
|
|
141
|
-
needsBindGroupRefresh = true;
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
} else if ( binding.isSampledTexture ) {
|
|
146
|
-
|
|
147
|
-
const texture = binding.getTexture();
|
|
148
|
-
|
|
149
|
-
const needsTextureRefresh = textures.updateTexture( texture );
|
|
150
|
-
|
|
151
|
-
const textureGPU = textures.getTextureGPU( texture );
|
|
152
|
-
|
|
153
|
-
if ( textureGPU !== undefined && binding.textureGPU !== textureGPU || needsTextureRefresh === true ) {
|
|
154
|
-
|
|
155
|
-
binding.textureGPU = textureGPU;
|
|
156
|
-
needsBindGroupRefresh = true;
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
updateMap.set( binding, frame );
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if ( needsBindGroupRefresh === true ) {
|
|
167
|
-
|
|
168
|
-
data.group = this._createBindGroup( bindings, data.layout );
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
dispose() {
|
|
175
|
-
|
|
176
|
-
this.uniformsData = new WeakMap();
|
|
177
|
-
this.updateMap = new WeakMap();
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
_createBindGroup( bindings, layout ) {
|
|
182
|
-
|
|
183
|
-
let bindingPoint = 0;
|
|
184
|
-
const entries = [];
|
|
185
|
-
|
|
186
|
-
for ( const binding of bindings ) {
|
|
187
|
-
|
|
188
|
-
if ( binding.isUniformBuffer ) {
|
|
189
|
-
|
|
190
|
-
if ( binding.bufferGPU === null ) {
|
|
191
|
-
|
|
192
|
-
const byteLength = binding.getByteLength();
|
|
193
|
-
|
|
194
|
-
binding.bufferGPU = this.device.createBuffer( {
|
|
195
|
-
label: 'bindingBuffer',
|
|
196
|
-
size: byteLength,
|
|
197
|
-
usage: binding.usage
|
|
198
|
-
} );
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
entries.push( { binding: bindingPoint, resource: { buffer: binding.bufferGPU } } );
|
|
203
|
-
|
|
204
|
-
} else if ( binding.isStorageBuffer ) {
|
|
205
|
-
|
|
206
|
-
if ( binding.bufferGPU === null ) {
|
|
207
|
-
|
|
208
|
-
const attribute = binding.attribute;
|
|
209
|
-
|
|
210
|
-
this.attributes.update( attribute, false, binding.usage );
|
|
211
|
-
binding.bufferGPU = this.attributes.get( attribute ).buffer;
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
entries.push( { binding: bindingPoint, resource: { buffer: binding.bufferGPU } } );
|
|
216
|
-
|
|
217
|
-
} else if ( binding.isSampler ) {
|
|
218
|
-
|
|
219
|
-
if ( binding.samplerGPU === null ) {
|
|
220
|
-
|
|
221
|
-
binding.samplerGPU = this.textures.getDefaultSampler();
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
entries.push( { binding: bindingPoint, resource: binding.samplerGPU } );
|
|
226
|
-
|
|
227
|
-
} else if ( binding.isSampledTexture ) {
|
|
228
|
-
|
|
229
|
-
if ( binding.textureGPU === null ) {
|
|
230
|
-
|
|
231
|
-
if ( binding.isSampledCubeTexture ) {
|
|
232
|
-
|
|
233
|
-
binding.textureGPU = this.textures.getDefaultCubeTexture();
|
|
234
|
-
|
|
235
|
-
} else if ( binding.texture.isVideoTexture ) {
|
|
236
|
-
|
|
237
|
-
binding.textureGPU = this.textures.getDefaultVideoTexture();
|
|
238
|
-
|
|
239
|
-
} else if ( binding.texture.isDepthTexture ) {
|
|
240
|
-
|
|
241
|
-
binding.textureGPU = this.textures.getDefaultDepthTexture();
|
|
242
|
-
|
|
243
|
-
} else {
|
|
244
|
-
|
|
245
|
-
binding.textureGPU = this.textures.getDefaultTexture();
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const resource = binding.textureGPU instanceof GPUTexture ? binding.textureGPU.createView( { aspect: binding.aspect, dimension: binding.dimension } ) : binding.textureGPU;
|
|
252
|
-
|
|
253
|
-
entries.push( { binding: bindingPoint, resource } );
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
bindingPoint ++;
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return this.device.createBindGroup( {
|
|
262
|
-
layout,
|
|
263
|
-
entries
|
|
264
|
-
} );
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export default WebGPUBindings;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import WebGPUBinding from './WebGPUBinding.js';
|
|
2
|
-
import { getFloatLength } from './WebGPUBufferUtils.js';
|
|
3
|
-
|
|
4
|
-
class WebGPUBuffer extends WebGPUBinding {
|
|
5
|
-
|
|
6
|
-
constructor( name, type, buffer = null ) {
|
|
7
|
-
|
|
8
|
-
super( name );
|
|
9
|
-
|
|
10
|
-
this.isBuffer = true;
|
|
11
|
-
|
|
12
|
-
this.bytesPerElement = Float32Array.BYTES_PER_ELEMENT;
|
|
13
|
-
this.type = type;
|
|
14
|
-
this.visibility = GPUShaderStage.VERTEX;
|
|
15
|
-
|
|
16
|
-
this.usage = GPUBufferUsage.COPY_DST;
|
|
17
|
-
|
|
18
|
-
this.buffer = buffer;
|
|
19
|
-
this.bufferGPU = null; // set by the renderer
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getByteLength() {
|
|
24
|
-
|
|
25
|
-
return getFloatLength( this.buffer.byteLength );
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getBuffer() {
|
|
30
|
-
|
|
31
|
-
return this.buffer;
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
update() {
|
|
36
|
-
|
|
37
|
-
return true;
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default WebGPUBuffer;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import WebGPUProgrammableStage from './WebGPUProgrammableStage.js';
|
|
2
|
-
|
|
3
|
-
class WebGPUComputePipelines {
|
|
4
|
-
|
|
5
|
-
constructor( device, nodes ) {
|
|
6
|
-
|
|
7
|
-
this.device = device;
|
|
8
|
-
this.nodes = nodes;
|
|
9
|
-
|
|
10
|
-
this.pipelines = new WeakMap();
|
|
11
|
-
this.stages = {
|
|
12
|
-
compute: new WeakMap()
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
has( computeNode ) {
|
|
18
|
-
|
|
19
|
-
return this.pipelines.get( computeNode ) !== undefined;
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get( computeNode ) {
|
|
24
|
-
|
|
25
|
-
let pipeline = this.pipelines.get( computeNode );
|
|
26
|
-
|
|
27
|
-
// @TODO: Reuse compute pipeline if possible, introduce WebGPUComputePipeline
|
|
28
|
-
|
|
29
|
-
if ( pipeline === undefined ) {
|
|
30
|
-
|
|
31
|
-
const device = this.device;
|
|
32
|
-
|
|
33
|
-
// get shader
|
|
34
|
-
|
|
35
|
-
const nodeBuilder = this.nodes.getForCompute( computeNode );
|
|
36
|
-
const computeShader = nodeBuilder.computeShader;
|
|
37
|
-
|
|
38
|
-
const shader = {
|
|
39
|
-
computeShader
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// programmable stage
|
|
43
|
-
|
|
44
|
-
let stageCompute = this.stages.compute.get( shader );
|
|
45
|
-
|
|
46
|
-
if ( stageCompute === undefined ) {
|
|
47
|
-
|
|
48
|
-
stageCompute = new WebGPUProgrammableStage( device, computeShader, 'compute' );
|
|
49
|
-
|
|
50
|
-
this.stages.compute.set( shader, stageCompute );
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
pipeline = device.createComputePipeline( {
|
|
55
|
-
compute: stageCompute.stage,
|
|
56
|
-
layout: 'auto'
|
|
57
|
-
} );
|
|
58
|
-
|
|
59
|
-
this.pipelines.set( computeNode, pipeline );
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return pipeline;
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
dispose() {
|
|
68
|
-
|
|
69
|
-
this.pipelines = new WeakMap();
|
|
70
|
-
this.stages = {
|
|
71
|
-
compute: new WeakMap()
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default WebGPUComputePipelines;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
let _id = 0;
|
|
2
|
-
|
|
3
|
-
class WebGPUProgrammableStage {
|
|
4
|
-
|
|
5
|
-
constructor( device, code, type ) {
|
|
6
|
-
|
|
7
|
-
this.id = _id ++;
|
|
8
|
-
|
|
9
|
-
this.code = code;
|
|
10
|
-
this.type = type;
|
|
11
|
-
this.usedTimes = 0;
|
|
12
|
-
|
|
13
|
-
this.stage = {
|
|
14
|
-
module: device.createShaderModule( { code, label: type } ),
|
|
15
|
-
entryPoint: 'main'
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default WebGPUProgrammableStage;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
class WebGPUProperties {
|
|
2
|
-
|
|
3
|
-
constructor() {
|
|
4
|
-
|
|
5
|
-
this.properties = new WeakMap();
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
get( object ) {
|
|
10
|
-
|
|
11
|
-
let map = this.properties.get( object );
|
|
12
|
-
|
|
13
|
-
if ( map === undefined ) {
|
|
14
|
-
|
|
15
|
-
map = {};
|
|
16
|
-
this.properties.set( object, map );
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return map;
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
remove( object ) {
|
|
25
|
-
|
|
26
|
-
this.properties.delete( object );
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
has( object ) {
|
|
31
|
-
|
|
32
|
-
return this.properties.has( object );
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
dispose() {
|
|
37
|
-
|
|
38
|
-
this.properties = new WeakMap();
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default WebGPUProperties;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export default class WebGPURenderObject {
|
|
2
|
-
|
|
3
|
-
constructor( renderer, nodes, object, material, scene, camera, lightsNode ) {
|
|
4
|
-
|
|
5
|
-
this.renderer = renderer;
|
|
6
|
-
this.nodes = nodes;
|
|
7
|
-
this.object = object;
|
|
8
|
-
this.material = material;
|
|
9
|
-
this.scene = scene;
|
|
10
|
-
this.camera = camera;
|
|
11
|
-
this.lightsNode = lightsNode;
|
|
12
|
-
|
|
13
|
-
this.geometry = object.geometry;
|
|
14
|
-
|
|
15
|
-
this._materialVersion = - 1;
|
|
16
|
-
this._materialCacheKey = '';
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
getCacheKey() {
|
|
21
|
-
|
|
22
|
-
const { material, scene, lightsNode } = this;
|
|
23
|
-
|
|
24
|
-
if ( material.version !== this._materialVersion ) {
|
|
25
|
-
|
|
26
|
-
this._materialVersion = material.version;
|
|
27
|
-
this._materialCacheKey = material.customProgramCacheKey();
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const cacheKey = [];
|
|
32
|
-
|
|
33
|
-
cacheKey.push( 'material:' + this._materialCacheKey );
|
|
34
|
-
cacheKey.push( 'nodes:' + this.nodes.getCacheKey( scene, lightsNode ) );
|
|
35
|
-
|
|
36
|
-
return '{' + cacheKey.join( ',' ) + '}';
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}
|