@needle-tools/three 0.169.20 → 0.183.2-canary.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/LICENSE +1 -1
- package/README.md +5 -6
- package/build/three.cjs +54178 -56709
- package/build/three.core.js +59506 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +11645 -73012
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +648 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +53905 -51657
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +53884 -51814
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +5 -15
- package/examples/jsm/animation/AnimationClipCreator.js +58 -6
- package/examples/jsm/animation/CCDIKSolver.js +152 -45
- package/examples/jsm/capabilities/WebGL.js +28 -29
- package/examples/jsm/capabilities/WebGPU.js +19 -17
- package/examples/jsm/controls/ArcballControls.js +474 -178
- package/examples/jsm/controls/DragControls.js +100 -58
- package/examples/jsm/controls/FirstPersonControls.js +116 -6
- package/examples/jsm/controls/FlyControls.js +50 -2
- package/examples/jsm/controls/MapControls.js +96 -8
- package/examples/jsm/controls/OrbitControls.js +496 -57
- package/examples/jsm/controls/PointerLockControls.js +115 -22
- package/examples/jsm/controls/TrackballControls.js +166 -14
- package/examples/jsm/controls/TransformControls.js +336 -26
- package/examples/jsm/csm/CSM.js +232 -18
- package/examples/jsm/csm/CSMFrustum.js +61 -4
- package/examples/jsm/csm/CSMHelper.js +50 -0
- package/examples/jsm/csm/CSMShader.js +13 -1
- package/examples/jsm/csm/CSMShadowNode.js +599 -0
- package/examples/jsm/curves/CurveExtras.js +303 -31
- package/examples/jsm/curves/NURBSCurve.js +91 -16
- package/examples/jsm/curves/NURBSSurface.js +52 -6
- package/examples/jsm/curves/NURBSUtils.js +102 -112
- package/examples/jsm/curves/NURBSVolume.js +24 -4
- package/examples/jsm/effects/AnaglyphEffect.js +134 -7
- package/examples/jsm/effects/AsciiEffect.js +69 -22
- package/examples/jsm/effects/OutlineEffect.js +61 -111
- package/examples/jsm/effects/ParallaxBarrierEffect.js +30 -0
- package/examples/jsm/effects/StereoEffect.js +31 -0
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/DebugEnvironment.js +50 -0
- package/examples/jsm/environments/RoomEnvironment.js +83 -42
- package/examples/jsm/exporters/DRACOExporter.js +56 -14
- package/examples/jsm/exporters/EXRExporter.js +40 -9
- package/examples/jsm/exporters/GLTFExporter.js +502 -169
- package/examples/jsm/exporters/OBJExporter.js +21 -1
- package/examples/jsm/exporters/PLYExporter.js +44 -12
- package/examples/jsm/exporters/STLExporter.js +27 -5
- package/examples/jsm/exporters/USDZExporter.js +781 -291
- package/examples/jsm/geometries/BoxLineGeometry.js +23 -0
- package/examples/jsm/geometries/ConvexGeometry.js +19 -0
- package/examples/jsm/geometries/DecalGeometry.js +91 -30
- package/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/examples/jsm/geometries/ParametricGeometry.js +38 -5
- package/examples/jsm/geometries/RoundedBoxGeometry.js +68 -7
- package/examples/jsm/geometries/TeapotGeometry.js +23 -38
- package/examples/jsm/geometries/TextGeometry.js +48 -29
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelper.js +36 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +38 -1
- package/examples/jsm/helpers/OctreeHelper.js +36 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +60 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +36 -3
- package/examples/jsm/helpers/TextureHelper.js +28 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +61 -2
- package/examples/jsm/helpers/VertexTangentsHelper.js +47 -2
- package/examples/jsm/helpers/ViewHelper.js +181 -9
- package/examples/jsm/inspector/Inspector.js +487 -0
- package/examples/jsm/inspector/RendererInspector.js +425 -0
- package/examples/jsm/inspector/tabs/Console.js +238 -0
- package/examples/jsm/inspector/tabs/Parameters.js +348 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +1975 -0
- package/examples/jsm/inspector/ui/Style.js +1613 -0
- package/examples/jsm/inspector/ui/Tab.js +233 -0
- package/examples/jsm/inspector/ui/Values.js +439 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +43 -12
- package/examples/jsm/interactive/InteractiveGroup.js +170 -52
- package/examples/jsm/interactive/SelectionBox.js +106 -9
- package/examples/jsm/interactive/SelectionHelper.js +76 -30
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +76 -58
- package/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/examples/jsm/lighting/TiledLighting.js +42 -0
- package/examples/jsm/lights/LightProbeGenerator.js +44 -7
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +50 -14
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +16 -0
- package/examples/jsm/lines/Line2.js +41 -4
- package/examples/jsm/lines/LineGeometry.js +80 -2
- package/examples/jsm/lines/LineMaterial.js +105 -5
- package/examples/jsm/lines/LineSegments2.js +54 -4
- package/examples/jsm/lines/LineSegmentsGeometry.js +65 -8
- package/examples/jsm/lines/Wireframe.js +41 -4
- package/examples/jsm/lines/WireframeGeometry2.js +27 -2
- package/examples/jsm/lines/webgpu/Line2.js +28 -2
- package/examples/jsm/lines/webgpu/LineSegments2.js +59 -24
- package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/examples/jsm/loaders/3DMLoader.js +78 -6
- package/examples/jsm/loaders/3MFLoader.js +148 -7
- package/examples/jsm/loaders/AMFLoader.js +34 -14
- package/examples/jsm/loaders/BVHLoader.js +59 -12
- package/examples/jsm/loaders/ColladaLoader.js +61 -4027
- package/examples/jsm/loaders/DDSLoader.js +68 -1
- package/examples/jsm/loaders/DRACOLoader.js +146 -22
- package/examples/jsm/loaders/EXRLoader.js +255 -34
- package/examples/jsm/loaders/FBXLoader.js +80 -42
- package/examples/jsm/loaders/FontLoader.js +83 -6
- package/examples/jsm/loaders/GCodeLoader.js +71 -14
- package/examples/jsm/loaders/GLTFLoader.js +381 -263
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +52 -3
- package/examples/jsm/loaders/HDRLoader.js +485 -0
- package/examples/jsm/loaders/IESLoader.js +42 -0
- package/examples/jsm/loaders/KMZLoader.js +39 -6
- package/examples/jsm/loaders/KTX2Loader.js +124 -48
- package/examples/jsm/loaders/KTXLoader.js +31 -10
- package/examples/jsm/loaders/LDrawLoader.js +192 -145
- package/examples/jsm/loaders/LUT3dlLoader.js +47 -10
- package/examples/jsm/loaders/LUTCubeLoader.js +46 -9
- package/examples/jsm/loaders/LUTImageLoader.js +79 -38
- package/examples/jsm/loaders/LWOLoader.js +54 -59
- package/examples/jsm/loaders/LottieLoader.js +54 -1
- package/examples/jsm/loaders/MD2Loader.js +37 -1
- package/examples/jsm/loaders/MDDLoader.js +57 -12
- package/examples/jsm/loaders/MTLLoader.js +60 -35
- package/examples/jsm/loaders/MaterialXLoader.js +268 -34
- package/examples/jsm/loaders/NRRDLoader.js +40 -8
- package/examples/jsm/loaders/OBJLoader.js +51 -2
- package/examples/jsm/loaders/PCDLoader.js +173 -21
- package/examples/jsm/loaders/PDBLoader.js +41 -2
- package/examples/jsm/loaders/PLYLoader.js +70 -39
- package/examples/jsm/loaders/PVRLoader.js +25 -6
- package/examples/jsm/loaders/RGBELoader.js +6 -438
- package/examples/jsm/loaders/STLLoader.js +48 -38
- package/examples/jsm/loaders/SVGLoader.js +119 -25
- package/examples/jsm/loaders/TDSLoader.js +92 -74
- package/examples/jsm/loaders/TGALoader.js +23 -2
- package/examples/jsm/loaders/TIFFLoader.js +23 -0
- package/examples/jsm/loaders/TTFLoader.js +50 -3
- package/examples/jsm/loaders/USDLoader.js +279 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -858
- package/examples/jsm/loaders/UltraHDRLoader.js +338 -166
- package/examples/jsm/loaders/VOXLoader.js +688 -87
- package/examples/jsm/loaders/VRMLLoader.js +121 -12
- package/examples/jsm/loaders/VTKLoader.js +77 -25
- package/examples/jsm/loaders/XYZLoader.js +36 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +77 -77
- package/examples/jsm/loaders/usd/USDAParser.js +822 -0
- package/examples/jsm/loaders/usd/USDCParser.js +1852 -0
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/Capsule.js +91 -14
- package/examples/jsm/math/ColorConverter.js +22 -0
- package/examples/jsm/math/ColorSpaces.js +74 -2
- package/examples/jsm/math/ConvexHull.js +517 -93
- package/examples/jsm/math/ImprovedNoise.js +32 -15
- package/examples/jsm/math/Lut.js +113 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +78 -13
- package/examples/jsm/math/OBB.js +141 -29
- package/examples/jsm/math/Octree.js +283 -7
- package/examples/jsm/math/SimplexNoise.js +68 -42
- package/examples/jsm/misc/ConvexObjectBreaker.js +45 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +96 -20
- package/examples/jsm/misc/Gyroscope.js +12 -0
- package/examples/jsm/misc/MD2Character.js +117 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +175 -11
- package/examples/jsm/misc/MorphAnimMesh.js +44 -0
- package/examples/jsm/misc/MorphBlendMesh.js +103 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +100 -54
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/examples/jsm/misc/RollerCoaster.js +57 -0
- package/examples/jsm/misc/TubePainter.js +437 -40
- package/examples/jsm/misc/Volume.js +123 -76
- package/examples/jsm/misc/VolumeSlice.js +95 -49
- package/examples/jsm/modifiers/CurveModifier.js +66 -38
- package/examples/jsm/modifiers/CurveModifierGPU.js +42 -19
- package/examples/jsm/modifiers/EdgeSplitModifier.js +20 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +24 -10
- package/examples/jsm/modifiers/TessellateModifier.js +35 -2
- package/examples/jsm/objects/GroundedSkybox.js +25 -6
- package/examples/jsm/objects/Lensflare.js +94 -2
- package/examples/jsm/objects/LensflareMesh.js +64 -10
- package/examples/jsm/objects/MarchingCubes.js +90 -5
- package/examples/jsm/objects/Reflector.js +76 -2
- package/examples/jsm/objects/ReflectorForSSRPass.js +41 -0
- package/examples/jsm/objects/Refractor.js +62 -0
- package/examples/jsm/objects/ShadowMesh.js +54 -4
- package/examples/jsm/objects/Sky.js +106 -16
- package/examples/jsm/objects/SkyMesh.js +211 -38
- package/examples/jsm/objects/Water.js +49 -8
- package/examples/jsm/objects/Water2.js +49 -7
- package/examples/jsm/objects/Water2Mesh.js +50 -9
- package/examples/jsm/objects/WaterMesh.js +136 -43
- package/examples/jsm/physics/AmmoPhysics.js +60 -7
- package/examples/jsm/physics/JoltPhysics.js +65 -12
- package/examples/jsm/physics/RapierPhysics.js +217 -21
- package/examples/jsm/postprocessing/AfterimagePass.js +110 -29
- package/examples/jsm/postprocessing/BloomPass.js +128 -26
- package/examples/jsm/postprocessing/BokehPass.js +99 -22
- package/examples/jsm/postprocessing/ClearPass.js +54 -3
- package/examples/jsm/postprocessing/CubeTexturePass.js +82 -21
- package/examples/jsm/postprocessing/DotScreenPass.js +59 -10
- package/examples/jsm/postprocessing/EffectComposer.js +140 -6
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.js +54 -5
- package/examples/jsm/postprocessing/GTAOPass.js +202 -57
- package/examples/jsm/postprocessing/GlitchPass.js +86 -34
- package/examples/jsm/postprocessing/HalftonePass.js +65 -10
- package/examples/jsm/postprocessing/LUTPass.js +38 -8
- package/examples/jsm/postprocessing/MaskPass.js +91 -0
- package/examples/jsm/postprocessing/OutlinePass.js +272 -135
- package/examples/jsm/postprocessing/OutputPass.js +65 -14
- package/examples/jsm/postprocessing/Pass.js +100 -4
- package/examples/jsm/postprocessing/RenderPass.js +94 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +124 -45
- package/examples/jsm/postprocessing/RenderTransitionPass.js +120 -21
- package/examples/jsm/postprocessing/SAOPass.js +128 -55
- package/examples/jsm/postprocessing/SMAAPass.js +106 -75
- package/examples/jsm/postprocessing/SSAARenderPass.js +118 -35
- package/examples/jsm/postprocessing/SSAOPass.js +173 -60
- package/examples/jsm/postprocessing/SSRPass.js +268 -53
- package/examples/jsm/postprocessing/SavePass.js +69 -16
- package/examples/jsm/postprocessing/ShaderPass.js +65 -7
- package/examples/jsm/postprocessing/TAARenderPass.js +79 -24
- package/examples/jsm/postprocessing/TexturePass.js +72 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +168 -59
- package/examples/jsm/renderers/CSS2DRenderer.js +98 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +111 -7
- package/examples/jsm/renderers/Projector.js +288 -32
- package/examples/jsm/renderers/SVGRenderer.js +323 -61
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +5 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +12 -5
- package/examples/jsm/shaders/AfterimageShader.js +8 -3
- package/examples/jsm/shaders/BasicShader.js +8 -1
- package/examples/jsm/shaders/BleachBypassShader.js +10 -3
- package/examples/jsm/shaders/BlendShader.js +8 -1
- package/examples/jsm/shaders/BokehShader.js +9 -3
- package/examples/jsm/shaders/BokehShader2.js +11 -4
- package/examples/jsm/shaders/BrightnessContrastShader.js +10 -4
- package/examples/jsm/shaders/ColorCorrectionShader.js +8 -1
- package/examples/jsm/shaders/ColorifyShader.js +8 -1
- package/examples/jsm/shaders/ConvolutionShader.js +9 -38
- package/examples/jsm/shaders/CopyShader.js +8 -1
- package/examples/jsm/shaders/DOFMipMapShader.js +10 -3
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +10 -1
- package/examples/jsm/shaders/DigitalGlitch.js +10 -7
- package/examples/jsm/shaders/DotScreenShader.js +8 -3
- package/examples/jsm/shaders/ExposureShader.js +8 -1
- package/examples/jsm/shaders/FXAAShader.js +233 -221
- package/examples/jsm/shaders/FilmShader.js +13 -0
- package/examples/jsm/shaders/FocusShader.js +8 -3
- package/examples/jsm/shaders/FreiChenShader.js +10 -3
- package/examples/jsm/shaders/GTAOShader.js +55 -45
- package/examples/jsm/shaders/GammaCorrectionShader.js +11 -2
- package/examples/jsm/shaders/HalftoneShader.js +24 -4
- package/examples/jsm/shaders/HorizontalBlurShader.js +12 -3
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +9 -2
- package/examples/jsm/shaders/HueSaturationShader.js +10 -3
- package/examples/jsm/shaders/KaleidoShader.js +11 -4
- package/examples/jsm/shaders/LuminosityHighPassShader.js +8 -4
- package/examples/jsm/shaders/LuminosityShader.js +8 -2
- package/examples/jsm/shaders/MirrorShader.js +10 -4
- package/examples/jsm/shaders/NormalMapShader.js +7 -2
- package/examples/jsm/shaders/OutputShader.js +19 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +30 -17
- package/examples/jsm/shaders/RGBShiftShader.js +8 -1
- package/examples/jsm/shaders/SAOShader.js +27 -5
- package/examples/jsm/shaders/SMAAShader.js +24 -1
- package/examples/jsm/shaders/SSAOShader.js +37 -6
- package/examples/jsm/shaders/SSRShader.js +32 -6
- package/examples/jsm/shaders/SepiaShader.js +8 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +9 -3
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +13 -8
- package/examples/jsm/shaders/TechnicolorShader.js +10 -4
- package/examples/jsm/shaders/ToonShader.js +29 -6
- package/examples/jsm/shaders/TriangleBlurShader.js +9 -4
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +19 -6
- package/examples/jsm/shaders/VelocityShader.js +8 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +9 -2
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +8 -1
- package/examples/jsm/shaders/VignetteShader.js +8 -3
- package/examples/jsm/shaders/VolumeShader.js +11 -2
- package/examples/jsm/shaders/WaterRefractionShader.js +11 -0
- package/examples/jsm/textures/FlakesTexture.js +14 -0
- package/examples/jsm/transpiler/AST.js +436 -31
- package/examples/jsm/transpiler/GLSLDecoder.js +380 -135
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +3 -1
- package/examples/jsm/transpiler/TSLEncoder.js +363 -97
- package/examples/jsm/transpiler/Transpiler.js +50 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +244 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +282 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +11 -4
- package/examples/jsm/tsl/display/BloomNode.js +534 -0
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
- package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
- package/examples/jsm/tsl/display/FXAANode.js +365 -0
- package/examples/jsm/tsl/display/FilmNode.js +101 -0
- package/examples/jsm/tsl/display/GTAONode.js +571 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +389 -0
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +279 -0
- package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
- package/examples/jsm/tsl/display/MotionBlur.js +33 -0
- package/examples/jsm/tsl/display/OutlineNode.js +762 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
- package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +768 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +120 -49
- package/examples/jsm/tsl/display/SSGINode.js +642 -0
- package/examples/jsm/tsl/display/SSRNode.js +656 -0
- package/examples/jsm/tsl/display/SSSNode.js +490 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +9 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +61 -19
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +48 -12
- package/examples/jsm/tsl/display/TRAANode.js +726 -0
- package/examples/jsm/tsl/display/TransitionNode.js +141 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/hashBlur.js +54 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
- package/examples/jsm/tsl/math/Bayer.js +73 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/examples/jsm/tsl/utils/Raymarching.js +70 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +91 -29
- package/examples/jsm/utils/CameraUtils.js +15 -6
- package/examples/jsm/utils/GeometryCompressionUtils.js +23 -30
- package/examples/jsm/utils/GeometryUtils.js +32 -27
- package/examples/jsm/utils/LDrawUtils.js +14 -5
- package/examples/jsm/utils/SceneOptimizer.js +458 -0
- package/examples/jsm/utils/SceneUtils.js +53 -3
- package/examples/jsm/utils/ShadowMapViewer.js +72 -33
- package/examples/jsm/utils/ShadowMapViewerGPU.js +61 -29
- package/examples/jsm/utils/SkeletonUtils.js +48 -0
- package/examples/jsm/utils/SortUtils.js +17 -5
- package/examples/jsm/utils/UVsDebug.js +12 -4
- package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +16 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +20 -2
- package/examples/jsm/utils/WorkerPool.js +67 -2
- package/examples/jsm/webxr/ARButton.js +19 -0
- package/examples/jsm/webxr/OculusHandModel.js +84 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +148 -22
- package/examples/jsm/webxr/Text2D.js +20 -6
- package/examples/jsm/webxr/VRButton.js +31 -0
- package/examples/jsm/webxr/XRButton.js +23 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +94 -3
- package/examples/jsm/webxr/XREstimatedLight.js +35 -4
- package/examples/jsm/webxr/XRHandMeshModel.js +37 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +96 -6
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +44 -0
- package/examples/jsm/webxr/XRPlanes.js +18 -0
- package/package.json +29 -34
- package/src/Three.Core.js +198 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +641 -0
- package/src/Three.WebGPU.Nodes.js +14 -186
- package/src/Three.WebGPU.js +16 -186
- package/src/Three.js +2 -197
- package/src/animation/AnimationAction.js +263 -31
- package/src/animation/AnimationClip.js +162 -7
- package/src/animation/AnimationMixer.js +99 -15
- package/src/animation/AnimationObjectGroup.js +45 -21
- package/src/animation/AnimationUtils.js +163 -24
- package/src/animation/KeyframeTrack.js +191 -17
- package/src/animation/PropertyBinding.js +91 -16
- package/src/animation/PropertyMixer.js +72 -5
- package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
- package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
- package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
- package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
- package/src/animation/tracks/StringKeyframeTrack.js +33 -2
- package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
- package/src/audio/Audio.js +386 -8
- package/src/audio/AudioAnalyser.js +58 -1
- package/src/audio/AudioContext.js +15 -0
- package/src/audio/AudioListener.js +94 -13
- package/src/audio/PositionalAudio.js +107 -0
- package/src/cameras/ArrayCamera.js +37 -0
- package/src/cameras/Camera.js +61 -0
- package/src/cameras/CubeCamera.js +86 -0
- package/src/cameras/OrthographicCamera.js +110 -1
- package/src/cameras/PerspectiveCamera.js +174 -35
- package/src/cameras/StereoCamera.js +48 -2
- package/src/constants.js +1546 -11
- package/src/core/BufferAttribute.js +417 -3
- package/src/core/BufferGeometry.js +407 -22
- package/src/core/Clock.js +69 -8
- package/src/core/EventDispatcher.js +52 -8
- package/src/core/GLBufferAttribute.js +113 -2
- package/src/core/InstancedBufferAttribute.js +29 -0
- package/src/core/InstancedBufferGeometry.js +20 -0
- package/src/core/InstancedInterleavedBuffer.js +26 -0
- package/src/core/InterleavedBuffer.js +141 -7
- package/src/core/InterleavedBufferAttribute.js +200 -2
- package/src/core/Layers.js +71 -10
- package/src/core/Object3D.js +673 -26
- package/src/core/Raycaster.js +136 -2
- package/src/core/RenderTarget.js +256 -27
- package/src/core/RenderTarget3D.js +48 -0
- package/src/core/Timer.js +184 -0
- package/src/core/Uniform.js +29 -0
- package/src/core/UniformsGroup.js +84 -2
- package/src/extras/Controls.js +89 -1
- package/src/extras/DataUtils.js +50 -9
- package/src/extras/Earcut.js +18 -779
- package/src/extras/ImageUtils.js +22 -14
- package/src/extras/PMREMGenerator.js +316 -67
- package/src/extras/ShapeUtils.js +24 -2
- package/src/extras/TextureUtils.js +101 -15
- package/src/extras/core/Curve.js +156 -55
- package/src/extras/core/CurvePath.js +63 -22
- package/src/extras/core/Interpolations.js +34 -2
- package/src/extras/core/Path.js +134 -1
- package/src/extras/core/Shape.js +66 -3
- package/src/extras/core/ShapePath.js +80 -4
- package/src/extras/curves/ArcCurve.js +22 -0
- package/src/extras/curves/CatmullRomCurve3.js +89 -18
- package/src/extras/curves/CubicBezierCurve.js +67 -0
- package/src/extras/curves/CubicBezierCurve3.js +50 -0
- package/src/extras/curves/EllipseCurve.js +102 -0
- package/src/extras/curves/LineCurve.js +36 -0
- package/src/extras/curves/LineCurve3.js +36 -0
- package/src/extras/curves/QuadraticBezierCurve.js +59 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +43 -0
- package/src/extras/curves/SplineCurve.js +48 -0
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/BoxGeometry.js +39 -0
- package/src/geometries/CapsuleGeometry.js +196 -11
- package/src/geometries/CircleGeometry.js +41 -0
- package/src/geometries/ConeGeometry.js +39 -0
- package/src/geometries/CylinderGeometry.js +42 -2
- package/src/geometries/DodecahedronGeometry.js +33 -0
- package/src/geometries/EdgesGeometry.js +30 -2
- package/src/geometries/ExtrudeGeometry.js +148 -52
- package/src/geometries/IcosahedronGeometry.js +33 -0
- package/src/geometries/LatheGeometry.js +44 -3
- package/src/geometries/OctahedronGeometry.js +33 -0
- package/src/geometries/PlaneGeometry.js +35 -0
- package/src/geometries/PolyhedronGeometry.js +30 -1
- package/src/geometries/RingGeometry.js +37 -0
- package/src/geometries/ShapeGeometry.js +38 -0
- package/src/geometries/SphereGeometry.js +38 -0
- package/src/geometries/TetrahedronGeometry.js +33 -0
- package/src/geometries/TorusGeometry.js +44 -3
- package/src/geometries/TorusKnotGeometry.js +39 -0
- package/src/geometries/TubeGeometry.js +50 -0
- package/src/geometries/WireframeGeometry.js +32 -0
- package/src/helpers/ArrowHelper.js +62 -5
- package/src/helpers/AxesHelper.js +28 -0
- package/src/helpers/Box3Helper.js +28 -0
- package/src/helpers/BoxHelper.js +43 -7
- package/src/helpers/CameraHelper.js +103 -27
- package/src/helpers/DirectionalLightHelper.js +55 -0
- package/src/helpers/GridHelper.js +26 -0
- package/src/helpers/HemisphereLightHelper.js +42 -0
- package/src/helpers/PlaneHelper.js +33 -0
- package/src/helpers/PointLightHelper.js +43 -24
- package/src/helpers/PolarGridHelper.js +30 -0
- package/src/helpers/SkeletonHelper.js +73 -7
- package/src/helpers/SpotLightHelper.js +43 -0
- package/src/lights/AmbientLight.js +25 -0
- package/src/lights/DirectionalLight.js +70 -0
- package/src/lights/DirectionalLightShadow.js +15 -0
- package/src/lights/HemisphereLight.js +42 -0
- package/src/lights/Light.js +37 -11
- package/src/lights/LightProbe.js +37 -9
- package/src/lights/LightShadow.js +202 -7
- package/src/lights/PointLight.js +74 -0
- package/src/lights/PointLightShadow.js +15 -80
- package/src/lights/RectAreaLight.js +59 -0
- package/src/lights/SpotLight.js +124 -1
- package/src/lights/SpotLightShadow.js +33 -3
- package/src/lights/webgpu/IESSpotLight.js +22 -0
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/AnimationLoader.js +34 -2
- package/src/loaders/AudioLoader.js +34 -2
- package/src/loaders/BufferGeometryLoader.js +38 -13
- package/src/loaders/Cache.js +75 -2
- package/src/loaders/CompressedTextureLoader.js +36 -3
- package/src/loaders/CubeTextureLoader.js +45 -0
- package/src/loaders/DataTextureLoader.js +45 -4
- package/src/loaders/FileLoader.js +85 -5
- package/src/loaders/ImageBitmapLoader.js +113 -11
- package/src/loaders/ImageLoader.js +85 -8
- package/src/loaders/Loader.js +144 -0
- package/src/loaders/LoaderUtils.js +18 -36
- package/src/loaders/LoadingManager.js +187 -0
- package/src/loaders/MaterialLoader.js +62 -3
- package/src/loaders/ObjectLoader.js +131 -31
- package/src/loaders/TextureLoader.js +33 -0
- package/src/loaders/nodes/NodeLoader.js +68 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/LineBasicMaterial.js +74 -1
- package/src/materials/LineDashedMaterial.js +52 -1
- package/src/materials/Material.js +502 -8
- package/src/materials/MeshBasicMaterial.js +168 -2
- package/src/materials/MeshDepthMaterial.js +94 -0
- package/src/materials/MeshDistanceMaterial.js +76 -0
- package/src/materials/MeshLambertMaterial.js +283 -0
- package/src/materials/MeshMatcapMaterial.js +164 -0
- package/src/materials/MeshNormalMaterial.js +114 -0
- package/src/materials/MeshPhongMaterial.js +298 -0
- package/src/materials/MeshPhysicalMaterial.js +296 -4
- package/src/materials/MeshStandardMaterial.js +300 -2
- package/src/materials/MeshToonMaterial.js +219 -0
- package/src/materials/PointsMaterial.js +89 -0
- package/src/materials/RawShaderMaterial.js +25 -0
- package/src/materials/ShaderMaterial.js +234 -6
- package/src/materials/ShadowMaterial.js +54 -0
- package/src/materials/SpriteMaterial.js +82 -0
- package/src/materials/nodes/Line2NodeMaterial.js +158 -53
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +81 -6
- package/src/materials/nodes/MeshBasicNodeMaterial.js +59 -2
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +23 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +27 -4
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +276 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +98 -10
- package/src/materials/nodes/MeshStandardNodeMaterial.js +83 -4
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +789 -74
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +180 -11
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +86 -23
- package/src/materials/nodes/VolumeNodeMaterial.js +57 -84
- package/src/materials/nodes/manager/NodeMaterialObserver.js +329 -12
- package/src/math/Box2.js +177 -0
- package/src/math/Box3.js +271 -0
- package/src/math/Color.js +355 -11
- package/src/math/ColorManagement.js +158 -92
- package/src/math/Cylindrical.js +65 -6
- package/src/math/Euler.js +139 -5
- package/src/math/Frustum.js +108 -9
- package/src/math/FrustumArray.js +258 -0
- package/src/math/Interpolant.js +87 -8
- package/src/math/Line3.js +221 -2
- package/src/math/MathUtils.js +408 -20
- package/src/math/Matrix2.js +70 -0
- package/src/math/Matrix3.js +229 -4
- package/src/math/Matrix4.js +489 -94
- package/src/math/Plane.js +164 -2
- package/src/math/Quaternion.js +322 -90
- package/src/math/Ray.js +162 -0
- package/src/math/Sphere.js +175 -0
- package/src/math/Spherical.js +73 -11
- package/src/math/SphericalHarmonics3.js +112 -14
- package/src/math/Triangle.js +206 -2
- package/src/math/Vector2.js +396 -10
- package/src/math/Vector3.js +550 -15
- package/src/math/Vector4.js +415 -9
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/math/interpolants/CubicInterpolant.js +10 -1
- package/src/math/interpolants/DiscreteInterpolant.js +10 -2
- package/src/math/interpolants/LinearInterpolant.js +13 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +10 -1
- package/src/nodes/Nodes.js +91 -88
- package/src/nodes/TSL.js +32 -38
- package/src/nodes/accessors/AccessorsUtils.js +37 -9
- package/src/nodes/accessors/Arrays.js +68 -0
- package/src/nodes/accessors/BatchNode.js +49 -14
- package/src/nodes/accessors/Bitangent.js +82 -13
- package/src/nodes/accessors/BufferAttributeNode.js +269 -8
- package/src/nodes/accessors/BufferNode.js +91 -2
- package/src/nodes/accessors/BuiltinNode.js +63 -0
- package/src/nodes/accessors/Camera.js +400 -10
- package/src/nodes/accessors/ClippingNode.js +149 -45
- package/src/nodes/accessors/CubeTextureNode.js +137 -7
- package/src/nodes/accessors/InstanceNode.js +245 -40
- package/src/nodes/accessors/InstancedMeshNode.js +50 -0
- package/src/nodes/accessors/Lights.js +88 -0
- package/src/nodes/accessors/MaterialNode.js +355 -13
- package/src/nodes/accessors/MaterialProperties.js +57 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +52 -14
- package/src/nodes/accessors/ModelNode.js +117 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -39
- package/src/nodes/accessors/MorphNode.js +73 -26
- package/src/nodes/accessors/Normal.js +174 -19
- package/src/nodes/accessors/Object3DNode.js +146 -12
- package/src/nodes/accessors/PointUVNode.js +25 -0
- package/src/nodes/accessors/Position.js +119 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +190 -4
- package/src/nodes/accessors/ReferenceNode.js +223 -8
- package/src/nodes/accessors/ReflectVector.js +29 -3
- package/src/nodes/accessors/RendererReferenceNode.js +45 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +180 -43
- package/src/nodes/accessors/StorageBufferNode.js +278 -26
- package/src/nodes/accessors/StorageTextureNode.js +205 -12
- package/src/nodes/accessors/Tangent.js +48 -10
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +104 -11
- package/src/nodes/accessors/TextureBicubic.js +31 -4
- package/src/nodes/accessors/TextureNode.js +564 -52
- package/src/nodes/accessors/TextureSizeNode.js +42 -1
- package/src/nodes/accessors/UV.js +9 -1
- package/src/nodes/accessors/UniformArrayNode.js +226 -34
- package/src/nodes/accessors/UserDataNode.js +46 -2
- package/src/nodes/accessors/VelocityNode.js +93 -3
- package/src/nodes/accessors/VertexColorNode.js +39 -4
- package/src/nodes/code/CodeNode.js +101 -8
- package/src/nodes/code/ExpressionNode.js +29 -2
- package/src/nodes/code/FunctionCallNode.js +98 -10
- package/src/nodes/code/FunctionNode.js +69 -2
- package/src/nodes/core/ArrayNode.js +174 -0
- package/src/nodes/core/AssignNode.js +80 -9
- package/src/nodes/core/AttributeNode.js +47 -4
- package/src/nodes/core/BypassNode.js +47 -3
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +220 -14
- package/src/nodes/core/IndexNode.js +72 -7
- package/src/nodes/core/InputNode.js +50 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/IsolateNode.js +133 -0
- package/src/nodes/core/LightingModel.js +65 -5
- package/src/nodes/core/MRTNode.js +113 -2
- package/src/nodes/core/Node.js +595 -36
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1840 -121
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +153 -24
- package/src/nodes/core/NodeFunction.js +48 -1
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +13 -1
- package/src/nodes/core/NodeUniform.js +53 -1
- package/src/nodes/core/NodeUtils.js +201 -51
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +47 -1
- package/src/nodes/core/OutputStructNode.js +54 -12
- package/src/nodes/core/ParameterNode.js +60 -2
- package/src/nodes/core/PropertyNode.js +286 -7
- package/src/nodes/core/StackNode.js +337 -20
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +134 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +126 -6
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +85 -7
- package/src/nodes/core/UniformNode.js +163 -16
- package/src/nodes/core/VarNode.js +317 -10
- package/src/nodes/core/VaryingNode.js +115 -13
- package/src/nodes/core/constants.js +40 -0
- package/src/nodes/display/BlendModes.js +171 -0
- package/src/nodes/display/BumpMapNode.js +38 -2
- package/src/nodes/display/ColorAdjustment.js +118 -6
- package/src/nodes/display/ColorSpaceFunctions.js +22 -6
- package/src/nodes/display/ColorSpaceNode.js +97 -47
- package/src/nodes/display/FrontFacingNode.js +64 -7
- package/src/nodes/display/NormalMapNode.js +101 -54
- package/src/nodes/display/PassNode.js +690 -33
- package/src/nodes/display/RenderOutputNode.js +94 -4
- package/src/nodes/display/ScreenNode.js +138 -27
- package/src/nodes/display/ToneMappingFunctions.js +62 -10
- package/src/nodes/display/ToneMappingNode.js +88 -8
- package/src/nodes/display/ToonOutlinePassNode.js +84 -4
- package/src/nodes/display/ViewportDepthNode.js +227 -10
- package/src/nodes/display/ViewportDepthTextureNode.js +39 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +35 -1
- package/src/nodes/display/ViewportTextureNode.js +171 -7
- package/src/nodes/fog/Fog.js +97 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +45 -1
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/BasicLightingModel.js +28 -6
- package/src/nodes/functions/PhongLightingModel.js +36 -6
- package/src/nodes/functions/PhysicalLightingModel.js +336 -91
- package/src/nodes/functions/ShadowMaskModel.js +30 -3
- package/src/nodes/functions/ToonLightingModel.js +21 -2
- package/src/nodes/functions/VolumetricLightingModel.js +183 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +10 -4
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
- package/src/nodes/geometry/RangeNode.js +97 -8
- package/src/nodes/gpgpu/AtomicFunctionNode.js +198 -23
- package/src/nodes/gpgpu/BarrierNode.js +52 -3
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +135 -6
- package/src/nodes/gpgpu/ComputeNode.js +212 -16
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +143 -9
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +186 -399
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +12 -11
- package/src/nodes/lighting/EnvironmentNode.js +59 -19
- package/src/nodes/lighting/HemisphereLightNode.js +33 -2
- package/src/nodes/lighting/IESSpotLightNode.js +13 -1
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +11 -3
- package/src/nodes/lighting/LightingContextNode.js +52 -4
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +238 -35
- package/src/nodes/lighting/PointLightNode.js +60 -25
- package/src/nodes/lighting/PointShadowNode.js +325 -0
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/RectAreaLightNode.js +50 -14
- package/src/nodes/lighting/ShadowBaseNode.js +81 -0
- package/src/nodes/lighting/ShadowFilterNode.js +264 -0
- package/src/nodes/lighting/ShadowNode.js +867 -0
- package/src/nodes/lighting/SpotLightNode.js +99 -18
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +166 -2
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +110 -21
- package/src/nodes/math/Hash.js +8 -0
- package/src/nodes/math/MathNode.js +820 -97
- package/src/nodes/math/MathUtils.js +47 -1
- package/src/nodes/math/OperatorNode.js +517 -84
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/TriNoise3D.js +17 -7
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +180 -23
- package/src/nodes/pmrem/PMREMUtils.js +114 -5
- package/src/nodes/procedural/Checker.js +8 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +10 -4
- package/src/nodes/tsl/TSLCore.js +732 -160
- package/src/nodes/utils/ArrayElementNode.js +55 -4
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +79 -2
- package/src/nodes/utils/DebugNode.js +83 -0
- package/src/nodes/utils/Discard.js +18 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +118 -0
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +91 -22
- package/src/nodes/utils/JoinNode.js +57 -4
- package/src/nodes/utils/LoopNode.js +193 -55
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -1
- package/src/nodes/utils/MemberNode.js +120 -0
- package/src/nodes/utils/Oscillators.js +41 -0
- package/src/nodes/utils/Packing.js +30 -1
- package/src/nodes/utils/PostProcessingUtils.js +154 -0
- package/src/nodes/utils/RTTNode.js +165 -9
- package/src/nodes/utils/ReflectorNode.js +407 -21
- package/src/nodes/utils/RemapNode.js +81 -2
- package/src/nodes/utils/RotateNode.js +41 -1
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +66 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/SpriteUtils.js +16 -0
- package/src/nodes/utils/StorageArrayElementNode.js +56 -3
- package/src/nodes/utils/Timer.js +26 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/nodes/utils/UVUtils.js +48 -0
- package/src/nodes/utils/ViewportUtils.js +12 -0
- package/src/objects/BatchedMesh.js +798 -309
- package/src/objects/Bone.js +24 -0
- package/src/objects/ClippingGroup.js +68 -0
- package/src/objects/Group.js +24 -0
- package/src/objects/InstancedMesh.js +131 -2
- package/src/objects/LOD.js +99 -5
- package/src/objects/Line.js +90 -7
- package/src/objects/LineLoop.js +20 -0
- package/src/objects/LineSegments.js +20 -1
- package/src/objects/Mesh.js +84 -0
- package/src/objects/Points.js +60 -0
- package/src/objects/Skeleton.js +120 -5
- package/src/objects/SkinnedMesh.js +102 -6
- package/src/objects/Sprite.js +65 -1
- package/src/renderers/WebGL3DRenderTarget.js +26 -0
- package/src/renderers/WebGLArrayRenderTarget.js +26 -0
- package/src/renderers/WebGLCubeRenderTarget.js +41 -5
- package/src/renderers/WebGLRenderTarget.js +19 -0
- package/src/renderers/WebGLRenderer.js +1016 -278
- package/src/renderers/common/Animation.js +123 -14
- package/src/renderers/common/Attributes.js +41 -1
- package/src/renderers/common/Backend.js +623 -44
- package/src/renderers/common/Background.js +99 -16
- package/src/renderers/common/BindGroup.js +37 -2
- package/src/renderers/common/Binding.js +46 -0
- package/src/renderers/common/Bindings.js +211 -20
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +89 -0
- package/src/renderers/common/BufferUtils.js +25 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +73 -10
- package/src/renderers/common/ClippingContext.js +172 -87
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/CubeRenderTarget.js +77 -7
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +163 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/src/renderers/common/Info.js +81 -36
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Lighting.js +57 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +150 -7
- package/src/renderers/common/PostProcessing.js +22 -84
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +63 -6
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +40 -10
- package/src/renderers/common/RenderContext.js +219 -4
- package/src/renderers/common/RenderContexts.js +54 -17
- package/src/renderers/common/RenderList.js +233 -24
- package/src/renderers/common/RenderLists.js +46 -6
- package/src/renderers/common/RenderObject.js +548 -46
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +133 -15
- package/src/renderers/common/RenderPipeline.js +216 -6
- package/src/renderers/common/Renderer.js +2155 -332
- package/src/renderers/common/RendererUtils.js +200 -0
- package/src/renderers/common/SampledTexture.js +99 -39
- package/src/renderers/common/Sampler.js +148 -1
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageBuffer.js +38 -2
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +65 -0
- package/src/renderers/common/Textures.js +273 -57
- package/src/renderers/common/TimestampQueryPool.js +163 -0
- package/src/renderers/common/Uniform.js +233 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +235 -26
- package/src/renderers/common/XRManager.js +1677 -0
- package/src/renderers/common/XRRenderTarget.js +91 -0
- package/src/renderers/common/extras/PMREMGenerator.js +371 -108
- package/src/renderers/common/nodes/NodeBuilderState.js +100 -6
- package/src/renderers/common/nodes/NodeLibrary.js +95 -17
- package/src/renderers/common/nodes/NodeManager.js +852 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +84 -8
- package/src/renderers/common/nodes/NodeSampler.js +41 -1
- package/src/renderers/common/nodes/NodeStorageBuffer.js +48 -3
- package/src/renderers/common/nodes/NodeUniform.js +285 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +81 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/shaders/DFGLUTData.js +49 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +154 -59
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +230 -181
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +14 -2
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +2 -7
- package/src/renderers/shaders/UniformsUtils.js +21 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLBackground.js +30 -5
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +7 -14
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLGeometries.js +10 -35
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +87 -148
- package/src/renderers/webgl/WebGLPrograms.js +53 -51
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +204 -28
- package/src/renderers/webgl/WebGLState.js +88 -56
- package/src/renderers/webgl/WebGLTextures.js +293 -59
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +7 -5
- package/src/renderers/webgl-fallback/WebGLBackend.js +1416 -293
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +5 -10
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +785 -92
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +62 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +3 -3
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +584 -20
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +468 -80
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +72 -24
- package/src/renderers/webgpu/WebGPUBackend.js +1517 -428
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +31 -4
- package/src/renderers/webgpu/WebGPURenderer.js +55 -4
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +23 -16
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +37 -42
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +1335 -241
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +32 -4
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +144 -20
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +460 -116
- package/src/renderers/webgpu/utils/WebGPUConstants.js +17 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +283 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +225 -178
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +583 -191
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +150 -28
- package/src/renderers/webxr/WebXRController.js +87 -2
- package/src/renderers/webxr/WebXRDepthSensing.js +52 -7
- package/src/renderers/webxr/WebXRManager.js +275 -15
- package/src/scenes/Fog.js +60 -0
- package/src/scenes/FogExp2.js +51 -0
- package/src/scenes/Scene.js +88 -0
- package/src/textures/CanvasTexture.js +28 -0
- package/src/textures/CompressedArrayTexture.js +57 -0
- package/src/textures/CompressedCubeTexture.js +29 -0
- package/src/textures/CompressedTexture.js +64 -6
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/CubeTexture.js +52 -4
- package/src/textures/Data3DTexture.js +79 -2
- package/src/textures/DataArrayTexture.js +93 -0
- package/src/textures/DataTexture.js +65 -0
- package/src/textures/DepthTexture.js +59 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +62 -0
- package/src/textures/Source.js +106 -4
- package/src/textures/Texture.js +488 -6
- package/src/textures/VideoFrameTexture.js +72 -0
- package/src/textures/VideoTexture.js +78 -6
- package/src/utils.js +322 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/examples/jsm/exporters/MMDExporter.js +0 -217
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -174
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +0 -729
- package/examples/jsm/loaders/MMDLoader.js +0 -2295
- package/examples/jsm/loaders/RGBMLoader.js +0 -1081
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -432
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -144
- package/examples/jsm/misc/Timer.js +0 -128
- package/examples/jsm/objects/InstancedPoints.js +0 -21
- package/examples/jsm/shaders/GodRaysShader.js +0 -321
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/accessors/SceneNode.js +0 -55
- package/src/nodes/code/ScriptableNode.js +0 -505
- package/src/nodes/code/ScriptableValueNode.js +0 -170
- package/src/nodes/core/CacheNode.js +0 -50
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/display/AfterImageNode.js +0 -158
- package/src/nodes/display/AnaglyphPassNode.js +0 -67
- package/src/nodes/display/AnamorphicNode.js +0 -151
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/BloomNode.js +0 -341
- package/src/nodes/display/DenoiseNode.js +0 -204
- package/src/nodes/display/DepthOfFieldNode.js +0 -124
- package/src/nodes/display/DotScreenNode.js +0 -66
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/display/FilmNode.js +0 -56
- package/src/nodes/display/GTAONode.js +0 -331
- package/src/nodes/display/GaussianBlurNode.js +0 -213
- package/src/nodes/display/Lut3DNode.js +0 -57
- package/src/nodes/display/MotionBlur.js +0 -25
- package/src/nodes/display/ParallaxBarrierPassNode.js +0 -58
- package/src/nodes/display/PixelationPassNode.js +0 -213
- package/src/nodes/display/PosterizeNode.js +0 -33
- package/src/nodes/display/RGBShiftNode.js +0 -53
- package/src/nodes/display/StereoCompositePassNode.js +0 -110
- package/src/nodes/display/TransitionNode.js +0 -80
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -30
- package/src/nodes/utils/EquirectUVNode.js +0 -36
- package/src/nodes/utils/MatcapUVNode.js +0 -33
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -45
- package/src/nodes/utils/TimerNode.js +0 -97
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -64
- package/src/renderers/common/nodes/Nodes.js +0 -534
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -136
|
@@ -1,20 +1,75 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping,
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, NoColorSpace, LinearTransfer, SRGBTransfer } from '../../../constants.js';
|
|
2
|
+
import { ColorManagement } from '../../../math/ColorManagement.js';
|
|
3
|
+
import { getByteLength } from '../../../extras/TextureUtils.js';
|
|
4
|
+
import { warn } from '../../../utils.js';
|
|
2
5
|
|
|
3
6
|
let initialized = false, wrappingToGL, filterToGL, compareToGL;
|
|
4
7
|
|
|
8
|
+
/**
|
|
9
|
+
* A WebGL 2 backend utility module for managing textures.
|
|
10
|
+
*
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
5
13
|
class WebGLTextureUtils {
|
|
6
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a new utility object.
|
|
17
|
+
*
|
|
18
|
+
* @param {WebGLBackend} backend - The WebGL 2 backend.
|
|
19
|
+
*/
|
|
7
20
|
constructor( backend ) {
|
|
8
21
|
|
|
22
|
+
/**
|
|
23
|
+
* A reference to the WebGL 2 backend.
|
|
24
|
+
*
|
|
25
|
+
* @type {WebGLBackend}
|
|
26
|
+
*/
|
|
9
27
|
this.backend = backend;
|
|
10
28
|
|
|
29
|
+
/**
|
|
30
|
+
* A reference to the rendering context.
|
|
31
|
+
*
|
|
32
|
+
* @type {WebGL2RenderingContext}
|
|
33
|
+
*/
|
|
11
34
|
this.gl = backend.gl;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A reference to a backend module holding extension-related
|
|
38
|
+
* utility functions.
|
|
39
|
+
*
|
|
40
|
+
* @type {WebGLExtensions}
|
|
41
|
+
*/
|
|
12
42
|
this.extensions = backend.extensions;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A dictionary for managing default textures. The key
|
|
46
|
+
* is the binding point (target), the value the WEbGL texture object.
|
|
47
|
+
*
|
|
48
|
+
* @type {Object<GLenum,WebGLTexture>}
|
|
49
|
+
*/
|
|
13
50
|
this.defaultTextures = {};
|
|
14
51
|
|
|
52
|
+
/**
|
|
53
|
+
* A scratch framebuffer used for attaching the source texture in
|
|
54
|
+
* {@link copyTextureToTexture}.
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
* @type {?WebGLFramebuffer}
|
|
58
|
+
*/
|
|
59
|
+
this._srcFramebuffer = null;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A scratch framebuffer used for attaching the destination texture in
|
|
63
|
+
* {@link copyTextureToTexture}.
|
|
64
|
+
*
|
|
65
|
+
* @private
|
|
66
|
+
* @type {?WebGLFramebuffer}
|
|
67
|
+
*/
|
|
68
|
+
this._dstFramebuffer = null;
|
|
69
|
+
|
|
15
70
|
if ( initialized === false ) {
|
|
16
71
|
|
|
17
|
-
this._init(
|
|
72
|
+
this._init();
|
|
18
73
|
|
|
19
74
|
initialized = true;
|
|
20
75
|
|
|
@@ -22,7 +77,14 @@ class WebGLTextureUtils {
|
|
|
22
77
|
|
|
23
78
|
}
|
|
24
79
|
|
|
25
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Inits the state of the utility.
|
|
82
|
+
*
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
_init() {
|
|
86
|
+
|
|
87
|
+
const gl = this.gl;
|
|
26
88
|
|
|
27
89
|
// Store only WebGL constants here.
|
|
28
90
|
|
|
@@ -55,20 +117,12 @@ class WebGLTextureUtils {
|
|
|
55
117
|
|
|
56
118
|
}
|
|
57
119
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return gl.NEAREST;
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return gl.LINEAR;
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Returns the native texture type for the given texture.
|
|
122
|
+
*
|
|
123
|
+
* @param {Texture} texture - The texture.
|
|
124
|
+
* @return {GLenum} The native texture type.
|
|
125
|
+
*/
|
|
72
126
|
getGLTextureType( texture ) {
|
|
73
127
|
|
|
74
128
|
const { gl } = this;
|
|
@@ -79,7 +133,7 @@ class WebGLTextureUtils {
|
|
|
79
133
|
|
|
80
134
|
glTextureType = gl.TEXTURE_CUBE_MAP;
|
|
81
135
|
|
|
82
|
-
} else if ( texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
136
|
+
} else if ( texture.isArrayTexture === true || texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
83
137
|
|
|
84
138
|
glTextureType = gl.TEXTURE_2D_ARRAY;
|
|
85
139
|
|
|
@@ -98,6 +152,16 @@ class WebGLTextureUtils {
|
|
|
98
152
|
|
|
99
153
|
}
|
|
100
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Returns the native texture type for the given texture.
|
|
157
|
+
*
|
|
158
|
+
* @param {?string} internalFormatName - The internal format name. When `null`, the internal format is derived from the subsequent parameters.
|
|
159
|
+
* @param {GLenum} glFormat - The WebGL format.
|
|
160
|
+
* @param {GLenum} glType - The WebGL type.
|
|
161
|
+
* @param {string} colorSpace - The texture's color space.
|
|
162
|
+
* @param {boolean} [forceLinearTransfer=false] - Whether to force a linear transfer or not.
|
|
163
|
+
* @return {GLenum} The internal format.
|
|
164
|
+
*/
|
|
101
165
|
getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
102
166
|
|
|
103
167
|
const { gl, extensions } = this;
|
|
@@ -106,7 +170,7 @@ class WebGLTextureUtils {
|
|
|
106
170
|
|
|
107
171
|
if ( gl[ internalFormatName ] !== undefined ) return gl[ internalFormatName ];
|
|
108
172
|
|
|
109
|
-
|
|
173
|
+
warn( 'WebGLBackend: Attempt to use non-existing WebGL internal format \'' + internalFormatName + '\'' );
|
|
110
174
|
|
|
111
175
|
}
|
|
112
176
|
|
|
@@ -162,6 +226,8 @@ class WebGLTextureUtils {
|
|
|
162
226
|
|
|
163
227
|
if ( glFormat === gl.RGB ) {
|
|
164
228
|
|
|
229
|
+
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
230
|
+
|
|
165
231
|
if ( glType === gl.FLOAT ) internalFormat = gl.RGB32F;
|
|
166
232
|
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGB16F;
|
|
167
233
|
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGB8;
|
|
@@ -170,7 +236,7 @@ class WebGLTextureUtils {
|
|
|
170
236
|
if ( glType === gl.BYTE ) internalFormat = gl.RGB8I;
|
|
171
237
|
if ( glType === gl.SHORT ) internalFormat = gl.RGB16I;
|
|
172
238
|
if ( glType === gl.INT ) internalFormat = gl.RGB32I;
|
|
173
|
-
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = (
|
|
239
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? gl.SRGB8 : gl.RGB8;
|
|
174
240
|
if ( glType === gl.UNSIGNED_SHORT_5_6_5 ) internalFormat = gl.RGB565;
|
|
175
241
|
if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;
|
|
176
242
|
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGB4;
|
|
@@ -192,6 +258,8 @@ class WebGLTextureUtils {
|
|
|
192
258
|
|
|
193
259
|
if ( glFormat === gl.RGBA ) {
|
|
194
260
|
|
|
261
|
+
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
262
|
+
|
|
195
263
|
if ( glType === gl.FLOAT ) internalFormat = gl.RGBA32F;
|
|
196
264
|
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGBA16F;
|
|
197
265
|
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGBA8;
|
|
@@ -200,7 +268,7 @@ class WebGLTextureUtils {
|
|
|
200
268
|
if ( glType === gl.BYTE ) internalFormat = gl.RGBA8I;
|
|
201
269
|
if ( glType === gl.SHORT ) internalFormat = gl.RGBA16I;
|
|
202
270
|
if ( glType === gl.INT ) internalFormat = gl.RGBA32I;
|
|
203
|
-
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = (
|
|
271
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? gl.SRGB8_ALPHA8 : gl.RGBA8;
|
|
204
272
|
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGBA4;
|
|
205
273
|
if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;
|
|
206
274
|
|
|
@@ -219,7 +287,8 @@ class WebGLTextureUtils {
|
|
|
219
287
|
|
|
220
288
|
if ( glFormat === gl.DEPTH_COMPONENT ) {
|
|
221
289
|
|
|
222
|
-
if ( glType === gl.
|
|
290
|
+
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.DEPTH_COMPONENT16;
|
|
291
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.DEPTH_COMPONENT24;
|
|
223
292
|
if ( glType === gl.FLOAT ) internalFormat = gl.DEPTH_COMPONENT32F;
|
|
224
293
|
|
|
225
294
|
}
|
|
@@ -242,22 +311,36 @@ class WebGLTextureUtils {
|
|
|
242
311
|
|
|
243
312
|
}
|
|
244
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Sets the texture parameters for the given texture.
|
|
316
|
+
*
|
|
317
|
+
* @param {GLenum} textureType - The texture type.
|
|
318
|
+
* @param {Texture} texture - The texture.
|
|
319
|
+
*/
|
|
245
320
|
setTextureParameters( textureType, texture ) {
|
|
246
321
|
|
|
247
322
|
const { gl, extensions, backend } = this;
|
|
248
323
|
|
|
324
|
+
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
325
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
|
|
326
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? gl.NONE : gl.BROWSER_DEFAULT_WEBGL;
|
|
249
327
|
|
|
250
328
|
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
251
329
|
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
252
330
|
gl.pixelStorei( gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
253
|
-
gl.pixelStorei( gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
|
|
331
|
+
gl.pixelStorei( gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
254
332
|
|
|
255
333
|
gl.texParameteri( textureType, gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
256
334
|
gl.texParameteri( textureType, gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
257
335
|
|
|
258
336
|
if ( textureType === gl.TEXTURE_3D || textureType === gl.TEXTURE_2D_ARRAY ) {
|
|
259
337
|
|
|
260
|
-
|
|
338
|
+
// WebGL 2 does not support wrapping for depth 2D array textures
|
|
339
|
+
if ( ! texture.isArrayTexture ) {
|
|
340
|
+
|
|
341
|
+
gl.texParameteri( textureType, gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
342
|
+
|
|
343
|
+
}
|
|
261
344
|
|
|
262
345
|
}
|
|
263
346
|
|
|
@@ -295,6 +378,12 @@ class WebGLTextureUtils {
|
|
|
295
378
|
|
|
296
379
|
}
|
|
297
380
|
|
|
381
|
+
/**
|
|
382
|
+
* Creates a default texture for the given texture that can be used
|
|
383
|
+
* as a placeholder until the actual texture is ready for usage.
|
|
384
|
+
*
|
|
385
|
+
* @param {Texture} texture - The texture to create a default texture for.
|
|
386
|
+
*/
|
|
298
387
|
createDefaultTexture( texture ) {
|
|
299
388
|
|
|
300
389
|
const { gl, backend, defaultTextures } = this;
|
|
@@ -320,12 +409,18 @@ class WebGLTextureUtils {
|
|
|
320
409
|
|
|
321
410
|
backend.set( texture, {
|
|
322
411
|
textureGPU,
|
|
323
|
-
glTextureType
|
|
324
|
-
isDefault: true
|
|
412
|
+
glTextureType
|
|
325
413
|
} );
|
|
326
414
|
|
|
327
415
|
}
|
|
328
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Defines a texture on the GPU for the given texture object.
|
|
419
|
+
*
|
|
420
|
+
* @param {Texture} texture - The texture.
|
|
421
|
+
* @param {Object} [options={}] - Optional configuration parameter.
|
|
422
|
+
* @return {undefined}
|
|
423
|
+
*/
|
|
329
424
|
createTexture( texture, options ) {
|
|
330
425
|
|
|
331
426
|
const { gl, backend } = this;
|
|
@@ -342,7 +437,7 @@ class WebGLTextureUtils {
|
|
|
342
437
|
|
|
343
438
|
this.setTextureParameters( glTextureType, texture );
|
|
344
439
|
|
|
345
|
-
if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
|
|
440
|
+
if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
|
|
346
441
|
|
|
347
442
|
gl.texStorage3D( gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, width, height, depth );
|
|
348
443
|
|
|
@@ -366,6 +461,12 @@ class WebGLTextureUtils {
|
|
|
366
461
|
|
|
367
462
|
}
|
|
368
463
|
|
|
464
|
+
/**
|
|
465
|
+
* Uploads texture buffer data to the GPU memory.
|
|
466
|
+
*
|
|
467
|
+
* @param {WebGLBuffer} buffer - The buffer data.
|
|
468
|
+
* @param {Texture} texture - The texture,
|
|
469
|
+
*/
|
|
369
470
|
copyBufferToTexture( buffer, texture ) {
|
|
370
471
|
|
|
371
472
|
const { gl, backend } = this;
|
|
@@ -387,7 +488,7 @@ class WebGLTextureUtils {
|
|
|
387
488
|
backend.state.unbindTexture();
|
|
388
489
|
// debug
|
|
389
490
|
// const framebuffer = gl.createFramebuffer();
|
|
390
|
-
//
|
|
491
|
+
// backend.state.bindFramebuffer( gl.FRAMEBUFFER, framebuffer );
|
|
391
492
|
// gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, glTextureType, textureGPU, 0 );
|
|
392
493
|
|
|
393
494
|
// const readout = new Float32Array( width * height * 4 );
|
|
@@ -396,11 +497,17 @@ class WebGLTextureUtils {
|
|
|
396
497
|
// const altType = gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE );
|
|
397
498
|
|
|
398
499
|
// gl.readPixels( 0, 0, width, height, altFormat, altType, readout );
|
|
399
|
-
//
|
|
400
|
-
//
|
|
500
|
+
// backend.state.bindFramebuffer( gl.FRAMEBUFFER, null );
|
|
501
|
+
// log( readout );
|
|
401
502
|
|
|
402
503
|
}
|
|
403
504
|
|
|
505
|
+
/**
|
|
506
|
+
* Uploads the updated texture data to the GPU.
|
|
507
|
+
*
|
|
508
|
+
* @param {Texture} texture - The texture.
|
|
509
|
+
* @param {Object} [options={}] - Optional configuration parameter.
|
|
510
|
+
*/
|
|
404
511
|
updateTexture( texture, options ) {
|
|
405
512
|
|
|
406
513
|
const { gl } = this;
|
|
@@ -410,22 +517,6 @@ class WebGLTextureUtils {
|
|
|
410
517
|
if ( texture.isRenderTargetTexture || ( textureGPU === undefined /* unsupported texture format */ ) )
|
|
411
518
|
return;
|
|
412
519
|
|
|
413
|
-
const getImage = ( source ) => {
|
|
414
|
-
|
|
415
|
-
if ( source.isDataTexture ) {
|
|
416
|
-
|
|
417
|
-
return source.image.data;
|
|
418
|
-
|
|
419
|
-
} else if ( source instanceof ImageBitmap || source instanceof OffscreenCanvas || source instanceof HTMLImageElement || source instanceof HTMLCanvasElement ) {
|
|
420
|
-
|
|
421
|
-
return source;
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
return source.data;
|
|
426
|
-
|
|
427
|
-
};
|
|
428
|
-
|
|
429
520
|
this.backend.state.bindTexture( glTextureType, textureGPU );
|
|
430
521
|
|
|
431
522
|
this.setTextureParameters( glTextureType, texture );
|
|
@@ -446,12 +537,11 @@ class WebGLTextureUtils {
|
|
|
446
537
|
|
|
447
538
|
if ( glFormat !== null ) {
|
|
448
539
|
|
|
449
|
-
gl.compressedTexSubImage3D( gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data
|
|
450
|
-
|
|
540
|
+
gl.compressedTexSubImage3D( gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data );
|
|
451
541
|
|
|
452
542
|
} else {
|
|
453
543
|
|
|
454
|
-
|
|
544
|
+
warn( 'WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()' );
|
|
455
545
|
|
|
456
546
|
}
|
|
457
547
|
|
|
@@ -469,7 +559,7 @@ class WebGLTextureUtils {
|
|
|
469
559
|
|
|
470
560
|
} else {
|
|
471
561
|
|
|
472
|
-
|
|
562
|
+
warn( 'WebGLBackend: Unsupported compressed texture format' );
|
|
473
563
|
|
|
474
564
|
}
|
|
475
565
|
|
|
@@ -481,6 +571,7 @@ class WebGLTextureUtils {
|
|
|
481
571
|
} else if ( texture.isCubeTexture ) {
|
|
482
572
|
|
|
483
573
|
const images = options.images;
|
|
574
|
+
const mipmaps = texture.mipmaps;
|
|
484
575
|
|
|
485
576
|
for ( let i = 0; i < 6; i ++ ) {
|
|
486
577
|
|
|
@@ -488,13 +579,42 @@ class WebGLTextureUtils {
|
|
|
488
579
|
|
|
489
580
|
gl.texSubImage2D( gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, width, height, glFormat, glType, image );
|
|
490
581
|
|
|
582
|
+
for ( let j = 0; j < mipmaps.length; j ++ ) {
|
|
583
|
+
|
|
584
|
+
const mipmap = mipmaps[ j ];
|
|
585
|
+
const image = getImage( mipmap.images[ i ] );
|
|
586
|
+
|
|
587
|
+
gl.texSubImage2D( gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, image.width, image.height, glFormat, glType, image );
|
|
588
|
+
|
|
589
|
+
}
|
|
590
|
+
|
|
491
591
|
}
|
|
492
592
|
|
|
493
|
-
} else if ( texture.isDataArrayTexture ) {
|
|
593
|
+
} else if ( texture.isDataArrayTexture || texture.isArrayTexture ) {
|
|
494
594
|
|
|
495
595
|
const image = options.image;
|
|
496
596
|
|
|
497
|
-
|
|
597
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
598
|
+
|
|
599
|
+
const layerByteLength = getByteLength( image.width, image.height, texture.format, texture.type );
|
|
600
|
+
|
|
601
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
602
|
+
|
|
603
|
+
const layerData = image.data.subarray(
|
|
604
|
+
layerIndex * layerByteLength / image.data.BYTES_PER_ELEMENT,
|
|
605
|
+
( layerIndex + 1 ) * layerByteLength / image.data.BYTES_PER_ELEMENT
|
|
606
|
+
);
|
|
607
|
+
gl.texSubImage3D( gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, layerData );
|
|
608
|
+
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
texture.clearLayerUpdates();
|
|
612
|
+
|
|
613
|
+
} else {
|
|
614
|
+
|
|
615
|
+
gl.texSubImage3D( gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
616
|
+
|
|
617
|
+
}
|
|
498
618
|
|
|
499
619
|
} else if ( texture.isData3DTexture ) {
|
|
500
620
|
|
|
@@ -511,14 +631,36 @@ class WebGLTextureUtils {
|
|
|
511
631
|
|
|
512
632
|
} else {
|
|
513
633
|
|
|
514
|
-
const
|
|
634
|
+
const mipmaps = texture.mipmaps;
|
|
635
|
+
|
|
636
|
+
if ( mipmaps.length > 0 ) {
|
|
637
|
+
|
|
638
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
639
|
+
|
|
640
|
+
const mipmap = mipmaps[ i ];
|
|
641
|
+
|
|
642
|
+
const image = getImage( mipmap );
|
|
643
|
+
gl.texSubImage2D( glTextureType, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, image );
|
|
644
|
+
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
} else {
|
|
648
|
+
|
|
649
|
+
const image = getImage( options.image );
|
|
650
|
+
gl.texSubImage2D( glTextureType, 0, 0, 0, width, height, glFormat, glType, image );
|
|
651
|
+
|
|
652
|
+
}
|
|
515
653
|
|
|
516
|
-
gl.texSubImage2D( glTextureType, 0, 0, 0, width, height, glFormat, glType, image );
|
|
517
654
|
|
|
518
655
|
}
|
|
519
656
|
|
|
520
657
|
}
|
|
521
658
|
|
|
659
|
+
/**
|
|
660
|
+
* Generates mipmaps for the given texture.
|
|
661
|
+
*
|
|
662
|
+
* @param {Texture} texture - The texture.
|
|
663
|
+
*/
|
|
522
664
|
generateMipmaps( texture ) {
|
|
523
665
|
|
|
524
666
|
const { gl, backend } = this;
|
|
@@ -529,6 +671,11 @@ class WebGLTextureUtils {
|
|
|
529
671
|
|
|
530
672
|
}
|
|
531
673
|
|
|
674
|
+
/**
|
|
675
|
+
* Deallocates the render buffers of the given render target.
|
|
676
|
+
*
|
|
677
|
+
* @param {RenderTarget} renderTarget - The render target.
|
|
678
|
+
*/
|
|
532
679
|
deallocateRenderBuffers( renderTarget ) {
|
|
533
680
|
|
|
534
681
|
const { gl, backend } = this;
|
|
@@ -589,41 +736,85 @@ class WebGLTextureUtils {
|
|
|
589
736
|
|
|
590
737
|
}
|
|
591
738
|
|
|
592
|
-
|
|
739
|
+
/**
|
|
740
|
+
* Destroys the GPU data for the given texture object.
|
|
741
|
+
*
|
|
742
|
+
* @param {Texture} texture - The texture.
|
|
743
|
+
* @param {boolean} [isDefaultTexture=false] - Whether the texture uses a default GPU texture or not.
|
|
744
|
+
*/
|
|
745
|
+
destroyTexture( texture, isDefaultTexture = false ) {
|
|
593
746
|
|
|
594
747
|
const { gl, backend } = this;
|
|
595
748
|
const { textureGPU, renderTarget } = backend.get( texture );
|
|
596
749
|
|
|
597
750
|
this.deallocateRenderBuffers( renderTarget );
|
|
598
|
-
|
|
751
|
+
|
|
752
|
+
if ( isDefaultTexture === false ) {
|
|
753
|
+
|
|
754
|
+
gl.deleteTexture( textureGPU );
|
|
755
|
+
|
|
756
|
+
}
|
|
599
757
|
|
|
600
758
|
backend.delete( texture );
|
|
601
759
|
|
|
602
760
|
}
|
|
603
761
|
|
|
604
|
-
|
|
762
|
+
/**
|
|
763
|
+
* Copies data of the given source texture to the given destination texture.
|
|
764
|
+
*
|
|
765
|
+
* @param {Texture} srcTexture - The source texture.
|
|
766
|
+
* @param {Texture} dstTexture - The destination texture.
|
|
767
|
+
* @param {?(Box3|Box2)} [srcRegion=null] - The region of the source texture to copy.
|
|
768
|
+
* @param {?(Vector2|Vector3)} [dstPosition=null] - The destination position of the copy.
|
|
769
|
+
* @param {number} [srcLevel=0] - The source mip level to copy from.
|
|
770
|
+
* @param {number} [dstLevel=0] - The destination mip level to copy to.
|
|
771
|
+
*/
|
|
772
|
+
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = 0 ) {
|
|
605
773
|
|
|
606
774
|
const { gl, backend } = this;
|
|
607
775
|
const { state } = this.backend;
|
|
608
776
|
|
|
609
777
|
const { textureGPU: dstTextureGPU, glTextureType, glType, glFormat } = backend.get( dstTexture );
|
|
610
778
|
|
|
779
|
+
state.bindTexture( glTextureType, dstTextureGPU );
|
|
780
|
+
|
|
781
|
+
// gather the necessary dimensions to copy
|
|
782
|
+
let width, height, depth, minX, minY, minZ;
|
|
783
|
+
let dstX, dstY, dstZ;
|
|
784
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ dstLevel ] : srcTexture.image;
|
|
611
785
|
|
|
612
|
-
let width, height, minX, minY;
|
|
613
|
-
let dstX, dstY;
|
|
614
786
|
if ( srcRegion !== null ) {
|
|
615
787
|
|
|
616
788
|
width = srcRegion.max.x - srcRegion.min.x;
|
|
617
789
|
height = srcRegion.max.y - srcRegion.min.y;
|
|
790
|
+
depth = srcRegion.isBox3 ? srcRegion.max.z - srcRegion.min.z : 1;
|
|
618
791
|
minX = srcRegion.min.x;
|
|
619
792
|
minY = srcRegion.min.y;
|
|
793
|
+
minZ = srcRegion.isBox3 ? srcRegion.min.z : 0;
|
|
620
794
|
|
|
621
795
|
} else {
|
|
622
796
|
|
|
623
|
-
|
|
624
|
-
|
|
797
|
+
const levelScale = Math.pow( 2, - srcLevel );
|
|
798
|
+
width = Math.floor( image.width * levelScale );
|
|
799
|
+
height = Math.floor( image.height * levelScale );
|
|
800
|
+
|
|
801
|
+
if ( srcTexture.isDataArrayTexture || srcTexture.isArrayTexture ) {
|
|
802
|
+
|
|
803
|
+
depth = image.depth;
|
|
804
|
+
|
|
805
|
+
} else if ( srcTexture.isData3DTexture ) {
|
|
806
|
+
|
|
807
|
+
depth = Math.floor( image.depth * levelScale );
|
|
808
|
+
|
|
809
|
+
} else {
|
|
810
|
+
|
|
811
|
+
depth = 1;
|
|
812
|
+
|
|
813
|
+
}
|
|
814
|
+
|
|
625
815
|
minX = 0;
|
|
626
816
|
minY = 0;
|
|
817
|
+
minZ = 0;
|
|
627
818
|
|
|
628
819
|
}
|
|
629
820
|
|
|
@@ -631,55 +822,165 @@ class WebGLTextureUtils {
|
|
|
631
822
|
|
|
632
823
|
dstX = dstPosition.x;
|
|
633
824
|
dstY = dstPosition.y;
|
|
825
|
+
dstZ = dstPosition.z;
|
|
634
826
|
|
|
635
827
|
} else {
|
|
636
828
|
|
|
637
829
|
dstX = 0;
|
|
638
830
|
dstY = 0;
|
|
831
|
+
dstZ = 0;
|
|
639
832
|
|
|
640
833
|
}
|
|
641
834
|
|
|
642
|
-
state.bindTexture( glTextureType, dstTextureGPU );
|
|
643
|
-
|
|
644
|
-
// As another texture upload may have changed pixelStorei
|
|
645
|
-
// parameters, make sure they are correct for the dstTexture
|
|
646
|
-
gl.pixelStorei( gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
647
835
|
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
|
|
648
836
|
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
649
837
|
gl.pixelStorei( gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
650
838
|
|
|
839
|
+
// used for copying data from cpu
|
|
651
840
|
const currentUnpackRowLen = gl.getParameter( gl.UNPACK_ROW_LENGTH );
|
|
652
841
|
const currentUnpackImageHeight = gl.getParameter( gl.UNPACK_IMAGE_HEIGHT );
|
|
653
842
|
const currentUnpackSkipPixels = gl.getParameter( gl.UNPACK_SKIP_PIXELS );
|
|
654
843
|
const currentUnpackSkipRows = gl.getParameter( gl.UNPACK_SKIP_ROWS );
|
|
655
844
|
const currentUnpackSkipImages = gl.getParameter( gl.UNPACK_SKIP_IMAGES );
|
|
656
845
|
|
|
657
|
-
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
658
|
-
|
|
659
846
|
gl.pixelStorei( gl.UNPACK_ROW_LENGTH, image.width );
|
|
660
847
|
gl.pixelStorei( gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
661
848
|
gl.pixelStorei( gl.UNPACK_SKIP_PIXELS, minX );
|
|
662
849
|
gl.pixelStorei( gl.UNPACK_SKIP_ROWS, minY );
|
|
850
|
+
gl.pixelStorei( gl.UNPACK_SKIP_IMAGES, minZ );
|
|
851
|
+
|
|
852
|
+
// set up the src texture
|
|
853
|
+
const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture || dstTexture.isArrayTexture;
|
|
854
|
+
const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture || dstTexture.isArrayTexture;
|
|
855
|
+
|
|
856
|
+
if ( srcTexture.isDepthTexture ) {
|
|
857
|
+
|
|
858
|
+
const srcTextureData = backend.get( srcTexture );
|
|
859
|
+
const dstTextureData = backend.get( dstTexture );
|
|
663
860
|
|
|
861
|
+
const srcRenderContextData = backend.get( srcTextureData.renderTarget );
|
|
862
|
+
const dstRenderContextData = backend.get( dstTextureData.renderTarget );
|
|
664
863
|
|
|
665
|
-
|
|
864
|
+
const srcFramebuffer = srcRenderContextData.framebuffers[ srcTextureData.cacheKey ];
|
|
865
|
+
const dstFramebuffer = dstRenderContextData.framebuffers[ dstTextureData.cacheKey ];
|
|
666
866
|
|
|
667
|
-
|
|
867
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, srcFramebuffer );
|
|
868
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, dstFramebuffer );
|
|
869
|
+
|
|
870
|
+
for ( let i = 0; i < depth; i ++ ) {
|
|
871
|
+
|
|
872
|
+
// if the source or destination are a 3d target then a layer needs to be bound
|
|
873
|
+
if ( isSrc3D ) {
|
|
874
|
+
|
|
875
|
+
gl.framebufferTextureLayer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, srcTextureData.textureGPU, srcLevel, minZ + i );
|
|
876
|
+
gl.framebufferTextureLayer( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, dstTextureGPU, dstLevel, dstZ + i );
|
|
877
|
+
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, gl.DEPTH_BUFFER_BIT, gl.NEAREST );
|
|
881
|
+
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
885
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
|
|
886
|
+
|
|
887
|
+
} else if ( srcLevel !== 0 || srcTexture.isRenderTargetTexture || backend.has( srcTexture ) ) {
|
|
888
|
+
|
|
889
|
+
// get the appropriate frame buffers
|
|
890
|
+
const srcTextureData = backend.get( srcTexture );
|
|
891
|
+
|
|
892
|
+
if ( this._srcFramebuffer === null ) this._srcFramebuffer = gl.createFramebuffer();
|
|
893
|
+
if ( this._dstFramebuffer === null ) this._dstFramebuffer = gl.createFramebuffer();
|
|
894
|
+
|
|
895
|
+
// bind the frame buffer targets
|
|
896
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, this._srcFramebuffer );
|
|
897
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, this._dstFramebuffer );
|
|
898
|
+
|
|
899
|
+
for ( let i = 0; i < depth; i ++ ) {
|
|
900
|
+
|
|
901
|
+
// assign the correct layers and mip maps to the frame buffers
|
|
902
|
+
if ( isSrc3D ) {
|
|
903
|
+
|
|
904
|
+
gl.framebufferTextureLayer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, srcTextureData.textureGPU, srcLevel, minZ + i );
|
|
905
|
+
|
|
906
|
+
} else {
|
|
907
|
+
|
|
908
|
+
gl.framebufferTexture2D( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, srcTextureData.textureGPU, srcLevel );
|
|
909
|
+
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
if ( isDst3D ) {
|
|
913
|
+
|
|
914
|
+
gl.framebufferTextureLayer( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, dstTextureGPU, dstLevel, dstZ + i );
|
|
915
|
+
|
|
916
|
+
} else {
|
|
917
|
+
|
|
918
|
+
gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, dstTextureGPU, dstLevel );
|
|
919
|
+
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// copy the data using the fastest function that can achieve the copy
|
|
923
|
+
if ( srcLevel !== 0 ) {
|
|
924
|
+
|
|
925
|
+
gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, gl.COLOR_BUFFER_BIT, gl.NEAREST );
|
|
926
|
+
|
|
927
|
+
} else if ( isDst3D ) {
|
|
928
|
+
|
|
929
|
+
gl.copyTexSubImage3D( glTextureType, dstLevel, dstX, dstY, dstZ + i, minX, minY, width, height );
|
|
930
|
+
|
|
931
|
+
} else {
|
|
932
|
+
|
|
933
|
+
gl.copyTexSubImage2D( glTextureType, dstLevel, dstX, dstY, minX, minY, width, height );
|
|
934
|
+
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// unbind read, draw buffers
|
|
940
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
941
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
|
|
668
942
|
|
|
669
943
|
} else {
|
|
670
944
|
|
|
671
|
-
if (
|
|
945
|
+
if ( isDst3D ) {
|
|
946
|
+
|
|
947
|
+
// copy data into the 3d texture
|
|
948
|
+
if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
672
949
|
|
|
673
|
-
|
|
950
|
+
gl.texSubImage3D( glTextureType, dstLevel, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
|
|
951
|
+
|
|
952
|
+
} else if ( dstTexture.isCompressedArrayTexture ) {
|
|
953
|
+
|
|
954
|
+
gl.compressedTexSubImage3D( glTextureType, dstLevel, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
|
|
955
|
+
|
|
956
|
+
} else {
|
|
957
|
+
|
|
958
|
+
gl.texSubImage3D( glTextureType, dstLevel, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
|
|
959
|
+
|
|
960
|
+
}
|
|
674
961
|
|
|
675
962
|
} else {
|
|
676
963
|
|
|
677
|
-
|
|
964
|
+
// copy data into the 2d texture
|
|
965
|
+
if ( srcTexture.isDataTexture ) {
|
|
966
|
+
|
|
967
|
+
gl.texSubImage2D( gl.TEXTURE_2D, dstLevel, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
968
|
+
|
|
969
|
+
} else if ( srcTexture.isCompressedTexture ) {
|
|
970
|
+
|
|
971
|
+
gl.compressedTexSubImage2D( gl.TEXTURE_2D, dstLevel, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
972
|
+
|
|
973
|
+
} else {
|
|
974
|
+
|
|
975
|
+
gl.texSubImage2D( gl.TEXTURE_2D, dstLevel, dstX, dstY, width, height, glFormat, glType, image );
|
|
976
|
+
|
|
977
|
+
}
|
|
678
978
|
|
|
679
979
|
}
|
|
680
980
|
|
|
681
981
|
}
|
|
682
982
|
|
|
983
|
+
// reset values
|
|
683
984
|
gl.pixelStorei( gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
684
985
|
gl.pixelStorei( gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
685
986
|
gl.pixelStorei( gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
@@ -687,12 +988,24 @@ class WebGLTextureUtils {
|
|
|
687
988
|
gl.pixelStorei( gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
688
989
|
|
|
689
990
|
// Generate mipmaps only when copying level 0
|
|
690
|
-
if (
|
|
991
|
+
if ( dstLevel === 0 && dstTexture.generateMipmaps ) {
|
|
992
|
+
|
|
993
|
+
gl.generateMipmap( glTextureType );
|
|
994
|
+
|
|
995
|
+
}
|
|
691
996
|
|
|
692
997
|
state.unbindTexture();
|
|
693
998
|
|
|
694
999
|
}
|
|
695
1000
|
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Copies the current bound framebuffer to the given texture.
|
|
1004
|
+
*
|
|
1005
|
+
* @param {Texture} texture - The destination texture.
|
|
1006
|
+
* @param {RenderContext} renderContext - The render context.
|
|
1007
|
+
* @param {Vector4} rectangle - A four dimensional vector defining the origin and dimension of the copy.
|
|
1008
|
+
*/
|
|
696
1009
|
copyFramebufferToTexture( texture, renderContext, rectangle ) {
|
|
697
1010
|
|
|
698
1011
|
const { gl } = this;
|
|
@@ -704,7 +1017,7 @@ class WebGLTextureUtils {
|
|
|
704
1017
|
|
|
705
1018
|
const requireDrawFrameBuffer = texture.isDepthTexture === true || ( renderContext.renderTarget && renderContext.renderTarget.samples > 0 );
|
|
706
1019
|
|
|
707
|
-
const srcHeight = renderContext.renderTarget ? renderContext.renderTarget.height : this.backend.
|
|
1020
|
+
const srcHeight = renderContext.renderTarget ? renderContext.renderTarget.height : this.backend.getDrawingBufferSize().y;
|
|
708
1021
|
|
|
709
1022
|
if ( requireDrawFrameBuffer ) {
|
|
710
1023
|
|
|
@@ -780,13 +1093,20 @@ class WebGLTextureUtils {
|
|
|
780
1093
|
|
|
781
1094
|
}
|
|
782
1095
|
|
|
783
|
-
|
|
784
|
-
|
|
1096
|
+
/**
|
|
1097
|
+
* SetupS storage for internal depth/stencil buffers and bind to correct framebuffer.
|
|
1098
|
+
*
|
|
1099
|
+
* @param {WebGLRenderbuffer} renderbuffer - The render buffer.
|
|
1100
|
+
* @param {RenderContext} renderContext - The render context.
|
|
1101
|
+
* @param {number} samples - The MSAA sample count.
|
|
1102
|
+
* @param {boolean} [useMultisampledRTT=false] - Whether to use WEBGL_multisampled_render_to_texture or not.
|
|
1103
|
+
*/
|
|
1104
|
+
setupRenderBufferStorage( renderbuffer, renderContext, samples, useMultisampledRTT = false ) {
|
|
785
1105
|
|
|
786
1106
|
const { gl } = this;
|
|
787
1107
|
const renderTarget = renderContext.renderTarget;
|
|
788
1108
|
|
|
789
|
-
const {
|
|
1109
|
+
const { depthTexture, depthBuffer, stencilBuffer, width, height } = renderTarget;
|
|
790
1110
|
|
|
791
1111
|
gl.bindRenderbuffer( gl.RENDERBUFFER, renderbuffer );
|
|
792
1112
|
|
|
@@ -794,7 +1114,13 @@ class WebGLTextureUtils {
|
|
|
794
1114
|
|
|
795
1115
|
let glInternalFormat = gl.DEPTH_COMPONENT24;
|
|
796
1116
|
|
|
797
|
-
if (
|
|
1117
|
+
if ( useMultisampledRTT === true ) {
|
|
1118
|
+
|
|
1119
|
+
const multisampledRTTExt = this.extensions.get( 'WEBGL_multisampled_render_to_texture' );
|
|
1120
|
+
|
|
1121
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( gl.RENDERBUFFER, renderTarget.samples, glInternalFormat, width, height );
|
|
1122
|
+
|
|
1123
|
+
} else if ( samples > 0 ) {
|
|
798
1124
|
|
|
799
1125
|
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
800
1126
|
|
|
@@ -833,8 +1159,22 @@ class WebGLTextureUtils {
|
|
|
833
1159
|
|
|
834
1160
|
}
|
|
835
1161
|
|
|
1162
|
+
gl.bindRenderbuffer( gl.RENDERBUFFER, null );
|
|
1163
|
+
|
|
836
1164
|
}
|
|
837
1165
|
|
|
1166
|
+
/**
|
|
1167
|
+
* Returns texture data as a typed array.
|
|
1168
|
+
*
|
|
1169
|
+
* @async
|
|
1170
|
+
* @param {Texture} texture - The texture to copy.
|
|
1171
|
+
* @param {number} x - The x coordinate of the copy origin.
|
|
1172
|
+
* @param {number} y - The y coordinate of the copy origin.
|
|
1173
|
+
* @param {number} width - The width of the copy.
|
|
1174
|
+
* @param {number} height - The height of the copy.
|
|
1175
|
+
* @param {number} faceIndex - The face index.
|
|
1176
|
+
* @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
|
|
1177
|
+
*/
|
|
838
1178
|
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
839
1179
|
|
|
840
1180
|
const { backend, gl } = this;
|
|
@@ -843,7 +1183,7 @@ class WebGLTextureUtils {
|
|
|
843
1183
|
|
|
844
1184
|
const fb = gl.createFramebuffer();
|
|
845
1185
|
|
|
846
|
-
|
|
1186
|
+
backend.state.bindFramebuffer( gl.READ_FRAMEBUFFER, fb );
|
|
847
1187
|
|
|
848
1188
|
const target = texture.isCubeTexture ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D;
|
|
849
1189
|
|
|
@@ -870,12 +1210,21 @@ class WebGLTextureUtils {
|
|
|
870
1210
|
gl.getBufferSubData( gl.PIXEL_PACK_BUFFER, 0, dstBuffer );
|
|
871
1211
|
gl.bindBuffer( gl.PIXEL_PACK_BUFFER, null );
|
|
872
1212
|
|
|
1213
|
+
backend.state.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
1214
|
+
|
|
873
1215
|
gl.deleteFramebuffer( fb );
|
|
874
1216
|
|
|
875
1217
|
return dstBuffer;
|
|
876
1218
|
|
|
877
1219
|
}
|
|
878
1220
|
|
|
1221
|
+
/**
|
|
1222
|
+
* Returns the corresponding typed array type for the given WebGL data type.
|
|
1223
|
+
*
|
|
1224
|
+
* @private
|
|
1225
|
+
* @param {GLenum} glType - The WebGL data type.
|
|
1226
|
+
* @return {TypedArray.constructor} The typed array type.
|
|
1227
|
+
*/
|
|
879
1228
|
_getTypedArrayType( glType ) {
|
|
880
1229
|
|
|
881
1230
|
const { gl } = this;
|
|
@@ -895,6 +1244,14 @@ class WebGLTextureUtils {
|
|
|
895
1244
|
|
|
896
1245
|
}
|
|
897
1246
|
|
|
1247
|
+
/**
|
|
1248
|
+
* Returns the bytes-per-texel value for the given WebGL data type and texture format.
|
|
1249
|
+
*
|
|
1250
|
+
* @private
|
|
1251
|
+
* @param {GLenum} glType - The WebGL data type.
|
|
1252
|
+
* @param {GLenum} glFormat - The WebGL texture format.
|
|
1253
|
+
* @return {number} The bytes-per-texel.
|
|
1254
|
+
*/
|
|
898
1255
|
_getBytesPerTexel( glType, glFormat ) {
|
|
899
1256
|
|
|
900
1257
|
const { gl } = this;
|
|
@@ -918,6 +1275,37 @@ class WebGLTextureUtils {
|
|
|
918
1275
|
|
|
919
1276
|
}
|
|
920
1277
|
|
|
1278
|
+
/**
|
|
1279
|
+
* Frees the internal resources.
|
|
1280
|
+
*/
|
|
1281
|
+
dispose() {
|
|
1282
|
+
|
|
1283
|
+
const { gl } = this;
|
|
1284
|
+
|
|
1285
|
+
if ( this._srcFramebuffer !== null ) gl.deleteFramebuffer( this._srcFramebuffer );
|
|
1286
|
+
if ( this._dstFramebuffer !== null ) gl.deleteFramebuffer( this._dstFramebuffer );
|
|
1287
|
+
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
function getImage( source ) {
|
|
1293
|
+
|
|
1294
|
+
if ( source.isDataTexture ) {
|
|
1295
|
+
|
|
1296
|
+
return source.image.data;
|
|
1297
|
+
|
|
1298
|
+
} else if ( ( typeof HTMLImageElement !== 'undefined' && source instanceof HTMLImageElement ) ||
|
|
1299
|
+
( typeof HTMLCanvasElement !== 'undefined' && source instanceof HTMLCanvasElement ) ||
|
|
1300
|
+
( typeof ImageBitmap !== 'undefined' && source instanceof ImageBitmap ) ||
|
|
1301
|
+
( typeof OffscreenCanvas !== 'undefined' && source instanceof OffscreenCanvas ) ) {
|
|
1302
|
+
|
|
1303
|
+
return source;
|
|
1304
|
+
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
return source.data;
|
|
1308
|
+
|
|
921
1309
|
}
|
|
922
1310
|
|
|
923
1311
|
export default WebGLTextureUtils;
|