@gnsx/three 0.184.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 +21 -0
- package/README.md +85 -0
- package/build/three.cjs +79695 -0
- package/build/three.core.js +59732 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +19552 -0
- package/build/three.module.min.js +6 -0
- package/build/three.tsl.js +654 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +83969 -0
- package/build/three.webgpu.min.js +6 -0
- package/build/three.webgpu.nodes.js +83702 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/fonts/LICENSE +13 -0
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/fonts/README.md +11 -0
- package/examples/fonts/droid/NOTICE +190 -0
- package/examples/fonts/droid/README.txt +18 -0
- package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
- package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
- package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
- package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
- package/examples/fonts/gentilis_bold.typeface.json +1 -0
- package/examples/fonts/gentilis_regular.typeface.json +1 -0
- package/examples/fonts/helvetiker_bold.typeface.json +1 -0
- package/examples/fonts/helvetiker_regular.typeface.json +1 -0
- package/examples/fonts/optimer_bold.typeface.json +1 -0
- package/examples/fonts/optimer_regular.typeface.json +1 -0
- package/examples/fonts/ttf/README.md +9 -0
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/Addons.js +293 -0
- package/examples/jsm/animation/AnimationClipCreator.js +168 -0
- package/examples/jsm/animation/CCDIKSolver.js +595 -0
- package/examples/jsm/capabilities/WebGL.js +113 -0
- package/examples/jsm/capabilities/WebGPU.js +59 -0
- package/examples/jsm/controls/ArcballControls.js +3539 -0
- package/examples/jsm/controls/DragControls.js +452 -0
- package/examples/jsm/controls/FirstPersonControls.js +451 -0
- package/examples/jsm/controls/FlyControls.js +384 -0
- package/examples/jsm/controls/MapControls.js +116 -0
- package/examples/jsm/controls/OrbitControls.js +1963 -0
- package/examples/jsm/controls/PointerLockControls.js +264 -0
- package/examples/jsm/controls/TrackballControls.js +1001 -0
- package/examples/jsm/controls/TransformControls.js +1950 -0
- package/examples/jsm/csm/CSM.js +598 -0
- package/examples/jsm/csm/CSMFrustum.js +209 -0
- package/examples/jsm/csm/CSMHelper.js +243 -0
- package/examples/jsm/csm/CSMShader.js +307 -0
- package/examples/jsm/csm/CSMShadowNode.js +603 -0
- package/examples/jsm/curves/CurveExtras.js +694 -0
- package/examples/jsm/curves/NURBSCurve.js +155 -0
- package/examples/jsm/curves/NURBSSurface.js +98 -0
- package/examples/jsm/curves/NURBSUtils.js +532 -0
- package/examples/jsm/curves/NURBSVolume.js +82 -0
- package/examples/jsm/effects/AnaglyphEffect.js +274 -0
- package/examples/jsm/effects/AsciiEffect.js +310 -0
- package/examples/jsm/effects/OutlineEffect.js +489 -0
- package/examples/jsm/effects/ParallaxBarrierEffect.js +155 -0
- package/examples/jsm/effects/StereoEffect.js +91 -0
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/DebugEnvironment.js +102 -0
- package/examples/jsm/environments/RoomEnvironment.js +185 -0
- package/examples/jsm/exporters/DRACOExporter.js +311 -0
- package/examples/jsm/exporters/EXRExporter.js +618 -0
- package/examples/jsm/exporters/GLTFExporter.js +3738 -0
- package/examples/jsm/exporters/KTX2Exporter.js +347 -0
- package/examples/jsm/exporters/OBJExporter.js +308 -0
- package/examples/jsm/exporters/PLYExporter.js +562 -0
- package/examples/jsm/exporters/STLExporter.js +221 -0
- package/examples/jsm/exporters/USDZExporter.js +1254 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +92 -0
- package/examples/jsm/geometries/ConvexGeometry.js +72 -0
- package/examples/jsm/geometries/DecalGeometry.js +420 -0
- package/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/examples/jsm/geometries/ParametricGeometry.js +172 -0
- package/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
- package/examples/jsm/geometries/TeapotGeometry.js +689 -0
- package/examples/jsm/geometries/TextGeometry.js +102 -0
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/helpers/LightProbeHelper.js +165 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +102 -0
- package/examples/jsm/helpers/OctreeHelper.js +109 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +169 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +118 -0
- package/examples/jsm/helpers/TextureHelper.js +265 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +155 -0
- package/examples/jsm/helpers/VertexTangentsHelper.js +133 -0
- package/examples/jsm/helpers/ViewHelper.js +519 -0
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +542 -0
- package/examples/jsm/inspector/RendererInspector.js +425 -0
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Console.js +238 -0
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +380 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +268 -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 +2072 -0
- package/examples/jsm/inspector/ui/Style.js +1667 -0
- package/examples/jsm/inspector/ui/Tab.js +265 -0
- package/examples/jsm/inspector/ui/Values.js +476 -0
- package/examples/jsm/inspector/ui/utils.js +69 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/interactive/HTMLMesh.js +601 -0
- package/examples/jsm/interactive/InteractiveGroup.js +224 -0
- package/examples/jsm/interactive/SelectionBox.js +324 -0
- package/examples/jsm/interactive/SelectionHelper.js +150 -0
- package/examples/jsm/libs/ammo.wasm.js +822 -0
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/basis/README.md +46 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +19 -0
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/chevrotain.module.min.js +141 -0
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/libs/draco/README.md +32 -0
- package/examples/jsm/libs/draco/draco_decoder.js +34 -0
- package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +33 -0
- package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +33 -0
- package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/examples/jsm/libs/ecsy.module.js +1792 -0
- package/examples/jsm/libs/fflate.module.js +2672 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -0
- package/examples/jsm/libs/lil-gui.module.min.js +8 -0
- package/examples/jsm/libs/lottie_canvas.module.js +14849 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +196 -0
- package/examples/jsm/libs/mikktspace.module.js +128 -0
- package/examples/jsm/libs/motion-controllers.module.js +397 -0
- package/examples/jsm/libs/opentype.module.js +14506 -0
- package/examples/jsm/libs/potpack.module.js +125 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/stats.module.js +167 -0
- package/examples/jsm/libs/surfaceNet.js +201 -0
- package/examples/jsm/libs/tween.module.js +876 -0
- package/examples/jsm/libs/utif.module.js +1665 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lighting/TiledLighting.js +42 -0
- package/examples/jsm/lights/LightProbeGenerator.js +337 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +127 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +40 -0
- package/examples/jsm/lines/Line2.js +56 -0
- package/examples/jsm/lines/LineGeometry.js +157 -0
- package/examples/jsm/lines/LineMaterial.js +703 -0
- package/examples/jsm/lines/LineSegments2.js +426 -0
- package/examples/jsm/lines/LineSegmentsGeometry.js +298 -0
- package/examples/jsm/lines/Wireframe.js +108 -0
- package/examples/jsm/lines/WireframeGeometry2.js +49 -0
- package/examples/jsm/lines/webgpu/Line2.js +46 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +411 -0
- package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/examples/jsm/loaders/3DMLoader.js +1836 -0
- package/examples/jsm/loaders/3MFLoader.js +1621 -0
- package/examples/jsm/loaders/AMFLoader.js +541 -0
- package/examples/jsm/loaders/BVHLoader.js +484 -0
- package/examples/jsm/loaders/ColladaLoader.js +153 -0
- package/examples/jsm/loaders/DDSLoader.js +385 -0
- package/examples/jsm/loaders/DRACOLoader.js +739 -0
- package/examples/jsm/loaders/EXRLoader.js +3423 -0
- package/examples/jsm/loaders/FBXLoader.js +4580 -0
- package/examples/jsm/loaders/FontLoader.js +260 -0
- package/examples/jsm/loaders/GCodeLoader.js +318 -0
- package/examples/jsm/loaders/GLTFLoader.js +4860 -0
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +164 -0
- package/examples/jsm/loaders/HDRLoader.js +485 -0
- package/examples/jsm/loaders/IESLoader.js +379 -0
- package/examples/jsm/loaders/KMZLoader.js +163 -0
- package/examples/jsm/loaders/KTX2Loader.js +1257 -0
- package/examples/jsm/loaders/KTXLoader.js +197 -0
- package/examples/jsm/loaders/LDrawLoader.js +2510 -0
- package/examples/jsm/loaders/LUT3dlLoader.js +205 -0
- package/examples/jsm/loaders/LUTCubeLoader.js +190 -0
- package/examples/jsm/loaders/LUTImageLoader.js +190 -0
- package/examples/jsm/loaders/LWOLoader.js +1047 -0
- package/examples/jsm/loaders/LottieLoader.js +130 -0
- package/examples/jsm/loaders/MD2Loader.js +435 -0
- package/examples/jsm/loaders/MDDLoader.js +147 -0
- package/examples/jsm/loaders/MTLLoader.js +593 -0
- package/examples/jsm/loaders/MaterialXLoader.js +1104 -0
- package/examples/jsm/loaders/NRRDLoader.js +718 -0
- package/examples/jsm/loaders/OBJLoader.js +955 -0
- package/examples/jsm/loaders/PCDLoader.js +620 -0
- package/examples/jsm/loaders/PDBLoader.js +272 -0
- package/examples/jsm/loaders/PLYLoader.js +805 -0
- package/examples/jsm/loaders/PVRLoader.js +270 -0
- package/examples/jsm/loaders/RGBELoader.js +18 -0
- package/examples/jsm/loaders/STLLoader.js +421 -0
- package/examples/jsm/loaders/SVGLoader.js +3267 -0
- package/examples/jsm/loaders/TDSLoader.js +1142 -0
- package/examples/jsm/loaders/TGALoader.js +538 -0
- package/examples/jsm/loaders/TIFFLoader.js +59 -0
- package/examples/jsm/loaders/TTFLoader.js +261 -0
- package/examples/jsm/loaders/USDLoader.js +279 -0
- package/examples/jsm/loaders/USDZLoader.js +16 -0
- package/examples/jsm/loaders/UltraHDRLoader.js +755 -0
- package/examples/jsm/loaders/VOXLoader.js +919 -0
- package/examples/jsm/loaders/VRMLLoader.js +3646 -0
- package/examples/jsm/loaders/VTKLoader.js +1293 -0
- package/examples/jsm/loaders/XYZLoader.js +143 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +3044 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1977 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +1217 -0
- package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
- package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
- package/examples/jsm/loaders/usd/USDAParser.js +828 -0
- package/examples/jsm/loaders/usd/USDCParser.js +1878 -0
- package/examples/jsm/loaders/usd/USDComposer.js +4594 -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 +159 -0
- package/examples/jsm/math/ColorConverter.js +58 -0
- package/examples/jsm/math/ColorSpaces.js +147 -0
- package/examples/jsm/math/ConvexHull.js +1695 -0
- package/examples/jsm/math/ImprovedNoise.js +88 -0
- package/examples/jsm/math/Lut.js +317 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +315 -0
- package/examples/jsm/math/OBB.js +535 -0
- package/examples/jsm/math/Octree.js +822 -0
- package/examples/jsm/math/SimplexNoise.js +470 -0
- package/examples/jsm/misc/ConvexObjectBreaker.js +539 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +508 -0
- package/examples/jsm/misc/Gyroscope.js +78 -0
- package/examples/jsm/misc/MD2Character.js +391 -0
- package/examples/jsm/misc/MD2CharacterComplex.js +740 -0
- package/examples/jsm/misc/MorphAnimMesh.js +119 -0
- package/examples/jsm/misc/MorphBlendMesh.js +425 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +370 -0
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/examples/jsm/misc/RollerCoaster.js +661 -0
- package/examples/jsm/misc/TubePainter.js +599 -0
- package/examples/jsm/misc/Volume.js +520 -0
- package/examples/jsm/misc/VolumeSlice.js +275 -0
- package/examples/jsm/modifiers/CurveModifier.js +374 -0
- package/examples/jsm/modifiers/CurveModifierGPU.js +256 -0
- package/examples/jsm/modifiers/EdgeSplitModifier.js +299 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +632 -0
- package/examples/jsm/modifiers/TessellateModifier.js +340 -0
- package/examples/jsm/objects/GroundedSkybox.js +69 -0
- package/examples/jsm/objects/Lensflare.js +489 -0
- package/examples/jsm/objects/LensflareMesh.js +376 -0
- package/examples/jsm/objects/MarchingCubes.js +1261 -0
- package/examples/jsm/objects/Reflector.js +386 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +393 -0
- package/examples/jsm/objects/Refractor.js +389 -0
- package/examples/jsm/objects/ShadowMesh.js +130 -0
- package/examples/jsm/objects/Sky.js +321 -0
- package/examples/jsm/objects/SkyMesh.js +377 -0
- package/examples/jsm/objects/Water.js +374 -0
- package/examples/jsm/objects/Water2.js +403 -0
- package/examples/jsm/objects/Water2Mesh.js +199 -0
- package/examples/jsm/objects/WaterMesh.js +194 -0
- package/examples/jsm/offscreen/jank.js +45 -0
- package/examples/jsm/offscreen/offscreen.js +8 -0
- package/examples/jsm/offscreen/scene.js +86 -0
- package/examples/jsm/physics/AmmoPhysics.js +359 -0
- package/examples/jsm/physics/JoltPhysics.js +334 -0
- package/examples/jsm/physics/RapierPhysics.js +436 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +185 -0
- package/examples/jsm/postprocessing/BloomPass.js +274 -0
- package/examples/jsm/postprocessing/BokehPass.js +218 -0
- package/examples/jsm/postprocessing/ClearPass.js +97 -0
- package/examples/jsm/postprocessing/CubeTexturePass.js +146 -0
- package/examples/jsm/postprocessing/DotScreenPass.js +114 -0
- package/examples/jsm/postprocessing/EffectComposer.js +365 -0
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.js +113 -0
- package/examples/jsm/postprocessing/GTAOPass.js +727 -0
- package/examples/jsm/postprocessing/GlitchPass.js +177 -0
- package/examples/jsm/postprocessing/HalftonePass.js +134 -0
- package/examples/jsm/postprocessing/LUTPass.js +138 -0
- package/examples/jsm/postprocessing/MaskPass.js +195 -0
- package/examples/jsm/postprocessing/OutlinePass.js +776 -0
- package/examples/jsm/postprocessing/OutputPass.js +148 -0
- package/examples/jsm/postprocessing/Pass.js +191 -0
- package/examples/jsm/postprocessing/RenderPass.js +193 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +314 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +267 -0
- package/examples/jsm/postprocessing/SAOPass.js +407 -0
- package/examples/jsm/postprocessing/SMAAPass.js +230 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +313 -0
- package/examples/jsm/postprocessing/SSAOPass.js +527 -0
- package/examples/jsm/postprocessing/SSRPass.js +856 -0
- package/examples/jsm/postprocessing/SavePass.js +132 -0
- package/examples/jsm/postprocessing/ShaderPass.js +135 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +243 -0
- package/examples/jsm/postprocessing/TexturePass.js +131 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +524 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +328 -0
- package/examples/jsm/renderers/CSS3DRenderer.js +454 -0
- package/examples/jsm/renderers/Projector.js +1154 -0
- package/examples/jsm/renderers/SVGRenderer.js +799 -0
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +96 -0
- package/examples/jsm/shaders/AfterimageShader.js +63 -0
- package/examples/jsm/shaders/BasicShader.js +36 -0
- package/examples/jsm/shaders/BleachBypassShader.js +68 -0
- package/examples/jsm/shaders/BlendShader.js +56 -0
- package/examples/jsm/shaders/BokehShader.js +151 -0
- package/examples/jsm/shaders/BokehShader2.js +404 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +62 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +59 -0
- package/examples/jsm/shaders/ColorifyShader.js +57 -0
- package/examples/jsm/shaders/ConvolutionShader.js +74 -0
- package/examples/jsm/shaders/CopyShader.js +52 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +63 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +180 -0
- package/examples/jsm/shaders/DigitalGlitch.js +104 -0
- package/examples/jsm/shaders/DotScreenShader.js +75 -0
- package/examples/jsm/shaders/ExposureShader.js +51 -0
- package/examples/jsm/shaders/FXAAShader.js +298 -0
- package/examples/jsm/shaders/FilmShader.js +72 -0
- package/examples/jsm/shaders/FocusShader.js +94 -0
- package/examples/jsm/shaders/FreiChenShader.js +103 -0
- package/examples/jsm/shaders/GTAOShader.js +434 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +52 -0
- package/examples/jsm/shaders/HalftoneShader.js +332 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +68 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +70 -0
- package/examples/jsm/shaders/HueSaturationShader.js +74 -0
- package/examples/jsm/shaders/KaleidoShader.js +65 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +68 -0
- package/examples/jsm/shaders/LuminosityShader.js +54 -0
- package/examples/jsm/shaders/MirrorShader.js +62 -0
- package/examples/jsm/shaders/NormalMapShader.js +60 -0
- package/examples/jsm/shaders/OutputShader.js +103 -0
- package/examples/jsm/shaders/PoissonDenoiseShader.js +239 -0
- package/examples/jsm/shaders/RGBShiftShader.js +61 -0
- package/examples/jsm/shaders/SAOShader.js +201 -0
- package/examples/jsm/shaders/SMAAShader.js +489 -0
- package/examples/jsm/shaders/SSAOShader.js +331 -0
- package/examples/jsm/shaders/SSRShader.js +396 -0
- package/examples/jsm/shaders/SepiaShader.js +57 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +98 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +95 -0
- package/examples/jsm/shaders/TechnicolorShader.js +51 -0
- package/examples/jsm/shaders/ToonShader.js +349 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +79 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +60 -0
- package/examples/jsm/shaders/VelocityShader.js +137 -0
- package/examples/jsm/shaders/VerticalBlurShader.js +66 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +70 -0
- package/examples/jsm/shaders/VignetteShader.js +56 -0
- package/examples/jsm/shaders/VolumeShader.js +298 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +106 -0
- package/examples/jsm/textures/FlakesTexture.js +54 -0
- package/examples/jsm/transpiler/AST.js +675 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +1228 -0
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +51 -0
- package/examples/jsm/transpiler/TSLEncoder.js +983 -0
- package/examples/jsm/transpiler/Transpiler.js +67 -0
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +254 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +293 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +374 -0
- package/examples/jsm/tsl/display/BleachBypass.js +33 -0
- 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 +174 -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/FSR1Node.js +477 -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 +572 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +399 -0
- package/examples/jsm/tsl/display/GodraysNode.js +615 -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 +812 -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/examples/jsm/tsl/display/SSAAPassNode.js +358 -0
- package/examples/jsm/tsl/display/SSGINode.js +638 -0
- package/examples/jsm/tsl/display/SSRNode.js +656 -0
- package/examples/jsm/tsl/display/SSSNode.js +490 -0
- package/examples/jsm/tsl/display/Sepia.js +24 -0
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +168 -0
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
- package/examples/jsm/tsl/display/StereoPassNode.js +119 -0
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +767 -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/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +84 -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 +1434 -0
- package/examples/jsm/utils/CameraUtils.js +82 -0
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/GeometryCompressionUtils.js +547 -0
- package/examples/jsm/utils/GeometryUtils.js +226 -0
- package/examples/jsm/utils/LDrawUtils.js +211 -0
- package/examples/jsm/utils/SceneOptimizer.js +458 -0
- package/examples/jsm/utils/SceneUtils.js +363 -0
- package/examples/jsm/utils/ShadowMapViewer.js +244 -0
- package/examples/jsm/utils/ShadowMapViewerGPU.js +233 -0
- package/examples/jsm/utils/SkeletonUtils.js +496 -0
- package/examples/jsm/utils/SortUtils.js +175 -0
- package/examples/jsm/utils/UVsDebug.js +173 -0
- package/examples/jsm/utils/WebGLTextureUtils.js +115 -0
- package/examples/jsm/utils/WebGPUTextureUtils.js +81 -0
- package/examples/jsm/utils/WorkerPool.js +167 -0
- package/examples/jsm/webxr/ARButton.js +251 -0
- package/examples/jsm/webxr/OculusHandModel.js +194 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +539 -0
- package/examples/jsm/webxr/Text2D.js +52 -0
- package/examples/jsm/webxr/VRButton.js +264 -0
- package/examples/jsm/webxr/XRButton.js +246 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +403 -0
- package/examples/jsm/webxr/XREstimatedLight.js +254 -0
- package/examples/jsm/webxr/XRHandMeshModel.js +177 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +198 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +147 -0
- package/examples/jsm/webxr/XRPlanes.js +118 -0
- package/package.json +123 -0
- package/src/Three.Core.js +187 -0
- package/src/Three.Legacy.js +0 -0
- package/src/Three.TSL.js +647 -0
- package/src/Three.WebGPU.Nodes.js +31 -0
- package/src/Three.WebGPU.js +37 -0
- package/src/Three.js +10 -0
- package/src/animation/AnimationAction.js +942 -0
- package/src/animation/AnimationClip.js +628 -0
- package/src/animation/AnimationMixer.js +860 -0
- package/src/animation/AnimationObjectGroup.js +411 -0
- package/src/animation/AnimationUtils.js +495 -0
- package/src/animation/KeyframeTrack.js +636 -0
- package/src/animation/PropertyBinding.js +794 -0
- package/src/animation/PropertyMixer.js +385 -0
- package/src/animation/tracks/BooleanKeyframeTrack.js +55 -0
- package/src/animation/tracks/ColorKeyframeTrack.js +36 -0
- package/src/animation/tracks/NumberKeyframeTrack.js +36 -0
- package/src/animation/tracks/QuaternionKeyframeTrack.js +51 -0
- package/src/animation/tracks/StringKeyframeTrack.js +55 -0
- package/src/animation/tracks/VectorKeyframeTrack.js +36 -0
- package/src/audio/Audio.js +778 -0
- package/src/audio/AudioAnalyser.js +97 -0
- package/src/audio/AudioContext.js +40 -0
- package/src/audio/AudioListener.js +218 -0
- package/src/audio/PositionalAudio.js +253 -0
- package/src/cameras/ArrayCamera.js +54 -0
- package/src/cameras/Camera.js +160 -0
- package/src/cameras/CubeCamera.js +259 -0
- package/src/cameras/OrthographicCamera.js +245 -0
- package/src/cameras/PerspectiveCamera.js +407 -0
- package/src/cameras/StereoCamera.js +146 -0
- package/src/constants.js +1760 -0
- package/src/core/BufferAttribute.js +1056 -0
- package/src/core/BufferGeometry.js +1458 -0
- package/src/core/Clock.js +135 -0
- package/src/core/EventDispatcher.js +131 -0
- package/src/core/GLBufferAttribute.js +171 -0
- package/src/core/InstancedBufferAttribute.js +68 -0
- package/src/core/InstancedBufferGeometry.js +60 -0
- package/src/core/InstancedInterleavedBuffer.js +74 -0
- package/src/core/InterleavedBuffer.js +291 -0
- package/src/core/InterleavedBufferAttribute.js +549 -0
- package/src/core/Layers.js +121 -0
- package/src/core/Object3D.js +1667 -0
- package/src/core/Raycaster.js +262 -0
- package/src/core/RenderTarget.js +392 -0
- package/src/core/RenderTarget3D.js +48 -0
- package/src/core/Timer.js +184 -0
- package/src/core/Uniform.js +46 -0
- package/src/core/UniformsGroup.js +180 -0
- package/src/extras/Controls.js +120 -0
- package/src/extras/DataUtils.js +217 -0
- package/src/extras/Earcut.js +28 -0
- package/src/extras/ImageUtils.js +137 -0
- package/src/extras/PMREMGenerator.js +1167 -0
- package/src/extras/ShapeUtils.js +114 -0
- package/src/extras/TextureUtils.js +297 -0
- package/src/extras/core/Curve.js +517 -0
- package/src/extras/core/CurvePath.js +296 -0
- package/src/extras/core/Interpolations.js +111 -0
- package/src/extras/core/Path.js +329 -0
- package/src/extras/core/Shape.js +165 -0
- package/src/extras/core/ShapePath.js +367 -0
- package/src/extras/curves/ArcCurve.js +39 -0
- package/src/extras/curves/CatmullRomCurve3.js +327 -0
- package/src/extras/curves/CubicBezierCurve.js +145 -0
- package/src/extras/curves/CubicBezierCurve3.js +129 -0
- package/src/extras/curves/Curves.js +10 -0
- package/src/extras/curves/EllipseCurve.js +258 -0
- package/src/extras/curves/LineCurve.js +128 -0
- package/src/extras/curves/LineCurve3.js +128 -0
- package/src/extras/curves/QuadraticBezierCurve.js +133 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +118 -0
- package/src/extras/curves/SplineCurve.js +145 -0
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/BoxGeometry.js +219 -0
- package/src/geometries/CapsuleGeometry.js +218 -0
- package/src/geometries/CircleGeometry.js +142 -0
- package/src/geometries/ConeGeometry.js +70 -0
- package/src/geometries/CylinderGeometry.js +333 -0
- package/src/geometries/DodecahedronGeometry.js +99 -0
- package/src/geometries/EdgesGeometry.js +180 -0
- package/src/geometries/ExtrudeGeometry.js +910 -0
- package/src/geometries/Geometries.js +21 -0
- package/src/geometries/IcosahedronGeometry.js +75 -0
- package/src/geometries/LatheGeometry.js +230 -0
- package/src/geometries/OctahedronGeometry.js +70 -0
- package/src/geometries/PlaneGeometry.js +133 -0
- package/src/geometries/PolyhedronGeometry.js +348 -0
- package/src/geometries/RingGeometry.js +165 -0
- package/src/geometries/ShapeGeometry.js +233 -0
- package/src/geometries/SphereGeometry.js +175 -0
- package/src/geometries/TetrahedronGeometry.js +67 -0
- package/src/geometries/TorusGeometry.js +161 -0
- package/src/geometries/TorusKnotGeometry.js +206 -0
- package/src/geometries/TubeGeometry.js +253 -0
- package/src/geometries/WireframeGeometry.js +179 -0
- package/src/helpers/ArrowHelper.js +171 -0
- package/src/helpers/AxesHelper.js +96 -0
- package/src/helpers/Box3Helper.js +83 -0
- package/src/helpers/BoxHelper.js +149 -0
- package/src/helpers/CameraHelper.js +345 -0
- package/src/helpers/DirectionalLightHelper.js +148 -0
- package/src/helpers/GridHelper.js +82 -0
- package/src/helpers/HemisphereLightHelper.js +130 -0
- package/src/helpers/PlaneHelper.js +96 -0
- package/src/helpers/PointLightHelper.js +111 -0
- package/src/helpers/PolarGridHelper.js +126 -0
- package/src/helpers/SkeletonHelper.js +194 -0
- package/src/helpers/SpotLightHelper.js +154 -0
- package/src/lights/AmbientLight.js +42 -0
- package/src/lights/DirectionalLight.js +113 -0
- package/src/lights/DirectionalLightShadow.js +31 -0
- package/src/lights/HemisphereLight.js +76 -0
- package/src/lights/Light.js +85 -0
- package/src/lights/LightProbe.js +75 -0
- package/src/lights/LightShadow.js +347 -0
- package/src/lights/PointLight.js +131 -0
- package/src/lights/PointLightShadow.js +31 -0
- package/src/lights/RectAreaLight.js +115 -0
- package/src/lights/SpotLight.js +194 -0
- package/src/lights/SpotLightShadow.js +80 -0
- package/src/lights/webgpu/IESSpotLight.js +47 -0
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/AnimationLoader.js +98 -0
- package/src/loaders/AudioLoader.js +108 -0
- package/src/loaders/BufferGeometryLoader.js +242 -0
- package/src/loaders/Cache.js +115 -0
- package/src/loaders/CompressedTextureLoader.js +167 -0
- package/src/loaders/CubeTextureLoader.js +103 -0
- package/src/loaders/DataTextureLoader.js +174 -0
- package/src/loaders/FileLoader.js +367 -0
- package/src/loaders/ImageBitmapLoader.js +223 -0
- package/src/loaders/ImageLoader.js +168 -0
- package/src/loaders/Loader.js +222 -0
- package/src/loaders/LoaderUtils.js +59 -0
- package/src/loaders/LoadingManager.js +329 -0
- package/src/loaders/MaterialLoader.js +439 -0
- package/src/loaders/ObjectLoader.js +1304 -0
- package/src/loaders/TextureLoader.js +74 -0
- package/src/loaders/nodes/NodeLoader.js +194 -0
- package/src/loaders/nodes/NodeMaterialLoader.js +108 -0
- package/src/loaders/nodes/NodeObjectLoader.js +169 -0
- package/src/materials/LineBasicMaterial.js +122 -0
- package/src/materials/LineDashedMaterial.js +86 -0
- package/src/materials/Material.js +1017 -0
- package/src/materials/Materials.js +39 -0
- package/src/materials/MeshBasicMaterial.js +250 -0
- package/src/materials/MeshDepthMaterial.js +148 -0
- package/src/materials/MeshDistanceMaterial.js +119 -0
- package/src/materials/MeshLambertMaterial.js +402 -0
- package/src/materials/MeshMatcapMaterial.js +245 -0
- package/src/materials/MeshNormalMaterial.js +175 -0
- package/src/materials/MeshPhongMaterial.js +421 -0
- package/src/materials/MeshPhysicalMaterial.js +536 -0
- package/src/materials/MeshStandardMaterial.js +425 -0
- package/src/materials/MeshToonMaterial.js +321 -0
- package/src/materials/PointsMaterial.js +139 -0
- package/src/materials/RawShaderMaterial.js +42 -0
- package/src/materials/ShaderMaterial.js +413 -0
- package/src/materials/ShadowMaterial.js +91 -0
- package/src/materials/SpriteMaterial.js +136 -0
- package/src/materials/nodes/Line2NodeMaterial.js +569 -0
- package/src/materials/nodes/LineBasicNodeMaterial.js +46 -0
- package/src/materials/nodes/LineDashedNodeMaterial.js +132 -0
- package/src/materials/nodes/MeshBasicNodeMaterial.js +134 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +82 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +77 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +67 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +141 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +521 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +175 -0
- package/src/materials/nodes/MeshStandardNodeMaterial.js +187 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +66 -0
- package/src/materials/nodes/NodeMaterial.js +1330 -0
- package/src/materials/nodes/NodeMaterials.js +21 -0
- package/src/materials/nodes/PointsNodeMaterial.js +211 -0
- package/src/materials/nodes/ShadowNodeMaterial.js +76 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +186 -0
- package/src/materials/nodes/VolumeNodeMaterial.js +81 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +718 -0
- package/src/math/Box2.js +381 -0
- package/src/math/Box3.js +805 -0
- package/src/math/Color.js +967 -0
- package/src/math/ColorManagement.js +215 -0
- package/src/math/Cylindrical.js +120 -0
- package/src/math/Euler.js +449 -0
- package/src/math/Frustum.js +285 -0
- package/src/math/FrustumArray.js +258 -0
- package/src/math/Interpolant.js +320 -0
- package/src/math/Line3.js +337 -0
- package/src/math/MathUtils.js +751 -0
- package/src/math/Matrix2.js +128 -0
- package/src/math/Matrix3.js +617 -0
- package/src/math/Matrix4.js +1314 -0
- package/src/math/Plane.js +368 -0
- package/src/math/Quaternion.js +918 -0
- package/src/math/Ray.js +655 -0
- package/src/math/Sphere.js +420 -0
- package/src/math/Spherical.js +147 -0
- package/src/math/SphericalHarmonics3.js +341 -0
- package/src/math/Triangle.js +539 -0
- package/src/math/Vector2.js +870 -0
- package/src/math/Vector3.js +1263 -0
- package/src/math/Vector4.js +1067 -0
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/math/interpolants/CubicInterpolant.js +159 -0
- package/src/math/interpolants/DiscreteInterpolant.js +34 -0
- package/src/math/interpolants/LinearInterpolant.js +51 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +48 -0
- package/src/nodes/Nodes.js +166 -0
- package/src/nodes/TSL.js +173 -0
- package/src/nodes/accessors/AccessorsUtils.js +53 -0
- package/src/nodes/accessors/Arrays.js +68 -0
- package/src/nodes/accessors/BatchNode.js +163 -0
- package/src/nodes/accessors/Bitangent.js +82 -0
- package/src/nodes/accessors/BufferAttributeNode.js +432 -0
- package/src/nodes/accessors/BufferNode.js +128 -0
- package/src/nodes/accessors/BuiltinNode.js +63 -0
- package/src/nodes/accessors/Camera.js +403 -0
- package/src/nodes/accessors/ClippingNode.js +255 -0
- package/src/nodes/accessors/CubeTextureNode.js +215 -0
- package/src/nodes/accessors/InstanceNode.js +349 -0
- package/src/nodes/accessors/InstancedMeshNode.js +50 -0
- package/src/nodes/accessors/Lights.js +139 -0
- package/src/nodes/accessors/MaterialNode.js +783 -0
- package/src/nodes/accessors/MaterialProperties.js +56 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +84 -0
- package/src/nodes/accessors/ModelNode.js +184 -0
- package/src/nodes/accessors/ModelViewProjectionNode.js +13 -0
- package/src/nodes/accessors/MorphNode.js +310 -0
- package/src/nodes/accessors/Normal.js +243 -0
- package/src/nodes/accessors/Object3DNode.js +268 -0
- package/src/nodes/accessors/PointUVNode.js +55 -0
- package/src/nodes/accessors/Position.js +122 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +357 -0
- package/src/nodes/accessors/ReferenceNode.js +424 -0
- package/src/nodes/accessors/ReflectVector.js +36 -0
- package/src/nodes/accessors/RendererReferenceNode.js +78 -0
- package/src/nodes/accessors/SceneProperties.js +47 -0
- package/src/nodes/accessors/SkinningNode.js +328 -0
- package/src/nodes/accessors/StorageBufferNode.js +405 -0
- package/src/nodes/accessors/StorageTextureNode.js +295 -0
- package/src/nodes/accessors/Tangent.js +60 -0
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +196 -0
- package/src/nodes/accessors/TextureBicubic.js +92 -0
- package/src/nodes/accessors/TextureNode.js +971 -0
- package/src/nodes/accessors/TextureSizeNode.js +77 -0
- package/src/nodes/accessors/UV.js +11 -0
- package/src/nodes/accessors/UniformArrayNode.js +350 -0
- package/src/nodes/accessors/UserDataNode.js +76 -0
- package/src/nodes/accessors/VelocityNode.js +224 -0
- package/src/nodes/accessors/VertexColorNode.js +109 -0
- package/src/nodes/code/CodeNode.js +181 -0
- package/src/nodes/code/ExpressionNode.js +68 -0
- package/src/nodes/code/FunctionCallNode.js +187 -0
- package/src/nodes/code/FunctionNode.js +182 -0
- package/src/nodes/core/ArrayNode.js +174 -0
- package/src/nodes/core/AssignNode.js +202 -0
- package/src/nodes/core/AttributeNode.js +168 -0
- package/src/nodes/core/BypassNode.js +93 -0
- package/src/nodes/core/ConstNode.js +67 -0
- package/src/nodes/core/ContextNode.js +283 -0
- package/src/nodes/core/IndexNode.js +165 -0
- package/src/nodes/core/InputNode.js +136 -0
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/IsolateNode.js +133 -0
- package/src/nodes/core/LightingModel.js +77 -0
- package/src/nodes/core/MRTNode.js +196 -0
- package/src/nodes/core/Node.js +1180 -0
- package/src/nodes/core/NodeAttribute.js +53 -0
- package/src/nodes/core/NodeBuilder.js +3299 -0
- package/src/nodes/core/NodeCache.js +75 -0
- package/src/nodes/core/NodeCode.js +46 -0
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +314 -0
- package/src/nodes/core/NodeFunction.js +69 -0
- package/src/nodes/core/NodeFunctionInput.js +61 -0
- package/src/nodes/core/NodeParser.js +23 -0
- package/src/nodes/core/NodeUniform.js +91 -0
- package/src/nodes/core/NodeUtils.js +408 -0
- package/src/nodes/core/NodeVar.js +60 -0
- package/src/nodes/core/NodeVarying.js +63 -0
- package/src/nodes/core/OutputStructNode.js +105 -0
- package/src/nodes/core/ParameterNode.js +94 -0
- package/src/nodes/core/PropertyNode.js +367 -0
- package/src/nodes/core/StackNode.js +426 -0
- 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 +148 -0
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/TempNode.js +88 -0
- package/src/nodes/core/UniformGroupNode.js +167 -0
- package/src/nodes/core/UniformNode.js +259 -0
- package/src/nodes/core/VarNode.js +367 -0
- package/src/nodes/core/VaryingNode.js +210 -0
- package/src/nodes/core/constants.js +68 -0
- package/src/nodes/display/BlendModes.js +171 -0
- package/src/nodes/display/BumpMapNode.js +117 -0
- package/src/nodes/display/ColorAdjustment.js +158 -0
- package/src/nodes/display/ColorSpaceFunctions.js +54 -0
- package/src/nodes/display/ColorSpaceNode.js +164 -0
- package/src/nodes/display/FrontFacingNode.js +102 -0
- package/src/nodes/display/NormalMapNode.js +153 -0
- package/src/nodes/display/PassNode.js +1055 -0
- package/src/nodes/display/RenderOutputNode.js +150 -0
- package/src/nodes/display/ScreenNode.js +292 -0
- package/src/nodes/display/ToneMappingFunctions.js +242 -0
- package/src/nodes/display/ToneMappingNode.js +147 -0
- package/src/nodes/display/ToonOutlinePassNode.js +191 -0
- package/src/nodes/display/ViewportDepthNode.js +342 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +63 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +73 -0
- package/src/nodes/display/ViewportTextureNode.js +256 -0
- package/src/nodes/fog/Fog.js +97 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +55 -0
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +57 -0
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/D_GGX.js +23 -0
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/src/nodes/functions/BSDF/F_Schlick.js +16 -0
- package/src/nodes/functions/BSDF/LTC.js +175 -0
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +21 -0
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +26 -0
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/src/nodes/functions/BasicLightingModel.js +100 -0
- package/src/nodes/functions/PhongLightingModel.js +99 -0
- package/src/nodes/functions/PhysicalLightingModel.js +878 -0
- package/src/nodes/functions/ShadowMaskModel.js +58 -0
- package/src/nodes/functions/ToonLightingModel.js +70 -0
- package/src/nodes/functions/VolumetricLightingModel.js +183 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +19 -0
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
- package/src/nodes/functions/material/getRoughness.js +18 -0
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +210 -0
- package/src/nodes/gpgpu/AtomicFunctionNode.js +274 -0
- package/src/nodes/gpgpu/BarrierNode.js +98 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +227 -0
- package/src/nodes/gpgpu/ComputeNode.js +310 -0
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +234 -0
- package/src/nodes/lighting/AONode.js +45 -0
- package/src/nodes/lighting/AmbientLightNode.js +35 -0
- package/src/nodes/lighting/AnalyticLightNode.js +309 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +49 -0
- package/src/nodes/lighting/BasicLightMapNode.js +49 -0
- package/src/nodes/lighting/DirectionalLightNode.js +39 -0
- package/src/nodes/lighting/EnvironmentNode.js +178 -0
- package/src/nodes/lighting/HemisphereLightNode.js +87 -0
- package/src/nodes/lighting/IESSpotLightNode.js +49 -0
- package/src/nodes/lighting/IrradianceNode.js +44 -0
- package/src/nodes/lighting/LightProbeNode.js +73 -0
- package/src/nodes/lighting/LightUtils.js +25 -0
- package/src/nodes/lighting/LightingContextNode.js +115 -0
- package/src/nodes/lighting/LightingNode.js +36 -0
- package/src/nodes/lighting/LightsNode.js +432 -0
- package/src/nodes/lighting/PointLightNode.js +102 -0
- package/src/nodes/lighting/PointShadowNode.js +325 -0
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/RectAreaLightNode.js +133 -0
- package/src/nodes/lighting/ShadowBaseNode.js +81 -0
- package/src/nodes/lighting/ShadowFilterNode.js +264 -0
- package/src/nodes/lighting/ShadowNode.js +889 -0
- package/src/nodes/lighting/SpotLightNode.js +168 -0
- package/src/nodes/materialx/DISCLAIMER.md +199 -0
- package/src/nodes/materialx/MaterialXNodes.js +197 -0
- package/src/nodes/materialx/lib/mx_hsv.js +127 -0
- package/src/nodes/materialx/lib/mx_noise.js +1491 -0
- package/src/nodes/materialx/lib/mx_transform_color.js +23 -0
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +245 -0
- package/src/nodes/math/Hash.js +21 -0
- package/src/nodes/math/MathNode.js +1202 -0
- package/src/nodes/math/MathUtils.js +54 -0
- package/src/nodes/math/OperatorNode.js +752 -0
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/TriNoise3D.js +71 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +168 -0
- package/src/nodes/parsers/GLSLNodeParser.js +25 -0
- package/src/nodes/pmrem/PMREMNode.js +397 -0
- package/src/nodes/pmrem/PMREMUtils.js +397 -0
- package/src/nodes/procedural/Checker.js +22 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +36 -0
- package/src/nodes/tsl/TSLCore.js +1250 -0
- package/src/nodes/utils/ArrayElementNode.js +90 -0
- package/src/nodes/utils/ConvertNode.js +100 -0
- package/src/nodes/utils/CubeMapNode.js +237 -0
- package/src/nodes/utils/DebugNode.js +83 -0
- package/src/nodes/utils/Discard.js +24 -0
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +148 -0
- package/src/nodes/utils/FlipNode.js +106 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +170 -0
- package/src/nodes/utils/JoinNode.js +117 -0
- package/src/nodes/utils/LoopNode.js +349 -0
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MaxMipLevelNode.js +103 -0
- package/src/nodes/utils/MemberNode.js +120 -0
- package/src/nodes/utils/Oscillators.js +41 -0
- package/src/nodes/utils/Packing.js +33 -0
- package/src/nodes/utils/PostProcessingUtils.js +154 -0
- package/src/nodes/utils/RTTNode.js +289 -0
- package/src/nodes/utils/ReflectorNode.js +629 -0
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +103 -0
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SetNode.js +108 -0
- package/src/nodes/utils/SplitNode.js +179 -0
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/SpriteUtils.js +63 -0
- package/src/nodes/utils/StorageArrayElementNode.js +143 -0
- package/src/nodes/utils/Timer.js +26 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/nodes/utils/UVUtils.js +67 -0
- package/src/nodes/utils/ViewportUtils.js +26 -0
- package/src/objects/BatchedMesh.js +1682 -0
- package/src/objects/Bone.js +41 -0
- package/src/objects/ClippingGroup.js +68 -0
- package/src/objects/Group.js +41 -0
- package/src/objects/InstancedMesh.js +422 -0
- package/src/objects/LOD.js +329 -0
- package/src/objects/Line.js +329 -0
- package/src/objects/LineLoop.js +37 -0
- package/src/objects/LineSegments.js +74 -0
- package/src/objects/Mesh.js +496 -0
- package/src/objects/Points.js +228 -0
- package/src/objects/Skeleton.js +392 -0
- package/src/objects/SkinnedMesh.js +370 -0
- package/src/objects/Sprite.js +245 -0
- package/src/renderers/WebGL3DRenderTarget.js +48 -0
- package/src/renderers/WebGLArrayRenderTarget.js +48 -0
- package/src/renderers/WebGLCubeRenderTarget.js +182 -0
- package/src/renderers/WebGLRenderTarget.js +34 -0
- package/src/renderers/WebGLRenderer.js +3699 -0
- package/src/renderers/common/Animation.js +159 -0
- package/src/renderers/common/Attributes.js +132 -0
- package/src/renderers/common/Backend.js +769 -0
- package/src/renderers/common/Background.js +225 -0
- package/src/renderers/common/BindGroup.js +46 -0
- package/src/renderers/common/Binding.js +71 -0
- package/src/renderers/common/Bindings.js +394 -0
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +127 -0
- package/src/renderers/common/BufferUtils.js +58 -0
- package/src/renderers/common/BundleGroup.js +83 -0
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +122 -0
- package/src/renderers/common/ClippingContext.js +262 -0
- package/src/renderers/common/Color4.js +77 -0
- package/src/renderers/common/ComputePipeline.js +41 -0
- package/src/renderers/common/Constants.js +15 -0
- package/src/renderers/common/CubeRenderTarget.js +147 -0
- package/src/renderers/common/DataMap.js +90 -0
- package/src/renderers/common/Geometries.js +396 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/src/renderers/common/Info.js +501 -0
- package/src/renderers/common/InspectorBase.js +151 -0
- package/src/renderers/common/Lighting.js +57 -0
- package/src/renderers/common/Pipeline.js +35 -0
- package/src/renderers/common/Pipelines.js +498 -0
- package/src/renderers/common/PostProcessing.js +28 -0
- package/src/renderers/common/ProgrammableStage.js +78 -0
- package/src/renderers/common/QuadMesh.js +112 -0
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +26 -0
- package/src/renderers/common/RenderBundles.js +71 -0
- package/src/renderers/common/RenderContext.js +281 -0
- package/src/renderers/common/RenderContexts.js +100 -0
- package/src/renderers/common/RenderList.js +404 -0
- package/src/renderers/common/RenderLists.js +78 -0
- package/src/renderers/common/RenderObject.js +915 -0
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +218 -0
- package/src/renderers/common/RenderPipeline.js +255 -0
- package/src/renderers/common/Renderer.js +3654 -0
- package/src/renderers/common/RendererUtils.js +200 -0
- package/src/renderers/common/SampledTexture.js +152 -0
- package/src/renderers/common/Sampler.js +165 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageBuffer.js +53 -0
- package/src/renderers/common/StorageBufferAttribute.js +46 -0
- package/src/renderers/common/StorageInstancedBufferAttribute.js +46 -0
- package/src/renderers/common/StorageTexture.js +86 -0
- package/src/renderers/common/Textures.js +629 -0
- package/src/renderers/common/TimestampQueryPool.js +163 -0
- package/src/renderers/common/Uniform.js +375 -0
- package/src/renderers/common/UniformBuffer.js +34 -0
- package/src/renderers/common/UniformsGroup.js +548 -0
- package/src/renderers/common/XRManager.js +1684 -0
- package/src/renderers/common/XRRenderTarget.js +91 -0
- package/src/renderers/common/extras/PMREMGenerator.js +1042 -0
- package/src/renderers/common/nodes/NodeBuilderState.js +152 -0
- package/src/renderers/common/nodes/NodeLibrary.js +196 -0
- package/src/renderers/common/nodes/NodeManager.js +983 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +140 -0
- package/src/renderers/common/nodes/NodeSampler.js +62 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +72 -0
- package/src/renderers/common/nodes/NodeUniform.js +418 -0
- package/src/renderers/common/nodes/NodeUniformBuffer.js +105 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +51 -0
- package/src/renderers/shaders/DFGLUTData.js +49 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +16 -0
- package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +49 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +33 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +43 -0
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +10 -0
- package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +78 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +29 -0
- package/src/renderers/shaders/ShaderChunk/colorspace_fragment.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +125 -0
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +186 -0
- package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +63 -0
- package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +17 -0
- package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +58 -0
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +69 -0
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
- package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
- package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +120 -0
- package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +213 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +44 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +216 -0
- package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +32 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +161 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +656 -0
- package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
- package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +27 -0
- package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +27 -0
- package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
- package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +16 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +16 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +76 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +40 -0
- package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
- package/src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js +11 -0
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +116 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
- package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +376 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +71 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +78 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
- package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +25 -0
- package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +200 -0
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +235 -0
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +119 -0
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +145 -0
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +122 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +21 -0
- package/src/renderers/shaders/ShaderChunk.js +272 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +40 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +36 -0
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +117 -0
- package/src/renderers/shaders/ShaderLib/distance.glsl.js +77 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +76 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +116 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +126 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +112 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +86 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +128 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +224 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +118 -0
- package/src/renderers/shaders/ShaderLib/points.glsl.js +87 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +58 -0
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +51 -0
- package/src/renderers/shaders/ShaderLib.js +362 -0
- package/src/renderers/shaders/UniformsLib.js +234 -0
- package/src/renderers/shaders/UniformsUtils.js +154 -0
- package/src/renderers/webgl/WebGLAnimation.js +54 -0
- package/src/renderers/webgl/WebGLAttributes.js +237 -0
- package/src/renderers/webgl/WebGLBackground.js +303 -0
- package/src/renderers/webgl/WebGLBindingStates.js +666 -0
- package/src/renderers/webgl/WebGLBufferRenderer.js +57 -0
- package/src/renderers/webgl/WebGLCapabilities.js +150 -0
- package/src/renderers/webgl/WebGLClipping.js +171 -0
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLExtensions.js +61 -0
- package/src/renderers/webgl/WebGLGeometries.js +186 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +68 -0
- package/src/renderers/webgl/WebGLInfo.js +73 -0
- package/src/renderers/webgl/WebGLLights.js +584 -0
- package/src/renderers/webgl/WebGLMaterials.js +602 -0
- package/src/renderers/webgl/WebGLMorphtargets.js +168 -0
- package/src/renderers/webgl/WebGLObjects.js +94 -0
- package/src/renderers/webgl/WebGLOutput.js +270 -0
- package/src/renderers/webgl/WebGLProgram.js +1031 -0
- package/src/renderers/webgl/WebGLPrograms.js +679 -0
- package/src/renderers/webgl/WebGLProperties.js +55 -0
- package/src/renderers/webgl/WebGLRenderLists.js +253 -0
- package/src/renderers/webgl/WebGLRenderStates.js +124 -0
- package/src/renderers/webgl/WebGLShader.js +12 -0
- package/src/renderers/webgl/WebGLShaderCache.js +124 -0
- package/src/renderers/webgl/WebGLShadowMap.js +600 -0
- package/src/renderers/webgl/WebGLState.js +1370 -0
- package/src/renderers/webgl/WebGLTextures.js +2506 -0
- package/src/renderers/webgl/WebGLUniforms.js +1203 -0
- package/src/renderers/webgl/WebGLUniformsGroups.js +413 -0
- package/src/renderers/webgl/WebGLUtils.js +217 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +2783 -0
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +99 -0
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +1676 -0
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +359 -0
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +89 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +13 -0
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +83 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1361 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1324 -0
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +317 -0
- package/src/renderers/webgpu/WebGPUBackend.js +2602 -0
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +69 -0
- package/src/renderers/webgpu/WebGPURenderer.js +107 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +66 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +100 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +2523 -0
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +187 -0
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +25 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +522 -0
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +642 -0
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +354 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +846 -0
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +389 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1673 -0
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +269 -0
- package/src/renderers/webxr/WebXRController.js +440 -0
- package/src/renderers/webxr/WebXRDepthSensing.js +155 -0
- package/src/renderers/webxr/WebXRManager.js +1103 -0
- package/src/scenes/Fog.js +98 -0
- package/src/scenes/FogExp2.js +86 -0
- package/src/scenes/Scene.js +165 -0
- package/src/textures/CanvasTexture.js +45 -0
- package/src/textures/CompressedArrayTexture.js +89 -0
- package/src/textures/CompressedCubeTexture.js +48 -0
- package/src/textures/CompressedTexture.js +86 -0
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/CubeTexture.js +81 -0
- package/src/textures/Data3DTexture.js +112 -0
- package/src/textures/DataArrayTexture.js +134 -0
- package/src/textures/DataTexture.js +87 -0
- package/src/textures/DepthTexture.js +104 -0
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +85 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +230 -0
- package/src/textures/Texture.js +812 -0
- package/src/textures/VideoFrameTexture.js +72 -0
- package/src/textures/VideoTexture.js +127 -0
- package/src/utils.js +493 -0
|
@@ -0,0 +1,1257 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CompressedArrayTexture,
|
|
3
|
+
CompressedCubeTexture,
|
|
4
|
+
CompressedTexture,
|
|
5
|
+
Data3DTexture,
|
|
6
|
+
DataTexture,
|
|
7
|
+
FileLoader,
|
|
8
|
+
FloatType,
|
|
9
|
+
HalfFloatType,
|
|
10
|
+
LinearFilter,
|
|
11
|
+
LinearMipmapLinearFilter,
|
|
12
|
+
NearestFilter,
|
|
13
|
+
NearestMipmapNearestFilter,
|
|
14
|
+
LinearSRGBColorSpace,
|
|
15
|
+
Loader,
|
|
16
|
+
NoColorSpace,
|
|
17
|
+
RGBAFormat,
|
|
18
|
+
RGBA_ASTC_4x4_Format,
|
|
19
|
+
RGBA_ASTC_6x6_Format,
|
|
20
|
+
RGBA_BPTC_Format,
|
|
21
|
+
RGBA_ETC2_EAC_Format,
|
|
22
|
+
R11_EAC_Format,
|
|
23
|
+
SIGNED_R11_EAC_Format,
|
|
24
|
+
RG11_EAC_Format,
|
|
25
|
+
SIGNED_RG11_EAC_Format,
|
|
26
|
+
RGBA_PVRTC_4BPPV1_Format,
|
|
27
|
+
RGBA_PVRTC_2BPPV1_Format,
|
|
28
|
+
RGBA_S3TC_DXT1_Format,
|
|
29
|
+
RGBA_S3TC_DXT5_Format,
|
|
30
|
+
RGB_BPTC_UNSIGNED_Format,
|
|
31
|
+
RGB_ETC1_Format,
|
|
32
|
+
RGB_ETC2_Format,
|
|
33
|
+
RGB_PVRTC_4BPPV1_Format,
|
|
34
|
+
RGB_S3TC_DXT1_Format,
|
|
35
|
+
SIGNED_RED_GREEN_RGTC2_Format,
|
|
36
|
+
SIGNED_RED_RGTC1_Format,
|
|
37
|
+
RED_GREEN_RGTC2_Format,
|
|
38
|
+
RED_RGTC1_Format,
|
|
39
|
+
RGBFormat,
|
|
40
|
+
RGFormat,
|
|
41
|
+
RedFormat,
|
|
42
|
+
SRGBColorSpace,
|
|
43
|
+
UnsignedByteType,
|
|
44
|
+
UnsignedInt5999Type,
|
|
45
|
+
UnsignedInt101111Type,
|
|
46
|
+
UnsignedShortType
|
|
47
|
+
} from 'three';
|
|
48
|
+
import { WorkerPool } from '../utils/WorkerPool.js';
|
|
49
|
+
import {
|
|
50
|
+
read,
|
|
51
|
+
KHR_DF_FLAG_ALPHA_PREMULTIPLIED,
|
|
52
|
+
KHR_DF_PRIMARIES_BT709,
|
|
53
|
+
KHR_DF_PRIMARIES_DISPLAYP3,
|
|
54
|
+
KHR_DF_PRIMARIES_UNSPECIFIED,
|
|
55
|
+
KHR_DF_TRANSFER_SRGB,
|
|
56
|
+
KHR_SUPERCOMPRESSION_NONE,
|
|
57
|
+
KHR_SUPERCOMPRESSION_ZSTD,
|
|
58
|
+
VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT,
|
|
59
|
+
VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT,
|
|
60
|
+
VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
|
|
61
|
+
VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
|
|
62
|
+
VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
|
|
63
|
+
VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
|
|
64
|
+
VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
|
|
65
|
+
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
|
|
66
|
+
VK_FORMAT_BC1_RGB_SRGB_BLOCK,
|
|
67
|
+
VK_FORMAT_BC1_RGB_UNORM_BLOCK,
|
|
68
|
+
VK_FORMAT_BC3_SRGB_BLOCK,
|
|
69
|
+
VK_FORMAT_BC3_UNORM_BLOCK,
|
|
70
|
+
VK_FORMAT_BC4_SNORM_BLOCK,
|
|
71
|
+
VK_FORMAT_BC4_UNORM_BLOCK,
|
|
72
|
+
VK_FORMAT_BC5_SNORM_BLOCK,
|
|
73
|
+
VK_FORMAT_BC5_UNORM_BLOCK,
|
|
74
|
+
VK_FORMAT_BC7_SRGB_BLOCK,
|
|
75
|
+
VK_FORMAT_BC7_UNORM_BLOCK,
|
|
76
|
+
VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
|
|
77
|
+
VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
|
|
78
|
+
VK_FORMAT_EAC_R11_UNORM_BLOCK,
|
|
79
|
+
VK_FORMAT_EAC_R11_SNORM_BLOCK,
|
|
80
|
+
VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
|
|
81
|
+
VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
|
|
82
|
+
VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG,
|
|
83
|
+
VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG,
|
|
84
|
+
VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG,
|
|
85
|
+
VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG,
|
|
86
|
+
VK_FORMAT_R16G16B16A16_SFLOAT,
|
|
87
|
+
VK_FORMAT_R16G16B16A16_UNORM,
|
|
88
|
+
VK_FORMAT_R16G16_SFLOAT,
|
|
89
|
+
VK_FORMAT_R16_SFLOAT,
|
|
90
|
+
VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
91
|
+
VK_FORMAT_R32G32_SFLOAT,
|
|
92
|
+
VK_FORMAT_R32_SFLOAT,
|
|
93
|
+
VK_FORMAT_R8G8B8A8_SRGB,
|
|
94
|
+
VK_FORMAT_R8G8B8A8_UNORM,
|
|
95
|
+
VK_FORMAT_R8G8_SRGB,
|
|
96
|
+
VK_FORMAT_R8G8_UNORM,
|
|
97
|
+
VK_FORMAT_R8_SRGB,
|
|
98
|
+
VK_FORMAT_R8_UNORM,
|
|
99
|
+
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
|
|
100
|
+
VK_FORMAT_B10G11R11_UFLOAT_PACK32,
|
|
101
|
+
VK_FORMAT_UNDEFINED
|
|
102
|
+
} from '../libs/ktx-parse.module.js';
|
|
103
|
+
import { ZSTDDecoder } from '../libs/zstddec.module.js';
|
|
104
|
+
import { DisplayP3ColorSpace, LinearDisplayP3ColorSpace } from '../math/ColorSpaces.js';
|
|
105
|
+
|
|
106
|
+
const _taskCache = new WeakMap();
|
|
107
|
+
|
|
108
|
+
let _activeLoaders = 0;
|
|
109
|
+
|
|
110
|
+
let _zstd;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* A loader for KTX 2.0 GPU Texture containers.
|
|
114
|
+
*
|
|
115
|
+
* KTX 2.0 is a container format for various GPU texture formats. The loader supports Basis Universal GPU textures,
|
|
116
|
+
* which can be quickly transcoded to a wide variety of GPU texture compression formats. While KTX 2.0 also allows
|
|
117
|
+
* other hardware-specific formats, this loader does not yet parse them.
|
|
118
|
+
*
|
|
119
|
+
* This loader parses the KTX 2.0 container and transcodes to a supported GPU compressed texture format.
|
|
120
|
+
* The required WASM transcoder and JS wrapper are available from the `examples/jsm/libs/basis` directory.
|
|
121
|
+
*
|
|
122
|
+
* This loader relies on Web Assembly which is not supported in older browsers.
|
|
123
|
+
*
|
|
124
|
+
* References:
|
|
125
|
+
* - [KTX specification](http://github.khronos.org/KTX-Specification/)
|
|
126
|
+
* - [DFD](https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#basicdescriptor)
|
|
127
|
+
* - [BasisU HDR](https://github.com/BinomialLLC/basis_universal/wiki/UASTC-HDR-Texture-Specification-v1.0)
|
|
128
|
+
*
|
|
129
|
+
* ```js
|
|
130
|
+
* const loader = new KTX2Loader();
|
|
131
|
+
* loader.setTranscoderPath( 'examples/jsm/libs/basis/' );
|
|
132
|
+
* loader.detectSupport( renderer );
|
|
133
|
+
* const texture = loader.loadAsync( 'diffuse.ktx2' );
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @augments Loader
|
|
137
|
+
* @three_import import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
|
|
138
|
+
*/
|
|
139
|
+
class KTX2Loader extends Loader {
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Constructs a new KTX2 loader.
|
|
143
|
+
*
|
|
144
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
145
|
+
*/
|
|
146
|
+
constructor( manager ) {
|
|
147
|
+
|
|
148
|
+
super( manager );
|
|
149
|
+
|
|
150
|
+
this.transcoderPath = '';
|
|
151
|
+
this.transcoderBinary = null;
|
|
152
|
+
this.transcoderPending = null;
|
|
153
|
+
|
|
154
|
+
this.workerPool = new WorkerPool();
|
|
155
|
+
this.workerSourceURL = '';
|
|
156
|
+
this.workerConfig = null;
|
|
157
|
+
|
|
158
|
+
if ( typeof MSC_TRANSCODER !== 'undefined' ) {
|
|
159
|
+
|
|
160
|
+
console.warn(
|
|
161
|
+
|
|
162
|
+
'THREE.KTX2Loader: Please update to latest "basis_transcoder".'
|
|
163
|
+
+ ' "msc_basis_transcoder" is no longer supported in three.js r125+.'
|
|
164
|
+
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Sets the transcoder path.
|
|
173
|
+
*
|
|
174
|
+
* The WASM transcoder and JS wrapper are available from the `examples/jsm/libs/basis` directory.
|
|
175
|
+
*
|
|
176
|
+
* @param {string} path - The transcoder path to set.
|
|
177
|
+
* @return {KTX2Loader} A reference to this loader.
|
|
178
|
+
*/
|
|
179
|
+
setTranscoderPath( path ) {
|
|
180
|
+
|
|
181
|
+
this.transcoderPath = path;
|
|
182
|
+
|
|
183
|
+
return this;
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Sets the maximum number of Web Workers to be allocated by this instance.
|
|
189
|
+
*
|
|
190
|
+
* @param {number} workerLimit - The worker limit.
|
|
191
|
+
* @return {KTX2Loader} A reference to this loader.
|
|
192
|
+
*/
|
|
193
|
+
setWorkerLimit( workerLimit ) {
|
|
194
|
+
|
|
195
|
+
this.workerPool.setWorkerLimit( workerLimit );
|
|
196
|
+
|
|
197
|
+
return this;
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Async version of {@link KTX2Loader#detectSupport}.
|
|
204
|
+
*
|
|
205
|
+
* @async
|
|
206
|
+
* @deprecated
|
|
207
|
+
* @param {WebGPURenderer} renderer - The renderer.
|
|
208
|
+
* @return {Promise} A Promise that resolves when the support has been detected.
|
|
209
|
+
*/
|
|
210
|
+
async detectSupportAsync( renderer ) {
|
|
211
|
+
|
|
212
|
+
console.warn( 'KTX2Loader: "detectSupportAsync()" has been deprecated. Use "detectSupport()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
|
|
213
|
+
|
|
214
|
+
await renderer.init();
|
|
215
|
+
|
|
216
|
+
return this.detectSupport( renderer );
|
|
217
|
+
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Detects hardware support for available compressed texture formats, to determine
|
|
222
|
+
* the output format for the transcoder. Must be called before loading a texture.
|
|
223
|
+
*
|
|
224
|
+
* @param {WebGPURenderer|WebGLRenderer} renderer - The renderer.
|
|
225
|
+
* @return {KTX2Loader} A reference to this loader.
|
|
226
|
+
*/
|
|
227
|
+
detectSupport( renderer ) {
|
|
228
|
+
|
|
229
|
+
if ( renderer.isWebGPURenderer === true ) {
|
|
230
|
+
|
|
231
|
+
this.workerConfig = {
|
|
232
|
+
astcSupported: renderer.hasFeature( 'texture-compression-astc' ),
|
|
233
|
+
astcHDRSupported: false, // https://github.com/gpuweb/gpuweb/issues/3856
|
|
234
|
+
etc1Supported: renderer.hasFeature( 'texture-compression-etc1' ),
|
|
235
|
+
etc2Supported: renderer.hasFeature( 'texture-compression-etc2' ),
|
|
236
|
+
dxtSupported: renderer.hasFeature( 'texture-compression-s3tc' ),
|
|
237
|
+
bptcSupported: renderer.hasFeature( 'texture-compression-bc' ),
|
|
238
|
+
pvrtcSupported: renderer.hasFeature( 'texture-compression-pvrtc' )
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
} else {
|
|
242
|
+
|
|
243
|
+
this.workerConfig = {
|
|
244
|
+
astcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_astc' ),
|
|
245
|
+
astcHDRSupported: renderer.extensions.has( 'WEBGL_compressed_texture_astc' )
|
|
246
|
+
&& renderer.extensions.get( 'WEBGL_compressed_texture_astc' ).getSupportedProfiles().includes( 'hdr' ),
|
|
247
|
+
etc1Supported: renderer.extensions.has( 'WEBGL_compressed_texture_etc1' ),
|
|
248
|
+
etc2Supported: renderer.extensions.has( 'WEBGL_compressed_texture_etc' ),
|
|
249
|
+
dxtSupported: renderer.extensions.has( 'WEBGL_compressed_texture_s3tc' ),
|
|
250
|
+
bptcSupported: renderer.extensions.has( 'EXT_texture_compression_bptc' ),
|
|
251
|
+
pvrtcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_pvrtc' )
|
|
252
|
+
|| renderer.extensions.has( 'WEBKIT_WEBGL_compressed_texture_pvrtc' )
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
if ( typeof navigator !== 'undefined' &&
|
|
256
|
+
typeof navigator.platform !== 'undefined' && typeof navigator.userAgent !== 'undefined' &&
|
|
257
|
+
navigator.platform.indexOf( 'Linux' ) >= 0 && navigator.userAgent.indexOf( 'Firefox' ) >= 0 &&
|
|
258
|
+
this.workerConfig.astcSupported && this.workerConfig.etc2Supported &&
|
|
259
|
+
this.workerConfig.bptcSupported && this.workerConfig.dxtSupported ) {
|
|
260
|
+
|
|
261
|
+
// On Linux, Mesa drivers for AMD and Intel GPUs expose ETC2 and ASTC even though the hardware doesn't support these.
|
|
262
|
+
// Using these extensions will result in expensive software decompression on the main thread inside the driver, causing performance issues.
|
|
263
|
+
// When using ANGLE (e.g. via Chrome), these extensions are not exposed except for some specific Intel GPU models - however, Firefox doesn't perform this filtering.
|
|
264
|
+
// Since a granular filter is a little too fragile and we can transcode into other GPU formats, disable formats that are likely to be emulated.
|
|
265
|
+
|
|
266
|
+
this.workerConfig.astcSupported = false;
|
|
267
|
+
this.workerConfig.etc2Supported = false;
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return this;
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// TODO: Make this method private
|
|
278
|
+
|
|
279
|
+
init() {
|
|
280
|
+
|
|
281
|
+
if ( ! this.transcoderPending ) {
|
|
282
|
+
|
|
283
|
+
// Load transcoder wrapper.
|
|
284
|
+
const jsLoader = new FileLoader( this.manager );
|
|
285
|
+
jsLoader.setPath( this.transcoderPath );
|
|
286
|
+
jsLoader.setWithCredentials( this.withCredentials );
|
|
287
|
+
const jsContent = jsLoader.loadAsync( 'basis_transcoder.js' );
|
|
288
|
+
|
|
289
|
+
// Load transcoder WASM binary.
|
|
290
|
+
const binaryLoader = new FileLoader( this.manager );
|
|
291
|
+
binaryLoader.setPath( this.transcoderPath );
|
|
292
|
+
binaryLoader.setResponseType( 'arraybuffer' );
|
|
293
|
+
binaryLoader.setWithCredentials( this.withCredentials );
|
|
294
|
+
const binaryContent = binaryLoader.loadAsync( 'basis_transcoder.wasm' );
|
|
295
|
+
|
|
296
|
+
this.transcoderPending = Promise.all( [ jsContent, binaryContent ] )
|
|
297
|
+
.then( ( [ jsContent, binaryContent ] ) => {
|
|
298
|
+
|
|
299
|
+
const fn = KTX2Loader.BasisWorker.toString();
|
|
300
|
+
|
|
301
|
+
const body = [
|
|
302
|
+
'/* constants */',
|
|
303
|
+
'let _EngineFormat = ' + JSON.stringify( KTX2Loader.EngineFormat ),
|
|
304
|
+
'let _EngineType = ' + JSON.stringify( KTX2Loader.EngineType ),
|
|
305
|
+
'let _TranscoderFormat = ' + JSON.stringify( KTX2Loader.TranscoderFormat ),
|
|
306
|
+
'let _BasisFormat = ' + JSON.stringify( KTX2Loader.BasisFormat ),
|
|
307
|
+
'/* basis_transcoder.js */',
|
|
308
|
+
jsContent,
|
|
309
|
+
'/* worker */',
|
|
310
|
+
fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
|
|
311
|
+
].join( '\n' );
|
|
312
|
+
|
|
313
|
+
this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) );
|
|
314
|
+
this.transcoderBinary = binaryContent;
|
|
315
|
+
|
|
316
|
+
this.workerPool.setWorkerCreator( () => {
|
|
317
|
+
|
|
318
|
+
const worker = new Worker( this.workerSourceURL );
|
|
319
|
+
const transcoderBinary = this.transcoderBinary.slice( 0 );
|
|
320
|
+
|
|
321
|
+
worker.postMessage( { type: 'init', config: this.workerConfig, transcoderBinary }, [ transcoderBinary ] );
|
|
322
|
+
|
|
323
|
+
return worker;
|
|
324
|
+
|
|
325
|
+
} );
|
|
326
|
+
|
|
327
|
+
} );
|
|
328
|
+
|
|
329
|
+
if ( _activeLoaders > 0 ) {
|
|
330
|
+
|
|
331
|
+
// Each instance loads a transcoder and allocates workers, increasing network and memory cost.
|
|
332
|
+
|
|
333
|
+
console.warn(
|
|
334
|
+
|
|
335
|
+
'THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues.'
|
|
336
|
+
+ ' Use a single KTX2Loader instance, or call .dispose() on old instances.'
|
|
337
|
+
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
_activeLoaders ++;
|
|
343
|
+
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return this.transcoderPending;
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Starts loading from the given URL and passes the loaded KTX2 texture
|
|
352
|
+
* to the `onLoad()` callback.
|
|
353
|
+
*
|
|
354
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
355
|
+
* @param {function(CompressedTexture)} onLoad - Executed when the loading process has been finished.
|
|
356
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
357
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
358
|
+
*/
|
|
359
|
+
load( url, onLoad, onProgress, onError ) {
|
|
360
|
+
|
|
361
|
+
if ( this.workerConfig === null ) {
|
|
362
|
+
|
|
363
|
+
throw new Error( 'THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.' );
|
|
364
|
+
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const loader = new FileLoader( this.manager );
|
|
368
|
+
|
|
369
|
+
loader.setPath( this.path );
|
|
370
|
+
loader.setCrossOrigin( this.crossOrigin );
|
|
371
|
+
loader.setWithCredentials( this.withCredentials );
|
|
372
|
+
loader.setRequestHeader( this.requestHeader );
|
|
373
|
+
loader.setResponseType( 'arraybuffer' );
|
|
374
|
+
|
|
375
|
+
loader.load( url, ( buffer ) => {
|
|
376
|
+
|
|
377
|
+
this.parse( buffer, onLoad, onError );
|
|
378
|
+
|
|
379
|
+
}, onProgress, onError );
|
|
380
|
+
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Parses the given KTX2 data.
|
|
385
|
+
*
|
|
386
|
+
* @param {ArrayBuffer} buffer - The raw KTX2 data as an array buffer.
|
|
387
|
+
* @param {function(CompressedTexture)} onLoad - Executed when the loading/parsing process has been finished.
|
|
388
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
389
|
+
* @returns {Promise} A Promise that resolves when the parsing has been finished.
|
|
390
|
+
*/
|
|
391
|
+
parse( buffer, onLoad, onError ) {
|
|
392
|
+
|
|
393
|
+
if ( this.workerConfig === null ) {
|
|
394
|
+
|
|
395
|
+
throw new Error( 'THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.' );
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
|
400
|
+
// again from this thread.
|
|
401
|
+
if ( _taskCache.has( buffer ) ) {
|
|
402
|
+
|
|
403
|
+
const cachedTask = _taskCache.get( buffer );
|
|
404
|
+
|
|
405
|
+
return cachedTask.promise.then( onLoad ).catch( onError );
|
|
406
|
+
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
this._createTexture( buffer )
|
|
410
|
+
.then( ( texture ) => onLoad ? onLoad( texture ) : null )
|
|
411
|
+
.catch( onError );
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
_createTextureFrom( transcodeResult, container ) {
|
|
416
|
+
|
|
417
|
+
const { type: messageType, error, data: { faces, width, height, format, type, dfdFlags } } = transcodeResult;
|
|
418
|
+
|
|
419
|
+
if ( messageType === 'error' ) return Promise.reject( error );
|
|
420
|
+
|
|
421
|
+
let texture;
|
|
422
|
+
|
|
423
|
+
if ( container.faceCount === 6 ) {
|
|
424
|
+
|
|
425
|
+
texture = new CompressedCubeTexture( faces, format, type );
|
|
426
|
+
|
|
427
|
+
} else {
|
|
428
|
+
|
|
429
|
+
const mipmaps = faces[ 0 ].mipmaps;
|
|
430
|
+
|
|
431
|
+
texture = container.layerCount > 1
|
|
432
|
+
? new CompressedArrayTexture( mipmaps, width, height, container.layerCount, format, type )
|
|
433
|
+
: new CompressedTexture( mipmaps, width, height, format, type );
|
|
434
|
+
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
texture.minFilter = faces[ 0 ].mipmaps.length === 1 ? LinearFilter : LinearMipmapLinearFilter;
|
|
438
|
+
texture.magFilter = LinearFilter;
|
|
439
|
+
texture.generateMipmaps = false;
|
|
440
|
+
|
|
441
|
+
texture.needsUpdate = true;
|
|
442
|
+
texture.colorSpace = parseColorSpace( container );
|
|
443
|
+
texture.premultiplyAlpha = !! ( dfdFlags & KHR_DF_FLAG_ALPHA_PREMULTIPLIED );
|
|
444
|
+
|
|
445
|
+
return texture;
|
|
446
|
+
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @private
|
|
451
|
+
* @param {ArrayBuffer} buffer
|
|
452
|
+
* @param {?Object} config
|
|
453
|
+
* @return {Promise<CompressedTexture|CompressedArrayTexture|DataTexture|Data3DTexture>}
|
|
454
|
+
*/
|
|
455
|
+
async _createTexture( buffer, config = {} ) {
|
|
456
|
+
|
|
457
|
+
const container = read( new Uint8Array( buffer ) );
|
|
458
|
+
|
|
459
|
+
// Basis UASTC HDR is a subset of ASTC, which can be transcoded efficiently
|
|
460
|
+
// to BC6H. To detect whether a KTX2 file uses Basis UASTC HDR, or default
|
|
461
|
+
// ASTC, inspect the DFD color model.
|
|
462
|
+
//
|
|
463
|
+
// Source: https://github.com/BinomialLLC/basis_universal/issues/381
|
|
464
|
+
const isBasisHDR = container.vkFormat === VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT
|
|
465
|
+
&& container.dataFormatDescriptor[ 0 ].colorModel === 0xA7;
|
|
466
|
+
|
|
467
|
+
// If the device supports ASTC, Basis UASTC HDR requires no transcoder.
|
|
468
|
+
const needsTranscoder = container.vkFormat === VK_FORMAT_UNDEFINED
|
|
469
|
+
|| isBasisHDR && ! this.workerConfig.astcHDRSupported;
|
|
470
|
+
|
|
471
|
+
if ( ! needsTranscoder ) {
|
|
472
|
+
|
|
473
|
+
return createRawTexture( container );
|
|
474
|
+
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
//
|
|
478
|
+
const taskConfig = config;
|
|
479
|
+
const texturePending = this.init().then( () => {
|
|
480
|
+
|
|
481
|
+
return this.workerPool.postMessage( { type: 'transcode', buffer, taskConfig: taskConfig }, [ buffer ] );
|
|
482
|
+
|
|
483
|
+
} ).then( ( e ) => this._createTextureFrom( e.data, container ) );
|
|
484
|
+
|
|
485
|
+
// Cache the task result.
|
|
486
|
+
_taskCache.set( buffer, { promise: texturePending } );
|
|
487
|
+
|
|
488
|
+
return texturePending;
|
|
489
|
+
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Frees internal resources. This method should be called
|
|
494
|
+
* when the loader is no longer required.
|
|
495
|
+
*/
|
|
496
|
+
dispose() {
|
|
497
|
+
|
|
498
|
+
this.workerPool.dispose();
|
|
499
|
+
if ( this.workerSourceURL ) URL.revokeObjectURL( this.workerSourceURL );
|
|
500
|
+
|
|
501
|
+
_activeLoaders --;
|
|
502
|
+
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
/* CONSTANTS */
|
|
509
|
+
|
|
510
|
+
KTX2Loader.BasisFormat = {
|
|
511
|
+
ETC1S: 0,
|
|
512
|
+
UASTC: 1,
|
|
513
|
+
UASTC_HDR: 2,
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
// Source: https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture_test/index.html
|
|
517
|
+
KTX2Loader.TranscoderFormat = {
|
|
518
|
+
ETC1: 0,
|
|
519
|
+
ETC2: 1,
|
|
520
|
+
BC1: 2,
|
|
521
|
+
BC3: 3,
|
|
522
|
+
BC4: 4,
|
|
523
|
+
BC5: 5,
|
|
524
|
+
BC7_M6_OPAQUE_ONLY: 6,
|
|
525
|
+
BC7_M5: 7,
|
|
526
|
+
PVRTC1_4_RGB: 8,
|
|
527
|
+
PVRTC1_4_RGBA: 9,
|
|
528
|
+
ASTC_4x4: 10,
|
|
529
|
+
ATC_RGB: 11,
|
|
530
|
+
ATC_RGBA_INTERPOLATED_ALPHA: 12,
|
|
531
|
+
RGBA32: 13,
|
|
532
|
+
RGB565: 14,
|
|
533
|
+
BGR565: 15,
|
|
534
|
+
RGBA4444: 16,
|
|
535
|
+
BC6H: 22,
|
|
536
|
+
RGB_HALF: 24,
|
|
537
|
+
RGBA_HALF: 25,
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
KTX2Loader.EngineFormat = {
|
|
541
|
+
RGBAFormat: RGBAFormat,
|
|
542
|
+
RGBA_ASTC_4x4_Format: RGBA_ASTC_4x4_Format,
|
|
543
|
+
RGB_BPTC_UNSIGNED_Format: RGB_BPTC_UNSIGNED_Format,
|
|
544
|
+
RGBA_BPTC_Format: RGBA_BPTC_Format,
|
|
545
|
+
RGBA_ETC2_EAC_Format: RGBA_ETC2_EAC_Format,
|
|
546
|
+
RGBA_PVRTC_4BPPV1_Format: RGBA_PVRTC_4BPPV1_Format,
|
|
547
|
+
RGBA_S3TC_DXT5_Format: RGBA_S3TC_DXT5_Format,
|
|
548
|
+
RGB_ETC1_Format: RGB_ETC1_Format,
|
|
549
|
+
RGB_ETC2_Format: RGB_ETC2_Format,
|
|
550
|
+
RGB_PVRTC_4BPPV1_Format: RGB_PVRTC_4BPPV1_Format,
|
|
551
|
+
RGBA_S3TC_DXT1_Format: RGBA_S3TC_DXT1_Format,
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
KTX2Loader.EngineType = {
|
|
555
|
+
UnsignedByteType: UnsignedByteType,
|
|
556
|
+
HalfFloatType: HalfFloatType,
|
|
557
|
+
FloatType: FloatType,
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
/* WEB WORKER */
|
|
561
|
+
|
|
562
|
+
KTX2Loader.BasisWorker = function () {
|
|
563
|
+
|
|
564
|
+
let config;
|
|
565
|
+
let transcoderPending;
|
|
566
|
+
let BasisModule;
|
|
567
|
+
|
|
568
|
+
const EngineFormat = _EngineFormat; // eslint-disable-line no-undef
|
|
569
|
+
const EngineType = _EngineType; // eslint-disable-line no-undef
|
|
570
|
+
const TranscoderFormat = _TranscoderFormat; // eslint-disable-line no-undef
|
|
571
|
+
const BasisFormat = _BasisFormat; // eslint-disable-line no-undef
|
|
572
|
+
|
|
573
|
+
self.addEventListener( 'message', function ( e ) {
|
|
574
|
+
|
|
575
|
+
const message = e.data;
|
|
576
|
+
|
|
577
|
+
switch ( message.type ) {
|
|
578
|
+
|
|
579
|
+
case 'init':
|
|
580
|
+
config = message.config;
|
|
581
|
+
init( message.transcoderBinary );
|
|
582
|
+
break;
|
|
583
|
+
|
|
584
|
+
case 'transcode':
|
|
585
|
+
transcoderPending.then( () => {
|
|
586
|
+
|
|
587
|
+
try {
|
|
588
|
+
|
|
589
|
+
const { faces, buffers, width, height, hasAlpha, format, type, dfdFlags } = transcode( message.buffer );
|
|
590
|
+
|
|
591
|
+
self.postMessage( { type: 'transcode', id: message.id, data: { faces, width, height, hasAlpha, format, type, dfdFlags } }, buffers );
|
|
592
|
+
|
|
593
|
+
} catch ( error ) {
|
|
594
|
+
|
|
595
|
+
console.error( error );
|
|
596
|
+
|
|
597
|
+
self.postMessage( { type: 'error', id: message.id, error: error.message } );
|
|
598
|
+
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
} );
|
|
602
|
+
break;
|
|
603
|
+
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
} );
|
|
607
|
+
|
|
608
|
+
function init( wasmBinary ) {
|
|
609
|
+
|
|
610
|
+
transcoderPending = new Promise( ( resolve ) => {
|
|
611
|
+
|
|
612
|
+
BasisModule = { wasmBinary, onRuntimeInitialized: resolve };
|
|
613
|
+
BASIS( BasisModule ); // eslint-disable-line no-undef
|
|
614
|
+
|
|
615
|
+
} ).then( () => {
|
|
616
|
+
|
|
617
|
+
BasisModule.initializeBasis();
|
|
618
|
+
|
|
619
|
+
if ( BasisModule.KTX2File === undefined ) {
|
|
620
|
+
|
|
621
|
+
console.warn( 'THREE.KTX2Loader: Please update Basis Universal transcoder.' );
|
|
622
|
+
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
} );
|
|
626
|
+
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function transcode( buffer ) {
|
|
630
|
+
|
|
631
|
+
const ktx2File = new BasisModule.KTX2File( new Uint8Array( buffer ) );
|
|
632
|
+
|
|
633
|
+
function cleanup() {
|
|
634
|
+
|
|
635
|
+
ktx2File.close();
|
|
636
|
+
ktx2File.delete();
|
|
637
|
+
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
if ( ! ktx2File.isValid() ) {
|
|
641
|
+
|
|
642
|
+
cleanup();
|
|
643
|
+
throw new Error( 'THREE.KTX2Loader: Invalid or unsupported .ktx2 file' );
|
|
644
|
+
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
let basisFormat;
|
|
648
|
+
|
|
649
|
+
if ( ktx2File.isUASTC() ) {
|
|
650
|
+
|
|
651
|
+
basisFormat = BasisFormat.UASTC;
|
|
652
|
+
|
|
653
|
+
} else if ( ktx2File.isETC1S() ) {
|
|
654
|
+
|
|
655
|
+
basisFormat = BasisFormat.ETC1S;
|
|
656
|
+
|
|
657
|
+
} else if ( ktx2File.isHDR() ) {
|
|
658
|
+
|
|
659
|
+
basisFormat = BasisFormat.UASTC_HDR;
|
|
660
|
+
|
|
661
|
+
} else {
|
|
662
|
+
|
|
663
|
+
throw new Error( 'THREE.KTX2Loader: Unknown Basis encoding' );
|
|
664
|
+
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
const width = ktx2File.getWidth();
|
|
668
|
+
const height = ktx2File.getHeight();
|
|
669
|
+
const layerCount = ktx2File.getLayers() || 1;
|
|
670
|
+
const levelCount = ktx2File.getLevels();
|
|
671
|
+
const faceCount = ktx2File.getFaces();
|
|
672
|
+
const hasAlpha = ktx2File.getHasAlpha();
|
|
673
|
+
const dfdFlags = ktx2File.getDFDFlags();
|
|
674
|
+
|
|
675
|
+
const { transcoderFormat, engineFormat, engineType } = getTranscoderFormat( basisFormat, width, height, hasAlpha );
|
|
676
|
+
|
|
677
|
+
if ( ! width || ! height || ! levelCount ) {
|
|
678
|
+
|
|
679
|
+
cleanup();
|
|
680
|
+
throw new Error( 'THREE.KTX2Loader: Invalid texture' );
|
|
681
|
+
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
if ( ! ktx2File.startTranscoding() ) {
|
|
685
|
+
|
|
686
|
+
cleanup();
|
|
687
|
+
throw new Error( 'THREE.KTX2Loader: .startTranscoding failed' );
|
|
688
|
+
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
const faces = [];
|
|
692
|
+
const buffers = [];
|
|
693
|
+
|
|
694
|
+
for ( let face = 0; face < faceCount; face ++ ) {
|
|
695
|
+
|
|
696
|
+
const mipmaps = [];
|
|
697
|
+
|
|
698
|
+
for ( let mip = 0; mip < levelCount; mip ++ ) {
|
|
699
|
+
|
|
700
|
+
const layerMips = [];
|
|
701
|
+
|
|
702
|
+
let mipWidth, mipHeight;
|
|
703
|
+
|
|
704
|
+
for ( let layer = 0; layer < layerCount; layer ++ ) {
|
|
705
|
+
|
|
706
|
+
const levelInfo = ktx2File.getImageLevelInfo( mip, layer, face );
|
|
707
|
+
|
|
708
|
+
if ( face === 0 && mip === 0 && layer === 0 && ( levelInfo.origWidth % 4 !== 0 || levelInfo.origHeight % 4 !== 0 ) ) {
|
|
709
|
+
|
|
710
|
+
console.warn( 'THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions.' );
|
|
711
|
+
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if ( levelCount > 1 ) {
|
|
715
|
+
|
|
716
|
+
mipWidth = levelInfo.origWidth;
|
|
717
|
+
mipHeight = levelInfo.origHeight;
|
|
718
|
+
|
|
719
|
+
} else {
|
|
720
|
+
|
|
721
|
+
// Handles non-multiple-of-four dimensions in textures without mipmaps. Textures with
|
|
722
|
+
// mipmaps must use multiple-of-four dimensions, for some texture formats and APIs.
|
|
723
|
+
// See mrdoob/three.js#25908.
|
|
724
|
+
mipWidth = levelInfo.width;
|
|
725
|
+
mipHeight = levelInfo.height;
|
|
726
|
+
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
let dst = new Uint8Array( ktx2File.getImageTranscodedSizeInBytes( mip, layer, 0, transcoderFormat ) );
|
|
730
|
+
const status = ktx2File.transcodeImage( dst, mip, layer, face, transcoderFormat, 0, - 1, - 1 );
|
|
731
|
+
|
|
732
|
+
if ( engineType === EngineType.HalfFloatType ) {
|
|
733
|
+
|
|
734
|
+
dst = new Uint16Array( dst.buffer, dst.byteOffset, dst.byteLength / Uint16Array.BYTES_PER_ELEMENT );
|
|
735
|
+
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if ( ! status ) {
|
|
739
|
+
|
|
740
|
+
cleanup();
|
|
741
|
+
throw new Error( 'THREE.KTX2Loader: .transcodeImage failed.' );
|
|
742
|
+
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
layerMips.push( dst );
|
|
746
|
+
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
const mipData = concat( layerMips );
|
|
750
|
+
|
|
751
|
+
mipmaps.push( { data: mipData, width: mipWidth, height: mipHeight } );
|
|
752
|
+
buffers.push( mipData.buffer );
|
|
753
|
+
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
faces.push( { mipmaps, width, height, format: engineFormat, type: engineType } );
|
|
757
|
+
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
cleanup();
|
|
761
|
+
|
|
762
|
+
return { faces, buffers, width, height, hasAlpha, dfdFlags, format: engineFormat, type: engineType };
|
|
763
|
+
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
//
|
|
767
|
+
|
|
768
|
+
// Optimal choice of a transcoder target format depends on the Basis format (ETC1S, UASTC, or
|
|
769
|
+
// UASTC HDR), device capabilities, and texture dimensions. The list below ranks the formats
|
|
770
|
+
// separately for each format. Currently, priority is assigned based on:
|
|
771
|
+
//
|
|
772
|
+
// high quality > low quality > uncompressed
|
|
773
|
+
//
|
|
774
|
+
// Prioritization may be revisited, or exposed for configuration, in the future.
|
|
775
|
+
//
|
|
776
|
+
// Reference: https://github.com/KhronosGroup/3D-Formats-Guidelines/blob/main/KTXDeveloperGuide.md
|
|
777
|
+
const FORMAT_OPTIONS = [
|
|
778
|
+
{
|
|
779
|
+
if: 'astcSupported',
|
|
780
|
+
basisFormat: [ BasisFormat.UASTC ],
|
|
781
|
+
transcoderFormat: [ TranscoderFormat.ASTC_4x4, TranscoderFormat.ASTC_4x4 ],
|
|
782
|
+
engineFormat: [ EngineFormat.RGBA_ASTC_4x4_Format, EngineFormat.RGBA_ASTC_4x4_Format ],
|
|
783
|
+
engineType: [ EngineType.UnsignedByteType ],
|
|
784
|
+
priorityETC1S: Infinity,
|
|
785
|
+
priorityUASTC: 1,
|
|
786
|
+
needsPowerOfTwo: false,
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
if: 'bptcSupported',
|
|
790
|
+
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC ],
|
|
791
|
+
transcoderFormat: [ TranscoderFormat.BC7_M5, TranscoderFormat.BC7_M5 ],
|
|
792
|
+
engineFormat: [ EngineFormat.RGBA_BPTC_Format, EngineFormat.RGBA_BPTC_Format ],
|
|
793
|
+
engineType: [ EngineType.UnsignedByteType ],
|
|
794
|
+
priorityETC1S: 3,
|
|
795
|
+
priorityUASTC: 2,
|
|
796
|
+
needsPowerOfTwo: false,
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
if: 'dxtSupported',
|
|
800
|
+
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC ],
|
|
801
|
+
transcoderFormat: [ TranscoderFormat.BC1, TranscoderFormat.BC3 ],
|
|
802
|
+
engineFormat: [ EngineFormat.RGBA_S3TC_DXT1_Format, EngineFormat.RGBA_S3TC_DXT5_Format ],
|
|
803
|
+
engineType: [ EngineType.UnsignedByteType ],
|
|
804
|
+
priorityETC1S: 4,
|
|
805
|
+
priorityUASTC: 5,
|
|
806
|
+
needsPowerOfTwo: false,
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
if: 'etc2Supported',
|
|
810
|
+
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC ],
|
|
811
|
+
transcoderFormat: [ TranscoderFormat.ETC1, TranscoderFormat.ETC2 ],
|
|
812
|
+
engineFormat: [ EngineFormat.RGB_ETC2_Format, EngineFormat.RGBA_ETC2_EAC_Format ],
|
|
813
|
+
engineType: [ EngineType.UnsignedByteType ],
|
|
814
|
+
priorityETC1S: 1,
|
|
815
|
+
priorityUASTC: 3,
|
|
816
|
+
needsPowerOfTwo: false,
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
if: 'etc1Supported',
|
|
820
|
+
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC ],
|
|
821
|
+
transcoderFormat: [ TranscoderFormat.ETC1 ],
|
|
822
|
+
engineFormat: [ EngineFormat.RGB_ETC1_Format ],
|
|
823
|
+
engineType: [ EngineType.UnsignedByteType ],
|
|
824
|
+
priorityETC1S: 2,
|
|
825
|
+
priorityUASTC: 4,
|
|
826
|
+
needsPowerOfTwo: false,
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
if: 'pvrtcSupported',
|
|
830
|
+
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC ],
|
|
831
|
+
transcoderFormat: [ TranscoderFormat.PVRTC1_4_RGB, TranscoderFormat.PVRTC1_4_RGBA ],
|
|
832
|
+
engineFormat: [ EngineFormat.RGB_PVRTC_4BPPV1_Format, EngineFormat.RGBA_PVRTC_4BPPV1_Format ],
|
|
833
|
+
engineType: [ EngineType.UnsignedByteType ],
|
|
834
|
+
priorityETC1S: 5,
|
|
835
|
+
priorityUASTC: 6,
|
|
836
|
+
needsPowerOfTwo: true,
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
if: 'bptcSupported',
|
|
840
|
+
basisFormat: [ BasisFormat.UASTC_HDR ],
|
|
841
|
+
transcoderFormat: [ TranscoderFormat.BC6H ],
|
|
842
|
+
engineFormat: [ EngineFormat.RGB_BPTC_UNSIGNED_Format ],
|
|
843
|
+
engineType: [ EngineType.HalfFloatType ],
|
|
844
|
+
priorityHDR: 1,
|
|
845
|
+
needsPowerOfTwo: false,
|
|
846
|
+
},
|
|
847
|
+
|
|
848
|
+
// Uncompressed fallbacks.
|
|
849
|
+
|
|
850
|
+
{
|
|
851
|
+
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC ],
|
|
852
|
+
transcoderFormat: [ TranscoderFormat.RGBA32, TranscoderFormat.RGBA32 ],
|
|
853
|
+
engineFormat: [ EngineFormat.RGBAFormat, EngineFormat.RGBAFormat ],
|
|
854
|
+
engineType: [ EngineType.UnsignedByteType, EngineType.UnsignedByteType ],
|
|
855
|
+
priorityETC1S: 100,
|
|
856
|
+
priorityUASTC: 100,
|
|
857
|
+
needsPowerOfTwo: false,
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
basisFormat: [ BasisFormat.UASTC_HDR ],
|
|
861
|
+
transcoderFormat: [ TranscoderFormat.RGBA_HALF ],
|
|
862
|
+
engineFormat: [ EngineFormat.RGBAFormat ],
|
|
863
|
+
engineType: [ EngineType.HalfFloatType ],
|
|
864
|
+
priorityHDR: 100,
|
|
865
|
+
needsPowerOfTwo: false,
|
|
866
|
+
}
|
|
867
|
+
];
|
|
868
|
+
|
|
869
|
+
const OPTIONS = {
|
|
870
|
+
[ BasisFormat.ETC1S ]: FORMAT_OPTIONS
|
|
871
|
+
.filter( ( opt ) => opt.basisFormat.includes( BasisFormat.ETC1S ) )
|
|
872
|
+
.sort( ( a, b ) => a.priorityETC1S - b.priorityETC1S ),
|
|
873
|
+
|
|
874
|
+
[ BasisFormat.UASTC ]: FORMAT_OPTIONS
|
|
875
|
+
.filter( ( opt ) => opt.basisFormat.includes( BasisFormat.UASTC ) )
|
|
876
|
+
.sort( ( a, b ) => a.priorityUASTC - b.priorityUASTC ),
|
|
877
|
+
|
|
878
|
+
[ BasisFormat.UASTC_HDR ]: FORMAT_OPTIONS
|
|
879
|
+
.filter( ( opt ) => opt.basisFormat.includes( BasisFormat.UASTC_HDR ) )
|
|
880
|
+
.sort( ( a, b ) => a.priorityHDR - b.priorityHDR ),
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
function getTranscoderFormat( basisFormat, width, height, hasAlpha ) {
|
|
884
|
+
|
|
885
|
+
const options = OPTIONS[ basisFormat ];
|
|
886
|
+
|
|
887
|
+
for ( let i = 0; i < options.length; i ++ ) {
|
|
888
|
+
|
|
889
|
+
const opt = options[ i ];
|
|
890
|
+
|
|
891
|
+
if ( opt.if && ! config[ opt.if ] ) continue;
|
|
892
|
+
if ( ! opt.basisFormat.includes( basisFormat ) ) continue;
|
|
893
|
+
if ( hasAlpha && opt.transcoderFormat.length < 2 ) continue;
|
|
894
|
+
if ( opt.needsPowerOfTwo && ! ( isPowerOfTwo( width ) && isPowerOfTwo( height ) ) ) continue;
|
|
895
|
+
|
|
896
|
+
const transcoderFormat = opt.transcoderFormat[ hasAlpha ? 1 : 0 ];
|
|
897
|
+
const engineFormat = opt.engineFormat[ hasAlpha ? 1 : 0 ];
|
|
898
|
+
const engineType = opt.engineType[ 0 ];
|
|
899
|
+
|
|
900
|
+
return { transcoderFormat, engineFormat, engineType };
|
|
901
|
+
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
throw new Error( 'THREE.KTX2Loader: Failed to identify transcoding target.' );
|
|
905
|
+
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
function isPowerOfTwo( value ) {
|
|
909
|
+
|
|
910
|
+
if ( value <= 2 ) return true;
|
|
911
|
+
|
|
912
|
+
return ( value & ( value - 1 ) ) === 0 && value !== 0;
|
|
913
|
+
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Concatenates N byte arrays.
|
|
918
|
+
*
|
|
919
|
+
* @param {Uint8Array[]} arrays
|
|
920
|
+
* @return {Uint8Array}
|
|
921
|
+
*/
|
|
922
|
+
function concat( arrays ) {
|
|
923
|
+
|
|
924
|
+
if ( arrays.length === 1 ) return arrays[ 0 ];
|
|
925
|
+
|
|
926
|
+
let totalByteLength = 0;
|
|
927
|
+
|
|
928
|
+
for ( let i = 0; i < arrays.length; i ++ ) {
|
|
929
|
+
|
|
930
|
+
const array = arrays[ i ];
|
|
931
|
+
totalByteLength += array.byteLength;
|
|
932
|
+
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
const result = new Uint8Array( totalByteLength );
|
|
936
|
+
|
|
937
|
+
let byteOffset = 0;
|
|
938
|
+
|
|
939
|
+
for ( let i = 0; i < arrays.length; i ++ ) {
|
|
940
|
+
|
|
941
|
+
const array = arrays[ i ];
|
|
942
|
+
result.set( array, byteOffset );
|
|
943
|
+
|
|
944
|
+
byteOffset += array.byteLength;
|
|
945
|
+
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
return result;
|
|
949
|
+
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
// Parsing for non-Basis textures. These textures may have supercompression
|
|
955
|
+
// like Zstd, but they do not require transcoding.
|
|
956
|
+
|
|
957
|
+
const UNCOMPRESSED_FORMATS = new Set( [ RGBAFormat, RGBFormat, RGFormat, RedFormat ] );
|
|
958
|
+
|
|
959
|
+
const FORMAT_MAP = {
|
|
960
|
+
|
|
961
|
+
[ VK_FORMAT_R32G32B32A32_SFLOAT ]: RGBAFormat,
|
|
962
|
+
[ VK_FORMAT_R32G32_SFLOAT ]: RGFormat,
|
|
963
|
+
[ VK_FORMAT_R32_SFLOAT ]: RedFormat,
|
|
964
|
+
|
|
965
|
+
[ VK_FORMAT_R16G16B16A16_SFLOAT ]: RGBAFormat,
|
|
966
|
+
[ VK_FORMAT_R16G16_SFLOAT ]: RGFormat,
|
|
967
|
+
[ VK_FORMAT_R16_SFLOAT ]: RedFormat,
|
|
968
|
+
|
|
969
|
+
[ VK_FORMAT_R16G16B16A16_UNORM ]: RGBAFormat,
|
|
970
|
+
|
|
971
|
+
[ VK_FORMAT_R8G8B8A8_SRGB ]: RGBAFormat,
|
|
972
|
+
[ VK_FORMAT_R8G8B8A8_UNORM ]: RGBAFormat,
|
|
973
|
+
[ VK_FORMAT_R8G8_SRGB ]: RGFormat,
|
|
974
|
+
[ VK_FORMAT_R8G8_UNORM ]: RGFormat,
|
|
975
|
+
[ VK_FORMAT_R8_SRGB ]: RedFormat,
|
|
976
|
+
[ VK_FORMAT_R8_UNORM ]: RedFormat,
|
|
977
|
+
|
|
978
|
+
[ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 ]: RGBFormat,
|
|
979
|
+
[ VK_FORMAT_B10G11R11_UFLOAT_PACK32 ]: RGBFormat,
|
|
980
|
+
|
|
981
|
+
[ VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK ]: RGBA_ETC2_EAC_Format,
|
|
982
|
+
[ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK ]: RGB_ETC2_Format,
|
|
983
|
+
[ VK_FORMAT_EAC_R11_UNORM_BLOCK ]: R11_EAC_Format,
|
|
984
|
+
[ VK_FORMAT_EAC_R11_SNORM_BLOCK ]: SIGNED_R11_EAC_Format,
|
|
985
|
+
[ VK_FORMAT_EAC_R11G11_UNORM_BLOCK ]: RG11_EAC_Format,
|
|
986
|
+
[ VK_FORMAT_EAC_R11G11_SNORM_BLOCK ]: SIGNED_RG11_EAC_Format,
|
|
987
|
+
|
|
988
|
+
[ VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT ]: RGBA_ASTC_4x4_Format,
|
|
989
|
+
[ VK_FORMAT_ASTC_4x4_SRGB_BLOCK ]: RGBA_ASTC_4x4_Format,
|
|
990
|
+
[ VK_FORMAT_ASTC_4x4_UNORM_BLOCK ]: RGBA_ASTC_4x4_Format,
|
|
991
|
+
[ VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT ]: RGBA_ASTC_6x6_Format,
|
|
992
|
+
[ VK_FORMAT_ASTC_6x6_SRGB_BLOCK ]: RGBA_ASTC_6x6_Format,
|
|
993
|
+
[ VK_FORMAT_ASTC_6x6_UNORM_BLOCK ]: RGBA_ASTC_6x6_Format,
|
|
994
|
+
|
|
995
|
+
[ VK_FORMAT_BC1_RGBA_SRGB_BLOCK ]: RGBA_S3TC_DXT1_Format,
|
|
996
|
+
[ VK_FORMAT_BC1_RGBA_UNORM_BLOCK ]: RGBA_S3TC_DXT1_Format,
|
|
997
|
+
[ VK_FORMAT_BC1_RGB_SRGB_BLOCK ]: RGB_S3TC_DXT1_Format,
|
|
998
|
+
[ VK_FORMAT_BC1_RGB_UNORM_BLOCK ]: RGB_S3TC_DXT1_Format,
|
|
999
|
+
|
|
1000
|
+
[ VK_FORMAT_BC3_SRGB_BLOCK ]: RGBA_S3TC_DXT5_Format,
|
|
1001
|
+
[ VK_FORMAT_BC3_UNORM_BLOCK ]: RGBA_S3TC_DXT5_Format,
|
|
1002
|
+
|
|
1003
|
+
[ VK_FORMAT_BC4_SNORM_BLOCK ]: SIGNED_RED_RGTC1_Format,
|
|
1004
|
+
[ VK_FORMAT_BC4_UNORM_BLOCK ]: RED_RGTC1_Format,
|
|
1005
|
+
|
|
1006
|
+
[ VK_FORMAT_BC5_SNORM_BLOCK ]: SIGNED_RED_GREEN_RGTC2_Format,
|
|
1007
|
+
[ VK_FORMAT_BC5_UNORM_BLOCK ]: RED_GREEN_RGTC2_Format,
|
|
1008
|
+
|
|
1009
|
+
[ VK_FORMAT_BC7_SRGB_BLOCK ]: RGBA_BPTC_Format,
|
|
1010
|
+
[ VK_FORMAT_BC7_UNORM_BLOCK ]: RGBA_BPTC_Format,
|
|
1011
|
+
|
|
1012
|
+
[ VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG ]: RGBA_PVRTC_4BPPV1_Format,
|
|
1013
|
+
[ VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG ]: RGBA_PVRTC_4BPPV1_Format,
|
|
1014
|
+
[ VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG ]: RGBA_PVRTC_2BPPV1_Format,
|
|
1015
|
+
[ VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG ]: RGBA_PVRTC_2BPPV1_Format,
|
|
1016
|
+
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
const TYPE_MAP = {
|
|
1020
|
+
|
|
1021
|
+
[ VK_FORMAT_R32G32B32A32_SFLOAT ]: FloatType,
|
|
1022
|
+
[ VK_FORMAT_R32G32_SFLOAT ]: FloatType,
|
|
1023
|
+
[ VK_FORMAT_R32_SFLOAT ]: FloatType,
|
|
1024
|
+
|
|
1025
|
+
[ VK_FORMAT_R16G16B16A16_SFLOAT ]: HalfFloatType,
|
|
1026
|
+
[ VK_FORMAT_R16G16_SFLOAT ]: HalfFloatType,
|
|
1027
|
+
[ VK_FORMAT_R16_SFLOAT ]: HalfFloatType,
|
|
1028
|
+
|
|
1029
|
+
[ VK_FORMAT_R16G16B16A16_UNORM ]: UnsignedShortType,
|
|
1030
|
+
|
|
1031
|
+
[ VK_FORMAT_R8G8B8A8_SRGB ]: UnsignedByteType,
|
|
1032
|
+
[ VK_FORMAT_R8G8B8A8_UNORM ]: UnsignedByteType,
|
|
1033
|
+
[ VK_FORMAT_R8G8_SRGB ]: UnsignedByteType,
|
|
1034
|
+
[ VK_FORMAT_R8G8_UNORM ]: UnsignedByteType,
|
|
1035
|
+
[ VK_FORMAT_R8_SRGB ]: UnsignedByteType,
|
|
1036
|
+
[ VK_FORMAT_R8_UNORM ]: UnsignedByteType,
|
|
1037
|
+
|
|
1038
|
+
[ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 ]: UnsignedInt5999Type,
|
|
1039
|
+
[ VK_FORMAT_B10G11R11_UFLOAT_PACK32 ]: UnsignedInt101111Type,
|
|
1040
|
+
|
|
1041
|
+
[ VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK ]: UnsignedByteType,
|
|
1042
|
+
[ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK ]: UnsignedByteType,
|
|
1043
|
+
[ VK_FORMAT_EAC_R11_UNORM_BLOCK ]: UnsignedByteType,
|
|
1044
|
+
[ VK_FORMAT_EAC_R11_SNORM_BLOCK ]: UnsignedByteType,
|
|
1045
|
+
[ VK_FORMAT_EAC_R11G11_UNORM_BLOCK ]: UnsignedByteType,
|
|
1046
|
+
[ VK_FORMAT_EAC_R11G11_SNORM_BLOCK ]: UnsignedByteType,
|
|
1047
|
+
|
|
1048
|
+
[ VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT ]: HalfFloatType,
|
|
1049
|
+
[ VK_FORMAT_ASTC_4x4_SRGB_BLOCK ]: UnsignedByteType,
|
|
1050
|
+
[ VK_FORMAT_ASTC_4x4_UNORM_BLOCK ]: UnsignedByteType,
|
|
1051
|
+
[ VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT ]: HalfFloatType,
|
|
1052
|
+
[ VK_FORMAT_ASTC_6x6_SRGB_BLOCK ]: UnsignedByteType,
|
|
1053
|
+
[ VK_FORMAT_ASTC_6x6_UNORM_BLOCK ]: UnsignedByteType,
|
|
1054
|
+
|
|
1055
|
+
[ VK_FORMAT_BC1_RGBA_SRGB_BLOCK ]: UnsignedByteType,
|
|
1056
|
+
[ VK_FORMAT_BC1_RGBA_UNORM_BLOCK ]: UnsignedByteType,
|
|
1057
|
+
[ VK_FORMAT_BC1_RGB_SRGB_BLOCK ]: UnsignedByteType,
|
|
1058
|
+
[ VK_FORMAT_BC1_RGB_UNORM_BLOCK ]: UnsignedByteType,
|
|
1059
|
+
|
|
1060
|
+
[ VK_FORMAT_BC3_SRGB_BLOCK ]: UnsignedByteType,
|
|
1061
|
+
[ VK_FORMAT_BC3_UNORM_BLOCK ]: UnsignedByteType,
|
|
1062
|
+
|
|
1063
|
+
[ VK_FORMAT_BC4_SNORM_BLOCK ]: UnsignedByteType,
|
|
1064
|
+
[ VK_FORMAT_BC4_UNORM_BLOCK ]: UnsignedByteType,
|
|
1065
|
+
|
|
1066
|
+
[ VK_FORMAT_BC5_SNORM_BLOCK ]: UnsignedByteType,
|
|
1067
|
+
[ VK_FORMAT_BC5_UNORM_BLOCK ]: UnsignedByteType,
|
|
1068
|
+
|
|
1069
|
+
[ VK_FORMAT_BC7_SRGB_BLOCK ]: UnsignedByteType,
|
|
1070
|
+
[ VK_FORMAT_BC7_UNORM_BLOCK ]: UnsignedByteType,
|
|
1071
|
+
|
|
1072
|
+
[ VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG ]: UnsignedByteType,
|
|
1073
|
+
[ VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG ]: UnsignedByteType,
|
|
1074
|
+
[ VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG ]: UnsignedByteType,
|
|
1075
|
+
[ VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG ]: UnsignedByteType,
|
|
1076
|
+
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
async function createRawTexture( container ) {
|
|
1080
|
+
|
|
1081
|
+
const { vkFormat } = container;
|
|
1082
|
+
|
|
1083
|
+
if ( FORMAT_MAP[ vkFormat ] === undefined ) {
|
|
1084
|
+
|
|
1085
|
+
throw new Error( 'THREE.KTX2Loader: Unsupported vkFormat: ' + vkFormat );
|
|
1086
|
+
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
// TODO: Merge the TYPE_MAP warning into the thrown error above, after r190.
|
|
1090
|
+
if ( TYPE_MAP[ vkFormat ] === undefined ) {
|
|
1091
|
+
|
|
1092
|
+
console.warn( 'THREE.KTX2Loader: Missing ".type" for vkFormat: ' + vkFormat );
|
|
1093
|
+
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
//
|
|
1097
|
+
|
|
1098
|
+
let zstd;
|
|
1099
|
+
|
|
1100
|
+
if ( container.supercompressionScheme === KHR_SUPERCOMPRESSION_ZSTD ) {
|
|
1101
|
+
|
|
1102
|
+
if ( ! _zstd ) {
|
|
1103
|
+
|
|
1104
|
+
_zstd = new Promise( async ( resolve ) => {
|
|
1105
|
+
|
|
1106
|
+
const zstd = new ZSTDDecoder();
|
|
1107
|
+
await zstd.init();
|
|
1108
|
+
resolve( zstd );
|
|
1109
|
+
|
|
1110
|
+
} );
|
|
1111
|
+
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
zstd = await _zstd;
|
|
1115
|
+
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
//
|
|
1119
|
+
|
|
1120
|
+
const mipmaps = [];
|
|
1121
|
+
|
|
1122
|
+
for ( let levelIndex = 0; levelIndex < container.levels.length; levelIndex ++ ) {
|
|
1123
|
+
|
|
1124
|
+
const levelWidth = Math.max( 1, container.pixelWidth >> levelIndex );
|
|
1125
|
+
const levelHeight = Math.max( 1, container.pixelHeight >> levelIndex );
|
|
1126
|
+
const levelDepth = container.pixelDepth ? Math.max( 1, container.pixelDepth >> levelIndex ) : 0;
|
|
1127
|
+
|
|
1128
|
+
const level = container.levels[ levelIndex ];
|
|
1129
|
+
|
|
1130
|
+
let levelData;
|
|
1131
|
+
|
|
1132
|
+
if ( container.supercompressionScheme === KHR_SUPERCOMPRESSION_NONE ) {
|
|
1133
|
+
|
|
1134
|
+
levelData = level.levelData;
|
|
1135
|
+
|
|
1136
|
+
} else if ( container.supercompressionScheme === KHR_SUPERCOMPRESSION_ZSTD ) {
|
|
1137
|
+
|
|
1138
|
+
levelData = zstd.decode( level.levelData, level.uncompressedByteLength );
|
|
1139
|
+
|
|
1140
|
+
} else {
|
|
1141
|
+
|
|
1142
|
+
throw new Error( 'THREE.KTX2Loader: Unsupported supercompressionScheme.' );
|
|
1143
|
+
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
let data;
|
|
1147
|
+
|
|
1148
|
+
if ( TYPE_MAP[ vkFormat ] === FloatType ) {
|
|
1149
|
+
|
|
1150
|
+
data = new Float32Array(
|
|
1151
|
+
|
|
1152
|
+
levelData.buffer,
|
|
1153
|
+
levelData.byteOffset,
|
|
1154
|
+
levelData.byteLength / Float32Array.BYTES_PER_ELEMENT
|
|
1155
|
+
|
|
1156
|
+
);
|
|
1157
|
+
|
|
1158
|
+
} else if ( TYPE_MAP[ vkFormat ] === HalfFloatType || TYPE_MAP[ vkFormat ] === UnsignedShortType ) {
|
|
1159
|
+
|
|
1160
|
+
data = new Uint16Array(
|
|
1161
|
+
|
|
1162
|
+
levelData.buffer,
|
|
1163
|
+
levelData.byteOffset,
|
|
1164
|
+
levelData.byteLength / Uint16Array.BYTES_PER_ELEMENT
|
|
1165
|
+
|
|
1166
|
+
);
|
|
1167
|
+
|
|
1168
|
+
} else if ( TYPE_MAP[ vkFormat ] === UnsignedInt5999Type || TYPE_MAP[ vkFormat ] === UnsignedInt101111Type ) {
|
|
1169
|
+
|
|
1170
|
+
data = new Uint32Array(
|
|
1171
|
+
|
|
1172
|
+
levelData.buffer,
|
|
1173
|
+
levelData.byteOffset,
|
|
1174
|
+
levelData.byteLength / Uint32Array.BYTES_PER_ELEMENT
|
|
1175
|
+
|
|
1176
|
+
);
|
|
1177
|
+
|
|
1178
|
+
} else {
|
|
1179
|
+
|
|
1180
|
+
data = levelData;
|
|
1181
|
+
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
mipmaps.push( {
|
|
1185
|
+
|
|
1186
|
+
data: data,
|
|
1187
|
+
width: levelWidth,
|
|
1188
|
+
height: levelHeight,
|
|
1189
|
+
depth: levelDepth,
|
|
1190
|
+
|
|
1191
|
+
} );
|
|
1192
|
+
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
// levelCount = 0 implies runtime-generated mipmaps.
|
|
1196
|
+
const useMipmaps = container.levelCount === 0 || mipmaps.length > 1;
|
|
1197
|
+
|
|
1198
|
+
let texture;
|
|
1199
|
+
|
|
1200
|
+
if ( UNCOMPRESSED_FORMATS.has( FORMAT_MAP[ vkFormat ] ) ) {
|
|
1201
|
+
|
|
1202
|
+
texture = container.pixelDepth === 0
|
|
1203
|
+
? new DataTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight )
|
|
1204
|
+
: new Data3DTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight, container.pixelDepth );
|
|
1205
|
+
texture.minFilter = useMipmaps ? NearestMipmapNearestFilter : NearestFilter;
|
|
1206
|
+
texture.magFilter = NearestFilter;
|
|
1207
|
+
texture.generateMipmaps = container.levelCount === 0;
|
|
1208
|
+
|
|
1209
|
+
} else {
|
|
1210
|
+
|
|
1211
|
+
if ( container.pixelDepth > 0 ) throw new Error( 'THREE.KTX2Loader: Unsupported pixelDepth.' );
|
|
1212
|
+
|
|
1213
|
+
texture = new CompressedTexture( mipmaps, container.pixelWidth, container.pixelHeight );
|
|
1214
|
+
texture.minFilter = useMipmaps ? LinearMipmapLinearFilter : LinearFilter;
|
|
1215
|
+
texture.magFilter = LinearFilter;
|
|
1216
|
+
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
texture.mipmaps = mipmaps;
|
|
1220
|
+
|
|
1221
|
+
texture.type = TYPE_MAP[ vkFormat ];
|
|
1222
|
+
texture.format = FORMAT_MAP[ vkFormat ];
|
|
1223
|
+
texture.colorSpace = parseColorSpace( container );
|
|
1224
|
+
texture.needsUpdate = true;
|
|
1225
|
+
|
|
1226
|
+
//
|
|
1227
|
+
|
|
1228
|
+
return Promise.resolve( texture );
|
|
1229
|
+
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
function parseColorSpace( container ) {
|
|
1233
|
+
|
|
1234
|
+
const dfd = container.dataFormatDescriptor[ 0 ];
|
|
1235
|
+
|
|
1236
|
+
if ( dfd.colorPrimaries === KHR_DF_PRIMARIES_BT709 ) {
|
|
1237
|
+
|
|
1238
|
+
return dfd.transferFunction === KHR_DF_TRANSFER_SRGB ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
1239
|
+
|
|
1240
|
+
} else if ( dfd.colorPrimaries === KHR_DF_PRIMARIES_DISPLAYP3 ) {
|
|
1241
|
+
|
|
1242
|
+
return dfd.transferFunction === KHR_DF_TRANSFER_SRGB ? DisplayP3ColorSpace : LinearDisplayP3ColorSpace;
|
|
1243
|
+
|
|
1244
|
+
} else if ( dfd.colorPrimaries === KHR_DF_PRIMARIES_UNSPECIFIED ) {
|
|
1245
|
+
|
|
1246
|
+
return NoColorSpace;
|
|
1247
|
+
|
|
1248
|
+
} else {
|
|
1249
|
+
|
|
1250
|
+
console.warn( `THREE.KTX2Loader: Unsupported color primaries, "${ dfd.colorPrimaries }"` );
|
|
1251
|
+
return NoColorSpace;
|
|
1252
|
+
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
export { KTX2Loader };
|