@gnsx/three 0.185.15 → 0.186.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +10 -82600
- package/build/three.core.js +1303 -728
- package/build/three.module.js +439 -338
- package/build/three.tsl.js +74 -44
- package/build/three.webgpu.js +6036 -2184
- package/build/three.webgpu.nodes.js +6020 -2184
- package/examples/jsm/Addons.js +6 -6
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +44 -20
- package/examples/jsm/controls/OrbitControls.js +9 -0
- package/examples/jsm/controls/TrackballControls.js +109 -4
- package/examples/jsm/csm/CSMShadowNode.js +13 -0
- package/examples/jsm/exporters/GLTFExporter.js +23 -7
- package/examples/jsm/exporters/USDZExporter.js +2 -2
- package/examples/jsm/generators/CityGenerator.js +377 -45
- package/examples/jsm/generators/ForestGenerator.js +12 -12
- package/examples/jsm/generators/TerrainGenerator.js +49 -37
- package/examples/jsm/generators/TreeGenerator.js +70 -76
- package/examples/jsm/generators/city/BenchGenerator.js +127 -0
- package/examples/jsm/generators/city/CarGenerator.js +479 -0
- package/examples/jsm/generators/city/CityGeneratorUtils.js +31 -0
- package/examples/jsm/generators/city/HydrantGenerator.js +106 -0
- package/examples/jsm/generators/city/InstancedMeshGenerator.js +86 -0
- package/examples/jsm/generators/city/PersonGenerator.js +447 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +33 -38
- package/examples/jsm/generators/city/SkyscraperGenerator.js +448 -48
- package/examples/jsm/generators/city/StreetTreeGenerator.js +231 -0
- package/examples/jsm/generators/city/StreetlightGenerator.js +100 -0
- package/examples/jsm/generators/city/TrafficlightGenerator.js +106 -0
- package/examples/jsm/generators/city/TrashcanGenerator.js +100 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/RoundedBoxGeometry.js +1 -1
- package/examples/jsm/gpgpu/CountingSort.js +271 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +60 -239
- package/examples/jsm/helpers/LightProbeGridHelperWebGL.js +221 -0
- package/examples/jsm/inspector/Extension.js +94 -0
- package/examples/jsm/inspector/Inspector.js +145 -41
- package/examples/jsm/inspector/RendererInspector.js +100 -52
- package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +2609 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorWheel.js +352 -0
- package/examples/jsm/inspector/extensions/color-grading/CurveEditor.js +599 -0
- package/examples/jsm/inspector/extensions/color-grading/LUT3DStyle.js +1201 -0
- package/examples/jsm/inspector/extensions/color-grading/LUTMath.js +788 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/BrightnessModule.js +72 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ColorWheelModule.js +112 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ContrastModule.js +82 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/CurvesModule.js +109 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureHueModule.js +110 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureModule.js +73 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/HueModule.js +78 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ImportedCubeModule.js +89 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/Module.js +285 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/OutputModule.js +101 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/RendererModule.js +225 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SatVibranceModule.js +102 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SaturationModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/VibranceModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/WhiteBalanceModule.js +86 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +26 -31
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -0
- package/examples/jsm/inspector/tabs/Memory.js +0 -2
- package/examples/jsm/inspector/tabs/Settings.js +4 -0
- package/examples/jsm/inspector/tabs/Timeline.js +223 -171
- package/examples/jsm/inspector/tabs/Viewer.js +515 -21
- package/examples/jsm/inspector/ui/List.js +15 -9
- package/examples/jsm/inspector/ui/Profiler.js +170 -14
- package/examples/jsm/inspector/ui/Style.js +269 -23
- package/examples/jsm/inspector/ui/Tab.js +2 -0
- package/examples/jsm/inspector/ui/Values.js +14 -2
- package/examples/jsm/interactive/HTMLMesh.js +19 -3
- package/examples/jsm/lighting/LightProbeGrid.js +484 -889
- package/examples/jsm/lighting/LightProbeGridUtils.js +107 -0
- package/examples/jsm/lighting/LightProbeGridWebGL.js +841 -0
- package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +194 -0
- package/examples/jsm/lighting/vxgi/VXGINode.js +660 -0
- package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +478 -0
- package/examples/jsm/lighting/vxgi/VXGIVolume.js +1430 -0
- package/examples/jsm/lights/SunLight.js +95 -0
- package/examples/jsm/lights/SunLightNode.js +56 -0
- package/examples/jsm/lights/SunLightShadow.js +319 -0
- package/examples/jsm/lights/SunShadowNode.js +312 -0
- package/examples/jsm/loaders/3DMLoader.js +150 -49
- package/examples/jsm/loaders/3MFLoader.js +202 -1
- package/examples/jsm/loaders/FBXLoader.js +81 -5
- package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.js +330 -0
- package/examples/jsm/loaders/GLTFLoader.js +79 -14
- package/examples/jsm/loaders/GaussianSplatPLYLoader.js +386 -0
- package/examples/jsm/loaders/KSPLATLoader.js +463 -0
- package/examples/jsm/loaders/MaterialXLoader.js +111 -1010
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/SPLATLoader.js +139 -0
- package/examples/jsm/loaders/SPZLoader.js +561 -0
- package/examples/jsm/loaders/materialx/MaterialXArchive.js +108 -0
- package/examples/jsm/loaders/materialx/MaterialXDocument.js +878 -0
- package/examples/jsm/loaders/materialx/MaterialXHextile.js +183 -0
- package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +376 -0
- package/examples/jsm/loaders/materialx/MaterialXLog.js +75 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +4 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +1021 -0
- package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +661 -0
- package/examples/jsm/loaders/materialx/MaterialXUtils.js +57 -0
- package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +997 -0
- package/examples/jsm/loaders/materialx/parse/MaterialXParser.js +28 -0
- package/examples/jsm/loaders/usd/USDAParser.js +15 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -4
- package/examples/jsm/loaders/usd/USDComposer.js +80 -42
- package/examples/jsm/materials/WoodNodeMaterial.js +6 -108
- package/examples/jsm/misc/RollerCoaster.js +2 -2
- package/examples/jsm/misc/SculptGL.LICENSE.txt +21 -0
- package/examples/jsm/misc/Sculptor.js +1679 -0
- package/examples/jsm/misc/SculptorMesh.js +1504 -0
- package/examples/jsm/misc/SculptorTools.js +1180 -0
- package/examples/jsm/misc/SculptorUtils.js +345 -0
- package/examples/jsm/misc/TubePainter.js +28 -16
- package/examples/jsm/misc/VolumeSlice.js +24 -24
- package/examples/jsm/modifiers/SimplifyModifier.js +63 -556
- package/examples/jsm/objects/GaussianSplat.js +1039 -0
- package/examples/jsm/objects/Sky.js +66 -45
- package/examples/jsm/objects/SkyMesh.js +70 -51
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/postprocessing/AfterimagePass.js +4 -2
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/GTAOPass.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +5 -5
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +4 -2
- package/examples/jsm/postprocessing/SavePass.js +1 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +30 -13
- package/examples/jsm/renderers/CSS2DRenderer.js +29 -5
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
- package/examples/jsm/shaders/ExposureShader.js +1 -1
- package/examples/jsm/shaders/FilmShader.js +2 -1
- package/examples/jsm/transpiler/AST.js +21 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +498 -8
- package/examples/jsm/transpiler/TSLEncoder.js +82 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +33 -4
- package/examples/jsm/tsl/WebGLNodesHandler.js +29 -39
- package/examples/jsm/tsl/display/AfterImageNode.js +2 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +3 -2
- package/examples/jsm/tsl/display/BilateralBlurNode.js +5 -2
- package/examples/jsm/tsl/display/BloomNode.js +55 -30
- package/examples/jsm/tsl/display/DenoiseNode.js +21 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +24 -6
- package/examples/jsm/tsl/display/DotScreenNode.js +11 -11
- package/examples/jsm/tsl/display/FSR1Node.js +8 -4
- package/examples/jsm/tsl/display/GTAONode.js +199 -86
- package/examples/jsm/tsl/display/GaussianBlurNode.js +65 -52
- package/examples/jsm/tsl/display/GodraysNode.js +5 -2
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +2 -2
- package/examples/jsm/tsl/display/LensflareNode.js +5 -2
- package/examples/jsm/tsl/display/OITPassNode.js +352 -0
- package/examples/jsm/tsl/display/OutlineNode.js +2 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +3 -2
- package/examples/jsm/tsl/display/RGBShiftNode.js +9 -9
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +7 -4
- package/examples/jsm/tsl/display/RetroPassNode.js +1 -1
- package/examples/jsm/tsl/display/SMAANode.js +22 -61
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -4
- package/examples/jsm/tsl/display/SSAONode.js +436 -0
- package/examples/jsm/tsl/display/SSGINode.js +5 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -2
- package/examples/jsm/tsl/display/SSSNode.js +5 -2
- package/examples/jsm/tsl/display/SharpenNode.js +5 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -3
- package/examples/jsm/tsl/display/TAAUNode.js +22 -125
- package/examples/jsm/tsl/display/TRAANode.js +16 -142
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +21 -15
- package/examples/jsm/tsl/display/depthAwareBlur.js +63 -0
- package/examples/jsm/tsl/display/hashBlur.js +3 -2
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +38 -27
- package/examples/jsm/tsl/lighting/LightProbeGridNode.js +136 -0
- package/examples/jsm/tsl/math/voronoiNoise.js +112 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +4 -6
- package/examples/jsm/tsl/utils/Raymarching.js +5 -5
- package/examples/jsm/tsl/utils/SoftParticles.js +60 -0
- package/examples/jsm/tsl/utils/TAAUtils.js +195 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +14 -14
- package/examples/jsm/utils/GaussianSplatUtils.js +229 -0
- package/examples/jsm/utils/WebGLTextureUtils.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +2 -16
- package/examples/jsm/webxr/XRControllerModelFactory.js +16 -4
- package/package.json +9 -16
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +73 -43
- package/src/Three.WebGPU.Nodes.js +1 -0
- package/src/Three.WebGPU.js +1 -0
- package/src/animation/AnimationClip.js +15 -2
- package/src/animation/AnimationObjectGroup.js +18 -6
- package/src/animation/AnimationUtils.js +26 -0
- package/src/animation/KeyframeTrack.js +37 -0
- package/src/constants.js +23 -1
- package/src/core/BufferAttribute.js +3 -2
- package/src/core/BufferGeometry.js +1 -1
- package/src/core/InterleavedBuffer.js +5 -1
- package/src/core/Object3D.js +40 -12
- package/src/core/Raycaster.js +4 -0
- package/src/core/RenderTarget.js +99 -9
- package/src/core/RenderTarget3D.js +12 -8
- package/src/extras/Controls.js +0 -8
- package/src/extras/PMREMGenerator.js +99 -205
- package/src/geometries/TorusGeometry.js +1 -1
- package/src/helpers/ArrowHelper.js +2 -0
- package/src/helpers/AxesHelper.js +2 -0
- package/src/helpers/Box3Helper.js +2 -0
- package/src/helpers/BoxHelper.js +2 -0
- package/src/helpers/CameraHelper.js +2 -0
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/GridHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PlaneHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/PolarGridHelper.js +2 -0
- package/src/helpers/SkeletonHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +2 -0
- package/src/lights/Light.js +0 -10
- package/src/lights/LightShadow.js +43 -12
- package/src/lights/SpotLightShadow.js +18 -0
- package/src/loaders/BufferGeometryLoader.js +5 -0
- package/src/loaders/ImageBitmapLoader.js +3 -1
- package/src/loaders/ObjectLoader.js +8 -5
- package/src/materials/Material.js +80 -57
- package/src/materials/MeshPhysicalMaterial.js +32 -0
- package/src/materials/nodes/Line2NodeMaterial.js +17 -8
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +42 -5
- package/src/materials/nodes/NodeMaterial.js +19 -13
- package/src/materials/nodes/PointsNodeMaterial.js +2 -1
- package/src/materials/nodes/manager/NodeMaterialObserver.js +282 -55
- package/src/math/Frustum.js +9 -0
- package/src/math/FrustumArray.js +1 -1
- package/src/math/MathUtils.js +5 -3
- package/src/math/Matrix4.js +2 -9
- package/src/math/Plane.js +30 -1
- package/src/math/Quaternion.js +0 -10
- package/src/math/Ray.js +95 -45
- package/src/math/Triangle.js +0 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +0 -4
- package/src/math/interpolants/BezierInterpolant.js +36 -23
- package/src/nodes/Nodes.js +2 -0
- package/src/nodes/TSL.js +11 -3
- package/src/nodes/accessors/Batch.js +85 -13
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/BuiltinNode.js +1 -1
- package/src/nodes/accessors/Instance.js +19 -18
- package/src/nodes/accessors/MaterialNode.js +9 -0
- package/src/nodes/accessors/ModelNode.js +85 -9
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -70
- package/src/nodes/accessors/ReferenceElementNode.js +72 -0
- package/src/nodes/accessors/ReferenceNode.js +1 -70
- package/src/nodes/accessors/Skinning.js +124 -12
- package/src/nodes/accessors/StorageTextureNode.js +7 -3
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +51 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -2
- package/src/nodes/accessors/UniformArrayNode.js +30 -5
- package/src/nodes/code/CodeNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +12 -2
- package/src/nodes/core/ArrayNode.js +2 -2
- package/src/nodes/core/ContextNode.js +57 -4
- package/src/nodes/core/IndexNode.js +69 -4
- package/src/nodes/core/InspectorNode.js +2 -2
- package/src/nodes/core/MRTNode.js +44 -2
- package/src/nodes/core/Node.js +6 -3
- package/src/nodes/core/NodeBuilder.js +65 -50
- package/src/nodes/core/NodeFrame.js +11 -3
- package/src/nodes/core/NodeUtils.js +88 -0
- package/src/nodes/core/PropertyNode.js +8 -0
- package/src/nodes/core/StackNode.js +0 -1
- package/src/nodes/core/StructNode.js +4 -3
- package/src/nodes/core/UniformGroupNode.js +3 -2
- package/src/nodes/core/UniformNode.js +26 -12
- package/src/nodes/core/VarNode.js +0 -1
- package/src/nodes/display/BumpMapNode.js +2 -2
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/PassNode.js +76 -15
- package/src/nodes/display/ScreenNode.js +22 -65
- package/src/nodes/fog/Fog.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_GGX.js +6 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +1 -1
- package/src/nodes/functions/BSDF/DFGLUT.js +2 -1
- package/src/nodes/functions/BSDF/LTC.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +83 -25
- package/src/nodes/functions/ToonLightingModel.js +2 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +3 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +64 -13
- package/src/nodes/gpgpu/BarrierNode.js +13 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +20 -17
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +165 -37
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +44 -6
- package/src/nodes/lighting/EnvironmentNode.js +40 -4
- package/src/nodes/lighting/LightsNode.js +20 -4
- package/src/nodes/lighting/ShadowBaseNode.js +158 -1
- package/src/nodes/lighting/ShadowFilterNode.js +2 -106
- package/src/nodes/lighting/ShadowNode.js +22 -91
- package/src/nodes/materialx/{lib/mx_hsv.js → MaterialXColor.js} +3 -6
- package/src/nodes/materialx/{lib/mx_transform_color.js → MaterialXColorTransform.js} +3 -6
- package/src/nodes/materialx/MaterialXCore.js +37 -0
- package/src/nodes/materialx/MaterialXNodes.js +64 -72
- package/src/nodes/materialx/{lib/mx_noise.js → MaterialXNoise.js} +426 -197
- package/src/nodes/math/BitcountNode.js +24 -4
- package/src/nodes/math/MathNode.js +4 -4
- package/src/nodes/math/MathUtils.js +15 -4
- package/src/nodes/math/OperatorNode.js +2 -2
- package/src/nodes/math/PackFloatNode.js +29 -1
- package/src/nodes/math/Packed4x8IntegerNode.js +433 -0
- package/src/nodes/math/UnpackFloatNode.js +30 -2
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +31 -74
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLCore.js +1 -31
- package/src/nodes/utils/EventNode.js +75 -0
- package/src/nodes/utils/LoopNode.js +54 -13
- package/src/nodes/utils/PostProcessingUtils.js +23 -2
- package/src/nodes/utils/RTTNode.js +97 -32
- package/src/nodes/utils/ReflectorNode.js +8 -4
- package/src/nodes/utils/RotateNode.js +85 -8
- package/src/nodes/utils/SpriteUtils.js +58 -23
- package/src/objects/BatchedMesh.js +6 -0
- package/src/objects/InstancedMesh.js +1 -1
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +12 -0
- package/src/objects/Mesh.js +12 -0
- package/src/objects/Points.js +12 -0
- package/src/objects/Sprite.js +12 -0
- package/src/renderers/WebGLRenderer.js +93 -27
- package/src/renderers/common/Animation.js +12 -2
- package/src/renderers/common/Backend.js +38 -10
- package/src/renderers/common/BindGroup.js +0 -1
- package/src/renderers/common/Bindings.js +50 -4
- package/src/renderers/common/BundleGroup.js +4 -0
- package/src/renderers/common/ClippingContext.js +11 -1
- package/src/renderers/common/Color4.js +9 -0
- package/src/renderers/common/Constants.js +0 -5
- package/src/renderers/common/DirectRenderPipeline.js +233 -0
- package/src/renderers/common/Geometries.js +24 -3
- package/src/renderers/common/Info.js +3 -3
- package/src/renderers/common/InspectorBase.js +37 -8
- package/src/renderers/common/Lighting.js +11 -4
- package/src/renderers/common/Pipelines.js +6 -4
- package/src/renderers/common/QuadMesh.js +16 -2
- package/src/renderers/common/RenderContext.js +8 -0
- package/src/renderers/common/RenderList.js +53 -19
- package/src/renderers/common/RenderLists.js +58 -11
- package/src/renderers/common/RenderObject.js +14 -0
- package/src/renderers/common/RenderObjects.js +14 -9
- package/src/renderers/common/RenderPipeline.js +52 -44
- package/src/renderers/common/Renderer.js +226 -55
- package/src/renderers/common/Storage3DTexture.js +16 -0
- package/src/renderers/common/Textures.js +3 -3
- package/src/renderers/common/XRManager.js +79 -72
- package/src/renderers/common/extras/PMREMGenerator.js +76 -144
- package/src/renderers/common/nodes/NodeManager.js +144 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +3 -1
- package/src/renderers/common/nodes/NodeUniformBuffer.js +3 -1
- package/src/renderers/shaders/DFGLUTData.js +2 -1
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +4 -2
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +48 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +53 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +20 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +61 -57
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +82 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +8 -1
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +15 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +1 -0
- package/src/renderers/shaders/UniformsLib.js +16 -0
- package/src/renderers/webgl/WebGLAnimation.js +2 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +74 -4
- package/src/renderers/webgl/WebGLMaterials.js +6 -0
- package/src/renderers/webgl/WebGLOutput.js +36 -24
- package/src/renderers/webgl/WebGLProgram.js +3 -0
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLRenderLists.js +6 -10
- package/src/renderers/webgl/WebGLShadowMap.js +47 -44
- package/src/renderers/webgl/WebGLTextures.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +153 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +83 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +163 -17
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +32 -5
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +11 -4
- package/src/renderers/webgpu/WebGPUBackend.js +513 -145
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +3 -12
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +24 -14
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +80 -14
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -7
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +9 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +16 -4
- package/src/renderers/webxr/WebXRManager.js +25 -2
- package/src/scenes/Scene.js +3 -3
- package/src/textures/CompressedArrayTexture.js +16 -0
- package/src/textures/Data3DTexture.js +16 -0
- package/src/textures/DataArrayTexture.js +16 -0
- package/src/textures/DepthTexture.js +3 -3
- package/src/textures/Texture.js +3 -3
- package/src/textures/{Source.js → TextureSource.js} +39 -8
- package/build/three.core.min.js +0 -6
- package/build/three.module.min.js +0 -6
- package/build/three.tsl.min.js +0 -6
- package/build/three.webgpu.min.js +0 -6
- package/build/three.webgpu.nodes.min.js +0 -6
- package/examples/jsm/libs/ecsy.module.js +0 -1792
- package/examples/jsm/loaders/LottieLoader.js +0 -130
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +0 -52
|
@@ -281,6 +281,25 @@ class GLSLDecoder {
|
|
|
281
281
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
+
getTokenPosition( token ) {
|
|
285
|
+
|
|
286
|
+
if ( ! token || token.pos === undefined || ! token.tokenizer || ! token.tokenizer.source ) {
|
|
287
|
+
|
|
288
|
+
return '';
|
|
289
|
+
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const source = token.tokenizer.source;
|
|
293
|
+
const textBefore = source.slice( 0, token.pos );
|
|
294
|
+
|
|
295
|
+
const lines = textBefore.split( '\n' );
|
|
296
|
+
const lineNumber = lines.length;
|
|
297
|
+
const columnNumber = lines[ lines.length - 1 ].length + 1;
|
|
298
|
+
|
|
299
|
+
return ` (line ${ lineNumber }, column ${ columnNumber })`;
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
|
|
284
303
|
getToken( offset = 0 ) {
|
|
285
304
|
|
|
286
305
|
return this.tokens[ this.index + offset ];
|
|
@@ -481,6 +500,14 @@ class GLSLDecoder {
|
|
|
481
500
|
|
|
482
501
|
return left;
|
|
483
502
|
|
|
503
|
+
} else if ( firstToken.str === '{' ) {
|
|
504
|
+
|
|
505
|
+
const internalTokens = tokens.slice( 1, tokens.length - 1 );
|
|
506
|
+
|
|
507
|
+
const paramsTokens = this.parseFunctionParametersFromTokens( internalTokens );
|
|
508
|
+
|
|
509
|
+
return new FunctionCall( 'array', paramsTokens );
|
|
510
|
+
|
|
484
511
|
}
|
|
485
512
|
|
|
486
513
|
// primitives and accessors
|
|
@@ -558,6 +585,20 @@ class GLSLDecoder {
|
|
|
558
585
|
|
|
559
586
|
} else if ( secondToken.str === '[' ) {
|
|
560
587
|
|
|
588
|
+
const bracketTokens = this.getTokensUntil( ']', tokens, 1 );
|
|
589
|
+
const parenToken = tokens[ 1 + bracketTokens.length ];
|
|
590
|
+
|
|
591
|
+
if ( parenToken && parenToken.str === '(' ) {
|
|
592
|
+
|
|
593
|
+
// array constructor: type[N](args...) or type[](args...)
|
|
594
|
+
const parenIndex = 1 + bracketTokens.length;
|
|
595
|
+
const internalTokens = this.getTokensUntil( ')', tokens, parenIndex ).slice( 1, - 1 );
|
|
596
|
+
const paramsTokens = this.parseFunctionParametersFromTokens( internalTokens );
|
|
597
|
+
|
|
598
|
+
return new FunctionCall( 'array', paramsTokens );
|
|
599
|
+
|
|
600
|
+
}
|
|
601
|
+
|
|
561
602
|
// array accessor
|
|
562
603
|
|
|
563
604
|
const elements = this.parseAccessorElementsFromTokens( tokens.slice( 1 ) );
|
|
@@ -572,6 +613,8 @@ class GLSLDecoder {
|
|
|
572
613
|
|
|
573
614
|
}
|
|
574
615
|
|
|
616
|
+
throw new Error( 'THREE.GLSLDecoder: Unexpected token "' + firstToken.str + '"' + this.getTokenPosition( firstToken ) );
|
|
617
|
+
|
|
575
618
|
}
|
|
576
619
|
|
|
577
620
|
parseAccessorElementsFromTokens( tokens ) {
|
|
@@ -606,9 +649,7 @@ class GLSLDecoder {
|
|
|
606
649
|
|
|
607
650
|
} else {
|
|
608
651
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
break;
|
|
652
|
+
throw new Error( 'THREE.GLSLDecoder: Unknown accessor expression token "' + token.str + '"' + this.getTokenPosition( token ) );
|
|
612
653
|
|
|
613
654
|
}
|
|
614
655
|
|
|
@@ -623,19 +664,26 @@ class GLSLDecoder {
|
|
|
623
664
|
if ( tokens.length === 0 ) return [];
|
|
624
665
|
|
|
625
666
|
const expression = this.parseExpressionFromTokens( tokens );
|
|
667
|
+
|
|
668
|
+
if ( ! expression ) {
|
|
669
|
+
|
|
670
|
+
throw new Error( 'THREE.GLSLDecoder: Invalid parameter expression' + this.getTokenPosition( tokens[ 0 ] ) );
|
|
671
|
+
|
|
672
|
+
}
|
|
673
|
+
|
|
626
674
|
const params = [];
|
|
627
675
|
|
|
628
676
|
let current = expression;
|
|
629
677
|
|
|
630
|
-
while ( current.type === ',' ) {
|
|
678
|
+
while ( current && current.type === ',' ) {
|
|
631
679
|
|
|
632
|
-
params.push( current.left );
|
|
680
|
+
if ( current.left ) params.push( current.left );
|
|
633
681
|
|
|
634
682
|
current = current.right;
|
|
635
683
|
|
|
636
684
|
}
|
|
637
685
|
|
|
638
|
-
params.push( current );
|
|
686
|
+
if ( current ) params.push( current );
|
|
639
687
|
|
|
640
688
|
return params;
|
|
641
689
|
|
|
@@ -711,11 +759,20 @@ class GLSLDecoder {
|
|
|
711
759
|
type = type || tokens[ index ++ ].str;
|
|
712
760
|
const name = tokens[ index ++ ].str;
|
|
713
761
|
|
|
714
|
-
|
|
762
|
+
let token = tokens[ index ];
|
|
715
763
|
|
|
716
764
|
let init = null;
|
|
717
765
|
let next = null;
|
|
718
766
|
|
|
767
|
+
if ( token && token.str === '[' ) {
|
|
768
|
+
|
|
769
|
+
const bracketTokens = this.getTokensUntil( ']', tokens, index );
|
|
770
|
+
|
|
771
|
+
index += bracketTokens.length;
|
|
772
|
+
token = tokens[ index ];
|
|
773
|
+
|
|
774
|
+
}
|
|
775
|
+
|
|
719
776
|
if ( token ) {
|
|
720
777
|
|
|
721
778
|
const initTokens = this.getTokensUntil( ',', tokens, index );
|
|
@@ -864,6 +921,45 @@ class GLSLDecoder {
|
|
|
864
921
|
|
|
865
922
|
}
|
|
866
923
|
|
|
924
|
+
parseDoWhile() {
|
|
925
|
+
|
|
926
|
+
this.readToken(); // skip 'do'
|
|
927
|
+
|
|
928
|
+
let body;
|
|
929
|
+
|
|
930
|
+
if ( this.getToken().str === '{' ) {
|
|
931
|
+
|
|
932
|
+
body = this.parseBlock();
|
|
933
|
+
|
|
934
|
+
} else {
|
|
935
|
+
|
|
936
|
+
body = [ this.parseExpression() ];
|
|
937
|
+
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
if ( this.getToken() && this.getToken().str === 'while' ) {
|
|
941
|
+
|
|
942
|
+
this.readToken(); // skip 'while'
|
|
943
|
+
|
|
944
|
+
} else {
|
|
945
|
+
|
|
946
|
+
throw new Error( 'THREE.GLSLDecoder: Expected \'while\' after \'do\' block' + this.getTokenPosition( this.getToken() ) );
|
|
947
|
+
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
const condTokens = this.readTokensUntil( ')' );
|
|
951
|
+
const condition = this.parseExpressionFromTokens( condTokens.slice( 1, - 1 ) );
|
|
952
|
+
|
|
953
|
+
if ( this.getToken() && this.getToken().str === ';' ) {
|
|
954
|
+
|
|
955
|
+
this.readToken(); // skip trailing ';'
|
|
956
|
+
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
return new While( condition, body, true );
|
|
960
|
+
|
|
961
|
+
}
|
|
962
|
+
|
|
867
963
|
parseFor() {
|
|
868
964
|
|
|
869
965
|
this.readToken(); // skip 'for'
|
|
@@ -1162,6 +1258,10 @@ class GLSLDecoder {
|
|
|
1162
1258
|
|
|
1163
1259
|
statement = this.parseWhile();
|
|
1164
1260
|
|
|
1261
|
+
} else if ( token.str === 'do' ) {
|
|
1262
|
+
|
|
1263
|
+
statement = this.parseDoWhile();
|
|
1264
|
+
|
|
1165
1265
|
} else if ( token.str === 'switch' ) {
|
|
1166
1266
|
|
|
1167
1267
|
statement = this.parseSwitch();
|
|
@@ -1190,8 +1290,399 @@ class GLSLDecoder {
|
|
|
1190
1290
|
|
|
1191
1291
|
}
|
|
1192
1292
|
|
|
1293
|
+
evaluateCondition( expr, macros ) {
|
|
1294
|
+
|
|
1295
|
+
let str = expr;
|
|
1296
|
+
|
|
1297
|
+
str = str.replace( /defined\s*\(\s*(\w+)\s*\)/g, ( _, name ) => macros.has( name ) ? '1' : '0' );
|
|
1298
|
+
str = str.replace( /defined\s+(\w+)/g, ( _, name ) => macros.has( name ) ? '1' : '0' );
|
|
1299
|
+
|
|
1300
|
+
str = str.replace( /\b([A-Za-z_]\w*)\b/g, ( _, name ) => {
|
|
1301
|
+
|
|
1302
|
+
if ( name === 'true' ) return '1';
|
|
1303
|
+
if ( name === 'false' ) return '0';
|
|
1304
|
+
|
|
1305
|
+
if ( macros.has( name ) ) {
|
|
1306
|
+
|
|
1307
|
+
const macro = macros.get( name );
|
|
1308
|
+
const val = macro.body;
|
|
1309
|
+
return val !== '' ? val : '1';
|
|
1310
|
+
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
return '0';
|
|
1314
|
+
|
|
1315
|
+
} );
|
|
1316
|
+
|
|
1317
|
+
try {
|
|
1318
|
+
|
|
1319
|
+
if ( /^[\d\s+\-*/%&|^!=<>~()]+$/.test( str ) ) {
|
|
1320
|
+
|
|
1321
|
+
return Boolean( Function( `"use strict"; return (${ str });` )() );
|
|
1322
|
+
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
} catch ( e ) {
|
|
1326
|
+
|
|
1327
|
+
return false;
|
|
1328
|
+
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
return false;
|
|
1332
|
+
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
extractMacroArgs( str ) {
|
|
1336
|
+
|
|
1337
|
+
const args = [];
|
|
1338
|
+
let currentArg = '';
|
|
1339
|
+
let parenDepth = 0;
|
|
1340
|
+
|
|
1341
|
+
for ( let i = 0; i < str.length; i ++ ) {
|
|
1342
|
+
|
|
1343
|
+
const char = str[ i ];
|
|
1344
|
+
|
|
1345
|
+
if ( char === '(' || char === '[' || char === '{' ) {
|
|
1346
|
+
|
|
1347
|
+
parenDepth ++;
|
|
1348
|
+
currentArg += char;
|
|
1349
|
+
|
|
1350
|
+
} else if ( char === ')' || char === ']' || char === '}' ) {
|
|
1351
|
+
|
|
1352
|
+
parenDepth --;
|
|
1353
|
+
currentArg += char;
|
|
1354
|
+
|
|
1355
|
+
} else if ( char === ',' && parenDepth === 0 ) {
|
|
1356
|
+
|
|
1357
|
+
args.push( currentArg.trim() );
|
|
1358
|
+
currentArg = '';
|
|
1359
|
+
|
|
1360
|
+
} else {
|
|
1361
|
+
|
|
1362
|
+
currentArg += char;
|
|
1363
|
+
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
if ( currentArg.trim() !== '' || args.length > 0 ) {
|
|
1369
|
+
|
|
1370
|
+
args.push( currentArg.trim() );
|
|
1371
|
+
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
return args;
|
|
1375
|
+
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
expandMacros( line, macros ) {
|
|
1379
|
+
|
|
1380
|
+
if ( macros.size === 0 ) return line;
|
|
1381
|
+
|
|
1382
|
+
let result = line;
|
|
1383
|
+
let passes = 0;
|
|
1384
|
+
const maxPasses = 10;
|
|
1385
|
+
|
|
1386
|
+
while ( passes < maxPasses ) {
|
|
1387
|
+
|
|
1388
|
+
let changed = false;
|
|
1389
|
+
|
|
1390
|
+
for ( const [ name, macro ] of macros ) {
|
|
1391
|
+
|
|
1392
|
+
if ( macro.params !== null ) {
|
|
1393
|
+
|
|
1394
|
+
const regex = new RegExp( `\\b${ name }\\s*\\(`, 'g' );
|
|
1395
|
+
let match;
|
|
1396
|
+
|
|
1397
|
+
while ( ( match = regex.exec( result ) ) !== null ) {
|
|
1398
|
+
|
|
1399
|
+
const startIdx = match.index;
|
|
1400
|
+
const parenStartIdx = startIdx + match[ 0 ].length - 1;
|
|
1401
|
+
|
|
1402
|
+
let parenDepth = 1;
|
|
1403
|
+
let parenEndIdx = - 1;
|
|
1404
|
+
|
|
1405
|
+
for ( let i = parenStartIdx + 1; i < result.length; i ++ ) {
|
|
1406
|
+
|
|
1407
|
+
if ( result[ i ] === '(' ) parenDepth ++;
|
|
1408
|
+
else if ( result[ i ] === ')' ) parenDepth --;
|
|
1409
|
+
|
|
1410
|
+
if ( parenDepth === 0 ) {
|
|
1411
|
+
|
|
1412
|
+
parenEndIdx = i;
|
|
1413
|
+
break;
|
|
1414
|
+
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
if ( parenEndIdx !== - 1 ) {
|
|
1420
|
+
|
|
1421
|
+
const rawArgs = result.slice( parenStartIdx + 1, parenEndIdx );
|
|
1422
|
+
const args = this.extractMacroArgs( rawArgs );
|
|
1423
|
+
|
|
1424
|
+
let substitutedBody = macro.body;
|
|
1425
|
+
|
|
1426
|
+
for ( let p = 0; p < macro.params.length; p ++ ) {
|
|
1427
|
+
|
|
1428
|
+
const paramName = macro.params[ p ];
|
|
1429
|
+
const argVal = args[ p ] !== undefined ? args[ p ] : '';
|
|
1430
|
+
const paramRegex = new RegExp( `\\b${ paramName }\\b`, 'g' );
|
|
1431
|
+
|
|
1432
|
+
substitutedBody = substitutedBody.replace( paramRegex, argVal );
|
|
1433
|
+
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
result = result.slice( 0, startIdx ) + substitutedBody + result.slice( parenEndIdx + 1 );
|
|
1437
|
+
changed = true;
|
|
1438
|
+
|
|
1439
|
+
break;
|
|
1440
|
+
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
} else {
|
|
1446
|
+
|
|
1447
|
+
if ( macro.body === '' ) continue;
|
|
1448
|
+
|
|
1449
|
+
const regex = new RegExp( `\\b${ name }\\b`, 'g' );
|
|
1450
|
+
|
|
1451
|
+
if ( regex.test( result ) ) {
|
|
1452
|
+
|
|
1453
|
+
result = result.replace( regex, macro.body );
|
|
1454
|
+
changed = true;
|
|
1455
|
+
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
if ( ! changed ) break;
|
|
1463
|
+
|
|
1464
|
+
passes ++;
|
|
1465
|
+
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
return result;
|
|
1469
|
+
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
preprocess( source ) {
|
|
1473
|
+
|
|
1474
|
+
const macros = new Map();
|
|
1475
|
+
const conditionalStack = [];
|
|
1476
|
+
|
|
1477
|
+
const isExecuting = () => conditionalStack.every( frame => frame.active );
|
|
1478
|
+
|
|
1479
|
+
const lines = source.split( '\n' );
|
|
1480
|
+
const outputLines = [];
|
|
1481
|
+
|
|
1482
|
+
let inBlockComment = false;
|
|
1483
|
+
|
|
1484
|
+
for ( let i = 0; i < lines.length; i ++ ) {
|
|
1485
|
+
|
|
1486
|
+
let line = lines[ i ];
|
|
1487
|
+
|
|
1488
|
+
while ( line.endsWith( '\\' ) && i + 1 < lines.length ) {
|
|
1489
|
+
|
|
1490
|
+
line = line.slice( 0, - 1 ) + ' ' + lines[ i + 1 ];
|
|
1491
|
+
i ++;
|
|
1492
|
+
outputLines.push( '' );
|
|
1493
|
+
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
let trimmedLine = line.trim();
|
|
1497
|
+
|
|
1498
|
+
if ( inBlockComment ) {
|
|
1499
|
+
|
|
1500
|
+
const endCommentIndex = trimmedLine.indexOf( '*/' );
|
|
1501
|
+
|
|
1502
|
+
if ( endCommentIndex !== - 1 ) {
|
|
1503
|
+
|
|
1504
|
+
inBlockComment = false;
|
|
1505
|
+
trimmedLine = trimmedLine.slice( endCommentIndex + 2 ).trim();
|
|
1506
|
+
|
|
1507
|
+
} else {
|
|
1508
|
+
|
|
1509
|
+
outputLines.push( line );
|
|
1510
|
+
continue;
|
|
1511
|
+
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
if ( trimmedLine.startsWith( '/*' ) ) {
|
|
1517
|
+
|
|
1518
|
+
const endCommentIndex = trimmedLine.indexOf( '*/', 2 );
|
|
1519
|
+
|
|
1520
|
+
if ( endCommentIndex === - 1 ) {
|
|
1521
|
+
|
|
1522
|
+
inBlockComment = true;
|
|
1523
|
+
outputLines.push( line );
|
|
1524
|
+
continue;
|
|
1525
|
+
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
const directiveMatch = trimmedLine.match( /^#\s*(\w+)(?:\s+(.*))?$/ );
|
|
1531
|
+
|
|
1532
|
+
if ( directiveMatch ) {
|
|
1533
|
+
|
|
1534
|
+
const directive = directiveMatch[ 1 ];
|
|
1535
|
+
let args = directiveMatch[ 2 ] || '';
|
|
1536
|
+
|
|
1537
|
+
args = args.replace( /\/\/.*$/, '' ).replace( /\/\*.*?\*\//g, '' ).trim();
|
|
1538
|
+
|
|
1539
|
+
if ( directive === 'define' ) {
|
|
1540
|
+
|
|
1541
|
+
if ( isExecuting() ) {
|
|
1542
|
+
|
|
1543
|
+
const fnMatch = args.match( /^(\w+)\((.*?)\)\s*(.*)$/ );
|
|
1544
|
+
|
|
1545
|
+
if ( fnMatch ) {
|
|
1546
|
+
|
|
1547
|
+
const name = fnMatch[ 1 ];
|
|
1548
|
+
const params = fnMatch[ 2 ].split( ',' ).map( p => p.trim() ).filter( p => p !== '' );
|
|
1549
|
+
const body = fnMatch[ 3 ] !== undefined ? fnMatch[ 3 ].trim() : '';
|
|
1550
|
+
|
|
1551
|
+
macros.set( name, { params, body } );
|
|
1552
|
+
|
|
1553
|
+
} else {
|
|
1554
|
+
|
|
1555
|
+
const objMatch = args.match( /^(\w+)(?:\s+(.*))?$/ );
|
|
1556
|
+
|
|
1557
|
+
if ( objMatch ) {
|
|
1558
|
+
|
|
1559
|
+
const name = objMatch[ 1 ];
|
|
1560
|
+
const value = objMatch[ 2 ] !== undefined ? objMatch[ 2 ].trim() : '';
|
|
1561
|
+
|
|
1562
|
+
macros.set( name, { params: null, body: value } );
|
|
1563
|
+
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
} else if ( directive === 'undef' ) {
|
|
1571
|
+
|
|
1572
|
+
if ( isExecuting() ) {
|
|
1573
|
+
|
|
1574
|
+
const name = args.trim();
|
|
1575
|
+
|
|
1576
|
+
macros.delete( name );
|
|
1577
|
+
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
} else if ( directive === 'ifdef' ) {
|
|
1581
|
+
|
|
1582
|
+
const name = args.trim();
|
|
1583
|
+
const parentActive = isExecuting();
|
|
1584
|
+
const condition = parentActive && macros.has( name );
|
|
1585
|
+
|
|
1586
|
+
conditionalStack.push( { active: condition, anyBranchExecuted: condition } );
|
|
1587
|
+
|
|
1588
|
+
} else if ( directive === 'ifndef' ) {
|
|
1589
|
+
|
|
1590
|
+
const name = args.trim();
|
|
1591
|
+
const parentActive = isExecuting();
|
|
1592
|
+
const condition = parentActive && ! macros.has( name );
|
|
1593
|
+
|
|
1594
|
+
conditionalStack.push( { active: condition, anyBranchExecuted: condition } );
|
|
1595
|
+
|
|
1596
|
+
} else if ( directive === 'if' ) {
|
|
1597
|
+
|
|
1598
|
+
const parentActive = isExecuting();
|
|
1599
|
+
const condition = parentActive && this.evaluateCondition( args, macros );
|
|
1600
|
+
|
|
1601
|
+
conditionalStack.push( { active: Boolean( condition ), anyBranchExecuted: Boolean( condition ) } );
|
|
1602
|
+
|
|
1603
|
+
} else if ( directive === 'elif' ) {
|
|
1604
|
+
|
|
1605
|
+
if ( conditionalStack.length > 0 ) {
|
|
1606
|
+
|
|
1607
|
+
const currentFrame = conditionalStack[ conditionalStack.length - 1 ];
|
|
1608
|
+
const parentActive = conditionalStack.slice( 0, - 1 ).every( frame => frame.active );
|
|
1609
|
+
|
|
1610
|
+
if ( ! parentActive || currentFrame.anyBranchExecuted ) {
|
|
1611
|
+
|
|
1612
|
+
currentFrame.active = false;
|
|
1613
|
+
|
|
1614
|
+
} else {
|
|
1615
|
+
|
|
1616
|
+
const condition = this.evaluateCondition( args, macros );
|
|
1617
|
+
|
|
1618
|
+
currentFrame.active = Boolean( condition );
|
|
1619
|
+
|
|
1620
|
+
if ( condition ) {
|
|
1621
|
+
|
|
1622
|
+
currentFrame.anyBranchExecuted = true;
|
|
1623
|
+
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
} else if ( directive === 'else' ) {
|
|
1631
|
+
|
|
1632
|
+
if ( conditionalStack.length > 0 ) {
|
|
1633
|
+
|
|
1634
|
+
const currentFrame = conditionalStack[ conditionalStack.length - 1 ];
|
|
1635
|
+
const parentActive = conditionalStack.slice( 0, - 1 ).every( frame => frame.active );
|
|
1636
|
+
|
|
1637
|
+
if ( ! parentActive || currentFrame.anyBranchExecuted ) {
|
|
1638
|
+
|
|
1639
|
+
currentFrame.active = false;
|
|
1640
|
+
|
|
1641
|
+
} else {
|
|
1642
|
+
|
|
1643
|
+
currentFrame.active = true;
|
|
1644
|
+
currentFrame.anyBranchExecuted = true;
|
|
1645
|
+
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
} else if ( directive === 'endif' ) {
|
|
1651
|
+
|
|
1652
|
+
if ( conditionalStack.length > 0 ) {
|
|
1653
|
+
|
|
1654
|
+
conditionalStack.pop();
|
|
1655
|
+
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
outputLines.push( '' );
|
|
1661
|
+
|
|
1662
|
+
} else {
|
|
1663
|
+
|
|
1664
|
+
if ( isExecuting() ) {
|
|
1665
|
+
|
|
1666
|
+
outputLines.push( this.expandMacros( line, macros ) );
|
|
1667
|
+
|
|
1668
|
+
} else {
|
|
1669
|
+
|
|
1670
|
+
outputLines.push( '' );
|
|
1671
|
+
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
return outputLines.join( '\n' );
|
|
1679
|
+
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1193
1682
|
parse( source ) {
|
|
1194
1683
|
|
|
1684
|
+
source = this.preprocess( source );
|
|
1685
|
+
|
|
1195
1686
|
let polyfill = '';
|
|
1196
1687
|
|
|
1197
1688
|
for ( const keyword of this.keywords ) {
|
|
@@ -1220,7 +1711,6 @@ class GLSLDecoder {
|
|
|
1220
1711
|
|
|
1221
1712
|
return program;
|
|
1222
1713
|
|
|
1223
|
-
|
|
1224
1714
|
}
|
|
1225
1715
|
|
|
1226
1716
|
}
|