@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,1682 @@
|
|
|
1
|
+
import { BufferAttribute } from '../core/BufferAttribute.js';
|
|
2
|
+
import { BufferGeometry } from '../core/BufferGeometry.js';
|
|
3
|
+
import { DataTexture } from '../textures/DataTexture.js';
|
|
4
|
+
import { FloatType, RedIntegerFormat, UnsignedIntType, RGBAFormat } from '../constants.js';
|
|
5
|
+
import { Matrix4 } from '../math/Matrix4.js';
|
|
6
|
+
import { Mesh } from './Mesh.js';
|
|
7
|
+
import { ColorManagement } from '../math/ColorManagement.js';
|
|
8
|
+
import { Box3 } from '../math/Box3.js';
|
|
9
|
+
import { Sphere } from '../math/Sphere.js';
|
|
10
|
+
import { Frustum } from '../math/Frustum.js';
|
|
11
|
+
import { Vector3 } from '../math/Vector3.js';
|
|
12
|
+
import { Color } from '../math/Color.js';
|
|
13
|
+
import { FrustumArray } from '../math/FrustumArray.js';
|
|
14
|
+
|
|
15
|
+
function ascIdSort( a, b ) {
|
|
16
|
+
|
|
17
|
+
return a - b;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function sortOpaque( a, b ) {
|
|
22
|
+
|
|
23
|
+
return a.z - b.z;
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function sortTransparent( a, b ) {
|
|
28
|
+
|
|
29
|
+
return b.z - a.z;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class MultiDrawRenderList {
|
|
34
|
+
|
|
35
|
+
constructor() {
|
|
36
|
+
|
|
37
|
+
this.index = 0;
|
|
38
|
+
this.pool = [];
|
|
39
|
+
this.list = [];
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
push( start, count, z, index ) {
|
|
44
|
+
|
|
45
|
+
const pool = this.pool;
|
|
46
|
+
const list = this.list;
|
|
47
|
+
if ( this.index >= pool.length ) {
|
|
48
|
+
|
|
49
|
+
pool.push( {
|
|
50
|
+
|
|
51
|
+
start: - 1,
|
|
52
|
+
count: - 1,
|
|
53
|
+
z: - 1,
|
|
54
|
+
index: - 1,
|
|
55
|
+
|
|
56
|
+
} );
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const item = pool[ this.index ];
|
|
61
|
+
list.push( item );
|
|
62
|
+
this.index ++;
|
|
63
|
+
|
|
64
|
+
item.start = start;
|
|
65
|
+
item.count = count;
|
|
66
|
+
item.z = z;
|
|
67
|
+
item.index = index;
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
reset() {
|
|
72
|
+
|
|
73
|
+
this.list.length = 0;
|
|
74
|
+
this.index = 0;
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const _matrix = /*@__PURE__*/ new Matrix4();
|
|
81
|
+
const _whiteColor = /*@__PURE__*/ new Color( 1, 1, 1 );
|
|
82
|
+
const _frustum = /*@__PURE__*/ new Frustum();
|
|
83
|
+
const _frustumArray = /*@__PURE__*/ new FrustumArray();
|
|
84
|
+
const _box = /*@__PURE__*/ new Box3();
|
|
85
|
+
const _sphere = /*@__PURE__*/ new Sphere();
|
|
86
|
+
const _vector = /*@__PURE__*/ new Vector3();
|
|
87
|
+
const _forward = /*@__PURE__*/ new Vector3();
|
|
88
|
+
const _temp = /*@__PURE__*/ new Vector3();
|
|
89
|
+
const _renderList = /*@__PURE__*/ new MultiDrawRenderList();
|
|
90
|
+
const _mesh = /*@__PURE__*/ new Mesh();
|
|
91
|
+
const _batchIntersects = [];
|
|
92
|
+
|
|
93
|
+
// copies data from attribute "src" into "target" starting at "targetOffset"
|
|
94
|
+
function copyAttributeData( src, target, targetOffset = 0 ) {
|
|
95
|
+
|
|
96
|
+
const itemSize = target.itemSize;
|
|
97
|
+
if ( src.isInterleavedBufferAttribute || src.array.constructor !== target.array.constructor ) {
|
|
98
|
+
|
|
99
|
+
// use the component getters and setters if the array data cannot
|
|
100
|
+
// be copied directly
|
|
101
|
+
const vertexCount = src.count;
|
|
102
|
+
for ( let i = 0; i < vertexCount; i ++ ) {
|
|
103
|
+
|
|
104
|
+
for ( let c = 0; c < itemSize; c ++ ) {
|
|
105
|
+
|
|
106
|
+
target.setComponent( i + targetOffset, c, src.getComponent( i, c ) );
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
} else {
|
|
113
|
+
|
|
114
|
+
// faster copy approach using typed array set function
|
|
115
|
+
target.array.set( src.array, targetOffset * itemSize );
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
target.needsUpdate = true;
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// safely copies array contents to a potentially smaller array
|
|
124
|
+
function copyArrayContents( src, target ) {
|
|
125
|
+
|
|
126
|
+
if ( src.constructor !== target.constructor ) {
|
|
127
|
+
|
|
128
|
+
// if arrays are of a different type (eg due to index size increasing) then data must be per-element copied
|
|
129
|
+
const len = Math.min( src.length, target.length );
|
|
130
|
+
for ( let i = 0; i < len; i ++ ) {
|
|
131
|
+
|
|
132
|
+
target[ i ] = src[ i ];
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
} else {
|
|
137
|
+
|
|
138
|
+
// if the arrays use the same data layout we can use a fast block copy
|
|
139
|
+
const len = Math.min( src.length, target.length );
|
|
140
|
+
target.set( new src.constructor( src.buffer, 0, len ) );
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A special version of a mesh with multi draw batch rendering support. Use
|
|
148
|
+
* this class if you have to render a large number of objects with the same
|
|
149
|
+
* material but with different geometries or world transformations. The usage of
|
|
150
|
+
* `BatchedMesh` will help you to reduce the number of draw calls and thus improve the overall
|
|
151
|
+
* rendering performance in your application.
|
|
152
|
+
*
|
|
153
|
+
* ```js
|
|
154
|
+
* const box = new THREE.BoxGeometry( 1, 1, 1 );
|
|
155
|
+
* const sphere = new THREE.SphereGeometry( 1, 12, 12 );
|
|
156
|
+
* const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
|
|
157
|
+
*
|
|
158
|
+
* // initialize and add geometries into the batched mesh
|
|
159
|
+
* const batchedMesh = new BatchedMesh( 10, 5000, 10000, material );
|
|
160
|
+
* const boxGeometryId = batchedMesh.addGeometry( box );
|
|
161
|
+
* const sphereGeometryId = batchedMesh.addGeometry( sphere );
|
|
162
|
+
*
|
|
163
|
+
* // create instances of those geometries
|
|
164
|
+
* const boxInstancedId1 = batchedMesh.addInstance( boxGeometryId );
|
|
165
|
+
* const boxInstancedId2 = batchedMesh.addInstance( boxGeometryId );
|
|
166
|
+
*
|
|
167
|
+
* const sphereInstancedId1 = batchedMesh.addInstance( sphereGeometryId );
|
|
168
|
+
* const sphereInstancedId2 = batchedMesh.addInstance( sphereGeometryId );
|
|
169
|
+
*
|
|
170
|
+
* // position the geometries
|
|
171
|
+
* batchedMesh.setMatrixAt( boxInstancedId1, boxMatrix1 );
|
|
172
|
+
* batchedMesh.setMatrixAt( boxInstancedId2, boxMatrix2 );
|
|
173
|
+
*
|
|
174
|
+
* batchedMesh.setMatrixAt( sphereInstancedId1, sphereMatrix1 );
|
|
175
|
+
* batchedMesh.setMatrixAt( sphereInstancedId2, sphereMatrix2 );
|
|
176
|
+
*
|
|
177
|
+
* scene.add( batchedMesh );
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @augments Mesh
|
|
181
|
+
*/
|
|
182
|
+
class BatchedMesh extends Mesh {
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Constructs a new batched mesh.
|
|
186
|
+
*
|
|
187
|
+
* @param {number} maxInstanceCount - The maximum number of individual instances planned to be added and rendered.
|
|
188
|
+
* @param {number} maxVertexCount - The maximum number of vertices to be used by all unique geometries.
|
|
189
|
+
* @param {number} [maxIndexCount=maxVertexCount*2] - The maximum number of indices to be used by all unique geometries
|
|
190
|
+
* @param {Material|Array<Material>} [material] - The mesh material.
|
|
191
|
+
*/
|
|
192
|
+
constructor( maxInstanceCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
|
|
193
|
+
|
|
194
|
+
super( new BufferGeometry(), material );
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* This flag can be used for type testing.
|
|
198
|
+
*
|
|
199
|
+
* @type {boolean}
|
|
200
|
+
* @readonly
|
|
201
|
+
* @default true
|
|
202
|
+
*/
|
|
203
|
+
this.isBatchedMesh = true;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* When set ot `true`, the individual objects of a batch are frustum culled.
|
|
207
|
+
*
|
|
208
|
+
* @type {boolean}
|
|
209
|
+
* @default true
|
|
210
|
+
*/
|
|
211
|
+
this.perObjectFrustumCulled = true;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* When set to `true`, the individual objects of a batch are sorted to improve overdraw-related artifacts.
|
|
215
|
+
* If the material is marked as "transparent" objects are rendered back to front and if not then they are
|
|
216
|
+
* rendered front to back.
|
|
217
|
+
*
|
|
218
|
+
* @type {boolean}
|
|
219
|
+
* @default true
|
|
220
|
+
*/
|
|
221
|
+
this.sortObjects = true;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* The bounding box of the batched mesh. Can be computed via {@link BatchedMesh#computeBoundingBox}.
|
|
225
|
+
*
|
|
226
|
+
* @type {?Box3}
|
|
227
|
+
* @default null
|
|
228
|
+
*/
|
|
229
|
+
this.boundingBox = null;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The bounding sphere of the batched mesh. Can be computed via {@link BatchedMesh#computeBoundingSphere}.
|
|
233
|
+
*
|
|
234
|
+
* @type {?Sphere}
|
|
235
|
+
* @default null
|
|
236
|
+
*/
|
|
237
|
+
this.boundingSphere = null;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Takes a sort a function that is run before render. The function takes a list of instances to
|
|
241
|
+
* sort and a camera. The objects in the list include a "z" field to perform a depth-ordered
|
|
242
|
+
* sort with.
|
|
243
|
+
*
|
|
244
|
+
* @type {?Function}
|
|
245
|
+
* @default null
|
|
246
|
+
*/
|
|
247
|
+
this.customSort = null;
|
|
248
|
+
|
|
249
|
+
// stores visible, active, and geometry id per instance and reserved buffer ranges for geometries
|
|
250
|
+
this._instanceInfo = [];
|
|
251
|
+
this._geometryInfo = [];
|
|
252
|
+
|
|
253
|
+
// instance, geometry ids that have been set as inactive, and are available to be overwritten
|
|
254
|
+
this._availableInstanceIds = [];
|
|
255
|
+
this._availableGeometryIds = [];
|
|
256
|
+
|
|
257
|
+
// used to track where the next point is that geometry should be inserted
|
|
258
|
+
this._nextIndexStart = 0;
|
|
259
|
+
this._nextVertexStart = 0;
|
|
260
|
+
this._geometryCount = 0;
|
|
261
|
+
|
|
262
|
+
// flags
|
|
263
|
+
this._visibilityChanged = true;
|
|
264
|
+
this._geometryInitialized = false;
|
|
265
|
+
|
|
266
|
+
// cached user options
|
|
267
|
+
this._maxInstanceCount = maxInstanceCount;
|
|
268
|
+
this._maxVertexCount = maxVertexCount;
|
|
269
|
+
this._maxIndexCount = maxIndexCount;
|
|
270
|
+
|
|
271
|
+
// buffers for multi draw
|
|
272
|
+
this._multiDrawCounts = new Int32Array( maxInstanceCount );
|
|
273
|
+
this._multiDrawStarts = new Int32Array( maxInstanceCount );
|
|
274
|
+
this._multiDrawCount = 0;
|
|
275
|
+
|
|
276
|
+
// Local matrix per geometry by using data texture
|
|
277
|
+
this._matricesTexture = null;
|
|
278
|
+
this._indirectTexture = null;
|
|
279
|
+
this._colorsTexture = null;
|
|
280
|
+
|
|
281
|
+
this._initMatricesTexture();
|
|
282
|
+
this._initIndirectTexture();
|
|
283
|
+
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The maximum number of individual instances that can be stored in the batch.
|
|
288
|
+
*
|
|
289
|
+
* @type {number}
|
|
290
|
+
* @readonly
|
|
291
|
+
*/
|
|
292
|
+
get maxInstanceCount() {
|
|
293
|
+
|
|
294
|
+
return this._maxInstanceCount;
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* The instance count.
|
|
300
|
+
*
|
|
301
|
+
* @type {number}
|
|
302
|
+
* @readonly
|
|
303
|
+
*/
|
|
304
|
+
get instanceCount() {
|
|
305
|
+
|
|
306
|
+
return this._instanceInfo.length - this._availableInstanceIds.length;
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* The number of unused vertices.
|
|
312
|
+
*
|
|
313
|
+
* @type {number}
|
|
314
|
+
* @readonly
|
|
315
|
+
*/
|
|
316
|
+
get unusedVertexCount() {
|
|
317
|
+
|
|
318
|
+
return this._maxVertexCount - this._nextVertexStart;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The number of unused indices.
|
|
324
|
+
*
|
|
325
|
+
* @type {number}
|
|
326
|
+
* @readonly
|
|
327
|
+
*/
|
|
328
|
+
get unusedIndexCount() {
|
|
329
|
+
|
|
330
|
+
return this._maxIndexCount - this._nextIndexStart;
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
_initMatricesTexture() {
|
|
335
|
+
|
|
336
|
+
// layout (1 matrix = 4 pixels)
|
|
337
|
+
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
|
|
338
|
+
// with 8x8 pixel texture max 16 matrices * 4 pixels = (8 * 8)
|
|
339
|
+
// 16x16 pixel texture max 64 matrices * 4 pixels = (16 * 16)
|
|
340
|
+
// 32x32 pixel texture max 256 matrices * 4 pixels = (32 * 32)
|
|
341
|
+
// 64x64 pixel texture max 1024 matrices * 4 pixels = (64 * 64)
|
|
342
|
+
|
|
343
|
+
let size = Math.sqrt( this._maxInstanceCount * 4 ); // 4 pixels needed for 1 matrix
|
|
344
|
+
size = Math.ceil( size / 4 ) * 4;
|
|
345
|
+
size = Math.max( size, 4 );
|
|
346
|
+
|
|
347
|
+
const matricesArray = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
|
|
348
|
+
const matricesTexture = new DataTexture( matricesArray, size, size, RGBAFormat, FloatType );
|
|
349
|
+
|
|
350
|
+
this._matricesTexture = matricesTexture;
|
|
351
|
+
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
_initIndirectTexture() {
|
|
355
|
+
|
|
356
|
+
let size = Math.sqrt( this._maxInstanceCount );
|
|
357
|
+
size = Math.ceil( size );
|
|
358
|
+
|
|
359
|
+
const indirectArray = new Uint32Array( size * size );
|
|
360
|
+
const indirectTexture = new DataTexture( indirectArray, size, size, RedIntegerFormat, UnsignedIntType );
|
|
361
|
+
|
|
362
|
+
this._indirectTexture = indirectTexture;
|
|
363
|
+
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
_initColorsTexture() {
|
|
367
|
+
|
|
368
|
+
let size = Math.sqrt( this._maxInstanceCount );
|
|
369
|
+
size = Math.ceil( size );
|
|
370
|
+
|
|
371
|
+
// 4 floats per RGBA pixel initialized to white
|
|
372
|
+
const colorsArray = new Float32Array( size * size * 4 ).fill( 1 );
|
|
373
|
+
const colorsTexture = new DataTexture( colorsArray, size, size, RGBAFormat, FloatType );
|
|
374
|
+
colorsTexture.colorSpace = ColorManagement.workingColorSpace;
|
|
375
|
+
|
|
376
|
+
this._colorsTexture = colorsTexture;
|
|
377
|
+
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
_initializeGeometry( reference ) {
|
|
381
|
+
|
|
382
|
+
const geometry = this.geometry;
|
|
383
|
+
const maxVertexCount = this._maxVertexCount;
|
|
384
|
+
const maxIndexCount = this._maxIndexCount;
|
|
385
|
+
if ( this._geometryInitialized === false ) {
|
|
386
|
+
|
|
387
|
+
for ( const attributeName in reference.attributes ) {
|
|
388
|
+
|
|
389
|
+
const srcAttribute = reference.getAttribute( attributeName );
|
|
390
|
+
const { array, itemSize, normalized } = srcAttribute;
|
|
391
|
+
|
|
392
|
+
const dstArray = new array.constructor( maxVertexCount * itemSize );
|
|
393
|
+
const dstAttribute = new BufferAttribute( dstArray, itemSize, normalized );
|
|
394
|
+
|
|
395
|
+
geometry.setAttribute( attributeName, dstAttribute );
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if ( reference.getIndex() !== null ) {
|
|
400
|
+
|
|
401
|
+
// Reserve last u16 index for primitive restart.
|
|
402
|
+
const indexArray = maxVertexCount > 65535
|
|
403
|
+
? new Uint32Array( maxIndexCount )
|
|
404
|
+
: new Uint16Array( maxIndexCount );
|
|
405
|
+
|
|
406
|
+
geometry.setIndex( new BufferAttribute( indexArray, 1 ) );
|
|
407
|
+
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
this._geometryInitialized = true;
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Make sure the geometry is compatible with the existing combined geometry attributes
|
|
417
|
+
_validateGeometry( geometry ) {
|
|
418
|
+
|
|
419
|
+
// check to ensure the geometries are using consistent attributes and indices
|
|
420
|
+
const batchGeometry = this.geometry;
|
|
421
|
+
if ( Boolean( geometry.getIndex() ) !== Boolean( batchGeometry.getIndex() ) ) {
|
|
422
|
+
|
|
423
|
+
throw new Error( 'THREE.BatchedMesh: All geometries must consistently have "index".' );
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
for ( const attributeName in batchGeometry.attributes ) {
|
|
428
|
+
|
|
429
|
+
if ( ! geometry.hasAttribute( attributeName ) ) {
|
|
430
|
+
|
|
431
|
+
throw new Error( `THREE.BatchedMesh: Added geometry missing "${ attributeName }". All geometries must have consistent attributes.` );
|
|
432
|
+
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const srcAttribute = geometry.getAttribute( attributeName );
|
|
436
|
+
const dstAttribute = batchGeometry.getAttribute( attributeName );
|
|
437
|
+
if ( srcAttribute.itemSize !== dstAttribute.itemSize || srcAttribute.normalized !== dstAttribute.normalized ) {
|
|
438
|
+
|
|
439
|
+
throw new Error( 'THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.' );
|
|
440
|
+
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Validates the instance defined by the given ID.
|
|
449
|
+
*
|
|
450
|
+
* @param {number} instanceId - The instance to validate.
|
|
451
|
+
*/
|
|
452
|
+
validateInstanceId( instanceId ) {
|
|
453
|
+
|
|
454
|
+
const instanceInfo = this._instanceInfo;
|
|
455
|
+
if ( instanceId < 0 || instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
|
|
456
|
+
|
|
457
|
+
throw new Error( `THREE.BatchedMesh: Invalid instanceId ${instanceId}. Instance is either out of range or has been deleted.` );
|
|
458
|
+
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Validates the geometry defined by the given ID.
|
|
465
|
+
*
|
|
466
|
+
* @param {number} geometryId - The geometry to validate.
|
|
467
|
+
*/
|
|
468
|
+
validateGeometryId( geometryId ) {
|
|
469
|
+
|
|
470
|
+
const geometryInfoList = this._geometryInfo;
|
|
471
|
+
if ( geometryId < 0 || geometryId >= geometryInfoList.length || geometryInfoList[ geometryId ].active === false ) {
|
|
472
|
+
|
|
473
|
+
throw new Error( `THREE.BatchedMesh: Invalid geometryId ${geometryId}. Geometry is either out of range or has been deleted.` );
|
|
474
|
+
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Takes a sort a function that is run before render. The function takes a list of instances to
|
|
481
|
+
* sort and a camera. The objects in the list include a "z" field to perform a depth-ordered sort with.
|
|
482
|
+
*
|
|
483
|
+
* @param {Function} func - The custom sort function.
|
|
484
|
+
* @return {BatchedMesh} A reference to this batched mesh.
|
|
485
|
+
*/
|
|
486
|
+
setCustomSort( func ) {
|
|
487
|
+
|
|
488
|
+
this.customSort = func;
|
|
489
|
+
return this;
|
|
490
|
+
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Computes the bounding box, updating {@link BatchedMesh#boundingBox}.
|
|
495
|
+
* Bounding boxes aren't computed by default. They need to be explicitly computed,
|
|
496
|
+
* otherwise they are `null`.
|
|
497
|
+
*/
|
|
498
|
+
computeBoundingBox() {
|
|
499
|
+
|
|
500
|
+
if ( this.boundingBox === null ) {
|
|
501
|
+
|
|
502
|
+
this.boundingBox = new Box3();
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const boundingBox = this.boundingBox;
|
|
507
|
+
const instanceInfo = this._instanceInfo;
|
|
508
|
+
|
|
509
|
+
boundingBox.makeEmpty();
|
|
510
|
+
for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
|
|
511
|
+
|
|
512
|
+
if ( instanceInfo[ i ].active === false ) continue;
|
|
513
|
+
|
|
514
|
+
const geometryId = instanceInfo[ i ].geometryIndex;
|
|
515
|
+
this.getMatrixAt( i, _matrix );
|
|
516
|
+
this.getBoundingBoxAt( geometryId, _box ).applyMatrix4( _matrix );
|
|
517
|
+
boundingBox.union( _box );
|
|
518
|
+
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Computes the bounding sphere, updating {@link BatchedMesh#boundingSphere}.
|
|
525
|
+
* Bounding spheres aren't computed by default. They need to be explicitly computed,
|
|
526
|
+
* otherwise they are `null`.
|
|
527
|
+
*/
|
|
528
|
+
computeBoundingSphere() {
|
|
529
|
+
|
|
530
|
+
if ( this.boundingSphere === null ) {
|
|
531
|
+
|
|
532
|
+
this.boundingSphere = new Sphere();
|
|
533
|
+
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const boundingSphere = this.boundingSphere;
|
|
537
|
+
const instanceInfo = this._instanceInfo;
|
|
538
|
+
|
|
539
|
+
boundingSphere.makeEmpty();
|
|
540
|
+
for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
|
|
541
|
+
|
|
542
|
+
if ( instanceInfo[ i ].active === false ) continue;
|
|
543
|
+
|
|
544
|
+
const geometryId = instanceInfo[ i ].geometryIndex;
|
|
545
|
+
this.getMatrixAt( i, _matrix );
|
|
546
|
+
this.getBoundingSphereAt( geometryId, _sphere ).applyMatrix4( _matrix );
|
|
547
|
+
boundingSphere.union( _sphere );
|
|
548
|
+
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Adds a new instance to the batch using the geometry of the given ID and returns
|
|
555
|
+
* a new id referring to the new instance to be used by other functions.
|
|
556
|
+
*
|
|
557
|
+
* @param {number} geometryId - The ID of a previously added geometry via {@link BatchedMesh#addGeometry}.
|
|
558
|
+
* @return {number} The instance ID.
|
|
559
|
+
*/
|
|
560
|
+
addInstance( geometryId ) {
|
|
561
|
+
|
|
562
|
+
const atCapacity = this._instanceInfo.length >= this.maxInstanceCount;
|
|
563
|
+
|
|
564
|
+
// ensure we're not over geometry
|
|
565
|
+
if ( atCapacity && this._availableInstanceIds.length === 0 ) {
|
|
566
|
+
|
|
567
|
+
throw new Error( 'THREE.BatchedMesh: Maximum item count reached.' );
|
|
568
|
+
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const instanceInfo = {
|
|
572
|
+
visible: true,
|
|
573
|
+
active: true,
|
|
574
|
+
geometryIndex: geometryId,
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
let drawId = null;
|
|
578
|
+
|
|
579
|
+
// Prioritize using previously freed instance ids
|
|
580
|
+
if ( this._availableInstanceIds.length > 0 ) {
|
|
581
|
+
|
|
582
|
+
this._availableInstanceIds.sort( ascIdSort );
|
|
583
|
+
|
|
584
|
+
drawId = this._availableInstanceIds.shift();
|
|
585
|
+
this._instanceInfo[ drawId ] = instanceInfo;
|
|
586
|
+
|
|
587
|
+
} else {
|
|
588
|
+
|
|
589
|
+
drawId = this._instanceInfo.length;
|
|
590
|
+
this._instanceInfo.push( instanceInfo );
|
|
591
|
+
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
const matricesTexture = this._matricesTexture;
|
|
595
|
+
_matrix.identity().toArray( matricesTexture.image.data, drawId * 16 );
|
|
596
|
+
matricesTexture.needsUpdate = true;
|
|
597
|
+
|
|
598
|
+
const colorsTexture = this._colorsTexture;
|
|
599
|
+
if ( colorsTexture ) {
|
|
600
|
+
|
|
601
|
+
_whiteColor.toArray( colorsTexture.image.data, drawId * 4 );
|
|
602
|
+
colorsTexture.needsUpdate = true;
|
|
603
|
+
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
this._visibilityChanged = true;
|
|
607
|
+
return drawId;
|
|
608
|
+
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Adds the given geometry to the batch and returns the associated
|
|
613
|
+
* geometry id referring to it to be used in other functions.
|
|
614
|
+
*
|
|
615
|
+
* @param {BufferGeometry} geometry - The geometry to add.
|
|
616
|
+
* @param {number} [reservedVertexCount=-1] - Optional parameter specifying the amount of
|
|
617
|
+
* vertex buffer space to reserve for the added geometry. This is necessary if it is planned
|
|
618
|
+
* to set a new geometry at this index at a later time that is larger than the original geometry.
|
|
619
|
+
* Defaults to the length of the given geometry vertex buffer.
|
|
620
|
+
* @param {number} [reservedIndexCount=-1] - Optional parameter specifying the amount of index
|
|
621
|
+
* buffer space to reserve for the added geometry. This is necessary if it is planned to set a
|
|
622
|
+
* new geometry at this index at a later time that is larger than the original geometry. Defaults to
|
|
623
|
+
* the length of the given geometry index buffer.
|
|
624
|
+
* @return {number} The geometry ID.
|
|
625
|
+
*/
|
|
626
|
+
addGeometry( geometry, reservedVertexCount = - 1, reservedIndexCount = - 1 ) {
|
|
627
|
+
|
|
628
|
+
this._initializeGeometry( geometry );
|
|
629
|
+
|
|
630
|
+
this._validateGeometry( geometry );
|
|
631
|
+
|
|
632
|
+
const geometryInfo = {
|
|
633
|
+
// geometry information
|
|
634
|
+
vertexStart: - 1,
|
|
635
|
+
vertexCount: - 1,
|
|
636
|
+
reservedVertexCount: - 1,
|
|
637
|
+
|
|
638
|
+
indexStart: - 1,
|
|
639
|
+
indexCount: - 1,
|
|
640
|
+
reservedIndexCount: - 1,
|
|
641
|
+
|
|
642
|
+
// draw range information
|
|
643
|
+
start: - 1,
|
|
644
|
+
count: - 1,
|
|
645
|
+
|
|
646
|
+
// state
|
|
647
|
+
boundingBox: null,
|
|
648
|
+
boundingSphere: null,
|
|
649
|
+
active: true,
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
const geometryInfoList = this._geometryInfo;
|
|
653
|
+
geometryInfo.vertexStart = this._nextVertexStart;
|
|
654
|
+
geometryInfo.reservedVertexCount = reservedVertexCount === - 1 ? geometry.getAttribute( 'position' ).count : reservedVertexCount;
|
|
655
|
+
|
|
656
|
+
const index = geometry.getIndex();
|
|
657
|
+
const hasIndex = index !== null;
|
|
658
|
+
if ( hasIndex ) {
|
|
659
|
+
|
|
660
|
+
geometryInfo.indexStart = this._nextIndexStart;
|
|
661
|
+
geometryInfo.reservedIndexCount = reservedIndexCount === - 1 ? index.count : reservedIndexCount;
|
|
662
|
+
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (
|
|
666
|
+
geometryInfo.indexStart !== - 1 &&
|
|
667
|
+
geometryInfo.indexStart + geometryInfo.reservedIndexCount > this._maxIndexCount ||
|
|
668
|
+
geometryInfo.vertexStart + geometryInfo.reservedVertexCount > this._maxVertexCount
|
|
669
|
+
) {
|
|
670
|
+
|
|
671
|
+
throw new Error( 'THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.' );
|
|
672
|
+
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// update id
|
|
676
|
+
let geometryId;
|
|
677
|
+
if ( this._availableGeometryIds.length > 0 ) {
|
|
678
|
+
|
|
679
|
+
this._availableGeometryIds.sort( ascIdSort );
|
|
680
|
+
|
|
681
|
+
geometryId = this._availableGeometryIds.shift();
|
|
682
|
+
geometryInfoList[ geometryId ] = geometryInfo;
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
} else {
|
|
686
|
+
|
|
687
|
+
geometryId = this._geometryCount;
|
|
688
|
+
this._geometryCount ++;
|
|
689
|
+
geometryInfoList.push( geometryInfo );
|
|
690
|
+
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// update the geometry
|
|
694
|
+
this.setGeometryAt( geometryId, geometry );
|
|
695
|
+
|
|
696
|
+
// increment the next geometry position
|
|
697
|
+
this._nextIndexStart = geometryInfo.indexStart + geometryInfo.reservedIndexCount;
|
|
698
|
+
this._nextVertexStart = geometryInfo.vertexStart + geometryInfo.reservedVertexCount;
|
|
699
|
+
|
|
700
|
+
return geometryId;
|
|
701
|
+
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Replaces the geometry at the given ID with the provided geometry. Throws an error if there
|
|
706
|
+
* is not enough space reserved for geometry. Calling this will change all instances that are
|
|
707
|
+
* rendering that geometry.
|
|
708
|
+
*
|
|
709
|
+
* @param {number} geometryId - The ID of the geometry that should be replaced with the given geometry.
|
|
710
|
+
* @param {BufferGeometry} geometry - The new geometry.
|
|
711
|
+
* @return {number} The geometry ID.
|
|
712
|
+
*/
|
|
713
|
+
setGeometryAt( geometryId, geometry ) {
|
|
714
|
+
|
|
715
|
+
if ( geometryId >= this._geometryCount ) {
|
|
716
|
+
|
|
717
|
+
throw new Error( 'THREE.BatchedMesh: Maximum geometry count reached.' );
|
|
718
|
+
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
this._validateGeometry( geometry );
|
|
722
|
+
|
|
723
|
+
const batchGeometry = this.geometry;
|
|
724
|
+
const hasIndex = batchGeometry.getIndex() !== null;
|
|
725
|
+
const dstIndex = batchGeometry.getIndex();
|
|
726
|
+
const srcIndex = geometry.getIndex();
|
|
727
|
+
const geometryInfo = this._geometryInfo[ geometryId ];
|
|
728
|
+
if (
|
|
729
|
+
hasIndex &&
|
|
730
|
+
srcIndex.count > geometryInfo.reservedIndexCount ||
|
|
731
|
+
geometry.attributes.position.count > geometryInfo.reservedVertexCount
|
|
732
|
+
) {
|
|
733
|
+
|
|
734
|
+
throw new Error( 'THREE.BatchedMesh: Reserved space not large enough for provided geometry.' );
|
|
735
|
+
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// copy geometry buffer data over
|
|
739
|
+
const vertexStart = geometryInfo.vertexStart;
|
|
740
|
+
const reservedVertexCount = geometryInfo.reservedVertexCount;
|
|
741
|
+
geometryInfo.vertexCount = geometry.getAttribute( 'position' ).count;
|
|
742
|
+
|
|
743
|
+
for ( const attributeName in batchGeometry.attributes ) {
|
|
744
|
+
|
|
745
|
+
// copy attribute data
|
|
746
|
+
const srcAttribute = geometry.getAttribute( attributeName );
|
|
747
|
+
const dstAttribute = batchGeometry.getAttribute( attributeName );
|
|
748
|
+
copyAttributeData( srcAttribute, dstAttribute, vertexStart );
|
|
749
|
+
|
|
750
|
+
// fill the rest in with zeroes
|
|
751
|
+
const itemSize = srcAttribute.itemSize;
|
|
752
|
+
for ( let i = srcAttribute.count, l = reservedVertexCount; i < l; i ++ ) {
|
|
753
|
+
|
|
754
|
+
const index = vertexStart + i;
|
|
755
|
+
for ( let c = 0; c < itemSize; c ++ ) {
|
|
756
|
+
|
|
757
|
+
dstAttribute.setComponent( index, c, 0 );
|
|
758
|
+
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
dstAttribute.needsUpdate = true;
|
|
764
|
+
dstAttribute.addUpdateRange( vertexStart * itemSize, reservedVertexCount * itemSize );
|
|
765
|
+
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// copy index
|
|
769
|
+
if ( hasIndex ) {
|
|
770
|
+
|
|
771
|
+
const indexStart = geometryInfo.indexStart;
|
|
772
|
+
const reservedIndexCount = geometryInfo.reservedIndexCount;
|
|
773
|
+
geometryInfo.indexCount = geometry.getIndex().count;
|
|
774
|
+
|
|
775
|
+
// copy index data over
|
|
776
|
+
for ( let i = 0; i < srcIndex.count; i ++ ) {
|
|
777
|
+
|
|
778
|
+
dstIndex.setX( indexStart + i, vertexStart + srcIndex.getX( i ) );
|
|
779
|
+
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// fill the rest in with zeroes
|
|
783
|
+
for ( let i = srcIndex.count, l = reservedIndexCount; i < l; i ++ ) {
|
|
784
|
+
|
|
785
|
+
dstIndex.setX( indexStart + i, vertexStart );
|
|
786
|
+
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
dstIndex.needsUpdate = true;
|
|
790
|
+
dstIndex.addUpdateRange( indexStart, geometryInfo.reservedIndexCount );
|
|
791
|
+
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// update the draw range
|
|
795
|
+
geometryInfo.start = hasIndex ? geometryInfo.indexStart : geometryInfo.vertexStart;
|
|
796
|
+
geometryInfo.count = hasIndex ? geometryInfo.indexCount : geometryInfo.vertexCount;
|
|
797
|
+
|
|
798
|
+
// store the bounding boxes
|
|
799
|
+
geometryInfo.boundingBox = null;
|
|
800
|
+
if ( geometry.boundingBox !== null ) {
|
|
801
|
+
|
|
802
|
+
geometryInfo.boundingBox = geometry.boundingBox.clone();
|
|
803
|
+
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
geometryInfo.boundingSphere = null;
|
|
807
|
+
if ( geometry.boundingSphere !== null ) {
|
|
808
|
+
|
|
809
|
+
geometryInfo.boundingSphere = geometry.boundingSphere.clone();
|
|
810
|
+
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
this._visibilityChanged = true;
|
|
814
|
+
return geometryId;
|
|
815
|
+
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Deletes the geometry defined by the given ID from this batch. Any instances referencing
|
|
820
|
+
* this geometry will also be removed as a side effect.
|
|
821
|
+
*
|
|
822
|
+
* @param {number} geometryId - The ID of the geometry to remove from the batch.
|
|
823
|
+
* @return {BatchedMesh} A reference to this batched mesh.
|
|
824
|
+
*/
|
|
825
|
+
deleteGeometry( geometryId ) {
|
|
826
|
+
|
|
827
|
+
const geometryInfoList = this._geometryInfo;
|
|
828
|
+
if ( geometryId >= geometryInfoList.length || geometryInfoList[ geometryId ].active === false ) {
|
|
829
|
+
|
|
830
|
+
return this;
|
|
831
|
+
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// delete any instances associated with this geometry
|
|
835
|
+
const instanceInfo = this._instanceInfo;
|
|
836
|
+
for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
|
|
837
|
+
|
|
838
|
+
if ( instanceInfo[ i ].active && instanceInfo[ i ].geometryIndex === geometryId ) {
|
|
839
|
+
|
|
840
|
+
this.deleteInstance( i );
|
|
841
|
+
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
geometryInfoList[ geometryId ].active = false;
|
|
847
|
+
this._availableGeometryIds.push( geometryId );
|
|
848
|
+
this._visibilityChanged = true;
|
|
849
|
+
|
|
850
|
+
return this;
|
|
851
|
+
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Deletes an existing instance from the batch using the given ID.
|
|
856
|
+
*
|
|
857
|
+
* @param {number} instanceId - The ID of the instance to remove from the batch.
|
|
858
|
+
* @return {BatchedMesh} A reference to this batched mesh.
|
|
859
|
+
*/
|
|
860
|
+
deleteInstance( instanceId ) {
|
|
861
|
+
|
|
862
|
+
this.validateInstanceId( instanceId );
|
|
863
|
+
|
|
864
|
+
this._instanceInfo[ instanceId ].active = false;
|
|
865
|
+
this._availableInstanceIds.push( instanceId );
|
|
866
|
+
this._visibilityChanged = true;
|
|
867
|
+
|
|
868
|
+
return this;
|
|
869
|
+
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Repacks the sub geometries in BatchedMesh to remove any unused space remaining from
|
|
874
|
+
* previously deleted geometry, freeing up space to add new geometry.
|
|
875
|
+
*
|
|
876
|
+
* @return {BatchedMesh} A reference to this batched mesh.
|
|
877
|
+
*/
|
|
878
|
+
optimize() {
|
|
879
|
+
|
|
880
|
+
// track the next indices to copy data to
|
|
881
|
+
let nextVertexStart = 0;
|
|
882
|
+
let nextIndexStart = 0;
|
|
883
|
+
|
|
884
|
+
// Iterate over all geometry ranges in order sorted from earliest in the geometry buffer to latest
|
|
885
|
+
// in the geometry buffer. Because draw range objects can be reused there is no guarantee of their order.
|
|
886
|
+
const geometryInfoList = this._geometryInfo;
|
|
887
|
+
const indices = geometryInfoList
|
|
888
|
+
.map( ( e, i ) => i )
|
|
889
|
+
.sort( ( a, b ) => {
|
|
890
|
+
|
|
891
|
+
return geometryInfoList[ a ].vertexStart - geometryInfoList[ b ].vertexStart;
|
|
892
|
+
|
|
893
|
+
} );
|
|
894
|
+
|
|
895
|
+
const geometry = this.geometry;
|
|
896
|
+
for ( let i = 0, l = geometryInfoList.length; i < l; i ++ ) {
|
|
897
|
+
|
|
898
|
+
// if a geometry range is inactive then don't copy anything
|
|
899
|
+
const index = indices[ i ];
|
|
900
|
+
const geometryInfo = geometryInfoList[ index ];
|
|
901
|
+
if ( geometryInfo.active === false ) {
|
|
902
|
+
|
|
903
|
+
continue;
|
|
904
|
+
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// if a geometry contains an index buffer then shift it, as well
|
|
908
|
+
if ( geometry.index !== null ) {
|
|
909
|
+
|
|
910
|
+
if ( geometryInfo.indexStart !== nextIndexStart ) {
|
|
911
|
+
|
|
912
|
+
const { indexStart, vertexStart, reservedIndexCount } = geometryInfo;
|
|
913
|
+
const index = geometry.index;
|
|
914
|
+
const array = index.array;
|
|
915
|
+
|
|
916
|
+
// shift the index pointers based on how the vertex data will shift
|
|
917
|
+
// adjusting the index must happen first so the original vertex start value is available
|
|
918
|
+
const elementDelta = nextVertexStart - vertexStart;
|
|
919
|
+
for ( let j = indexStart; j < indexStart + reservedIndexCount; j ++ ) {
|
|
920
|
+
|
|
921
|
+
array[ j ] = array[ j ] + elementDelta;
|
|
922
|
+
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
index.array.copyWithin( nextIndexStart, indexStart, indexStart + reservedIndexCount );
|
|
926
|
+
index.addUpdateRange( nextIndexStart, reservedIndexCount );
|
|
927
|
+
index.needsUpdate = true;
|
|
928
|
+
|
|
929
|
+
geometryInfo.indexStart = nextIndexStart;
|
|
930
|
+
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
nextIndexStart += geometryInfo.reservedIndexCount;
|
|
934
|
+
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
// if a geometry needs to be moved then copy attribute data to overwrite unused space
|
|
938
|
+
if ( geometryInfo.vertexStart !== nextVertexStart ) {
|
|
939
|
+
|
|
940
|
+
const { vertexStart, reservedVertexCount } = geometryInfo;
|
|
941
|
+
const attributes = geometry.attributes;
|
|
942
|
+
for ( const key in attributes ) {
|
|
943
|
+
|
|
944
|
+
const attribute = attributes[ key ];
|
|
945
|
+
const { array, itemSize } = attribute;
|
|
946
|
+
array.copyWithin( nextVertexStart * itemSize, vertexStart * itemSize, ( vertexStart + reservedVertexCount ) * itemSize );
|
|
947
|
+
attribute.addUpdateRange( nextVertexStart * itemSize, reservedVertexCount * itemSize );
|
|
948
|
+
attribute.needsUpdate = true;
|
|
949
|
+
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
geometryInfo.vertexStart = nextVertexStart;
|
|
953
|
+
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
nextVertexStart += geometryInfo.reservedVertexCount;
|
|
957
|
+
geometryInfo.start = geometry.index ? geometryInfo.indexStart : geometryInfo.vertexStart;
|
|
958
|
+
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
this._nextIndexStart = nextIndexStart;
|
|
962
|
+
this._nextVertexStart = nextVertexStart;
|
|
963
|
+
this._visibilityChanged = true;
|
|
964
|
+
|
|
965
|
+
return this;
|
|
966
|
+
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Returns the bounding box for the given geometry.
|
|
971
|
+
*
|
|
972
|
+
* @param {number} geometryId - The ID of the geometry to return the bounding box for.
|
|
973
|
+
* @param {Box3} target - The target object that is used to store the method's result.
|
|
974
|
+
* @return {?Box3} The geometry's bounding box. Returns `null` if no geometry has been found for the given ID.
|
|
975
|
+
*/
|
|
976
|
+
getBoundingBoxAt( geometryId, target ) {
|
|
977
|
+
|
|
978
|
+
if ( geometryId >= this._geometryCount ) {
|
|
979
|
+
|
|
980
|
+
return null;
|
|
981
|
+
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// compute bounding box
|
|
985
|
+
const geometry = this.geometry;
|
|
986
|
+
const geometryInfo = this._geometryInfo[ geometryId ];
|
|
987
|
+
if ( geometryInfo.boundingBox === null ) {
|
|
988
|
+
|
|
989
|
+
const box = new Box3();
|
|
990
|
+
const index = geometry.index;
|
|
991
|
+
const position = geometry.attributes.position;
|
|
992
|
+
for ( let i = geometryInfo.start, l = geometryInfo.start + geometryInfo.count; i < l; i ++ ) {
|
|
993
|
+
|
|
994
|
+
let iv = i;
|
|
995
|
+
if ( index ) {
|
|
996
|
+
|
|
997
|
+
iv = index.getX( iv );
|
|
998
|
+
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
box.expandByPoint( _vector.fromBufferAttribute( position, iv ) );
|
|
1002
|
+
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
geometryInfo.boundingBox = box;
|
|
1006
|
+
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
target.copy( geometryInfo.boundingBox );
|
|
1010
|
+
return target;
|
|
1011
|
+
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Returns the bounding sphere for the given geometry.
|
|
1016
|
+
*
|
|
1017
|
+
* @param {number} geometryId - The ID of the geometry to return the bounding sphere for.
|
|
1018
|
+
* @param {Sphere} target - The target object that is used to store the method's result.
|
|
1019
|
+
* @return {?Sphere} The geometry's bounding sphere. Returns `null` if no geometry has been found for the given ID.
|
|
1020
|
+
*/
|
|
1021
|
+
getBoundingSphereAt( geometryId, target ) {
|
|
1022
|
+
|
|
1023
|
+
if ( geometryId >= this._geometryCount ) {
|
|
1024
|
+
|
|
1025
|
+
return null;
|
|
1026
|
+
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
// compute bounding sphere
|
|
1030
|
+
const geometry = this.geometry;
|
|
1031
|
+
const geometryInfo = this._geometryInfo[ geometryId ];
|
|
1032
|
+
if ( geometryInfo.boundingSphere === null ) {
|
|
1033
|
+
|
|
1034
|
+
const sphere = new Sphere();
|
|
1035
|
+
this.getBoundingBoxAt( geometryId, _box );
|
|
1036
|
+
_box.getCenter( sphere.center );
|
|
1037
|
+
|
|
1038
|
+
const index = geometry.index;
|
|
1039
|
+
const position = geometry.attributes.position;
|
|
1040
|
+
|
|
1041
|
+
let maxRadiusSq = 0;
|
|
1042
|
+
for ( let i = geometryInfo.start, l = geometryInfo.start + geometryInfo.count; i < l; i ++ ) {
|
|
1043
|
+
|
|
1044
|
+
let iv = i;
|
|
1045
|
+
if ( index ) {
|
|
1046
|
+
|
|
1047
|
+
iv = index.getX( iv );
|
|
1048
|
+
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
_vector.fromBufferAttribute( position, iv );
|
|
1052
|
+
maxRadiusSq = Math.max( maxRadiusSq, sphere.center.distanceToSquared( _vector ) );
|
|
1053
|
+
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
sphere.radius = Math.sqrt( maxRadiusSq );
|
|
1057
|
+
geometryInfo.boundingSphere = sphere;
|
|
1058
|
+
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
target.copy( geometryInfo.boundingSphere );
|
|
1062
|
+
return target;
|
|
1063
|
+
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Sets the given local transformation matrix to the defined instance.
|
|
1068
|
+
* Negatively scaled matrices are not supported.
|
|
1069
|
+
*
|
|
1070
|
+
* @param {number} instanceId - The ID of an instance to set the matrix of.
|
|
1071
|
+
* @param {Matrix4} matrix - A 4x4 matrix representing the local transformation of a single instance.
|
|
1072
|
+
* @return {BatchedMesh} A reference to this batched mesh.
|
|
1073
|
+
*/
|
|
1074
|
+
setMatrixAt( instanceId, matrix ) {
|
|
1075
|
+
|
|
1076
|
+
this.validateInstanceId( instanceId );
|
|
1077
|
+
|
|
1078
|
+
const matricesTexture = this._matricesTexture;
|
|
1079
|
+
const matricesArray = this._matricesTexture.image.data;
|
|
1080
|
+
matrix.toArray( matricesArray, instanceId * 16 );
|
|
1081
|
+
matricesTexture.needsUpdate = true;
|
|
1082
|
+
|
|
1083
|
+
return this;
|
|
1084
|
+
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* Returns the local transformation matrix of the defined instance.
|
|
1089
|
+
*
|
|
1090
|
+
* @param {number} instanceId - The ID of an instance to get the matrix of.
|
|
1091
|
+
* @param {Matrix4} matrix - The target object that is used to store the method's result.
|
|
1092
|
+
* @return {Matrix4} The instance's local transformation matrix.
|
|
1093
|
+
*/
|
|
1094
|
+
getMatrixAt( instanceId, matrix ) {
|
|
1095
|
+
|
|
1096
|
+
this.validateInstanceId( instanceId );
|
|
1097
|
+
return matrix.fromArray( this._matricesTexture.image.data, instanceId * 16 );
|
|
1098
|
+
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* Sets the given color to the defined instance.
|
|
1103
|
+
*
|
|
1104
|
+
* @param {number} instanceId - The ID of an instance to set the color of.
|
|
1105
|
+
* @param {Color|Vector4} color - The color to set the instance to. Use a `Vector4` to also define alpha.
|
|
1106
|
+
* @return {BatchedMesh} A reference to this batched mesh.
|
|
1107
|
+
*/
|
|
1108
|
+
setColorAt( instanceId, color ) {
|
|
1109
|
+
|
|
1110
|
+
this.validateInstanceId( instanceId );
|
|
1111
|
+
|
|
1112
|
+
if ( this._colorsTexture === null ) {
|
|
1113
|
+
|
|
1114
|
+
this._initColorsTexture();
|
|
1115
|
+
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
color.toArray( this._colorsTexture.image.data, instanceId * 4 );
|
|
1119
|
+
this._colorsTexture.needsUpdate = true;
|
|
1120
|
+
|
|
1121
|
+
return this;
|
|
1122
|
+
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Returns the color of the defined instance.
|
|
1127
|
+
*
|
|
1128
|
+
* @param {number} instanceId - The ID of an instance to get the color of.
|
|
1129
|
+
* @param {Color|Vector4} color - The target object that is used to store the method's result.
|
|
1130
|
+
* @return {Color|Vector4} The instance's color. Use a `Vector4` to also retrieve alpha.
|
|
1131
|
+
*/
|
|
1132
|
+
getColorAt( instanceId, color ) {
|
|
1133
|
+
|
|
1134
|
+
this.validateInstanceId( instanceId );
|
|
1135
|
+
if ( this._colorsTexture === null ) {
|
|
1136
|
+
|
|
1137
|
+
if ( color.isVector4 ) {
|
|
1138
|
+
|
|
1139
|
+
return color.set( 1, 1, 1, 1 );
|
|
1140
|
+
|
|
1141
|
+
} else {
|
|
1142
|
+
|
|
1143
|
+
return color.setRGB( 1, 1, 1 );
|
|
1144
|
+
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
} else {
|
|
1148
|
+
|
|
1149
|
+
return color.fromArray( this._colorsTexture.image.data, instanceId * 4 );
|
|
1150
|
+
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* Sets the visibility of the instance.
|
|
1157
|
+
*
|
|
1158
|
+
* @param {number} instanceId - The id of the instance to set the visibility of.
|
|
1159
|
+
* @param {boolean} visible - Whether the instance is visible or not.
|
|
1160
|
+
* @return {BatchedMesh} A reference to this batched mesh.
|
|
1161
|
+
*/
|
|
1162
|
+
setVisibleAt( instanceId, visible ) {
|
|
1163
|
+
|
|
1164
|
+
this.validateInstanceId( instanceId );
|
|
1165
|
+
|
|
1166
|
+
if ( this._instanceInfo[ instanceId ].visible === visible ) {
|
|
1167
|
+
|
|
1168
|
+
return this;
|
|
1169
|
+
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
this._instanceInfo[ instanceId ].visible = visible;
|
|
1173
|
+
this._visibilityChanged = true;
|
|
1174
|
+
|
|
1175
|
+
return this;
|
|
1176
|
+
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* Returns the visibility state of the defined instance.
|
|
1181
|
+
*
|
|
1182
|
+
* @param {number} instanceId - The ID of an instance to get the visibility state of.
|
|
1183
|
+
* @return {boolean} Whether the instance is visible or not.
|
|
1184
|
+
*/
|
|
1185
|
+
getVisibleAt( instanceId ) {
|
|
1186
|
+
|
|
1187
|
+
this.validateInstanceId( instanceId );
|
|
1188
|
+
|
|
1189
|
+
return this._instanceInfo[ instanceId ].visible;
|
|
1190
|
+
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Sets the geometry ID of the instance at the given index.
|
|
1195
|
+
*
|
|
1196
|
+
* @param {number} instanceId - The ID of the instance to set the geometry ID of.
|
|
1197
|
+
* @param {number} geometryId - The geometry ID to be use by the instance.
|
|
1198
|
+
* @return {BatchedMesh} A reference to this batched mesh.
|
|
1199
|
+
*/
|
|
1200
|
+
setGeometryIdAt( instanceId, geometryId ) {
|
|
1201
|
+
|
|
1202
|
+
this.validateInstanceId( instanceId );
|
|
1203
|
+
this.validateGeometryId( geometryId );
|
|
1204
|
+
|
|
1205
|
+
this._instanceInfo[ instanceId ].geometryIndex = geometryId;
|
|
1206
|
+
|
|
1207
|
+
return this;
|
|
1208
|
+
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* Returns the geometry ID of the defined instance.
|
|
1213
|
+
*
|
|
1214
|
+
* @param {number} instanceId - The ID of an instance to get the geometry ID of.
|
|
1215
|
+
* @return {number} The instance's geometry ID.
|
|
1216
|
+
*/
|
|
1217
|
+
getGeometryIdAt( instanceId ) {
|
|
1218
|
+
|
|
1219
|
+
this.validateInstanceId( instanceId );
|
|
1220
|
+
|
|
1221
|
+
return this._instanceInfo[ instanceId ].geometryIndex;
|
|
1222
|
+
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* Get the range representing the subset of triangles related to the attached geometry,
|
|
1227
|
+
* indicating the starting offset and count, or `null` if invalid.
|
|
1228
|
+
*
|
|
1229
|
+
* @param {number} geometryId - The id of the geometry to get the range of.
|
|
1230
|
+
* @param {Object} [target] - The target object that is used to store the method's result.
|
|
1231
|
+
* @return {{
|
|
1232
|
+
* vertexStart:number,vertexCount:number,reservedVertexCount:number,
|
|
1233
|
+
* indexStart:number,indexCount:number,reservedIndexCount:number,
|
|
1234
|
+
* start:number,count:number
|
|
1235
|
+
* }} The result object with range data.
|
|
1236
|
+
*/
|
|
1237
|
+
getGeometryRangeAt( geometryId, target = {} ) {
|
|
1238
|
+
|
|
1239
|
+
this.validateGeometryId( geometryId );
|
|
1240
|
+
|
|
1241
|
+
const geometryInfo = this._geometryInfo[ geometryId ];
|
|
1242
|
+
target.vertexStart = geometryInfo.vertexStart;
|
|
1243
|
+
target.vertexCount = geometryInfo.vertexCount;
|
|
1244
|
+
target.reservedVertexCount = geometryInfo.reservedVertexCount;
|
|
1245
|
+
|
|
1246
|
+
target.indexStart = geometryInfo.indexStart;
|
|
1247
|
+
target.indexCount = geometryInfo.indexCount;
|
|
1248
|
+
target.reservedIndexCount = geometryInfo.reservedIndexCount;
|
|
1249
|
+
|
|
1250
|
+
target.start = geometryInfo.start;
|
|
1251
|
+
target.count = geometryInfo.count;
|
|
1252
|
+
|
|
1253
|
+
return target;
|
|
1254
|
+
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* Resizes the necessary buffers to support the provided number of instances.
|
|
1259
|
+
* If the provided arguments shrink the number of instances but there are not enough
|
|
1260
|
+
* unused Ids at the end of the list then an error is thrown.
|
|
1261
|
+
*
|
|
1262
|
+
* @param {number} maxInstanceCount - The max number of individual instances that can be added and rendered by the batch.
|
|
1263
|
+
*/
|
|
1264
|
+
setInstanceCount( maxInstanceCount ) {
|
|
1265
|
+
|
|
1266
|
+
// shrink the available instances as much as possible
|
|
1267
|
+
const availableInstanceIds = this._availableInstanceIds;
|
|
1268
|
+
const instanceInfo = this._instanceInfo;
|
|
1269
|
+
availableInstanceIds.sort( ascIdSort );
|
|
1270
|
+
while ( availableInstanceIds[ availableInstanceIds.length - 1 ] === instanceInfo.length - 1 ) {
|
|
1271
|
+
|
|
1272
|
+
instanceInfo.pop();
|
|
1273
|
+
availableInstanceIds.pop();
|
|
1274
|
+
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
// throw an error if it can't be shrunk to the desired size
|
|
1278
|
+
if ( maxInstanceCount < instanceInfo.length ) {
|
|
1279
|
+
|
|
1280
|
+
throw new Error( `BatchedMesh: Instance ids outside the range ${ maxInstanceCount } are being used. Cannot shrink instance count.` );
|
|
1281
|
+
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
// copy the multi draw counts
|
|
1285
|
+
const multiDrawCounts = new Int32Array( maxInstanceCount );
|
|
1286
|
+
const multiDrawStarts = new Int32Array( maxInstanceCount );
|
|
1287
|
+
copyArrayContents( this._multiDrawCounts, multiDrawCounts );
|
|
1288
|
+
copyArrayContents( this._multiDrawStarts, multiDrawStarts );
|
|
1289
|
+
|
|
1290
|
+
this._multiDrawCounts = multiDrawCounts;
|
|
1291
|
+
this._multiDrawStarts = multiDrawStarts;
|
|
1292
|
+
this._maxInstanceCount = maxInstanceCount;
|
|
1293
|
+
|
|
1294
|
+
// update texture data for instance sampling
|
|
1295
|
+
const indirectTexture = this._indirectTexture;
|
|
1296
|
+
const matricesTexture = this._matricesTexture;
|
|
1297
|
+
const colorsTexture = this._colorsTexture;
|
|
1298
|
+
|
|
1299
|
+
indirectTexture.dispose();
|
|
1300
|
+
this._initIndirectTexture();
|
|
1301
|
+
copyArrayContents( indirectTexture.image.data, this._indirectTexture.image.data );
|
|
1302
|
+
|
|
1303
|
+
matricesTexture.dispose();
|
|
1304
|
+
this._initMatricesTexture();
|
|
1305
|
+
copyArrayContents( matricesTexture.image.data, this._matricesTexture.image.data );
|
|
1306
|
+
|
|
1307
|
+
if ( colorsTexture ) {
|
|
1308
|
+
|
|
1309
|
+
colorsTexture.dispose();
|
|
1310
|
+
this._initColorsTexture();
|
|
1311
|
+
copyArrayContents( colorsTexture.image.data, this._colorsTexture.image.data );
|
|
1312
|
+
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Resizes the available space in the batch's vertex and index buffer attributes to the provided sizes.
|
|
1319
|
+
* If the provided arguments shrink the geometry buffers but there is not enough unused space at the
|
|
1320
|
+
* end of the geometry attributes then an error is thrown.
|
|
1321
|
+
*
|
|
1322
|
+
* @param {number} maxVertexCount - The maximum number of vertices to be used by all unique geometries to resize to.
|
|
1323
|
+
* @param {number} maxIndexCount - The maximum number of indices to be used by all unique geometries to resize to.
|
|
1324
|
+
*/
|
|
1325
|
+
setGeometrySize( maxVertexCount, maxIndexCount ) {
|
|
1326
|
+
|
|
1327
|
+
// Check if we can shrink to the requested vertex attribute size
|
|
1328
|
+
const validRanges = [ ...this._geometryInfo ].filter( info => info.active );
|
|
1329
|
+
const requiredVertexLength = Math.max( ...validRanges.map( range => range.vertexStart + range.reservedVertexCount ) );
|
|
1330
|
+
if ( requiredVertexLength > maxVertexCount ) {
|
|
1331
|
+
|
|
1332
|
+
throw new Error( `BatchedMesh: Geometry vertex values are being used outside the range ${ maxIndexCount }. Cannot shrink further.` );
|
|
1333
|
+
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
// Check if we can shrink to the requested index attribute size
|
|
1337
|
+
if ( this.geometry.index ) {
|
|
1338
|
+
|
|
1339
|
+
const requiredIndexLength = Math.max( ...validRanges.map( range => range.indexStart + range.reservedIndexCount ) );
|
|
1340
|
+
if ( requiredIndexLength > maxIndexCount ) {
|
|
1341
|
+
|
|
1342
|
+
throw new Error( `BatchedMesh: Geometry index values are being used outside the range ${ maxIndexCount }. Cannot shrink further.` );
|
|
1343
|
+
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
//
|
|
1349
|
+
|
|
1350
|
+
// dispose of the previous geometry
|
|
1351
|
+
const oldGeometry = this.geometry;
|
|
1352
|
+
oldGeometry.dispose();
|
|
1353
|
+
|
|
1354
|
+
// recreate the geometry needed based on the previous variant
|
|
1355
|
+
this._maxVertexCount = maxVertexCount;
|
|
1356
|
+
this._maxIndexCount = maxIndexCount;
|
|
1357
|
+
|
|
1358
|
+
if ( this._geometryInitialized ) {
|
|
1359
|
+
|
|
1360
|
+
this._geometryInitialized = false;
|
|
1361
|
+
this.geometry = new BufferGeometry();
|
|
1362
|
+
this._initializeGeometry( oldGeometry );
|
|
1363
|
+
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
// copy data from the previous geometry
|
|
1367
|
+
const geometry = this.geometry;
|
|
1368
|
+
if ( oldGeometry.index ) {
|
|
1369
|
+
|
|
1370
|
+
copyArrayContents( oldGeometry.index.array, geometry.index.array );
|
|
1371
|
+
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
for ( const key in oldGeometry.attributes ) {
|
|
1375
|
+
|
|
1376
|
+
copyArrayContents( oldGeometry.attributes[ key ].array, geometry.attributes[ key ].array );
|
|
1377
|
+
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
raycast( raycaster, intersects ) {
|
|
1383
|
+
|
|
1384
|
+
const instanceInfo = this._instanceInfo;
|
|
1385
|
+
const geometryInfoList = this._geometryInfo;
|
|
1386
|
+
const matrixWorld = this.matrixWorld;
|
|
1387
|
+
const batchGeometry = this.geometry;
|
|
1388
|
+
|
|
1389
|
+
// iterate over each geometry
|
|
1390
|
+
_mesh.material = this.material;
|
|
1391
|
+
_mesh.geometry.index = batchGeometry.index;
|
|
1392
|
+
_mesh.geometry.attributes = batchGeometry.attributes;
|
|
1393
|
+
if ( _mesh.geometry.boundingBox === null ) {
|
|
1394
|
+
|
|
1395
|
+
_mesh.geometry.boundingBox = new Box3();
|
|
1396
|
+
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
if ( _mesh.geometry.boundingSphere === null ) {
|
|
1400
|
+
|
|
1401
|
+
_mesh.geometry.boundingSphere = new Sphere();
|
|
1402
|
+
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
|
|
1406
|
+
|
|
1407
|
+
if ( ! instanceInfo[ i ].visible || ! instanceInfo[ i ].active ) {
|
|
1408
|
+
|
|
1409
|
+
continue;
|
|
1410
|
+
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
const geometryId = instanceInfo[ i ].geometryIndex;
|
|
1414
|
+
const geometryInfo = geometryInfoList[ geometryId ];
|
|
1415
|
+
_mesh.geometry.setDrawRange( geometryInfo.start, geometryInfo.count );
|
|
1416
|
+
|
|
1417
|
+
// get the intersects
|
|
1418
|
+
this.getMatrixAt( i, _mesh.matrixWorld ).premultiply( matrixWorld );
|
|
1419
|
+
this.getBoundingBoxAt( geometryId, _mesh.geometry.boundingBox );
|
|
1420
|
+
this.getBoundingSphereAt( geometryId, _mesh.geometry.boundingSphere );
|
|
1421
|
+
_mesh.raycast( raycaster, _batchIntersects );
|
|
1422
|
+
|
|
1423
|
+
// add batch id to the intersects
|
|
1424
|
+
for ( let j = 0, l = _batchIntersects.length; j < l; j ++ ) {
|
|
1425
|
+
|
|
1426
|
+
const intersect = _batchIntersects[ j ];
|
|
1427
|
+
intersect.object = this;
|
|
1428
|
+
intersect.batchId = i;
|
|
1429
|
+
intersects.push( intersect );
|
|
1430
|
+
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
_batchIntersects.length = 0;
|
|
1434
|
+
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
_mesh.material = null;
|
|
1438
|
+
_mesh.geometry.index = null;
|
|
1439
|
+
_mesh.geometry.attributes = {};
|
|
1440
|
+
_mesh.geometry.setDrawRange( 0, Infinity );
|
|
1441
|
+
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
copy( source ) {
|
|
1445
|
+
|
|
1446
|
+
super.copy( source );
|
|
1447
|
+
|
|
1448
|
+
this.geometry = source.geometry.clone();
|
|
1449
|
+
this.perObjectFrustumCulled = source.perObjectFrustumCulled;
|
|
1450
|
+
this.sortObjects = source.sortObjects;
|
|
1451
|
+
this.boundingBox = source.boundingBox !== null ? source.boundingBox.clone() : null;
|
|
1452
|
+
this.boundingSphere = source.boundingSphere !== null ? source.boundingSphere.clone() : null;
|
|
1453
|
+
|
|
1454
|
+
this._geometryInfo = source._geometryInfo.map( info => ( {
|
|
1455
|
+
...info,
|
|
1456
|
+
|
|
1457
|
+
boundingBox: info.boundingBox !== null ? info.boundingBox.clone() : null,
|
|
1458
|
+
boundingSphere: info.boundingSphere !== null ? info.boundingSphere.clone() : null,
|
|
1459
|
+
} ) );
|
|
1460
|
+
this._instanceInfo = source._instanceInfo.map( info => ( { ...info } ) );
|
|
1461
|
+
|
|
1462
|
+
this._availableInstanceIds = source._availableInstanceIds.slice();
|
|
1463
|
+
this._availableGeometryIds = source._availableGeometryIds.slice();
|
|
1464
|
+
|
|
1465
|
+
this._nextIndexStart = source._nextIndexStart;
|
|
1466
|
+
this._nextVertexStart = source._nextVertexStart;
|
|
1467
|
+
this._geometryCount = source._geometryCount;
|
|
1468
|
+
|
|
1469
|
+
this._maxInstanceCount = source._maxInstanceCount;
|
|
1470
|
+
this._maxVertexCount = source._maxVertexCount;
|
|
1471
|
+
this._maxIndexCount = source._maxIndexCount;
|
|
1472
|
+
|
|
1473
|
+
this._geometryInitialized = source._geometryInitialized;
|
|
1474
|
+
this._multiDrawCounts = source._multiDrawCounts.slice();
|
|
1475
|
+
this._multiDrawStarts = source._multiDrawStarts.slice();
|
|
1476
|
+
|
|
1477
|
+
this._indirectTexture = source._indirectTexture.clone();
|
|
1478
|
+
this._indirectTexture.image.data = this._indirectTexture.image.data.slice();
|
|
1479
|
+
|
|
1480
|
+
this._matricesTexture = source._matricesTexture.clone();
|
|
1481
|
+
this._matricesTexture.image.data = this._matricesTexture.image.data.slice();
|
|
1482
|
+
|
|
1483
|
+
if ( this._colorsTexture !== null ) {
|
|
1484
|
+
|
|
1485
|
+
this._colorsTexture = source._colorsTexture.clone();
|
|
1486
|
+
this._colorsTexture.image.data = this._colorsTexture.image.data.slice();
|
|
1487
|
+
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
return this;
|
|
1491
|
+
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* Frees the GPU-related resources allocated by this instance. Call this
|
|
1496
|
+
* method whenever this instance is no longer used in your app.
|
|
1497
|
+
*/
|
|
1498
|
+
dispose() {
|
|
1499
|
+
|
|
1500
|
+
// Assuming the geometry is not shared with other meshes
|
|
1501
|
+
this.geometry.dispose();
|
|
1502
|
+
|
|
1503
|
+
this._matricesTexture.dispose();
|
|
1504
|
+
this._matricesTexture = null;
|
|
1505
|
+
|
|
1506
|
+
this._indirectTexture.dispose();
|
|
1507
|
+
this._indirectTexture = null;
|
|
1508
|
+
|
|
1509
|
+
if ( this._colorsTexture !== null ) {
|
|
1510
|
+
|
|
1511
|
+
this._colorsTexture.dispose();
|
|
1512
|
+
this._colorsTexture = null;
|
|
1513
|
+
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
onBeforeRender( renderer, scene, camera, geometry, material/*, _group*/ ) {
|
|
1519
|
+
|
|
1520
|
+
// if visibility has not changed and frustum culling and object sorting is not required
|
|
1521
|
+
// then skip iterating over all items
|
|
1522
|
+
if ( ! this._visibilityChanged && ! this.perObjectFrustumCulled && ! this.sortObjects ) {
|
|
1523
|
+
|
|
1524
|
+
return;
|
|
1525
|
+
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
// the indexed version of the multi draw function requires specifying the start
|
|
1529
|
+
// offset in bytes.
|
|
1530
|
+
const index = geometry.getIndex();
|
|
1531
|
+
let bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
// the "wireframe" attribute implicitly creates a line attribute in the renderer, which is double
|
|
1535
|
+
// the vertices to draw (3 lines per triangle) so we multiply the draw counts / starts and make
|
|
1536
|
+
// assumptions about the index buffer byte size.
|
|
1537
|
+
let multiDrawMultiplier = 1;
|
|
1538
|
+
if ( material.wireframe ) {
|
|
1539
|
+
|
|
1540
|
+
multiDrawMultiplier = 2;
|
|
1541
|
+
bytesPerElement = geometry.attributes.position.count > 65535 ? 4 : 2;
|
|
1542
|
+
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
const instanceInfo = this._instanceInfo;
|
|
1546
|
+
const multiDrawStarts = this._multiDrawStarts;
|
|
1547
|
+
const multiDrawCounts = this._multiDrawCounts;
|
|
1548
|
+
const geometryInfoList = this._geometryInfo;
|
|
1549
|
+
const perObjectFrustumCulled = this.perObjectFrustumCulled;
|
|
1550
|
+
const indirectTexture = this._indirectTexture;
|
|
1551
|
+
const indirectArray = indirectTexture.image.data;
|
|
1552
|
+
|
|
1553
|
+
const frustum = camera.isArrayCamera ? _frustumArray : _frustum;
|
|
1554
|
+
// prepare the frustum in the local frame
|
|
1555
|
+
if ( perObjectFrustumCulled && ! camera.isArrayCamera ) {
|
|
1556
|
+
|
|
1557
|
+
_matrix
|
|
1558
|
+
.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse )
|
|
1559
|
+
.multiply( this.matrixWorld );
|
|
1560
|
+
|
|
1561
|
+
_frustum.setFromProjectionMatrix(
|
|
1562
|
+
_matrix,
|
|
1563
|
+
camera.coordinateSystem,
|
|
1564
|
+
camera.reversedDepth
|
|
1565
|
+
);
|
|
1566
|
+
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
let multiDrawCount = 0;
|
|
1570
|
+
if ( this.sortObjects ) {
|
|
1571
|
+
|
|
1572
|
+
// get the camera position in the local frame
|
|
1573
|
+
_matrix.copy( this.matrixWorld ).invert();
|
|
1574
|
+
_vector.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _matrix );
|
|
1575
|
+
_forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _matrix );
|
|
1576
|
+
|
|
1577
|
+
for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
|
|
1578
|
+
|
|
1579
|
+
if ( instanceInfo[ i ].visible && instanceInfo[ i ].active ) {
|
|
1580
|
+
|
|
1581
|
+
const geometryId = instanceInfo[ i ].geometryIndex;
|
|
1582
|
+
|
|
1583
|
+
// get the bounds in world space
|
|
1584
|
+
this.getMatrixAt( i, _matrix );
|
|
1585
|
+
this.getBoundingSphereAt( geometryId, _sphere ).applyMatrix4( _matrix );
|
|
1586
|
+
|
|
1587
|
+
// determine whether the batched geometry is within the frustum
|
|
1588
|
+
let culled = false;
|
|
1589
|
+
if ( perObjectFrustumCulled ) {
|
|
1590
|
+
|
|
1591
|
+
culled = ! frustum.intersectsSphere( _sphere, camera );
|
|
1592
|
+
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
if ( ! culled ) {
|
|
1596
|
+
|
|
1597
|
+
// get the distance from camera used for sorting
|
|
1598
|
+
const geometryInfo = geometryInfoList[ geometryId ];
|
|
1599
|
+
const z = _temp.subVectors( _sphere.center, _vector ).dot( _forward );
|
|
1600
|
+
_renderList.push( geometryInfo.start, geometryInfo.count, z, i );
|
|
1601
|
+
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
// Sort the draw ranges and prep for rendering
|
|
1609
|
+
const list = _renderList.list;
|
|
1610
|
+
const customSort = this.customSort;
|
|
1611
|
+
if ( customSort === null ) {
|
|
1612
|
+
|
|
1613
|
+
list.sort( material.transparent ? sortTransparent : sortOpaque );
|
|
1614
|
+
|
|
1615
|
+
} else {
|
|
1616
|
+
|
|
1617
|
+
customSort.call( this, list, camera );
|
|
1618
|
+
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
for ( let i = 0, l = list.length; i < l; i ++ ) {
|
|
1622
|
+
|
|
1623
|
+
const item = list[ i ];
|
|
1624
|
+
multiDrawStarts[ multiDrawCount ] = item.start * bytesPerElement * multiDrawMultiplier;
|
|
1625
|
+
multiDrawCounts[ multiDrawCount ] = item.count * multiDrawMultiplier;
|
|
1626
|
+
indirectArray[ multiDrawCount ] = item.index;
|
|
1627
|
+
multiDrawCount ++;
|
|
1628
|
+
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
_renderList.reset();
|
|
1632
|
+
|
|
1633
|
+
} else {
|
|
1634
|
+
|
|
1635
|
+
for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
|
|
1636
|
+
|
|
1637
|
+
if ( instanceInfo[ i ].visible && instanceInfo[ i ].active ) {
|
|
1638
|
+
|
|
1639
|
+
const geometryId = instanceInfo[ i ].geometryIndex;
|
|
1640
|
+
|
|
1641
|
+
// determine whether the batched geometry is within the frustum
|
|
1642
|
+
let culled = false;
|
|
1643
|
+
if ( perObjectFrustumCulled ) {
|
|
1644
|
+
|
|
1645
|
+
// get the bounds in world space
|
|
1646
|
+
this.getMatrixAt( i, _matrix );
|
|
1647
|
+
this.getBoundingSphereAt( geometryId, _sphere ).applyMatrix4( _matrix );
|
|
1648
|
+
culled = ! frustum.intersectsSphere( _sphere, camera );
|
|
1649
|
+
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
if ( ! culled ) {
|
|
1653
|
+
|
|
1654
|
+
const geometryInfo = geometryInfoList[ geometryId ];
|
|
1655
|
+
multiDrawStarts[ multiDrawCount ] = geometryInfo.start * bytesPerElement * multiDrawMultiplier;
|
|
1656
|
+
multiDrawCounts[ multiDrawCount ] = geometryInfo.count * multiDrawMultiplier;
|
|
1657
|
+
indirectArray[ multiDrawCount ] = i;
|
|
1658
|
+
multiDrawCount ++;
|
|
1659
|
+
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
indirectTexture.needsUpdate = true;
|
|
1669
|
+
this._multiDrawCount = multiDrawCount;
|
|
1670
|
+
this._visibilityChanged = false;
|
|
1671
|
+
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial/* , group */ ) {
|
|
1675
|
+
|
|
1676
|
+
this.onBeforeRender( renderer, null, shadowCamera, geometry, depthMaterial );
|
|
1677
|
+
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
export { BatchedMesh };
|