super-three 0.184.0 → 0.185.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 +1260 -927
- package/build/three.core.js +1104 -829
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +156 -98
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +11 -4
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +7538 -3367
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +7538 -3366
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -0
- package/examples/jsm/controls/ArcballControls.js +6 -2
- package/examples/jsm/controls/FirstPersonControls.js +79 -42
- package/examples/jsm/controls/TransformControls.js +68 -15
- package/examples/jsm/csm/CSMFrustum.js +31 -6
- package/examples/jsm/csm/CSMShadowNode.js +4 -1
- package/examples/jsm/effects/AsciiEffect.js +14 -1
- package/examples/jsm/exporters/DRACOExporter.js +27 -6
- package/examples/jsm/exporters/GLTFExporter.js +114 -12
- package/examples/jsm/exporters/PLYExporter.js +286 -73
- package/examples/jsm/exporters/USDZExporter.js +347 -112
- package/examples/jsm/generators/CityGenerator.js +346 -0
- package/examples/jsm/generators/ForestGenerator.js +347 -0
- package/examples/jsm/generators/TerrainGenerator.js +504 -0
- package/examples/jsm/generators/TreeGenerator.js +377 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +253 -0
- package/examples/jsm/generators/city/SkyscraperGenerator.js +1357 -0
- package/examples/jsm/geometries/LoftGeometry.js +355 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +5 -4
- package/examples/jsm/helpers/ViewHelper.js +16 -6
- package/examples/jsm/inspector/Inspector.js +53 -15
- package/examples/jsm/inspector/RendererInspector.js +152 -36
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +1 -1
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -1
- package/examples/jsm/inspector/tabs/Console.js +200 -18
- package/examples/jsm/inspector/tabs/Memory.js +8 -0
- package/examples/jsm/inspector/tabs/Parameters.js +64 -4
- package/examples/jsm/inspector/tabs/Performance.js +21 -6
- package/examples/jsm/inspector/tabs/Settings.js +51 -9
- package/examples/jsm/inspector/tabs/Timeline.js +178 -93
- package/examples/jsm/inspector/tabs/Viewer.js +628 -16
- package/examples/jsm/inspector/ui/Graph.js +162 -25
- package/examples/jsm/inspector/ui/Item.js +92 -13
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +90 -45
- package/examples/jsm/inspector/ui/Style.js +1788 -1401
- package/examples/jsm/inspector/ui/Tab.js +5 -3
- package/examples/jsm/inspector/ui/Values.js +71 -6
- package/examples/jsm/inspector/ui/utils.js +130 -10
- package/examples/jsm/libs/basis/README.md +0 -1
- package/examples/jsm/libs/demuxer_mp4.js +3 -3
- package/examples/jsm/libs/draco/README.md +0 -1
- package/examples/jsm/libs/meshopt_clusterizer.module.js +421 -0
- package/examples/jsm/libs/meshopt_simplifier.module.js +627 -0
- package/examples/jsm/libs/mikktspace.module.js +34 -9
- package/examples/jsm/lighting/ClusteredLighting.js +55 -0
- package/examples/jsm/lighting/LightProbeGrid.js +106 -76
- package/examples/jsm/lines/LineMaterial.js +38 -15
- package/examples/jsm/lines/LineSegments2.js +8 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +8 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +46 -13
- package/examples/jsm/loaders/EXRLoader.js +27 -55
- package/examples/jsm/loaders/HDRLoader.js +6 -28
- package/examples/jsm/loaders/KTX2Loader.js +31 -12
- package/examples/jsm/loaders/LDrawLoader.js +8 -8
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +2 -2
- package/examples/jsm/loaders/LWOLoader.js +4 -0
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +31 -9
- package/examples/jsm/loaders/NRRDLoader.js +3 -3
- package/examples/jsm/loaders/PCDLoader.js +7 -7
- package/examples/jsm/loaders/PLYLoader.js +218 -55
- package/examples/jsm/loaders/SVGLoader.js +547 -495
- package/examples/jsm/loaders/TTFLoader.js +1 -1
- package/examples/jsm/loaders/USDLoader.js +33 -9
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +93 -20
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/loaders/usd/USDComposer.js +52 -19
- package/examples/jsm/misc/TileCreasedNormalsPlugin.js +270 -0
- package/examples/jsm/misc/Volume.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +1 -1
- package/examples/jsm/objects/Reflector.js +2 -3
- package/examples/jsm/objects/Water2Mesh.js +1 -1
- package/examples/jsm/physics/AmmoPhysics.js +15 -8
- package/examples/jsm/physics/RapierPhysics.js +27 -2
- package/examples/jsm/shaders/VolumeShader.js +31 -44
- package/examples/jsm/transpiler/GLSLDecoder.js +6 -6
- package/examples/jsm/transpiler/Linker.js +1 -1
- package/examples/jsm/tsl/display/BloomNode.js +59 -19
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +2 -2
- package/examples/jsm/tsl/display/FXAANode.js +11 -12
- package/examples/jsm/tsl/display/GTAONode.js +34 -13
- package/examples/jsm/tsl/display/GodraysNode.js +1 -1
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +560 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -2
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +912 -0
- package/examples/jsm/tsl/display/SSAAPassNode.js +13 -25
- package/examples/jsm/tsl/display/SSGINode.js +89 -39
- package/examples/jsm/tsl/display/SSRNode.js +829 -132
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +1023 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +622 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +1 -1
- package/examples/jsm/tsl/math/curlNoise.js +107 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +1 -1
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +3 -3
- package/examples/jsm/tsl/utils/GroundedSkybox.js +62 -0
- package/examples/jsm/tsl/utils/RNoise.js +51 -0
- package/examples/jsm/tsl/utils/SpecularHelpers.js +325 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +126 -59
- package/examples/jsm/utils/GeometryCompressionUtils.js +1 -1
- package/examples/jsm/utils/SceneOptimizer.js +1 -1
- package/examples/jsm/webxr/ARButton.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +89 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +2 -2
- package/package.json +7 -7
- package/src/Three.TSL.js +10 -3
- package/src/Three.WebGPU.js +4 -0
- package/src/animation/AnimationAction.js +15 -11
- package/src/animation/AnimationClip.js +0 -139
- package/src/animation/KeyframeTrack.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/Camera.js +2 -2
- package/src/cameras/StereoCamera.js +5 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +29 -7
- package/src/core/Object3D.js +17 -7
- package/src/core/Raycaster.js +1 -1
- package/src/core/RenderTarget.js +15 -2
- package/src/extras/PMREMGenerator.js +6 -4
- package/src/extras/TextureUtils.js +1 -1
- package/src/extras/core/ShapePath.js +149 -160
- package/src/geometries/SphereGeometry.js +8 -3
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +1 -1
- package/src/loaders/DataTextureLoader.js +69 -38
- package/src/loaders/LoadingManager.js +5 -0
- package/src/loaders/MaterialLoader.js +36 -266
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +196 -1
- package/src/materials/MeshBasicMaterial.js +24 -0
- package/src/materials/MeshDepthMaterial.js +10 -0
- package/src/materials/MeshDistanceMaterial.js +10 -0
- package/src/materials/MeshLambertMaterial.js +40 -1
- package/src/materials/MeshMatcapMaterial.js +25 -1
- package/src/materials/MeshNormalMaterial.js +9 -1
- package/src/materials/MeshPhongMaterial.js +40 -1
- package/src/materials/MeshPhysicalMaterial.js +38 -0
- package/src/materials/MeshStandardMaterial.js +42 -1
- package/src/materials/MeshToonMaterial.js +34 -1
- package/src/materials/PointsMaterial.js +7 -0
- package/src/materials/ShaderMaterial.js +86 -0
- package/src/materials/SpriteMaterial.js +7 -0
- package/src/materials/nodes/Line2NodeMaterial.js +378 -322
- package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +0 -9
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +0 -30
- package/src/materials/nodes/MeshSSSNodeMaterial.js +0 -13
- package/src/materials/nodes/MeshStandardNodeMaterial.js +0 -11
- package/src/materials/nodes/NodeMaterial.js +115 -71
- package/src/materials/nodes/SpriteNodeMaterial.js +0 -10
- package/src/materials/nodes/manager/NodeMaterialObserver.js +49 -20
- package/src/math/Box3.js +5 -0
- package/src/math/FrustumArray.js +103 -133
- package/src/math/Interpolant.js +1 -1
- package/src/math/MathUtils.js +2 -2
- package/src/math/Matrix3.js +11 -0
- package/src/math/Matrix4.js +28 -3
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +2 -2
- package/src/math/interpolants/BezierInterpolant.js +4 -6
- package/src/nodes/Nodes.js +2 -5
- package/src/nodes/TSL.js +8 -6
- package/src/nodes/accessors/Arrays.js +4 -4
- package/src/nodes/accessors/Batch.js +108 -0
- package/src/nodes/accessors/Bitangent.js +2 -2
- package/src/nodes/accessors/BufferAttributeNode.js +13 -2
- package/src/nodes/accessors/Camera.js +7 -7
- package/src/nodes/accessors/ClippingNode.js +1 -1
- package/src/nodes/accessors/Instance.js +264 -0
- package/src/nodes/accessors/MaterialNode.js +18 -2
- package/src/nodes/accessors/MaterialProperties.js +4 -3
- package/src/nodes/accessors/{MorphNode.js → Morph.js} +99 -112
- package/src/nodes/accessors/Normal.js +13 -13
- package/src/nodes/accessors/Position.js +5 -1
- package/src/nodes/accessors/ReferenceNode.js +1 -0
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneProperties.js +1 -1
- package/src/nodes/accessors/Skinning.js +263 -0
- package/src/nodes/accessors/StorageBufferNode.js +2 -2
- package/src/nodes/accessors/StorageTexture3DNode.js +100 -0
- package/src/nodes/accessors/StorageTextureNode.js +39 -7
- package/src/nodes/accessors/Tangent.js +4 -4
- package/src/nodes/accessors/TextureNode.js +60 -5
- package/src/nodes/code/FunctionNode.js +2 -16
- package/src/nodes/core/MRTNode.js +7 -2
- package/src/nodes/core/Node.js +39 -2
- package/src/nodes/core/NodeBuilder.js +201 -41
- package/src/nodes/core/NodeUtils.js +13 -13
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/OverrideContextNode.js +153 -0
- package/src/nodes/core/PropertyNode.js +51 -5
- package/src/nodes/core/StackNode.js +56 -34
- package/src/nodes/core/StructNode.js +4 -6
- package/src/nodes/core/StructTypeNode.js +6 -6
- package/src/nodes/core/VarNode.js +8 -0
- package/src/nodes/core/VaryingNode.js +12 -2
- package/src/nodes/display/BlendModes.js +1 -41
- package/src/nodes/display/BumpMapNode.js +6 -1
- package/src/nodes/display/ColorAdjustment.js +10 -9
- package/src/nodes/display/FrontFacingNode.js +38 -9
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +35 -43
- package/src/nodes/display/PremultiplyAlphaFunctions.js +39 -0
- package/src/nodes/display/RenderOutputNode.js +12 -3
- package/src/nodes/functions/VolumetricLightingModel.js +40 -7
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
- package/src/nodes/lighting/EnvironmentNode.js +2 -2
- package/src/nodes/lighting/IESSpotLightNode.js +40 -2
- package/src/nodes/lighting/LightingContextNode.js +10 -2
- package/src/nodes/lighting/LightsNode.js +90 -37
- package/src/nodes/lighting/PointShadowNode.js +6 -1
- package/src/nodes/lighting/ShadowFilterNode.js +21 -52
- package/src/nodes/lighting/ShadowNode.js +34 -14
- package/src/nodes/materialx/lib/mx_noise.js +2 -2
- package/src/nodes/math/ConditionalNode.js +3 -3
- package/src/nodes/math/MathNode.js +39 -11
- package/src/nodes/math/OperatorNode.js +23 -23
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +33 -2
- package/src/nodes/tsl/TSLCore.js +63 -18
- package/src/nodes/utils/EquirectUV.js +30 -5
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/Packing.js +35 -4
- package/src/nodes/utils/RTTNode.js +40 -24
- package/src/nodes/utils/ReflectorNode.js +1 -0
- package/src/nodes/utils/StorageArrayElementNode.js +1 -1
- package/src/objects/BatchedMesh.js +22 -14
- package/src/objects/InstancedMesh.js +0 -11
- package/src/objects/Skeleton.js +0 -9
- package/src/renderers/WebGLRenderer.js +19 -15
- package/src/renderers/common/Backend.js +49 -5
- package/src/renderers/common/Bindings.js +114 -45
- package/src/renderers/common/Buffer.js +9 -0
- package/src/renderers/common/ClippingContext.js +10 -2
- package/src/renderers/common/Info.js +63 -22
- package/src/renderers/common/Lighting.js +53 -5
- package/src/renderers/common/RenderList.js +41 -4
- package/src/renderers/common/RenderObject.js +73 -13
- package/src/renderers/common/Renderer.js +281 -108
- package/src/renderers/common/Sampler.js +16 -48
- package/src/renderers/common/Textures.js +32 -5
- package/src/renderers/common/TimestampQueryPool.js +1 -1
- package/src/renderers/common/UniformsGroup.js +31 -9
- package/src/renderers/common/XRManager.js +340 -22
- package/src/renderers/common/extras/PMREMGenerator.js +15 -38
- package/src/renderers/common/nodes/NodeBuilderState.js +9 -1
- package/src/renderers/common/nodes/NodeLibrary.js +4 -4
- package/src/renderers/common/nodes/NodeManager.js +63 -14
- package/src/renderers/common/nodes/NodeUniformBuffer.js +13 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +13 -4
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +0 -6
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/distance.glsl.js +1 -1
- package/src/renderers/webgl/WebGLOutput.js +2 -1
- package/src/renderers/webgl/WebGLProgram.js +5 -4
- package/src/renderers/webgl/WebGLPrograms.js +12 -5
- package/src/renderers/webgl/WebGLRenderLists.js +9 -1
- package/src/renderers/webgl/WebGLShaderCache.js +5 -11
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUniformsGroups.js +66 -38
- package/src/renderers/webgl-fallback/WebGLBackend.js +84 -25
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +138 -8
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +4 -2
- package/src/renderers/webgpu/WebGPUBackend.js +480 -169
- package/src/renderers/webgpu/descriptors/GPUBindGroupDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUBufferDescriptor.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js +30 -0
- package/src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js +38 -0
- package/src/renderers/webgpu/descriptors/GPUComputePipelineDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js +47 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js +50 -0
- package/src/renderers/webgpu/descriptors/GPUExtent3D.js +51 -0
- package/src/renderers/webgpu/descriptors/GPUPipelineLayoutDescriptor.js +39 -0
- package/src/renderers/webgpu/descriptors/GPUQuerySetDescriptor.js +47 -0
- package/src/renderers/webgpu/descriptors/GPURenderBundleEncoderDescriptor.js +74 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDepthStencilAttachment.js +99 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDescriptor.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassTimestampWrites.js +49 -0
- package/src/renderers/webgpu/descriptors/GPURenderPipelineDescriptor.js +130 -0
- package/src/renderers/webgpu/descriptors/GPUSamplerDescriptor.js +119 -0
- package/src/renderers/webgpu/descriptors/GPUShaderModuleDescriptor.js +46 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferInfo.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferLayout.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyTextureInfo.js +61 -0
- package/src/renderers/webgpu/descriptors/GPUTextureDescriptor.js +99 -0
- package/src/renderers/webgpu/descriptors/GPUTextureViewDescriptor.js +108 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +164 -7
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +98 -38
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -68
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +164 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +158 -95
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +297 -141
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +33 -18
- package/src/renderers/webgpu/utils/WebGPUUtils.js +38 -3
- package/src/textures/DepthTexture.js +1 -1
- package/src/textures/ExternalTexture.js +0 -3
- package/examples/fonts/LICENSE +0 -13
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +0 -91
- package/examples/fonts/README.md +0 -11
- package/examples/fonts/droid/NOTICE +0 -190
- package/examples/fonts/droid/README.txt +0 -18
- package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
- package/examples/fonts/gentilis_bold.typeface.json +0 -1
- package/examples/fonts/gentilis_regular.typeface.json +0 -1
- package/examples/fonts/helvetiker_bold.typeface.json +0 -1
- package/examples/fonts/helvetiker_regular.typeface.json +0 -1
- package/examples/fonts/optimer_bold.typeface.json +0 -1
- package/examples/fonts/optimer_regular.typeface.json +0 -1
- package/examples/fonts/ttf/README.md +0 -9
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/inspector/extensions/extensions.json +0 -6
- package/examples/jsm/libs/ammo.wasm.js +0 -822
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
- package/examples/jsm/libs/lottie_canvas.module.js +0 -14849
- package/examples/jsm/libs/opentype.module.js +0 -14506
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lighting/TiledLighting.js +0 -42
- package/examples/jsm/tsl/display/AnamorphicNode.js +0 -293
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +0 -442
- package/src/nodes/accessors/BatchNode.js +0 -163
- package/src/nodes/accessors/InstanceNode.js +0 -349
- package/src/nodes/accessors/InstancedMeshNode.js +0 -50
- package/src/nodes/accessors/SkinningNode.js +0 -328
|
@@ -98,73 +98,101 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
98
98
|
|
|
99
99
|
for ( let i = 0, il = uniforms.length; i < il; i ++ ) {
|
|
100
100
|
|
|
101
|
-
const
|
|
101
|
+
const uniformItem = uniforms[ i ];
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
if ( Array.isArray( uniformItem ) ) {
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
for ( let j = 0, jl = uniformItem.length; j < jl; j ++ ) {
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
updateUniform( uniformItem[ j ], i, j, cache );
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
}
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
} else {
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
updateUniform( uniformItem, i, 0, cache );
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
gl.bindBuffer( gl.UNIFORM_BUFFER, null );
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
if ( typeof value === 'number' || typeof value === 'boolean' ) {
|
|
121
|
+
}
|
|
123
122
|
|
|
124
|
-
|
|
125
|
-
gl.bufferSubData( gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data );
|
|
123
|
+
function updateUniform( uniform, index, indexArray, cache ) {
|
|
126
124
|
|
|
127
|
-
|
|
125
|
+
if ( hasUniformChanged( uniform, index, indexArray, cache ) === true ) {
|
|
128
126
|
|
|
129
|
-
|
|
127
|
+
const offset = uniform.__offset;
|
|
128
|
+
const value = uniform.value;
|
|
130
129
|
|
|
131
|
-
|
|
132
|
-
uniform.__data[ 1 ] = value.elements[ 1 ];
|
|
133
|
-
uniform.__data[ 2 ] = value.elements[ 2 ];
|
|
134
|
-
uniform.__data[ 3 ] = 0;
|
|
135
|
-
uniform.__data[ 4 ] = value.elements[ 3 ];
|
|
136
|
-
uniform.__data[ 5 ] = value.elements[ 4 ];
|
|
137
|
-
uniform.__data[ 6 ] = value.elements[ 5 ];
|
|
138
|
-
uniform.__data[ 7 ] = 0;
|
|
139
|
-
uniform.__data[ 8 ] = value.elements[ 6 ];
|
|
140
|
-
uniform.__data[ 9 ] = value.elements[ 7 ];
|
|
141
|
-
uniform.__data[ 10 ] = value.elements[ 8 ];
|
|
142
|
-
uniform.__data[ 11 ] = 0;
|
|
130
|
+
if ( Array.isArray( value ) ) {
|
|
143
131
|
|
|
144
|
-
|
|
132
|
+
let arrayOffset = 0;
|
|
145
133
|
|
|
146
|
-
|
|
147
|
-
uniform.__data.set( new value.constructor( value.buffer, value.byteOffset, uniform.__data.length ) );
|
|
134
|
+
for ( let k = 0; k < value.length; k ++ ) {
|
|
148
135
|
|
|
149
|
-
|
|
136
|
+
const val = value[ k ];
|
|
137
|
+
const info = getUniformSize( val );
|
|
150
138
|
|
|
151
|
-
|
|
139
|
+
writeUniformValue( val, uniform.__data, arrayOffset );
|
|
152
140
|
|
|
153
|
-
|
|
141
|
+
// only toArray() values advance arrayOffset
|
|
142
|
+
if ( typeof val !== 'number' && typeof val !== 'boolean' && ! val.isMatrix3 && ! ArrayBuffer.isView( val ) ) {
|
|
154
143
|
|
|
155
|
-
|
|
144
|
+
arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
|
|
156
145
|
|
|
157
146
|
}
|
|
158
147
|
|
|
159
|
-
gl.bufferSubData( gl.UNIFORM_BUFFER, offset, uniform.__data );
|
|
160
|
-
|
|
161
148
|
}
|
|
162
149
|
|
|
150
|
+
} else {
|
|
151
|
+
|
|
152
|
+
writeUniformValue( value, uniform.__data, 0 );
|
|
153
|
+
|
|
163
154
|
}
|
|
164
155
|
|
|
156
|
+
gl.bufferSubData( gl.UNIFORM_BUFFER, offset, uniform.__data );
|
|
157
|
+
|
|
165
158
|
}
|
|
166
159
|
|
|
167
|
-
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function writeUniformValue( value, data, offset ) {
|
|
163
|
+
|
|
164
|
+
// TODO add integer and struct support
|
|
165
|
+
if ( typeof value === 'number' || typeof value === 'boolean' ) {
|
|
166
|
+
|
|
167
|
+
data[ 0 ] = value;
|
|
168
|
+
|
|
169
|
+
} else if ( value.isMatrix3 ) {
|
|
170
|
+
|
|
171
|
+
// manually converting 3x3 to 3x4
|
|
172
|
+
|
|
173
|
+
data[ 0 ] = value.elements[ 0 ];
|
|
174
|
+
data[ 1 ] = value.elements[ 1 ];
|
|
175
|
+
data[ 2 ] = value.elements[ 2 ];
|
|
176
|
+
data[ 3 ] = 0;
|
|
177
|
+
data[ 4 ] = value.elements[ 3 ];
|
|
178
|
+
data[ 5 ] = value.elements[ 4 ];
|
|
179
|
+
data[ 6 ] = value.elements[ 5 ];
|
|
180
|
+
data[ 7 ] = 0;
|
|
181
|
+
data[ 8 ] = value.elements[ 6 ];
|
|
182
|
+
data[ 9 ] = value.elements[ 7 ];
|
|
183
|
+
data[ 10 ] = value.elements[ 8 ];
|
|
184
|
+
data[ 11 ] = 0;
|
|
185
|
+
|
|
186
|
+
} else if ( ArrayBuffer.isView( value ) ) {
|
|
187
|
+
|
|
188
|
+
// copy the buffer data using "set"
|
|
189
|
+
data.set( new value.constructor( value.buffer, value.byteOffset, data.length ) );
|
|
190
|
+
|
|
191
|
+
} else {
|
|
192
|
+
|
|
193
|
+
value.toArray( data, offset );
|
|
194
|
+
|
|
195
|
+
}
|
|
168
196
|
|
|
169
197
|
}
|
|
170
198
|
|
|
@@ -307,6 +307,18 @@ class WebGLBackend extends Backend {
|
|
|
307
307
|
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Whether the backend supports query timestamps or not.
|
|
312
|
+
*
|
|
313
|
+
* @type {boolean}
|
|
314
|
+
* @readonly
|
|
315
|
+
*/
|
|
316
|
+
get hasTimestamp() {
|
|
317
|
+
|
|
318
|
+
return this.disjoint !== null;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
310
322
|
/**
|
|
311
323
|
* This method performs a readback operation by moving buffer data from
|
|
312
324
|
* a storage buffer attribute from the GPU to the CPU. ReadbackBuffer can
|
|
@@ -832,6 +844,14 @@ class WebGLBackend extends Backend {
|
|
|
832
844
|
|
|
833
845
|
if ( setFrameBuffer && resolveRenderTarget ) this._resolveRenderTarget( descriptor );
|
|
834
846
|
|
|
847
|
+
// Restore the framebuffer of the active render pass when clearing an unrelated
|
|
848
|
+
// render target, so subsequent draws in the pass don't bind to the cleared target.
|
|
849
|
+
if ( setFrameBuffer && this._currentContext !== null && this._currentContext !== descriptor ) {
|
|
850
|
+
|
|
851
|
+
this._setFramebuffer( this._currentContext );
|
|
852
|
+
|
|
853
|
+
}
|
|
854
|
+
|
|
835
855
|
}
|
|
836
856
|
|
|
837
857
|
}
|
|
@@ -1060,7 +1080,7 @@ class WebGLBackend extends Backend {
|
|
|
1060
1080
|
|
|
1061
1081
|
this._bindUniforms( renderObject.getBindings() );
|
|
1062
1082
|
|
|
1063
|
-
const frontFaceCW = ( object.isMesh && object.matrixWorld.
|
|
1083
|
+
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinantAffine() < 0 );
|
|
1064
1084
|
|
|
1065
1085
|
state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
|
|
1066
1086
|
|
|
@@ -1409,10 +1429,10 @@ class WebGLBackend extends Backend {
|
|
|
1409
1429
|
/**
|
|
1410
1430
|
* This method does nothing since WebGL 2 has no concept of samplers.
|
|
1411
1431
|
*
|
|
1412
|
-
* @param {
|
|
1432
|
+
* @param {Sampler} binding - The sampler binding to update.
|
|
1413
1433
|
* @return {string} The current sampler key.
|
|
1414
1434
|
*/
|
|
1415
|
-
updateSampler( /*
|
|
1435
|
+
updateSampler( /*binding*/ ) {
|
|
1416
1436
|
|
|
1417
1437
|
return '';
|
|
1418
1438
|
|
|
@@ -1621,7 +1641,7 @@ class WebGLBackend extends Backend {
|
|
|
1621
1641
|
const fragmentErrors = this._getShaderErrors( gl, glFragmentShader, 'fragment' );
|
|
1622
1642
|
|
|
1623
1643
|
error(
|
|
1624
|
-
'
|
|
1644
|
+
'WebGLProgram: Shader Error ' + gl.getError() + ' - ' +
|
|
1625
1645
|
'VALIDATE_STATUS ' + gl.getProgramParameter( programGPU, gl.VALIDATE_STATUS ) + '\n\n' +
|
|
1626
1646
|
'Program Info Log: ' + programLog + '\n' +
|
|
1627
1647
|
vertexErrors + '\n' +
|
|
@@ -1834,24 +1854,9 @@ class WebGLBackend extends Backend {
|
|
|
1834
1854
|
if ( binding.isUniformsGroup || binding.isUniformBuffer ) {
|
|
1835
1855
|
|
|
1836
1856
|
const array = binding.buffer;
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
if ( bufferGPU === undefined ) {
|
|
1840
|
-
|
|
1841
|
-
// create
|
|
1857
|
+
const bufferGPU = map.bufferGPU;
|
|
1842
1858
|
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1846
|
-
gl.bufferData( gl.UNIFORM_BUFFER, array.byteLength, gl.DYNAMIC_DRAW );
|
|
1847
|
-
|
|
1848
|
-
this.set( array, { bufferGPU } );
|
|
1849
|
-
|
|
1850
|
-
} else {
|
|
1851
|
-
|
|
1852
|
-
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1853
|
-
|
|
1854
|
-
}
|
|
1859
|
+
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1855
1860
|
|
|
1856
1861
|
// update
|
|
1857
1862
|
|
|
@@ -1883,8 +1888,6 @@ class WebGLBackend extends Backend {
|
|
|
1883
1888
|
|
|
1884
1889
|
}
|
|
1885
1890
|
|
|
1886
|
-
map.bufferGPU = bufferGPU;
|
|
1887
|
-
|
|
1888
1891
|
this.set( binding, map );
|
|
1889
1892
|
|
|
1890
1893
|
} else if ( binding.isSampledTexture ) {
|
|
@@ -1930,17 +1933,35 @@ class WebGLBackend extends Backend {
|
|
|
1930
1933
|
const isTyped = isTypedArray( array );
|
|
1931
1934
|
const byteOffsetFactor = isTyped ? 1 : array.BYTES_PER_ELEMENT;
|
|
1932
1935
|
|
|
1936
|
+
// Update ranges arrive sorted and non-overlapping which makes
|
|
1937
|
+
// it easy to merge contiguous ranges.
|
|
1938
|
+
|
|
1939
|
+
let start = updateRanges[ 0 ].start; // start of the current merged range
|
|
1940
|
+
|
|
1933
1941
|
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
1934
1942
|
|
|
1935
1943
|
const range = updateRanges[ i ];
|
|
1944
|
+
const next = updateRanges[ i + 1 ];
|
|
1945
|
+
|
|
1946
|
+
const end = range.start + range.count; // exclusive end of the current range
|
|
1936
1947
|
|
|
1937
|
-
|
|
1938
|
-
|
|
1948
|
+
// keep merging while the next range is contiguous
|
|
1949
|
+
|
|
1950
|
+
if ( next !== undefined && next.start === end ) continue;
|
|
1951
|
+
|
|
1952
|
+
// write the merged range
|
|
1953
|
+
|
|
1954
|
+
const dataOffset = start * byteOffsetFactor;
|
|
1955
|
+
const size = ( end - start ) * byteOffsetFactor;
|
|
1939
1956
|
|
|
1940
1957
|
const bufferOffset = dataOffset * ( isTyped ? array.BYTES_PER_ELEMENT : 1 ); // bufferOffset is always in bytes
|
|
1941
1958
|
|
|
1942
1959
|
gl.bufferSubData( gl.UNIFORM_BUFFER, bufferOffset, array, dataOffset, size );
|
|
1943
1960
|
|
|
1961
|
+
// start next if possible
|
|
1962
|
+
|
|
1963
|
+
if ( next !== undefined ) start = next.start;
|
|
1964
|
+
|
|
1944
1965
|
}
|
|
1945
1966
|
|
|
1946
1967
|
}
|
|
@@ -1951,6 +1972,44 @@ class WebGLBackend extends Backend {
|
|
|
1951
1972
|
|
|
1952
1973
|
// attributes
|
|
1953
1974
|
|
|
1975
|
+
/**
|
|
1976
|
+
* Creates a uniform buffer.
|
|
1977
|
+
*
|
|
1978
|
+
* @param {Buffer} uniformBuffer - The uniform buffer.
|
|
1979
|
+
*/
|
|
1980
|
+
createUniformBuffer( uniformBuffer ) {
|
|
1981
|
+
|
|
1982
|
+
const uniformBufferData = this.get( uniformBuffer );
|
|
1983
|
+
|
|
1984
|
+
if ( uniformBufferData.bufferGPU === undefined ) {
|
|
1985
|
+
|
|
1986
|
+
const gl = this.gl;
|
|
1987
|
+
const array = uniformBuffer.buffer;
|
|
1988
|
+
|
|
1989
|
+
uniformBufferData.bufferGPU = gl.createBuffer();
|
|
1990
|
+
|
|
1991
|
+
gl.bindBuffer( gl.UNIFORM_BUFFER, uniformBufferData.bufferGPU );
|
|
1992
|
+
gl.bufferData( gl.UNIFORM_BUFFER, array.byteLength, gl.DYNAMIC_DRAW );
|
|
1993
|
+
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
/**
|
|
1999
|
+
* Destroys the GPU data for the given uniform buffer.
|
|
2000
|
+
*
|
|
2001
|
+
* @param {Buffer} uniformBuffer - The uniform buffer.
|
|
2002
|
+
*/
|
|
2003
|
+
destroyUniformBuffer( uniformBuffer ) {
|
|
2004
|
+
|
|
2005
|
+
const uniformBufferData = this.get( uniformBuffer );
|
|
2006
|
+
|
|
2007
|
+
this.gl.deleteBuffer( uniformBufferData.bufferGPU );
|
|
2008
|
+
|
|
2009
|
+
this.delete( uniformBuffer );
|
|
2010
|
+
|
|
2011
|
+
}
|
|
2012
|
+
|
|
1954
2013
|
/**
|
|
1955
2014
|
* Creates the GPU buffer of an indexed shader attribute.
|
|
1956
2015
|
*
|
|
@@ -11,7 +11,67 @@ import { error } from '../../../utils.js';
|
|
|
11
11
|
|
|
12
12
|
const glslPolyfills = {
|
|
13
13
|
bitcast_int_uint: new CodeNode( /* glsl */'uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }' ),
|
|
14
|
-
bitcast_uint_int: new CodeNode( /* glsl */'uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }' )
|
|
14
|
+
bitcast_uint_int: new CodeNode( /* glsl */'uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }' ),
|
|
15
|
+
textureGather: new CodeNode( /* glsl */`
|
|
16
|
+
vec4 tsl_textureGather( const int comp, sampler2D map, vec2 coord, ivec2 offset, bool flipY ) {
|
|
17
|
+
if ( flipY ) offset.y = - offset.y;
|
|
18
|
+
vec2 size = vec2( textureSize( map, 0 ) );
|
|
19
|
+
vec2 st = floor( coord * size + vec2( offset ) - 0.5 );
|
|
20
|
+
vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
|
|
21
|
+
vec4 ret = vec4(
|
|
22
|
+
textureLod( map, ij.xw, 0.0 )[ comp ],
|
|
23
|
+
textureLod( map, ij.zw, 0.0 )[ comp ],
|
|
24
|
+
textureLod( map, ij.zy, 0.0 )[ comp ],
|
|
25
|
+
textureLod( map, ij.xy, 0.0 )[ comp ]
|
|
26
|
+
);
|
|
27
|
+
return flipY ? ret.wzyx : ret;
|
|
28
|
+
}
|
|
29
|
+
` ),
|
|
30
|
+
textureGatherArray: new CodeNode( /* glsl */`
|
|
31
|
+
vec4 tsl_textureGather_array( const int comp, sampler2DArray map, vec3 coord, ivec2 offset, bool flipY ) {
|
|
32
|
+
if ( flipY ) offset.y = - offset.y;
|
|
33
|
+
vec2 size = vec2( textureSize( map, 0 ).xy );
|
|
34
|
+
vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );
|
|
35
|
+
vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
|
|
36
|
+
vec4 ret = vec4(
|
|
37
|
+
textureLod( map, vec3( ij.xw, coord.z ), 0.0 )[ comp ],
|
|
38
|
+
textureLod( map, vec3( ij.zw, coord.z ), 0.0 )[ comp ],
|
|
39
|
+
textureLod( map, vec3( ij.zy, coord.z ), 0.0 )[ comp ],
|
|
40
|
+
textureLod( map, vec3( ij.xy, coord.z ), 0.0 )[ comp ]
|
|
41
|
+
);
|
|
42
|
+
return flipY ? ret.wzyx : ret;
|
|
43
|
+
}
|
|
44
|
+
` ),
|
|
45
|
+
textureGatherCompare: new CodeNode( /* glsl */`
|
|
46
|
+
vec4 tsl_textureGatherCompare( sampler2DShadow map, vec2 coord, ivec2 offset, float ref, bool flipY ) {
|
|
47
|
+
if ( flipY ) offset.y = - offset.y;
|
|
48
|
+
vec2 size = vec2( textureSize( map, 0 ) );
|
|
49
|
+
vec2 st = floor( coord * size + vec2( offset ) - 0.5 );
|
|
50
|
+
vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
|
|
51
|
+
vec4 ret = vec4(
|
|
52
|
+
textureLod( map, vec3( ij.xw, ref ), 0.0 ),
|
|
53
|
+
textureLod( map, vec3( ij.zw, ref ), 0.0 ),
|
|
54
|
+
textureLod( map, vec3( ij.zy, ref ), 0.0 ),
|
|
55
|
+
textureLod( map, vec3( ij.xy, ref ), 0.0 )
|
|
56
|
+
);
|
|
57
|
+
return flipY ? ret.wzyx : ret;
|
|
58
|
+
}
|
|
59
|
+
` ),
|
|
60
|
+
textureGatherCompareArray: new CodeNode( /* glsl */`
|
|
61
|
+
vec4 tsl_textureGatherCompare_array( sampler2DArrayShadow map, vec3 coord, ivec2 offset, float ref, bool flipY ) {
|
|
62
|
+
if ( flipY ) offset.y = - offset.y;
|
|
63
|
+
vec2 size = vec2( textureSize( map, 0 ).xy );
|
|
64
|
+
vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );
|
|
65
|
+
vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
|
|
66
|
+
vec4 ret = vec4(
|
|
67
|
+
texture( map, vec4( ij.xw, coord.z, ref ) ),
|
|
68
|
+
texture( map, vec4( ij.zw, coord.z, ref ) ),
|
|
69
|
+
texture( map, vec4( ij.zy, coord.z, ref ) ),
|
|
70
|
+
texture( map, vec4( ij.xy, coord.z, ref ) )
|
|
71
|
+
);
|
|
72
|
+
return flipY ? ret.wzyx : ret;
|
|
73
|
+
}
|
|
74
|
+
` )
|
|
15
75
|
};
|
|
16
76
|
|
|
17
77
|
const glslMethods = {
|
|
@@ -182,7 +242,7 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
182
242
|
*
|
|
183
243
|
* @param {string} type - The output type to bitcast to.
|
|
184
244
|
* @param {string} inputType - The input type of the.
|
|
185
|
-
* @return {string} The resolved
|
|
245
|
+
* @return {string} The resolved GLSL bitcast invocation.
|
|
186
246
|
*/
|
|
187
247
|
getBitcastMethod( type, inputType ) {
|
|
188
248
|
|
|
@@ -665,6 +725,72 @@ ${ flowData.code }
|
|
|
665
725
|
|
|
666
726
|
}
|
|
667
727
|
|
|
728
|
+
/**
|
|
729
|
+
* Generates the GLSL snippet for gathering four texels from the given texture.
|
|
730
|
+
*
|
|
731
|
+
* @param {Texture} texture - The texture.
|
|
732
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
733
|
+
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
734
|
+
* @param {string} gatherSnippet - A GLSL snippet that represents the index of the channel to read.
|
|
735
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents 0-based texture array index to sample.
|
|
736
|
+
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
737
|
+
* @param {?string} flipYSnippet - A GLSL snippet that represents the y-flip. Only used for WebGL.
|
|
738
|
+
* @return {string} The GLSL snippet.
|
|
739
|
+
*/
|
|
740
|
+
generateTextureGather( texture, textureProperty, uvSnippet, gatherSnippet, depthSnippet, offsetSnippet, flipYSnippet ) {
|
|
741
|
+
|
|
742
|
+
if ( texture.isDepthTexture ) gatherSnippet = '0';
|
|
743
|
+
|
|
744
|
+
if ( offsetSnippet === null ) offsetSnippet = 'ivec2( 0 )';
|
|
745
|
+
|
|
746
|
+
if ( flipYSnippet === null ) flipYSnippet = 'false';
|
|
747
|
+
|
|
748
|
+
if ( depthSnippet ) {
|
|
749
|
+
|
|
750
|
+
this._include( 'textureGatherArray' );
|
|
751
|
+
|
|
752
|
+
return `tsl_textureGather_array( ${gatherSnippet}, ${ textureProperty }, vec3( ${ uvSnippet }, ${ depthSnippet } ), ${ offsetSnippet }, ${ flipYSnippet } )`;
|
|
753
|
+
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
this._include( 'textureGather' );
|
|
757
|
+
|
|
758
|
+
return `tsl_textureGather( ${gatherSnippet}, ${ textureProperty }, ${ uvSnippet }, ${ offsetSnippet }, ${ flipYSnippet } )`;
|
|
759
|
+
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Generates the GLSL snippet for performing a depth comparison on four texels in the given depth texture.
|
|
764
|
+
*
|
|
765
|
+
* @param {Texture} texture - The texture.
|
|
766
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
767
|
+
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
768
|
+
* @param {string} compareSnippet - A GLSL snippet that represents the reference value.
|
|
769
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents 0-based texture array index to sample.
|
|
770
|
+
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
771
|
+
* @param {?string} flipYSnippet - A GLSL snippet that represents the y-flip. Only used for WebGL.
|
|
772
|
+
* @return {string} The GLSL snippet.
|
|
773
|
+
*/
|
|
774
|
+
generateTextureGatherCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet, offsetSnippet, flipYSnippet ) {
|
|
775
|
+
|
|
776
|
+
if ( offsetSnippet === null ) offsetSnippet = 'ivec2( 0 )';
|
|
777
|
+
|
|
778
|
+
if ( flipYSnippet === null ) flipYSnippet = 'false';
|
|
779
|
+
|
|
780
|
+
if ( depthSnippet ) {
|
|
781
|
+
|
|
782
|
+
this._include( 'textureGatherCompareArray' );
|
|
783
|
+
|
|
784
|
+
return `tsl_textureGatherCompare_array( ${ textureProperty }, vec3( ${ uvSnippet }, ${depthSnippet} ), ${ offsetSnippet }, ${ compareSnippet }, ${ flipYSnippet } )`;
|
|
785
|
+
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
this._include( 'textureGatherCompare' );
|
|
789
|
+
|
|
790
|
+
return `tsl_textureGatherCompare( ${ textureProperty }, ${ uvSnippet }, ${ offsetSnippet }, ${ compareSnippet }, ${ flipYSnippet } )`;
|
|
791
|
+
|
|
792
|
+
}
|
|
793
|
+
|
|
668
794
|
/**
|
|
669
795
|
* Returns the uniforms of the given shader stage as a GLSL string.
|
|
670
796
|
*
|
|
@@ -685,7 +811,8 @@ ${ flowData.code }
|
|
|
685
811
|
|
|
686
812
|
if ( uniform.type === 'texture' || uniform.type === 'texture3D' ) {
|
|
687
813
|
|
|
688
|
-
const
|
|
814
|
+
const textureNode = uniform.node;
|
|
815
|
+
const texture = textureNode.value;
|
|
689
816
|
|
|
690
817
|
let typePrefix = '';
|
|
691
818
|
|
|
@@ -707,7 +834,7 @@ ${ flowData.code }
|
|
|
707
834
|
|
|
708
835
|
snippet = `${typePrefix}sampler3D ${ uniform.name };`;
|
|
709
836
|
|
|
710
|
-
} else if ( texture.compareFunction ) {
|
|
837
|
+
} else if ( texture.compareFunction && textureNode.compareNode !== null ) {
|
|
711
838
|
|
|
712
839
|
if ( texture.isArrayTexture === true ) {
|
|
713
840
|
|
|
@@ -946,9 +1073,9 @@ ${ flowData.code }
|
|
|
946
1073
|
|
|
947
1074
|
}
|
|
948
1075
|
|
|
949
|
-
if ( outputSnippet.length === 0 ) {
|
|
1076
|
+
if ( shaderStage === 'fragment' && outputSnippet.length === 0 ) {
|
|
950
1077
|
|
|
951
|
-
outputSnippet.push(
|
|
1078
|
+
outputSnippet.push( `layout( location = 0 ) out ${ this.getOutputType() } fragColor;` );
|
|
952
1079
|
|
|
953
1080
|
}
|
|
954
1081
|
|
|
@@ -1390,6 +1517,9 @@ ${shaderData.extensions}
|
|
|
1390
1517
|
// precision
|
|
1391
1518
|
${ defaultPrecisions }
|
|
1392
1519
|
|
|
1520
|
+
// structs
|
|
1521
|
+
${shaderData.structs}
|
|
1522
|
+
|
|
1393
1523
|
// uniforms
|
|
1394
1524
|
${shaderData.uniforms}
|
|
1395
1525
|
|
|
@@ -1503,14 +1633,14 @@ void main() {
|
|
|
1503
1633
|
if ( shaderStage === 'vertex' ) {
|
|
1504
1634
|
|
|
1505
1635
|
flow += 'gl_Position = ';
|
|
1506
|
-
flow += `${ flowSlotData.result };`;
|
|
1636
|
+
flow += `${ this.format( flowSlotData.result, mainNode.getNodeType( this ), 'vec4' ) };`;
|
|
1507
1637
|
|
|
1508
1638
|
} else if ( shaderStage === 'fragment' ) {
|
|
1509
1639
|
|
|
1510
1640
|
if ( ! node.outputNode.isOutputStructNode ) {
|
|
1511
1641
|
|
|
1512
1642
|
flow += 'fragColor = ';
|
|
1513
|
-
flow += `${ flowSlotData.result };`;
|
|
1643
|
+
flow += `${ this.format( flowSlotData.result, mainNode.getNodeType( this ), this.getOutputType() ) };`;
|
|
1514
1644
|
|
|
1515
1645
|
}
|
|
1516
1646
|
|
|
@@ -286,7 +286,7 @@ class WebGLAttributeUtils {
|
|
|
286
286
|
|
|
287
287
|
if ( target._mapped === true ) {
|
|
288
288
|
|
|
289
|
-
throw new Error( 'WebGPURenderer: ReadbackBuffer must be released before being used again.' );
|
|
289
|
+
throw new Error( 'THREE.WebGPURenderer: ReadbackBuffer must be released before being used again.' );
|
|
290
290
|
|
|
291
291
|
}
|
|
292
292
|
|
|
@@ -429,30 +429,42 @@ class WebGLTextureUtils {
|
|
|
429
429
|
createTexture( texture, options ) {
|
|
430
430
|
|
|
431
431
|
const { gl, backend } = this;
|
|
432
|
-
const { levels, width, height, depth } = options;
|
|
433
432
|
|
|
434
|
-
|
|
435
|
-
const glType = backend.utils.convert( texture.type );
|
|
436
|
-
const glInternalFormat = this.getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, texture.isVideoTexture );
|
|
433
|
+
let textureGPU, glTextureType, glFormat, glType, glInternalFormat;
|
|
437
434
|
|
|
438
|
-
|
|
439
|
-
const glTextureType = this.getGLTextureType( texture );
|
|
435
|
+
if ( texture.isExternalTexture === true ) {
|
|
440
436
|
|
|
441
|
-
|
|
437
|
+
textureGPU = texture.sourceTexture;
|
|
438
|
+
glTextureType = this.getGLTextureType( texture );
|
|
442
439
|
|
|
443
|
-
|
|
440
|
+
} else {
|
|
444
441
|
|
|
445
|
-
|
|
442
|
+
const { levels, width, height, depth } = options;
|
|
446
443
|
|
|
447
|
-
|
|
444
|
+
glFormat = backend.utils.convert( texture.format, texture.colorSpace );
|
|
445
|
+
glType = backend.utils.convert( texture.type );
|
|
446
|
+
glInternalFormat = this.getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, texture.isVideoTexture );
|
|
448
447
|
|
|
449
|
-
|
|
448
|
+
textureGPU = gl.createTexture();
|
|
449
|
+
glTextureType = this.getGLTextureType( texture );
|
|
450
|
+
|
|
451
|
+
backend.state.bindTexture( glTextureType, textureGPU );
|
|
452
|
+
|
|
453
|
+
this.setTextureParameters( glTextureType, texture );
|
|
454
|
+
|
|
455
|
+
if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
|
|
456
|
+
|
|
457
|
+
gl.texStorage3D( gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, width, height, depth );
|
|
458
|
+
|
|
459
|
+
} else if ( texture.isData3DTexture ) {
|
|
450
460
|
|
|
451
|
-
|
|
461
|
+
gl.texStorage3D( gl.TEXTURE_3D, levels, glInternalFormat, width, height, depth );
|
|
452
462
|
|
|
453
|
-
|
|
463
|
+
} else if ( ! texture.isVideoTexture ) {
|
|
454
464
|
|
|
455
|
-
|
|
465
|
+
gl.texStorage2D( glTextureType, levels, glInternalFormat, width, height );
|
|
466
|
+
|
|
467
|
+
}
|
|
456
468
|
|
|
457
469
|
}
|
|
458
470
|
|
|
@@ -638,7 +650,19 @@ class WebGLTextureUtils {
|
|
|
638
650
|
|
|
639
651
|
if ( typeof gl.texElementImage2D === 'function' ) {
|
|
640
652
|
|
|
641
|
-
|
|
653
|
+
if ( gl.texElementImage2D.length === 3 ) {
|
|
654
|
+
|
|
655
|
+
// Chrome 150+
|
|
656
|
+
|
|
657
|
+
gl.texElementImage2D( gl.TEXTURE_2D, gl.RGBA8, options.image );
|
|
658
|
+
|
|
659
|
+
} else {
|
|
660
|
+
|
|
661
|
+
// Chrome 138 - 149
|
|
662
|
+
|
|
663
|
+
gl.texElementImage2D( gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, options.image );
|
|
664
|
+
|
|
665
|
+
}
|
|
642
666
|
|
|
643
667
|
}
|
|
644
668
|
|
|
@@ -762,7 +786,7 @@ class WebGLTextureUtils {
|
|
|
762
786
|
|
|
763
787
|
this.deallocateRenderBuffers( renderTarget );
|
|
764
788
|
|
|
765
|
-
if ( isDefaultTexture === false ) {
|
|
789
|
+
if ( isDefaultTexture === false && texture.isExternalTexture !== true ) {
|
|
766
790
|
|
|
767
791
|
gl.deleteTexture( textureGPU );
|
|
768
792
|
|
|
@@ -877,6 +901,9 @@ class WebGLTextureUtils {
|
|
|
877
901
|
const srcFramebuffer = srcRenderContextData.framebuffers[ srcTextureData.cacheKey ];
|
|
878
902
|
const dstFramebuffer = dstRenderContextData.framebuffers[ dstTextureData.cacheKey ];
|
|
879
903
|
|
|
904
|
+
const prevReadFramebuffer = state.currentBoundFramebuffers[ gl.READ_FRAMEBUFFER ] ?? null;
|
|
905
|
+
const prevDrawFramebuffer = state.currentBoundFramebuffers[ gl.DRAW_FRAMEBUFFER ] ?? null;
|
|
906
|
+
|
|
880
907
|
state.bindFramebuffer( gl.READ_FRAMEBUFFER, srcFramebuffer );
|
|
881
908
|
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, dstFramebuffer );
|
|
882
909
|
|
|
@@ -894,8 +921,8 @@ class WebGLTextureUtils {
|
|
|
894
921
|
|
|
895
922
|
}
|
|
896
923
|
|
|
897
|
-
state.bindFramebuffer( gl.READ_FRAMEBUFFER,
|
|
898
|
-
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER,
|
|
924
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, prevReadFramebuffer );
|
|
925
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, prevDrawFramebuffer );
|
|
899
926
|
|
|
900
927
|
} else if ( srcLevel !== 0 || srcTexture.isRenderTargetTexture || backend.has( srcTexture ) ) {
|
|
901
928
|
|
|
@@ -905,6 +932,9 @@ class WebGLTextureUtils {
|
|
|
905
932
|
if ( this._srcFramebuffer === null ) this._srcFramebuffer = gl.createFramebuffer();
|
|
906
933
|
if ( this._dstFramebuffer === null ) this._dstFramebuffer = gl.createFramebuffer();
|
|
907
934
|
|
|
935
|
+
const prevReadFramebuffer = state.currentBoundFramebuffers[ gl.READ_FRAMEBUFFER ] ?? null;
|
|
936
|
+
const prevDrawFramebuffer = state.currentBoundFramebuffers[ gl.DRAW_FRAMEBUFFER ] ?? null;
|
|
937
|
+
|
|
908
938
|
// bind the frame buffer targets
|
|
909
939
|
state.bindFramebuffer( gl.READ_FRAMEBUFFER, this._srcFramebuffer );
|
|
910
940
|
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, this._dstFramebuffer );
|
|
@@ -949,9 +979,9 @@ class WebGLTextureUtils {
|
|
|
949
979
|
|
|
950
980
|
}
|
|
951
981
|
|
|
952
|
-
//
|
|
953
|
-
state.bindFramebuffer( gl.READ_FRAMEBUFFER,
|
|
954
|
-
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER,
|
|
982
|
+
// restore previous read, draw framebuffer bindings
|
|
983
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, prevReadFramebuffer );
|
|
984
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, prevDrawFramebuffer );
|
|
955
985
|
|
|
956
986
|
} else {
|
|
957
987
|
|
|
@@ -1253,7 +1283,7 @@ class WebGLTextureUtils {
|
|
|
1253
1283
|
if ( glType === gl.HALF_FLOAT ) return Uint16Array;
|
|
1254
1284
|
if ( glType === gl.FLOAT ) return Float32Array;
|
|
1255
1285
|
|
|
1256
|
-
throw new Error( `Unsupported WebGL type: ${glType}` );
|
|
1286
|
+
throw new Error( `THREE.WebGLTextureUtils: Unsupported WebGL type: ${glType}` );
|
|
1257
1287
|
|
|
1258
1288
|
}
|
|
1259
1289
|
|