@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
|
@@ -0,0 +1,2609 @@
|
|
|
1
|
+
import { Extension } from '@gnsx/three/addons/inspector/Extension.js';
|
|
2
|
+
import {
|
|
3
|
+
createDefaultParams,
|
|
4
|
+
LUT_PRESETS,
|
|
5
|
+
exportCubeFormat,
|
|
6
|
+
exportLUTCanvas,
|
|
7
|
+
parseCubeFormat
|
|
8
|
+
} from './LUTMath.js';
|
|
9
|
+
import {
|
|
10
|
+
Data3DTexture,
|
|
11
|
+
LinearFilter,
|
|
12
|
+
RGBAFormat,
|
|
13
|
+
FloatType,
|
|
14
|
+
NoToneMapping,
|
|
15
|
+
RenderPipeline
|
|
16
|
+
} from '@gnsx/three/webgpu';
|
|
17
|
+
import { pass, texture3D, renderOutput } from '@gnsx/three/tsl';
|
|
18
|
+
import { lut3D } from '@gnsx/three/addons/tsl/display/Lut3DNode.js';
|
|
19
|
+
|
|
20
|
+
import { LUT3DStyle } from './LUT3DStyle.js';
|
|
21
|
+
|
|
22
|
+
// Module imports
|
|
23
|
+
import { WhiteBalanceModule } from './modules/WhiteBalanceModule.js';
|
|
24
|
+
import { ExposureModule } from './modules/ExposureModule.js';
|
|
25
|
+
import { BrightnessModule } from './modules/BrightnessModule.js';
|
|
26
|
+
import { HueModule } from './modules/HueModule.js';
|
|
27
|
+
import { ColorWheelModule } from './modules/ColorWheelModule.js';
|
|
28
|
+
import { CurvesModule } from './modules/CurvesModule.js';
|
|
29
|
+
import { ContrastModule } from './modules/ContrastModule.js';
|
|
30
|
+
import { SaturationModule } from './modules/SaturationModule.js';
|
|
31
|
+
import { VibranceModule } from './modules/VibranceModule.js';
|
|
32
|
+
import { ImportedCubeModule } from './modules/ImportedCubeModule.js';
|
|
33
|
+
import { RendererModule } from './modules/RendererModule.js';
|
|
34
|
+
import { OutputModule } from './modules/OutputModule.js';
|
|
35
|
+
|
|
36
|
+
const _rendererPipelines = new WeakMap();
|
|
37
|
+
|
|
38
|
+
const _origRender = RenderPipeline.prototype.render;
|
|
39
|
+
|
|
40
|
+
if ( _origRender && ! _origRender._lut3dHooked ) {
|
|
41
|
+
|
|
42
|
+
RenderPipeline.prototype.render = function ( ...args ) {
|
|
43
|
+
|
|
44
|
+
if ( this.renderer ) {
|
|
45
|
+
|
|
46
|
+
_rendererPipelines.set( this.renderer, this );
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return _origRender.apply( this, args );
|
|
51
|
+
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
RenderPipeline.prototype.render._lut3dHooked = true;
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const DEFAULT_PIPELINE_ORDER = [
|
|
59
|
+
'renderer',
|
|
60
|
+
'whiteBalance',
|
|
61
|
+
'lift',
|
|
62
|
+
'gammaBal',
|
|
63
|
+
'gain',
|
|
64
|
+
'offset',
|
|
65
|
+
'curves',
|
|
66
|
+
'saturation',
|
|
67
|
+
'vibrance',
|
|
68
|
+
'output'
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
export class ColorGrading extends Extension {
|
|
72
|
+
|
|
73
|
+
constructor( options = {} ) {
|
|
74
|
+
|
|
75
|
+
super( 'Color Grading', options );
|
|
76
|
+
|
|
77
|
+
LUT3DStyle.init( options.nonce );
|
|
78
|
+
|
|
79
|
+
this.params = createDefaultParams();
|
|
80
|
+
this.lutSize = 32;
|
|
81
|
+
this.lutTexture = null;
|
|
82
|
+
this.lutPassNode = null;
|
|
83
|
+
this.sceneGradingEnabled = false;
|
|
84
|
+
this.selectedToneMapping = NoToneMapping;
|
|
85
|
+
this._lutNeedsUpdate = true;
|
|
86
|
+
this._lutSizeChanged = false;
|
|
87
|
+
this.activeTab = 'wheels';
|
|
88
|
+
|
|
89
|
+
this.modulesMap = new Map();
|
|
90
|
+
this.cardsMap = new Map();
|
|
91
|
+
|
|
92
|
+
// Container Setup matching Inspector tabs
|
|
93
|
+
this.content.style.overflow = 'hidden';
|
|
94
|
+
this.content.style.display = 'flex';
|
|
95
|
+
this.content.style.flexDirection = 'column';
|
|
96
|
+
this.content.style.height = '100%';
|
|
97
|
+
this.content.style.background = 'transparent';
|
|
98
|
+
|
|
99
|
+
this._buildHeader();
|
|
100
|
+
this._buildMainView();
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
_createSvgIcon( svgPath, width = 13, height = 13, strokeWidth = 2 ) {
|
|
105
|
+
|
|
106
|
+
const ns = 'http://www.w3.org/2000/svg';
|
|
107
|
+
const svg = document.createElementNS( ns, 'svg' );
|
|
108
|
+
svg.setAttribute( 'width', String( width ) );
|
|
109
|
+
svg.setAttribute( 'height', String( height ) );
|
|
110
|
+
svg.setAttribute( 'viewBox', '0 0 24 24' );
|
|
111
|
+
svg.setAttribute( 'fill', 'none' );
|
|
112
|
+
svg.setAttribute( 'stroke', 'currentColor' );
|
|
113
|
+
svg.setAttribute( 'stroke-width', String( strokeWidth ) );
|
|
114
|
+
svg.setAttribute( 'stroke-linecap', 'round' );
|
|
115
|
+
svg.setAttribute( 'stroke-linejoin', 'round' );
|
|
116
|
+
svg.style.display = 'block';
|
|
117
|
+
svg.innerHTML = svgPath;
|
|
118
|
+
return svg;
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_buildHeader() {
|
|
123
|
+
|
|
124
|
+
// All controls consolidated into sleek Control Dock inside lut-container
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
_buildMainView() {
|
|
129
|
+
|
|
130
|
+
this.viewContainer = document.createElement( 'div' );
|
|
131
|
+
this.viewContainer.className = this.sceneGradingEnabled ? 'lut-container is-live-active' : 'lut-container';
|
|
132
|
+
|
|
133
|
+
// Glass Control Dock Container at top of lut-container
|
|
134
|
+
const dock = document.createElement( 'div' );
|
|
135
|
+
dock.className = 'lut-dock-container';
|
|
136
|
+
this.dockContainer = dock;
|
|
137
|
+
|
|
138
|
+
// 1. LEFT GROUP: Grid Size
|
|
139
|
+
const leftGroup = document.createElement( 'div' );
|
|
140
|
+
leftGroup.className = 'lut-dock-group';
|
|
141
|
+
|
|
142
|
+
const sizeLabel = document.createElement( 'span' );
|
|
143
|
+
sizeLabel.className = 'lut-dock-label';
|
|
144
|
+
sizeLabel.textContent = 'Grid';
|
|
145
|
+
|
|
146
|
+
const sizeSelect = document.createElement( 'select' );
|
|
147
|
+
sizeSelect.className = 'lut-dock-select';
|
|
148
|
+
this.lutSizeSelect = sizeSelect;
|
|
149
|
+
|
|
150
|
+
const sizes = [ 16, 32, 64 ];
|
|
151
|
+
sizes.forEach( size => {
|
|
152
|
+
|
|
153
|
+
const opt = document.createElement( 'option' );
|
|
154
|
+
opt.value = size;
|
|
155
|
+
opt.textContent = `${size}³`;
|
|
156
|
+
if ( size === this.lutSize ) opt.selected = true;
|
|
157
|
+
sizeSelect.appendChild( opt );
|
|
158
|
+
|
|
159
|
+
} );
|
|
160
|
+
|
|
161
|
+
sizeSelect.onchange = ( e ) => {
|
|
162
|
+
|
|
163
|
+
this.lutSize = parseInt( e.target.value, 10 );
|
|
164
|
+
this._lutSizeChanged = true;
|
|
165
|
+
this._onParamChange();
|
|
166
|
+
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
leftGroup.appendChild( sizeLabel );
|
|
170
|
+
leftGroup.appendChild( sizeSelect );
|
|
171
|
+
|
|
172
|
+
// 2. CENTER GROUP: Live Preview Button
|
|
173
|
+
const centerGroup = document.createElement( 'div' );
|
|
174
|
+
centerGroup.className = 'lut-dock-group';
|
|
175
|
+
|
|
176
|
+
const gradingBtn = document.createElement( 'button' );
|
|
177
|
+
gradingBtn.className = 'lut-dock-btn';
|
|
178
|
+
gradingBtn.title = 'Toggle Realtime Scene Color Grading';
|
|
179
|
+
this.gradingBtn = gradingBtn;
|
|
180
|
+
|
|
181
|
+
const updateGradingBtnState = () => {
|
|
182
|
+
|
|
183
|
+
gradingBtn.innerHTML = '';
|
|
184
|
+
const eyeIcon = this._createSvgIcon( '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>', 13, 13 );
|
|
185
|
+
const lbl = document.createElement( 'span' );
|
|
186
|
+
|
|
187
|
+
if ( this.sceneGradingEnabled ) {
|
|
188
|
+
|
|
189
|
+
this.viewContainer.classList.add( 'is-live-active' );
|
|
190
|
+
gradingBtn.className = 'lut-dock-btn active';
|
|
191
|
+
lbl.textContent = 'Live Preview';
|
|
192
|
+
lbl.className = 'lut-dock-text';
|
|
193
|
+
|
|
194
|
+
} else {
|
|
195
|
+
|
|
196
|
+
this.viewContainer.classList.remove( 'is-live-active' );
|
|
197
|
+
gradingBtn.className = 'lut-dock-btn';
|
|
198
|
+
lbl.textContent = 'Live Preview';
|
|
199
|
+
lbl.className = 'lut-dock-text';
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
gradingBtn.appendChild( eyeIcon );
|
|
204
|
+
gradingBtn.appendChild( lbl );
|
|
205
|
+
this._updateRendererCardState();
|
|
206
|
+
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
this.updateGradingBtnState = updateGradingBtnState;
|
|
210
|
+
|
|
211
|
+
gradingBtn.onclick = () => {
|
|
212
|
+
|
|
213
|
+
this.sceneGradingEnabled = ! this.sceneGradingEnabled;
|
|
214
|
+
updateGradingBtnState();
|
|
215
|
+
this._toggleSceneGrading( this.sceneGradingEnabled );
|
|
216
|
+
this.save();
|
|
217
|
+
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
updateGradingBtnState();
|
|
221
|
+
centerGroup.appendChild( gradingBtn );
|
|
222
|
+
|
|
223
|
+
// Active context menu tracker
|
|
224
|
+
let activeContextMenu = null;
|
|
225
|
+
|
|
226
|
+
const closeContextMenu = () => {
|
|
227
|
+
|
|
228
|
+
if ( activeContextMenu ) {
|
|
229
|
+
|
|
230
|
+
activeContextMenu.remove();
|
|
231
|
+
activeContextMenu = null;
|
|
232
|
+
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
window.addEventListener( 'pointerdown', ( e ) => {
|
|
238
|
+
|
|
239
|
+
if ( activeContextMenu && ! activeContextMenu.contains( e.target ) ) {
|
|
240
|
+
|
|
241
|
+
closeContextMenu();
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
} );
|
|
246
|
+
|
|
247
|
+
const showContextMenu = ( parentNode, items, isSubmenu = false ) => {
|
|
248
|
+
|
|
249
|
+
if ( ! isSubmenu ) closeContextMenu();
|
|
250
|
+
|
|
251
|
+
const menu = document.createElement( 'div' );
|
|
252
|
+
menu.className = isSubmenu ? 'lut-context-menu lut-submenu' : 'lut-context-menu';
|
|
253
|
+
|
|
254
|
+
let activeSubmenu = null;
|
|
255
|
+
|
|
256
|
+
const closeActiveSubmenu = () => {
|
|
257
|
+
|
|
258
|
+
if ( activeSubmenu ) {
|
|
259
|
+
|
|
260
|
+
activeSubmenu.remove();
|
|
261
|
+
activeSubmenu = null;
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
items.forEach( item => {
|
|
268
|
+
|
|
269
|
+
if ( item.divider ) {
|
|
270
|
+
|
|
271
|
+
const div = document.createElement( 'div' );
|
|
272
|
+
div.className = 'lut-menu-divider';
|
|
273
|
+
menu.appendChild( div );
|
|
274
|
+
return;
|
|
275
|
+
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const row = document.createElement( 'div' );
|
|
279
|
+
row.className = 'lut-menu-item';
|
|
280
|
+
|
|
281
|
+
if ( item.iconPath ) {
|
|
282
|
+
|
|
283
|
+
const icon = this._createSvgIcon( item.iconPath, 13, 13 );
|
|
284
|
+
row.appendChild( icon );
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const label = document.createElement( 'span' );
|
|
289
|
+
label.textContent = item.label;
|
|
290
|
+
label.style.flex = '1';
|
|
291
|
+
row.appendChild( label );
|
|
292
|
+
|
|
293
|
+
if ( item.submenu ) {
|
|
294
|
+
|
|
295
|
+
const arrow = document.createElement( 'span' );
|
|
296
|
+
arrow.textContent = '▸';
|
|
297
|
+
arrow.style.cssText = 'font-size: 10px; opacity: 0.6; margin-left: 6px;';
|
|
298
|
+
row.appendChild( arrow );
|
|
299
|
+
|
|
300
|
+
row.style.position = 'relative';
|
|
301
|
+
|
|
302
|
+
const toggleSubmenu = ( e ) => {
|
|
303
|
+
|
|
304
|
+
e.stopPropagation();
|
|
305
|
+
if ( activeSubmenu ) {
|
|
306
|
+
|
|
307
|
+
closeActiveSubmenu();
|
|
308
|
+
|
|
309
|
+
} else {
|
|
310
|
+
|
|
311
|
+
activeSubmenu = showContextMenu( row, item.submenu, true );
|
|
312
|
+
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
row.onmouseenter = () => {
|
|
318
|
+
|
|
319
|
+
closeActiveSubmenu();
|
|
320
|
+
activeSubmenu = showContextMenu( row, item.submenu, true );
|
|
321
|
+
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
row.onclick = toggleSubmenu;
|
|
325
|
+
|
|
326
|
+
} else if ( item.action ) {
|
|
327
|
+
|
|
328
|
+
row.onmouseenter = () => closeActiveSubmenu();
|
|
329
|
+
|
|
330
|
+
row.onclick = ( e ) => {
|
|
331
|
+
|
|
332
|
+
e.stopPropagation();
|
|
333
|
+
closeContextMenu();
|
|
334
|
+
item.action();
|
|
335
|
+
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
menu.appendChild( row );
|
|
341
|
+
|
|
342
|
+
} );
|
|
343
|
+
|
|
344
|
+
if ( ! isSubmenu ) {
|
|
345
|
+
|
|
346
|
+
parentNode.style.position = 'relative';
|
|
347
|
+
activeContextMenu = menu;
|
|
348
|
+
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
parentNode.appendChild( menu );
|
|
352
|
+
return menu;
|
|
353
|
+
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// 3. RIGHT GROUP: Action Buttons with Context Menus
|
|
357
|
+
const rightGroup = document.createElement( 'div' );
|
|
358
|
+
rightGroup.className = 'lut-dock-group';
|
|
359
|
+
|
|
360
|
+
const createDockBtn = ( title, text, svgPath, onClick ) => {
|
|
361
|
+
|
|
362
|
+
const btn = document.createElement( 'button' );
|
|
363
|
+
btn.className = text ? 'lut-dock-btn' : 'lut-dock-btn lut-dock-icon-btn';
|
|
364
|
+
btn.title = title;
|
|
365
|
+
|
|
366
|
+
if ( svgPath ) {
|
|
367
|
+
|
|
368
|
+
const icon = this._createSvgIcon( svgPath, 13, 13 );
|
|
369
|
+
btn.appendChild( icon );
|
|
370
|
+
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if ( text ) {
|
|
374
|
+
|
|
375
|
+
const txt = document.createElement( 'span' );
|
|
376
|
+
txt.textContent = text;
|
|
377
|
+
btn.appendChild( txt );
|
|
378
|
+
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
btn.onclick = onClick;
|
|
382
|
+
return btn;
|
|
383
|
+
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
const importBtn = createDockBtn(
|
|
387
|
+
'Import (.CUBE / JSON / Presets)',
|
|
388
|
+
'▾',
|
|
389
|
+
'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>',
|
|
390
|
+
( e ) => {
|
|
391
|
+
|
|
392
|
+
e.stopPropagation();
|
|
393
|
+
|
|
394
|
+
const presetItems = Object.keys( LUT_PRESETS ).map( presetName => ( {
|
|
395
|
+
label: presetName,
|
|
396
|
+
iconPath: '<path d="M12 2L2 7l10 5 10-5-10-5z"/><path d="M2 17l10 5 10-5"/><path d="M2 12l10 5 10-5"/>',
|
|
397
|
+
action: () => this.load( { params: LUT_PRESETS[ presetName ] } )
|
|
398
|
+
} ) );
|
|
399
|
+
|
|
400
|
+
showContextMenu( importBtn, [
|
|
401
|
+
{
|
|
402
|
+
label: 'Load JSON',
|
|
403
|
+
iconPath: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>',
|
|
404
|
+
action: () => this._importJsonFile()
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
label: 'Import Adobe .CUBE',
|
|
408
|
+
iconPath: '<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/>',
|
|
409
|
+
action: () => this._importCubeFile()
|
|
410
|
+
},
|
|
411
|
+
{ divider: true },
|
|
412
|
+
{
|
|
413
|
+
label: 'Presets',
|
|
414
|
+
iconPath: '<path d="M12 2L2 7l10 5 10-5-10-5z"/><path d="M2 17l10 5 10-5"/><path d="M2 12l10 5 10-5"/>',
|
|
415
|
+
submenu: presetItems
|
|
416
|
+
}
|
|
417
|
+
] );
|
|
418
|
+
|
|
419
|
+
}
|
|
420
|
+
);
|
|
421
|
+
|
|
422
|
+
const exportBtn = createDockBtn(
|
|
423
|
+
'Export (.CUBE / PNG / JSON)',
|
|
424
|
+
'▾',
|
|
425
|
+
'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>',
|
|
426
|
+
( e ) => {
|
|
427
|
+
|
|
428
|
+
e.stopPropagation();
|
|
429
|
+
showContextMenu( exportBtn, [
|
|
430
|
+
{
|
|
431
|
+
label: 'Export JSON',
|
|
432
|
+
iconPath: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>',
|
|
433
|
+
action: () => this._exportJsonFile()
|
|
434
|
+
},
|
|
435
|
+
{ divider: true },
|
|
436
|
+
{
|
|
437
|
+
label: 'Export .CUBE (3D LUT)',
|
|
438
|
+
iconPath: '<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="7.5 4.21 12 6.81 16.5 4.21"/>',
|
|
439
|
+
action: () => this._exportCubeFile()
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
label: 'Export PNG (2D LUT)',
|
|
443
|
+
iconPath: '<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/>',
|
|
444
|
+
action: () => this._exportPngFile()
|
|
445
|
+
}
|
|
446
|
+
] );
|
|
447
|
+
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
const resetBtn = createDockBtn(
|
|
452
|
+
'Reset',
|
|
453
|
+
null,
|
|
454
|
+
'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/>',
|
|
455
|
+
() => {
|
|
456
|
+
|
|
457
|
+
// Reset component pipeline order to default
|
|
458
|
+
this.pipelineOrder = [ ...DEFAULT_PIPELINE_ORDER ];
|
|
459
|
+
|
|
460
|
+
// Remove any custom or duplicated cards if present
|
|
461
|
+
this.modulesMap.forEach( ( comp, modId ) => {
|
|
462
|
+
|
|
463
|
+
if ( ! DEFAULT_PIPELINE_ORDER.includes( modId ) ) {
|
|
464
|
+
|
|
465
|
+
if ( comp && comp.domElement ) comp.domElement.remove();
|
|
466
|
+
this.modulesMap.delete( modId );
|
|
467
|
+
this.cardsMap.delete( modId );
|
|
468
|
+
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
} );
|
|
472
|
+
|
|
473
|
+
// Re-render pipeline cards flow
|
|
474
|
+
this._renderCardsFlow();
|
|
475
|
+
|
|
476
|
+
// Reset all module components
|
|
477
|
+
this.modulesMap.forEach( ( comp ) => {
|
|
478
|
+
|
|
479
|
+
if ( comp && typeof comp.reset === 'function' ) {
|
|
480
|
+
|
|
481
|
+
comp.reset();
|
|
482
|
+
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
} );
|
|
486
|
+
|
|
487
|
+
// Reset all color grading parameters to neutral default
|
|
488
|
+
this.load( { params: LUT_PRESETS[ 'Neutral (Default)' ] } );
|
|
489
|
+
|
|
490
|
+
}
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
rightGroup.appendChild( importBtn );
|
|
494
|
+
rightGroup.appendChild( exportBtn );
|
|
495
|
+
rightGroup.appendChild( resetBtn );
|
|
496
|
+
|
|
497
|
+
dock.appendChild( leftGroup );
|
|
498
|
+
dock.appendChild( centerGroup );
|
|
499
|
+
dock.appendChild( rightGroup );
|
|
500
|
+
|
|
501
|
+
this.viewContainer.appendChild( dock );
|
|
502
|
+
|
|
503
|
+
const panel = document.createElement( 'div' );
|
|
504
|
+
panel.className = 'lut-panel';
|
|
505
|
+
|
|
506
|
+
// Single Unified Horizontal Flow Cards Row
|
|
507
|
+
this.cardsRow = document.createElement( 'div' );
|
|
508
|
+
this.cardsRow.className = 'lut-cards-row';
|
|
509
|
+
|
|
510
|
+
// Default calculation pipeline sequence
|
|
511
|
+
this.pipelineOrder = [ ...DEFAULT_PIPELINE_ORDER ];
|
|
512
|
+
|
|
513
|
+
// Initialize Module instances
|
|
514
|
+
const onParamChange = () => this._onParamChange();
|
|
515
|
+
|
|
516
|
+
const rendererComp = new RendererModule(
|
|
517
|
+
{ toneMapping: this.selectedToneMapping, exposure: 1.0 },
|
|
518
|
+
onParamChange,
|
|
519
|
+
( comp ) => {
|
|
520
|
+
|
|
521
|
+
this.selectedToneMapping = comp.params.toneMapping;
|
|
522
|
+
if ( this.sceneGradingEnabled ) {
|
|
523
|
+
|
|
524
|
+
const renderer = this.inspector ? this.inspector.getRenderer() : null;
|
|
525
|
+
if ( renderer ) {
|
|
526
|
+
|
|
527
|
+
renderer.toneMappingExposure = comp.params.exposure;
|
|
528
|
+
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
this._applyLiveGrading();
|
|
532
|
+
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
this.save();
|
|
536
|
+
|
|
537
|
+
}
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
const wbComp = new WhiteBalanceModule( this.params, onParamChange, () => this._removeCard( 'whiteBalance' ) );
|
|
541
|
+
|
|
542
|
+
const liftComp = new ColorWheelModule( 'lift', 'Shadows', this.params.lift, onParamChange, () => this._removeCard( 'lift' ) );
|
|
543
|
+
const gammaBalComp = new ColorWheelModule( 'gammaBal', 'Midtones', this.params.gammaBal, onParamChange, () => this._removeCard( 'gammaBal' ) );
|
|
544
|
+
const gainComp = new ColorWheelModule( 'gain', 'Highlights', this.params.gain, onParamChange, () => this._removeCard( 'gain' ) );
|
|
545
|
+
const offsetComp = new ColorWheelModule( 'offset', 'Offset', this.params.offset || { r: 0, g: 0, b: 0 }, onParamChange, () => this._removeCard( 'offset' ) );
|
|
546
|
+
|
|
547
|
+
const curvesComp = new CurvesModule( this.params.curves, onParamChange, () => this._removeCard( 'curves' ) );
|
|
548
|
+
const satComp = new SaturationModule( this.params, onParamChange, () => this._removeCard( 'saturation' ) );
|
|
549
|
+
const vibranceComp = new VibranceModule( this.params, onParamChange, () => this._removeCard( 'vibrance' ) );
|
|
550
|
+
const outputComp = new OutputModule( {}, onParamChange );
|
|
551
|
+
|
|
552
|
+
this.modulesMap = new Map( [
|
|
553
|
+
[ 'renderer', rendererComp ],
|
|
554
|
+
[ 'whiteBalance', wbComp ],
|
|
555
|
+
[ 'lift', liftComp ],
|
|
556
|
+
[ 'gammaBal', gammaBalComp ],
|
|
557
|
+
[ 'gain', gainComp ],
|
|
558
|
+
[ 'offset', offsetComp ],
|
|
559
|
+
[ 'curves', curvesComp ],
|
|
560
|
+
[ 'saturation', satComp ],
|
|
561
|
+
[ 'vibrance', vibranceComp ],
|
|
562
|
+
[ 'output', outputComp ]
|
|
563
|
+
] );
|
|
564
|
+
|
|
565
|
+
this.cardsMap = new Map();
|
|
566
|
+
|
|
567
|
+
this.modulesMap.forEach( ( comp, id ) => {
|
|
568
|
+
|
|
569
|
+
this.cardsMap.set( id, comp.domElement );
|
|
570
|
+
this._setupCardDragAndDrop( comp.domElement, id );
|
|
571
|
+
|
|
572
|
+
} );
|
|
573
|
+
|
|
574
|
+
// Render initial flow of cards separated by connector lines
|
|
575
|
+
this._renderCardsFlow();
|
|
576
|
+
|
|
577
|
+
// Enable mouse wheel horizontal scrolling & background drag-to-pan
|
|
578
|
+
this._setupPanAndWheelScroll( panel, this.cardsRow );
|
|
579
|
+
|
|
580
|
+
if ( typeof ResizeObserver !== 'undefined' ) {
|
|
581
|
+
|
|
582
|
+
this._cardsResizeObserver = new ResizeObserver( () => this._updateCardsRowAlignment() );
|
|
583
|
+
this._cardsResizeObserver.observe( this.cardsRow );
|
|
584
|
+
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
this._windowResizeHandler = () => this._updateCardsRowAlignment();
|
|
588
|
+
window.addEventListener( 'resize', this._windowResizeHandler );
|
|
589
|
+
|
|
590
|
+
panel.appendChild( this.cardsRow );
|
|
591
|
+
this.viewContainer.appendChild( panel );
|
|
592
|
+
this.content.appendChild( this.viewContainer );
|
|
593
|
+
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
_isVerticalMode() {
|
|
597
|
+
|
|
598
|
+
if ( ! this.cardsRow ) return false;
|
|
599
|
+
const panelEl = this.content ? this.content.closest( '.profiler-panel' ) : null;
|
|
600
|
+
return this.cardsRow.classList.contains( 'is-vertical' ) ||
|
|
601
|
+
( this.viewContainer && this.viewContainer.classList.contains( 'is-vertical' ) ) ||
|
|
602
|
+
( panelEl && ( panelEl.classList.contains( 'position-left' ) || panelEl.classList.contains( 'position-right' ) ) );
|
|
603
|
+
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
_updateCardsRowAlignment() {
|
|
607
|
+
|
|
608
|
+
if ( ! this.cardsRow ) return;
|
|
609
|
+
|
|
610
|
+
requestAnimationFrame( () => {
|
|
611
|
+
|
|
612
|
+
if ( ! this.cardsRow ) return;
|
|
613
|
+
|
|
614
|
+
const isVert = this._isVerticalMode();
|
|
615
|
+
|
|
616
|
+
if ( isVert ) {
|
|
617
|
+
|
|
618
|
+
const hasVertOverflow = this.cardsRow.scrollHeight > ( this.cardsRow.clientHeight + 2 );
|
|
619
|
+
|
|
620
|
+
if ( hasVertOverflow ) {
|
|
621
|
+
|
|
622
|
+
this.cardsRow.style.setProperty( 'justify-content', 'flex-start', 'important' );
|
|
623
|
+
|
|
624
|
+
} else {
|
|
625
|
+
|
|
626
|
+
this.cardsRow.style.setProperty( 'justify-content', 'center', 'important' );
|
|
627
|
+
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
this.cardsRow.style.setProperty( 'align-items', 'center', 'important' );
|
|
631
|
+
|
|
632
|
+
} else {
|
|
633
|
+
|
|
634
|
+
const hasOverflow = this.cardsRow.scrollWidth > ( this.cardsRow.clientWidth + 2 );
|
|
635
|
+
|
|
636
|
+
if ( hasOverflow ) {
|
|
637
|
+
|
|
638
|
+
this.cardsRow.style.setProperty( 'justify-content', 'flex-start', 'important' );
|
|
639
|
+
|
|
640
|
+
} else {
|
|
641
|
+
|
|
642
|
+
this.cardsRow.style.setProperty( 'justify-content', 'center', 'important' );
|
|
643
|
+
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
this.cardsRow.style.setProperty( 'align-items', 'center', 'important' );
|
|
647
|
+
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
} );
|
|
651
|
+
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
_setupPanAndWheelScroll( container, cardsRow ) {
|
|
655
|
+
|
|
656
|
+
if ( ! cardsRow || ! container ) return;
|
|
657
|
+
|
|
658
|
+
let targetScroll = 0;
|
|
659
|
+
let isAnimating = false;
|
|
660
|
+
|
|
661
|
+
const isVerticalMode = () => this._isVerticalMode();
|
|
662
|
+
|
|
663
|
+
const updateSmoothScroll = () => {
|
|
664
|
+
|
|
665
|
+
const isVert = isVerticalMode();
|
|
666
|
+
const current = isVert ? cardsRow.scrollTop : cardsRow.scrollLeft;
|
|
667
|
+
const diff = targetScroll - current;
|
|
668
|
+
|
|
669
|
+
if ( Math.abs( diff ) > 0.5 ) {
|
|
670
|
+
|
|
671
|
+
if ( isVert ) {
|
|
672
|
+
|
|
673
|
+
cardsRow.scrollTop += diff * 0.18;
|
|
674
|
+
|
|
675
|
+
} else {
|
|
676
|
+
|
|
677
|
+
cardsRow.scrollLeft += diff * 0.18;
|
|
678
|
+
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
requestAnimationFrame( updateSmoothScroll );
|
|
682
|
+
|
|
683
|
+
} else {
|
|
684
|
+
|
|
685
|
+
if ( isVert ) {
|
|
686
|
+
|
|
687
|
+
cardsRow.scrollTop = targetScroll;
|
|
688
|
+
|
|
689
|
+
} else {
|
|
690
|
+
|
|
691
|
+
cardsRow.scrollLeft = targetScroll;
|
|
692
|
+
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
isAnimating = false;
|
|
696
|
+
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
cardsRow.addEventListener( 'wheel', ( e ) => {
|
|
702
|
+
|
|
703
|
+
if ( isVerticalMode() ) {
|
|
704
|
+
|
|
705
|
+
return; // Native vertical scrolling in vertical mode
|
|
706
|
+
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
if ( e.deltaY !== 0 ) {
|
|
710
|
+
|
|
711
|
+
e.preventDefault();
|
|
712
|
+
|
|
713
|
+
const maxScroll = cardsRow.scrollWidth - cardsRow.clientWidth;
|
|
714
|
+
if ( ! isAnimating ) {
|
|
715
|
+
|
|
716
|
+
targetScroll = cardsRow.scrollLeft;
|
|
717
|
+
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
targetScroll = Math.max( 0, Math.min( maxScroll, targetScroll + e.deltaY * 1.2 ) );
|
|
721
|
+
|
|
722
|
+
if ( ! isAnimating ) {
|
|
723
|
+
|
|
724
|
+
isAnimating = true;
|
|
725
|
+
requestAnimationFrame( updateSmoothScroll );
|
|
726
|
+
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
}, { passive: false } );
|
|
732
|
+
|
|
733
|
+
let isPanning = false;
|
|
734
|
+
let startPos = 0;
|
|
735
|
+
let scrollStart = 0;
|
|
736
|
+
let lastPos = 0;
|
|
737
|
+
let lastTime = 0;
|
|
738
|
+
let velocity = 0;
|
|
739
|
+
let momentumRafId = null;
|
|
740
|
+
|
|
741
|
+
const startPan = ( e ) => {
|
|
742
|
+
|
|
743
|
+
if ( e.pointerType === 'touch' ) return;
|
|
744
|
+
if ( e.target.closest( '.lut-card' ) || e.target.closest( '.lut-dock-container' ) ) return;
|
|
745
|
+
|
|
746
|
+
if ( momentumRafId ) {
|
|
747
|
+
|
|
748
|
+
cancelAnimationFrame( momentumRafId );
|
|
749
|
+
momentumRafId = null;
|
|
750
|
+
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
isPanning = true;
|
|
754
|
+
cardsRow.classList.add( 'is-panning' );
|
|
755
|
+
container.classList.add( 'is-panning' );
|
|
756
|
+
|
|
757
|
+
const isVert = isVerticalMode();
|
|
758
|
+
const currentPos = isVert ? ( e.pageY - cardsRow.offsetTop ) : ( e.pageX - cardsRow.offsetLeft );
|
|
759
|
+
|
|
760
|
+
startPos = currentPos;
|
|
761
|
+
lastPos = currentPos;
|
|
762
|
+
lastTime = performance.now();
|
|
763
|
+
velocity = 0;
|
|
764
|
+
scrollStart = isVert ? cardsRow.scrollTop : cardsRow.scrollLeft;
|
|
765
|
+
targetScroll = scrollStart;
|
|
766
|
+
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
const movePan = ( e ) => {
|
|
770
|
+
|
|
771
|
+
if ( ! isPanning ) return;
|
|
772
|
+
e.preventDefault();
|
|
773
|
+
|
|
774
|
+
const isVert = isVerticalMode();
|
|
775
|
+
const currentPos = isVert ? ( e.pageY - cardsRow.offsetTop ) : ( e.pageX - cardsRow.offsetLeft );
|
|
776
|
+
const currentTime = performance.now();
|
|
777
|
+
|
|
778
|
+
const deltaPos = currentPos - lastPos;
|
|
779
|
+
const deltaTime = Math.max( 1, currentTime - lastTime );
|
|
780
|
+
|
|
781
|
+
const instantVelocity = deltaPos / deltaTime;
|
|
782
|
+
velocity = 0.5 * velocity + 0.5 * instantVelocity;
|
|
783
|
+
|
|
784
|
+
lastPos = currentPos;
|
|
785
|
+
lastTime = currentTime;
|
|
786
|
+
|
|
787
|
+
const walk = currentPos - startPos;
|
|
788
|
+
|
|
789
|
+
if ( isVert ) {
|
|
790
|
+
|
|
791
|
+
cardsRow.scrollTop = scrollStart - walk;
|
|
792
|
+
targetScroll = cardsRow.scrollTop;
|
|
793
|
+
|
|
794
|
+
} else {
|
|
795
|
+
|
|
796
|
+
cardsRow.scrollLeft = scrollStart - walk;
|
|
797
|
+
targetScroll = cardsRow.scrollLeft;
|
|
798
|
+
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
const endPan = () => {
|
|
804
|
+
|
|
805
|
+
if ( ! isPanning ) return;
|
|
806
|
+
|
|
807
|
+
isPanning = false;
|
|
808
|
+
cardsRow.classList.remove( 'is-panning' );
|
|
809
|
+
container.classList.remove( 'is-panning' );
|
|
810
|
+
|
|
811
|
+
const isVert = isVerticalMode();
|
|
812
|
+
|
|
813
|
+
// Apply smooth momentum deceleration physics
|
|
814
|
+
let currentVelocity = velocity;
|
|
815
|
+
|
|
816
|
+
const animateMomentum = () => {
|
|
817
|
+
|
|
818
|
+
if ( Math.abs( currentVelocity ) < 0.02 ) return;
|
|
819
|
+
|
|
820
|
+
const maxScroll = isVert ? ( cardsRow.scrollHeight - cardsRow.clientHeight ) : ( cardsRow.scrollWidth - cardsRow.clientWidth );
|
|
821
|
+
|
|
822
|
+
if ( isVert ) {
|
|
823
|
+
|
|
824
|
+
cardsRow.scrollTop = Math.max( 0, Math.min( maxScroll, cardsRow.scrollTop - currentVelocity * 16 ) );
|
|
825
|
+
|
|
826
|
+
} else {
|
|
827
|
+
|
|
828
|
+
cardsRow.scrollLeft = Math.max( 0, Math.min( maxScroll, cardsRow.scrollLeft - currentVelocity * 16 ) );
|
|
829
|
+
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
currentVelocity *= 0.94; // Friction factor
|
|
833
|
+
|
|
834
|
+
if ( Math.abs( currentVelocity ) >= 0.02 ) {
|
|
835
|
+
|
|
836
|
+
momentumRafId = requestAnimationFrame( animateMomentum );
|
|
837
|
+
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
momentumRafId = requestAnimationFrame( animateMomentum );
|
|
843
|
+
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
cardsRow.addEventListener( 'pointerdown', startPan );
|
|
847
|
+
window.addEventListener( 'pointermove', movePan );
|
|
848
|
+
window.addEventListener( 'pointerup', endPan );
|
|
849
|
+
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
_renderCardsFlow() {
|
|
853
|
+
|
|
854
|
+
if ( ! this.cardsRow ) return;
|
|
855
|
+
|
|
856
|
+
// Remove cards no longer in pipelineOrder
|
|
857
|
+
const existingCards = Array.from( this.cardsRow.children );
|
|
858
|
+
existingCards.forEach( child => {
|
|
859
|
+
|
|
860
|
+
const modId = child.getAttribute( 'data-module-id' );
|
|
861
|
+
if ( modId && ! this.pipelineOrder.includes( modId ) ) {
|
|
862
|
+
|
|
863
|
+
child.remove();
|
|
864
|
+
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
} );
|
|
868
|
+
|
|
869
|
+
// Clean old connectors
|
|
870
|
+
const connectors = this.cardsRow.querySelectorAll( '.lut-flow-connector' );
|
|
871
|
+
connectors.forEach( c => c.remove() );
|
|
872
|
+
|
|
873
|
+
// Guarantee Renderer at start (0) and Output at end (last)
|
|
874
|
+
if ( ! this.pipelineOrder.includes( 'renderer' ) ) {
|
|
875
|
+
|
|
876
|
+
this.pipelineOrder.unshift( 'renderer' );
|
|
877
|
+
|
|
878
|
+
} else {
|
|
879
|
+
|
|
880
|
+
const rIdx = this.pipelineOrder.indexOf( 'renderer' );
|
|
881
|
+
if ( rIdx !== 0 ) {
|
|
882
|
+
|
|
883
|
+
this.pipelineOrder.splice( rIdx, 1 );
|
|
884
|
+
this.pipelineOrder.unshift( 'renderer' );
|
|
885
|
+
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
if ( ! this.pipelineOrder.includes( 'output' ) ) {
|
|
891
|
+
|
|
892
|
+
this.pipelineOrder.push( 'output' );
|
|
893
|
+
|
|
894
|
+
} else {
|
|
895
|
+
|
|
896
|
+
const oIdx = this.pipelineOrder.indexOf( 'output' );
|
|
897
|
+
if ( oIdx !== this.pipelineOrder.length - 1 ) {
|
|
898
|
+
|
|
899
|
+
this.pipelineOrder.splice( oIdx, 1 );
|
|
900
|
+
this.pipelineOrder.push( 'output' );
|
|
901
|
+
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// Re-append cards in current pipelineOrder
|
|
907
|
+
this.pipelineOrder.forEach( ( modId ) => {
|
|
908
|
+
|
|
909
|
+
const comp = this.modulesMap.get( modId );
|
|
910
|
+
if ( comp && comp.domElement ) {
|
|
911
|
+
|
|
912
|
+
comp.domElement.classList.remove( 'lut-card-moving' );
|
|
913
|
+
this.cardsRow.appendChild( comp.domElement );
|
|
914
|
+
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
} );
|
|
918
|
+
|
|
919
|
+
this._updateLiveFlowConnectors();
|
|
920
|
+
this._updateRendererCardState();
|
|
921
|
+
this._updateCardsRowAlignment();
|
|
922
|
+
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
_updateLiveFlowConnectors() {
|
|
926
|
+
|
|
927
|
+
if ( ! this.cardsRow ) return;
|
|
928
|
+
|
|
929
|
+
const oldConnectors = this.cardsRow.querySelectorAll( '.lut-flow-connector' );
|
|
930
|
+
oldConnectors.forEach( c => c.remove() );
|
|
931
|
+
|
|
932
|
+
const items = Array.from( this.cardsRow.children ).filter( el =>
|
|
933
|
+
el.classList.contains( 'lut-card' )
|
|
934
|
+
);
|
|
935
|
+
|
|
936
|
+
const createConnector = ( insertIndex, titleTip ) => {
|
|
937
|
+
|
|
938
|
+
const connector = document.createElement( 'div' );
|
|
939
|
+
connector.className = 'lut-flow-connector';
|
|
940
|
+
connector.title = titleTip;
|
|
941
|
+
|
|
942
|
+
const addBtn = document.createElement( 'button' );
|
|
943
|
+
addBtn.className = 'lut-connector-add-btn';
|
|
944
|
+
addBtn.appendChild( this._createSvgIcon( '<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>', 12, 12, 2.5 ) );
|
|
945
|
+
addBtn.title = 'Add Card Here';
|
|
946
|
+
addBtn.onclick = ( e ) => {
|
|
947
|
+
|
|
948
|
+
e.stopPropagation();
|
|
949
|
+
this._openAddCardModal( insertIndex );
|
|
950
|
+
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
connector.appendChild( addBtn );
|
|
954
|
+
return connector;
|
|
955
|
+
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
for ( let i = 0; i < items.length - 1; i ++ ) {
|
|
959
|
+
|
|
960
|
+
const current = items[ i ];
|
|
961
|
+
const next = items[ i + 1 ];
|
|
962
|
+
|
|
963
|
+
const idA = current.getAttribute( 'data-module-id' ) || 'Origin';
|
|
964
|
+
const idB = next.getAttribute( 'data-module-id' ) || 'Target';
|
|
965
|
+
|
|
966
|
+
const connector = createConnector( i + 1, `Insert Card between ${idA} ➔ ${idB}` );
|
|
967
|
+
this.cardsRow.insertBefore( connector, next );
|
|
968
|
+
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
_openAddCardModal( insertIndex ) {
|
|
974
|
+
|
|
975
|
+
this._closeAddCardModal();
|
|
976
|
+
|
|
977
|
+
const overlay = document.createElement( 'div' );
|
|
978
|
+
overlay.className = 'lut-modal-overlay';
|
|
979
|
+
this._activeModalOverlay = overlay;
|
|
980
|
+
|
|
981
|
+
const content = document.createElement( 'div' );
|
|
982
|
+
content.className = 'lut-modal-content';
|
|
983
|
+
|
|
984
|
+
// Header
|
|
985
|
+
const header = document.createElement( 'div' );
|
|
986
|
+
header.className = 'lut-modal-header';
|
|
987
|
+
|
|
988
|
+
const title = document.createElement( 'div' );
|
|
989
|
+
title.className = 'lut-modal-title';
|
|
990
|
+
title.appendChild( this._createSvgIcon( '<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>', 14, 14, 2.5 ) );
|
|
991
|
+
|
|
992
|
+
const titleTxt = document.createElement( 'span' );
|
|
993
|
+
titleTxt.textContent = 'Add to Pipeline';
|
|
994
|
+
title.appendChild( titleTxt );
|
|
995
|
+
|
|
996
|
+
const closeBtn = document.createElement( 'button' );
|
|
997
|
+
closeBtn.className = 'lut-modal-close-btn';
|
|
998
|
+
closeBtn.appendChild( this._createSvgIcon( '<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>', 12, 12, 2.5 ) );
|
|
999
|
+
closeBtn.title = 'Close';
|
|
1000
|
+
closeBtn.onclick = () => this._closeAddCardModal();
|
|
1001
|
+
|
|
1002
|
+
header.appendChild( title );
|
|
1003
|
+
header.appendChild( closeBtn );
|
|
1004
|
+
content.appendChild( header );
|
|
1005
|
+
|
|
1006
|
+
// Filter Input Search Bar
|
|
1007
|
+
const filterBox = document.createElement( 'div' );
|
|
1008
|
+
filterBox.className = 'lut-modal-filter-box';
|
|
1009
|
+
|
|
1010
|
+
const filterIcon = document.createElement( 'span' );
|
|
1011
|
+
filterIcon.className = 'lut-modal-filter-icon';
|
|
1012
|
+
filterIcon.appendChild( this._createSvgIcon( '<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>', 13, 13, 2 ) );
|
|
1013
|
+
|
|
1014
|
+
const filterInput = document.createElement( 'input' );
|
|
1015
|
+
filterInput.type = 'text';
|
|
1016
|
+
filterInput.className = 'lut-modal-filter-input';
|
|
1017
|
+
filterInput.placeholder = 'Filter...';
|
|
1018
|
+
|
|
1019
|
+
filterBox.appendChild( filterIcon );
|
|
1020
|
+
filterBox.appendChild( filterInput );
|
|
1021
|
+
content.appendChild( filterBox );
|
|
1022
|
+
|
|
1023
|
+
// Options Grid
|
|
1024
|
+
const grid = document.createElement( 'div' );
|
|
1025
|
+
grid.className = 'lut-modal-grid';
|
|
1026
|
+
|
|
1027
|
+
const emptyMsg = document.createElement( 'div' );
|
|
1028
|
+
emptyMsg.className = 'lut-modal-empty-msg';
|
|
1029
|
+
emptyMsg.textContent = 'No cards match your filter';
|
|
1030
|
+
emptyMsg.style.display = 'none';
|
|
1031
|
+
|
|
1032
|
+
const cardOptions = [
|
|
1033
|
+
{
|
|
1034
|
+
type: 'whiteBalance',
|
|
1035
|
+
name: 'White Balance',
|
|
1036
|
+
iconSvg: '<path d="M14 14.76V3.5a2.5 2.5 0 0 0-5 0v11.26a4.5 4.5 0 1 0 5 0z"/>'
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
type: 'exposure',
|
|
1040
|
+
name: 'Exposure',
|
|
1041
|
+
iconSvg: '<circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>'
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
type: 'brightness',
|
|
1045
|
+
name: 'Brightness',
|
|
1046
|
+
iconSvg: '<circle cx="12" cy="12" r="9"/><path d="M12 3v18a9 9 0 0 0 0-18z"/>'
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
type: 'hue',
|
|
1050
|
+
name: 'Hue Shift',
|
|
1051
|
+
iconSvg: '<circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 1 9 9h-9V3z"/>'
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
type: 'lift',
|
|
1055
|
+
name: 'Shadows (Lift)',
|
|
1056
|
+
iconSvg: '<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>'
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
type: 'gammaBal',
|
|
1060
|
+
name: 'Midtones (Gamma)',
|
|
1061
|
+
iconSvg: '<circle cx="12" cy="12" r="10"/><path d="M12 2a10 10 0 0 0 0 20z" fill="currentColor"/>'
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
type: 'gain',
|
|
1065
|
+
name: 'Highlights (Gain)',
|
|
1066
|
+
iconSvg: '<circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="4"/>'
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
type: 'offset',
|
|
1070
|
+
name: 'Offset',
|
|
1071
|
+
iconSvg: '<circle cx="12" cy="12" r="10"/><line x1="22" y1="12" x2="18" y2="12"/><line x1="6" y1="12" x2="2" y2="12"/><line x1="12" y1="6" x2="12" y2="2"/><line x1="12" y1="22" x2="12" y2="18"/>'
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
type: 'curves',
|
|
1075
|
+
name: 'Curves',
|
|
1076
|
+
iconSvg: '<path d="M3 3v18h18"/><path d="M19 9l-5 5-4-4-3 3"/>'
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
type: 'contrast',
|
|
1080
|
+
name: 'Contrast & Pivot',
|
|
1081
|
+
iconSvg: '<circle cx="12" cy="12" r="10"/><path d="M12 2v20a10 10 0 0 0 0-20z"/>'
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
type: 'saturation',
|
|
1085
|
+
name: 'Saturation',
|
|
1086
|
+
iconSvg: '<path d="M12 2.69l5.66 5.66a8 8 0 1 1-11.31 0z"/>'
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
type: 'vibrance',
|
|
1090
|
+
name: 'Vibrance',
|
|
1091
|
+
iconSvg: '<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>'
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
type: 'importedCube',
|
|
1095
|
+
name: 'Import .CUBE',
|
|
1096
|
+
iconSvg: '<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/>'
|
|
1097
|
+
}
|
|
1098
|
+
];
|
|
1099
|
+
|
|
1100
|
+
const optionElements = [];
|
|
1101
|
+
|
|
1102
|
+
cardOptions.forEach( opt => {
|
|
1103
|
+
|
|
1104
|
+
const item = document.createElement( 'div' );
|
|
1105
|
+
item.className = 'lut-modal-option';
|
|
1106
|
+
|
|
1107
|
+
const icon = document.createElement( 'div' );
|
|
1108
|
+
icon.className = 'lut-modal-option-icon';
|
|
1109
|
+
icon.appendChild( this._createSvgIcon( opt.iconSvg, 20, 20, 2 ) );
|
|
1110
|
+
|
|
1111
|
+
const optTitle = document.createElement( 'div' );
|
|
1112
|
+
optTitle.className = 'lut-modal-option-title';
|
|
1113
|
+
optTitle.textContent = opt.name;
|
|
1114
|
+
|
|
1115
|
+
item.appendChild( icon );
|
|
1116
|
+
item.appendChild( optTitle );
|
|
1117
|
+
|
|
1118
|
+
const selectAction = () => {
|
|
1119
|
+
|
|
1120
|
+
this._closeAddCardModal();
|
|
1121
|
+
if ( opt.type === 'importedCube' ) {
|
|
1122
|
+
|
|
1123
|
+
this._importCubeFileAt( insertIndex );
|
|
1124
|
+
|
|
1125
|
+
} else {
|
|
1126
|
+
|
|
1127
|
+
this._addCardAt( opt.type, insertIndex );
|
|
1128
|
+
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1133
|
+
item.onclick = selectAction;
|
|
1134
|
+
|
|
1135
|
+
grid.appendChild( item );
|
|
1136
|
+
optionElements.push( { el: item, name: opt.name.toLowerCase(), select: selectAction } );
|
|
1137
|
+
|
|
1138
|
+
} );
|
|
1139
|
+
|
|
1140
|
+
grid.appendChild( emptyMsg );
|
|
1141
|
+
|
|
1142
|
+
const updateFocusState = ( query, visibleCount ) => {
|
|
1143
|
+
|
|
1144
|
+
let singleVisibleObj = null;
|
|
1145
|
+
if ( query.length > 0 && visibleCount === 1 ) {
|
|
1146
|
+
|
|
1147
|
+
singleVisibleObj = optionElements.find( obj => obj.el.style.display !== 'none' );
|
|
1148
|
+
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
optionElements.forEach( obj => {
|
|
1152
|
+
|
|
1153
|
+
if ( singleVisibleObj && obj === singleVisibleObj ) {
|
|
1154
|
+
|
|
1155
|
+
obj.el.classList.add( 'is-focused' );
|
|
1156
|
+
|
|
1157
|
+
} else {
|
|
1158
|
+
|
|
1159
|
+
obj.el.classList.remove( 'is-focused' );
|
|
1160
|
+
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
} );
|
|
1164
|
+
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
filterInput.oninput = () => {
|
|
1168
|
+
|
|
1169
|
+
const query = filterInput.value.trim().toLowerCase();
|
|
1170
|
+
let visibleCount = 0;
|
|
1171
|
+
|
|
1172
|
+
optionElements.forEach( obj => {
|
|
1173
|
+
|
|
1174
|
+
const matches = ! query || obj.name.includes( query );
|
|
1175
|
+
obj.el.style.display = matches ? 'flex' : 'none';
|
|
1176
|
+
if ( matches ) visibleCount ++;
|
|
1177
|
+
|
|
1178
|
+
} );
|
|
1179
|
+
|
|
1180
|
+
emptyMsg.style.display = visibleCount === 0 ? 'block' : 'none';
|
|
1181
|
+
|
|
1182
|
+
if ( visibleCount === 1 ) {
|
|
1183
|
+
|
|
1184
|
+
grid.style.justifyContent = 'center';
|
|
1185
|
+
grid.style.alignContent = 'center';
|
|
1186
|
+
grid.style.gridTemplateColumns = 'minmax(120px, 150px)';
|
|
1187
|
+
|
|
1188
|
+
} else {
|
|
1189
|
+
|
|
1190
|
+
grid.style.justifyContent = 'start';
|
|
1191
|
+
grid.style.alignContent = 'start';
|
|
1192
|
+
grid.style.gridTemplateColumns = 'repeat(auto-fill, minmax(120px, 1fr))';
|
|
1193
|
+
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
updateFocusState( query, visibleCount );
|
|
1197
|
+
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1200
|
+
updateFocusState( '', optionElements.length );
|
|
1201
|
+
|
|
1202
|
+
const handleKeyDown = ( e ) => {
|
|
1203
|
+
|
|
1204
|
+
if ( e.key === 'Escape' || e.code === 'Escape' || e.keyCode === 27 ) {
|
|
1205
|
+
|
|
1206
|
+
e.preventDefault();
|
|
1207
|
+
e.stopImmediatePropagation();
|
|
1208
|
+
this._closeAddCardModal();
|
|
1209
|
+
|
|
1210
|
+
} else if ( e.key === 'Enter' || e.code === 'Enter' || e.keyCode === 13 ) {
|
|
1211
|
+
|
|
1212
|
+
e.preventDefault();
|
|
1213
|
+
e.stopImmediatePropagation();
|
|
1214
|
+
const visibleItem = optionElements.find( obj => obj.el.style.display !== 'none' );
|
|
1215
|
+
if ( visibleItem ) {
|
|
1216
|
+
|
|
1217
|
+
visibleItem.select();
|
|
1218
|
+
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
};
|
|
1224
|
+
|
|
1225
|
+
window.addEventListener( 'keydown', handleKeyDown, true );
|
|
1226
|
+
this._modalKeyDownHandler = handleKeyDown;
|
|
1227
|
+
|
|
1228
|
+
content.appendChild( grid );
|
|
1229
|
+
overlay.appendChild( content );
|
|
1230
|
+
|
|
1231
|
+
setTimeout( () => filterInput.focus(), 50 );
|
|
1232
|
+
|
|
1233
|
+
overlay.onclick = ( e ) => {
|
|
1234
|
+
|
|
1235
|
+
if ( e.target === overlay ) {
|
|
1236
|
+
|
|
1237
|
+
this._closeAddCardModal();
|
|
1238
|
+
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
if ( this.viewContainer ) {
|
|
1244
|
+
|
|
1245
|
+
this.viewContainer.appendChild( overlay );
|
|
1246
|
+
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
_closeAddCardModal() {
|
|
1252
|
+
|
|
1253
|
+
if ( this._modalKeyDownHandler ) {
|
|
1254
|
+
|
|
1255
|
+
window.removeEventListener( 'keydown', this._modalKeyDownHandler, true );
|
|
1256
|
+
this._modalKeyDownHandler = null;
|
|
1257
|
+
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
if ( this._activeModalOverlay ) {
|
|
1261
|
+
|
|
1262
|
+
this._activeModalOverlay.remove();
|
|
1263
|
+
this._activeModalOverlay = null;
|
|
1264
|
+
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
_addCardAt( type, insertIndex, initialParams = {}, customId = null ) {
|
|
1270
|
+
|
|
1271
|
+
const modId = customId || ( `${type}_${Date.now()}_${Math.floor( Math.random() * 1000 )}` );
|
|
1272
|
+
|
|
1273
|
+
const onParamChange = () => this._onParamChange();
|
|
1274
|
+
const onRemove = () => this._removeCard( modId );
|
|
1275
|
+
|
|
1276
|
+
let comp = null;
|
|
1277
|
+
|
|
1278
|
+
switch ( type ) {
|
|
1279
|
+
|
|
1280
|
+
case 'whiteBalance':
|
|
1281
|
+
comp = new WhiteBalanceModule( initialParams, onParamChange, onRemove, modId );
|
|
1282
|
+
break;
|
|
1283
|
+
|
|
1284
|
+
case 'exposure':
|
|
1285
|
+
case 'exposureHue':
|
|
1286
|
+
comp = new ExposureModule( initialParams, onParamChange, onRemove, modId );
|
|
1287
|
+
break;
|
|
1288
|
+
|
|
1289
|
+
case 'brightness':
|
|
1290
|
+
comp = new BrightnessModule( initialParams, onParamChange, onRemove, modId );
|
|
1291
|
+
break;
|
|
1292
|
+
|
|
1293
|
+
case 'hue':
|
|
1294
|
+
comp = new HueModule( initialParams, onParamChange, onRemove, modId );
|
|
1295
|
+
break;
|
|
1296
|
+
|
|
1297
|
+
case 'lift':
|
|
1298
|
+
comp = new ColorWheelModule( 'lift', 'Shadows', initialParams, onParamChange, onRemove, modId );
|
|
1299
|
+
break;
|
|
1300
|
+
|
|
1301
|
+
case 'gammaBal':
|
|
1302
|
+
comp = new ColorWheelModule( 'gammaBal', 'Midtones', initialParams, onParamChange, onRemove, modId );
|
|
1303
|
+
break;
|
|
1304
|
+
|
|
1305
|
+
case 'gain':
|
|
1306
|
+
comp = new ColorWheelModule( 'gain', 'Highlights', initialParams, onParamChange, onRemove, modId );
|
|
1307
|
+
break;
|
|
1308
|
+
|
|
1309
|
+
case 'offset':
|
|
1310
|
+
comp = new ColorWheelModule( 'offset', 'Offset', initialParams, onParamChange, onRemove, modId );
|
|
1311
|
+
break;
|
|
1312
|
+
|
|
1313
|
+
case 'curves':
|
|
1314
|
+
comp = new CurvesModule( initialParams, onParamChange, onRemove, modId );
|
|
1315
|
+
break;
|
|
1316
|
+
|
|
1317
|
+
case 'contrast':
|
|
1318
|
+
comp = new ContrastModule( initialParams, onParamChange, onRemove, modId );
|
|
1319
|
+
break;
|
|
1320
|
+
|
|
1321
|
+
case 'saturation':
|
|
1322
|
+
comp = new SaturationModule( initialParams, onParamChange, onRemove, modId );
|
|
1323
|
+
break;
|
|
1324
|
+
|
|
1325
|
+
case 'vibrance':
|
|
1326
|
+
case 'satVibrance':
|
|
1327
|
+
comp = new VibranceModule( initialParams, onParamChange, onRemove, modId );
|
|
1328
|
+
break;
|
|
1329
|
+
|
|
1330
|
+
default:
|
|
1331
|
+
console.warn( `Unknown card module type: ${type}` );
|
|
1332
|
+
return null;
|
|
1333
|
+
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
this.modulesMap.set( modId, comp );
|
|
1337
|
+
this.cardsMap.set( modId, comp.domElement );
|
|
1338
|
+
|
|
1339
|
+
const targetIdx = Math.max( 0, Math.min( this.pipelineOrder.length, insertIndex ) );
|
|
1340
|
+
this.pipelineOrder.splice( targetIdx, 0, modId );
|
|
1341
|
+
|
|
1342
|
+
this._setupCardDragAndDrop( comp.domElement, modId );
|
|
1343
|
+
this._renderCardsFlow();
|
|
1344
|
+
this._onParamChange();
|
|
1345
|
+
|
|
1346
|
+
if ( comp.domElement ) {
|
|
1347
|
+
|
|
1348
|
+
setTimeout( () => {
|
|
1349
|
+
|
|
1350
|
+
comp.domElement.scrollIntoView( { behavior: 'smooth', block: 'nearest', inline: 'center' } );
|
|
1351
|
+
|
|
1352
|
+
}, 50 );
|
|
1353
|
+
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
return comp;
|
|
1357
|
+
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
_removeCard( modId ) {
|
|
1361
|
+
|
|
1362
|
+
const comp = this.modulesMap.get( modId );
|
|
1363
|
+
if ( comp ) {
|
|
1364
|
+
|
|
1365
|
+
if ( comp.domElement ) comp.domElement.remove();
|
|
1366
|
+
this.modulesMap.delete( modId );
|
|
1367
|
+
this.cardsMap.delete( modId );
|
|
1368
|
+
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
const idx = this.pipelineOrder.indexOf( modId );
|
|
1372
|
+
if ( idx !== - 1 ) {
|
|
1373
|
+
|
|
1374
|
+
this.pipelineOrder.splice( idx, 1 );
|
|
1375
|
+
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
this._renderCardsFlow();
|
|
1379
|
+
this._onParamChange();
|
|
1380
|
+
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
_setupCardDragAndDrop( card, moduleId ) {
|
|
1384
|
+
|
|
1385
|
+
card.setAttribute( 'data-module-id', moduleId );
|
|
1386
|
+
|
|
1387
|
+
const comp = this.modulesMap.get( moduleId );
|
|
1388
|
+
const isDraggable = comp ? comp.dragAndDrop !== false : true;
|
|
1389
|
+
|
|
1390
|
+
if ( ! isDraggable ) {
|
|
1391
|
+
|
|
1392
|
+
card.classList.add( 'lut-card-nodrag' );
|
|
1393
|
+
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
const header = card.querySelector( '.lut-card-header' );
|
|
1397
|
+
|
|
1398
|
+
if ( header ) {
|
|
1399
|
+
|
|
1400
|
+
if ( isDraggable ) {
|
|
1401
|
+
|
|
1402
|
+
header.draggable = true;
|
|
1403
|
+
|
|
1404
|
+
if ( ! header.querySelector( '.lut-card-drag-handle' ) ) {
|
|
1405
|
+
|
|
1406
|
+
const dragHandle = document.createElement( 'div' );
|
|
1407
|
+
dragHandle.className = 'lut-card-drag-handle';
|
|
1408
|
+
header.insertBefore( dragHandle, header.firstChild );
|
|
1409
|
+
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
header.ondragstart = ( e ) => {
|
|
1413
|
+
|
|
1414
|
+
e.dataTransfer.setData( 'text/plain', moduleId );
|
|
1415
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
1416
|
+
|
|
1417
|
+
const rect = card.getBoundingClientRect();
|
|
1418
|
+
const xOffset = e.clientX - rect.left;
|
|
1419
|
+
const yOffset = e.clientY - rect.top;
|
|
1420
|
+
e.dataTransfer.setDragImage( card, xOffset, yOffset );
|
|
1421
|
+
|
|
1422
|
+
this._draggedModuleId = moduleId;
|
|
1423
|
+
|
|
1424
|
+
setTimeout( () => {
|
|
1425
|
+
|
|
1426
|
+
card.classList.add( 'lut-card-moving' );
|
|
1427
|
+
|
|
1428
|
+
}, 0 );
|
|
1429
|
+
|
|
1430
|
+
this._updateLiveFlowConnectors();
|
|
1431
|
+
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
header.ondragend = () => {
|
|
1435
|
+
|
|
1436
|
+
card.classList.remove( 'lut-card-moving' );
|
|
1437
|
+
this._draggedModuleId = null;
|
|
1438
|
+
|
|
1439
|
+
const newOrder = [];
|
|
1440
|
+
const childCards = this.cardsRow.querySelectorAll( '.lut-card' );
|
|
1441
|
+
childCards.forEach( childCard => {
|
|
1442
|
+
|
|
1443
|
+
const id = childCard.getAttribute( 'data-module-id' );
|
|
1444
|
+
if ( id && ! newOrder.includes( id ) ) {
|
|
1445
|
+
|
|
1446
|
+
newOrder.push( id );
|
|
1447
|
+
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
} );
|
|
1451
|
+
|
|
1452
|
+
if ( newOrder.length > 0 ) {
|
|
1453
|
+
|
|
1454
|
+
this.pipelineOrder = newOrder;
|
|
1455
|
+
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
this._renderCardsFlow();
|
|
1459
|
+
this._onParamChange();
|
|
1460
|
+
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
} else {
|
|
1464
|
+
|
|
1465
|
+
header.draggable = false;
|
|
1466
|
+
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
card.ondragover = ( e ) => {
|
|
1472
|
+
|
|
1473
|
+
e.preventDefault();
|
|
1474
|
+
e.dataTransfer.dropEffect = 'move';
|
|
1475
|
+
|
|
1476
|
+
if ( this._draggedModuleId && this.cardsMap.has( this._draggedModuleId ) ) {
|
|
1477
|
+
|
|
1478
|
+
const draggedCard = this.cardsMap.get( this._draggedModuleId );
|
|
1479
|
+
if ( card === draggedCard ) return;
|
|
1480
|
+
|
|
1481
|
+
const targetComp = this.modulesMap.get( moduleId );
|
|
1482
|
+
if ( targetComp && targetComp.dragAndDrop === false ) return;
|
|
1483
|
+
|
|
1484
|
+
const draggedComp = this.modulesMap.get( this._draggedModuleId );
|
|
1485
|
+
if ( draggedComp && draggedComp.dragAndDrop === false ) return;
|
|
1486
|
+
|
|
1487
|
+
const rect = card.getBoundingClientRect();
|
|
1488
|
+
const isVert = this._isVerticalMode();
|
|
1489
|
+
|
|
1490
|
+
const childCards = Array.from( this.cardsRow.querySelectorAll( '.lut-card' ) );
|
|
1491
|
+
const draggedIndex = childCards.indexOf( draggedCard );
|
|
1492
|
+
const targetIndex = childCards.indexOf( card );
|
|
1493
|
+
|
|
1494
|
+
let changed = false;
|
|
1495
|
+
|
|
1496
|
+
if ( isVert ) {
|
|
1497
|
+
|
|
1498
|
+
const relativeY = ( e.clientY - rect.top ) / rect.height;
|
|
1499
|
+
|
|
1500
|
+
if ( draggedIndex < targetIndex ) {
|
|
1501
|
+
|
|
1502
|
+
if ( relativeY > 0.05 ) {
|
|
1503
|
+
|
|
1504
|
+
if ( card.nextSibling !== draggedCard ) {
|
|
1505
|
+
|
|
1506
|
+
this.cardsRow.insertBefore( draggedCard, card.nextSibling );
|
|
1507
|
+
changed = true;
|
|
1508
|
+
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
} else {
|
|
1514
|
+
|
|
1515
|
+
if ( relativeY < 0.95 ) {
|
|
1516
|
+
|
|
1517
|
+
if ( card.previousSibling !== draggedCard ) {
|
|
1518
|
+
|
|
1519
|
+
this.cardsRow.insertBefore( draggedCard, card );
|
|
1520
|
+
changed = true;
|
|
1521
|
+
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
} else {
|
|
1529
|
+
|
|
1530
|
+
const relativeX = ( e.clientX - rect.left ) / rect.width;
|
|
1531
|
+
|
|
1532
|
+
if ( draggedIndex < targetIndex ) {
|
|
1533
|
+
|
|
1534
|
+
if ( relativeX > 0.05 ) {
|
|
1535
|
+
|
|
1536
|
+
if ( card.nextSibling !== draggedCard ) {
|
|
1537
|
+
|
|
1538
|
+
this.cardsRow.insertBefore( draggedCard, card.nextSibling );
|
|
1539
|
+
changed = true;
|
|
1540
|
+
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
} else {
|
|
1546
|
+
|
|
1547
|
+
if ( relativeX < 0.95 ) {
|
|
1548
|
+
|
|
1549
|
+
if ( card.previousSibling !== draggedCard ) {
|
|
1550
|
+
|
|
1551
|
+
this.cardsRow.insertBefore( draggedCard, card );
|
|
1552
|
+
changed = true;
|
|
1553
|
+
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
if ( changed ) {
|
|
1563
|
+
|
|
1564
|
+
this._updateLiveFlowConnectors();
|
|
1565
|
+
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
};
|
|
1571
|
+
|
|
1572
|
+
card.ondrop = ( e ) => {
|
|
1573
|
+
|
|
1574
|
+
e.preventDefault();
|
|
1575
|
+
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
_updateRendererCardState() {
|
|
1581
|
+
|
|
1582
|
+
if ( ! this.cardsRow ) return;
|
|
1583
|
+
|
|
1584
|
+
const cards = this.cardsRow.querySelectorAll( '.lut-card' );
|
|
1585
|
+
cards.forEach( card => {
|
|
1586
|
+
|
|
1587
|
+
if ( this.sceneGradingEnabled ) {
|
|
1588
|
+
|
|
1589
|
+
card.style.opacity = '1';
|
|
1590
|
+
card.style.pointerEvents = 'auto';
|
|
1591
|
+
|
|
1592
|
+
} else {
|
|
1593
|
+
|
|
1594
|
+
card.style.opacity = '0.4';
|
|
1595
|
+
card.style.pointerEvents = 'none';
|
|
1596
|
+
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
} );
|
|
1600
|
+
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
_onParamChange() {
|
|
1604
|
+
|
|
1605
|
+
this._lutNeedsUpdate = true;
|
|
1606
|
+
|
|
1607
|
+
if ( this.sceneGradingEnabled ) {
|
|
1608
|
+
|
|
1609
|
+
this._applyLiveGrading();
|
|
1610
|
+
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
this.save();
|
|
1614
|
+
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
generate3DLUTData( size = this.lutSize, buffer = null ) {
|
|
1618
|
+
|
|
1619
|
+
if ( buffer === null ) {
|
|
1620
|
+
|
|
1621
|
+
buffer = new Float32Array( size * size * size * 4 );
|
|
1622
|
+
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
let idx = 0;
|
|
1626
|
+
const norm = 1.0 / ( size - 1 );
|
|
1627
|
+
const _pixel = [ 0, 0, 0 ];
|
|
1628
|
+
|
|
1629
|
+
const activeModules = [];
|
|
1630
|
+
for ( let i = 0; i < this.pipelineOrder.length; i ++ ) {
|
|
1631
|
+
|
|
1632
|
+
const mod = this.modulesMap.get( this.pipelineOrder[ i ] );
|
|
1633
|
+
if ( mod && mod.enabled ) {
|
|
1634
|
+
|
|
1635
|
+
activeModules.push( mod );
|
|
1636
|
+
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
const numModules = activeModules.length;
|
|
1642
|
+
|
|
1643
|
+
for ( let b = 0; b < size; b ++ ) {
|
|
1644
|
+
|
|
1645
|
+
for ( let g = 0; g < size; g ++ ) {
|
|
1646
|
+
|
|
1647
|
+
for ( let r = 0; r < size; r ++ ) {
|
|
1648
|
+
|
|
1649
|
+
_pixel[ 0 ] = r * norm;
|
|
1650
|
+
_pixel[ 1 ] = g * norm;
|
|
1651
|
+
_pixel[ 2 ] = b * norm;
|
|
1652
|
+
|
|
1653
|
+
for ( let m = 0; m < numModules; m ++ ) {
|
|
1654
|
+
|
|
1655
|
+
activeModules[ m ].applyPixel( _pixel[ 0 ], _pixel[ 1 ], _pixel[ 2 ], _pixel );
|
|
1656
|
+
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
buffer[ idx ++ ] = _pixel[ 0 ];
|
|
1660
|
+
buffer[ idx ++ ] = _pixel[ 1 ];
|
|
1661
|
+
buffer[ idx ++ ] = _pixel[ 2 ];
|
|
1662
|
+
buffer[ idx ++ ] = 1.0;
|
|
1663
|
+
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
return buffer;
|
|
1671
|
+
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
_getExportFileName( defaultBase = 'My Color Grading' ) {
|
|
1675
|
+
|
|
1676
|
+
const outputComp = this.modulesMap.get( 'output' );
|
|
1677
|
+
|
|
1678
|
+
if ( outputComp && outputComp.params && outputComp.params.fileName ) {
|
|
1679
|
+
|
|
1680
|
+
return outputComp.params.fileName;
|
|
1681
|
+
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
return defaultBase;
|
|
1685
|
+
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
_exportCubeFile() {
|
|
1689
|
+
|
|
1690
|
+
const baseName = this._getExportFileName();
|
|
1691
|
+
const buffer = this.generate3DLUTData( this.lutSize );
|
|
1692
|
+
const cubeContent = exportCubeFormat( buffer, this.lutSize, baseName );
|
|
1693
|
+
const blob = new Blob( [ cubeContent ], { type: 'text/plain' } );
|
|
1694
|
+
const url = URL.createObjectURL( blob );
|
|
1695
|
+
|
|
1696
|
+
const a = document.createElement( 'a' );
|
|
1697
|
+
a.href = url;
|
|
1698
|
+
a.download = `${baseName}_${this.lutSize}x${this.lutSize}.cube`;
|
|
1699
|
+
a.click();
|
|
1700
|
+
URL.revokeObjectURL( url );
|
|
1701
|
+
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
_exportPngFile() {
|
|
1705
|
+
|
|
1706
|
+
const baseName = this._getExportFileName();
|
|
1707
|
+
const buffer = this.generate3DLUTData( this.lutSize );
|
|
1708
|
+
const canvas = exportLUTCanvas( buffer, this.lutSize );
|
|
1709
|
+
canvas.toBlob( ( blob ) => {
|
|
1710
|
+
|
|
1711
|
+
const url = URL.createObjectURL( blob );
|
|
1712
|
+
const a = document.createElement( 'a' );
|
|
1713
|
+
a.href = url;
|
|
1714
|
+
a.download = `${baseName}_${this.lutSize}x${this.lutSize}.png`;
|
|
1715
|
+
a.click();
|
|
1716
|
+
URL.revokeObjectURL( url );
|
|
1717
|
+
|
|
1718
|
+
} );
|
|
1719
|
+
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
toJSON() {
|
|
1723
|
+
|
|
1724
|
+
const params = {};
|
|
1725
|
+
const modulesData = {};
|
|
1726
|
+
|
|
1727
|
+
this.modulesMap.forEach( ( comp, id ) => {
|
|
1728
|
+
|
|
1729
|
+
if ( ! comp ) return;
|
|
1730
|
+
|
|
1731
|
+
let modType = 'whiteBalance';
|
|
1732
|
+
let mode = null;
|
|
1733
|
+
|
|
1734
|
+
if ( comp.mode ) {
|
|
1735
|
+
|
|
1736
|
+
modType = 'colorWheel';
|
|
1737
|
+
mode = comp.mode;
|
|
1738
|
+
|
|
1739
|
+
} else if ( id.startsWith( 'importedCube_' ) ) {
|
|
1740
|
+
|
|
1741
|
+
modType = 'importedCube';
|
|
1742
|
+
|
|
1743
|
+
} else if ( id.startsWith( 'whiteBalance' ) ) {
|
|
1744
|
+
|
|
1745
|
+
modType = 'whiteBalance';
|
|
1746
|
+
|
|
1747
|
+
} else if ( id.startsWith( 'exposure' ) ) {
|
|
1748
|
+
|
|
1749
|
+
modType = 'exposure';
|
|
1750
|
+
|
|
1751
|
+
} else if ( id.startsWith( 'brightness' ) ) {
|
|
1752
|
+
|
|
1753
|
+
modType = 'brightness';
|
|
1754
|
+
|
|
1755
|
+
} else if ( id.startsWith( 'hue' ) ) {
|
|
1756
|
+
|
|
1757
|
+
modType = 'hue';
|
|
1758
|
+
|
|
1759
|
+
} else if ( id.startsWith( 'curves' ) ) {
|
|
1760
|
+
|
|
1761
|
+
modType = 'curves';
|
|
1762
|
+
|
|
1763
|
+
} else if ( id.startsWith( 'contrast' ) ) {
|
|
1764
|
+
|
|
1765
|
+
modType = 'contrast';
|
|
1766
|
+
|
|
1767
|
+
} else if ( id.startsWith( 'saturation' ) ) {
|
|
1768
|
+
|
|
1769
|
+
modType = 'saturation';
|
|
1770
|
+
|
|
1771
|
+
} else if ( id.startsWith( 'vibrance' ) ) {
|
|
1772
|
+
|
|
1773
|
+
modType = 'vibrance';
|
|
1774
|
+
|
|
1775
|
+
} else if ( id === 'renderer' ) {
|
|
1776
|
+
|
|
1777
|
+
modType = 'renderer';
|
|
1778
|
+
|
|
1779
|
+
} else if ( id === 'output' ) {
|
|
1780
|
+
|
|
1781
|
+
modType = 'output';
|
|
1782
|
+
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
modulesData[ id ] = {
|
|
1786
|
+
type: modType,
|
|
1787
|
+
mode: mode,
|
|
1788
|
+
params: JSON.parse( JSON.stringify( comp.params ) )
|
|
1789
|
+
};
|
|
1790
|
+
|
|
1791
|
+
if ( id === 'lift' || id === 'gammaBal' || id === 'gain' || id === 'offset' ) {
|
|
1792
|
+
|
|
1793
|
+
params[ id ] = JSON.parse( JSON.stringify( comp.params ) );
|
|
1794
|
+
|
|
1795
|
+
} else if ( id === 'curves' ) {
|
|
1796
|
+
|
|
1797
|
+
params.curves = JSON.parse( JSON.stringify( comp.params.curves ) );
|
|
1798
|
+
|
|
1799
|
+
} else if ( id.startsWith( 'importedCube_' ) ) {
|
|
1800
|
+
|
|
1801
|
+
if ( ! params.importedCubes ) params.importedCubes = {};
|
|
1802
|
+
params.importedCubes[ id ] = JSON.parse( JSON.stringify( comp.params ) );
|
|
1803
|
+
|
|
1804
|
+
} else if ( id !== 'renderer' && ! id.includes( '_' ) ) {
|
|
1805
|
+
|
|
1806
|
+
Object.assign( params, JSON.parse( JSON.stringify( comp.params ) ) );
|
|
1807
|
+
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
} );
|
|
1811
|
+
|
|
1812
|
+
return {
|
|
1813
|
+
version: 2,
|
|
1814
|
+
lutSize: this.lutSize,
|
|
1815
|
+
selectedToneMapping: this.selectedToneMapping,
|
|
1816
|
+
pipelineOrder: [ ...this.pipelineOrder ],
|
|
1817
|
+
modules: modulesData,
|
|
1818
|
+
params: params
|
|
1819
|
+
};
|
|
1820
|
+
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
serialize() {
|
|
1824
|
+
|
|
1825
|
+
return this.toJSON();
|
|
1826
|
+
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
deserialize( data ) {
|
|
1830
|
+
|
|
1831
|
+
if ( data ) {
|
|
1832
|
+
|
|
1833
|
+
this.load( data );
|
|
1834
|
+
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
_applyParamsToModule( modId, params ) {
|
|
1840
|
+
|
|
1841
|
+
const comp = this.modulesMap.get( modId );
|
|
1842
|
+
if ( ! comp ) return;
|
|
1843
|
+
|
|
1844
|
+
switch ( modId ) {
|
|
1845
|
+
|
|
1846
|
+
case 'whiteBalance':
|
|
1847
|
+
comp.fromJSON( { params: { temperature: params.temperature ?? 0, tint: params.tint ?? 0 } } );
|
|
1848
|
+
break;
|
|
1849
|
+
|
|
1850
|
+
case 'exposure':
|
|
1851
|
+
comp.fromJSON( { params: { exposure: params.exposure ?? 0 } } );
|
|
1852
|
+
break;
|
|
1853
|
+
|
|
1854
|
+
case 'brightness':
|
|
1855
|
+
comp.fromJSON( { params: { brightness: params.brightness ?? 0 } } );
|
|
1856
|
+
break;
|
|
1857
|
+
|
|
1858
|
+
case 'hue':
|
|
1859
|
+
comp.fromJSON( { params: { hueShift: params.hueShift ?? 0 } } );
|
|
1860
|
+
break;
|
|
1861
|
+
|
|
1862
|
+
case 'lift':
|
|
1863
|
+
if ( params.lift ) comp.fromJSON( { params: params.lift } );
|
|
1864
|
+
else comp.reset();
|
|
1865
|
+
break;
|
|
1866
|
+
|
|
1867
|
+
case 'gammaBal':
|
|
1868
|
+
if ( params.gammaBal ) comp.fromJSON( { params: params.gammaBal } );
|
|
1869
|
+
else comp.reset();
|
|
1870
|
+
break;
|
|
1871
|
+
|
|
1872
|
+
case 'gain':
|
|
1873
|
+
if ( params.gain ) comp.fromJSON( { params: params.gain } );
|
|
1874
|
+
else comp.reset();
|
|
1875
|
+
break;
|
|
1876
|
+
|
|
1877
|
+
case 'offset':
|
|
1878
|
+
if ( params.offset ) comp.fromJSON( { params: params.offset } );
|
|
1879
|
+
else comp.reset();
|
|
1880
|
+
break;
|
|
1881
|
+
|
|
1882
|
+
case 'curves':
|
|
1883
|
+
if ( params.curves ) comp.fromJSON( { params: { curves: params.curves } } );
|
|
1884
|
+
else comp.reset();
|
|
1885
|
+
break;
|
|
1886
|
+
|
|
1887
|
+
case 'contrast':
|
|
1888
|
+
comp.fromJSON( { params: { contrast: params.contrast ?? 1.0, contrastPivot: params.contrastPivot ?? 0.5 } } );
|
|
1889
|
+
break;
|
|
1890
|
+
|
|
1891
|
+
case 'saturation':
|
|
1892
|
+
comp.fromJSON( { params: { saturation: params.saturation ?? 1.0 } } );
|
|
1893
|
+
break;
|
|
1894
|
+
|
|
1895
|
+
case 'vibrance':
|
|
1896
|
+
comp.fromJSON( { params: { vibrance: params.vibrance ?? 0 } } );
|
|
1897
|
+
break;
|
|
1898
|
+
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
load( data ) {
|
|
1904
|
+
|
|
1905
|
+
if ( ! data ) return;
|
|
1906
|
+
|
|
1907
|
+
let json = data;
|
|
1908
|
+
if ( typeof json === 'string' ) {
|
|
1909
|
+
|
|
1910
|
+
try {
|
|
1911
|
+
|
|
1912
|
+
json = JSON.parse( json );
|
|
1913
|
+
|
|
1914
|
+
} catch ( err ) {
|
|
1915
|
+
|
|
1916
|
+
console.error( 'ColorGrading.load: Invalid JSON data', err );
|
|
1917
|
+
return;
|
|
1918
|
+
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
if ( typeof json !== 'object' || json === null ) return;
|
|
1924
|
+
|
|
1925
|
+
const params = json.params ? json.params : ( json.temperature !== undefined || json.contrast !== undefined || json.curves !== undefined ? json : null );
|
|
1926
|
+
|
|
1927
|
+
if ( typeof json.lutSize === 'number' ) {
|
|
1928
|
+
|
|
1929
|
+
this.lutSize = json.lutSize;
|
|
1930
|
+
if ( this.lutSizeSelect ) {
|
|
1931
|
+
|
|
1932
|
+
this.lutSizeSelect.value = String( this.lutSize );
|
|
1933
|
+
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
if ( typeof json.selectedToneMapping === 'number' ) {
|
|
1939
|
+
|
|
1940
|
+
this.selectedToneMapping = json.selectedToneMapping;
|
|
1941
|
+
const rendererComp = this.modulesMap.get( 'renderer' );
|
|
1942
|
+
if ( rendererComp ) {
|
|
1943
|
+
|
|
1944
|
+
rendererComp.fromJSON( { params: { toneMapping: this.selectedToneMapping } } );
|
|
1945
|
+
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
|
|
1951
|
+
if ( Array.isArray( json.pipelineOrder ) && json.pipelineOrder.length > 0 ) {
|
|
1952
|
+
|
|
1953
|
+
this.pipelineOrder = [ ...json.pipelineOrder ];
|
|
1954
|
+
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
if ( json.modules && typeof json.modules === 'object' ) {
|
|
1958
|
+
|
|
1959
|
+
this.modulesMap.forEach( ( comp, id ) => {
|
|
1960
|
+
|
|
1961
|
+
if ( id !== 'renderer' && id !== 'output' && ! this.pipelineOrder.includes( id ) ) {
|
|
1962
|
+
|
|
1963
|
+
if ( comp.domElement ) comp.domElement.remove();
|
|
1964
|
+
this.modulesMap.delete( id );
|
|
1965
|
+
this.cardsMap.delete( id );
|
|
1966
|
+
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
} );
|
|
1970
|
+
|
|
1971
|
+
Object.keys( json.modules ).forEach( id => {
|
|
1972
|
+
|
|
1973
|
+
const mData = json.modules[ id ];
|
|
1974
|
+
if ( id === 'renderer' ) {
|
|
1975
|
+
|
|
1976
|
+
const rendererComp = this.modulesMap.get( 'renderer' );
|
|
1977
|
+
if ( rendererComp ) {
|
|
1978
|
+
|
|
1979
|
+
rendererComp.fromJSON( { params: mData.params } );
|
|
1980
|
+
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
} else if ( this.modulesMap.has( id ) ) {
|
|
1984
|
+
|
|
1985
|
+
this.modulesMap.get( id ).fromJSON( { params: mData.params } );
|
|
1986
|
+
|
|
1987
|
+
} else {
|
|
1988
|
+
|
|
1989
|
+
if ( mData.type === 'importedCube' ) {
|
|
1990
|
+
|
|
1991
|
+
const comp = new ImportedCubeModule(
|
|
1992
|
+
id,
|
|
1993
|
+
mData.params,
|
|
1994
|
+
() => this._onParamChange(),
|
|
1995
|
+
( removeId ) => this._removeCard( removeId )
|
|
1996
|
+
);
|
|
1997
|
+
|
|
1998
|
+
this.modulesMap.set( id, comp );
|
|
1999
|
+
this.cardsMap.set( id, comp.domElement );
|
|
2000
|
+
this._setupCardDragAndDrop( comp.domElement, id );
|
|
2001
|
+
|
|
2002
|
+
} else {
|
|
2003
|
+
|
|
2004
|
+
const targetType = mData.mode || mData.type;
|
|
2005
|
+
this._addCardAt( targetType, this.pipelineOrder.length, mData.params, id );
|
|
2006
|
+
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
} );
|
|
2012
|
+
|
|
2013
|
+
} else if ( params ) {
|
|
2014
|
+
|
|
2015
|
+
const isWBActive = ( params.temperature !== undefined && params.temperature !== 0 ) || ( params.tint !== undefined && params.tint !== 0 );
|
|
2016
|
+
const isExpActive = params.exposure !== undefined && params.exposure !== 0;
|
|
2017
|
+
const isBrightActive = params.brightness !== undefined && params.brightness !== 0;
|
|
2018
|
+
const isHueActive = params.hueShift !== undefined && params.hueShift !== 0;
|
|
2019
|
+
const isLiftActive = params.lift && ( params.lift.r !== 0 || params.lift.g !== 0 || params.lift.b !== 0 );
|
|
2020
|
+
const isGammaActive = params.gammaBal && ( params.gammaBal.r !== 0 || params.gammaBal.g !== 0 || params.gammaBal.b !== 0 );
|
|
2021
|
+
const isGainActive = params.gain && ( params.gain.r !== 0 || params.gain.g !== 0 || params.gain.b !== 0 );
|
|
2022
|
+
const isOffsetActive = params.offset && ( params.offset.r !== 0 || params.offset.g !== 0 || params.offset.b !== 0 );
|
|
2023
|
+
const isCurvesActive = params.curves && Array.isArray( params.curves.rgb ) && ( params.curves.rgb.length > 2 || params.curves.rgb.some( p => p.x !== p.y ) || ( params.curves.red && params.curves.red.some( p => p.x !== p.y ) ) || ( params.curves.blue && params.curves.blue.some( p => p.x !== p.y ) ) );
|
|
2024
|
+
const isContrastActive = params.contrast !== undefined && params.contrast !== 1.0;
|
|
2025
|
+
const isSatActive = params.saturation !== undefined && params.saturation !== 1.0;
|
|
2026
|
+
const isVibActive = params.vibrance !== undefined && params.vibrance !== 0;
|
|
2027
|
+
|
|
2028
|
+
const isAllNeutral = ! isWBActive && ! isExpActive && ! isBrightActive && ! isHueActive && ! isLiftActive && ! isGammaActive && ! isGainActive && ! isOffsetActive && ! isCurvesActive && ! isContrastActive && ! isSatActive && ! isVibActive;
|
|
2029
|
+
|
|
2030
|
+
let targetOrder = [];
|
|
2031
|
+
|
|
2032
|
+
if ( isAllNeutral ) {
|
|
2033
|
+
|
|
2034
|
+
targetOrder = [ ...DEFAULT_PIPELINE_ORDER ];
|
|
2035
|
+
|
|
2036
|
+
} else {
|
|
2037
|
+
|
|
2038
|
+
targetOrder = [ 'renderer' ];
|
|
2039
|
+
if ( isWBActive ) targetOrder.push( 'whiteBalance' );
|
|
2040
|
+
if ( isExpActive ) targetOrder.push( 'exposure' );
|
|
2041
|
+
if ( isBrightActive ) targetOrder.push( 'brightness' );
|
|
2042
|
+
if ( isHueActive ) targetOrder.push( 'hue' );
|
|
2043
|
+
if ( isLiftActive ) targetOrder.push( 'lift' );
|
|
2044
|
+
if ( isGammaActive ) targetOrder.push( 'gammaBal' );
|
|
2045
|
+
if ( isGainActive ) targetOrder.push( 'gain' );
|
|
2046
|
+
if ( isOffsetActive ) targetOrder.push( 'offset' );
|
|
2047
|
+
if ( isCurvesActive ) targetOrder.push( 'curves' );
|
|
2048
|
+
if ( isContrastActive ) targetOrder.push( 'contrast' );
|
|
2049
|
+
if ( isSatActive ) targetOrder.push( 'saturation' );
|
|
2050
|
+
if ( isVibActive ) targetOrder.push( 'vibrance' );
|
|
2051
|
+
targetOrder.push( 'output' );
|
|
2052
|
+
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
// Remove cards not used by this preset (except renderer)
|
|
2056
|
+
this.modulesMap.forEach( ( comp, id ) => {
|
|
2057
|
+
|
|
2058
|
+
if ( id !== 'renderer' && id !== 'output' && ! targetOrder.includes( id ) ) {
|
|
2059
|
+
|
|
2060
|
+
if ( comp && comp.domElement ) comp.domElement.remove();
|
|
2061
|
+
this.modulesMap.delete( id );
|
|
2062
|
+
this.cardsMap.delete( id );
|
|
2063
|
+
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
} );
|
|
2067
|
+
|
|
2068
|
+
// Ensure target cards exist and update their values
|
|
2069
|
+
targetOrder.forEach( ( modId ) => {
|
|
2070
|
+
|
|
2071
|
+
if ( modId === 'renderer' ) {
|
|
2072
|
+
|
|
2073
|
+
const rendererComp = this.modulesMap.get( 'renderer' );
|
|
2074
|
+
if ( rendererComp && ( params.rendererToneMapping !== undefined || params.rendererExposure !== undefined ) ) {
|
|
2075
|
+
|
|
2076
|
+
const toneMapping = params.rendererToneMapping !== undefined ? params.rendererToneMapping : rendererComp.params.toneMapping;
|
|
2077
|
+
const exposure = params.rendererExposure !== undefined ? params.rendererExposure : rendererComp.params.exposure;
|
|
2078
|
+
rendererComp.fromJSON( { params: { toneMapping, exposure } } );
|
|
2079
|
+
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
} else if ( this.modulesMap.has( modId ) ) {
|
|
2083
|
+
|
|
2084
|
+
this._applyParamsToModule( modId, params );
|
|
2085
|
+
|
|
2086
|
+
} else {
|
|
2087
|
+
|
|
2088
|
+
this._addCardAt( modId, targetOrder.length, params, modId );
|
|
2089
|
+
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
} );
|
|
2093
|
+
|
|
2094
|
+
this.pipelineOrder = targetOrder;
|
|
2095
|
+
|
|
2096
|
+
if ( params.importedCubes ) {
|
|
2097
|
+
|
|
2098
|
+
Object.keys( params.importedCubes ).forEach( modId => {
|
|
2099
|
+
|
|
2100
|
+
const cubeData = params.importedCubes[ modId ];
|
|
2101
|
+
const comp = this.modulesMap.get( modId );
|
|
2102
|
+
|
|
2103
|
+
if ( ! comp ) {
|
|
2104
|
+
|
|
2105
|
+
const newComp = new ImportedCubeModule(
|
|
2106
|
+
modId,
|
|
2107
|
+
cubeData,
|
|
2108
|
+
() => this._onParamChange(),
|
|
2109
|
+
( removeId ) => this._removeCard( removeId )
|
|
2110
|
+
);
|
|
2111
|
+
|
|
2112
|
+
this.modulesMap.set( modId, newComp );
|
|
2113
|
+
this.cardsMap.set( modId, newComp.domElement );
|
|
2114
|
+
this._setupCardDragAndDrop( newComp.domElement, modId );
|
|
2115
|
+
|
|
2116
|
+
} else {
|
|
2117
|
+
|
|
2118
|
+
comp.fromJSON( { params: cubeData } );
|
|
2119
|
+
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
} );
|
|
2123
|
+
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
this._renderCardsFlow();
|
|
2129
|
+
this._onParamChange();
|
|
2130
|
+
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
_exportJsonFile() {
|
|
2134
|
+
|
|
2135
|
+
const baseName = this._getExportFileName();
|
|
2136
|
+
const configStr = JSON.stringify( this.toJSON(), null, 2 );
|
|
2137
|
+
const blob = new Blob( [ configStr ], { type: 'application/json' } );
|
|
2138
|
+
const url = URL.createObjectURL( blob );
|
|
2139
|
+
const link = document.createElement( 'a' );
|
|
2140
|
+
link.href = url;
|
|
2141
|
+
link.download = `${baseName}.json`;
|
|
2142
|
+
link.click();
|
|
2143
|
+
URL.revokeObjectURL( url );
|
|
2144
|
+
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
_importJsonFile() {
|
|
2148
|
+
|
|
2149
|
+
const fileInput = document.createElement( 'input' );
|
|
2150
|
+
fileInput.type = 'file';
|
|
2151
|
+
fileInput.accept = '.json';
|
|
2152
|
+
|
|
2153
|
+
fileInput.onchange = ( e ) => {
|
|
2154
|
+
|
|
2155
|
+
const file = e.target.files[ 0 ];
|
|
2156
|
+
if ( ! file ) return;
|
|
2157
|
+
|
|
2158
|
+
const reader = new FileReader();
|
|
2159
|
+
reader.onload = ( evt ) => {
|
|
2160
|
+
|
|
2161
|
+
try {
|
|
2162
|
+
|
|
2163
|
+
const json = JSON.parse( evt.target.result );
|
|
2164
|
+
this.load( json );
|
|
2165
|
+
|
|
2166
|
+
} catch ( err ) {
|
|
2167
|
+
|
|
2168
|
+
alert( 'Error reading JSON config file: ' + err.message );
|
|
2169
|
+
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
};
|
|
2173
|
+
|
|
2174
|
+
reader.readAsText( file );
|
|
2175
|
+
|
|
2176
|
+
};
|
|
2177
|
+
|
|
2178
|
+
fileInput.click();
|
|
2179
|
+
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
_createImportedCubeCard( modId ) {
|
|
2183
|
+
|
|
2184
|
+
const cubeInfo = this.params.importedCubes ? this.params.importedCubes[ modId ] : null;
|
|
2185
|
+
const comp = new ImportedCubeModule(
|
|
2186
|
+
modId,
|
|
2187
|
+
cubeInfo || {},
|
|
2188
|
+
() => this._onParamChange(),
|
|
2189
|
+
( removeId ) => this._removeCard( removeId )
|
|
2190
|
+
);
|
|
2191
|
+
|
|
2192
|
+
this.modulesMap.set( modId, comp );
|
|
2193
|
+
this.cardsMap.set( modId, comp.domElement );
|
|
2194
|
+
|
|
2195
|
+
return comp.domElement;
|
|
2196
|
+
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
_removeImportedCubeCard( modId ) {
|
|
2200
|
+
|
|
2201
|
+
this._removeCard( modId );
|
|
2202
|
+
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
_importCubeFileAt( insertIndex ) {
|
|
2206
|
+
|
|
2207
|
+
const fileInput = document.createElement( 'input' );
|
|
2208
|
+
fileInput.type = 'file';
|
|
2209
|
+
fileInput.accept = '.cube';
|
|
2210
|
+
|
|
2211
|
+
fileInput.onchange = ( e ) => {
|
|
2212
|
+
|
|
2213
|
+
const file = e.target.files[ 0 ];
|
|
2214
|
+
if ( ! file ) return;
|
|
2215
|
+
|
|
2216
|
+
const reader = new FileReader();
|
|
2217
|
+
reader.onload = ( evt ) => {
|
|
2218
|
+
|
|
2219
|
+
try {
|
|
2220
|
+
|
|
2221
|
+
const text = evt.target.result;
|
|
2222
|
+
const parsed = parseCubeFormat( text );
|
|
2223
|
+
const cubeData = parsed.dataLines || parsed.data;
|
|
2224
|
+
if ( ! cubeData || cubeData.length === 0 ) {
|
|
2225
|
+
|
|
2226
|
+
alert( 'Invalid or empty .CUBE file.' );
|
|
2227
|
+
return;
|
|
2228
|
+
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
const modId = 'importedCube_' + Date.now() + '_' + Math.floor( Math.random() * 1000 );
|
|
2232
|
+
|
|
2233
|
+
const fileNameNoExt = file.name.replace( /\.cube$/i, '' );
|
|
2234
|
+
const parsedTitle = parsed.title ? parsed.title.trim() : '';
|
|
2235
|
+
const isGenericTitle = ! parsedTitle ||
|
|
2236
|
+
parsedTitle.toLowerCase() === 'untitled' ||
|
|
2237
|
+
parsedTitle.toLowerCase() === 'imported lut';
|
|
2238
|
+
|
|
2239
|
+
const titleName = isGenericTitle ? fileNameNoExt : parsedTitle;
|
|
2240
|
+
|
|
2241
|
+
const cubeInfo = {
|
|
2242
|
+
title: titleName,
|
|
2243
|
+
size: parsed.size || 32,
|
|
2244
|
+
dataLines: cubeData,
|
|
2245
|
+
weight: 1.0
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2248
|
+
const comp = new ImportedCubeModule(
|
|
2249
|
+
modId,
|
|
2250
|
+
cubeInfo,
|
|
2251
|
+
() => this._onParamChange(),
|
|
2252
|
+
( removeId ) => this._removeCard( removeId )
|
|
2253
|
+
);
|
|
2254
|
+
|
|
2255
|
+
this.modulesMap.set( modId, comp );
|
|
2256
|
+
this.cardsMap.set( modId, comp.domElement );
|
|
2257
|
+
|
|
2258
|
+
const targetIdx = ( typeof insertIndex === 'number' ) ? Math.max( 0, Math.min( this.pipelineOrder.length, insertIndex ) ) : this.pipelineOrder.length;
|
|
2259
|
+
this.pipelineOrder.splice( targetIdx, 0, modId );
|
|
2260
|
+
|
|
2261
|
+
this._setupCardDragAndDrop( comp.domElement, modId );
|
|
2262
|
+
|
|
2263
|
+
this._renderCardsFlow();
|
|
2264
|
+
this._onParamChange();
|
|
2265
|
+
|
|
2266
|
+
if ( comp.domElement ) {
|
|
2267
|
+
|
|
2268
|
+
setTimeout( () => {
|
|
2269
|
+
|
|
2270
|
+
comp.domElement.scrollIntoView( { behavior: 'smooth', block: 'nearest', inline: 'center' } );
|
|
2271
|
+
|
|
2272
|
+
}, 50 );
|
|
2273
|
+
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
} catch ( err ) {
|
|
2277
|
+
|
|
2278
|
+
alert( 'Error reading .CUBE file: ' + err.message );
|
|
2279
|
+
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
};
|
|
2283
|
+
|
|
2284
|
+
reader.readAsText( file );
|
|
2285
|
+
|
|
2286
|
+
};
|
|
2287
|
+
|
|
2288
|
+
fileInput.click();
|
|
2289
|
+
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
_importCubeFile() {
|
|
2293
|
+
|
|
2294
|
+
this._importCubeFileAt( 1 );
|
|
2295
|
+
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
init( inspector ) {
|
|
2299
|
+
|
|
2300
|
+
super.init( inspector );
|
|
2301
|
+
|
|
2302
|
+
LUT3DStyle.init( inspector.nonce );
|
|
2303
|
+
|
|
2304
|
+
const renderer = inspector.getRenderer();
|
|
2305
|
+
const rendererComp = this.modulesMap.get( 'renderer' );
|
|
2306
|
+
|
|
2307
|
+
if ( renderer && rendererComp ) {
|
|
2308
|
+
|
|
2309
|
+
const defaultTM = ( renderer.toneMapping !== undefined ) ? renderer.toneMapping : NoToneMapping;
|
|
2310
|
+
const defaultExp = ( renderer.toneMappingExposure !== undefined ) ? renderer.toneMappingExposure : 1.0;
|
|
2311
|
+
|
|
2312
|
+
rendererComp.defaultToneMapping = defaultTM;
|
|
2313
|
+
rendererComp.defaultExposure = defaultExp;
|
|
2314
|
+
rendererComp.params.toneMapping = defaultTM;
|
|
2315
|
+
rendererComp.params.exposure = defaultExp;
|
|
2316
|
+
rendererComp.updateUI();
|
|
2317
|
+
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
this.onOrientationChange();
|
|
2321
|
+
this.onLayoutChange();
|
|
2322
|
+
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
setActive( isActive ) {
|
|
2326
|
+
|
|
2327
|
+
super.setActive( isActive );
|
|
2328
|
+
|
|
2329
|
+
if ( isActive ) {
|
|
2330
|
+
|
|
2331
|
+
this.onOrientationChange();
|
|
2332
|
+
this.onLayoutChange();
|
|
2333
|
+
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
onOrientationChange( event ) {
|
|
2339
|
+
|
|
2340
|
+
const isVert = this.inspector.isVertical() ||
|
|
2341
|
+
( event && event.isVertical ) ||
|
|
2342
|
+
( this.content.clientWidth < 550 );
|
|
2343
|
+
|
|
2344
|
+
this.viewContainer.classList.toggle( 'is-vertical', isVert );
|
|
2345
|
+
this.cardsRow.classList.toggle( 'is-vertical', isVert );
|
|
2346
|
+
|
|
2347
|
+
this.onLayoutChange();
|
|
2348
|
+
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
onLayoutChange() {
|
|
2352
|
+
|
|
2353
|
+
const width = this.content.clientWidth;
|
|
2354
|
+
this.dockContainer.classList.toggle( 'is-compact', width > 0 && width < 400 );
|
|
2355
|
+
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
update( inspector ) {
|
|
2359
|
+
|
|
2360
|
+
super.update( inspector );
|
|
2361
|
+
|
|
2362
|
+
if ( this.sceneGradingEnabled && ( this._lutNeedsUpdate || this._lutSizeChanged ) ) {
|
|
2363
|
+
|
|
2364
|
+
this._updateLiveGrading( inspector );
|
|
2365
|
+
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
_getRenderPipeline( renderer ) {
|
|
2371
|
+
|
|
2372
|
+
return _rendererPipelines.get( renderer );
|
|
2373
|
+
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
_toggleSceneGrading( enable ) {
|
|
2377
|
+
|
|
2378
|
+
this.sceneGradingEnabled = enable;
|
|
2379
|
+
|
|
2380
|
+
if ( enable ) {
|
|
2381
|
+
|
|
2382
|
+
this._lutNeedsUpdate = true;
|
|
2383
|
+
|
|
2384
|
+
this._applyLiveGrading();
|
|
2385
|
+
|
|
2386
|
+
} else {
|
|
2387
|
+
|
|
2388
|
+
this._removeLiveGrading();
|
|
2389
|
+
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
_updateLiveGrading( /* inspector */ ) {
|
|
2395
|
+
|
|
2396
|
+
if ( this.sceneGradingEnabled ) {
|
|
2397
|
+
|
|
2398
|
+
this._applyLiveGrading();
|
|
2399
|
+
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
_applyLiveGrading() {
|
|
2405
|
+
|
|
2406
|
+
if ( ! this.lutTexture || this._lutSizeChanged || this._lutNeedsUpdate ) {
|
|
2407
|
+
|
|
2408
|
+
const buffer = ( this.lutTexture && this.lutTexture.image && ! this._lutSizeChanged ) ? this.lutTexture.image.data : null;
|
|
2409
|
+
const data = this.generate3DLUTData( this.lutSize, buffer );
|
|
2410
|
+
|
|
2411
|
+
if ( ! this.lutTexture || this._lutSizeChanged ) {
|
|
2412
|
+
|
|
2413
|
+
if ( this.lutTexture ) this.lutTexture.dispose();
|
|
2414
|
+
|
|
2415
|
+
this.lutTexture = new Data3DTexture( data, this.lutSize, this.lutSize, this.lutSize );
|
|
2416
|
+
this.lutTexture.format = RGBAFormat;
|
|
2417
|
+
this.lutTexture.type = FloatType;
|
|
2418
|
+
this.lutTexture.minFilter = LinearFilter;
|
|
2419
|
+
this.lutTexture.magFilter = LinearFilter;
|
|
2420
|
+
this.lutTexture.unpackAlignment = 1;
|
|
2421
|
+
this._lutSizeChanged = false;
|
|
2422
|
+
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
this.lutTexture.needsUpdate = true;
|
|
2426
|
+
this._lutNeedsUpdate = false;
|
|
2427
|
+
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
const renderer = this.inspector.getRenderer();
|
|
2431
|
+
let renderPipeline = _rendererPipelines.get( renderer );
|
|
2432
|
+
|
|
2433
|
+
const primaryPass = this.inspector.getPrimaryPass();
|
|
2434
|
+
const scene = primaryPass ? primaryPass.scene : null;
|
|
2435
|
+
const camera = primaryPass ? primaryPass.camera : null;
|
|
2436
|
+
|
|
2437
|
+
if ( ! renderPipeline && scene && camera ) {
|
|
2438
|
+
|
|
2439
|
+
this._createdPipeline = new RenderPipeline( renderer, pass( scene, camera ) );
|
|
2440
|
+
renderPipeline = this._createdPipeline;
|
|
2441
|
+
_rendererPipelines.set( renderer, renderPipeline );
|
|
2442
|
+
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
if ( ! renderPipeline ) return;
|
|
2446
|
+
|
|
2447
|
+
if ( this._createdPipeline && ! this._origRendererRender ) {
|
|
2448
|
+
|
|
2449
|
+
this._origRendererRender = renderer.render;
|
|
2450
|
+
let isRendering = false;
|
|
2451
|
+
|
|
2452
|
+
renderer.render = ( sceneArg, cameraArg, ...rest ) => {
|
|
2453
|
+
|
|
2454
|
+
if ( this.sceneGradingEnabled && ! isRendering ) {
|
|
2455
|
+
|
|
2456
|
+
const activePipeline = _rendererPipelines.get( renderer );
|
|
2457
|
+
|
|
2458
|
+
if ( activePipeline ) {
|
|
2459
|
+
|
|
2460
|
+
isRendering = true;
|
|
2461
|
+
|
|
2462
|
+
try {
|
|
2463
|
+
|
|
2464
|
+
activePipeline.render();
|
|
2465
|
+
return;
|
|
2466
|
+
|
|
2467
|
+
} finally {
|
|
2468
|
+
|
|
2469
|
+
isRendering = false;
|
|
2470
|
+
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
return this._origRendererRender.call( renderer, sceneArg, cameraArg, ...rest );
|
|
2478
|
+
|
|
2479
|
+
};
|
|
2480
|
+
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2483
|
+
if ( ! this._originalPipelineSettings ) {
|
|
2484
|
+
|
|
2485
|
+
this._originalPipelineSettings = {
|
|
2486
|
+
outputNode: renderPipeline.outputNode,
|
|
2487
|
+
outputColorTransform: renderPipeline.outputColorTransform,
|
|
2488
|
+
rendererToneMapping: renderer.toneMapping
|
|
2489
|
+
};
|
|
2490
|
+
|
|
2491
|
+
if ( renderer.toneMapping !== undefined ) {
|
|
2492
|
+
|
|
2493
|
+
this.selectedToneMapping = renderer.toneMapping;
|
|
2494
|
+
const rendererComp = this.modulesMap.get( 'renderer' );
|
|
2495
|
+
if ( rendererComp ) {
|
|
2496
|
+
|
|
2497
|
+
rendererComp.fromJSON( { params: { toneMapping: this.selectedToneMapping } } );
|
|
2498
|
+
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
renderer.toneMapping = this.selectedToneMapping;
|
|
2506
|
+
renderPipeline.outputColorTransform = false;
|
|
2507
|
+
|
|
2508
|
+
let inputNode = this._originalPipelineSettings.outputNode;
|
|
2509
|
+
|
|
2510
|
+
if ( ! inputNode && scene && camera ) {
|
|
2511
|
+
|
|
2512
|
+
inputNode = pass( scene, camera );
|
|
2513
|
+
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
if ( inputNode ) {
|
|
2517
|
+
|
|
2518
|
+
const outputPass = renderOutput( inputNode, this.selectedToneMapping );
|
|
2519
|
+
this.lutPassNode = lut3D( outputPass, texture3D( this.lutTexture ), this.lutSize, 1.0 );
|
|
2520
|
+
|
|
2521
|
+
renderPipeline.outputNode = this.lutPassNode;
|
|
2522
|
+
renderPipeline.needsUpdate = true;
|
|
2523
|
+
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
_removeLiveGrading() {
|
|
2529
|
+
|
|
2530
|
+
const renderer = this.inspector.getRenderer();
|
|
2531
|
+
const renderPipeline = _rendererPipelines.get( renderer );
|
|
2532
|
+
|
|
2533
|
+
if ( this._originalPipelineSettings ) {
|
|
2534
|
+
|
|
2535
|
+
if ( renderPipeline ) {
|
|
2536
|
+
|
|
2537
|
+
renderPipeline.outputNode = this._originalPipelineSettings.outputNode;
|
|
2538
|
+
renderPipeline.outputColorTransform = this._originalPipelineSettings.outputColorTransform;
|
|
2539
|
+
renderPipeline.needsUpdate = true;
|
|
2540
|
+
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
if ( renderer && this._originalPipelineSettings.rendererToneMapping !== undefined ) {
|
|
2544
|
+
|
|
2545
|
+
renderer.toneMapping = this._originalPipelineSettings.rendererToneMapping;
|
|
2546
|
+
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
this._originalPipelineSettings = null;
|
|
2550
|
+
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
if ( renderer && this._origRendererRender ) {
|
|
2554
|
+
|
|
2555
|
+
renderer.render = this._origRendererRender;
|
|
2556
|
+
this._origRendererRender = null;
|
|
2557
|
+
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
if ( this._createdPipeline ) {
|
|
2561
|
+
|
|
2562
|
+
if ( renderer ) {
|
|
2563
|
+
|
|
2564
|
+
_rendererPipelines.delete( renderer );
|
|
2565
|
+
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
this._createdPipeline.dispose();
|
|
2569
|
+
this._createdPipeline = null;
|
|
2570
|
+
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
this.lutPassNode = null;
|
|
2574
|
+
|
|
2575
|
+
if ( this.lutTexture ) {
|
|
2576
|
+
|
|
2577
|
+
this.lutTexture.dispose();
|
|
2578
|
+
this.lutTexture = null;
|
|
2579
|
+
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
dispose() {
|
|
2585
|
+
|
|
2586
|
+
this._removeLiveGrading();
|
|
2587
|
+
|
|
2588
|
+
if ( this._cardsResizeObserver ) {
|
|
2589
|
+
|
|
2590
|
+
this._cardsResizeObserver.disconnect();
|
|
2591
|
+
this._cardsResizeObserver = null;
|
|
2592
|
+
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
if ( this._windowResizeHandler ) {
|
|
2596
|
+
|
|
2597
|
+
window.removeEventListener( 'resize', this._windowResizeHandler );
|
|
2598
|
+
this._windowResizeHandler = null;
|
|
2599
|
+
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
this.modulesMap.clear();
|
|
2603
|
+
this.cardsMap.clear();
|
|
2604
|
+
|
|
2605
|
+
super.dispose();
|
|
2606
|
+
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
}
|