@playdrop/playdrop-cli 0.3.5-build.1 → 0.3.8-build.2
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/config/client-meta.json +5 -5
- package/dist/apps/upload.js +1 -0
- package/dist/catalogue.d.ts +7 -0
- package/dist/catalogue.js +70 -33
- package/dist/commands/create.js +129 -70
- package/dist/commands/createRemixContent.d.ts +3 -0
- package/dist/commands/createRemixContent.js +310 -0
- package/dist/commands/generation.d.ts +0 -1
- package/dist/commands/generation.js +0 -18
- package/dist/commands/init.js +3 -3
- package/dist/commands/upload.js +11 -0
- package/dist/index.js +17 -4
- package/node_modules/@playdrop/ai-client/dist/index.d.ts +1 -1
- package/node_modules/@playdrop/ai-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/ai-client/dist/index.js +1 -1
- package/node_modules/@playdrop/api-client/dist/client.d.ts +8 -2
- package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/client.js +2 -0
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts +3 -2
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/apps.js +24 -2
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts +3 -1
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.js +19 -1
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts +3 -1
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/assets.js +19 -1
- package/node_modules/@playdrop/api-client/dist/index.d.ts +3 -0
- package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/index.js +9 -0
- package/node_modules/@playdrop/config/client-meta.json +5 -5
- package/node_modules/@playdrop/types/dist/api.d.ts +22 -1
- package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts +1 -0
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset.d.ts +27 -0
- package/node_modules/@playdrop/types/dist/asset.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/graph.d.ts +21 -0
- package/node_modules/@playdrop/types/dist/graph.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/graph.js +66 -0
- package/node_modules/@playdrop/types/dist/version.d.ts +1 -0
- package/node_modules/@playdrop/types/dist/version.d.ts.map +1 -1
- package/node_modules/@playdrop/vox-three/dist/src/index.d.ts +1 -0
- package/node_modules/@playdrop/vox-three/dist/src/index.js +18 -0
- package/node_modules/@playdrop/vox-three/dist/src/index.js.map +1 -0
- package/node_modules/@playdrop/vox-three/dist/src/vox.d.ts +25 -0
- package/node_modules/@playdrop/vox-three/dist/src/vox.js +425 -0
- package/node_modules/@playdrop/vox-three/dist/src/vox.js.map +1 -0
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.d.ts +1 -0
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js +79 -0
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js.map +1 -0
- package/node_modules/@playdrop/vox-three/package.json +25 -0
- package/node_modules/three/LICENSE +1 -1
- package/node_modules/three/README.md +7 -7
- package/node_modules/three/build/three.cjs +49655 -25499
- package/node_modules/three/build/three.core.js +58952 -0
- package/node_modules/three/build/three.core.min.js +6 -0
- package/node_modules/three/build/three.module.js +11162 -45962
- package/node_modules/three/build/three.module.min.js +2 -2
- package/node_modules/three/build/three.tsl.js +640 -0
- package/node_modules/three/build/three.tsl.min.js +6 -0
- package/node_modules/three/build/three.webgpu.js +79685 -0
- package/node_modules/three/build/three.webgpu.min.js +6 -0
- package/node_modules/three/build/three.webgpu.nodes.js +79456 -0
- package/node_modules/three/build/three.webgpu.nodes.min.js +6 -0
- package/node_modules/three/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/node_modules/three/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/node_modules/three/examples/jsm/Addons.js +8 -18
- package/node_modules/three/examples/jsm/animation/AnimationClipCreator.js +59 -7
- package/node_modules/three/examples/jsm/animation/CCDIKSolver.js +154 -45
- package/node_modules/three/examples/jsm/capabilities/WebGL.js +28 -23
- package/node_modules/three/examples/jsm/capabilities/WebGPU.js +19 -17
- package/node_modules/three/examples/jsm/controls/ArcballControls.js +636 -324
- package/node_modules/three/examples/jsm/controls/DragControls.js +332 -101
- package/node_modules/three/examples/jsm/controls/FirstPersonControls.js +291 -169
- package/node_modules/three/examples/jsm/controls/FlyControls.js +245 -191
- package/node_modules/three/examples/jsm/controls/MapControls.js +43 -9
- package/node_modules/three/examples/jsm/controls/OrbitControls.js +1156 -802
- package/node_modules/three/examples/jsm/controls/PointerLockControls.js +137 -35
- package/node_modules/three/examples/jsm/controls/TrackballControls.js +629 -456
- package/node_modules/three/examples/jsm/controls/TransformControls.js +442 -97
- package/node_modules/three/examples/jsm/csm/CSM.js +230 -17
- package/node_modules/three/examples/jsm/csm/CSMFrustum.js +61 -4
- package/node_modules/three/examples/jsm/csm/CSMHelper.js +50 -0
- package/node_modules/three/examples/jsm/csm/CSMShader.js +17 -5
- package/node_modules/three/examples/jsm/csm/CSMShadowNode.js +599 -0
- package/node_modules/three/examples/jsm/curves/CurveExtras.js +303 -31
- package/node_modules/three/examples/jsm/curves/NURBSCurve.js +91 -16
- package/node_modules/three/examples/jsm/curves/NURBSSurface.js +52 -6
- package/node_modules/three/examples/jsm/curves/NURBSUtils.js +102 -112
- package/node_modules/three/examples/jsm/curves/NURBSVolume.js +24 -4
- package/node_modules/three/examples/jsm/effects/AnaglyphEffect.js +39 -14
- package/node_modules/three/examples/jsm/effects/AsciiEffect.js +69 -22
- package/node_modules/three/examples/jsm/effects/OutlineEffect.js +61 -111
- package/node_modules/three/examples/jsm/effects/ParallaxBarrierEffect.js +48 -12
- package/node_modules/three/examples/jsm/effects/StereoEffect.js +37 -1
- package/node_modules/three/examples/jsm/environments/DebugEnvironment.js +50 -0
- package/node_modules/three/examples/jsm/environments/RoomEnvironment.js +82 -48
- package/node_modules/three/examples/jsm/exporters/DRACOExporter.js +59 -15
- package/node_modules/three/examples/jsm/exporters/EXRExporter.js +58 -19
- package/node_modules/three/examples/jsm/exporters/GLTFExporter.js +460 -174
- package/node_modules/three/examples/jsm/exporters/KTX2Exporter.js +80 -25
- package/node_modules/three/examples/jsm/exporters/OBJExporter.js +25 -1
- package/node_modules/three/examples/jsm/exporters/PLYExporter.js +51 -17
- package/node_modules/three/examples/jsm/exporters/STLExporter.js +27 -5
- package/node_modules/three/examples/jsm/exporters/USDZExporter.js +783 -268
- package/node_modules/three/examples/jsm/geometries/BoxLineGeometry.js +23 -0
- package/node_modules/three/examples/jsm/geometries/ConvexGeometry.js +19 -0
- package/node_modules/three/examples/jsm/geometries/DecalGeometry.js +94 -30
- package/node_modules/three/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/node_modules/three/examples/jsm/geometries/ParametricGeometry.js +38 -5
- package/node_modules/three/examples/jsm/geometries/RoundedBoxGeometry.js +68 -7
- package/node_modules/three/examples/jsm/geometries/TeapotGeometry.js +23 -38
- package/node_modules/three/examples/jsm/geometries/TextGeometry.js +48 -21
- package/node_modules/three/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/node_modules/three/examples/jsm/helpers/LightProbeHelper.js +79 -44
- package/node_modules/three/examples/jsm/helpers/LightProbeHelperGPU.js +102 -0
- package/node_modules/three/examples/jsm/helpers/OctreeHelper.js +36 -0
- package/node_modules/three/examples/jsm/helpers/PositionalAudioHelper.js +60 -0
- package/node_modules/three/examples/jsm/helpers/RapierHelper.js +59 -0
- package/node_modules/three/examples/jsm/helpers/RectAreaLightHelper.js +36 -3
- package/node_modules/three/examples/jsm/helpers/TextureHelper.js +28 -0
- package/node_modules/three/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/node_modules/three/examples/jsm/helpers/VertexNormalsHelper.js +61 -2
- package/node_modules/three/examples/jsm/helpers/VertexTangentsHelper.js +47 -2
- package/node_modules/three/examples/jsm/helpers/ViewHelper.js +192 -65
- package/node_modules/three/examples/jsm/inspector/Inspector.js +427 -0
- package/node_modules/three/examples/jsm/inspector/RendererInspector.js +415 -0
- package/node_modules/three/examples/jsm/inspector/tabs/Console.js +204 -0
- package/node_modules/three/examples/jsm/inspector/tabs/Parameters.js +332 -0
- package/node_modules/three/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/node_modules/three/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/node_modules/three/examples/jsm/inspector/ui/Graph.js +95 -0
- package/node_modules/three/examples/jsm/inspector/ui/Item.js +170 -0
- package/node_modules/three/examples/jsm/inspector/ui/List.js +75 -0
- package/node_modules/three/examples/jsm/inspector/ui/Profiler.js +170 -0
- package/node_modules/three/examples/jsm/inspector/ui/Style.js +654 -0
- package/node_modules/three/examples/jsm/inspector/ui/Tab.js +46 -0
- package/node_modules/three/examples/jsm/inspector/ui/Values.js +423 -0
- package/node_modules/three/examples/jsm/inspector/ui/utils.js +56 -0
- package/node_modules/three/examples/jsm/interactive/HTMLMesh.js +50 -21
- package/node_modules/three/examples/jsm/interactive/InteractiveGroup.js +170 -62
- package/node_modules/three/examples/jsm/interactive/SelectionBox.js +106 -9
- package/node_modules/three/examples/jsm/interactive/SelectionHelper.js +76 -30
- package/node_modules/three/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/node_modules/three/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/node_modules/three/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/node_modules/three/examples/jsm/libs/draco/README.md +2 -2
- package/node_modules/three/examples/jsm/libs/fflate.module.js +694 -496
- package/node_modules/three/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/node_modules/three/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/node_modules/three/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/node_modules/three/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
- package/node_modules/three/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
- package/node_modules/three/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/node_modules/three/examples/jsm/libs/tween.module.js +32 -14
- package/node_modules/three/examples/jsm/lighting/TiledLighting.js +42 -0
- package/node_modules/three/examples/jsm/lights/LightProbeGenerator.js +65 -14
- package/node_modules/three/examples/jsm/lights/RectAreaLightTexturesLib.js +127 -0
- package/node_modules/three/examples/jsm/lights/RectAreaLightUniformsLib.js +20 -59
- package/node_modules/three/examples/jsm/lines/Line2.js +41 -4
- package/node_modules/three/examples/jsm/lines/LineGeometry.js +80 -2
- package/node_modules/three/examples/jsm/lines/LineMaterial.js +100 -22
- package/node_modules/three/examples/jsm/lines/LineSegments2.js +69 -4
- package/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.js +65 -8
- package/node_modules/three/examples/jsm/lines/Wireframe.js +58 -6
- package/node_modules/three/examples/jsm/lines/WireframeGeometry2.js +27 -2
- package/node_modules/three/examples/jsm/lines/webgpu/Line2.js +46 -0
- package/node_modules/three/examples/jsm/lines/webgpu/LineSegments2.js +411 -0
- package/node_modules/three/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/node_modules/three/examples/jsm/loaders/3DMLoader.js +86 -23
- package/node_modules/three/examples/jsm/loaders/3MFLoader.js +148 -5
- package/node_modules/three/examples/jsm/loaders/AMFLoader.js +32 -12
- package/node_modules/three/examples/jsm/loaders/BVHLoader.js +59 -12
- package/node_modules/three/examples/jsm/loaders/ColladaLoader.js +51 -12
- package/node_modules/three/examples/jsm/loaders/DDSLoader.js +68 -1
- package/node_modules/three/examples/jsm/loaders/DRACOLoader.js +149 -23
- package/node_modules/three/examples/jsm/loaders/EXRLoader.js +584 -109
- package/node_modules/three/examples/jsm/loaders/FBXLoader.js +165 -97
- package/node_modules/three/examples/jsm/loaders/FontLoader.js +83 -6
- package/node_modules/three/examples/jsm/loaders/GCodeLoader.js +37 -6
- package/node_modules/three/examples/jsm/loaders/GLTFLoader.js +337 -108
- package/node_modules/three/examples/jsm/loaders/HDRCubeTextureLoader.js +52 -3
- package/node_modules/three/examples/jsm/loaders/HDRLoader.js +486 -0
- package/node_modules/three/examples/jsm/loaders/IESLoader.js +42 -0
- package/node_modules/three/examples/jsm/loaders/KMZLoader.js +33 -0
- package/node_modules/three/examples/jsm/loaders/KTX2Loader.js +441 -138
- package/node_modules/three/examples/jsm/loaders/KTXLoader.js +31 -10
- package/node_modules/three/examples/jsm/loaders/LDrawLoader.js +194 -145
- package/node_modules/three/examples/jsm/loaders/LUT3dlLoader.js +47 -25
- package/node_modules/three/examples/jsm/loaders/LUTCubeLoader.js +46 -23
- package/node_modules/three/examples/jsm/loaders/LUTImageLoader.js +79 -52
- package/node_modules/three/examples/jsm/loaders/LWOLoader.js +47 -20
- package/node_modules/three/examples/jsm/loaders/LottieLoader.js +54 -1
- package/node_modules/three/examples/jsm/loaders/MD2Loader.js +37 -1
- package/node_modules/three/examples/jsm/loaders/MDDLoader.js +57 -12
- package/node_modules/three/examples/jsm/loaders/MTLLoader.js +61 -35
- package/node_modules/three/examples/jsm/loaders/MaterialXLoader.js +291 -39
- package/node_modules/three/examples/jsm/loaders/NRRDLoader.js +38 -6
- package/node_modules/three/examples/jsm/loaders/OBJLoader.js +54 -4
- package/node_modules/three/examples/jsm/loaders/PCDLoader.js +183 -32
- package/node_modules/three/examples/jsm/loaders/PDBLoader.js +44 -4
- package/node_modules/three/examples/jsm/loaders/PLYLoader.js +78 -44
- package/node_modules/three/examples/jsm/loaders/PVRLoader.js +25 -6
- package/node_modules/three/examples/jsm/loaders/RGBELoader.js +6 -438
- package/node_modules/three/examples/jsm/loaders/STLLoader.js +51 -40
- package/node_modules/three/examples/jsm/loaders/SVGLoader.js +118 -24
- package/node_modules/three/examples/jsm/loaders/TDSLoader.js +92 -72
- package/node_modules/three/examples/jsm/loaders/TGALoader.js +23 -0
- package/node_modules/three/examples/jsm/loaders/TIFFLoader.js +23 -0
- package/node_modules/three/examples/jsm/loaders/TTFLoader.js +50 -3
- package/node_modules/three/examples/jsm/loaders/USDLoader.js +219 -0
- package/node_modules/three/examples/jsm/loaders/USDZLoader.js +4 -810
- package/node_modules/three/examples/jsm/loaders/UltraHDRLoader.js +630 -0
- package/node_modules/three/examples/jsm/loaders/VOXLoader.js +67 -2
- package/node_modules/three/examples/jsm/loaders/VRMLLoader.js +57 -21
- package/node_modules/three/examples/jsm/loaders/VTKLoader.js +119 -6
- package/node_modules/three/examples/jsm/loaders/XYZLoader.js +39 -2
- package/node_modules/three/examples/jsm/loaders/lwo/IFFParser.js +81 -78
- package/node_modules/three/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/node_modules/three/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/node_modules/three/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
- package/node_modules/three/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
- package/node_modules/three/examples/jsm/materials/MeshGouraudMaterial.js +9 -1
- package/node_modules/three/examples/jsm/materials/MeshPostProcessingMaterial.js +25 -2
- package/node_modules/three/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/node_modules/three/examples/jsm/math/Capsule.js +91 -14
- package/node_modules/three/examples/jsm/math/ColorConverter.js +22 -0
- package/node_modules/three/examples/jsm/math/ColorSpaces.js +147 -0
- package/node_modules/three/examples/jsm/math/ConvexHull.js +517 -93
- package/node_modules/three/examples/jsm/math/ImprovedNoise.js +32 -15
- package/node_modules/three/examples/jsm/math/Lut.js +113 -0
- package/node_modules/three/examples/jsm/math/MeshSurfaceSampler.js +78 -13
- package/node_modules/three/examples/jsm/math/OBB.js +141 -29
- package/node_modules/three/examples/jsm/math/Octree.js +177 -25
- package/node_modules/three/examples/jsm/math/SimplexNoise.js +68 -42
- package/node_modules/three/examples/jsm/misc/ConvexObjectBreaker.js +45 -25
- package/node_modules/three/examples/jsm/misc/GPUComputationRenderer.js +105 -45
- package/node_modules/three/examples/jsm/misc/Gyroscope.js +12 -0
- package/node_modules/three/examples/jsm/misc/MD2Character.js +117 -2
- package/node_modules/three/examples/jsm/misc/MD2CharacterComplex.js +175 -11
- package/node_modules/three/examples/jsm/misc/MorphAnimMesh.js +44 -0
- package/node_modules/three/examples/jsm/misc/MorphBlendMesh.js +103 -0
- package/node_modules/three/examples/jsm/misc/ProgressiveLightMap.js +101 -54
- package/node_modules/three/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/node_modules/three/examples/jsm/misc/RollerCoaster.js +57 -0
- package/node_modules/three/examples/jsm/misc/TubePainter.js +437 -40
- package/node_modules/three/examples/jsm/misc/Volume.js +123 -75
- package/node_modules/three/examples/jsm/misc/VolumeSlice.js +95 -48
- package/node_modules/three/examples/jsm/modifiers/CurveModifier.js +77 -47
- package/node_modules/three/examples/jsm/modifiers/CurveModifierGPU.js +256 -0
- package/node_modules/three/examples/jsm/modifiers/EdgeSplitModifier.js +20 -0
- package/node_modules/three/examples/jsm/modifiers/SimplifyModifier.js +26 -11
- package/node_modules/three/examples/jsm/modifiers/TessellateModifier.js +35 -2
- package/node_modules/three/examples/jsm/objects/GroundedSkybox.js +25 -6
- package/node_modules/three/examples/jsm/objects/Lensflare.js +96 -4
- package/node_modules/three/examples/jsm/objects/LensflareMesh.js +376 -0
- package/node_modules/three/examples/jsm/objects/MarchingCubes.js +90 -5
- package/node_modules/three/examples/jsm/objects/Reflector.js +76 -2
- package/node_modules/three/examples/jsm/objects/ReflectorForSSRPass.js +41 -0
- package/node_modules/three/examples/jsm/objects/Refractor.js +62 -0
- package/node_modules/three/examples/jsm/objects/ShadowMesh.js +54 -4
- package/node_modules/three/examples/jsm/objects/Sky.js +30 -12
- package/node_modules/three/examples/jsm/objects/SkyMesh.js +243 -0
- package/node_modules/three/examples/jsm/objects/Water.js +45 -5
- package/node_modules/three/examples/jsm/objects/Water2.js +44 -4
- package/node_modules/three/examples/jsm/objects/Water2Mesh.js +199 -0
- package/node_modules/three/examples/jsm/objects/WaterMesh.js +196 -0
- package/node_modules/three/examples/jsm/physics/AmmoPhysics.js +48 -0
- package/node_modules/three/examples/jsm/physics/JoltPhysics.js +330 -0
- package/node_modules/three/examples/jsm/physics/RapierPhysics.js +231 -19
- package/node_modules/three/examples/jsm/postprocessing/AfterimagePass.js +110 -29
- package/node_modules/three/examples/jsm/postprocessing/BloomPass.js +128 -26
- package/node_modules/three/examples/jsm/postprocessing/BokehPass.js +99 -22
- package/node_modules/three/examples/jsm/postprocessing/ClearPass.js +54 -3
- package/node_modules/three/examples/jsm/postprocessing/CubeTexturePass.js +82 -21
- package/node_modules/three/examples/jsm/postprocessing/DotScreenPass.js +59 -10
- package/node_modules/three/examples/jsm/postprocessing/EffectComposer.js +135 -3
- package/node_modules/three/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/node_modules/three/examples/jsm/postprocessing/FilmPass.js +54 -5
- package/node_modules/three/examples/jsm/postprocessing/GTAOPass.js +202 -57
- package/node_modules/three/examples/jsm/postprocessing/GlitchPass.js +86 -37
- package/node_modules/three/examples/jsm/postprocessing/HalftonePass.js +65 -10
- package/node_modules/three/examples/jsm/postprocessing/LUTPass.js +43 -79
- package/node_modules/three/examples/jsm/postprocessing/MaskPass.js +91 -0
- package/node_modules/three/examples/jsm/postprocessing/OutlinePass.js +277 -155
- package/node_modules/three/examples/jsm/postprocessing/OutputPass.js +58 -14
- package/node_modules/three/examples/jsm/postprocessing/Pass.js +100 -4
- package/node_modules/three/examples/jsm/postprocessing/RenderPass.js +85 -1
- package/node_modules/three/examples/jsm/postprocessing/RenderPixelatedPass.js +124 -45
- package/node_modules/three/examples/jsm/postprocessing/RenderTransitionPass.js +267 -0
- package/node_modules/three/examples/jsm/postprocessing/SAOPass.js +128 -56
- package/node_modules/three/examples/jsm/postprocessing/SMAAPass.js +106 -75
- package/node_modules/three/examples/jsm/postprocessing/SSAARenderPass.js +120 -35
- package/node_modules/three/examples/jsm/postprocessing/SSAOPass.js +174 -67
- package/node_modules/three/examples/jsm/postprocessing/SSRPass.js +268 -53
- package/node_modules/three/examples/jsm/postprocessing/SavePass.js +69 -16
- package/node_modules/three/examples/jsm/postprocessing/ShaderPass.js +65 -7
- package/node_modules/three/examples/jsm/postprocessing/TAARenderPass.js +79 -24
- package/node_modules/three/examples/jsm/postprocessing/TexturePass.js +72 -8
- package/node_modules/three/examples/jsm/postprocessing/UnrealBloomPass.js +125 -46
- package/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +122 -9
- package/node_modules/three/examples/jsm/renderers/CSS3DRenderer.js +133 -8
- package/node_modules/three/examples/jsm/renderers/Projector.js +20 -2
- package/node_modules/three/examples/jsm/renderers/SVGRenderer.js +134 -5
- package/node_modules/three/examples/jsm/shaders/ACESFilmicToneMappingShader.js +12 -5
- package/node_modules/three/examples/jsm/shaders/AfterimageShader.js +8 -3
- package/node_modules/three/examples/jsm/shaders/BasicShader.js +8 -1
- package/node_modules/three/examples/jsm/shaders/BleachBypassShader.js +11 -5
- package/node_modules/three/examples/jsm/shaders/BlendShader.js +8 -1
- package/node_modules/three/examples/jsm/shaders/BokehShader.js +9 -3
- package/node_modules/three/examples/jsm/shaders/BokehShader2.js +11 -4
- package/node_modules/three/examples/jsm/shaders/BrightnessContrastShader.js +10 -4
- package/node_modules/three/examples/jsm/shaders/ColorCorrectionShader.js +8 -1
- package/node_modules/three/examples/jsm/shaders/ColorifyShader.js +9 -3
- package/node_modules/three/examples/jsm/shaders/ConvolutionShader.js +9 -38
- package/node_modules/three/examples/jsm/shaders/CopyShader.js +8 -1
- package/node_modules/three/examples/jsm/shaders/DOFMipMapShader.js +10 -3
- package/node_modules/three/examples/jsm/shaders/DepthLimitedBlurShader.js +10 -1
- package/node_modules/three/examples/jsm/shaders/DigitalGlitch.js +10 -7
- package/node_modules/three/examples/jsm/shaders/DotScreenShader.js +8 -3
- package/node_modules/three/examples/jsm/shaders/ExposureShader.js +8 -1
- package/node_modules/three/examples/jsm/shaders/FXAAShader.js +243 -233
- package/node_modules/three/examples/jsm/shaders/FilmShader.js +13 -0
- package/node_modules/three/examples/jsm/shaders/FocusShader.js +8 -3
- package/node_modules/three/examples/jsm/shaders/FreiChenShader.js +10 -3
- package/node_modules/three/examples/jsm/shaders/GTAOShader.js +37 -40
- package/node_modules/three/examples/jsm/shaders/GammaCorrectionShader.js +11 -2
- package/node_modules/three/examples/jsm/shaders/GodRaysShader.js +20 -8
- package/node_modules/three/examples/jsm/shaders/HalftoneShader.js +13 -4
- package/node_modules/three/examples/jsm/shaders/HorizontalBlurShader.js +12 -3
- package/node_modules/three/examples/jsm/shaders/HorizontalTiltShiftShader.js +9 -2
- package/node_modules/three/examples/jsm/shaders/HueSaturationShader.js +10 -3
- package/node_modules/three/examples/jsm/shaders/KaleidoShader.js +11 -4
- package/node_modules/three/examples/jsm/shaders/LuminosityHighPassShader.js +9 -7
- package/node_modules/three/examples/jsm/shaders/LuminosityShader.js +8 -2
- package/node_modules/three/examples/jsm/shaders/MirrorShader.js +10 -4
- package/node_modules/three/examples/jsm/shaders/NormalMapShader.js +7 -2
- package/node_modules/three/examples/jsm/shaders/OutputShader.js +24 -2
- package/node_modules/three/examples/jsm/shaders/PoissonDenoiseShader.js +24 -15
- package/node_modules/three/examples/jsm/shaders/RGBShiftShader.js +8 -1
- package/node_modules/three/examples/jsm/shaders/SAOShader.js +10 -1
- package/node_modules/three/examples/jsm/shaders/SMAAShader.js +24 -1
- package/node_modules/three/examples/jsm/shaders/SSAOShader.js +26 -5
- package/node_modules/three/examples/jsm/shaders/SSRShader.js +26 -1
- package/node_modules/three/examples/jsm/shaders/SepiaShader.js +8 -3
- package/node_modules/three/examples/jsm/shaders/SobelOperatorShader.js +9 -3
- package/node_modules/three/examples/jsm/shaders/SubsurfaceScatteringShader.js +13 -8
- package/node_modules/three/examples/jsm/shaders/TechnicolorShader.js +10 -4
- package/node_modules/three/examples/jsm/shaders/ToonShader.js +29 -6
- package/node_modules/three/examples/jsm/shaders/TriangleBlurShader.js +9 -4
- package/node_modules/three/examples/jsm/shaders/UnpackDepthRGBAShader.js +19 -4
- package/node_modules/three/examples/jsm/shaders/VelocityShader.js +8 -1
- package/node_modules/three/examples/jsm/shaders/VerticalBlurShader.js +9 -2
- package/node_modules/three/examples/jsm/shaders/VerticalTiltShiftShader.js +8 -1
- package/node_modules/three/examples/jsm/shaders/VignetteShader.js +8 -3
- package/node_modules/three/examples/jsm/shaders/VolumeShader.js +11 -2
- package/node_modules/three/examples/jsm/shaders/WaterRefractionShader.js +11 -0
- package/node_modules/three/examples/jsm/textures/FlakesTexture.js +14 -0
- package/node_modules/three/examples/jsm/transpiler/AST.js +392 -31
- package/node_modules/three/examples/jsm/transpiler/GLSLDecoder.js +366 -136
- package/node_modules/three/examples/jsm/transpiler/Linker.js +327 -0
- package/node_modules/three/examples/jsm/transpiler/ShaderToyDecoder.js +3 -3
- package/node_modules/three/examples/jsm/transpiler/TSLEncoder.js +336 -111
- package/node_modules/three/examples/jsm/transpiler/Transpiler.js +50 -1
- package/node_modules/three/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/node_modules/three/examples/jsm/transpiler/WGSLEncoder.js +812 -0
- package/node_modules/three/examples/jsm/tsl/display/AfterImageNode.js +244 -0
- package/node_modules/three/examples/jsm/tsl/display/AnaglyphPassNode.js +107 -0
- package/node_modules/three/examples/jsm/tsl/display/AnamorphicNode.js +282 -0
- package/node_modules/three/examples/jsm/tsl/display/BleachBypass.js +33 -0
- package/node_modules/three/examples/jsm/tsl/display/BloomNode.js +524 -0
- package/node_modules/three/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/node_modules/three/examples/jsm/tsl/display/DenoiseNode.js +334 -0
- package/node_modules/three/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
- package/node_modules/three/examples/jsm/tsl/display/DotScreenNode.js +104 -0
- package/node_modules/three/examples/jsm/tsl/display/FXAANode.js +365 -0
- package/node_modules/three/examples/jsm/tsl/display/FilmNode.js +101 -0
- package/node_modules/three/examples/jsm/tsl/display/GTAONode.js +570 -0
- package/node_modules/three/examples/jsm/tsl/display/GaussianBlurNode.js +380 -0
- package/node_modules/three/examples/jsm/tsl/display/LensflareNode.js +279 -0
- package/node_modules/three/examples/jsm/tsl/display/Lut3DNode.js +109 -0
- package/node_modules/three/examples/jsm/tsl/display/MotionBlur.js +33 -0
- package/node_modules/three/examples/jsm/tsl/display/OutlineNode.js +762 -0
- package/node_modules/three/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
- package/node_modules/three/examples/jsm/tsl/display/PixelationPassNode.js +334 -0
- package/node_modules/three/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
- package/node_modules/three/examples/jsm/tsl/display/SMAANode.js +768 -0
- package/node_modules/three/examples/jsm/tsl/display/SSAAPassNode.js +358 -0
- package/node_modules/three/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/node_modules/three/examples/jsm/tsl/display/SSRNode.js +656 -0
- package/node_modules/three/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/node_modules/three/examples/jsm/tsl/display/Sepia.js +24 -0
- package/node_modules/three/examples/jsm/tsl/display/SobelOperatorNode.js +168 -0
- package/node_modules/three/examples/jsm/tsl/display/StereoCompositePassNode.js +185 -0
- package/node_modules/three/examples/jsm/tsl/display/StereoPassNode.js +120 -0
- package/node_modules/three/examples/jsm/tsl/display/TRAANode.js +578 -0
- package/node_modules/three/examples/jsm/tsl/display/TransitionNode.js +141 -0
- package/node_modules/three/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/node_modules/three/examples/jsm/tsl/display/hashBlur.js +54 -0
- package/node_modules/three/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
- package/node_modules/three/examples/jsm/tsl/math/Bayer.js +34 -0
- package/node_modules/three/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
- package/node_modules/three/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/node_modules/three/examples/jsm/tsl/utils/Raymarching.js +70 -0
- package/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +109 -45
- package/node_modules/three/examples/jsm/utils/CameraUtils.js +15 -6
- package/node_modules/three/examples/jsm/utils/GeometryCompressionUtils.js +54 -146
- package/node_modules/three/examples/jsm/utils/GeometryUtils.js +32 -27
- package/node_modules/three/examples/jsm/utils/LDrawUtils.js +13 -4
- package/node_modules/three/examples/jsm/utils/SceneOptimizer.js +458 -0
- package/node_modules/three/examples/jsm/utils/SceneUtils.js +112 -3
- package/node_modules/three/examples/jsm/utils/ShadowMapViewer.js +51 -31
- package/node_modules/three/examples/jsm/utils/ShadowMapViewerGPU.js +233 -0
- package/node_modules/three/examples/jsm/utils/SkeletonUtils.js +145 -68
- package/node_modules/three/examples/jsm/utils/SortUtils.js +23 -8
- package/node_modules/three/examples/jsm/utils/UVsDebug.js +12 -4
- package/node_modules/three/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +19 -2
- package/node_modules/three/examples/jsm/utils/WebGPUTextureUtils.js +81 -0
- package/node_modules/three/examples/jsm/utils/WorkerPool.js +67 -2
- package/node_modules/three/examples/jsm/webxr/ARButton.js +19 -0
- package/node_modules/three/examples/jsm/webxr/OculusHandModel.js +87 -2
- package/node_modules/three/examples/jsm/webxr/OculusHandPointerModel.js +148 -22
- package/node_modules/three/examples/jsm/webxr/Text2D.js +20 -6
- package/node_modules/three/examples/jsm/webxr/VRButton.js +44 -5
- package/node_modules/three/examples/jsm/webxr/XRButton.js +23 -1
- package/node_modules/three/examples/jsm/webxr/XRControllerModelFactory.js +103 -4
- package/node_modules/three/examples/jsm/webxr/XREstimatedLight.js +35 -4
- package/node_modules/three/examples/jsm/webxr/XRHandMeshModel.js +37 -0
- package/node_modules/three/examples/jsm/webxr/XRHandModelFactory.js +101 -9
- package/node_modules/three/examples/jsm/webxr/XRHandPrimitiveModel.js +44 -0
- package/node_modules/three/examples/jsm/webxr/XRPlanes.js +18 -0
- package/node_modules/three/package.json +25 -20
- package/node_modules/three/src/Three.Core.js +185 -0
- package/node_modules/three/src/Three.Legacy.js +0 -1
- package/node_modules/three/src/Three.TSL.js +633 -0
- package/node_modules/three/src/Three.WebGPU.Nodes.js +26 -0
- package/node_modules/three/src/Three.WebGPU.js +28 -0
- package/node_modules/three/src/Three.js +1 -176
- package/node_modules/three/src/animation/AnimationAction.js +262 -30
- package/node_modules/three/src/animation/AnimationClip.js +164 -9
- package/node_modules/three/src/animation/AnimationMixer.js +99 -15
- package/node_modules/three/src/animation/AnimationObjectGroup.js +45 -21
- package/node_modules/three/src/animation/AnimationUtils.js +169 -19
- package/node_modules/three/src/animation/KeyframeTrack.js +151 -16
- package/node_modules/three/src/animation/PropertyBinding.js +91 -16
- package/node_modules/three/src/animation/PropertyMixer.js +72 -5
- package/node_modules/three/src/animation/tracks/BooleanKeyframeTrack.js +42 -6
- package/node_modules/three/src/animation/tracks/ColorKeyframeTrack.js +26 -5
- package/node_modules/three/src/animation/tracks/NumberKeyframeTrack.js +26 -2
- package/node_modules/three/src/animation/tracks/QuaternionKeyframeTrack.js +31 -3
- package/node_modules/three/src/animation/tracks/StringKeyframeTrack.js +42 -2
- package/node_modules/three/src/animation/tracks/VectorKeyframeTrack.js +26 -2
- package/node_modules/three/src/audio/Audio.js +388 -10
- package/node_modules/three/src/audio/AudioAnalyser.js +58 -1
- package/node_modules/three/src/audio/AudioContext.js +15 -0
- package/node_modules/three/src/audio/AudioListener.js +89 -10
- package/node_modules/three/src/audio/PositionalAudio.js +107 -0
- package/node_modules/three/src/cameras/ArrayCamera.js +37 -0
- package/node_modules/three/src/cameras/Camera.js +61 -0
- package/node_modules/three/src/cameras/CubeCamera.js +66 -0
- package/node_modules/three/src/cameras/OrthographicCamera.js +110 -1
- package/node_modules/three/src/cameras/PerspectiveCamera.js +174 -35
- package/node_modules/three/src/cameras/StereoCamera.js +48 -2
- package/node_modules/three/src/constants.js +1477 -18
- package/node_modules/three/src/core/BufferAttribute.js +417 -23
- package/node_modules/three/src/core/BufferGeometry.js +416 -49
- package/node_modules/three/src/core/Clock.js +62 -8
- package/node_modules/three/src/core/EventDispatcher.js +52 -8
- package/node_modules/three/src/core/GLBufferAttribute.js +113 -2
- package/node_modules/three/src/core/InstancedBufferAttribute.js +29 -0
- package/node_modules/three/src/core/InstancedBufferGeometry.js +20 -0
- package/node_modules/three/src/core/InstancedInterleavedBuffer.js +26 -0
- package/node_modules/three/src/core/InterleavedBuffer.js +141 -16
- package/node_modules/three/src/core/InterleavedBufferAttribute.js +200 -2
- package/node_modules/three/src/core/Layers.js +71 -10
- package/node_modules/three/src/core/Object3D.js +665 -54
- package/node_modules/three/src/core/Raycaster.js +160 -8
- package/node_modules/three/src/core/RenderTarget.js +297 -36
- package/node_modules/three/src/core/RenderTarget3D.js +48 -0
- package/node_modules/three/src/core/Timer.js +184 -0
- package/node_modules/three/src/core/Uniform.js +29 -0
- package/node_modules/three/src/core/UniformsGroup.js +84 -2
- package/node_modules/three/src/extras/Controls.js +120 -0
- package/node_modules/three/src/extras/DataUtils.js +50 -9
- package/node_modules/three/src/extras/Earcut.js +18 -779
- package/node_modules/three/src/extras/ImageUtils.js +22 -14
- package/node_modules/three/src/extras/PMREMGenerator.js +329 -64
- package/node_modules/three/src/extras/ShapeUtils.js +24 -2
- package/node_modules/three/src/extras/TextureUtils.js +293 -0
- package/node_modules/three/src/extras/core/Curve.js +156 -55
- package/node_modules/three/src/extras/core/CurvePath.js +63 -22
- package/node_modules/three/src/extras/core/Interpolations.js +34 -2
- package/node_modules/three/src/extras/core/Path.js +134 -1
- package/node_modules/three/src/extras/core/Shape.js +66 -3
- package/node_modules/three/src/extras/core/ShapePath.js +80 -4
- package/node_modules/three/src/extras/curves/ArcCurve.js +22 -0
- package/node_modules/three/src/extras/curves/CatmullRomCurve3.js +89 -18
- package/node_modules/three/src/extras/curves/CubicBezierCurve.js +67 -0
- package/node_modules/three/src/extras/curves/CubicBezierCurve3.js +50 -0
- package/node_modules/three/src/extras/curves/EllipseCurve.js +104 -2
- package/node_modules/three/src/extras/curves/LineCurve.js +36 -0
- package/node_modules/three/src/extras/curves/LineCurve3.js +36 -0
- package/node_modules/three/src/extras/curves/QuadraticBezierCurve.js +59 -0
- package/node_modules/three/src/extras/curves/QuadraticBezierCurve3.js +43 -0
- package/node_modules/three/src/extras/curves/SplineCurve.js +48 -0
- package/node_modules/three/src/extras/lib/earcut.js +685 -0
- package/node_modules/three/src/geometries/BoxGeometry.js +39 -0
- package/node_modules/three/src/geometries/CapsuleGeometry.js +196 -11
- package/node_modules/three/src/geometries/CircleGeometry.js +41 -0
- package/node_modules/three/src/geometries/ConeGeometry.js +39 -0
- package/node_modules/three/src/geometries/CylinderGeometry.js +51 -4
- package/node_modules/three/src/geometries/DodecahedronGeometry.js +33 -0
- package/node_modules/three/src/geometries/EdgesGeometry.js +30 -2
- package/node_modules/three/src/geometries/ExtrudeGeometry.js +146 -50
- package/node_modules/three/src/geometries/IcosahedronGeometry.js +33 -0
- package/node_modules/three/src/geometries/LatheGeometry.js +44 -3
- package/node_modules/three/src/geometries/OctahedronGeometry.js +33 -0
- package/node_modules/three/src/geometries/PlaneGeometry.js +35 -0
- package/node_modules/three/src/geometries/PolyhedronGeometry.js +29 -0
- package/node_modules/three/src/geometries/RingGeometry.js +37 -0
- package/node_modules/three/src/geometries/ShapeGeometry.js +38 -0
- package/node_modules/three/src/geometries/SphereGeometry.js +38 -0
- package/node_modules/three/src/geometries/TetrahedronGeometry.js +33 -0
- package/node_modules/three/src/geometries/TorusGeometry.js +36 -0
- package/node_modules/three/src/geometries/TorusKnotGeometry.js +39 -0
- package/node_modules/three/src/geometries/TubeGeometry.js +50 -0
- package/node_modules/three/src/geometries/WireframeGeometry.js +32 -0
- package/node_modules/three/src/helpers/ArrowHelper.js +62 -5
- package/node_modules/three/src/helpers/AxesHelper.js +28 -0
- package/node_modules/three/src/helpers/Box3Helper.js +28 -0
- package/node_modules/three/src/helpers/BoxHelper.js +43 -7
- package/node_modules/three/src/helpers/CameraHelper.js +100 -27
- package/node_modules/three/src/helpers/DirectionalLightHelper.js +52 -0
- package/node_modules/three/src/helpers/GridHelper.js +26 -0
- package/node_modules/three/src/helpers/HemisphereLightHelper.js +39 -0
- package/node_modules/three/src/helpers/PlaneHelper.js +33 -0
- package/node_modules/three/src/helpers/PointLightHelper.js +43 -0
- package/node_modules/three/src/helpers/PolarGridHelper.js +30 -0
- package/node_modules/three/src/helpers/SkeletonHelper.js +73 -7
- package/node_modules/three/src/helpers/SpotLightHelper.js +58 -1
- package/node_modules/three/src/lights/AmbientLight.js +25 -0
- package/node_modules/three/src/lights/DirectionalLight.js +57 -0
- package/node_modules/three/src/lights/DirectionalLightShadow.js +15 -0
- package/node_modules/three/src/lights/HemisphereLight.js +32 -0
- package/node_modules/three/src/lights/Light.js +37 -0
- package/node_modules/three/src/lights/LightProbe.js +43 -0
- package/node_modules/three/src/lights/LightShadow.js +198 -7
- package/node_modules/three/src/lights/PointLight.js +59 -0
- package/node_modules/three/src/lights/PointLightShadow.js +22 -1
- package/node_modules/three/src/lights/RectAreaLight.js +59 -0
- package/node_modules/three/src/lights/SpotLight.js +102 -0
- package/node_modules/three/src/lights/SpotLightShadow.js +33 -3
- package/node_modules/three/src/lights/webgpu/IESSpotLight.js +46 -0
- package/node_modules/three/src/lights/webgpu/ProjectorLight.js +46 -0
- package/node_modules/three/src/loaders/AnimationLoader.js +34 -2
- package/node_modules/three/src/loaders/AudioLoader.js +34 -2
- package/node_modules/three/src/loaders/BufferGeometryLoader.js +38 -13
- package/node_modules/three/src/loaders/Cache.js +47 -2
- package/node_modules/three/src/loaders/CompressedTextureLoader.js +36 -3
- package/node_modules/three/src/loaders/CubeTextureLoader.js +45 -0
- package/node_modules/three/src/loaders/DataTextureLoader.js +45 -8
- package/node_modules/three/src/loaders/FileLoader.js +90 -6
- package/node_modules/three/src/loaders/ImageBitmapLoader.js +108 -11
- package/node_modules/three/src/loaders/ImageLoader.js +85 -8
- package/node_modules/three/src/loaders/Loader.js +144 -0
- package/node_modules/three/src/loaders/LoaderUtils.js +18 -34
- package/node_modules/three/src/loaders/LoadingManager.js +187 -0
- package/node_modules/three/src/loaders/MaterialLoader.js +70 -4
- package/node_modules/three/src/loaders/ObjectLoader.js +146 -30
- package/node_modules/three/src/loaders/TextureLoader.js +33 -0
- package/node_modules/three/src/loaders/nodes/NodeLoader.js +194 -0
- package/node_modules/three/src/loaders/nodes/NodeMaterialLoader.js +108 -0
- package/node_modules/three/src/loaders/nodes/NodeObjectLoader.js +151 -0
- package/node_modules/three/src/materials/LineBasicMaterial.js +74 -1
- package/node_modules/three/src/materials/LineDashedMaterial.js +52 -1
- package/node_modules/three/src/materials/Material.js +504 -11
- package/node_modules/three/src/materials/MeshBasicMaterial.js +172 -3
- package/node_modules/three/src/materials/MeshDepthMaterial.js +94 -0
- package/node_modules/three/src/materials/MeshDistanceMaterial.js +76 -0
- package/node_modules/three/src/materials/MeshLambertMaterial.js +278 -1
- package/node_modules/three/src/materials/MeshMatcapMaterial.js +164 -0
- package/node_modules/three/src/materials/MeshNormalMaterial.js +114 -0
- package/node_modules/three/src/materials/MeshPhongMaterial.js +293 -1
- package/node_modules/three/src/materials/MeshPhysicalMaterial.js +316 -4
- package/node_modules/three/src/materials/MeshStandardMaterial.js +304 -3
- package/node_modules/three/src/materials/MeshToonMaterial.js +219 -0
- package/node_modules/three/src/materials/PointsMaterial.js +89 -0
- package/node_modules/three/src/materials/RawShaderMaterial.js +25 -0
- package/node_modules/three/src/materials/ShaderMaterial.js +215 -10
- package/node_modules/three/src/materials/ShadowMaterial.js +54 -0
- package/node_modules/three/src/materials/SpriteMaterial.js +82 -0
- package/node_modules/three/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +206 -100
- package/node_modules/three/src/materials/nodes/LineBasicNodeMaterial.js +46 -0
- package/node_modules/three/src/materials/nodes/LineDashedNodeMaterial.js +132 -0
- package/node_modules/three/src/materials/nodes/MeshBasicNodeMaterial.js +134 -0
- package/node_modules/three/src/materials/nodes/MeshLambertNodeMaterial.js +82 -0
- package/node_modules/three/src/materials/nodes/MeshMatcapNodeMaterial.js +77 -0
- package/node_modules/three/src/materials/nodes/MeshNormalNodeMaterial.js +67 -0
- package/node_modules/three/src/materials/nodes/MeshPhongNodeMaterial.js +141 -0
- package/node_modules/three/src/materials/nodes/MeshPhysicalNodeMaterial.js +518 -0
- package/node_modules/three/src/materials/nodes/MeshSSSNodeMaterial.js +175 -0
- package/node_modules/three/src/materials/nodes/MeshStandardNodeMaterial.js +186 -0
- package/node_modules/three/src/materials/nodes/MeshToonNodeMaterial.js +66 -0
- package/node_modules/three/src/materials/nodes/NodeMaterial.js +1310 -0
- package/node_modules/three/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +7 -2
- package/node_modules/three/src/materials/nodes/PointsNodeMaterial.js +211 -0
- package/node_modules/three/src/materials/nodes/ShadowNodeMaterial.js +76 -0
- package/node_modules/three/src/materials/nodes/SpriteNodeMaterial.js +186 -0
- package/node_modules/three/src/materials/nodes/VolumeNodeMaterial.js +81 -0
- package/node_modules/three/src/materials/nodes/manager/NodeMaterialObserver.js +613 -0
- package/node_modules/three/src/math/Box2.js +181 -4
- package/node_modules/three/src/math/Box3.js +277 -6
- package/node_modules/three/src/math/Color.js +355 -11
- package/node_modules/three/src/math/ColorManagement.js +161 -85
- package/node_modules/three/src/math/Cylindrical.js +65 -6
- package/node_modules/three/src/math/Euler.js +139 -5
- package/node_modules/three/src/math/Frustum.js +108 -9
- package/node_modules/three/src/math/FrustumArray.js +258 -0
- package/node_modules/three/src/math/Interpolant.js +87 -8
- package/node_modules/three/src/math/Line3.js +223 -2
- package/node_modules/three/src/math/MathUtils.js +408 -20
- package/node_modules/three/src/math/Matrix2.js +124 -0
- package/node_modules/three/src/math/Matrix3.js +229 -4
- package/node_modules/three/src/math/Matrix4.js +416 -30
- package/node_modules/three/src/math/Plane.js +164 -2
- package/node_modules/three/src/math/Quaternion.js +345 -86
- package/node_modules/three/src/math/Ray.js +162 -0
- package/node_modules/three/src/math/Sphere.js +175 -0
- package/node_modules/three/src/math/Spherical.js +74 -13
- package/node_modules/three/src/math/SphericalHarmonics3.js +112 -14
- package/node_modules/three/src/math/Triangle.js +230 -2
- package/node_modules/three/src/math/Vector2.js +396 -10
- package/node_modules/three/src/math/Vector3.js +557 -20
- package/node_modules/three/src/math/Vector4.js +428 -9
- package/node_modules/three/src/math/interpolants/CubicInterpolant.js +10 -1
- package/node_modules/three/src/math/interpolants/DiscreteInterpolant.js +10 -2
- package/node_modules/three/src/math/interpolants/LinearInterpolant.js +13 -0
- package/node_modules/three/src/math/interpolants/QuaternionLinearInterpolant.js +10 -1
- package/node_modules/three/src/nodes/Nodes.js +148 -0
- package/node_modules/three/src/nodes/TSL.js +173 -0
- package/node_modules/three/src/nodes/accessors/AccessorsUtils.js +53 -0
- package/node_modules/three/src/nodes/accessors/Arrays.js +68 -0
- package/node_modules/three/src/nodes/accessors/BatchNode.js +163 -0
- package/node_modules/three/src/nodes/accessors/Bitangent.js +82 -0
- package/node_modules/three/src/nodes/accessors/BufferAttributeNode.js +340 -0
- package/node_modules/three/src/nodes/accessors/BufferNode.js +101 -0
- package/node_modules/three/src/nodes/accessors/BuiltinNode.js +63 -0
- package/node_modules/three/src/nodes/accessors/Camera.js +282 -0
- package/node_modules/three/src/nodes/accessors/ClippingNode.js +255 -0
- package/node_modules/three/src/nodes/accessors/CubeTextureNode.js +190 -0
- package/node_modules/three/src/nodes/accessors/InstanceNode.js +244 -0
- package/node_modules/three/src/nodes/accessors/InstancedMeshNode.js +50 -0
- package/node_modules/three/src/nodes/accessors/Lights.js +139 -0
- package/node_modules/three/src/nodes/accessors/MaterialNode.js +775 -0
- package/node_modules/three/src/nodes/accessors/MaterialProperties.js +59 -0
- package/node_modules/three/src/nodes/accessors/MaterialReferenceNode.js +85 -0
- package/node_modules/three/src/nodes/accessors/ModelNode.js +184 -0
- package/node_modules/three/src/nodes/accessors/ModelViewProjectionNode.js +13 -0
- package/node_modules/three/{examples/jsm → src}/nodes/accessors/MorphNode.js +122 -57
- package/node_modules/three/src/nodes/accessors/Normal.js +243 -0
- package/node_modules/three/src/nodes/accessors/Object3DNode.js +268 -0
- package/node_modules/three/src/nodes/accessors/PointUVNode.js +55 -0
- package/node_modules/three/src/nodes/accessors/Position.js +90 -0
- package/node_modules/three/src/nodes/accessors/ReferenceBaseNode.js +357 -0
- package/node_modules/three/src/nodes/accessors/ReferenceNode.js +424 -0
- package/node_modules/three/src/nodes/accessors/ReflectVector.js +36 -0
- package/node_modules/three/src/nodes/accessors/RendererReferenceNode.js +79 -0
- package/node_modules/three/src/nodes/accessors/SceneNode.js +145 -0
- package/node_modules/three/src/nodes/accessors/SkinningNode.js +327 -0
- package/node_modules/three/src/nodes/accessors/StorageBufferNode.js +416 -0
- package/node_modules/three/src/nodes/accessors/StorageTextureNode.js +264 -0
- package/node_modules/three/src/nodes/accessors/Tangent.js +70 -0
- package/node_modules/three/src/nodes/accessors/TangentUtils.js +46 -0
- package/node_modules/three/src/nodes/accessors/Texture3DNode.js +199 -0
- package/node_modules/three/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +28 -30
- package/node_modules/three/src/nodes/accessors/TextureNode.js +927 -0
- package/node_modules/three/src/nodes/accessors/TextureSizeNode.js +77 -0
- package/node_modules/three/src/nodes/accessors/UV.js +11 -0
- package/node_modules/three/src/nodes/accessors/UniformArrayNode.js +348 -0
- package/node_modules/three/src/nodes/accessors/UserDataNode.js +77 -0
- package/node_modules/three/src/nodes/accessors/VelocityNode.js +224 -0
- package/node_modules/three/src/nodes/accessors/VertexColorNode.js +110 -0
- package/node_modules/three/src/nodes/code/CodeNode.js +181 -0
- package/node_modules/three/src/nodes/code/ExpressionNode.js +68 -0
- package/node_modules/three/src/nodes/code/FunctionCallNode.js +187 -0
- package/node_modules/three/src/nodes/code/FunctionNode.js +183 -0
- package/node_modules/three/{examples/jsm → src}/nodes/code/ScriptableNode.js +253 -15
- package/node_modules/three/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +95 -9
- package/node_modules/three/src/nodes/core/ArrayNode.js +155 -0
- package/node_modules/three/src/nodes/core/AssignNode.js +202 -0
- package/node_modules/three/src/nodes/core/AttributeNode.js +168 -0
- package/node_modules/three/src/nodes/core/BypassNode.js +93 -0
- package/node_modules/three/src/nodes/core/ConstNode.js +67 -0
- package/node_modules/three/src/nodes/core/ContextNode.js +184 -0
- package/node_modules/three/src/nodes/core/IndexNode.js +164 -0
- package/node_modules/three/src/nodes/core/InputNode.js +136 -0
- package/node_modules/three/src/nodes/core/InspectorNode.js +128 -0
- package/node_modules/three/src/nodes/core/IsolateNode.js +133 -0
- package/node_modules/three/src/nodes/core/LightingModel.js +77 -0
- package/node_modules/three/src/nodes/core/MRTNode.js +150 -0
- package/node_modules/three/src/nodes/core/Node.js +1083 -0
- package/node_modules/three/src/nodes/core/NodeAttribute.js +53 -0
- package/node_modules/three/src/nodes/core/NodeBuilder.js +3081 -0
- package/node_modules/three/src/nodes/core/NodeCache.js +75 -0
- package/node_modules/three/src/nodes/core/NodeCode.js +46 -0
- package/node_modules/three/src/nodes/core/NodeFrame.js +306 -0
- package/node_modules/three/src/nodes/core/NodeFunction.js +69 -0
- package/node_modules/three/src/nodes/core/NodeFunctionInput.js +61 -0
- package/node_modules/three/src/nodes/core/NodeParser.js +23 -0
- package/node_modules/three/src/nodes/core/NodeUniform.js +91 -0
- package/node_modules/three/src/nodes/core/NodeUtils.js +406 -0
- package/node_modules/three/src/nodes/core/NodeVar.js +60 -0
- package/node_modules/three/src/nodes/core/NodeVarying.js +63 -0
- package/node_modules/three/src/nodes/core/OutputStructNode.js +103 -0
- package/node_modules/three/src/nodes/core/ParameterNode.js +94 -0
- package/node_modules/three/src/nodes/core/PropertyNode.js +351 -0
- package/node_modules/three/src/nodes/core/StackNode.js +377 -0
- package/node_modules/three/src/nodes/core/StructNode.js +120 -0
- package/node_modules/three/src/nodes/core/StructType.js +13 -0
- package/node_modules/three/src/nodes/core/StructTypeNode.js +154 -0
- package/node_modules/three/src/nodes/core/SubBuildNode.js +89 -0
- package/node_modules/three/src/nodes/core/TempNode.js +88 -0
- package/node_modules/three/src/nodes/core/UniformGroupNode.js +137 -0
- package/node_modules/three/src/nodes/core/UniformNode.js +243 -0
- package/node_modules/three/src/nodes/core/VarNode.js +342 -0
- package/node_modules/three/src/nodes/core/VaryingNode.js +227 -0
- package/node_modules/three/src/nodes/core/constants.js +68 -0
- package/node_modules/three/src/nodes/display/BlendModes.js +235 -0
- package/node_modules/three/src/nodes/display/BumpMapNode.js +117 -0
- package/node_modules/three/src/nodes/display/ColorAdjustment.js +141 -0
- package/node_modules/three/src/nodes/display/ColorSpaceFunctions.js +54 -0
- package/node_modules/three/src/nodes/display/ColorSpaceNode.js +164 -0
- package/node_modules/three/src/nodes/display/FrontFacingNode.js +102 -0
- package/node_modules/three/src/nodes/display/NormalMapNode.js +118 -0
- package/node_modules/three/src/nodes/display/PassNode.js +946 -0
- package/node_modules/three/src/nodes/display/PosterizeNode.js +65 -0
- package/node_modules/three/src/nodes/display/RenderOutputNode.js +150 -0
- package/node_modules/three/src/nodes/display/ScreenNode.js +290 -0
- package/node_modules/three/src/nodes/display/ToneMappingFunctions.js +242 -0
- package/node_modules/three/src/nodes/display/ToneMappingNode.js +147 -0
- package/node_modules/three/src/nodes/display/ToonOutlinePassNode.js +191 -0
- package/node_modules/three/src/nodes/display/ViewportDepthNode.js +294 -0
- package/node_modules/three/src/nodes/display/ViewportDepthTextureNode.js +67 -0
- package/node_modules/three/src/nodes/display/ViewportSharedTextureNode.js +73 -0
- package/node_modules/three/src/nodes/display/ViewportTextureNode.js +228 -0
- package/node_modules/three/src/nodes/fog/Fog.js +114 -0
- package/node_modules/three/src/nodes/functions/BSDF/BRDF_GGX.js +55 -0
- package/node_modules/three/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/node_modules/three/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/node_modules/three/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +9 -9
- package/node_modules/three/src/nodes/functions/BSDF/DFGApprox.js +71 -0
- package/node_modules/three/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +2 -2
- package/node_modules/three/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/node_modules/three/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/node_modules/three/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/node_modules/three/src/nodes/functions/BSDF/LTC.js +175 -0
- package/node_modules/three/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/node_modules/three/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -4
- package/node_modules/three/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/node_modules/three/src/nodes/functions/BasicLightingModel.js +100 -0
- package/node_modules/three/src/nodes/functions/PhongLightingModel.js +99 -0
- package/node_modules/three/src/nodes/functions/PhysicalLightingModel.js +797 -0
- package/node_modules/three/src/nodes/functions/ShadowMaskModel.js +58 -0
- package/node_modules/three/src/nodes/functions/ToonLightingModel.js +70 -0
- package/node_modules/three/src/nodes/functions/VolumetricLightingModel.js +183 -0
- package/node_modules/three/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
- package/node_modules/three/src/nodes/functions/material/getGeometryRoughness.js +19 -0
- package/node_modules/three/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
- package/node_modules/three/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/node_modules/three/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/node_modules/three/src/nodes/geometry/RangeNode.js +208 -0
- package/node_modules/three/src/nodes/gpgpu/AtomicFunctionNode.js +274 -0
- package/node_modules/three/src/nodes/gpgpu/BarrierNode.js +89 -0
- package/node_modules/three/src/nodes/gpgpu/ComputeBuiltinNode.js +228 -0
- package/node_modules/three/src/nodes/gpgpu/ComputeNode.js +284 -0
- package/node_modules/three/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/node_modules/three/src/nodes/gpgpu/WorkgroupInfoNode.js +234 -0
- package/node_modules/three/src/nodes/lighting/AONode.js +45 -0
- package/node_modules/three/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +16 -8
- package/node_modules/three/src/nodes/lighting/AnalyticLightNode.js +256 -0
- package/node_modules/three/src/nodes/lighting/BasicEnvironmentNode.js +49 -0
- package/node_modules/three/src/nodes/lighting/BasicLightMapNode.js +49 -0
- package/node_modules/three/src/nodes/lighting/DirectionalLightNode.js +39 -0
- package/node_modules/three/src/nodes/lighting/EnvironmentNode.js +153 -0
- package/node_modules/three/src/nodes/lighting/HemisphereLightNode.js +87 -0
- package/node_modules/three/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +20 -10
- package/node_modules/three/src/nodes/lighting/IrradianceNode.js +44 -0
- package/node_modules/three/src/nodes/lighting/LightProbeNode.js +73 -0
- package/node_modules/three/src/nodes/lighting/LightUtils.js +25 -0
- package/node_modules/three/src/nodes/lighting/LightingContextNode.js +115 -0
- package/node_modules/three/src/nodes/lighting/LightingNode.js +36 -0
- package/node_modules/three/src/nodes/lighting/LightsNode.js +453 -0
- package/node_modules/three/src/nodes/lighting/PointLightNode.js +102 -0
- package/node_modules/three/src/nodes/lighting/PointShadowNode.js +312 -0
- package/node_modules/three/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/node_modules/three/src/nodes/lighting/RectAreaLightNode.js +133 -0
- package/node_modules/three/src/nodes/lighting/ShadowBaseNode.js +81 -0
- package/node_modules/three/src/nodes/lighting/ShadowFilterNode.js +276 -0
- package/node_modules/three/src/nodes/lighting/ShadowNode.js +811 -0
- package/node_modules/three/src/nodes/lighting/SpotLightNode.js +168 -0
- package/node_modules/three/src/nodes/materialx/MaterialXNodes.js +197 -0
- package/node_modules/three/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +43 -46
- package/node_modules/three/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +625 -564
- package/node_modules/three/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +3 -9
- package/node_modules/three/src/nodes/math/BitcastNode.js +156 -0
- package/node_modules/three/src/nodes/math/ConditionalNode.js +245 -0
- package/node_modules/three/src/nodes/math/Hash.js +21 -0
- package/node_modules/three/src/nodes/math/MathNode.js +1167 -0
- package/node_modules/three/src/nodes/math/MathUtils.js +54 -0
- package/node_modules/three/src/nodes/math/OperatorNode.js +751 -0
- package/node_modules/three/{examples/jsm → src}/nodes/math/TriNoise3D.js +34 -34
- package/node_modules/three/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +23 -7
- package/node_modules/three/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +11 -0
- package/node_modules/three/src/nodes/pmrem/PMREMNode.js +397 -0
- package/node_modules/three/src/nodes/pmrem/PMREMUtils.js +403 -0
- package/node_modules/three/src/nodes/procedural/Checker.js +22 -0
- package/node_modules/three/src/nodes/shapes/Shapes.js +33 -0
- package/node_modules/three/src/nodes/tsl/TSLBase.js +36 -0
- package/node_modules/three/src/nodes/tsl/TSLCore.js +1229 -0
- package/node_modules/three/src/nodes/utils/ArrayElementNode.js +77 -0
- package/node_modules/three/src/nodes/utils/ConvertNode.js +100 -0
- package/node_modules/three/src/nodes/utils/CubeMapNode.js +237 -0
- package/node_modules/three/src/nodes/utils/DebugNode.js +83 -0
- package/node_modules/three/src/nodes/utils/Discard.js +24 -0
- package/node_modules/three/src/nodes/utils/EquirectUV.js +27 -0
- package/node_modules/three/src/nodes/utils/EventNode.js +119 -0
- package/node_modules/three/src/nodes/utils/FlipNode.js +106 -0
- package/node_modules/three/src/nodes/utils/FunctionOverloadingNode.js +170 -0
- package/node_modules/three/src/nodes/utils/JoinNode.js +117 -0
- package/node_modules/three/src/nodes/utils/LoopNode.js +349 -0
- package/node_modules/three/src/nodes/utils/MatcapUV.js +22 -0
- package/node_modules/three/src/nodes/utils/MaxMipLevelNode.js +103 -0
- package/node_modules/three/src/nodes/utils/MemberNode.js +120 -0
- package/node_modules/three/src/nodes/utils/Oscillators.js +41 -0
- package/node_modules/three/src/nodes/utils/Packing.js +21 -0
- package/node_modules/three/src/nodes/utils/PostProcessingUtils.js +122 -0
- package/node_modules/three/src/nodes/utils/RTTNode.js +289 -0
- package/node_modules/three/src/nodes/utils/ReflectorNode.js +630 -0
- package/node_modules/three/src/nodes/utils/RemapNode.js +125 -0
- package/node_modules/three/{examples/jsm → src}/nodes/utils/RotateNode.js +48 -13
- package/node_modules/three/src/nodes/utils/SampleNode.js +91 -0
- package/node_modules/three/{examples/jsm → src}/nodes/utils/SetNode.js +50 -4
- package/node_modules/three/{examples/jsm → src}/nodes/utils/SplitNode.js +73 -6
- package/node_modules/three/src/nodes/utils/SpriteSheetUVNode.js +90 -0
- package/node_modules/three/src/nodes/utils/SpriteUtils.js +63 -0
- package/node_modules/three/src/nodes/utils/StorageArrayElementNode.js +143 -0
- package/node_modules/three/src/nodes/utils/Timer.js +26 -0
- package/node_modules/three/src/nodes/utils/TriplanarTextures.js +65 -0
- package/node_modules/three/src/nodes/utils/UVUtils.js +39 -0
- package/node_modules/three/src/nodes/utils/ViewportUtils.js +26 -0
- package/node_modules/three/src/objects/BatchedMesh.js +940 -305
- package/node_modules/three/src/objects/Bone.js +24 -0
- package/node_modules/three/src/objects/ClippingGroup.js +68 -0
- package/node_modules/three/src/objects/Group.js +24 -0
- package/node_modules/three/src/objects/InstancedMesh.js +182 -1
- package/node_modules/three/src/objects/LOD.js +120 -5
- package/node_modules/three/src/objects/Line.js +151 -44
- package/node_modules/three/src/objects/LineLoop.js +20 -0
- package/node_modules/three/src/objects/LineSegments.js +20 -1
- package/node_modules/three/src/objects/Mesh.js +91 -24
- package/node_modules/three/src/objects/Points.js +62 -0
- package/node_modules/three/src/objects/Skeleton.js +111 -5
- package/node_modules/three/src/objects/SkinnedMesh.js +102 -6
- package/node_modules/three/src/objects/Sprite.js +65 -1
- package/node_modules/three/src/renderers/WebGL3DRenderTarget.js +26 -0
- package/node_modules/three/src/renderers/WebGLArrayRenderTarget.js +26 -0
- package/node_modules/three/src/renderers/WebGLCubeRenderTarget.js +42 -15
- package/node_modules/three/src/renderers/WebGLRenderTarget.js +19 -0
- package/node_modules/three/src/renderers/WebGLRenderer.js +1222 -318
- package/node_modules/three/src/renderers/common/Animation.js +159 -0
- package/node_modules/three/{examples/jsm → src}/renderers/common/Attributes.js +45 -2
- package/node_modules/three/src/renderers/common/Backend.js +748 -0
- package/node_modules/three/src/renderers/common/Background.js +212 -0
- package/node_modules/three/src/renderers/common/BindGroup.js +61 -0
- package/node_modules/three/src/renderers/common/Binding.js +60 -0
- package/node_modules/three/src/renderers/common/Bindings.js +379 -0
- package/node_modules/three/src/renderers/common/Buffer.js +87 -0
- package/node_modules/three/src/renderers/common/BufferUtils.js +58 -0
- package/node_modules/three/src/renderers/common/BundleGroup.js +83 -0
- package/node_modules/three/src/renderers/common/CanvasTarget.js +341 -0
- package/node_modules/three/src/renderers/common/ChainMap.js +98 -0
- package/node_modules/three/src/renderers/common/ClippingContext.js +262 -0
- package/node_modules/three/src/renderers/common/Color4.js +77 -0
- package/node_modules/three/src/renderers/common/ComputePipeline.js +41 -0
- package/node_modules/three/{examples/jsm → src}/renderers/common/Constants.js +2 -1
- package/node_modules/three/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +43 -5
- package/node_modules/three/src/renderers/common/DataMap.js +90 -0
- package/node_modules/three/src/renderers/common/Geometries.js +370 -0
- package/node_modules/three/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/node_modules/three/src/renderers/common/Info.js +172 -0
- package/node_modules/three/src/renderers/common/InspectorBase.js +146 -0
- package/node_modules/three/src/renderers/common/Lighting.js +73 -0
- package/node_modules/three/src/renderers/common/Pipeline.js +35 -0
- package/node_modules/three/{examples/jsm → src}/renderers/common/Pipelines.js +150 -7
- package/node_modules/three/src/renderers/common/PostProcessing.js +226 -0
- package/node_modules/three/src/renderers/common/ProgrammableStage.js +78 -0
- package/node_modules/three/src/renderers/common/QuadMesh.js +112 -0
- package/node_modules/three/src/renderers/common/RenderBundle.js +24 -0
- package/node_modules/three/src/renderers/common/RenderBundles.js +67 -0
- package/node_modules/three/src/renderers/common/RenderContext.js +265 -0
- package/node_modules/three/src/renderers/common/RenderContexts.js +116 -0
- package/node_modules/three/src/renderers/common/RenderList.js +404 -0
- package/node_modules/three/src/renderers/common/RenderLists.js +77 -0
- package/node_modules/three/src/renderers/common/RenderObject.js +903 -0
- package/node_modules/three/src/renderers/common/RenderObjects.js +202 -0
- package/node_modules/three/src/renderers/common/RenderPipeline.js +40 -0
- package/node_modules/three/src/renderers/common/Renderer.js +3290 -0
- package/node_modules/three/src/renderers/common/RendererUtils.js +200 -0
- package/node_modules/three/src/renderers/common/SampledTexture.js +152 -0
- package/node_modules/three/src/renderers/common/Sampler.js +165 -0
- package/node_modules/three/src/renderers/common/Storage3DTexture.js +100 -0
- package/node_modules/three/src/renderers/common/StorageArrayTexture.js +84 -0
- package/node_modules/three/src/renderers/common/StorageBuffer.js +41 -0
- package/node_modules/three/src/renderers/common/StorageBufferAttribute.js +46 -0
- package/node_modules/three/src/renderers/common/StorageInstancedBufferAttribute.js +46 -0
- package/node_modules/three/src/renderers/common/StorageTexture.js +86 -0
- package/node_modules/three/src/renderers/common/Textures.js +544 -0
- package/node_modules/three/src/renderers/common/TimestampQueryPool.js +161 -0
- package/node_modules/three/src/renderers/common/Uniform.js +367 -0
- package/node_modules/three/src/renderers/common/UniformBuffer.js +34 -0
- package/node_modules/three/src/renderers/common/UniformsGroup.js +487 -0
- package/node_modules/three/src/renderers/common/XRManager.js +1676 -0
- package/node_modules/three/src/renderers/common/XRRenderTarget.js +91 -0
- package/node_modules/three/src/renderers/common/extras/PMREMGenerator.js +1034 -0
- package/node_modules/three/src/renderers/common/nodes/NodeBuilderState.js +152 -0
- package/node_modules/three/src/renderers/common/nodes/NodeLibrary.js +196 -0
- package/node_modules/three/src/renderers/common/nodes/NodeSampledTexture.js +140 -0
- package/node_modules/three/src/renderers/common/nodes/NodeSampler.js +62 -0
- package/node_modules/three/src/renderers/common/nodes/NodeStorageBuffer.js +61 -0
- package/node_modules/three/src/renderers/common/nodes/NodeUniform.js +418 -0
- package/node_modules/three/src/renderers/common/nodes/NodeUniformBuffer.js +53 -0
- package/node_modules/three/src/renderers/common/nodes/NodeUniformsGroup.js +51 -0
- package/node_modules/three/src/renderers/common/nodes/Nodes.js +840 -0
- package/node_modules/three/src/renderers/shaders/DFGLUTData.js +64 -0
- package/node_modules/three/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +31 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -33
- package/node_modules/three/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -22
- package/node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +2 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +3 -3
- package/node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/node_modules/three/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +55 -20
- package/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +3 -11
- package/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +3 -17
- package/node_modules/three/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +3 -3
- package/node_modules/three/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
- package/node_modules/three/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +12 -24
- package/node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/node_modules/three/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
- package/node_modules/three/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +59 -36
- package/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
- package/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
- package/node_modules/three/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +33 -2
- package/node_modules/three/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/node_modules/three/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/node_modules/three/src/renderers/shaders/ShaderChunk.js +2 -2
- package/node_modules/three/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/node_modules/three/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
- package/node_modules/three/src/renderers/shaders/ShaderLib/depth.glsl.js +21 -2
- package/node_modules/three/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +5 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/node_modules/three/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/node_modules/three/src/renderers/shaders/ShaderLib.js +4 -2
- package/node_modules/three/src/renderers/shaders/UniformsLib.js +6 -4
- package/node_modules/three/src/renderers/shaders/UniformsUtils.js +31 -3
- package/node_modules/three/src/renderers/webgl/WebGLAttributes.js +46 -38
- package/node_modules/three/src/renderers/webgl/WebGLBackground.js +69 -5
- package/node_modules/three/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/node_modules/three/src/renderers/webgl/WebGLBufferRenderer.js +19 -22
- package/node_modules/three/src/renderers/webgl/WebGLCapabilities.js +39 -14
- package/node_modules/three/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/node_modules/three/src/renderers/webgl/WebGLExtensions.js +8 -44
- package/node_modules/three/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/node_modules/three/src/renderers/webgl/WebGLIndexedBufferRenderer.js +19 -21
- package/node_modules/three/src/renderers/webgl/WebGLInfo.js +3 -1
- package/node_modules/three/src/renderers/webgl/WebGLLights.js +21 -44
- package/node_modules/three/src/renderers/webgl/WebGLMaterials.js +33 -9
- package/node_modules/three/src/renderers/webgl/WebGLMorphtargets.js +78 -210
- package/node_modules/three/src/renderers/webgl/WebGLProgram.js +103 -121
- package/node_modules/three/src/renderers/webgl/WebGLPrograms.js +32 -26
- package/node_modules/three/src/renderers/webgl/WebGLProperties.js +7 -0
- package/node_modules/three/src/renderers/webgl/WebGLRenderStates.js +15 -9
- package/node_modules/three/src/renderers/webgl/WebGLShadowMap.js +41 -29
- package/node_modules/three/src/renderers/webgl/WebGLState.js +104 -100
- package/node_modules/three/src/renderers/webgl/WebGLTextures.js +567 -408
- package/node_modules/three/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/node_modules/three/src/renderers/webgl/WebGLUniformsGroups.js +13 -11
- package/node_modules/three/src/renderers/webgl/WebGLUtils.js +11 -81
- package/node_modules/three/src/renderers/webgl-fallback/WebGLBackend.js +2612 -0
- package/node_modules/three/src/renderers/webgl-fallback/WebGLBufferRenderer.js +140 -0
- package/node_modules/three/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +1577 -0
- package/node_modules/three/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +76 -3
- package/node_modules/three/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +64 -0
- package/node_modules/three/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +5 -3
- package/node_modules/three/src/renderers/webgl-fallback/utils/WebGLExtensions.js +83 -0
- package/node_modules/three/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +427 -21
- package/node_modules/three/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1309 -0
- package/node_modules/three/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
- package/node_modules/three/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +72 -43
- package/node_modules/three/src/renderers/webgpu/WebGPUBackend.js +2482 -0
- package/node_modules/three/src/renderers/webgpu/WebGPURenderer.Nodes.js +69 -0
- package/node_modules/three/src/renderers/webgpu/WebGPURenderer.js +106 -0
- package/node_modules/three/src/renderers/webgpu/nodes/BasicNodeLibrary.js +66 -0
- package/node_modules/three/src/renderers/webgpu/nodes/StandardNodeLibrary.js +100 -0
- package/node_modules/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +2247 -0
- package/node_modules/three/src/renderers/webgpu/nodes/WGSLNodeFunction.js +187 -0
- package/node_modules/three/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/node_modules/three/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +449 -0
- package/node_modules/three/src/renderers/webgpu/utils/WebGPUBindingUtils.js +485 -0
- package/node_modules/three/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +24 -4
- package/node_modules/three/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +289 -72
- package/node_modules/three/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +160 -8
- package/node_modules/three/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1576 -0
- package/node_modules/three/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
- package/node_modules/three/src/renderers/webgpu/utils/WebGPUUtils.js +247 -0
- package/node_modules/three/src/renderers/webxr/WebXRController.js +87 -2
- package/node_modules/three/src/renderers/webxr/WebXRDepthSensing.js +63 -13
- package/node_modules/three/src/renderers/webxr/WebXRManager.js +323 -44
- package/node_modules/three/src/scenes/Fog.js +60 -0
- package/node_modules/three/src/scenes/FogExp2.js +51 -0
- package/node_modules/three/src/scenes/Scene.js +103 -1
- package/node_modules/three/src/textures/CanvasTexture.js +28 -0
- package/node_modules/three/src/textures/CompressedArrayTexture.js +71 -0
- package/node_modules/three/src/textures/CompressedCubeTexture.js +29 -0
- package/node_modules/three/src/textures/CompressedTexture.js +64 -6
- package/node_modules/three/src/textures/CubeTexture.js +52 -4
- package/node_modules/three/src/textures/Data3DTexture.js +79 -2
- package/node_modules/three/src/textures/DataArrayTexture.js +107 -0
- package/node_modules/three/src/textures/DataTexture.js +65 -0
- package/node_modules/three/src/textures/DepthTexture.js +59 -13
- package/node_modules/three/src/textures/ExternalTexture.js +56 -0
- package/node_modules/three/src/textures/FramebufferTexture.js +62 -0
- package/node_modules/three/src/textures/Source.js +106 -4
- package/node_modules/three/src/textures/Texture.js +490 -27
- package/node_modules/three/src/textures/VideoFrameTexture.js +72 -0
- package/node_modules/three/src/textures/VideoTexture.js +78 -6
- package/node_modules/three/src/utils.js +128 -3
- package/package.json +3 -2
- package/node_modules/three/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/node_modules/three/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/node_modules/three/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/node_modules/three/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/node_modules/three/examples/jsm/exporters/MMDExporter.js +0 -217
- package/node_modules/three/examples/jsm/geometries/InstancedPointsGeometry.js +0 -174
- package/node_modules/three/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/node_modules/three/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/node_modules/three/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/node_modules/three/examples/jsm/lights/IESSpotLight.js +0 -25
- package/node_modules/three/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/node_modules/three/examples/jsm/loaders/MMDLoader.js +0 -2276
- package/node_modules/three/examples/jsm/loaders/RGBMLoader.js +0 -1065
- package/node_modules/three/examples/jsm/loaders/TiltLoader.js +0 -520
- package/node_modules/three/examples/jsm/misc/Timer.js +0 -128
- package/node_modules/three/examples/jsm/nodes/Nodes.js +0 -193
- package/node_modules/three/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/node_modules/three/examples/jsm/nodes/accessors/BufferAttributeNode.js +0 -127
- package/node_modules/three/examples/jsm/nodes/accessors/BufferNode.js +0 -30
- package/node_modules/three/examples/jsm/nodes/accessors/CameraNode.js +0 -119
- package/node_modules/three/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/node_modules/three/examples/jsm/nodes/accessors/InstanceNode.js +0 -71
- package/node_modules/three/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/node_modules/three/examples/jsm/nodes/accessors/MaterialNode.js +0 -314
- package/node_modules/three/examples/jsm/nodes/accessors/MaterialReferenceNode.js +0 -51
- package/node_modules/three/examples/jsm/nodes/accessors/ModelNode.js +0 -33
- package/node_modules/three/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +0 -39
- package/node_modules/three/examples/jsm/nodes/accessors/NormalNode.js +0 -96
- package/node_modules/three/examples/jsm/nodes/accessors/Object3DNode.js +0 -150
- package/node_modules/three/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/node_modules/three/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/node_modules/three/examples/jsm/nodes/accessors/ReferenceNode.js +0 -102
- package/node_modules/three/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/node_modules/three/examples/jsm/nodes/accessors/SceneNode.js +0 -52
- package/node_modules/three/examples/jsm/nodes/accessors/SkinningNode.js +0 -103
- package/node_modules/three/examples/jsm/nodes/accessors/StorageBufferNode.js +0 -54
- package/node_modules/three/examples/jsm/nodes/accessors/TangentNode.js +0 -103
- package/node_modules/three/examples/jsm/nodes/accessors/TextureNode.js +0 -367
- package/node_modules/three/examples/jsm/nodes/accessors/TextureSizeNode.js +0 -35
- package/node_modules/three/examples/jsm/nodes/accessors/TextureStoreNode.js +0 -82
- package/node_modules/three/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/node_modules/three/examples/jsm/nodes/accessors/UserDataNode.js +0 -29
- package/node_modules/three/examples/jsm/nodes/accessors/VertexColorNode.js +0 -70
- package/node_modules/three/examples/jsm/nodes/code/CodeNode.js +0 -78
- package/node_modules/three/examples/jsm/nodes/code/ExpressionNode.js +0 -37
- package/node_modules/three/examples/jsm/nodes/code/FunctionCallNode.js +0 -96
- package/node_modules/three/examples/jsm/nodes/code/FunctionNode.js +0 -138
- package/node_modules/three/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/node_modules/three/examples/jsm/nodes/core/AssignNode.js +0 -72
- package/node_modules/three/examples/jsm/nodes/core/AttributeNode.js +0 -108
- package/node_modules/three/examples/jsm/nodes/core/BypassNode.js +0 -45
- package/node_modules/three/examples/jsm/nodes/core/CacheNode.js +0 -49
- package/node_modules/three/examples/jsm/nodes/core/ConstNode.js +0 -32
- package/node_modules/three/examples/jsm/nodes/core/ContextNode.js +0 -61
- package/node_modules/three/examples/jsm/nodes/core/IndexNode.js +0 -66
- package/node_modules/three/examples/jsm/nodes/core/InputNode.js +0 -83
- package/node_modules/three/examples/jsm/nodes/core/LightingModel.js +0 -17
- package/node_modules/three/examples/jsm/nodes/core/Node.js +0 -483
- package/node_modules/three/examples/jsm/nodes/core/NodeAttribute.js +0 -15
- package/node_modules/three/examples/jsm/nodes/core/NodeBuilder.js +0 -1256
- package/node_modules/three/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/node_modules/three/examples/jsm/nodes/core/NodeCode.js +0 -15
- package/node_modules/three/examples/jsm/nodes/core/NodeFrame.js +0 -143
- package/node_modules/three/examples/jsm/nodes/core/NodeFunction.js +0 -22
- package/node_modules/three/examples/jsm/nodes/core/NodeFunctionInput.js +0 -17
- package/node_modules/three/examples/jsm/nodes/core/NodeKeywords.js +0 -80
- package/node_modules/three/examples/jsm/nodes/core/NodeParser.js +0 -11
- package/node_modules/three/examples/jsm/nodes/core/NodeUniform.js +0 -40
- package/node_modules/three/examples/jsm/nodes/core/NodeUtils.js +0 -210
- package/node_modules/three/examples/jsm/nodes/core/NodeVar.js +0 -14
- package/node_modules/three/examples/jsm/nodes/core/NodeVarying.js +0 -17
- package/node_modules/three/examples/jsm/nodes/core/OutputStructNode.js +0 -62
- package/node_modules/three/examples/jsm/nodes/core/ParameterNode.js +0 -33
- package/node_modules/three/examples/jsm/nodes/core/PropertyNode.js +0 -72
- package/node_modules/three/examples/jsm/nodes/core/StackNode.js +0 -89
- package/node_modules/three/examples/jsm/nodes/core/StructTypeNode.js +0 -24
- package/node_modules/three/examples/jsm/nodes/core/TempNode.js +0 -58
- package/node_modules/three/examples/jsm/nodes/core/UniformGroup.js +0 -13
- package/node_modules/three/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- package/node_modules/three/examples/jsm/nodes/core/UniformNode.js +0 -80
- package/node_modules/three/examples/jsm/nodes/core/VarNode.js +0 -60
- package/node_modules/three/examples/jsm/nodes/core/VaryingNode.js +0 -65
- package/node_modules/three/examples/jsm/nodes/core/constants.js +0 -28
- package/node_modules/three/examples/jsm/nodes/display/AfterImageNode.js +0 -148
- package/node_modules/three/examples/jsm/nodes/display/AnamorphicNode.js +0 -148
- package/node_modules/three/examples/jsm/nodes/display/BlendModeNode.js +0 -99
- package/node_modules/three/examples/jsm/nodes/display/BumpMapNode.js +0 -99
- package/node_modules/three/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -99
- package/node_modules/three/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
- package/node_modules/three/examples/jsm/nodes/display/FrontFacingNode.js +0 -27
- package/node_modules/three/examples/jsm/nodes/display/GaussianBlurNode.js +0 -190
- package/node_modules/three/examples/jsm/nodes/display/NormalMapNode.js +0 -108
- package/node_modules/three/examples/jsm/nodes/display/PassNode.js +0 -183
- package/node_modules/three/examples/jsm/nodes/display/PosterizeNode.js +0 -32
- package/node_modules/three/examples/jsm/nodes/display/ToneMappingNode.js +0 -184
- package/node_modules/three/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/node_modules/three/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/node_modules/three/examples/jsm/nodes/display/ViewportNode.js +0 -134
- package/node_modules/three/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -31
- package/node_modules/three/examples/jsm/nodes/display/ViewportTextureNode.js +0 -75
- package/node_modules/three/examples/jsm/nodes/fog/FogExp2Node.js +0 -35
- package/node_modules/three/examples/jsm/nodes/fog/FogNode.js +0 -38
- package/node_modules/three/examples/jsm/nodes/fog/FogRangeNode.js +0 -34
- package/node_modules/three/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +0 -40
- package/node_modules/three/examples/jsm/nodes/functions/BSDF/DFGApprox.js +0 -30
- package/node_modules/three/examples/jsm/nodes/functions/PhongLightingModel.js +0 -67
- package/node_modules/three/examples/jsm/nodes/functions/PhysicalLightingModel.js +0 -393
- package/node_modules/three/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
- package/node_modules/three/examples/jsm/nodes/geometry/RangeNode.js +0 -104
- package/node_modules/three/examples/jsm/nodes/gpgpu/ComputeNode.js +0 -85
- package/node_modules/three/examples/jsm/nodes/lighting/AONode.js +0 -27
- package/node_modules/three/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -241
- package/node_modules/three/examples/jsm/nodes/lighting/DirectionalLightNode.js +0 -40
- package/node_modules/three/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -181
- package/node_modules/three/examples/jsm/nodes/lighting/HemisphereLightNode.js +0 -55
- package/node_modules/three/examples/jsm/nodes/lighting/LightNode.js +0 -57
- package/node_modules/three/examples/jsm/nodes/lighting/LightUtils.js +0 -17
- package/node_modules/three/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/node_modules/three/examples/jsm/nodes/lighting/LightingNode.js +0 -21
- package/node_modules/three/examples/jsm/nodes/lighting/LightsNode.js +0 -188
- package/node_modules/three/examples/jsm/nodes/lighting/PointLightNode.js +0 -68
- package/node_modules/three/examples/jsm/nodes/lighting/SpotLightNode.js +0 -89
- package/node_modules/three/examples/jsm/nodes/loaders/NodeLoader.js +0 -108
- package/node_modules/three/examples/jsm/nodes/loaders/NodeMaterialLoader.js +0 -59
- package/node_modules/three/examples/jsm/nodes/loaders/NodeObjectLoader.js +0 -70
- package/node_modules/three/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/node_modules/three/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
- package/node_modules/three/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +0 -54
- package/node_modules/three/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/node_modules/three/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
- package/node_modules/three/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/node_modules/three/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/node_modules/three/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +0 -155
- package/node_modules/three/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +0 -84
- package/node_modules/three/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +0 -80
- package/node_modules/three/examples/jsm/nodes/materials/NodeMaterial.js +0 -570
- package/node_modules/three/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -39
- package/node_modules/three/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -90
- package/node_modules/three/examples/jsm/nodes/materialx/MaterialXNodes.js +0 -68
- package/node_modules/three/examples/jsm/nodes/math/CondNode.js +0 -86
- package/node_modules/three/examples/jsm/nodes/math/HashNode.js +0 -34
- package/node_modules/three/examples/jsm/nodes/math/MathNode.js +0 -371
- package/node_modules/three/examples/jsm/nodes/math/MathUtils.js +0 -15
- package/node_modules/three/examples/jsm/nodes/math/OperatorNode.js +0 -274
- package/node_modules/three/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/node_modules/three/examples/jsm/nodes/shadernode/ShaderNode.js +0 -634
- package/node_modules/three/examples/jsm/nodes/utils/ArrayElementNode.js +0 -41
- package/node_modules/three/examples/jsm/nodes/utils/ConvertNode.js +0 -65
- package/node_modules/three/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/node_modules/three/examples/jsm/nodes/utils/EquirectUVNode.js +0 -33
- package/node_modules/three/examples/jsm/nodes/utils/FunctionOverloadingNode.js +0 -95
- package/node_modules/three/examples/jsm/nodes/utils/JoinNode.js +0 -61
- package/node_modules/three/examples/jsm/nodes/utils/LoopNode.js +0 -198
- package/node_modules/three/examples/jsm/nodes/utils/MatcapUVNode.js +0 -30
- package/node_modules/three/examples/jsm/nodes/utils/MaxMipLevelNode.js +0 -46
- package/node_modules/three/examples/jsm/nodes/utils/OscNode.js +0 -81
- package/node_modules/three/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/node_modules/three/examples/jsm/nodes/utils/ReflectorNode.js +0 -227
- package/node_modules/three/examples/jsm/nodes/utils/RemapNode.js +0 -42
- package/node_modules/three/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- package/node_modules/three/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/node_modules/three/examples/jsm/nodes/utils/SpriteSheetUVNode.js +0 -41
- package/node_modules/three/examples/jsm/nodes/utils/TimerNode.js +0 -94
- package/node_modules/three/examples/jsm/nodes/utils/TriplanarTexturesNode.js +0 -62
- package/node_modules/three/examples/jsm/objects/InstancedPoints.js +0 -21
- package/node_modules/three/examples/jsm/objects/QuadMesh.js +0 -66
- package/node_modules/three/examples/jsm/renderers/common/Animation.js +0 -47
- package/node_modules/three/examples/jsm/renderers/common/Backend.js +0 -195
- package/node_modules/three/examples/jsm/renderers/common/Background.js +0 -134
- package/node_modules/three/examples/jsm/renderers/common/Binding.js +0 -25
- package/node_modules/three/examples/jsm/renderers/common/Bindings.js +0 -173
- package/node_modules/three/examples/jsm/renderers/common/Buffer.js +0 -38
- package/node_modules/three/examples/jsm/renderers/common/BufferUtils.js +0 -33
- package/node_modules/three/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/node_modules/three/examples/jsm/renderers/common/Color4.js +0 -37
- package/node_modules/three/examples/jsm/renderers/common/ComputePipeline.js +0 -17
- package/node_modules/three/examples/jsm/renderers/common/DataMap.js +0 -54
- package/node_modules/three/examples/jsm/renderers/common/Geometries.js +0 -215
- package/node_modules/three/examples/jsm/renderers/common/Info.js +0 -107
- package/node_modules/three/examples/jsm/renderers/common/Pipeline.js +0 -13
- package/node_modules/three/examples/jsm/renderers/common/PostProcessing.js +0 -25
- package/node_modules/three/examples/jsm/renderers/common/ProgrammableStage.js +0 -20
- package/node_modules/three/examples/jsm/renderers/common/RenderContext.js +0 -41
- package/node_modules/three/examples/jsm/renderers/common/RenderContexts.js +0 -74
- package/node_modules/three/examples/jsm/renderers/common/RenderList.js +0 -186
- package/node_modules/three/examples/jsm/renderers/common/RenderLists.js +0 -38
- package/node_modules/three/examples/jsm/renderers/common/RenderObject.js +0 -178
- package/node_modules/three/examples/jsm/renderers/common/RenderObjects.js +0 -91
- package/node_modules/three/examples/jsm/renderers/common/RenderPipeline.js +0 -16
- package/node_modules/three/examples/jsm/renderers/common/Renderer.js +0 -1247
- package/node_modules/three/examples/jsm/renderers/common/SampledTexture.js +0 -83
- package/node_modules/three/examples/jsm/renderers/common/Sampler.js +0 -18
- package/node_modules/three/examples/jsm/renderers/common/StorageBuffer.js +0 -17
- package/node_modules/three/examples/jsm/renderers/common/StorageBufferAttribute.js +0 -17
- package/node_modules/three/examples/jsm/renderers/common/StorageTexture.js +0 -20
- package/node_modules/three/examples/jsm/renderers/common/Textures.js +0 -354
- package/node_modules/three/examples/jsm/renderers/common/Uniform.js +0 -140
- package/node_modules/three/examples/jsm/renderers/common/UniformBuffer.js +0 -15
- package/node_modules/three/examples/jsm/renderers/common/UniformsGroup.js +0 -299
- package/node_modules/three/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/node_modules/three/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +0 -49
- package/node_modules/three/examples/jsm/renderers/common/nodes/NodeSampler.js +0 -15
- package/node_modules/three/examples/jsm/renderers/common/nodes/NodeUniform.js +0 -135
- package/node_modules/three/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +0 -44
- package/node_modules/three/examples/jsm/renderers/common/nodes/Nodes.js +0 -495
- package/node_modules/three/examples/jsm/renderers/webgl/WebGLBackend.js +0 -1362
- package/node_modules/three/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +0 -679
- package/node_modules/three/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +0 -36
- package/node_modules/three/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +0 -36
- package/node_modules/three/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +0 -647
- package/node_modules/three/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -320
- package/node_modules/three/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
- package/node_modules/three/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -794
- package/node_modules/three/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
- package/node_modules/three/examples/jsm/renderers/webgpu/WebGPUBackend.js +0 -1321
- package/node_modules/three/examples/jsm/renderers/webgpu/WebGPURenderer.js +0 -53
- package/node_modules/three/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +0 -1103
- package/node_modules/three/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- package/node_modules/three/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +0 -287
- package/node_modules/three/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +0 -244
- package/node_modules/three/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +0 -1040
- package/node_modules/three/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +0 -93
- package/node_modules/three/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/node_modules/three/examples/jsm/utils/GPUStatsPanel.js +0 -128
- package/node_modules/three/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/node_modules/three/src/renderers/WebGL1Renderer.js +0 -7
- package/node_modules/three/src/renderers/WebGLMultipleRenderTargets.js +0 -82
- package/node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
- /package/node_modules/three/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
|
@@ -0,0 +1,3081 @@
|
|
|
1
|
+
import NodeUniform from './NodeUniform.js';
|
|
2
|
+
import NodeAttribute from './NodeAttribute.js';
|
|
3
|
+
import NodeVarying from './NodeVarying.js';
|
|
4
|
+
import NodeVar from './NodeVar.js';
|
|
5
|
+
import NodeCode from './NodeCode.js';
|
|
6
|
+
import NodeCache from './NodeCache.js';
|
|
7
|
+
import ParameterNode from './ParameterNode.js';
|
|
8
|
+
import StructType from './StructType.js';
|
|
9
|
+
import FunctionNode from '../code/FunctionNode.js';
|
|
10
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
11
|
+
import { getTypeFromLength } from './NodeUtils.js';
|
|
12
|
+
import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
NumberNodeUniform, Vector2NodeUniform, Vector3NodeUniform, Vector4NodeUniform,
|
|
16
|
+
ColorNodeUniform, Matrix2NodeUniform, Matrix3NodeUniform, Matrix4NodeUniform
|
|
17
|
+
} from '../../renderers/common/nodes/NodeUniform.js';
|
|
18
|
+
|
|
19
|
+
import { stack } from './StackNode.js';
|
|
20
|
+
import { getCurrentStack, setCurrentStack } from '../tsl/TSLBase.js';
|
|
21
|
+
|
|
22
|
+
import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
|
|
23
|
+
import ChainMap from '../../renderers/common/ChainMap.js';
|
|
24
|
+
|
|
25
|
+
import BindGroup from '../../renderers/common/BindGroup.js';
|
|
26
|
+
|
|
27
|
+
import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter, NormalBlending } from '../../constants.js';
|
|
28
|
+
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
29
|
+
import { Color } from '../../math/Color.js';
|
|
30
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
31
|
+
import { Vector3 } from '../../math/Vector3.js';
|
|
32
|
+
import { Vector4 } from '../../math/Vector4.js';
|
|
33
|
+
import { Float16BufferAttribute } from '../../core/BufferAttribute.js';
|
|
34
|
+
import { warn, error } from '../../utils.js';
|
|
35
|
+
|
|
36
|
+
let _id = 0;
|
|
37
|
+
|
|
38
|
+
const rendererCache = new WeakMap();
|
|
39
|
+
|
|
40
|
+
const typeFromArray = new Map( [
|
|
41
|
+
[ Int8Array, 'int' ],
|
|
42
|
+
[ Int16Array, 'int' ],
|
|
43
|
+
[ Int32Array, 'int' ],
|
|
44
|
+
[ Uint8Array, 'uint' ],
|
|
45
|
+
[ Uint16Array, 'uint' ],
|
|
46
|
+
[ Uint32Array, 'uint' ],
|
|
47
|
+
[ Float32Array, 'float' ]
|
|
48
|
+
] );
|
|
49
|
+
|
|
50
|
+
const toFloat = ( value ) => {
|
|
51
|
+
|
|
52
|
+
if ( /e/g.test( value ) ) {
|
|
53
|
+
|
|
54
|
+
return String( value ).replace( /\+/g, '' );
|
|
55
|
+
|
|
56
|
+
} else {
|
|
57
|
+
|
|
58
|
+
value = Number( value );
|
|
59
|
+
|
|
60
|
+
return value + ( value % 1 ? '' : '.0' );
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Base class for builders which generate a shader program based
|
|
68
|
+
* on a 3D object and its node material definition.
|
|
69
|
+
*/
|
|
70
|
+
class NodeBuilder {
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Constructs a new node builder.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object3D} object - The 3D object.
|
|
76
|
+
* @param {Renderer} renderer - The current renderer.
|
|
77
|
+
* @param {NodeParser} parser - A reference to a node parser.
|
|
78
|
+
*/
|
|
79
|
+
constructor( object, renderer, parser ) {
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The 3D object.
|
|
83
|
+
*
|
|
84
|
+
* @type {Object3D}
|
|
85
|
+
*/
|
|
86
|
+
this.object = object;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The material of the 3D object.
|
|
90
|
+
*
|
|
91
|
+
* @type {?Material}
|
|
92
|
+
*/
|
|
93
|
+
this.material = ( object && object.material ) || null;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The geometry of the 3D object.
|
|
97
|
+
*
|
|
98
|
+
* @type {?BufferGeometry}
|
|
99
|
+
*/
|
|
100
|
+
this.geometry = ( object && object.geometry ) || null;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The current renderer.
|
|
104
|
+
*
|
|
105
|
+
* @type {Renderer}
|
|
106
|
+
*/
|
|
107
|
+
this.renderer = renderer;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A reference to a node parser.
|
|
111
|
+
*
|
|
112
|
+
* @type {NodeParser}
|
|
113
|
+
*/
|
|
114
|
+
this.parser = parser;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The scene the 3D object belongs to.
|
|
118
|
+
*
|
|
119
|
+
* @type {?Scene}
|
|
120
|
+
* @default null
|
|
121
|
+
*/
|
|
122
|
+
this.scene = null;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The camera the 3D object is rendered with.
|
|
126
|
+
*
|
|
127
|
+
* @type {?Camera}
|
|
128
|
+
* @default null
|
|
129
|
+
*/
|
|
130
|
+
this.camera = null;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* A list of all nodes the builder is processing
|
|
134
|
+
* for this 3D object.
|
|
135
|
+
*
|
|
136
|
+
* @type {Array<Node>}
|
|
137
|
+
*/
|
|
138
|
+
this.nodes = [];
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A list of all sequential nodes.
|
|
142
|
+
*
|
|
143
|
+
* @type {Array<Node>}
|
|
144
|
+
*/
|
|
145
|
+
this.sequentialNodes = [];
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A list of all nodes which {@link Node#update} method should be executed.
|
|
149
|
+
*
|
|
150
|
+
* @type {Array<Node>}
|
|
151
|
+
*/
|
|
152
|
+
this.updateNodes = [];
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* A list of all nodes which {@link Node#updateBefore} method should be executed.
|
|
156
|
+
*
|
|
157
|
+
* @type {Array<Node>}
|
|
158
|
+
*/
|
|
159
|
+
this.updateBeforeNodes = [];
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* A list of all nodes which {@link Node#updateAfter} method should be executed.
|
|
163
|
+
*
|
|
164
|
+
* @type {Array<Node>}
|
|
165
|
+
*/
|
|
166
|
+
this.updateAfterNodes = [];
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* A dictionary that assigns each node to a unique hash.
|
|
170
|
+
*
|
|
171
|
+
* @type {Object<number,Node>}
|
|
172
|
+
*/
|
|
173
|
+
this.hashNodes = {};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* A reference to a node material observer.
|
|
177
|
+
*
|
|
178
|
+
* @type {?NodeMaterialObserver}
|
|
179
|
+
* @default null
|
|
180
|
+
*/
|
|
181
|
+
this.observer = null;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* A reference to the current lights node.
|
|
185
|
+
*
|
|
186
|
+
* @type {?LightsNode}
|
|
187
|
+
* @default null
|
|
188
|
+
*/
|
|
189
|
+
this.lightsNode = null;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* A reference to the current environment node.
|
|
193
|
+
*
|
|
194
|
+
* @type {?Node}
|
|
195
|
+
* @default null
|
|
196
|
+
*/
|
|
197
|
+
this.environmentNode = null;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* A reference to the current fog node.
|
|
201
|
+
*
|
|
202
|
+
* @type {?Node}
|
|
203
|
+
* @default null
|
|
204
|
+
*/
|
|
205
|
+
this.fogNode = null;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The current clipping context.
|
|
209
|
+
*
|
|
210
|
+
* @type {?ClippingContext}
|
|
211
|
+
*/
|
|
212
|
+
this.clippingContext = null;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The generated vertex shader.
|
|
216
|
+
*
|
|
217
|
+
* @type {?string}
|
|
218
|
+
*/
|
|
219
|
+
this.vertexShader = null;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The generated fragment shader.
|
|
223
|
+
*
|
|
224
|
+
* @type {?string}
|
|
225
|
+
*/
|
|
226
|
+
this.fragmentShader = null;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The generated compute shader.
|
|
230
|
+
*
|
|
231
|
+
* @type {?string}
|
|
232
|
+
*/
|
|
233
|
+
this.computeShader = null;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Nodes used in the primary flow of code generation.
|
|
237
|
+
*
|
|
238
|
+
* @type {Object<string,Array<Node>>}
|
|
239
|
+
*/
|
|
240
|
+
this.flowNodes = { vertex: [], fragment: [], compute: [] };
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Nodes code from `.flowNodes`.
|
|
244
|
+
*
|
|
245
|
+
* @type {Object<string,string>}
|
|
246
|
+
*/
|
|
247
|
+
this.flowCode = { vertex: '', fragment: '', compute: '' };
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* This dictionary holds the node uniforms of the builder.
|
|
251
|
+
* The uniforms are maintained in an array for each shader stage.
|
|
252
|
+
*
|
|
253
|
+
* @type {Object}
|
|
254
|
+
*/
|
|
255
|
+
this.uniforms = { vertex: [], fragment: [], compute: [], index: 0 };
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* This dictionary holds the output structs of the builder.
|
|
259
|
+
* The structs are maintained in an array for each shader stage.
|
|
260
|
+
*
|
|
261
|
+
* @type {Object}
|
|
262
|
+
*/
|
|
263
|
+
this.structs = { vertex: [], fragment: [], compute: [], index: 0 };
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* This dictionary holds the types of the builder.
|
|
267
|
+
*
|
|
268
|
+
* @type {Object}
|
|
269
|
+
*/
|
|
270
|
+
this.types = { vertex: [], fragment: [], compute: [], index: 0 };
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* This dictionary holds the bindings for each shader stage.
|
|
274
|
+
*
|
|
275
|
+
* @type {Object}
|
|
276
|
+
*/
|
|
277
|
+
this.bindings = { vertex: {}, fragment: {}, compute: {} };
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* This dictionary maintains the binding indices per bind group.
|
|
281
|
+
*
|
|
282
|
+
* @type {Object}
|
|
283
|
+
*/
|
|
284
|
+
this.bindingsIndexes = {};
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Reference to the array of bind groups.
|
|
288
|
+
*
|
|
289
|
+
* @type {?Array<BindGroup>}
|
|
290
|
+
*/
|
|
291
|
+
this.bindGroups = null;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* This array holds the node attributes of this builder
|
|
295
|
+
* created via {@link AttributeNode}.
|
|
296
|
+
*
|
|
297
|
+
* @type {Array<NodeAttribute>}
|
|
298
|
+
*/
|
|
299
|
+
this.attributes = [];
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* This array holds the node attributes of this builder
|
|
303
|
+
* created via {@link BufferAttributeNode}.
|
|
304
|
+
*
|
|
305
|
+
* @type {Array<NodeAttribute>}
|
|
306
|
+
*/
|
|
307
|
+
this.bufferAttributes = [];
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* This array holds the node varyings of this builder.
|
|
311
|
+
*
|
|
312
|
+
* @type {Array<NodeVarying>}
|
|
313
|
+
*/
|
|
314
|
+
this.varyings = [];
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* This dictionary holds the (native) node codes of this builder.
|
|
318
|
+
* The codes are maintained in an array for each shader stage.
|
|
319
|
+
*
|
|
320
|
+
* @type {Object<string,Array<NodeCode>>}
|
|
321
|
+
*/
|
|
322
|
+
this.codes = {};
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* This dictionary holds the node variables of this builder.
|
|
326
|
+
* The variables are maintained in an array for each shader stage.
|
|
327
|
+
* This dictionary is also used to count the number of variables
|
|
328
|
+
* according to their type (const, vars).
|
|
329
|
+
*
|
|
330
|
+
* @type {Object<string,Array<NodeVar>|number>}
|
|
331
|
+
*/
|
|
332
|
+
this.vars = {};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* This dictionary holds the declarations for each shader stage.
|
|
336
|
+
*
|
|
337
|
+
* @type {Object}
|
|
338
|
+
*/
|
|
339
|
+
this.declarations = {};
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Current code flow.
|
|
343
|
+
* All code generated in this stack will be stored in `.flow`.
|
|
344
|
+
*
|
|
345
|
+
* @type {{code: string}}
|
|
346
|
+
*/
|
|
347
|
+
this.flow = { code: '' };
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* A chain of nodes.
|
|
351
|
+
* Used to check recursive calls in node-graph.
|
|
352
|
+
*
|
|
353
|
+
* @type {Array<Node>}
|
|
354
|
+
*/
|
|
355
|
+
this.chaining = [];
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* The current stack.
|
|
359
|
+
* This reflects the current process in the code block hierarchy,
|
|
360
|
+
* it is useful to know if the current process is inside a conditional for example.
|
|
361
|
+
*
|
|
362
|
+
* @type {StackNode}
|
|
363
|
+
*/
|
|
364
|
+
this.stack = stack();
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* List of stack nodes.
|
|
368
|
+
* The current stack hierarchy is stored in an array.
|
|
369
|
+
*
|
|
370
|
+
* @type {Array<StackNode>}
|
|
371
|
+
*/
|
|
372
|
+
this.stacks = [];
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* A tab value. Used for shader string generation.
|
|
376
|
+
*
|
|
377
|
+
* @type {string}
|
|
378
|
+
* @default '\t'
|
|
379
|
+
*/
|
|
380
|
+
this.tab = '\t';
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Reference to the current function node.
|
|
384
|
+
*
|
|
385
|
+
* @type {?FunctionNode}
|
|
386
|
+
* @default null
|
|
387
|
+
*/
|
|
388
|
+
this.currentFunctionNode = null;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* The builder's context.
|
|
392
|
+
*
|
|
393
|
+
* @type {Object}
|
|
394
|
+
*/
|
|
395
|
+
this.context = {
|
|
396
|
+
material: this.material
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* The builder's cache.
|
|
401
|
+
*
|
|
402
|
+
* @type {NodeCache}
|
|
403
|
+
*/
|
|
404
|
+
this.cache = new NodeCache();
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Since the {@link NodeBuilder#cache} might be temporarily
|
|
408
|
+
* overwritten by other caches, this member retains the reference
|
|
409
|
+
* to the builder's own cache.
|
|
410
|
+
*
|
|
411
|
+
* @type {NodeCache}
|
|
412
|
+
* @default this.cache
|
|
413
|
+
*/
|
|
414
|
+
this.globalCache = this.cache;
|
|
415
|
+
|
|
416
|
+
this.flowsData = new WeakMap();
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* The current shader stage.
|
|
420
|
+
*
|
|
421
|
+
* @type {?('vertex'|'fragment'|'compute'|'any')}
|
|
422
|
+
*/
|
|
423
|
+
this.shaderStage = null;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* The current build stage.
|
|
427
|
+
*
|
|
428
|
+
* @type {?('setup'|'analyze'|'generate')}
|
|
429
|
+
*/
|
|
430
|
+
this.buildStage = null;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* The sub-build layers.
|
|
434
|
+
*
|
|
435
|
+
* @type {Array<SubBuildNode>}
|
|
436
|
+
* @default []
|
|
437
|
+
*/
|
|
438
|
+
this.subBuildLayers = [];
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* The active stack nodes.
|
|
443
|
+
*
|
|
444
|
+
* @type {Array<StackNode>}
|
|
445
|
+
*/
|
|
446
|
+
this.activeStacks = [];
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* The current sub-build TSL function(Fn).
|
|
450
|
+
*
|
|
451
|
+
* @type {?string}
|
|
452
|
+
* @default null
|
|
453
|
+
*/
|
|
454
|
+
this.subBuildFn = null;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* The current TSL function(Fn) call node.
|
|
458
|
+
*
|
|
459
|
+
* @type {?Node}
|
|
460
|
+
* @default null
|
|
461
|
+
*/
|
|
462
|
+
this.fnCall = null;
|
|
463
|
+
|
|
464
|
+
Object.defineProperty( this, 'id', { value: _id ++ } );
|
|
465
|
+
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Whether the material is opaque or not.
|
|
470
|
+
*
|
|
471
|
+
* @return {boolean} Whether the material is opaque or not.
|
|
472
|
+
*/
|
|
473
|
+
isOpaque() {
|
|
474
|
+
|
|
475
|
+
const material = this.material;
|
|
476
|
+
|
|
477
|
+
return material.transparent === false && material.blending === NormalBlending && material.alphaToCoverage === false;
|
|
478
|
+
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Returns the bind groups of the current renderer.
|
|
483
|
+
*
|
|
484
|
+
* @return {ChainMap} The cache.
|
|
485
|
+
*/
|
|
486
|
+
getBindGroupsCache() {
|
|
487
|
+
|
|
488
|
+
let bindGroupsCache = rendererCache.get( this.renderer );
|
|
489
|
+
|
|
490
|
+
if ( bindGroupsCache === undefined ) {
|
|
491
|
+
|
|
492
|
+
bindGroupsCache = new ChainMap();
|
|
493
|
+
|
|
494
|
+
rendererCache.set( this.renderer, bindGroupsCache );
|
|
495
|
+
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
return bindGroupsCache;
|
|
499
|
+
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Factory method for creating an instance of {@link RenderTarget} with the given
|
|
504
|
+
* dimensions and options.
|
|
505
|
+
*
|
|
506
|
+
* @param {number} width - The width of the render target.
|
|
507
|
+
* @param {number} height - The height of the render target.
|
|
508
|
+
* @param {Object} options - The options of the render target.
|
|
509
|
+
* @return {RenderTarget} The render target.
|
|
510
|
+
*/
|
|
511
|
+
createRenderTarget( width, height, options ) {
|
|
512
|
+
|
|
513
|
+
return new RenderTarget( width, height, options );
|
|
514
|
+
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Factory method for creating an instance of {@link CubeRenderTarget} with the given
|
|
519
|
+
* dimensions and options.
|
|
520
|
+
*
|
|
521
|
+
* @param {number} size - The size of the cube render target.
|
|
522
|
+
* @param {Object} options - The options of the cube render target.
|
|
523
|
+
* @return {CubeRenderTarget} The cube render target.
|
|
524
|
+
*/
|
|
525
|
+
createCubeRenderTarget( size, options ) {
|
|
526
|
+
|
|
527
|
+
return new CubeRenderTarget( size, options );
|
|
528
|
+
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Whether the given node is included in the internal array of nodes or not.
|
|
533
|
+
*
|
|
534
|
+
* @param {Node} node - The node to test.
|
|
535
|
+
* @return {boolean} Whether the given node is included in the internal array of nodes or not.
|
|
536
|
+
*/
|
|
537
|
+
includes( node ) {
|
|
538
|
+
|
|
539
|
+
return this.nodes.includes( node );
|
|
540
|
+
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Returns the output struct name which is required by
|
|
545
|
+
* {@link OutputStructNode}.
|
|
546
|
+
*
|
|
547
|
+
* @abstract
|
|
548
|
+
* @return {string} The name of the output struct.
|
|
549
|
+
*/
|
|
550
|
+
getOutputStructName() {}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Returns a bind group for the given group name and binding.
|
|
554
|
+
*
|
|
555
|
+
* @private
|
|
556
|
+
* @param {string} groupName - The group name.
|
|
557
|
+
* @param {Array<NodeUniformsGroup>} bindings - List of bindings.
|
|
558
|
+
* @return {BindGroup} The bind group
|
|
559
|
+
*/
|
|
560
|
+
_getBindGroup( groupName, bindings ) {
|
|
561
|
+
|
|
562
|
+
const bindGroupsCache = this.getBindGroupsCache();
|
|
563
|
+
|
|
564
|
+
//
|
|
565
|
+
|
|
566
|
+
const bindingsArray = [];
|
|
567
|
+
|
|
568
|
+
let sharedGroup = true;
|
|
569
|
+
|
|
570
|
+
for ( const binding of bindings ) {
|
|
571
|
+
|
|
572
|
+
bindingsArray.push( binding );
|
|
573
|
+
|
|
574
|
+
sharedGroup = sharedGroup && binding.groupNode.shared !== true;
|
|
575
|
+
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
//
|
|
579
|
+
|
|
580
|
+
let bindGroup;
|
|
581
|
+
|
|
582
|
+
if ( sharedGroup ) {
|
|
583
|
+
|
|
584
|
+
bindGroup = bindGroupsCache.get( bindingsArray );
|
|
585
|
+
|
|
586
|
+
if ( bindGroup === undefined ) {
|
|
587
|
+
|
|
588
|
+
bindGroup = new BindGroup( groupName, bindingsArray, this.bindingsIndexes[ groupName ].group, bindingsArray );
|
|
589
|
+
|
|
590
|
+
bindGroupsCache.set( bindingsArray, bindGroup );
|
|
591
|
+
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
} else {
|
|
595
|
+
|
|
596
|
+
bindGroup = new BindGroup( groupName, bindingsArray, this.bindingsIndexes[ groupName ].group, bindingsArray );
|
|
597
|
+
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return bindGroup;
|
|
601
|
+
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Returns an array of node uniform groups for the given group name and shader stage.
|
|
606
|
+
*
|
|
607
|
+
* @param {string} groupName - The group name.
|
|
608
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
|
|
609
|
+
* @return {Array<NodeUniformsGroup>} The array of node uniform groups.
|
|
610
|
+
*/
|
|
611
|
+
getBindGroupArray( groupName, shaderStage ) {
|
|
612
|
+
|
|
613
|
+
const bindings = this.bindings[ shaderStage ];
|
|
614
|
+
|
|
615
|
+
let bindGroup = bindings[ groupName ];
|
|
616
|
+
|
|
617
|
+
if ( bindGroup === undefined ) {
|
|
618
|
+
|
|
619
|
+
if ( this.bindingsIndexes[ groupName ] === undefined ) {
|
|
620
|
+
|
|
621
|
+
this.bindingsIndexes[ groupName ] = { binding: 0, group: Object.keys( this.bindingsIndexes ).length };
|
|
622
|
+
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
bindings[ groupName ] = bindGroup = [];
|
|
626
|
+
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
return bindGroup;
|
|
630
|
+
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Returns a list bindings of all shader stages separated by groups.
|
|
635
|
+
*
|
|
636
|
+
* @return {Array<BindGroup>} The list of bindings.
|
|
637
|
+
*/
|
|
638
|
+
getBindings() {
|
|
639
|
+
|
|
640
|
+
let bindingsGroups = this.bindGroups;
|
|
641
|
+
|
|
642
|
+
if ( bindingsGroups === null ) {
|
|
643
|
+
|
|
644
|
+
const groups = {};
|
|
645
|
+
const bindings = this.bindings;
|
|
646
|
+
|
|
647
|
+
for ( const shaderStage of shaderStages ) {
|
|
648
|
+
|
|
649
|
+
for ( const groupName in bindings[ shaderStage ] ) {
|
|
650
|
+
|
|
651
|
+
const uniforms = bindings[ shaderStage ][ groupName ];
|
|
652
|
+
|
|
653
|
+
const groupUniforms = groups[ groupName ] || ( groups[ groupName ] = [] );
|
|
654
|
+
groupUniforms.push( ...uniforms );
|
|
655
|
+
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
bindingsGroups = [];
|
|
661
|
+
|
|
662
|
+
for ( const groupName in groups ) {
|
|
663
|
+
|
|
664
|
+
const group = groups[ groupName ];
|
|
665
|
+
|
|
666
|
+
const bindingsGroup = this._getBindGroup( groupName, group );
|
|
667
|
+
|
|
668
|
+
bindingsGroups.push( bindingsGroup );
|
|
669
|
+
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
this.bindGroups = bindingsGroups;
|
|
673
|
+
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
return bindingsGroups;
|
|
677
|
+
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Sorts the bind groups and updates {@link NodeBuilder#bindingsIndexes}.
|
|
682
|
+
*/
|
|
683
|
+
sortBindingGroups() {
|
|
684
|
+
|
|
685
|
+
const bindingsGroups = this.getBindings();
|
|
686
|
+
|
|
687
|
+
bindingsGroups.sort( ( a, b ) => ( a.bindings[ 0 ].groupNode.order - b.bindings[ 0 ].groupNode.order ) );
|
|
688
|
+
|
|
689
|
+
for ( let i = 0; i < bindingsGroups.length; i ++ ) {
|
|
690
|
+
|
|
691
|
+
const bindingGroup = bindingsGroups[ i ];
|
|
692
|
+
this.bindingsIndexes[ bindingGroup.name ].group = i;
|
|
693
|
+
|
|
694
|
+
bindingGroup.index = i;
|
|
695
|
+
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* The builder maintains each node in a hash-based dictionary.
|
|
702
|
+
* This method sets the given node (value) with the given hash (key) into this dictionary.
|
|
703
|
+
*
|
|
704
|
+
* @param {Node} node - The node to add.
|
|
705
|
+
* @param {number} hash - The hash of the node.
|
|
706
|
+
*/
|
|
707
|
+
setHashNode( node, hash ) {
|
|
708
|
+
|
|
709
|
+
this.hashNodes[ hash ] = node;
|
|
710
|
+
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Adds a node to this builder.
|
|
715
|
+
*
|
|
716
|
+
* @param {Node} node - The node to add.
|
|
717
|
+
*/
|
|
718
|
+
addNode( node ) {
|
|
719
|
+
|
|
720
|
+
if ( this.nodes.includes( node ) === false ) {
|
|
721
|
+
|
|
722
|
+
this.nodes.push( node );
|
|
723
|
+
|
|
724
|
+
this.setHashNode( node, node.getHash( this ) );
|
|
725
|
+
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* It is used to add Nodes that will be used as FRAME and RENDER events,
|
|
732
|
+
* and need to follow a certain sequence in the calls to work correctly.
|
|
733
|
+
* This function should be called after 'setup()' in the 'build()' process to ensure that the child nodes are processed first.
|
|
734
|
+
*
|
|
735
|
+
* @param {Node} node - The node to add.
|
|
736
|
+
*/
|
|
737
|
+
addSequentialNode( node ) {
|
|
738
|
+
|
|
739
|
+
if ( this.sequentialNodes.includes( node ) === false ) {
|
|
740
|
+
|
|
741
|
+
this.sequentialNodes.push( node );
|
|
742
|
+
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Checks the update types of nodes
|
|
749
|
+
*/
|
|
750
|
+
buildUpdateNodes() {
|
|
751
|
+
|
|
752
|
+
for ( const node of this.nodes ) {
|
|
753
|
+
|
|
754
|
+
const updateType = node.getUpdateType();
|
|
755
|
+
|
|
756
|
+
if ( updateType !== NodeUpdateType.NONE ) {
|
|
757
|
+
|
|
758
|
+
this.updateNodes.push( node );
|
|
759
|
+
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
for ( const node of this.sequentialNodes ) {
|
|
765
|
+
|
|
766
|
+
const updateBeforeType = node.getUpdateBeforeType();
|
|
767
|
+
const updateAfterType = node.getUpdateAfterType();
|
|
768
|
+
|
|
769
|
+
if ( updateBeforeType !== NodeUpdateType.NONE ) {
|
|
770
|
+
|
|
771
|
+
this.updateBeforeNodes.push( node );
|
|
772
|
+
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
if ( updateAfterType !== NodeUpdateType.NONE ) {
|
|
776
|
+
|
|
777
|
+
this.updateAfterNodes.push( node );
|
|
778
|
+
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* A reference the current node which is the
|
|
787
|
+
* last node in the chain of nodes.
|
|
788
|
+
*
|
|
789
|
+
* @type {Node}
|
|
790
|
+
*/
|
|
791
|
+
get currentNode() {
|
|
792
|
+
|
|
793
|
+
return this.chaining[ this.chaining.length - 1 ];
|
|
794
|
+
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Whether the given texture is filtered or not.
|
|
799
|
+
*
|
|
800
|
+
* @param {Texture} texture - The texture to check.
|
|
801
|
+
* @return {boolean} Whether the given texture is filtered or not.
|
|
802
|
+
*/
|
|
803
|
+
isFilteredTexture( texture ) {
|
|
804
|
+
|
|
805
|
+
return ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
|
|
806
|
+
texture.minFilter === LinearFilter || texture.minFilter === LinearMipmapNearestFilter || texture.minFilter === NearestMipmapLinearFilter || texture.minFilter === LinearMipmapLinearFilter );
|
|
807
|
+
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Adds the given node to the internal node chain.
|
|
812
|
+
* This is used to check recursive calls in node-graph.
|
|
813
|
+
*
|
|
814
|
+
* @param {Node} node - The node to add.
|
|
815
|
+
*/
|
|
816
|
+
addChain( node ) {
|
|
817
|
+
|
|
818
|
+
/*
|
|
819
|
+
if ( this.chaining.indexOf( node ) !== - 1 ) {
|
|
820
|
+
|
|
821
|
+
warn( 'Recursive node: ', node );
|
|
822
|
+
|
|
823
|
+
}
|
|
824
|
+
*/
|
|
825
|
+
|
|
826
|
+
this.chaining.push( node );
|
|
827
|
+
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Removes the given node from the internal node chain.
|
|
832
|
+
*
|
|
833
|
+
* @param {Node} node - The node to remove.
|
|
834
|
+
*/
|
|
835
|
+
removeChain( node ) {
|
|
836
|
+
|
|
837
|
+
const lastChain = this.chaining.pop();
|
|
838
|
+
|
|
839
|
+
if ( lastChain !== node ) {
|
|
840
|
+
|
|
841
|
+
throw new Error( 'NodeBuilder: Invalid node chaining!' );
|
|
842
|
+
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Returns the native shader method name for a given generic name. E.g.
|
|
849
|
+
* the method name `textureDimensions` matches the WGSL name but must be
|
|
850
|
+
* resolved to `textureSize` in GLSL.
|
|
851
|
+
*
|
|
852
|
+
* @abstract
|
|
853
|
+
* @param {string} method - The method name to resolve.
|
|
854
|
+
* @return {string} The resolved method name.
|
|
855
|
+
*/
|
|
856
|
+
getMethod( method ) {
|
|
857
|
+
|
|
858
|
+
return method;
|
|
859
|
+
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Returns the native snippet for a ternary operation. E.g. GLSL would output
|
|
864
|
+
* a ternary op as `cond ? x : y` whereas WGSL would output it as `select(y, x, cond)`
|
|
865
|
+
*
|
|
866
|
+
* @abstract
|
|
867
|
+
* @param {string} condSnippet - The condition determining which expression gets resolved.
|
|
868
|
+
* @param {string} ifSnippet - The expression to resolve to if the condition is true.
|
|
869
|
+
* @param {string} elseSnippet - The expression to resolve to if the condition is false.
|
|
870
|
+
* @return {string} The resolved method name.
|
|
871
|
+
*/
|
|
872
|
+
getTernary( /* condSnippet, ifSnippet, elseSnippet*/ ) {
|
|
873
|
+
|
|
874
|
+
return null;
|
|
875
|
+
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Returns a node for the given hash, see {@link NodeBuilder#setHashNode}.
|
|
880
|
+
*
|
|
881
|
+
* @param {number} hash - The hash of the node.
|
|
882
|
+
* @return {Node} The found node.
|
|
883
|
+
*/
|
|
884
|
+
getNodeFromHash( hash ) {
|
|
885
|
+
|
|
886
|
+
return this.hashNodes[ hash ];
|
|
887
|
+
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Adds the Node to a target flow so that it can generate code in the 'generate' process.
|
|
892
|
+
*
|
|
893
|
+
* @param {('vertex'|'fragment'|'compute')} shaderStage - The shader stage.
|
|
894
|
+
* @param {Node} node - The node to add.
|
|
895
|
+
* @return {Node} The node.
|
|
896
|
+
*/
|
|
897
|
+
addFlow( shaderStage, node ) {
|
|
898
|
+
|
|
899
|
+
this.flowNodes[ shaderStage ].push( node );
|
|
900
|
+
|
|
901
|
+
return node;
|
|
902
|
+
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Sets builder's context.
|
|
907
|
+
*
|
|
908
|
+
* @param {Object} context - The context to set.
|
|
909
|
+
*/
|
|
910
|
+
setContext( context ) {
|
|
911
|
+
|
|
912
|
+
this.context = context;
|
|
913
|
+
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Returns the builder's current context.
|
|
918
|
+
*
|
|
919
|
+
* @return {Object} The builder's current context.
|
|
920
|
+
*/
|
|
921
|
+
getContext() {
|
|
922
|
+
|
|
923
|
+
return this.context;
|
|
924
|
+
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Adds context data to the builder's current context.
|
|
929
|
+
*
|
|
930
|
+
* @param {Object} context - The context to add.
|
|
931
|
+
* @return {Object} The previous context.
|
|
932
|
+
*/
|
|
933
|
+
addContext( context ) {
|
|
934
|
+
|
|
935
|
+
const previousContext = this.getContext();
|
|
936
|
+
|
|
937
|
+
this.setContext( { ...this.context, ...context } );
|
|
938
|
+
|
|
939
|
+
return previousContext;
|
|
940
|
+
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* Gets a context used in shader construction that can be shared across different materials.
|
|
945
|
+
* This is necessary since the renderer cache can reuse shaders generated in one material and use them in another.
|
|
946
|
+
*
|
|
947
|
+
* @return {Object} The builder's current context without material.
|
|
948
|
+
*/
|
|
949
|
+
getSharedContext() {
|
|
950
|
+
|
|
951
|
+
const context = { ...this.context };
|
|
952
|
+
|
|
953
|
+
delete context.material;
|
|
954
|
+
|
|
955
|
+
return this.context;
|
|
956
|
+
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Sets builder's cache.
|
|
961
|
+
*
|
|
962
|
+
* @param {NodeCache} cache - The cache to set.
|
|
963
|
+
*/
|
|
964
|
+
setCache( cache ) {
|
|
965
|
+
|
|
966
|
+
this.cache = cache;
|
|
967
|
+
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Returns the builder's current cache.
|
|
972
|
+
*
|
|
973
|
+
* @return {NodeCache} The builder's current cache.
|
|
974
|
+
*/
|
|
975
|
+
getCache() {
|
|
976
|
+
|
|
977
|
+
return this.cache;
|
|
978
|
+
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Returns a cache for the given node.
|
|
983
|
+
*
|
|
984
|
+
* @param {Node} node - The node.
|
|
985
|
+
* @param {boolean} [parent=true] - Whether this node refers to a shared parent cache or not.
|
|
986
|
+
* @return {NodeCache} The cache.
|
|
987
|
+
*/
|
|
988
|
+
getCacheFromNode( node, parent = true ) {
|
|
989
|
+
|
|
990
|
+
const data = this.getDataFromNode( node );
|
|
991
|
+
if ( data.cache === undefined ) data.cache = new NodeCache( parent ? this.getCache() : null );
|
|
992
|
+
|
|
993
|
+
return data.cache;
|
|
994
|
+
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* Whether the requested feature is available or not.
|
|
999
|
+
*
|
|
1000
|
+
* @abstract
|
|
1001
|
+
* @param {string} name - The requested feature.
|
|
1002
|
+
* @return {boolean} Whether the requested feature is supported or not.
|
|
1003
|
+
*/
|
|
1004
|
+
isAvailable( /*name*/ ) {
|
|
1005
|
+
|
|
1006
|
+
return false;
|
|
1007
|
+
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* Returns the vertexIndex input variable as a native shader string.
|
|
1012
|
+
*
|
|
1013
|
+
* @abstract
|
|
1014
|
+
* @return {string} The instanceIndex shader string.
|
|
1015
|
+
*/
|
|
1016
|
+
getVertexIndex() {
|
|
1017
|
+
|
|
1018
|
+
warn( 'Abstract function.' );
|
|
1019
|
+
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Contextually returns either the vertex stage instance index builtin
|
|
1024
|
+
* or the linearized index of an compute invocation within a grid of workgroups.
|
|
1025
|
+
*
|
|
1026
|
+
* @abstract
|
|
1027
|
+
* @return {string} The instanceIndex shader string.
|
|
1028
|
+
*/
|
|
1029
|
+
getInstanceIndex() {
|
|
1030
|
+
|
|
1031
|
+
warn( 'Abstract function.' );
|
|
1032
|
+
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Returns the drawIndex input variable as a native shader string.
|
|
1037
|
+
* Only relevant for WebGL and its `WEBGL_multi_draw` extension.
|
|
1038
|
+
*
|
|
1039
|
+
* @abstract
|
|
1040
|
+
* @return {?string} The drawIndex shader string.
|
|
1041
|
+
*/
|
|
1042
|
+
getDrawIndex() {
|
|
1043
|
+
|
|
1044
|
+
warn( 'Abstract function.' );
|
|
1045
|
+
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Returns the frontFacing input variable as a native shader string.
|
|
1050
|
+
*
|
|
1051
|
+
* @abstract
|
|
1052
|
+
* @return {string} The frontFacing shader string.
|
|
1053
|
+
*/
|
|
1054
|
+
getFrontFacing() {
|
|
1055
|
+
|
|
1056
|
+
warn( 'Abstract function.' );
|
|
1057
|
+
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Returns the fragCoord input variable as a native shader string.
|
|
1062
|
+
*
|
|
1063
|
+
* @abstract
|
|
1064
|
+
* @return {string} The fragCoord shader string.
|
|
1065
|
+
*/
|
|
1066
|
+
getFragCoord() {
|
|
1067
|
+
|
|
1068
|
+
warn( 'Abstract function.' );
|
|
1069
|
+
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Whether to flip texture data along its vertical axis or not. WebGL needs
|
|
1074
|
+
* this method evaluate to `true`, WebGPU to `false`.
|
|
1075
|
+
*
|
|
1076
|
+
* @abstract
|
|
1077
|
+
* @return {boolean} Whether to flip texture data along its vertical axis or not.
|
|
1078
|
+
*/
|
|
1079
|
+
isFlipY() {
|
|
1080
|
+
|
|
1081
|
+
return false;
|
|
1082
|
+
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* Calling this method increases the usage count for the given node by one.
|
|
1087
|
+
*
|
|
1088
|
+
* @param {Node} node - The node to increase the usage count for.
|
|
1089
|
+
* @return {number} The updated usage count.
|
|
1090
|
+
*/
|
|
1091
|
+
increaseUsage( node ) {
|
|
1092
|
+
|
|
1093
|
+
const nodeData = this.getDataFromNode( node );
|
|
1094
|
+
nodeData.usageCount = nodeData.usageCount === undefined ? 1 : nodeData.usageCount + 1;
|
|
1095
|
+
|
|
1096
|
+
return nodeData.usageCount;
|
|
1097
|
+
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Generates a texture sample shader string for the given texture data.
|
|
1102
|
+
*
|
|
1103
|
+
* @abstract
|
|
1104
|
+
* @param {Texture} texture - The texture.
|
|
1105
|
+
* @param {string} textureProperty - The texture property name.
|
|
1106
|
+
* @param {string} uvSnippet - Snippet defining the texture coordinates.
|
|
1107
|
+
* @return {string} The generated shader string.
|
|
1108
|
+
*/
|
|
1109
|
+
generateTexture( /* texture, textureProperty, uvSnippet */ ) {
|
|
1110
|
+
|
|
1111
|
+
warn( 'Abstract function.' );
|
|
1112
|
+
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* Generates a texture LOD shader string for the given texture data.
|
|
1117
|
+
*
|
|
1118
|
+
* @abstract
|
|
1119
|
+
* @param {Texture} texture - The texture.
|
|
1120
|
+
* @param {string} textureProperty - The texture property name.
|
|
1121
|
+
* @param {string} uvSnippet - Snippet defining the texture coordinates.
|
|
1122
|
+
* @param {?string} depthSnippet - Snippet defining the 0-based texture array index to sample.
|
|
1123
|
+
* @param {string} levelSnippet - Snippet defining the mip level.
|
|
1124
|
+
* @return {string} The generated shader string.
|
|
1125
|
+
*/
|
|
1126
|
+
generateTextureLod( /* texture, textureProperty, uvSnippet, depthSnippet, levelSnippet */ ) {
|
|
1127
|
+
|
|
1128
|
+
warn( 'Abstract function.' );
|
|
1129
|
+
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* Generates the array declaration string.
|
|
1134
|
+
*
|
|
1135
|
+
* @param {string} type - The type.
|
|
1136
|
+
* @param {?number} [count] - The count.
|
|
1137
|
+
* @return {string} The generated value as a shader string.
|
|
1138
|
+
*/
|
|
1139
|
+
generateArrayDeclaration( type, count ) {
|
|
1140
|
+
|
|
1141
|
+
return this.getType( type ) + '[ ' + count + ' ]';
|
|
1142
|
+
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* Generates the array shader string for the given type and value.
|
|
1147
|
+
*
|
|
1148
|
+
* @param {string} type - The type.
|
|
1149
|
+
* @param {?number} [count] - The count.
|
|
1150
|
+
* @param {?Array<Node>} [values=null] - The default values.
|
|
1151
|
+
* @return {string} The generated value as a shader string.
|
|
1152
|
+
*/
|
|
1153
|
+
generateArray( type, count, values = null ) {
|
|
1154
|
+
|
|
1155
|
+
let snippet = this.generateArrayDeclaration( type, count ) + '( ';
|
|
1156
|
+
|
|
1157
|
+
for ( let i = 0; i < count; i ++ ) {
|
|
1158
|
+
|
|
1159
|
+
const value = values ? values[ i ] : null;
|
|
1160
|
+
|
|
1161
|
+
if ( value !== null ) {
|
|
1162
|
+
|
|
1163
|
+
snippet += value.build( this, type );
|
|
1164
|
+
|
|
1165
|
+
} else {
|
|
1166
|
+
|
|
1167
|
+
snippet += this.generateConst( type );
|
|
1168
|
+
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
if ( i < count - 1 ) snippet += ', ';
|
|
1172
|
+
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
snippet += ' )';
|
|
1176
|
+
|
|
1177
|
+
return snippet;
|
|
1178
|
+
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Generates the struct shader string.
|
|
1183
|
+
*
|
|
1184
|
+
* @param {string} type - The type.
|
|
1185
|
+
* @param {Array<Object>} [membersLayout] - The count.
|
|
1186
|
+
* @param {?Array<Node>} [values=null] - The default values.
|
|
1187
|
+
* @return {string} The generated value as a shader string.
|
|
1188
|
+
*/
|
|
1189
|
+
generateStruct( type, membersLayout, values = null ) {
|
|
1190
|
+
|
|
1191
|
+
const snippets = [];
|
|
1192
|
+
|
|
1193
|
+
for ( const member of membersLayout ) {
|
|
1194
|
+
|
|
1195
|
+
const { name, type } = member;
|
|
1196
|
+
|
|
1197
|
+
if ( values && values[ name ] && values[ name ].isNode ) {
|
|
1198
|
+
|
|
1199
|
+
snippets.push( values[ name ].build( this, type ) );
|
|
1200
|
+
|
|
1201
|
+
} else {
|
|
1202
|
+
|
|
1203
|
+
snippets.push( this.generateConst( type ) );
|
|
1204
|
+
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
return type + '( ' + snippets.join( ', ' ) + ' )';
|
|
1210
|
+
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Generates the shader string for the given type and value.
|
|
1215
|
+
*
|
|
1216
|
+
* @param {string} type - The type.
|
|
1217
|
+
* @param {?any} [value=null] - The value.
|
|
1218
|
+
* @return {string} The generated value as a shader string.
|
|
1219
|
+
*/
|
|
1220
|
+
generateConst( type, value = null ) {
|
|
1221
|
+
|
|
1222
|
+
if ( value === null ) {
|
|
1223
|
+
|
|
1224
|
+
if ( type === 'float' || type === 'int' || type === 'uint' ) value = 0;
|
|
1225
|
+
else if ( type === 'bool' ) value = false;
|
|
1226
|
+
else if ( type === 'color' ) value = new Color();
|
|
1227
|
+
else if ( type === 'vec2' ) value = new Vector2();
|
|
1228
|
+
else if ( type === 'vec3' ) value = new Vector3();
|
|
1229
|
+
else if ( type === 'vec4' ) value = new Vector4();
|
|
1230
|
+
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
if ( type === 'float' ) return toFloat( value );
|
|
1234
|
+
if ( type === 'int' ) return `${ Math.round( value ) }`;
|
|
1235
|
+
if ( type === 'uint' ) return value >= 0 ? `${ Math.round( value ) }u` : '0u';
|
|
1236
|
+
if ( type === 'bool' ) return value ? 'true' : 'false';
|
|
1237
|
+
if ( type === 'color' ) return `${ this.getType( 'vec3' ) }( ${ toFloat( value.r ) }, ${ toFloat( value.g ) }, ${ toFloat( value.b ) } )`;
|
|
1238
|
+
|
|
1239
|
+
const typeLength = this.getTypeLength( type );
|
|
1240
|
+
|
|
1241
|
+
const componentType = this.getComponentType( type );
|
|
1242
|
+
|
|
1243
|
+
const generateConst = value => this.generateConst( componentType, value );
|
|
1244
|
+
|
|
1245
|
+
if ( typeLength === 2 ) {
|
|
1246
|
+
|
|
1247
|
+
return `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) } )`;
|
|
1248
|
+
|
|
1249
|
+
} else if ( typeLength === 3 ) {
|
|
1250
|
+
|
|
1251
|
+
return `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) }, ${ generateConst( value.z ) } )`;
|
|
1252
|
+
|
|
1253
|
+
} else if ( typeLength === 4 && type !== 'mat2' ) {
|
|
1254
|
+
|
|
1255
|
+
return `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) }, ${ generateConst( value.z ) }, ${ generateConst( value.w ) } )`;
|
|
1256
|
+
|
|
1257
|
+
} else if ( typeLength >= 4 && value && ( value.isMatrix2 || value.isMatrix3 || value.isMatrix4 ) ) {
|
|
1258
|
+
|
|
1259
|
+
return `${ this.getType( type ) }( ${ value.elements.map( generateConst ).join( ', ' ) } )`;
|
|
1260
|
+
|
|
1261
|
+
} else if ( typeLength > 4 ) {
|
|
1262
|
+
|
|
1263
|
+
return `${ this.getType( type ) }()`;
|
|
1264
|
+
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
throw new Error( `NodeBuilder: Type '${type}' not found in generate constant attempt.` );
|
|
1268
|
+
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* It might be necessary to convert certain data types to different ones
|
|
1273
|
+
* so this method can be used to hide the conversion.
|
|
1274
|
+
*
|
|
1275
|
+
* @param {string} type - The type.
|
|
1276
|
+
* @return {string} The updated type.
|
|
1277
|
+
*/
|
|
1278
|
+
getType( type ) {
|
|
1279
|
+
|
|
1280
|
+
if ( type === 'color' ) return 'vec3';
|
|
1281
|
+
|
|
1282
|
+
return type;
|
|
1283
|
+
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
/**
|
|
1287
|
+
* Whether the given attribute name is defined in the geometry or not.
|
|
1288
|
+
*
|
|
1289
|
+
* @param {string} name - The attribute name.
|
|
1290
|
+
* @return {boolean} Whether the given attribute name is defined in the geometry.
|
|
1291
|
+
*/
|
|
1292
|
+
hasGeometryAttribute( name ) {
|
|
1293
|
+
|
|
1294
|
+
return this.geometry && this.geometry.getAttribute( name ) !== undefined;
|
|
1295
|
+
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* Returns a node attribute for the given name and type.
|
|
1300
|
+
*
|
|
1301
|
+
* @param {string} name - The attribute's name.
|
|
1302
|
+
* @param {string} type - The attribute's type.
|
|
1303
|
+
* @return {NodeAttribute} The node attribute.
|
|
1304
|
+
*/
|
|
1305
|
+
getAttribute( name, type ) {
|
|
1306
|
+
|
|
1307
|
+
const attributes = this.attributes;
|
|
1308
|
+
|
|
1309
|
+
// find attribute
|
|
1310
|
+
|
|
1311
|
+
for ( const attribute of attributes ) {
|
|
1312
|
+
|
|
1313
|
+
if ( attribute.name === name ) {
|
|
1314
|
+
|
|
1315
|
+
return attribute;
|
|
1316
|
+
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// create a new if no exist
|
|
1322
|
+
|
|
1323
|
+
const attribute = new NodeAttribute( name, type );
|
|
1324
|
+
|
|
1325
|
+
this.registerDeclaration( attribute );
|
|
1326
|
+
|
|
1327
|
+
attributes.push( attribute );
|
|
1328
|
+
|
|
1329
|
+
return attribute;
|
|
1330
|
+
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* Returns for the given node and shader stage the property name for the shader.
|
|
1335
|
+
*
|
|
1336
|
+
* @param {Node} node - The node.
|
|
1337
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
|
|
1338
|
+
* @return {string} The property name.
|
|
1339
|
+
*/
|
|
1340
|
+
getPropertyName( node/*, shaderStage*/ ) {
|
|
1341
|
+
|
|
1342
|
+
return node.name;
|
|
1343
|
+
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* Whether the given type is a vector type or not.
|
|
1348
|
+
*
|
|
1349
|
+
* @param {string} type - The type to check.
|
|
1350
|
+
* @return {boolean} Whether the given type is a vector type or not.
|
|
1351
|
+
*/
|
|
1352
|
+
isVector( type ) {
|
|
1353
|
+
|
|
1354
|
+
return /vec\d/.test( type );
|
|
1355
|
+
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* Whether the given type is a matrix type or not.
|
|
1360
|
+
*
|
|
1361
|
+
* @param {string} type - The type to check.
|
|
1362
|
+
* @return {boolean} Whether the given type is a matrix type or not.
|
|
1363
|
+
*/
|
|
1364
|
+
isMatrix( type ) {
|
|
1365
|
+
|
|
1366
|
+
return /mat\d/.test( type );
|
|
1367
|
+
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* Whether the given type is a reference type or not.
|
|
1372
|
+
*
|
|
1373
|
+
* @param {string} type - The type to check.
|
|
1374
|
+
* @return {boolean} Whether the given type is a reference type or not.
|
|
1375
|
+
*/
|
|
1376
|
+
isReference( type ) {
|
|
1377
|
+
|
|
1378
|
+
return type === 'void' || type === 'property' || type === 'sampler' || type === 'samplerComparison' || type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'depthTexture' || type === 'texture3D';
|
|
1379
|
+
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* Checks if the given texture requires a manual conversion to the working color space.
|
|
1384
|
+
*
|
|
1385
|
+
* @abstract
|
|
1386
|
+
* @param {Texture} texture - The texture to check.
|
|
1387
|
+
* @return {boolean} Whether the given texture requires a conversion to working color space or not.
|
|
1388
|
+
*/
|
|
1389
|
+
needsToWorkingColorSpace( /*texture*/ ) {
|
|
1390
|
+
|
|
1391
|
+
return false;
|
|
1392
|
+
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* Returns the component type of a given texture.
|
|
1397
|
+
*
|
|
1398
|
+
* @param {Texture} texture - The texture.
|
|
1399
|
+
* @return {string} The component type.
|
|
1400
|
+
*/
|
|
1401
|
+
getComponentTypeFromTexture( texture ) {
|
|
1402
|
+
|
|
1403
|
+
const type = texture.type;
|
|
1404
|
+
|
|
1405
|
+
if ( texture.isDataTexture ) {
|
|
1406
|
+
|
|
1407
|
+
if ( type === IntType ) return 'int';
|
|
1408
|
+
if ( type === UnsignedIntType ) return 'uint';
|
|
1409
|
+
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
return 'float';
|
|
1413
|
+
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* Returns the element type for a given type.
|
|
1418
|
+
*
|
|
1419
|
+
* @param {string} type - The type.
|
|
1420
|
+
* @return {string} The element type.
|
|
1421
|
+
*/
|
|
1422
|
+
getElementType( type ) {
|
|
1423
|
+
|
|
1424
|
+
if ( type === 'mat2' ) return 'vec2';
|
|
1425
|
+
if ( type === 'mat3' ) return 'vec3';
|
|
1426
|
+
if ( type === 'mat4' ) return 'vec4';
|
|
1427
|
+
|
|
1428
|
+
return this.getComponentType( type );
|
|
1429
|
+
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Returns the component type for a given type.
|
|
1434
|
+
*
|
|
1435
|
+
* @param {string} type - The type.
|
|
1436
|
+
* @return {string} The component type.
|
|
1437
|
+
*/
|
|
1438
|
+
getComponentType( type ) {
|
|
1439
|
+
|
|
1440
|
+
type = this.getVectorType( type );
|
|
1441
|
+
|
|
1442
|
+
if ( type === 'float' || type === 'bool' || type === 'int' || type === 'uint' ) return type;
|
|
1443
|
+
|
|
1444
|
+
const componentType = /(b|i|u|)(vec|mat)([2-4])/.exec( type );
|
|
1445
|
+
|
|
1446
|
+
if ( componentType === null ) return null;
|
|
1447
|
+
|
|
1448
|
+
if ( componentType[ 1 ] === 'b' ) return 'bool';
|
|
1449
|
+
if ( componentType[ 1 ] === 'i' ) return 'int';
|
|
1450
|
+
if ( componentType[ 1 ] === 'u' ) return 'uint';
|
|
1451
|
+
|
|
1452
|
+
return 'float';
|
|
1453
|
+
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Returns the vector type for a given type.
|
|
1458
|
+
*
|
|
1459
|
+
* @param {string} type - The type.
|
|
1460
|
+
* @return {string} The vector type.
|
|
1461
|
+
*/
|
|
1462
|
+
getVectorType( type ) {
|
|
1463
|
+
|
|
1464
|
+
if ( type === 'color' ) return 'vec3';
|
|
1465
|
+
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) return 'vec4';
|
|
1466
|
+
|
|
1467
|
+
return type;
|
|
1468
|
+
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* Returns the data type for the given the length and component type.
|
|
1473
|
+
*
|
|
1474
|
+
* @param {number} length - The length.
|
|
1475
|
+
* @param {string} [componentType='float'] - The component type.
|
|
1476
|
+
* @return {string} The type.
|
|
1477
|
+
*/
|
|
1478
|
+
getTypeFromLength( length, componentType = 'float' ) {
|
|
1479
|
+
|
|
1480
|
+
if ( length === 1 ) return componentType;
|
|
1481
|
+
|
|
1482
|
+
let baseType = getTypeFromLength( length );
|
|
1483
|
+
const prefix = componentType === 'float' ? '' : componentType[ 0 ];
|
|
1484
|
+
|
|
1485
|
+
// fix edge case for mat2x2 being same size as vec4
|
|
1486
|
+
if ( /mat2/.test( componentType ) === true ) {
|
|
1487
|
+
|
|
1488
|
+
baseType = baseType.replace( 'vec', 'mat' );
|
|
1489
|
+
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
return prefix + baseType;
|
|
1493
|
+
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
/**
|
|
1497
|
+
* Returns the type for a given typed array.
|
|
1498
|
+
*
|
|
1499
|
+
* @param {TypedArray} array - The typed array.
|
|
1500
|
+
* @return {string} The type.
|
|
1501
|
+
*/
|
|
1502
|
+
getTypeFromArray( array ) {
|
|
1503
|
+
|
|
1504
|
+
return typeFromArray.get( array.constructor );
|
|
1505
|
+
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* Returns the type is an integer type.
|
|
1510
|
+
*
|
|
1511
|
+
* @param {string} type - The type.
|
|
1512
|
+
* @return {boolean} Whether the type is an integer type or not.
|
|
1513
|
+
*/
|
|
1514
|
+
isInteger( type ) {
|
|
1515
|
+
|
|
1516
|
+
return /int|uint|(i|u)vec/.test( type );
|
|
1517
|
+
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
/**
|
|
1521
|
+
* Returns the type for a given buffer attribute.
|
|
1522
|
+
*
|
|
1523
|
+
* @param {BufferAttribute} attribute - The buffer attribute.
|
|
1524
|
+
* @return {string} The type.
|
|
1525
|
+
*/
|
|
1526
|
+
getTypeFromAttribute( attribute ) {
|
|
1527
|
+
|
|
1528
|
+
let dataAttribute = attribute;
|
|
1529
|
+
|
|
1530
|
+
if ( attribute.isInterleavedBufferAttribute ) dataAttribute = attribute.data;
|
|
1531
|
+
|
|
1532
|
+
const array = dataAttribute.array;
|
|
1533
|
+
const itemSize = attribute.itemSize;
|
|
1534
|
+
const normalized = attribute.normalized;
|
|
1535
|
+
|
|
1536
|
+
let arrayType;
|
|
1537
|
+
|
|
1538
|
+
if ( ! ( attribute instanceof Float16BufferAttribute ) && normalized !== true ) {
|
|
1539
|
+
|
|
1540
|
+
arrayType = this.getTypeFromArray( array );
|
|
1541
|
+
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
return this.getTypeFromLength( itemSize, arrayType );
|
|
1545
|
+
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
/**
|
|
1549
|
+
* Returns the length for the given data type.
|
|
1550
|
+
*
|
|
1551
|
+
* @param {string} type - The data type.
|
|
1552
|
+
* @return {number} The length.
|
|
1553
|
+
*/
|
|
1554
|
+
getTypeLength( type ) {
|
|
1555
|
+
|
|
1556
|
+
const vecType = this.getVectorType( type );
|
|
1557
|
+
const vecNum = /vec([2-4])/.exec( vecType );
|
|
1558
|
+
|
|
1559
|
+
if ( vecNum !== null ) return Number( vecNum[ 1 ] );
|
|
1560
|
+
if ( vecType === 'float' || vecType === 'bool' || vecType === 'int' || vecType === 'uint' ) return 1;
|
|
1561
|
+
if ( /mat2/.test( type ) === true ) return 4;
|
|
1562
|
+
if ( /mat3/.test( type ) === true ) return 9;
|
|
1563
|
+
if ( /mat4/.test( type ) === true ) return 16;
|
|
1564
|
+
|
|
1565
|
+
return 0;
|
|
1566
|
+
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* Returns the vector type for a given matrix type.
|
|
1571
|
+
*
|
|
1572
|
+
* @param {string} type - The matrix type.
|
|
1573
|
+
* @return {string} The vector type.
|
|
1574
|
+
*/
|
|
1575
|
+
getVectorFromMatrix( type ) {
|
|
1576
|
+
|
|
1577
|
+
return type.replace( 'mat', 'vec' );
|
|
1578
|
+
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* For a given type this method changes the component type to the
|
|
1583
|
+
* given value. E.g. `vec4` should be changed to the new component type
|
|
1584
|
+
* `uint` which results in `uvec4`.
|
|
1585
|
+
*
|
|
1586
|
+
* @param {string} type - The type.
|
|
1587
|
+
* @param {string} newComponentType - The new component type.
|
|
1588
|
+
* @return {string} The new type.
|
|
1589
|
+
*/
|
|
1590
|
+
changeComponentType( type, newComponentType ) {
|
|
1591
|
+
|
|
1592
|
+
return this.getTypeFromLength( this.getTypeLength( type ), newComponentType );
|
|
1593
|
+
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* Returns the integer type pendant for the given type.
|
|
1598
|
+
*
|
|
1599
|
+
* @param {string} type - The type.
|
|
1600
|
+
* @return {string} The integer type.
|
|
1601
|
+
*/
|
|
1602
|
+
getIntegerType( type ) {
|
|
1603
|
+
|
|
1604
|
+
const componentType = this.getComponentType( type );
|
|
1605
|
+
|
|
1606
|
+
if ( componentType === 'int' || componentType === 'uint' ) return type;
|
|
1607
|
+
|
|
1608
|
+
return this.changeComponentType( type, 'int' );
|
|
1609
|
+
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Adds an active stack to the internal stack.
|
|
1614
|
+
*
|
|
1615
|
+
* @param {StackNode} stack - The stack node to add.
|
|
1616
|
+
*/
|
|
1617
|
+
setActiveStack( stack ) {
|
|
1618
|
+
|
|
1619
|
+
this.activeStacks.push( stack );
|
|
1620
|
+
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
/**
|
|
1624
|
+
* Removes the active stack from the internal stack.
|
|
1625
|
+
*
|
|
1626
|
+
* @param {StackNode} stack - The stack node to remove.
|
|
1627
|
+
*/
|
|
1628
|
+
removeActiveStack( stack ) {
|
|
1629
|
+
|
|
1630
|
+
if ( this.activeStacks[ this.activeStacks.length - 1 ] === stack ) {
|
|
1631
|
+
|
|
1632
|
+
this.activeStacks.pop();
|
|
1633
|
+
|
|
1634
|
+
} else {
|
|
1635
|
+
|
|
1636
|
+
throw new Error( 'NodeBuilder: Invalid active stack removal.' );
|
|
1637
|
+
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* Returns the active stack.
|
|
1644
|
+
*
|
|
1645
|
+
* @return {StackNode} The active stack.
|
|
1646
|
+
*/
|
|
1647
|
+
getActiveStack() {
|
|
1648
|
+
|
|
1649
|
+
return this.activeStacks[ this.activeStacks.length - 1 ];
|
|
1650
|
+
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* Returns the base stack.
|
|
1655
|
+
*
|
|
1656
|
+
* @return {StackNode} The base stack.
|
|
1657
|
+
*/
|
|
1658
|
+
getBaseStack() {
|
|
1659
|
+
|
|
1660
|
+
return this.activeStacks[ 0 ];
|
|
1661
|
+
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
/**
|
|
1665
|
+
* Adds a stack node to the internal stack.
|
|
1666
|
+
*
|
|
1667
|
+
* @return {StackNode} The added stack node.
|
|
1668
|
+
*/
|
|
1669
|
+
addStack() {
|
|
1670
|
+
|
|
1671
|
+
this.stack = stack( this.stack );
|
|
1672
|
+
|
|
1673
|
+
const previousStack = getCurrentStack();
|
|
1674
|
+
|
|
1675
|
+
this.stacks.push( previousStack );
|
|
1676
|
+
setCurrentStack( this.stack );
|
|
1677
|
+
|
|
1678
|
+
return this.stack;
|
|
1679
|
+
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* Removes the last stack node from the internal stack.
|
|
1684
|
+
*
|
|
1685
|
+
* @return {StackNode} The removed stack node.
|
|
1686
|
+
*/
|
|
1687
|
+
removeStack() {
|
|
1688
|
+
|
|
1689
|
+
const lastStack = this.stack;
|
|
1690
|
+
|
|
1691
|
+
for ( const node of lastStack.nodes ) {
|
|
1692
|
+
|
|
1693
|
+
const nodeData = this.getDataFromNode( node );
|
|
1694
|
+
nodeData.stack = lastStack;
|
|
1695
|
+
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
this.stack = lastStack.parent;
|
|
1699
|
+
|
|
1700
|
+
setCurrentStack( this.stacks.pop() );
|
|
1701
|
+
|
|
1702
|
+
return lastStack;
|
|
1703
|
+
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
/**
|
|
1707
|
+
* The builder maintains (cached) data for each node during the building process. This method
|
|
1708
|
+
* can be used to get these data for a specific shader stage and cache.
|
|
1709
|
+
*
|
|
1710
|
+
* @param {Node} node - The node to get the data for.
|
|
1711
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage.
|
|
1712
|
+
* @param {?NodeCache} cache - An optional cache.
|
|
1713
|
+
* @return {Object} The node data.
|
|
1714
|
+
*/
|
|
1715
|
+
getDataFromNode( node, shaderStage = this.shaderStage, cache = null ) {
|
|
1716
|
+
|
|
1717
|
+
cache = cache === null ? ( node.isGlobal( this ) ? this.globalCache : this.cache ) : cache;
|
|
1718
|
+
|
|
1719
|
+
let nodeData = cache.getData( node );
|
|
1720
|
+
|
|
1721
|
+
if ( nodeData === undefined ) {
|
|
1722
|
+
|
|
1723
|
+
nodeData = {};
|
|
1724
|
+
|
|
1725
|
+
cache.setData( node, nodeData );
|
|
1726
|
+
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
if ( nodeData[ shaderStage ] === undefined ) nodeData[ shaderStage ] = {};
|
|
1730
|
+
|
|
1731
|
+
//
|
|
1732
|
+
|
|
1733
|
+
let data = nodeData[ shaderStage ];
|
|
1734
|
+
|
|
1735
|
+
const subBuilds = nodeData.any ? nodeData.any.subBuilds : null;
|
|
1736
|
+
const subBuild = this.getClosestSubBuild( subBuilds );
|
|
1737
|
+
|
|
1738
|
+
if ( subBuild ) {
|
|
1739
|
+
|
|
1740
|
+
if ( data.subBuildsCache === undefined ) data.subBuildsCache = {};
|
|
1741
|
+
|
|
1742
|
+
data = data.subBuildsCache[ subBuild ] || ( data.subBuildsCache[ subBuild ] = {} );
|
|
1743
|
+
data.subBuilds = subBuilds;
|
|
1744
|
+
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
return data;
|
|
1748
|
+
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
/**
|
|
1752
|
+
* Returns the properties for the given node and shader stage.
|
|
1753
|
+
*
|
|
1754
|
+
* Properties are typically used within a build stage to reference a node's
|
|
1755
|
+
* child node or nodes manually assigned to the properties in a separate build stage.
|
|
1756
|
+
* A typical usage pattern for defining nodes manually would be assigning dependency nodes
|
|
1757
|
+
* to the current node's properties in the setup stage and building those properties in the generate stage.
|
|
1758
|
+
*
|
|
1759
|
+
* @param {Node} node - The node to get the properties for.
|
|
1760
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage='any'] - The shader stage.
|
|
1761
|
+
* @return {Object} The node properties.
|
|
1762
|
+
*/
|
|
1763
|
+
getNodeProperties( node, shaderStage = 'any' ) {
|
|
1764
|
+
|
|
1765
|
+
const nodeData = this.getDataFromNode( node, shaderStage );
|
|
1766
|
+
|
|
1767
|
+
return nodeData.properties || ( nodeData.properties = { outputNode: null } );
|
|
1768
|
+
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
/**
|
|
1772
|
+
* Returns an instance of {@link NodeAttribute} for the given buffer attribute node.
|
|
1773
|
+
*
|
|
1774
|
+
* @param {BufferAttributeNode} node - The buffer attribute node.
|
|
1775
|
+
* @param {string} type - The node type.
|
|
1776
|
+
* @return {NodeAttribute} The node attribute.
|
|
1777
|
+
*/
|
|
1778
|
+
getBufferAttributeFromNode( node, type ) {
|
|
1779
|
+
|
|
1780
|
+
const nodeData = this.getDataFromNode( node );
|
|
1781
|
+
|
|
1782
|
+
let bufferAttribute = nodeData.bufferAttribute;
|
|
1783
|
+
|
|
1784
|
+
if ( bufferAttribute === undefined ) {
|
|
1785
|
+
|
|
1786
|
+
const index = this.uniforms.index ++;
|
|
1787
|
+
|
|
1788
|
+
bufferAttribute = new NodeAttribute( 'nodeAttribute' + index, type, node );
|
|
1789
|
+
|
|
1790
|
+
this.bufferAttributes.push( bufferAttribute );
|
|
1791
|
+
|
|
1792
|
+
nodeData.bufferAttribute = bufferAttribute;
|
|
1793
|
+
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
return bufferAttribute;
|
|
1797
|
+
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
/**
|
|
1801
|
+
* Returns an instance of {@link StructType} for the given struct name and shader stage
|
|
1802
|
+
* or null if not found.
|
|
1803
|
+
*
|
|
1804
|
+
* @param {string} name - The name of the struct.
|
|
1805
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage.
|
|
1806
|
+
* @return {?StructType} The struct type or null if not found.
|
|
1807
|
+
*/
|
|
1808
|
+
getStructTypeNode( name, shaderStage = this.shaderStage ) {
|
|
1809
|
+
|
|
1810
|
+
return this.types[ shaderStage ][ name ] || null;
|
|
1811
|
+
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
/**
|
|
1815
|
+
* Returns an instance of {@link StructType} for the given output struct node.
|
|
1816
|
+
*
|
|
1817
|
+
* @param {OutputStructNode} node - The output struct node.
|
|
1818
|
+
* @param {Array<Object>} membersLayout - The output struct types.
|
|
1819
|
+
* @param {?string} [name=null] - The name of the struct.
|
|
1820
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage.
|
|
1821
|
+
* @return {StructType} The struct type attribute.
|
|
1822
|
+
*/
|
|
1823
|
+
getStructTypeFromNode( node, membersLayout, name = null, shaderStage = this.shaderStage ) {
|
|
1824
|
+
|
|
1825
|
+
const nodeData = this.getDataFromNode( node, shaderStage, this.globalCache );
|
|
1826
|
+
|
|
1827
|
+
let structType = nodeData.structType;
|
|
1828
|
+
|
|
1829
|
+
if ( structType === undefined ) {
|
|
1830
|
+
|
|
1831
|
+
const index = this.structs.index ++;
|
|
1832
|
+
|
|
1833
|
+
if ( name === null ) name = 'StructType' + index;
|
|
1834
|
+
|
|
1835
|
+
structType = new StructType( name, membersLayout );
|
|
1836
|
+
|
|
1837
|
+
this.structs[ shaderStage ].push( structType );
|
|
1838
|
+
this.types[ shaderStage ][ name ] = node;
|
|
1839
|
+
|
|
1840
|
+
nodeData.structType = structType;
|
|
1841
|
+
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
return structType;
|
|
1845
|
+
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
/**
|
|
1849
|
+
* Returns an instance of {@link StructType} for the given output struct node.
|
|
1850
|
+
*
|
|
1851
|
+
* @param {OutputStructNode} node - The output struct node.
|
|
1852
|
+
* @param {Array<Object>} membersLayout - The output struct types.
|
|
1853
|
+
* @return {StructType} The struct type attribute.
|
|
1854
|
+
*/
|
|
1855
|
+
getOutputStructTypeFromNode( node, membersLayout ) {
|
|
1856
|
+
|
|
1857
|
+
const structType = this.getStructTypeFromNode( node, membersLayout, 'OutputType', 'fragment' );
|
|
1858
|
+
structType.output = true;
|
|
1859
|
+
|
|
1860
|
+
return structType;
|
|
1861
|
+
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
/**
|
|
1865
|
+
* Returns an instance of {@link NodeUniform} for the given uniform node.
|
|
1866
|
+
*
|
|
1867
|
+
* @param {UniformNode} node - The uniform node.
|
|
1868
|
+
* @param {string} type - The uniform type.
|
|
1869
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage.
|
|
1870
|
+
* @param {?string} name - The name of the uniform.
|
|
1871
|
+
* @return {NodeUniform} The node uniform.
|
|
1872
|
+
*/
|
|
1873
|
+
getUniformFromNode( node, type, shaderStage = this.shaderStage, name = null ) {
|
|
1874
|
+
|
|
1875
|
+
const nodeData = this.getDataFromNode( node, shaderStage, this.globalCache );
|
|
1876
|
+
|
|
1877
|
+
let nodeUniform = nodeData.uniform;
|
|
1878
|
+
|
|
1879
|
+
if ( nodeUniform === undefined ) {
|
|
1880
|
+
|
|
1881
|
+
const index = this.uniforms.index ++;
|
|
1882
|
+
|
|
1883
|
+
nodeUniform = new NodeUniform( name || ( 'nodeUniform' + index ), type, node );
|
|
1884
|
+
|
|
1885
|
+
this.uniforms[ shaderStage ].push( nodeUniform );
|
|
1886
|
+
|
|
1887
|
+
this.registerDeclaration( nodeUniform );
|
|
1888
|
+
|
|
1889
|
+
nodeData.uniform = nodeUniform;
|
|
1890
|
+
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
return nodeUniform;
|
|
1894
|
+
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* Returns an instance of {@link NodeVar} for the given variable node.
|
|
1899
|
+
*
|
|
1900
|
+
* @param {VarNode} node - The variable node.
|
|
1901
|
+
* @param {?string} name - The variable's name.
|
|
1902
|
+
* @param {string} [type=node.getNodeType( this )] - The variable's type.
|
|
1903
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage.
|
|
1904
|
+
* @param {boolean} [readOnly=false] - Whether the variable is read-only or not.
|
|
1905
|
+
*
|
|
1906
|
+
* @return {NodeVar} The node variable.
|
|
1907
|
+
*/
|
|
1908
|
+
getVarFromNode( node, name = null, type = node.getNodeType( this ), shaderStage = this.shaderStage, readOnly = false ) {
|
|
1909
|
+
|
|
1910
|
+
const nodeData = this.getDataFromNode( node, shaderStage );
|
|
1911
|
+
const subBuildVariable = this.getSubBuildProperty( 'variable', nodeData.subBuilds );
|
|
1912
|
+
|
|
1913
|
+
let nodeVar = nodeData[ subBuildVariable ];
|
|
1914
|
+
|
|
1915
|
+
if ( nodeVar === undefined ) {
|
|
1916
|
+
|
|
1917
|
+
const idNS = readOnly ? '_const' : '_var';
|
|
1918
|
+
|
|
1919
|
+
const vars = this.vars[ shaderStage ] || ( this.vars[ shaderStage ] = [] );
|
|
1920
|
+
const id = this.vars[ idNS ] || ( this.vars[ idNS ] = 0 );
|
|
1921
|
+
|
|
1922
|
+
if ( name === null ) {
|
|
1923
|
+
|
|
1924
|
+
name = ( readOnly ? 'nodeConst' : 'nodeVar' ) + id;
|
|
1925
|
+
|
|
1926
|
+
this.vars[ idNS ] ++;
|
|
1927
|
+
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
//
|
|
1931
|
+
|
|
1932
|
+
if ( subBuildVariable !== 'variable' ) {
|
|
1933
|
+
|
|
1934
|
+
name = this.getSubBuildProperty( name, nodeData.subBuilds );
|
|
1935
|
+
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
//
|
|
1939
|
+
|
|
1940
|
+
const count = node.getArrayCount( this );
|
|
1941
|
+
|
|
1942
|
+
nodeVar = new NodeVar( name, type, readOnly, count );
|
|
1943
|
+
|
|
1944
|
+
if ( ! readOnly ) {
|
|
1945
|
+
|
|
1946
|
+
vars.push( nodeVar );
|
|
1947
|
+
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
this.registerDeclaration( nodeVar );
|
|
1951
|
+
|
|
1952
|
+
nodeData[ subBuildVariable ] = nodeVar;
|
|
1953
|
+
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
return nodeVar;
|
|
1957
|
+
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
/**
|
|
1961
|
+
* Returns whether a Node or its flow is deterministic, useful for use in `const`.
|
|
1962
|
+
*
|
|
1963
|
+
* @param {Node} node - The varying node.
|
|
1964
|
+
* @return {boolean} Returns true if deterministic.
|
|
1965
|
+
*/
|
|
1966
|
+
isDeterministic( node ) {
|
|
1967
|
+
|
|
1968
|
+
if ( node.isMathNode ) {
|
|
1969
|
+
|
|
1970
|
+
return this.isDeterministic( node.aNode ) &&
|
|
1971
|
+
( node.bNode ? this.isDeterministic( node.bNode ) : true ) &&
|
|
1972
|
+
( node.cNode ? this.isDeterministic( node.cNode ) : true );
|
|
1973
|
+
|
|
1974
|
+
} else if ( node.isOperatorNode ) {
|
|
1975
|
+
|
|
1976
|
+
return this.isDeterministic( node.aNode ) &&
|
|
1977
|
+
( node.bNode ? this.isDeterministic( node.bNode ) : true );
|
|
1978
|
+
|
|
1979
|
+
} else if ( node.isArrayNode ) {
|
|
1980
|
+
|
|
1981
|
+
if ( node.values !== null ) {
|
|
1982
|
+
|
|
1983
|
+
for ( const n of node.values ) {
|
|
1984
|
+
|
|
1985
|
+
if ( ! this.isDeterministic( n ) ) {
|
|
1986
|
+
|
|
1987
|
+
return false;
|
|
1988
|
+
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
return true;
|
|
1996
|
+
|
|
1997
|
+
} else if ( node.isConstNode ) {
|
|
1998
|
+
|
|
1999
|
+
return true;
|
|
2000
|
+
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
return false;
|
|
2004
|
+
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* Returns an instance of {@link NodeVarying} for the given varying node.
|
|
2009
|
+
*
|
|
2010
|
+
* @param {(VaryingNode|PropertyNode)} node - The varying node.
|
|
2011
|
+
* @param {?string} name - The varying's name.
|
|
2012
|
+
* @param {string} [type=node.getNodeType( this )] - The varying's type.
|
|
2013
|
+
* @param {?string} interpolationType - The interpolation type of the varying.
|
|
2014
|
+
* @param {?string} interpolationSampling - The interpolation sampling type of the varying.
|
|
2015
|
+
* @return {NodeVar} The node varying.
|
|
2016
|
+
*/
|
|
2017
|
+
getVaryingFromNode( node, name = null, type = node.getNodeType( this ), interpolationType = null, interpolationSampling = null ) {
|
|
2018
|
+
|
|
2019
|
+
const nodeData = this.getDataFromNode( node, 'any' );
|
|
2020
|
+
const subBuildVarying = this.getSubBuildProperty( 'varying', nodeData.subBuilds );
|
|
2021
|
+
|
|
2022
|
+
let nodeVarying = nodeData[ subBuildVarying ];
|
|
2023
|
+
|
|
2024
|
+
if ( nodeVarying === undefined ) {
|
|
2025
|
+
|
|
2026
|
+
const varyings = this.varyings;
|
|
2027
|
+
const index = varyings.length;
|
|
2028
|
+
|
|
2029
|
+
if ( name === null ) name = 'nodeVarying' + index;
|
|
2030
|
+
|
|
2031
|
+
//
|
|
2032
|
+
|
|
2033
|
+
if ( subBuildVarying !== 'varying' ) {
|
|
2034
|
+
|
|
2035
|
+
name = this.getSubBuildProperty( name, nodeData.subBuilds );
|
|
2036
|
+
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
//
|
|
2040
|
+
|
|
2041
|
+
nodeVarying = new NodeVarying( name, type, interpolationType, interpolationSampling );
|
|
2042
|
+
|
|
2043
|
+
varyings.push( nodeVarying );
|
|
2044
|
+
|
|
2045
|
+
this.registerDeclaration( nodeVarying );
|
|
2046
|
+
|
|
2047
|
+
nodeData[ subBuildVarying ] = nodeVarying;
|
|
2048
|
+
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
return nodeVarying;
|
|
2052
|
+
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
/**
|
|
2056
|
+
* Registers a node declaration in the current shader stage.
|
|
2057
|
+
*
|
|
2058
|
+
* @param {Object} node - The node to be registered.
|
|
2059
|
+
*/
|
|
2060
|
+
registerDeclaration( node ) {
|
|
2061
|
+
|
|
2062
|
+
const shaderStage = this.shaderStage;
|
|
2063
|
+
const declarations = this.declarations[ shaderStage ] || ( this.declarations[ shaderStage ] = {} );
|
|
2064
|
+
|
|
2065
|
+
const property = this.getPropertyName( node );
|
|
2066
|
+
|
|
2067
|
+
let index = 1;
|
|
2068
|
+
let name = property;
|
|
2069
|
+
|
|
2070
|
+
// Automatically renames the property if the name is already in use.
|
|
2071
|
+
|
|
2072
|
+
while ( declarations[ name ] !== undefined ) {
|
|
2073
|
+
|
|
2074
|
+
name = property + '_' + index ++;
|
|
2075
|
+
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
if ( index > 1 ) {
|
|
2079
|
+
|
|
2080
|
+
node.name = name;
|
|
2081
|
+
|
|
2082
|
+
warn( `TSL: Declaration name '${ property }' of '${ node.type }' already in use. Renamed to '${ name }'.` );
|
|
2083
|
+
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
declarations[ name ] = node;
|
|
2087
|
+
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Returns an instance of {@link NodeCode} for the given code node.
|
|
2092
|
+
*
|
|
2093
|
+
* @param {CodeNode} node - The code node.
|
|
2094
|
+
* @param {string} type - The node type.
|
|
2095
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage.
|
|
2096
|
+
* @return {NodeCode} The node code.
|
|
2097
|
+
*/
|
|
2098
|
+
getCodeFromNode( node, type, shaderStage = this.shaderStage ) {
|
|
2099
|
+
|
|
2100
|
+
const nodeData = this.getDataFromNode( node );
|
|
2101
|
+
|
|
2102
|
+
let nodeCode = nodeData.code;
|
|
2103
|
+
|
|
2104
|
+
if ( nodeCode === undefined ) {
|
|
2105
|
+
|
|
2106
|
+
const codes = this.codes[ shaderStage ] || ( this.codes[ shaderStage ] = [] );
|
|
2107
|
+
const index = codes.length;
|
|
2108
|
+
|
|
2109
|
+
nodeCode = new NodeCode( 'nodeCode' + index, type );
|
|
2110
|
+
|
|
2111
|
+
codes.push( nodeCode );
|
|
2112
|
+
|
|
2113
|
+
nodeData.code = nodeCode;
|
|
2114
|
+
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
return nodeCode;
|
|
2118
|
+
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
* Adds a code flow based on the code-block hierarchy.
|
|
2123
|
+
|
|
2124
|
+
* This is used so that code-blocks like If,Else create their variables locally if the Node
|
|
2125
|
+
* is only used inside one of these conditionals in the current shader stage.
|
|
2126
|
+
*
|
|
2127
|
+
* @param {Node} node - The node to add.
|
|
2128
|
+
* @param {Node} nodeBlock - Node-based code-block. Usually 'ConditionalNode'.
|
|
2129
|
+
*/
|
|
2130
|
+
addFlowCodeHierarchy( node, nodeBlock ) {
|
|
2131
|
+
|
|
2132
|
+
const { flowCodes, flowCodeBlock } = this.getDataFromNode( node );
|
|
2133
|
+
|
|
2134
|
+
let needsFlowCode = true;
|
|
2135
|
+
let nodeBlockHierarchy = nodeBlock;
|
|
2136
|
+
|
|
2137
|
+
while ( nodeBlockHierarchy ) {
|
|
2138
|
+
|
|
2139
|
+
if ( flowCodeBlock.get( nodeBlockHierarchy ) === true ) {
|
|
2140
|
+
|
|
2141
|
+
needsFlowCode = false;
|
|
2142
|
+
break;
|
|
2143
|
+
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
nodeBlockHierarchy = this.getDataFromNode( nodeBlockHierarchy ).parentNodeBlock;
|
|
2147
|
+
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
if ( needsFlowCode ) {
|
|
2151
|
+
|
|
2152
|
+
for ( const flowCode of flowCodes ) {
|
|
2153
|
+
|
|
2154
|
+
this.addLineFlowCode( flowCode );
|
|
2155
|
+
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
/**
|
|
2163
|
+
* Add a inline-code to the current flow code-block.
|
|
2164
|
+
*
|
|
2165
|
+
* @param {Node} node - The node to add.
|
|
2166
|
+
* @param {string} code - The code to add.
|
|
2167
|
+
* @param {Node} nodeBlock - Current ConditionalNode
|
|
2168
|
+
*/
|
|
2169
|
+
addLineFlowCodeBlock( node, code, nodeBlock ) {
|
|
2170
|
+
|
|
2171
|
+
const nodeData = this.getDataFromNode( node );
|
|
2172
|
+
const flowCodes = nodeData.flowCodes || ( nodeData.flowCodes = [] );
|
|
2173
|
+
const codeBlock = nodeData.flowCodeBlock || ( nodeData.flowCodeBlock = new WeakMap() );
|
|
2174
|
+
|
|
2175
|
+
flowCodes.push( code );
|
|
2176
|
+
codeBlock.set( nodeBlock, true );
|
|
2177
|
+
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
/**
|
|
2181
|
+
* Add a inline-code to the current flow.
|
|
2182
|
+
*
|
|
2183
|
+
* @param {string} code - The code to add.
|
|
2184
|
+
* @param {?Node} [node= null] - Optional Node, can help the system understand if the Node is part of a code-block.
|
|
2185
|
+
* @return {NodeBuilder} A reference to this node builder.
|
|
2186
|
+
*/
|
|
2187
|
+
addLineFlowCode( code, node = null ) {
|
|
2188
|
+
|
|
2189
|
+
if ( code === '' ) return this;
|
|
2190
|
+
|
|
2191
|
+
if ( node !== null && this.context.nodeBlock ) {
|
|
2192
|
+
|
|
2193
|
+
this.addLineFlowCodeBlock( node, code, this.context.nodeBlock );
|
|
2194
|
+
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
code = this.tab + code;
|
|
2198
|
+
|
|
2199
|
+
if ( ! /;\s*$/.test( code ) ) {
|
|
2200
|
+
|
|
2201
|
+
code = code + ';\n';
|
|
2202
|
+
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
this.flow.code += code;
|
|
2206
|
+
|
|
2207
|
+
return this;
|
|
2208
|
+
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
/**
|
|
2212
|
+
* Adds a code to the current code flow.
|
|
2213
|
+
*
|
|
2214
|
+
* @param {string} code - Shader code.
|
|
2215
|
+
* @return {NodeBuilder} A reference to this node builder.
|
|
2216
|
+
*/
|
|
2217
|
+
addFlowCode( code ) {
|
|
2218
|
+
|
|
2219
|
+
this.flow.code += code;
|
|
2220
|
+
|
|
2221
|
+
return this;
|
|
2222
|
+
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* Add tab in the code that will be generated so that other snippets respect the current tabulation.
|
|
2227
|
+
* Typically used in codes with If,Else.
|
|
2228
|
+
*
|
|
2229
|
+
* @return {NodeBuilder} A reference to this node builder.
|
|
2230
|
+
*/
|
|
2231
|
+
addFlowTab() {
|
|
2232
|
+
|
|
2233
|
+
this.tab += '\t';
|
|
2234
|
+
|
|
2235
|
+
return this;
|
|
2236
|
+
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
/**
|
|
2240
|
+
* Removes a tab.
|
|
2241
|
+
*
|
|
2242
|
+
* @return {NodeBuilder} A reference to this node builder.
|
|
2243
|
+
*/
|
|
2244
|
+
removeFlowTab() {
|
|
2245
|
+
|
|
2246
|
+
this.tab = this.tab.slice( 0, - 1 );
|
|
2247
|
+
|
|
2248
|
+
return this;
|
|
2249
|
+
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
/**
|
|
2253
|
+
* Gets the current flow data based on a Node.
|
|
2254
|
+
*
|
|
2255
|
+
* @param {Node} node - Node that the flow was started.
|
|
2256
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
|
|
2257
|
+
* @return {Object} The flow data.
|
|
2258
|
+
*/
|
|
2259
|
+
getFlowData( node/*, shaderStage*/ ) {
|
|
2260
|
+
|
|
2261
|
+
return this.flowsData.get( node );
|
|
2262
|
+
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
/**
|
|
2266
|
+
* Executes the node flow based on a root node to generate the final shader code.
|
|
2267
|
+
*
|
|
2268
|
+
* @param {Node} node - The node to execute.
|
|
2269
|
+
* @return {Object} The code flow.
|
|
2270
|
+
*/
|
|
2271
|
+
flowNode( node ) {
|
|
2272
|
+
|
|
2273
|
+
const output = node.getNodeType( this );
|
|
2274
|
+
|
|
2275
|
+
const flowData = this.flowChildNode( node, output );
|
|
2276
|
+
|
|
2277
|
+
this.flowsData.set( node, flowData );
|
|
2278
|
+
|
|
2279
|
+
return flowData;
|
|
2280
|
+
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
/**
|
|
2284
|
+
* Includes a node in the current function node.
|
|
2285
|
+
*
|
|
2286
|
+
* @param {Node} node - The node to include.
|
|
2287
|
+
* @returns {void}
|
|
2288
|
+
*/
|
|
2289
|
+
addInclude( node ) {
|
|
2290
|
+
|
|
2291
|
+
if ( this.currentFunctionNode !== null ) {
|
|
2292
|
+
|
|
2293
|
+
this.currentFunctionNode.includes.push( node );
|
|
2294
|
+
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
/**
|
|
2300
|
+
* Returns the native shader operator name for a given generic name.
|
|
2301
|
+
* It is a similar type of method like {@link NodeBuilder#getMethod}.
|
|
2302
|
+
*
|
|
2303
|
+
* @param {ShaderNodeInternal} shaderNode - The shader node to build the function node with.
|
|
2304
|
+
* @return {FunctionNode} The build function node.
|
|
2305
|
+
*/
|
|
2306
|
+
buildFunctionNode( shaderNode ) {
|
|
2307
|
+
|
|
2308
|
+
const fn = new FunctionNode();
|
|
2309
|
+
|
|
2310
|
+
const previous = this.currentFunctionNode;
|
|
2311
|
+
|
|
2312
|
+
this.currentFunctionNode = fn;
|
|
2313
|
+
|
|
2314
|
+
fn.code = this.buildFunctionCode( shaderNode );
|
|
2315
|
+
|
|
2316
|
+
this.currentFunctionNode = previous;
|
|
2317
|
+
|
|
2318
|
+
return fn;
|
|
2319
|
+
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
/**
|
|
2323
|
+
* Generates a code flow based on a TSL function: Fn().
|
|
2324
|
+
*
|
|
2325
|
+
* @param {ShaderNodeInternal} shaderNode - A function code will be generated based on the input.
|
|
2326
|
+
* @return {Object}
|
|
2327
|
+
*/
|
|
2328
|
+
flowShaderNode( shaderNode ) {
|
|
2329
|
+
|
|
2330
|
+
const layout = shaderNode.layout;
|
|
2331
|
+
|
|
2332
|
+
const inputs = {
|
|
2333
|
+
[ Symbol.iterator ]() {
|
|
2334
|
+
|
|
2335
|
+
let index = 0;
|
|
2336
|
+
const values = Object.values( this );
|
|
2337
|
+
return {
|
|
2338
|
+
next: () => ( {
|
|
2339
|
+
value: values[ index ],
|
|
2340
|
+
done: index ++ >= values.length
|
|
2341
|
+
} )
|
|
2342
|
+
};
|
|
2343
|
+
|
|
2344
|
+
}
|
|
2345
|
+
};
|
|
2346
|
+
|
|
2347
|
+
for ( const input of layout.inputs ) {
|
|
2348
|
+
|
|
2349
|
+
inputs[ input.name ] = new ParameterNode( input.type, input.name );
|
|
2350
|
+
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
//
|
|
2354
|
+
|
|
2355
|
+
shaderNode.layout = null;
|
|
2356
|
+
|
|
2357
|
+
const callNode = shaderNode.call( inputs );
|
|
2358
|
+
const flowData = this.flowStagesNode( callNode, layout.type );
|
|
2359
|
+
|
|
2360
|
+
shaderNode.layout = layout;
|
|
2361
|
+
|
|
2362
|
+
return flowData;
|
|
2363
|
+
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
/**
|
|
2367
|
+
* Executes the node in a specific build stage.
|
|
2368
|
+
*
|
|
2369
|
+
* This function can be used to arbitrarily execute the specified build stage
|
|
2370
|
+
* outside of the standard build process. For instance, if a node's type depends
|
|
2371
|
+
* on properties created by the 'setup' stage, then flowBuildStage(node, 'setup')
|
|
2372
|
+
* can be used to execute the setup build stage and access its generated nodes
|
|
2373
|
+
* before the standard build process begins.
|
|
2374
|
+
*
|
|
2375
|
+
* @param {Node} node - The node to execute.
|
|
2376
|
+
* @param {string} buildStage - The build stage to execute the node in.
|
|
2377
|
+
* @param {?(Node|string)} [output=null] - Expected output type. For example 'vec3'.
|
|
2378
|
+
* @return {?(Node|string)} The result of the node build.
|
|
2379
|
+
*/
|
|
2380
|
+
flowBuildStage( node, buildStage, output = null ) {
|
|
2381
|
+
|
|
2382
|
+
const previousBuildStage = this.getBuildStage();
|
|
2383
|
+
|
|
2384
|
+
this.setBuildStage( buildStage );
|
|
2385
|
+
|
|
2386
|
+
const result = node.build( this, output );
|
|
2387
|
+
|
|
2388
|
+
this.setBuildStage( previousBuildStage );
|
|
2389
|
+
|
|
2390
|
+
return result;
|
|
2391
|
+
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
/**
|
|
2395
|
+
* Runs the node flow through all the steps of creation, 'setup', 'analyze', 'generate'.
|
|
2396
|
+
*
|
|
2397
|
+
* @param {Node} node - The node to execute.
|
|
2398
|
+
* @param {?string} output - Expected output type. For example 'vec3'.
|
|
2399
|
+
* @return {Object}
|
|
2400
|
+
*/
|
|
2401
|
+
flowStagesNode( node, output = null ) {
|
|
2402
|
+
|
|
2403
|
+
const previousFlow = this.flow;
|
|
2404
|
+
const previousVars = this.vars;
|
|
2405
|
+
const previousDeclarations = this.declarations;
|
|
2406
|
+
const previousCache = this.cache;
|
|
2407
|
+
const previousBuildStage = this.buildStage;
|
|
2408
|
+
const previousStack = this.stack;
|
|
2409
|
+
|
|
2410
|
+
const flow = {
|
|
2411
|
+
code: ''
|
|
2412
|
+
};
|
|
2413
|
+
|
|
2414
|
+
this.flow = flow;
|
|
2415
|
+
this.vars = {};
|
|
2416
|
+
this.declarations = {};
|
|
2417
|
+
this.cache = new NodeCache();
|
|
2418
|
+
this.stack = stack();
|
|
2419
|
+
|
|
2420
|
+
for ( const buildStage of defaultBuildStages ) {
|
|
2421
|
+
|
|
2422
|
+
this.setBuildStage( buildStage );
|
|
2423
|
+
|
|
2424
|
+
flow.result = node.build( this, output );
|
|
2425
|
+
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
flow.vars = this.getVars( this.shaderStage );
|
|
2429
|
+
|
|
2430
|
+
this.flow = previousFlow;
|
|
2431
|
+
this.vars = previousVars;
|
|
2432
|
+
this.declarations = previousDeclarations;
|
|
2433
|
+
this.cache = previousCache;
|
|
2434
|
+
this.stack = previousStack;
|
|
2435
|
+
|
|
2436
|
+
this.setBuildStage( previousBuildStage );
|
|
2437
|
+
|
|
2438
|
+
return flow;
|
|
2439
|
+
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
/**
|
|
2443
|
+
* Returns the native shader operator name for a given generic name.
|
|
2444
|
+
* It is a similar type of method like {@link NodeBuilder#getMethod}.
|
|
2445
|
+
*
|
|
2446
|
+
* @abstract
|
|
2447
|
+
* @param {string} op - The operator name to resolve.
|
|
2448
|
+
* @return {?string} The resolved operator name.
|
|
2449
|
+
*/
|
|
2450
|
+
getFunctionOperator( /* op */ ) {
|
|
2451
|
+
|
|
2452
|
+
return null;
|
|
2453
|
+
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
/**
|
|
2457
|
+
* Builds the given shader node.
|
|
2458
|
+
*
|
|
2459
|
+
* @abstract
|
|
2460
|
+
* @param {ShaderNodeInternal} shaderNode - The shader node.
|
|
2461
|
+
* @return {string} The function code.
|
|
2462
|
+
*/
|
|
2463
|
+
buildFunctionCode( /* shaderNode */ ) {
|
|
2464
|
+
|
|
2465
|
+
warn( 'Abstract function.' );
|
|
2466
|
+
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
/**
|
|
2470
|
+
* Generates a code flow based on a child Node.
|
|
2471
|
+
*
|
|
2472
|
+
* @param {Node} node - The node to execute.
|
|
2473
|
+
* @param {?string} output - Expected output type. For example 'vec3'.
|
|
2474
|
+
* @return {Object} The code flow.
|
|
2475
|
+
*/
|
|
2476
|
+
flowChildNode( node, output = null ) {
|
|
2477
|
+
|
|
2478
|
+
const previousFlow = this.flow;
|
|
2479
|
+
|
|
2480
|
+
const flow = {
|
|
2481
|
+
code: ''
|
|
2482
|
+
};
|
|
2483
|
+
|
|
2484
|
+
this.flow = flow;
|
|
2485
|
+
|
|
2486
|
+
flow.result = node.build( this, output );
|
|
2487
|
+
|
|
2488
|
+
this.flow = previousFlow;
|
|
2489
|
+
|
|
2490
|
+
return flow;
|
|
2491
|
+
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
/**
|
|
2495
|
+
* Executes a flow of code in a different stage.
|
|
2496
|
+
*
|
|
2497
|
+
* Some nodes like `varying()` have the ability to compute code in vertex-stage and
|
|
2498
|
+
* return the value in fragment-stage even if it is being executed in an input fragment.
|
|
2499
|
+
*
|
|
2500
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
|
|
2501
|
+
* @param {Node} node - The node to execute.
|
|
2502
|
+
* @param {?string} output - Expected output type. For example 'vec3'.
|
|
2503
|
+
* @param {?string} propertyName - The property name to assign the result.
|
|
2504
|
+
* @return {?(Object|Node)} The code flow or node.build() result.
|
|
2505
|
+
*/
|
|
2506
|
+
flowNodeFromShaderStage( shaderStage, node, output = null, propertyName = null ) {
|
|
2507
|
+
|
|
2508
|
+
const previousTab = this.tab;
|
|
2509
|
+
const previousCache = this.cache;
|
|
2510
|
+
const previousShaderStage = this.shaderStage;
|
|
2511
|
+
const previousContext = this.context;
|
|
2512
|
+
|
|
2513
|
+
this.setShaderStage( shaderStage );
|
|
2514
|
+
|
|
2515
|
+
const context = { ...this.context };
|
|
2516
|
+
delete context.nodeBlock;
|
|
2517
|
+
|
|
2518
|
+
this.cache = this.globalCache;
|
|
2519
|
+
this.tab = '\t';
|
|
2520
|
+
this.context = context;
|
|
2521
|
+
|
|
2522
|
+
let result = null;
|
|
2523
|
+
|
|
2524
|
+
if ( this.buildStage === 'generate' ) {
|
|
2525
|
+
|
|
2526
|
+
const flowData = this.flowChildNode( node, output );
|
|
2527
|
+
|
|
2528
|
+
if ( propertyName !== null ) {
|
|
2529
|
+
|
|
2530
|
+
flowData.code += `${ this.tab + propertyName } = ${ flowData.result };\n`;
|
|
2531
|
+
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
this.flowCode[ shaderStage ] = this.flowCode[ shaderStage ] + flowData.code;
|
|
2535
|
+
|
|
2536
|
+
result = flowData;
|
|
2537
|
+
|
|
2538
|
+
} else {
|
|
2539
|
+
|
|
2540
|
+
result = node.build( this );
|
|
2541
|
+
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
this.setShaderStage( previousShaderStage );
|
|
2545
|
+
|
|
2546
|
+
this.cache = previousCache;
|
|
2547
|
+
this.tab = previousTab;
|
|
2548
|
+
this.context = previousContext;
|
|
2549
|
+
|
|
2550
|
+
return result;
|
|
2551
|
+
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
/**
|
|
2555
|
+
* Returns an array holding all node attributes of this node builder.
|
|
2556
|
+
*
|
|
2557
|
+
* @return {Array<NodeAttribute>} The node attributes of this builder.
|
|
2558
|
+
*/
|
|
2559
|
+
getAttributesArray() {
|
|
2560
|
+
|
|
2561
|
+
return this.attributes.concat( this.bufferAttributes );
|
|
2562
|
+
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
/**
|
|
2566
|
+
* Returns the attribute definitions as a shader string for the given shader stage.
|
|
2567
|
+
*
|
|
2568
|
+
* @abstract
|
|
2569
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
|
|
2570
|
+
* @return {string} The attribute code section.
|
|
2571
|
+
*/
|
|
2572
|
+
getAttributes( /*shaderStage*/ ) {
|
|
2573
|
+
|
|
2574
|
+
warn( 'Abstract function.' );
|
|
2575
|
+
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
/**
|
|
2579
|
+
* Returns the varying definitions as a shader string for the given shader stage.
|
|
2580
|
+
*
|
|
2581
|
+
* @abstract
|
|
2582
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
|
|
2583
|
+
* @return {string} The varying code section.
|
|
2584
|
+
*/
|
|
2585
|
+
getVaryings( /*shaderStage*/ ) {
|
|
2586
|
+
|
|
2587
|
+
warn( 'Abstract function.' );
|
|
2588
|
+
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
/**
|
|
2592
|
+
* Returns a single variable definition as a shader string for the given variable type and name.
|
|
2593
|
+
*
|
|
2594
|
+
* @param {string} type - The variable's type.
|
|
2595
|
+
* @param {string} name - The variable's name.
|
|
2596
|
+
* @param {?number} [count=null] - The array length.
|
|
2597
|
+
* @return {string} The shader string.
|
|
2598
|
+
*/
|
|
2599
|
+
getVar( type, name, count = null ) {
|
|
2600
|
+
|
|
2601
|
+
return `${ count !== null ? this.generateArrayDeclaration( type, count ) : this.getType( type ) } ${ name }`;
|
|
2602
|
+
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
/**
|
|
2606
|
+
* Returns the variable definitions as a shader string for the given shader stage.
|
|
2607
|
+
*
|
|
2608
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
|
|
2609
|
+
* @return {string} The variable code section.
|
|
2610
|
+
*/
|
|
2611
|
+
getVars( shaderStage ) {
|
|
2612
|
+
|
|
2613
|
+
let snippet = '';
|
|
2614
|
+
|
|
2615
|
+
const vars = this.vars[ shaderStage ];
|
|
2616
|
+
|
|
2617
|
+
if ( vars !== undefined ) {
|
|
2618
|
+
|
|
2619
|
+
for ( const variable of vars ) {
|
|
2620
|
+
|
|
2621
|
+
snippet += `${ this.getVar( variable.type, variable.name ) }; `;
|
|
2622
|
+
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
return snippet;
|
|
2628
|
+
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2631
|
+
/**
|
|
2632
|
+
* Returns the uniform definitions as a shader string for the given shader stage.
|
|
2633
|
+
*
|
|
2634
|
+
* @abstract
|
|
2635
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
|
|
2636
|
+
* @return {string} The uniform code section.
|
|
2637
|
+
*/
|
|
2638
|
+
getUniforms( /*shaderStage*/ ) {
|
|
2639
|
+
|
|
2640
|
+
warn( 'Abstract function.' );
|
|
2641
|
+
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
/**
|
|
2645
|
+
* Returns the native code definitions as a shader string for the given shader stage.
|
|
2646
|
+
*
|
|
2647
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
|
|
2648
|
+
* @return {string} The native code section.
|
|
2649
|
+
*/
|
|
2650
|
+
getCodes( shaderStage ) {
|
|
2651
|
+
|
|
2652
|
+
const codes = this.codes[ shaderStage ];
|
|
2653
|
+
|
|
2654
|
+
let code = '';
|
|
2655
|
+
|
|
2656
|
+
if ( codes !== undefined ) {
|
|
2657
|
+
|
|
2658
|
+
for ( const nodeCode of codes ) {
|
|
2659
|
+
|
|
2660
|
+
code += nodeCode.code + '\n';
|
|
2661
|
+
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
return code;
|
|
2667
|
+
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
/**
|
|
2671
|
+
* Returns the hash of this node builder.
|
|
2672
|
+
*
|
|
2673
|
+
* @return {string} The hash.
|
|
2674
|
+
*/
|
|
2675
|
+
getHash() {
|
|
2676
|
+
|
|
2677
|
+
return this.vertexShader + this.fragmentShader + this.computeShader;
|
|
2678
|
+
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
/**
|
|
2682
|
+
* Sets the current shader stage.
|
|
2683
|
+
*
|
|
2684
|
+
* @param {?('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage to set.
|
|
2685
|
+
*/
|
|
2686
|
+
setShaderStage( shaderStage ) {
|
|
2687
|
+
|
|
2688
|
+
this.shaderStage = shaderStage;
|
|
2689
|
+
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
/**
|
|
2693
|
+
* Returns the current shader stage.
|
|
2694
|
+
*
|
|
2695
|
+
* @return {?('vertex'|'fragment'|'compute'|'any')} The current shader stage.
|
|
2696
|
+
*/
|
|
2697
|
+
getShaderStage() {
|
|
2698
|
+
|
|
2699
|
+
return this.shaderStage;
|
|
2700
|
+
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
/**
|
|
2704
|
+
* Sets the current build stage.
|
|
2705
|
+
*
|
|
2706
|
+
* @param {?('setup'|'analyze'|'generate')} buildStage - The build stage to set.
|
|
2707
|
+
*/
|
|
2708
|
+
setBuildStage( buildStage ) {
|
|
2709
|
+
|
|
2710
|
+
this.buildStage = buildStage;
|
|
2711
|
+
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
/**
|
|
2715
|
+
* Returns the current build stage.
|
|
2716
|
+
*
|
|
2717
|
+
* @return {?('setup'|'analyze'|'generate')} The current build stage.
|
|
2718
|
+
*/
|
|
2719
|
+
getBuildStage() {
|
|
2720
|
+
|
|
2721
|
+
return this.buildStage;
|
|
2722
|
+
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
/**
|
|
2726
|
+
* Controls the code build of the shader stages.
|
|
2727
|
+
*
|
|
2728
|
+
* @abstract
|
|
2729
|
+
*/
|
|
2730
|
+
buildCode() {
|
|
2731
|
+
|
|
2732
|
+
warn( 'Abstract function.' );
|
|
2733
|
+
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
/**
|
|
2737
|
+
* Returns the current sub-build layer.
|
|
2738
|
+
*
|
|
2739
|
+
* @return {SubBuildNode} The current sub-build layers.
|
|
2740
|
+
*/
|
|
2741
|
+
get subBuild() {
|
|
2742
|
+
|
|
2743
|
+
return this.subBuildLayers[ this.subBuildLayers.length - 1 ] || null;
|
|
2744
|
+
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
/**
|
|
2748
|
+
* Adds a sub-build layer to the node builder.
|
|
2749
|
+
*
|
|
2750
|
+
* @param {SubBuildNode} subBuild - The sub-build layer to add.
|
|
2751
|
+
*/
|
|
2752
|
+
addSubBuild( subBuild ) {
|
|
2753
|
+
|
|
2754
|
+
this.subBuildLayers.push( subBuild );
|
|
2755
|
+
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
/**
|
|
2759
|
+
* Removes the last sub-build layer from the node builder.
|
|
2760
|
+
*
|
|
2761
|
+
* @return {SubBuildNode} The removed sub-build layer.
|
|
2762
|
+
*/
|
|
2763
|
+
removeSubBuild() {
|
|
2764
|
+
|
|
2765
|
+
return this.subBuildLayers.pop();
|
|
2766
|
+
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
/**
|
|
2770
|
+
* Returns the closest sub-build layer for the given data.
|
|
2771
|
+
*
|
|
2772
|
+
* @param {Node|Set<string>|Array<string>} data - The data to get the closest sub-build layer from.
|
|
2773
|
+
* @return {?string} The closest sub-build name or null if none found.
|
|
2774
|
+
*/
|
|
2775
|
+
getClosestSubBuild( data ) {
|
|
2776
|
+
|
|
2777
|
+
let subBuilds;
|
|
2778
|
+
|
|
2779
|
+
if ( data && data.isNode ) {
|
|
2780
|
+
|
|
2781
|
+
if ( data.isShaderCallNodeInternal ) {
|
|
2782
|
+
|
|
2783
|
+
subBuilds = data.shaderNode.subBuilds;
|
|
2784
|
+
|
|
2785
|
+
} else if ( data.isStackNode ) {
|
|
2786
|
+
|
|
2787
|
+
subBuilds = [ data.subBuild ];
|
|
2788
|
+
|
|
2789
|
+
} else {
|
|
2790
|
+
|
|
2791
|
+
subBuilds = this.getDataFromNode( data, 'any' ).subBuilds;
|
|
2792
|
+
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
} else if ( data instanceof Set ) {
|
|
2796
|
+
|
|
2797
|
+
subBuilds = [ ...data ];
|
|
2798
|
+
|
|
2799
|
+
} else {
|
|
2800
|
+
|
|
2801
|
+
subBuilds = data;
|
|
2802
|
+
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
if ( ! subBuilds ) return null;
|
|
2806
|
+
|
|
2807
|
+
const subBuildLayers = this.subBuildLayers;
|
|
2808
|
+
|
|
2809
|
+
for ( let i = subBuilds.length - 1; i >= 0; i -- ) {
|
|
2810
|
+
|
|
2811
|
+
const subBuild = subBuilds[ i ];
|
|
2812
|
+
|
|
2813
|
+
if ( subBuildLayers.includes( subBuild ) ) {
|
|
2814
|
+
|
|
2815
|
+
return subBuild;
|
|
2816
|
+
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
return null;
|
|
2822
|
+
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
|
|
2826
|
+
/**
|
|
2827
|
+
* Returns the output node of a sub-build layer.
|
|
2828
|
+
*
|
|
2829
|
+
* @param {Node} node - The node to get the output from.
|
|
2830
|
+
* @return {string} The output node name.
|
|
2831
|
+
*/
|
|
2832
|
+
getSubBuildOutput( node ) {
|
|
2833
|
+
|
|
2834
|
+
return this.getSubBuildProperty( 'outputNode', node );
|
|
2835
|
+
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
/**
|
|
2839
|
+
* Returns the sub-build property name for the given property and node.
|
|
2840
|
+
*
|
|
2841
|
+
* @param {string} [property=''] - The property name.
|
|
2842
|
+
* @param {?Node} [node=null] - The node to get the sub-build from.
|
|
2843
|
+
* @return {string} The sub-build property name.
|
|
2844
|
+
*/
|
|
2845
|
+
getSubBuildProperty( property = '', node = null ) {
|
|
2846
|
+
|
|
2847
|
+
let subBuild;
|
|
2848
|
+
|
|
2849
|
+
if ( node !== null ) {
|
|
2850
|
+
|
|
2851
|
+
subBuild = this.getClosestSubBuild( node );
|
|
2852
|
+
|
|
2853
|
+
} else {
|
|
2854
|
+
|
|
2855
|
+
subBuild = this.subBuildFn;
|
|
2856
|
+
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
let result;
|
|
2860
|
+
|
|
2861
|
+
if ( subBuild ) {
|
|
2862
|
+
|
|
2863
|
+
result = property ? ( subBuild + '_' + property ) : subBuild;
|
|
2864
|
+
|
|
2865
|
+
} else {
|
|
2866
|
+
|
|
2867
|
+
result = property;
|
|
2868
|
+
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
return result;
|
|
2872
|
+
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
/**
|
|
2876
|
+
* Central build method which controls the build for the given object.
|
|
2877
|
+
*
|
|
2878
|
+
* @return {NodeBuilder} A reference to this node builder.
|
|
2879
|
+
*/
|
|
2880
|
+
build() {
|
|
2881
|
+
|
|
2882
|
+
const { object, material, renderer } = this;
|
|
2883
|
+
|
|
2884
|
+
if ( material !== null ) {
|
|
2885
|
+
|
|
2886
|
+
let nodeMaterial = renderer.library.fromMaterial( material );
|
|
2887
|
+
|
|
2888
|
+
if ( nodeMaterial === null ) {
|
|
2889
|
+
|
|
2890
|
+
error( `NodeMaterial: Material "${ material.type }" is not compatible.` );
|
|
2891
|
+
|
|
2892
|
+
nodeMaterial = new NodeMaterial();
|
|
2893
|
+
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
nodeMaterial.build( this );
|
|
2897
|
+
|
|
2898
|
+
} else {
|
|
2899
|
+
|
|
2900
|
+
this.addFlow( 'compute', object );
|
|
2901
|
+
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
// setup() -> stage 1: create possible new nodes and/or return an output reference node
|
|
2905
|
+
// analyze() -> stage 2: analyze nodes to possible optimization and validation
|
|
2906
|
+
// generate() -> stage 3: generate shader
|
|
2907
|
+
|
|
2908
|
+
for ( const buildStage of defaultBuildStages ) {
|
|
2909
|
+
|
|
2910
|
+
this.setBuildStage( buildStage );
|
|
2911
|
+
|
|
2912
|
+
if ( this.context.vertex && this.context.vertex.isNode ) {
|
|
2913
|
+
|
|
2914
|
+
this.flowNodeFromShaderStage( 'vertex', this.context.vertex );
|
|
2915
|
+
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
for ( const shaderStage of shaderStages ) {
|
|
2919
|
+
|
|
2920
|
+
this.setShaderStage( shaderStage );
|
|
2921
|
+
|
|
2922
|
+
const flowNodes = this.flowNodes[ shaderStage ];
|
|
2923
|
+
|
|
2924
|
+
for ( const node of flowNodes ) {
|
|
2925
|
+
|
|
2926
|
+
if ( buildStage === 'generate' ) {
|
|
2927
|
+
|
|
2928
|
+
this.flowNode( node );
|
|
2929
|
+
|
|
2930
|
+
} else {
|
|
2931
|
+
|
|
2932
|
+
node.build( this );
|
|
2933
|
+
|
|
2934
|
+
}
|
|
2935
|
+
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2942
|
+
this.setBuildStage( null );
|
|
2943
|
+
this.setShaderStage( null );
|
|
2944
|
+
|
|
2945
|
+
// stage 4: build code for a specific output
|
|
2946
|
+
|
|
2947
|
+
this.buildCode();
|
|
2948
|
+
this.buildUpdateNodes();
|
|
2949
|
+
|
|
2950
|
+
return this;
|
|
2951
|
+
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
/**
|
|
2955
|
+
* Returns a uniform representation which is later used for UBO generation and rendering.
|
|
2956
|
+
*
|
|
2957
|
+
* @param {NodeUniform} uniformNode - The uniform node.
|
|
2958
|
+
* @param {string} type - The requested type.
|
|
2959
|
+
* @return {Uniform} The uniform.
|
|
2960
|
+
*/
|
|
2961
|
+
getNodeUniform( uniformNode, type ) {
|
|
2962
|
+
|
|
2963
|
+
if ( type === 'float' || type === 'int' || type === 'uint' ) return new NumberNodeUniform( uniformNode );
|
|
2964
|
+
if ( type === 'vec2' || type === 'ivec2' || type === 'uvec2' ) return new Vector2NodeUniform( uniformNode );
|
|
2965
|
+
if ( type === 'vec3' || type === 'ivec3' || type === 'uvec3' ) return new Vector3NodeUniform( uniformNode );
|
|
2966
|
+
if ( type === 'vec4' || type === 'ivec4' || type === 'uvec4' ) return new Vector4NodeUniform( uniformNode );
|
|
2967
|
+
if ( type === 'color' ) return new ColorNodeUniform( uniformNode );
|
|
2968
|
+
if ( type === 'mat2' ) return new Matrix2NodeUniform( uniformNode );
|
|
2969
|
+
if ( type === 'mat3' ) return new Matrix3NodeUniform( uniformNode );
|
|
2970
|
+
if ( type === 'mat4' ) return new Matrix4NodeUniform( uniformNode );
|
|
2971
|
+
|
|
2972
|
+
throw new Error( `Uniform "${type}" not declared.` );
|
|
2973
|
+
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
/**
|
|
2977
|
+
* Formats the given shader snippet from a given type into another one. E.g.
|
|
2978
|
+
* this method might be used to convert a simple float string `"1.0"` into a
|
|
2979
|
+
* `vec3` representation: `"vec3<f32>( 1.0 )"`.
|
|
2980
|
+
*
|
|
2981
|
+
* @param {string} snippet - The shader snippet.
|
|
2982
|
+
* @param {string} fromType - The source type.
|
|
2983
|
+
* @param {string} toType - The target type.
|
|
2984
|
+
* @return {string} The updated shader string.
|
|
2985
|
+
*/
|
|
2986
|
+
format( snippet, fromType, toType ) {
|
|
2987
|
+
|
|
2988
|
+
fromType = this.getVectorType( fromType );
|
|
2989
|
+
toType = this.getVectorType( toType );
|
|
2990
|
+
|
|
2991
|
+
if ( fromType === toType || toType === null || this.isReference( toType ) ) {
|
|
2992
|
+
|
|
2993
|
+
return snippet;
|
|
2994
|
+
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2997
|
+
const fromTypeLength = this.getTypeLength( fromType );
|
|
2998
|
+
const toTypeLength = this.getTypeLength( toType );
|
|
2999
|
+
|
|
3000
|
+
if ( fromTypeLength === 16 && toTypeLength === 9 ) {
|
|
3001
|
+
|
|
3002
|
+
return `${ this.getType( toType ) }( ${ snippet }[ 0 ].xyz, ${ snippet }[ 1 ].xyz, ${ snippet }[ 2 ].xyz )`;
|
|
3003
|
+
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
if ( fromTypeLength === 9 && toTypeLength === 4 ) {
|
|
3007
|
+
|
|
3008
|
+
return `${ this.getType( toType ) }( ${ snippet }[ 0 ].xy, ${ snippet }[ 1 ].xy )`;
|
|
3009
|
+
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
|
|
3013
|
+
if ( fromTypeLength > 4 ) { // fromType is matrix-like
|
|
3014
|
+
|
|
3015
|
+
// @TODO: ignore for now
|
|
3016
|
+
|
|
3017
|
+
return snippet;
|
|
3018
|
+
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
if ( toTypeLength > 4 || toTypeLength === 0 ) { // toType is matrix-like or unknown
|
|
3022
|
+
|
|
3023
|
+
// @TODO: ignore for now
|
|
3024
|
+
|
|
3025
|
+
return snippet;
|
|
3026
|
+
|
|
3027
|
+
}
|
|
3028
|
+
|
|
3029
|
+
if ( fromTypeLength === toTypeLength ) {
|
|
3030
|
+
|
|
3031
|
+
return `${ this.getType( toType ) }( ${ snippet } )`;
|
|
3032
|
+
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
if ( fromTypeLength > toTypeLength ) {
|
|
3036
|
+
|
|
3037
|
+
snippet = toType === 'bool' ? `all( ${ snippet } )` : `${ snippet }.${ 'xyz'.slice( 0, toTypeLength ) }`;
|
|
3038
|
+
|
|
3039
|
+
return this.format( snippet, this.getTypeFromLength( toTypeLength, this.getComponentType( fromType ) ), toType );
|
|
3040
|
+
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
if ( toTypeLength === 4 && fromTypeLength > 1 ) { // toType is vec4-like
|
|
3044
|
+
|
|
3045
|
+
return `${ this.getType( toType ) }( ${ this.format( snippet, fromType, 'vec3' ) }, 1.0 )`;
|
|
3046
|
+
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
if ( fromTypeLength === 2 ) { // fromType is vec2-like and toType is vec3-like
|
|
3050
|
+
|
|
3051
|
+
return `${ this.getType( toType ) }( ${ this.format( snippet, fromType, 'vec2' ) }, 0.0 )`;
|
|
3052
|
+
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
if ( fromTypeLength === 1 && toTypeLength > 1 && fromType !== this.getComponentType( toType ) ) { // fromType is float-like
|
|
3056
|
+
|
|
3057
|
+
// convert a number value to vector type, e.g:
|
|
3058
|
+
// vec3( 1u ) -> vec3( float( 1u ) )
|
|
3059
|
+
|
|
3060
|
+
snippet = `${ this.getType( this.getComponentType( toType ) ) }( ${ snippet } )`;
|
|
3061
|
+
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
return `${ this.getType( toType ) }( ${ snippet } )`; // fromType is float-like
|
|
3065
|
+
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
/**
|
|
3069
|
+
* Returns a signature with the engine's current revision.
|
|
3070
|
+
*
|
|
3071
|
+
* @return {string} The signature.
|
|
3072
|
+
*/
|
|
3073
|
+
getSignature() {
|
|
3074
|
+
|
|
3075
|
+
return `// Three.js r${ REVISION } - Node System\n`;
|
|
3076
|
+
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
export default NodeBuilder;
|