@needle-tools/three 0.146.9 → 0.153.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/build/three.cjs +39486 -20286
- package/build/three.js +39471 -20270
- package/build/three.min.js +3 -2
- package/build/three.module.js +6717 -5427
- package/build/three.module.min.js +6 -0
- package/examples/jsm/animation/AnimationClipCreator.js +5 -3
- package/examples/jsm/cameras/CinematicCamera.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +17 -5
- package/examples/jsm/controls/ArcballControls.js +1828 -1821
- package/examples/jsm/controls/MapControls.js +28 -0
- package/examples/jsm/controls/OrbitControls.js +25 -46
- package/examples/jsm/controls/PointerLockControls.js +70 -65
- package/examples/jsm/controls/TrackballControls.js +18 -4
- package/examples/jsm/controls/TransformControls.js +0 -1
- package/examples/jsm/csm/CSM.js +11 -5
- package/examples/jsm/csm/CSMShader.js +7 -6
- package/examples/jsm/effects/AnaglyphEffect.js +6 -20
- package/examples/jsm/effects/AsciiEffect.js +3 -6
- package/examples/jsm/effects/OutlineEffect.js +1 -15
- package/examples/jsm/effects/ParallaxBarrierEffect.js +3 -0
- package/examples/jsm/exporters/DRACOExporter.js +53 -11
- package/examples/jsm/exporters/EXRExporter.js +3 -9
- package/examples/jsm/exporters/GLTFExporter.js +561 -154
- package/examples/jsm/exporters/KTX2Exporter.js +34 -23
- package/examples/jsm/exporters/MMDExporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +8 -1
- package/examples/jsm/exporters/STLExporter.js +8 -4
- package/examples/jsm/exporters/USDZExporter.js +305 -792
- package/examples/jsm/geometries/ConvexGeometry.js +0 -6
- package/examples/jsm/geometries/ParametricGeometry.js +10 -0
- package/examples/jsm/helpers/OctreeHelper.js +1 -0
- package/examples/jsm/helpers/ViewHelper.js +71 -57
- package/examples/jsm/interactive/HTMLMesh.js +16 -3
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/{js → jsm}/libs/basis/README.md +4 -4
- package/examples/jsm/libs/draco/draco_decoder.js +34 -0
- package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/examples/jsm/libs/lil-gui.module.min.js +2 -2
- package/examples/jsm/libs/tween.module.js +803 -0
- package/examples/jsm/lights/IESSpotLight.js +25 -0
- package/examples/jsm/lights/LightProbeGenerator.js +11 -9
- package/examples/jsm/lines/LineSegments2.js +16 -10
- package/examples/jsm/loaders/3DMLoader.js +8 -5
- package/examples/jsm/loaders/3MFLoader.js +12 -11
- package/examples/jsm/loaders/AMFLoader.js +2 -3
- package/examples/jsm/loaders/BVHLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +15 -16
- package/examples/jsm/loaders/DRACOLoader.js +69 -18
- package/examples/jsm/loaders/EXRLoader.js +23 -24
- package/examples/jsm/loaders/FBXLoader.js +34 -50
- package/examples/jsm/loaders/GCodeLoader.js +1 -2
- package/examples/jsm/loaders/GLTFLoader.js +417 -895
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +684 -0
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +4 -4
- package/examples/jsm/loaders/IESLoader.js +337 -0
- package/examples/jsm/loaders/KMZLoader.js +4 -4
- package/examples/jsm/loaders/KTX2Loader.js +145 -69
- package/examples/jsm/loaders/LDrawLoader.js +20 -18
- package/examples/jsm/loaders/LWOLoader.js +12 -29
- package/examples/jsm/loaders/LottieLoader.js +3 -1
- package/examples/jsm/loaders/MMDLoader.js +49 -18
- package/examples/jsm/loaders/MTLLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +9 -3
- package/examples/jsm/loaders/NRRDLoader.js +33 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PCDLoader.js +26 -12
- package/examples/jsm/loaders/PDBLoader.js +7 -2
- package/examples/jsm/loaders/PLYLoader.js +254 -109
- package/examples/jsm/loaders/RGBELoader.js +3 -3
- package/examples/jsm/loaders/STLLoader.js +9 -5
- package/examples/jsm/loaders/SVGLoader.js +36 -27
- package/examples/jsm/loaders/TTFLoader.js +1 -8
- package/examples/jsm/loaders/TiltLoader.js +13 -7
- package/examples/jsm/loaders/USDZLoader.js +6 -6
- package/examples/jsm/loaders/VOXLoader.js +8 -2
- package/examples/jsm/loaders/VRMLLoader.js +44 -16
- package/examples/jsm/loaders/VTKLoader.js +19 -10
- package/examples/jsm/loaders/XYZLoader.js +9 -3
- package/examples/jsm/loaders/lwo/IFFParser.js +19 -19
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -3
- package/examples/jsm/math/ConvexHull.js +3 -3
- package/examples/jsm/math/Lut.js +5 -4
- package/examples/jsm/math/MeshSurfaceSampler.js +7 -9
- package/examples/jsm/math/Octree.js +1 -1
- package/examples/jsm/misc/ConvexObjectBreaker.js +2 -8
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -5
- package/examples/jsm/misc/MD2Character.js +2 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +2 -2
- package/examples/jsm/misc/ProgressiveLightMap.js +12 -10
- package/examples/jsm/misc/RollerCoaster.js +7 -1
- package/examples/jsm/misc/Volume.js +20 -5
- package/examples/jsm/misc/VolumeSlice.js +3 -1
- package/examples/jsm/modifiers/CurveModifier.js +1 -0
- package/examples/jsm/modifiers/TessellateModifier.js +19 -19
- package/examples/jsm/nodes/Nodes.js +144 -335
- package/examples/jsm/nodes/accessors/BitangentNode.js +43 -16
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +86 -0
- package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +12 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +27 -33
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +58 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +41 -26
- package/examples/jsm/nodes/accessors/MaterialNode.js +155 -38
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +16 -0
- package/examples/jsm/nodes/accessors/ModelNode.js +11 -0
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +13 -14
- package/examples/jsm/nodes/accessors/NormalNode.js +35 -19
- package/examples/jsm/nodes/accessors/Object3DNode.js +32 -12
- package/examples/jsm/nodes/accessors/PointUVNode.js +6 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +38 -23
- package/examples/jsm/nodes/accessors/ReferenceNode.js +21 -14
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +11 -7
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -40
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +28 -20
- package/examples/jsm/nodes/accessors/TextureNode.js +80 -12
- package/examples/jsm/nodes/accessors/UVNode.js +6 -0
- package/examples/jsm/nodes/accessors/UserDataNode.js +6 -0
- package/examples/jsm/nodes/code/CodeNode.js +75 -0
- package/examples/jsm/nodes/code/ExpressionNode.js +37 -0
- package/examples/jsm/nodes/{core → code}/FunctionCallNode.js +15 -1
- package/examples/jsm/nodes/{core → code}/FunctionNode.js +8 -7
- package/examples/jsm/nodes/code/ScriptableNode.js +488 -0
- package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -0
- package/examples/jsm/nodes/core/ArrayUniformNode.js +3 -0
- package/examples/jsm/nodes/core/AttributeNode.js +17 -9
- package/examples/jsm/nodes/core/BypassNode.js +9 -2
- package/examples/jsm/nodes/core/CacheNode.js +46 -0
- package/examples/jsm/nodes/core/ConstNode.js +3 -0
- package/examples/jsm/nodes/core/ContextNode.js +8 -1
- package/examples/jsm/nodes/core/InputNode.js +26 -5
- package/examples/jsm/nodes/core/InstanceIndexNode.js +26 -2
- package/examples/jsm/nodes/core/LightingModel.js +16 -0
- package/examples/jsm/nodes/core/Node.js +129 -35
- package/examples/jsm/nodes/core/NodeAttribute.js +2 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +271 -121
- package/examples/jsm/nodes/core/NodeCache.js +26 -0
- package/examples/jsm/nodes/core/NodeFrame.js +56 -5
- package/examples/jsm/nodes/core/NodeUtils.js +115 -28
- package/examples/jsm/nodes/core/PropertyNode.js +19 -2
- package/examples/jsm/nodes/core/StackNode.js +99 -0
- package/examples/jsm/nodes/core/TempNode.js +11 -3
- package/examples/jsm/nodes/core/UniformNode.js +16 -1
- package/examples/jsm/nodes/core/VarNode.js +21 -29
- package/examples/jsm/nodes/core/VaryingNode.js +15 -2
- package/examples/jsm/nodes/core/constants.js +6 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +25 -11
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +30 -14
- package/examples/jsm/nodes/display/ColorSpaceNode.js +39 -27
- package/examples/jsm/nodes/display/FrontFacingNode.js +7 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +31 -18
- package/examples/jsm/nodes/display/PosterizeNode.js +10 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +101 -11
- package/examples/jsm/nodes/display/ViewportNode.js +27 -18
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +30 -0
- package/examples/jsm/nodes/display/ViewportTextureNode.js +67 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +35 -0
- package/examples/jsm/nodes/fog/FogNode.js +12 -6
- package/examples/jsm/nodes/fog/FogRangeNode.js +12 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +30 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -13
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -6
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +3 -3
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +7 -5
- package/examples/jsm/nodes/functions/PhongLightingModel.js +28 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +35 -36
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +4 -3
- package/examples/jsm/nodes/functions/material/getRoughness.js +4 -4
- package/examples/jsm/nodes/geometry/RangeNode.js +50 -55
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +9 -2
- package/examples/jsm/nodes/lighting/AONode.js +5 -3
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +27 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +114 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +43 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +121 -35
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +15 -10
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +39 -0
- package/examples/jsm/nodes/lighting/LightNode.js +57 -0
- package/examples/jsm/nodes/lighting/LightUtils.js +17 -0
- package/examples/jsm/nodes/lighting/LightingContextNode.js +30 -8
- package/examples/jsm/nodes/lighting/LightingNode.js +3 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +18 -10
- package/examples/jsm/nodes/lighting/PointLightNode.js +71 -0
- package/examples/jsm/nodes/lighting/SpotLightNode.js +92 -0
- package/examples/jsm/nodes/loaders/NodeLoader.js +5 -4
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +4 -20
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +6 -9
- package/examples/jsm/nodes/materials/Materials.js +11 -55
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +5 -11
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +48 -0
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +74 -0
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +21 -96
- package/examples/jsm/nodes/materials/NodeMaterial.js +284 -62
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +7 -1
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +29 -25
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +31 -22
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +1 -1
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +2 -1
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +2 -1
- package/examples/jsm/nodes/math/CondNode.js +43 -17
- package/examples/jsm/nodes/math/MathNode.js +178 -73
- package/examples/jsm/nodes/math/OperatorNode.js +52 -2
- package/examples/jsm/nodes/procedural/CheckerNode.js +14 -6
- package/examples/jsm/nodes/shadernode/ShaderNode.js +186 -63
- package/examples/jsm/nodes/utils/ArrayElementNode.js +4 -2
- package/examples/jsm/nodes/utils/ConvertNode.js +19 -1
- package/examples/jsm/nodes/utils/DiscardNode.js +26 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +10 -4
- package/examples/jsm/nodes/utils/JoinNode.js +4 -1
- package/examples/jsm/nodes/utils/LoopNode.js +186 -0
- package/examples/jsm/nodes/utils/MatcapUVNode.js +11 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +18 -5
- package/examples/jsm/nodes/utils/OscNode.js +21 -14
- package/examples/jsm/nodes/utils/PackingNode.js +55 -0
- package/examples/jsm/nodes/utils/RemapNode.js +13 -5
- package/examples/jsm/nodes/utils/RotateUVNode.js +18 -7
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -0
- package/examples/jsm/nodes/utils/SplitNode.js +7 -5
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +15 -30
- package/examples/jsm/nodes/utils/TimerNode.js +16 -6
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +21 -10
- package/examples/jsm/objects/GroundProjectedSkybox.js +172 -0
- package/examples/jsm/objects/Lensflare.js +3 -4
- package/examples/jsm/objects/MarchingCubes.js +5 -1
- package/examples/jsm/objects/Reflector.js +7 -4
- package/examples/jsm/objects/Refractor.js +4 -4
- package/examples/jsm/objects/ShadowMesh.js +3 -3
- package/examples/jsm/objects/Water.js +2 -1
- package/examples/jsm/physics/AmmoPhysics.js +27 -28
- package/examples/jsm/physics/RapierPhysics.js +199 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +3 -2
- package/examples/jsm/postprocessing/BloomPass.js +7 -4
- package/examples/jsm/postprocessing/BokehPass.js +3 -8
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -2
- package/examples/jsm/postprocessing/EffectComposer.js +5 -95
- package/examples/jsm/postprocessing/FilmPass.js +1 -2
- package/examples/jsm/postprocessing/GlitchPass.js +0 -2
- package/examples/jsm/postprocessing/HalftonePass.js +0 -6
- package/examples/jsm/postprocessing/OutlinePass.js +7 -7
- package/examples/jsm/postprocessing/OutputPass.js +72 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +4 -3
- package/examples/jsm/postprocessing/SAOPass.js +4 -26
- package/examples/jsm/postprocessing/SMAAPass.js +5 -8
- package/examples/jsm/postprocessing/SSAARenderPass.js +15 -6
- package/examples/jsm/postprocessing/SSAOPass.js +4 -14
- package/examples/jsm/postprocessing/SSRPass.js +3 -7
- package/examples/jsm/postprocessing/SavePass.js +2 -3
- package/examples/jsm/postprocessing/ShaderPass.js +1 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +3 -2
- package/examples/jsm/postprocessing/TexturePass.js +0 -2
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -11
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +27 -5
- package/examples/jsm/renderers/{webgpu/WebGPUAnimation.js → common/Animation.js} +4 -4
- package/examples/jsm/renderers/common/Attributes.js +75 -0
- package/examples/jsm/renderers/common/Backend.js +160 -0
- package/examples/jsm/renderers/common/Background.js +133 -0
- package/examples/jsm/renderers/common/Binding.js +11 -0
- package/examples/jsm/renderers/common/Bindings.js +169 -0
- package/examples/jsm/renderers/common/Buffer.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPUBufferUtils.js → common/BufferUtils.js} +2 -2
- package/examples/jsm/renderers/common/ChainMap.js +89 -0
- package/examples/jsm/renderers/common/ComputePipeline.js +17 -0
- package/examples/jsm/renderers/common/Constants.js +14 -0
- package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -0
- package/examples/jsm/renderers/common/DataMap.js +54 -0
- package/examples/jsm/renderers/common/Geometries.js +215 -0
- package/examples/jsm/renderers/{webgpu/WebGPUInfo.js → common/Info.js} +2 -3
- package/examples/jsm/renderers/common/Pipeline.js +13 -0
- package/examples/jsm/renderers/common/Pipelines.js +309 -0
- package/examples/jsm/renderers/common/ProgrammableStage.js +18 -0
- package/examples/jsm/renderers/common/RenderContext.js +37 -0
- package/examples/jsm/renderers/common/RenderContexts.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderLists.js → common/RenderList.js} +26 -47
- package/examples/jsm/renderers/common/RenderLists.js +38 -0
- package/examples/jsm/renderers/common/RenderObject.js +95 -0
- package/examples/jsm/renderers/common/RenderObjects.js +92 -0
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -0
- package/examples/jsm/renderers/common/RenderTarget.js +15 -0
- package/examples/jsm/renderers/common/Renderer.js +822 -0
- package/examples/jsm/renderers/common/SampledTexture.js +80 -0
- package/examples/jsm/renderers/common/Sampler.js +18 -0
- package/examples/jsm/renderers/common/StorageBuffer.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +206 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniform.js → common/Uniform.js} +13 -9
- package/examples/jsm/renderers/common/UniformBuffer.js +15 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniformsGroup.js → common/UniformsGroup.js} +13 -13
- package/examples/jsm/renderers/common/nodes/NodeRender.js +302 -0
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampledTexture.js → common/nodes/NodeSampledTexture.js} +4 -4
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampler.js → common/nodes/NodeSampler.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeUniform.js → common/nodes/NodeUniform.js} +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +319 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +35 -31
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +765 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +15 -987
- package/examples/jsm/renderers/webgpu/nodes/{WebGPUNodeBuilder.js → WGSLNodeBuilder.js} +117 -90
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeFunction.js +2 -2
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeParser.js +1 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +251 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +145 -0
- package/examples/jsm/renderers/webgpu/{constants.js → utils/WebGPUConstants.js} +73 -12
- package/examples/jsm/renderers/webgpu/{WebGPURenderPipeline.js → utils/WebGPUPipelineUtils.js} +135 -285
- package/examples/jsm/renderers/webgpu/{WebGPUTextureUtils.js → utils/WebGPUTextureMipmapUtils.js} +5 -25
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +855 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +88 -0
- package/examples/jsm/shaders/BleachBypassShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +3 -0
- package/examples/jsm/shaders/ColorifyShader.js +2 -0
- package/examples/jsm/shaders/ConvolutionShader.js +2 -0
- package/examples/jsm/shaders/CopyShader.js +2 -0
- package/examples/jsm/shaders/DotScreenShader.js +2 -0
- package/examples/jsm/shaders/ExposureShader.js +44 -0
- package/examples/jsm/shaders/FilmShader.js +2 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +2 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +15 -4
- package/examples/jsm/shaders/OutputShader.js +61 -0
- package/examples/jsm/shaders/RGBShiftShader.js +4 -2
- package/examples/jsm/shaders/SepiaShader.js +2 -0
- package/examples/jsm/shaders/ToonShader.js +13 -5
- package/examples/jsm/shaders/VelocityShader.js +1 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +2 -0
- package/examples/jsm/shaders/VignetteShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +5 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +54 -36
- package/examples/jsm/utils/LDrawUtils.js +4 -4
- package/examples/jsm/utils/PackedPhongMaterial.js +5 -78
- package/examples/jsm/utils/SceneUtils.js +8 -4
- package/examples/jsm/utils/SkeletonUtils.js +27 -210
- package/examples/jsm/utils/TextureUtils.js +41 -40
- package/examples/jsm/webxr/VRButton.js +1 -2
- package/examples/jsm/webxr/XRButton.js +198 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +1 -0
- package/examples/jsm/webxr/XRPlanes.js +100 -0
- package/package.json +34 -87
- package/src/Three.Legacy.js +19 -110
- package/src/Three.js +4 -3
- package/src/animation/AnimationUtils.js +13 -1
- package/src/audio/Audio.js +7 -2
- package/src/audio/PositionalAudio.js +8 -0
- package/src/cameras/Camera.js +5 -0
- package/src/cameras/CubeCamera.js +76 -13
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +22 -2
- package/src/core/BufferAttribute.js +150 -9
- package/src/core/BufferGeometry.js +4 -10
- package/src/core/GLBufferAttribute.js +2 -0
- package/src/core/InterleavedBufferAttribute.js +5 -5
- package/src/core/Object3D.js +37 -8
- package/src/extras/DataUtils.js +7 -1
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +5 -5
- package/src/extras/core/Curve.js +1 -1
- package/src/extras/curves/LineCurve.js +6 -4
- package/src/extras/curves/LineCurve3.js +13 -0
- package/src/geometries/BoxGeometry.js +10 -0
- package/src/geometries/CircleGeometry.js +11 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +11 -1
- package/src/geometries/EdgesGeometry.js +10 -0
- package/src/geometries/ExtrudeGeometry.js +11 -1
- package/src/geometries/LatheGeometry.js +10 -0
- package/src/geometries/PlaneGeometry.js +10 -0
- package/src/geometries/PolyhedronGeometry.js +11 -1
- package/src/geometries/RingGeometry.js +11 -1
- package/src/geometries/ShapeGeometry.js +11 -1
- package/src/geometries/SphereGeometry.js +12 -2
- package/src/geometries/TorusGeometry.js +11 -1
- package/src/geometries/TorusKnotGeometry.js +10 -0
- package/src/geometries/TubeGeometry.js +10 -0
- package/src/geometries/WireframeGeometry.js +10 -0
- package/src/helpers/Box3Helper.js +1 -2
- package/src/lights/DirectionalLight.js +1 -1
- package/src/lights/HemisphereLight.js +1 -1
- package/src/lights/SpotLight.js +1 -1
- package/src/loaders/AudioLoader.js +14 -8
- package/src/loaders/CubeTextureLoader.js +2 -0
- package/src/loaders/DataTextureLoader.js +5 -1
- package/src/loaders/MaterialLoader.js +8 -0
- package/src/loaders/ObjectLoader.js +10 -2
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +16 -4
- package/src/materials/MeshDistanceMaterial.js +0 -9
- package/src/materials/MeshPhysicalMaterial.js +32 -6
- package/src/materials/ShaderMaterial.js +6 -1
- package/src/math/Box2.js +3 -2
- package/src/math/Box3.js +49 -64
- package/src/math/Color.js +88 -66
- package/src/math/ColorManagement.js +75 -16
- package/src/math/Euler.js +2 -11
- package/src/math/Frustum.js +29 -5
- package/src/math/MathUtils.js +43 -1
- package/src/math/Matrix3.js +26 -6
- package/src/math/Matrix4.js +74 -19
- package/src/math/Plane.js +2 -2
- package/src/math/Quaternion.js +6 -0
- package/src/math/Ray.js +7 -7
- package/src/math/Triangle.js +37 -7
- package/src/math/Vector2.js +16 -0
- package/src/math/Vector3.js +10 -0
- package/src/math/interpolants/CubicInterpolant.js +1 -2
- package/src/objects/InstancedMesh.js +82 -1
- package/src/objects/Mesh.js +108 -76
- package/src/objects/Skeleton.js +1 -1
- package/src/objects/SkinnedMesh.js +123 -8
- package/src/objects/Sprite.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +12 -3
- package/src/renderers/WebGLMultipleRenderTargets.js +4 -2
- package/src/renderers/WebGLRenderTarget.js +14 -2
- package/src/renderers/WebGLRenderer.js +1433 -1236
- package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +0 -271
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +32 -0
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +26 -3
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -11
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +39 -13
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +306 -10
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +32 -10
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +5 -13
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +11 -5
- package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +4 -11
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +39 -34
- package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +101 -16
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +113 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +134 -6
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +116 -1
- package/src/renderers/shaders/ShaderChunk.js +0 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +0 -8
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +5 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -4
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -3
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -3
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -3
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +16 -12
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -3
- package/src/renderers/shaders/ShaderLib/points.glsl.js +13 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +5 -0
- package/src/renderers/shaders/ShaderLib.js +18 -4
- package/src/renderers/shaders/UniformsLib.js +27 -15
- package/src/renderers/shaders/UniformsUtils.js +12 -3
- package/src/renderers/webgl/WebGLBackground.js +23 -12
- package/src/renderers/webgl/WebGLBindingStates.js +13 -5
- package/src/renderers/webgl/WebGLCapabilities.js +1 -2
- package/src/renderers/webgl/WebGLClipping.js +7 -3
- package/src/renderers/webgl/WebGLGeometries.js +12 -0
- package/src/renderers/webgl/WebGLInfo.js +0 -1
- package/src/renderers/webgl/WebGLLights.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +123 -234
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +130 -48
- package/src/renderers/webgl/WebGLPrograms.js +210 -130
- package/src/renderers/webgl/WebGLRenderStates.js +2 -2
- package/src/renderers/webgl/WebGLShadowMap.js +40 -27
- package/src/renderers/webgl/WebGLState.js +23 -9
- package/src/renderers/webgl/WebGLTextures.js +39 -19
- package/src/renderers/webgl/WebGLUniformsGroups.js +74 -33
- package/src/renderers/webgl/WebGLUtils.js +41 -29
- package/src/renderers/webxr/WebXRController.js +3 -0
- package/src/renderers/webxr/WebXRManager.js +85 -141
- package/src/scenes/Scene.js +4 -6
- package/src/textures/CompressedTexture.js +2 -2
- package/src/textures/CubeTexture.js +2 -2
- package/src/textures/DataTexture.js +2 -2
- package/src/textures/DepthTexture.js +22 -0
- package/src/textures/FramebufferTexture.js +1 -3
- package/src/textures/Source.js +4 -0
- package/src/textures/Texture.js +43 -13
- package/src/utils.js +13 -1
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
- package/examples/fonts/open-sans/open-sans.css +0 -9
- package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +0 -3966
- package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
- package/examples/fonts/tabler-icons/tabler-icons.min.css +0 -4
- package/examples/js/animation/AnimationClipCreator.js +0 -89
- package/examples/js/animation/CCDIKSolver.js +0 -416
- package/examples/js/animation/MMDAnimationHelper.js +0 -1046
- package/examples/js/animation/MMDPhysics.js +0 -1174
- package/examples/js/cameras/CinematicCamera.js +0 -168
- package/examples/js/controls/ArcballControls.js +0 -2770
- package/examples/js/controls/DragControls.js +0 -205
- package/examples/js/controls/FirstPersonControls.js +0 -312
- package/examples/js/controls/FlyControls.js +0 -321
- package/examples/js/controls/OrbitControls.js +0 -1065
- package/examples/js/controls/PointerLockControls.js +0 -144
- package/examples/js/controls/TrackballControls.js +0 -729
- package/examples/js/controls/TransformControls.js +0 -1301
- package/examples/js/csm/CSM.js +0 -347
- package/examples/js/csm/CSMFrustum.js +0 -127
- package/examples/js/csm/CSMHelper.js +0 -165
- package/examples/js/csm/CSMShader.js +0 -253
- package/examples/js/curves/CurveExtras.js +0 -348
- package/examples/js/curves/NURBSCurve.js +0 -63
- package/examples/js/curves/NURBSSurface.js +0 -48
- package/examples/js/curves/NURBSUtils.js +0 -439
- package/examples/js/effects/AnaglyphEffect.js +0 -86
- package/examples/js/effects/AsciiEffect.js +0 -260
- package/examples/js/effects/OutlineEffect.js +0 -450
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -62
- package/examples/js/effects/PeppersGhostEffect.js +0 -139
- package/examples/js/effects/StereoEffect.js +0 -46
- package/examples/js/environments/DebugEnvironment.js +0 -53
- package/examples/js/environments/RoomEnvironment.js +0 -124
- package/examples/js/exporters/ColladaExporter.js +0 -487
- package/examples/js/exporters/DRACOExporter.js +0 -212
- package/examples/js/exporters/EXRExporter.js +0 -455
- package/examples/js/exporters/GLTFExporter.js +0 -2425
- package/examples/js/exporters/MMDExporter.js +0 -187
- package/examples/js/exporters/OBJExporter.js +0 -260
- package/examples/js/exporters/PLYExporter.js +0 -427
- package/examples/js/exporters/STLExporter.js +0 -188
- package/examples/js/exporters/USDZExporter.js +0 -608
- package/examples/js/geometries/BoxLineGeometry.js +0 -59
- package/examples/js/geometries/ConvexGeometry.js +0 -53
- package/examples/js/geometries/DecalGeometry.js +0 -324
- package/examples/js/geometries/LightningStrike.js +0 -861
- package/examples/js/geometries/ParametricGeometries.js +0 -216
- package/examples/js/geometries/ParametricGeometry.js +0 -121
- package/examples/js/geometries/RoundedBoxGeometry.js +0 -142
- package/examples/js/geometries/TeapotGeometry.js +0 -335
- package/examples/js/geometries/TextGeometry.js +0 -53
- package/examples/js/helpers/LightProbeHelper.js +0 -48
- package/examples/js/helpers/OctreeHelper.js +0 -76
- package/examples/js/helpers/PositionalAudioHelper.js +0 -91
- package/examples/js/helpers/RectAreaLightHelper.js +0 -73
- package/examples/js/helpers/VertexNormalsHelper.js +0 -74
- package/examples/js/helpers/VertexTangentsHelper.js +0 -68
- package/examples/js/helpers/ViewHelper.js +0 -281
- package/examples/js/interactive/HTMLMesh.js +0 -497
- package/examples/js/interactive/InteractiveGroup.js +0 -95
- package/examples/js/interactive/SelectionBox.js +0 -195
- package/examples/js/interactive/SelectionHelper.js +0 -83
- package/examples/js/libs/chevrotain.min.js +0 -3
- package/examples/js/libs/draco/draco_decoder.js +0 -52
- package/examples/js/libs/draco/draco_decoder.wasm +0 -0
- package/examples/js/libs/draco/draco_wasm_wrapper.js +0 -104
- package/examples/js/libs/draco/gltf/draco_decoder.js +0 -48
- package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +0 -104
- package/examples/js/libs/fflate.min.js +0 -7
- package/examples/js/libs/ktx-parse.umd.js +0 -1
- package/examples/js/libs/meshopt_decoder.js +0 -188
- package/examples/js/libs/opentype.min.js +0 -1
- package/examples/js/libs/stats.min.js +0 -5
- package/examples/js/lights/LightProbeGenerator.js +0 -221
- package/examples/js/lights/RectAreaLightUniformsLib.js +0 -60
- package/examples/js/lines/Line2.js +0 -19
- package/examples/js/lines/LineGeometry.js +0 -69
- package/examples/js/lines/LineMaterial.js +0 -635
- package/examples/js/lines/LineSegments2.js +0 -311
- package/examples/js/lines/LineSegmentsGeometry.js +0 -198
- package/examples/js/lines/Wireframe.js +0 -47
- package/examples/js/lines/WireframeGeometry2.js +0 -20
- package/examples/js/loaders/3DMLoader.js +0 -1273
- package/examples/js/loaders/3MFLoader.js +0 -1306
- package/examples/js/loaders/AMFLoader.js +0 -504
- package/examples/js/loaders/BVHLoader.js +0 -395
- package/examples/js/loaders/BasisTextureLoader.js +0 -706
- package/examples/js/loaders/ColladaLoader.js +0 -3663
- package/examples/js/loaders/DDSLoader.js +0 -244
- package/examples/js/loaders/DRACOLoader.js +0 -511
- package/examples/js/loaders/EXRLoader.js +0 -2039
- package/examples/js/loaders/FBXLoader.js +0 -3680
- package/examples/js/loaders/FontLoader.js +0 -160
- package/examples/js/loaders/GCodeLoader.js +0 -255
- package/examples/js/loaders/GLTFLoader.js +0 -4108
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -87
- package/examples/js/loaders/KMZLoader.js +0 -121
- package/examples/js/loaders/KTXLoader.js +0 -159
- package/examples/js/loaders/LDrawLoader.js +0 -2263
- package/examples/js/loaders/LUT3dlLoader.js +0 -135
- package/examples/js/loaders/LUTCubeLoader.js +0 -132
- package/examples/js/loaders/LWOLoader.js +0 -901
- package/examples/js/loaders/LogLuvLoader.js +0 -715
- package/examples/js/loaders/LottieLoader.js +0 -62
- package/examples/js/loaders/MD2Loader.js +0 -248
- package/examples/js/loaders/MDDLoader.js +0 -91
- package/examples/js/loaders/MMDLoader.js +0 -1915
- package/examples/js/loaders/MTLLoader.js +0 -472
- package/examples/js/loaders/MaterialXLoader.js +0 -392
- package/examples/js/loaders/NRRDLoader.js +0 -609
- package/examples/js/loaders/OBJLoader.js +0 -789
- package/examples/js/loaders/PCDLoader.js +0 -413
- package/examples/js/loaders/PDBLoader.js +0 -317
- package/examples/js/loaders/PLYLoader.js +0 -532
- package/examples/js/loaders/PRWMLoader.js +0 -249
- package/examples/js/loaders/PVRLoader.js +0 -218
- package/examples/js/loaders/RGBELoader.js +0 -442
- package/examples/js/loaders/RGBMLoader.js +0 -1354
- package/examples/js/loaders/STLLoader.js +0 -364
- package/examples/js/loaders/SVGLoader.js +0 -2783
- package/examples/js/loaders/TDSLoader.js +0 -992
- package/examples/js/loaders/TGALoader.js +0 -484
- package/examples/js/loaders/TIFFLoader.js +0 -30
- package/examples/js/loaders/TTFLoader.js +0 -203
- package/examples/js/loaders/TiltLoader.js +0 -459
- package/examples/js/loaders/VOXLoader.js +0 -240
- package/examples/js/loaders/VRMLLoader.js +0 -3140
- package/examples/js/loaders/VTKLoader.js +0 -1078
- package/examples/js/loaders/XYZLoader.js +0 -89
- package/examples/js/loaders/lwo/IFFParser.js +0 -1067
- package/examples/js/loaders/lwo/LWO2Parser.js +0 -397
- package/examples/js/loaders/lwo/LWO3Parser.js +0 -360
- package/examples/js/materials/MeshGouraudMaterial.js +0 -387
- package/examples/js/math/Capsule.js +0 -103
- package/examples/js/math/ColorConverter.js +0 -33
- package/examples/js/math/ConvexHull.js +0 -1154
- package/examples/js/math/ImprovedNoise.js +0 -66
- package/examples/js/math/Lut.js +0 -164
- package/examples/js/math/MeshSurfaceSampler.js +0 -171
- package/examples/js/math/OBB.js +0 -382
- package/examples/js/math/Octree.js +0 -410
- package/examples/js/math/SimplexNoise.js +0 -445
- package/examples/js/misc/ConvexObjectBreaker.js +0 -474
- package/examples/js/misc/GPUComputationRenderer.js +0 -393
- package/examples/js/misc/Gyroscope.js +0 -56
- package/examples/js/misc/MD2Character.js +0 -235
- package/examples/js/misc/MD2CharacterComplex.js +0 -513
- package/examples/js/misc/MorphAnimMesh.js +0 -63
- package/examples/js/misc/MorphBlendMesh.js +0 -265
- package/examples/js/misc/ProgressiveLightMap.js +0 -335
- package/examples/js/misc/RollerCoaster.js +0 -430
- package/examples/js/misc/TubePainter.js +0 -167
- package/examples/js/misc/Volume.js +0 -437
- package/examples/js/misc/VolumeSlice.js +0 -214
- package/examples/js/modifiers/CurveModifier.js +0 -309
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -228
- package/examples/js/modifiers/SimplifyModifier.js +0 -465
- package/examples/js/modifiers/TessellateModifier.js +0 -276
- package/examples/js/objects/GroundProjectedEnv.js +0 -181
- package/examples/js/objects/Lensflare.js +0 -356
- package/examples/js/objects/LightningStorm.js +0 -206
- package/examples/js/objects/MarchingCubes.js +0 -759
- package/examples/js/objects/Reflector.js +0 -216
- package/examples/js/objects/ReflectorForSSRPass.js +0 -315
- package/examples/js/objects/Refractor.js +0 -283
- package/examples/js/objects/ShadowMesh.js +0 -59
- package/examples/js/objects/Sky.js +0 -218
- package/examples/js/objects/Water.js +0 -292
- package/examples/js/objects/Water2.js +0 -307
- package/examples/js/physics/AmmoPhysics.js +0 -259
- package/examples/js/physics/OimoPhysics.js +0 -217
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +0 -335
- package/examples/js/postprocessing/AfterimagePass.js +0 -77
- package/examples/js/postprocessing/BloomPass.js +0 -135
- package/examples/js/postprocessing/BokehPass.js +0 -120
- package/examples/js/postprocessing/ClearPass.js +0 -39
- package/examples/js/postprocessing/CubeTexturePass.js +0 -60
- package/examples/js/postprocessing/DotScreenPass.js +0 -51
- package/examples/js/postprocessing/EffectComposer.js +0 -272
- package/examples/js/postprocessing/FilmPass.js +0 -52
- package/examples/js/postprocessing/GlitchPass.js +0 -104
- package/examples/js/postprocessing/HalftonePass.js +0 -75
- package/examples/js/postprocessing/LUTPass.js +0 -171
- package/examples/js/postprocessing/MaskPass.js +0 -95
- package/examples/js/postprocessing/OutlinePass.js +0 -598
- package/examples/js/postprocessing/Pass.js +0 -72
- package/examples/js/postprocessing/RenderPass.js +0 -70
- package/examples/js/postprocessing/SAOPass.js +0 -374
- package/examples/js/postprocessing/SMAAPass.js +0 -170
- package/examples/js/postprocessing/SSAARenderPass.js +0 -156
- package/examples/js/postprocessing/SSAOPass.js +0 -365
- package/examples/js/postprocessing/SSRPass.js +0 -567
- package/examples/js/postprocessing/SavePass.js +0 -59
- package/examples/js/postprocessing/ShaderPass.js +0 -64
- package/examples/js/postprocessing/TAARenderPass.js +0 -130
- package/examples/js/postprocessing/TexturePass.js +0 -49
- package/examples/js/postprocessing/UnrealBloomPass.js +0 -375
- package/examples/js/renderers/CSS2DRenderer.js +0 -178
- package/examples/js/renderers/CSS3DRenderer.js +0 -237
- package/examples/js/renderers/Projector.js +0 -818
- package/examples/js/renderers/SVGRenderer.js +0 -491
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +0 -89
- package/examples/js/shaders/AfterimageShader.js +0 -60
- package/examples/js/shaders/BasicShader.js +0 -27
- package/examples/js/shaders/BleachBypassShader.js +0 -62
- package/examples/js/shaders/BlendShader.js +0 -54
- package/examples/js/shaders/BokehShader.js +0 -156
- package/examples/js/shaders/BokehShader2.js +0 -419
- package/examples/js/shaders/BrightnessContrastShader.js +0 -58
- package/examples/js/shaders/ColorCorrectionShader.js +0 -52
- package/examples/js/shaders/ColorifyShader.js +0 -47
- package/examples/js/shaders/ConvolutionShader.js +0 -92
- package/examples/js/shaders/CopyShader.js +0 -45
- package/examples/js/shaders/DOFMipMapShader.js +0 -60
- package/examples/js/shaders/DepthLimitedBlurShader.js +0 -173
- package/examples/js/shaders/DigitalGlitch.js +0 -127
- package/examples/js/shaders/DotScreenShader.js +0 -72
- package/examples/js/shaders/FXAAShader.js +0 -284
- package/examples/js/shaders/FilmShader.js +0 -110
- package/examples/js/shaders/FocusShader.js +0 -95
- package/examples/js/shaders/FreiChenShader.js +0 -93
- package/examples/js/shaders/GammaCorrectionShader.js +0 -41
- package/examples/js/shaders/GodRaysShader.js +0 -284
- package/examples/js/shaders/HalftoneShader.js +0 -336
- package/examples/js/shaders/HorizontalBlurShader.js +0 -59
- package/examples/js/shaders/HorizontalTiltShiftShader.js +0 -65
- package/examples/js/shaders/HueSaturationShader.js +0 -69
- package/examples/js/shaders/KaleidoShader.js +0 -60
- package/examples/js/shaders/LuminosityHighPassShader.js +0 -67
- package/examples/js/shaders/LuminosityShader.js +0 -46
- package/examples/js/shaders/MMDToonShader.js +0 -96
- package/examples/js/shaders/MirrorShader.js +0 -56
- package/examples/js/shaders/NormalMapShader.js +0 -55
- package/examples/js/shaders/RGBShiftShader.js +0 -56
- package/examples/js/shaders/SAOShader.js +0 -209
- package/examples/js/shaders/SMAAShader.js +0 -454
- package/examples/js/shaders/SSAOShader.js +0 -295
- package/examples/js/shaders/SSRShader.js +0 -381
- package/examples/js/shaders/SepiaShader.js +0 -52
- package/examples/js/shaders/SobelOperatorShader.js +0 -88
- package/examples/js/shaders/SubsurfaceScatteringShader.js +0 -49
- package/examples/js/shaders/TechnicolorShader.js +0 -43
- package/examples/js/shaders/ToneMapShader.js +0 -84
- package/examples/js/shaders/ToonShader.js +0 -335
- package/examples/js/shaders/TriangleBlurShader.js +0 -70
- package/examples/js/shaders/UnpackDepthRGBAShader.js +0 -47
- package/examples/js/shaders/VelocityShader.js +0 -126
- package/examples/js/shaders/VerticalBlurShader.js +0 -59
- package/examples/js/shaders/VerticalTiltShiftShader.js +0 -65
- package/examples/js/shaders/VignetteShader.js +0 -53
- package/examples/js/shaders/VolumeShader.js +0 -296
- package/examples/js/shaders/WaterRefractionShader.js +0 -84
- package/examples/js/textures/FlakesTexture.js +0 -40
- package/examples/js/utils/BufferGeometryUtils.js +0 -1160
- package/examples/js/utils/CameraUtils.js +0 -71
- package/examples/js/utils/GPUStatsPanel.js +0 -125
- package/examples/js/utils/GeometryCompressionUtils.js +0 -549
- package/examples/js/utils/GeometryUtils.js +0 -168
- package/examples/js/utils/LDrawUtils.js +0 -179
- package/examples/js/utils/PackedPhongMaterial.js +0 -109
- package/examples/js/utils/SceneUtils.js +0 -214
- package/examples/js/utils/ShadowMapViewer.js +0 -183
- package/examples/js/utils/SkeletonUtils.js +0 -493
- package/examples/js/utils/UVsDebug.js +0 -143
- package/examples/js/utils/WorkerPool.js +0 -105
- package/examples/jsm/exporters/ColladaExporter.js +0 -713
- package/examples/jsm/geometries/LightningStrike.js +0 -1017
- package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +0 -37071
- package/examples/jsm/libs/OimoPhysics/index.js +0 -43
- package/examples/jsm/libs/flow.module.js +0 -4552
- package/examples/jsm/libs/tween.module.min.js +0 -3
- package/examples/jsm/loaders/BasisTextureLoader.js +0 -790
- package/examples/jsm/loaders/IFCLoader.js +0 -2431
- package/examples/jsm/loaders/PRWMLoader.js +0 -299
- package/examples/jsm/loaders/ifc/web-ifc-api.js +0 -47504
- package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
- package/examples/jsm/node-editor/NodeEditor.js +0 -857
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +0 -14
- package/examples/jsm/node-editor/accessors/NormalEditor.js +0 -30
- package/examples/jsm/node-editor/accessors/PositionEditor.js +0 -30
- package/examples/jsm/node-editor/accessors/UVEditor.js +0 -25
- package/examples/jsm/node-editor/core/BaseNode.js +0 -96
- package/examples/jsm/node-editor/core/DataFile.js +0 -59
- package/examples/jsm/node-editor/core/FileEditor.js +0 -20
- package/examples/jsm/node-editor/core/FileURLEditor.js +0 -29
- package/examples/jsm/node-editor/display/BlendEditor.js +0 -44
- package/examples/jsm/node-editor/display/NormalMapEditor.js +0 -49
- package/examples/jsm/node-editor/examples/animate-uv.json +0 -1
- package/examples/jsm/node-editor/examples/fake-top-light.json +0 -1
- package/examples/jsm/node-editor/examples/matcap.json +0 -1
- package/examples/jsm/node-editor/examples/oscillator-color.json +0 -1
- package/examples/jsm/node-editor/examples/rim.json +0 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +0 -96
- package/examples/jsm/node-editor/inputs/FloatEditor.js +0 -23
- package/examples/jsm/node-editor/inputs/SliderEditor.js +0 -67
- package/examples/jsm/node-editor/inputs/TextureEditor.js +0 -155
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +0 -28
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +0 -30
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +0 -37
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +0 -84
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +0 -102
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +0 -118
- package/examples/jsm/node-editor/math/AngleEditor.js +0 -40
- package/examples/jsm/node-editor/math/DotEditor.js +0 -35
- package/examples/jsm/node-editor/math/InvertEditor.js +0 -39
- package/examples/jsm/node-editor/math/LimiterEditor.js +0 -62
- package/examples/jsm/node-editor/math/NormalizeEditor.js +0 -28
- package/examples/jsm/node-editor/math/OperatorEditor.js +0 -63
- package/examples/jsm/node-editor/math/PowerEditor.js +0 -44
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +0 -45
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +0 -27
- package/examples/jsm/node-editor/scene/MeshEditor.js +0 -102
- package/examples/jsm/node-editor/scene/Object3DEditor.js +0 -160
- package/examples/jsm/node-editor/scene/PointsEditor.js +0 -99
- package/examples/jsm/node-editor/utils/JoinEditor.js +0 -58
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +0 -43
- package/examples/jsm/node-editor/utils/PreviewEditor.js +0 -170
- package/examples/jsm/node-editor/utils/SplitEditor.js +0 -39
- package/examples/jsm/node-editor/utils/TimerEditor.js +0 -58
- package/examples/jsm/nodes/core/CodeNode.js +0 -50
- package/examples/jsm/nodes/core/ExpressionNode.js +0 -32
- package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +0 -22
- package/examples/jsm/nodes/lighting/PunctualLightNode.js +0 -68
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +0 -301
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +0 -149
- package/examples/jsm/objects/GroundProjectedEnv.js +0 -186
- package/examples/jsm/objects/LightningStorm.js +0 -245
- package/examples/jsm/physics/OimoPhysics.js +0 -231
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -369
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +0 -187
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +0 -173
- package/examples/jsm/renderers/webgpu/WebGPUBinding.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +0 -255
- package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +0 -43
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +0 -78
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +0 -82
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +0 -36
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUProperties.js +0 -38
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +0 -296
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +0 -66
- package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +0 -73
- package/examples/jsm/renderers/webgpu/WebGPUSampler.js +0 -29
- package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +0 -20
- package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +0 -40
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +0 -794
- package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +0 -18
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +0 -81
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +0 -83
- package/examples/jsm/shaders/ToneMapShader.js +0 -73
- package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +0 -7
- package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +0 -7
- /package/examples/{js → jsm}/libs/ammo.wasm.js +0 -0
- /package/examples/{js → jsm}/libs/ammo.wasm.wasm +0 -0
- /package/examples/{js → jsm}/libs/basis/basis_transcoder.js +0 -0
- /package/examples/{js → jsm}/libs/basis/basis_transcoder.wasm +0 -0
- /package/examples/{js → jsm}/libs/draco/README.md +0 -0
- /package/examples/{js → jsm}/libs/draco/draco_encoder.js +0 -0
- /package/examples/{js → jsm}/libs/draco/gltf/draco_encoder.js +0 -0
|
@@ -1,4552 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://github.com/sunag/flow
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
function __flow__addCSS( css ) {
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
|
|
9
|
-
const style = document.createElement( 'style' );
|
|
10
|
-
|
|
11
|
-
style.setAttribute( 'type', 'text/css' );
|
|
12
|
-
style.innerHTML = css;
|
|
13
|
-
document.head.appendChild( style );
|
|
14
|
-
|
|
15
|
-
} catch ( e ) {}
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
__flow__addCSS( `@keyframes f-animation-open { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; }}f-canvas,f-canvas canvas.background,f-canvas canvas.frontground { position: absolute; top: 0; left: 0; margin: 0; padding: 0; width: 100%; height: 100%; -webkit-touch-callout: none; transition: opacity .17s;}f-canvas { cursor: grab;}f-canvas canvas.frontground { z-index: 10;}body.dragging *:not(.drag) { pointer-events: none !important;}f-canvas.grabbing * { cursor: grabbing; user-select: none;}f-canvas canvas.background,f-canvas canvas.frontground { position: fixed; overflow: hidden;}f-canvas canvas.frontground { pointer-events: none;}f-canvas::-webkit-scrollbar { width: 8px; height: 8px;}f-canvas::-webkit-scrollbar-thumb:hover{ background: #014fc5;}f-canvas::-webkit-scrollbar-track { background: #363636;}f-canvas::-webkit-scrollbar-thumb { background-color: #666666; border-radius: 10px; border: 0;}f-canvas f-content { left: 0; top: 0;}f-canvas f-content,f-canvas f-area { position: absolute; display: block;}f-canvas canvas.map { position: absolute; top: 10px; right: 10px; z-index: 50; backdrop-filter: blur( 10px ); background-color: rgba( 45, 45, 48, .8 );}f-node { position: absolute; margin: 0; padding: 0; user-select: none; width: 320px; z-index: 1; cursor: auto; filter: drop-shadow(0 0 10px #00000061); backdrop-filter: blur(4px);}f-node.selected { z-index: 2;}f-canvas.focusing canvas.background,f-canvas.focusing f-node:not(.selected),f-canvas.focusing f-element f-disconnect:not(.selected) { opacity: 0; pointer-events: none;}.dragging f-canvas f-element f-disconnect { opacity: 0;}.dragging.node f-canvas.focusing canvas.background,.dragging.node f-canvas.focusing f-node:not(.selected) { opacity: .5;}f-node.selected,f-canvas.dragging-rio f-node:hover,f-canvas.dragging-lio f-node:hover { filter: drop-shadow(0 0 10px #00000061) drop-shadow(0 0 8px #4444dd);}f-node.closed f-element:not(:first-child) { display: none;}f-node.center { top: 50%; left: 50%; transform: translate( -50%, -50% );}f-node.top-right { top: 0; right: 0;}f-node.top-center { top: 0; left: 50%; transform: translateX( -50% );}f-node.top-left { top: 0; left: 0;}f-node { transition: filter 0.2s ease, opacity 0.12s ease;}f-node { animation: .2s f-animation-open 1 alternate ease-out;}f-tips,f-drop,f-menu,f-menu input,f-menu button,f-element,f-element input,f-element select,f-element button,f-element textarea { font-family: 'Open Sans', sans-serif; font-size: 13px; text-transform: capitalize; color: #eeeeee; outline: solid 0px #000; margin: 0; padding: 0; border: 0; user-select: none; -webkit-tap-highlight-color: transparent; transition: background 0.2s ease, filter 0.2s ease;}f-element input:read-only { color: #666;}f-element input,f-element textarea { text-transform: initial;}f-element input { transition: background 0.1s ease;}f-element input,f-element select,f-element button,f-element textarea { background-color: #232324d1;}f-element { position: relative; width: calc( 100% - 14px ); background: rgba(45, 45, 48, 0.95); pointer-events: auto; border-bottom: 2px solid #232323; display: flex; padding-left: 7px; padding-right: 7px; padding-top: 2px; padding-bottom: 2px;}f-element:after,f-element:before { transition: opacity .17s; opacity: 0; content: '';}f-element[tooltip]:hover:after,f-element[tooltip]:focus-within:after { font-size: 14px !important; display: flex; justify-content: center; position: fixed; margin-left: -7px; width: calc( 100% ); background: #1d1d1de8; border: 1px solid #444444a1; border-radius: 6px; color: #dadada; content: attr( tooltip ); margin-top: -41px; font-size: 16px; padding-top: 3px; padding-bottom: 3px; z-index: 10; opacity: 1; backdrop-filter: blur(4px); white-space: nowrap; overflow: hidden; text-shadow: 1px 1px 0px #0007;}f-element[tooltip]:hover:before,f-element[tooltip]:focus-within:before { border: solid; border-color: #1d1d1de8 transparent; border-width: 12px 6px 0 6px; left: calc( 50% - 6px ); bottom: 30px; position: absolute; opacity: 1; z-index: 11;}f-element[error] { background-color: #ff0000;}f-element[error]:hover:after,f-element[error]:focus-within:after { border: none; background-color: #ff0000bb; filter: drop-shadow( 2px 2px 5px #000 ); color: #fff;}f-element[error]:hover:before,f-element[error]:focus-within:before { border-color: #ff0000bb transparent;}f-element { height: 24px;}f-element input { margin-top: 2px; margin-bottom: 2px; box-shadow: inset 0px 1px 1px rgb(0 0 0 / 20%), 0px 1px 0px rgb(255 255 255 / 5%); margin-left: 2px; margin-right: 2px; width: 100%; padding-left: 4px; padding-right: 4px;}f-element input.number { cursor: col-resize;}f-element input:focus[type='text'], f-element input:focus[type='range'], f-element input:focus[type='color'] { background: rgba( 0, 0, 0, 0.6 ); outline: solid 1px rgba( 0, 80, 200, 0.98 );}f-element input[type='color'] { appearance: none; padding: 0; margin-left: 2px; margin-right: 2px; height: calc( 100% - 4px ); margin-top: 2px; border: none;}f-element input[type='color']::-webkit-color-swatch-wrapper { padding: 2px;}f-element input[type='color']::-webkit-color-swatch { border: none; cursor: alias;}f-element input[type='range'] { appearance: none; width: 100%; overflow: hidden; padding: 0; cursor: ew-resize;}f-element input[type='range']::-webkit-slider-runnable-track { appearance: none; height: 10px; color: #13bba4; margin: 0;}f-element input[type='range']::-webkit-slider-thumb { appearance: none; width: 0; background: #434343; box-shadow: -500px 0 0 500px rgba( 0, 120, 255, 0.98 ); border-radius: 50%; border: 0 !important;}f-element input[type='range']::-webkit-slider-runnable-track { margin-left: -4px; margin-right: -5px;}f-element input[type='checkbox'] { appearance: none; cursor: pointer;}f-element input[type='checkbox'].toggle { height: 20px; width: 45px; border-radius: 16px; display: inline-block; position: relative; margin: 0; margin-top: 2px; background: linear-gradient( 0deg, #292929 0%, #0a0a0ac2 100% ); transition: all 0.2s ease;}f-element input[type='checkbox'].toggle:after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: 0 1px 2px rgba(44, 44, 44, 0.2); transition: all 0.2s cubic-bezier(0.5, 0.1, 0.75, 1.35);}f-element input[type='checkbox'].toggle:checked { background: linear-gradient( 0deg, #0177fb 0%, #0177fb 100% );}f-element input[type='checkbox'].toggle:checked:after { transform: translatex(25px);}f-element.auto-height { display: table;}f-element textarea { width: calc( 100% - 18px ); padding-top: 1px; padding-bottom: 3px; padding-left: 3px; padding-right: 8px; margin-top: 2px; margin-left: 2px; height: calc( 100% - 8px ); max-height: 300px; border-radius: 2px; resize: none; box-shadow: inset 0px 1px 1px rgb(0 0 0 / 20%), 0px 1px 0px rgb(255 255 255 / 5%);}f-element.auto-height textarea { resize: auto;}f-element select { width: 100%; margin-top: 2px; margin-bottom: 2px; margin-left: 2px; margin-right: 2px; cursor: pointer; box-shadow: inset 0px 1px 1px rgb(0 0 0 / 20%), 0px 1px 0px rgb(255 255 255 / 5%);}f-element f-toolbar { position: absolute; display: flex; top: 0; width: 100%; height: 100%; align-content: space-around;}f-element.input-right f-toolbar { right: 7px; float: right; justify-content: end;}f-element f-toolbar { margin-top: auto; margin-bottom: auto; margin-left: 3px; margin-right: 3px; font-size: 18px; line-height: 18px;}f-element f-toolbar button { opacity: .7; cursor: pointer; font-size: 14px; width: unset; height: unset; border-radius: unset; border: unset; outline: 0; background-color: unset; box-shadow: unset;}f-element f-toolbar button:hover,f-element f-toolbar button:active { opacity: 1; border: 0; background-color: unset;}f-element input.range-value { width: 60px; text-align: center;}f-menu.context button,f-element button { width: 100%; height: calc( 100% - 4px ); margin-left: 2px; margin-right: 2px; margin-top: 2px; border-radius: 3px; cursor: pointer;}f-element button { box-shadow: inset 1px 1px 1px 0 rgb(255 255 255 / 17%), inset -2px -2px 2px 0 rgb(0 0 0 / 26%);}f-element button:hover { color: #fff; background-color: #2a2a2a;}f-element button:active { border: 1px solid rgba( 0, 120, 255, 0.98 );}f-element f-inputs,f-element f-subinputs { display: flex; justify-content: flex-end; width: 100%;}f-element f-inputs { left: 100px; top: 50%; transform: translateY( -50% ); position: absolute; width: calc( 100% - 106px ); height: calc( 100% - 4px ); z-index: 1;}f-element.inputs-disable f-inputs { filter: grayscale(100%); opacity: .5;}f-element.inputs-disable f-inputs input { pointer-events: none;}f-element f-label,f-element span { margin: auto; text-shadow: 1px 1px 0px #0007;}f-element f-label { padding-left: 4px; white-space: nowrap; position: absolute; top: 50%; transform: translateY( -50% ); width: calc( 100% - 20px );}f-element.right f-label { text-align: right;}f-element.center f-label { text-align: center;}f-element f-label i { font-size: 18px; margin-right: 6px; vertical-align: sub;}f-element f-label.center { width: 100%; text-align: center; display: block;}f-element.title { height: 29px; background-color: #3a3a3ab0; background-color: #3b3b43ed; cursor: all-scroll; border-top-left-radius: 6px; border-top-right-radius: 6px;}f-element.blue { background-color: #014fc5;}f-element.red { background-color: #bd0b0b;}f-element.green { background-color: #148d05;}f-element.yellow { background-color: #d6b100;}f-element.title.left { text-align: left; display: inline-grid; justify-content: start;}f-element.title f-title { text-align: center; font-size: 15px; padding-top: 2px; position: absolute; top: 50%; transform: translateY( -50% ); width: 100%;}f-element.title i { font-size: 18px; position: absolute; right: 10px; top: 50%; transform: translateY( -50% ); opacity: .5;}f-element.title f-toolbar i { font-size: 20px; right: unset; left: 0px;}f-element.input-right.title i { left: 10px; right: unset;}f-element.title.left span { text-align: left;}f-element f-io { border: 2px solid #dadada; width: 7px; height: 7px; position: absolute; background: #242427; border-radius: 8px; float: left; left: -7px; top: calc( 50% - 5px ); cursor: alias; box-shadow: 0 0 3px 2px #0000005e; z-index: 1;}f-element f-io.connect,f-canvas.dragging-rio f-element:hover f-io.lio,f-canvas.dragging-lio f-element:hover f-io.rio { zoom: 1.4;}f-node.io-connect f-io:not(.connect) { border: 2px solid #dadada !important; zoom: 1 !important;}f-element f-io.rio { float: right; right: -7px; left: unset;}f-element f-disconnect { position: absolute; left: -35px; top: 50%; font-size: 22px; transform: translateY( -50% ); filter: drop-shadow(0 0 5px #000); text-shadow: 0px 0px 5px black; cursor: pointer; transition: all .2s;}f-element.input-right f-disconnect { right: -35px; left: unset;}f-element f-disconnect:hover { color: #ff3300;}f-element textarea::-webkit-scrollbar { width: 6px;}f-element textarea::-webkit-scrollbar-track { background: #111; } f-element textarea::-webkit-scrollbar-thumb { background: #0177fb; }f-element textarea::-webkit-scrollbar-thumb:hover { background: #1187ff; }f-element.small { height: 18px;}f-element.large { height: 36px;}f-canvas.dragging-lio f-node:not(.io-connect) f-element.rio:hover,f-canvas.dragging-rio f-node:not(.io-connect) f-element.lio:hover,f-element.select { background-color: rgba(61, 70, 82, 0.98);}f-element.invalid > f-io { zoom: 1 !important;}f-element.invalid::after { font-size: 14px !important; display: flex; justify-content: center; align-items:center; margin: auto; position: absolute; width: 100%; height: 100%; background: #bd0b0b77; vertical-align: middle; color: #fff; content: 'Not Compatible'; opacity: .95; backdrop-filter: grayscale(100%); white-space: nowrap; overflow: hidden; left: 0; top: 0; text-transform: initial;}f-drop { width: 100%; height: 100%; position: sticky; left: 0; top: 0; background: #02358417; text-align: center; justify-content: center; align-items: center; display: flex; box-shadow: inset 0 0 20px 10px #464ace17; pointer-events: none; transition: all .07s; opacity: 0; visibility: hidden;}f-drop.visible { visibility: unset; opacity: unset; transition: all .23s;}f-drop span { opacity: .5; font-size: 40px; text-shadow: 0px 0px 5px #000; font-weight: bold;}f-tooltip { pointer-events: none;}f-tooltip { position: absolute; left: 0; top: 0; background: rgba(0,0,0,.8); backdrop-filter: blur(4px); font-size: 14px; padding: 7px; left: 50%; border-radius: 10px; transform: translateX(-50%); visibility: hidden; pointer-events: none; opacity: 0; transition: all 0.3s ease; z-index: 150; white-space: nowrap;}f-menu.context,f-menu.search { position: absolute;}f-menu.context { width: 170px; z-index: 110;}f-menu.search { bottom: 85px; left: 50%; transform: translateX(-50%); z-index: 10; width: 300px;}f-menu.context f-list { display: block; margin: 0; background: #171717e6; font-size: 12px; border-radius: 6px; backdrop-filter: blur(6px); border: 1px solid #7e7e7e45; box-shadow: 3px 3px 6px rgba(0,0,0,.2); transition: opacity 0.2s ease, transform 0.1s ease;}f-menu.search f-list { margin: 0 6px 0 6px; display: flex; flex-direction: column-reverse; margin-bottom: 5px;}f-menu.context.hidden { visibility: hidden; opacity: 0;}f-menu.context f-item,f-menu.search f-item { display: block; position: relative; margin: 0; padding: 0; white-space: nowrap;}f-menu.search f-item { opacity: 0;}f-menu.context f-item.submenu::after { content: ""; position: absolute; right: 6px; top: 50%; -webkit-transform: translateY( -50% ); transform: translateY( -50% ); border: 5px solid transparent; border-left-color: #808080;}f-menu.context f-item:hover > f-menu,f-menu.context f-item.active > f-menu { visibility: unset; transform: unset; opacity: unset;}f-menu.context f-menu { top: 0px; left: calc( 100% - 4px );}f-menu.context f-item button,f-menu.search f-item button { overflow: visible; display: block; width: calc( 100% - 6px ); text-align: left; cursor: pointer; white-space: nowrap; padding: 6px 8px; border-radius: 3px; background: rgba(45, 45, 48, 0.95); border: 0; color: #ddd; margin: 3px; text-shadow: 1px 1px 0px #0007;}f-menu.context f-item button i,f-menu.search f-item button i { float: left; font-size: 16px;}f-menu.context f-item button span,f-menu.search f-item button span { margin-left: 6px;}f-menu.context f-item:hover > button,f-menu.search f-item:hover > button,f-menu.search f-item.active > button { color: #fff; background-color: rgba(61, 70, 82, 0.98);}f-menu.search f-item:hover,f-menu.search f-item.active { opacity: 1 !important;}f-menu.context f-item button:active { outline: solid 1px rgba( 0, 80, 200, 0.98 );}f-menu.context f-item f-tooltip { margin-left: 85px; top: -50px;}f-menu.search f-item { display: none;}f-menu.search f-item:nth-child(1) { opacity: 1; display: unset;}f-menu.search f-item:nth-child(2) { opacity: .8; display: unset;}f-menu.search f-item:nth-child(3) { opacity: .6; display: unset;}f-menu.search f-item:nth-child(4) { opacity: .4; display: unset;}f-menu.search f-item button { border-radius: 14px;}f-tips { right: 10px; top: 10px; position: absolute; z-index: 100; pointer-events: none; display: flex; flex-direction: column;}f-tips f-tip { width: 450px; font-size: 13px; border-radius: 6px; text-align: center; display: block; height: auto; color: #ffffffe0; margin: 4px; padding: 4px; background: #17171794; border: 1px solid #7e7e7e38; line-height: 100%; backdrop-filter: blur(6px); transition: all 0.2s ease; text-transform: initial; opacity: 0;}f-tips f-tip:nth-child(1) { opacity: 1;}f-tips f-tip:nth-child(2) { opacity: .75;}f-tips f-tip:nth-child(3) { opacity: .25;}f-tips f-tip:nth-child(4) { opacity: .1;}f-tips f-tip.error { background: #b900005e;}f-menu.search input { width: calc( 100% - 28px ); height: 41px; position: absolute; z-index: 10; border-radius: 20px; padding-left: 14px; padding-right: 14px; font-size: 15px; background-color: #17171794; border: 1px solid #7e7e7e45; backdrop-filter: blur(6px); box-shadow: 3px 3px 6px rgb(0 0 0 / 20%); text-transform: initial;}f-menu.circle { position: absolute; z-index: 100;}f-menu.circle.top { top: 40px;}f-menu.circle.left { left: 40px;}f-menu.circle.bottom { bottom: 40px;}f-menu.circle.right { right: 40px;}f-menu.circle f-item { align-content: space-around; margin-right: 20px;}f-menu.circle f-item button { width: 47px; height: 47px; font-size: 22px; background: #17171794; border-radius: 50%; backdrop-filter: blur(6px); border: 1px solid #7e7e7e45; line-height: 100%; cursor: pointer; box-shadow: 3px 3px 6px rgba(0,0,0,.2);}f-menu.circle f-item f-tooltip { margin-top: -60px;}f-menu.circle.top f-item f-tooltip { margin-top: 50px;}.f-rounded f-node f-element,.f-rounded f-node f-element.title.left { border-radius: 10px 5px 10px 5px;}.f-rounded f-node f-element input, .f-rounded f-node f-element select,.f-rounded f-node f-element button,.f-rounded f-node f-element textarea,.f-rounded f-node f-element input[type='checkbox'].toggle,.f-rounded f-node f-element input[type='checkbox'].toggle:after { border-radius: 20px 10px;}.f-rounded f-node f-element input { padding-left: 7px; padding-right: 7px;}.f-rounded f-menu.context,.f-rounded f-menu.context f-item button { border-radius: 20px 10px;}@media (hover: hover) and (pointer: fine) { f-node:not(.selected):hover { filter: drop-shadow(0 0 6px #66666630); } f-element f-toolbar { visibility: hidden; opacity: 0; transition: opacity 0.2s ease; } body:not(.connecting) f-node:hover > f-element f-toolbar { visibility: visible; opacity: 1; } f-element f-io:hover { zoom: 1.4; } f-menu.circle f-item button:hover { background-color: #2a2a2a; } f-menu.search input:hover, f-menu.search input:focus { background-color: #1a1a1a; filter: drop-shadow(0 0 6px #66666630); } f-menu.search input:focus { filter: drop-shadow(0 0 8px #4444dd); } f-menu.circle f-item button:hover > f-tooltip, f-menu.context f-item button:hover > f-tooltip { visibility: visible; opacity: 1; } f-menu.circle f-item button:hover > f-tooltip { margin-top: -50px; } f-menu.circle.top f-item button:hover > f-tooltip { margin-top: 60px; } f-menu.context f-item button:hover > f-tooltip { top: -30px; } f-menu.circle f-item button:focus > f-tooltip, f-menu.context f-item button:focus > f-tooltip { visibility: hidden; opacity: 0; }}@media (hover: none) and (pointer: coarse) { body.dragging f-canvas, body.connecting f-canvas { overflow: hidden !important; }}f-element.invalid > f-inputs,f-element.invalid > f-label,f-element.invalid > f-title,f-element.invalid > f-toolbar,f-element.invalid > input,f-element.invalid > select { opacity: .1 !important;}f-canvas { will-change: top, left;}f-node { will-change: transform !important;}` );
|
|
20
|
-
|
|
21
|
-
const REVISION = '1';
|
|
22
|
-
|
|
23
|
-
const Styles = {
|
|
24
|
-
icons: {
|
|
25
|
-
close: '',
|
|
26
|
-
unlink: ''
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
let _id = 0;
|
|
31
|
-
|
|
32
|
-
class Serializer extends EventTarget {
|
|
33
|
-
|
|
34
|
-
constructor() {
|
|
35
|
-
|
|
36
|
-
super();
|
|
37
|
-
|
|
38
|
-
this._id = _id ++;
|
|
39
|
-
|
|
40
|
-
this._serializable = true;
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get id() {
|
|
45
|
-
|
|
46
|
-
return this._id;
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
setSerializable( value ) {
|
|
51
|
-
|
|
52
|
-
this._serializable = value;
|
|
53
|
-
|
|
54
|
-
return this;
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getSerializable() {
|
|
59
|
-
|
|
60
|
-
return this._serializable;
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
serialize( /*data*/ ) {
|
|
65
|
-
|
|
66
|
-
console.warn( 'Serializer: Abstract function.' );
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
deserialize( /*data*/ ) {
|
|
71
|
-
|
|
72
|
-
console.warn( 'Serializer: Abstract function.' );
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
toJSON( data = null ) {
|
|
77
|
-
|
|
78
|
-
let object = null;
|
|
79
|
-
|
|
80
|
-
const id = this.id;
|
|
81
|
-
|
|
82
|
-
if ( data !== null ) {
|
|
83
|
-
|
|
84
|
-
const objects = data.objects;
|
|
85
|
-
|
|
86
|
-
object = objects[ id ];
|
|
87
|
-
|
|
88
|
-
if ( object === undefined ) {
|
|
89
|
-
|
|
90
|
-
object = { objects };
|
|
91
|
-
|
|
92
|
-
this.serialize( object );
|
|
93
|
-
|
|
94
|
-
delete object.objects;
|
|
95
|
-
|
|
96
|
-
objects[ id ] = object;
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
} else {
|
|
101
|
-
|
|
102
|
-
object = { objects: {} };
|
|
103
|
-
|
|
104
|
-
this.serialize( object );
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
object.id = id;
|
|
109
|
-
object.type = this.constructor.name;
|
|
110
|
-
|
|
111
|
-
return object;
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
class PointerMonitor {
|
|
118
|
-
|
|
119
|
-
started = false;
|
|
120
|
-
|
|
121
|
-
constructor() {
|
|
122
|
-
|
|
123
|
-
this.x = 0;
|
|
124
|
-
this.y = 0;
|
|
125
|
-
|
|
126
|
-
this._onMoveEvent = ( e ) => {
|
|
127
|
-
|
|
128
|
-
const event = e.touches ? e.touches[ 0 ] : e;
|
|
129
|
-
|
|
130
|
-
this.x = event.clientX;
|
|
131
|
-
this.y = event.clientY;
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
start() {
|
|
138
|
-
|
|
139
|
-
if ( this.started ) return;
|
|
140
|
-
|
|
141
|
-
this.started = true;
|
|
142
|
-
|
|
143
|
-
window.addEventListener( 'wheel', this._onMoveEvent, true );
|
|
144
|
-
|
|
145
|
-
window.addEventListener( 'mousedown', this._onMoveEvent, true );
|
|
146
|
-
window.addEventListener( 'touchstart', this._onMoveEvent, true );
|
|
147
|
-
|
|
148
|
-
window.addEventListener( 'mousemove', this._onMoveEvent, true );
|
|
149
|
-
window.addEventListener( 'touchmove', this._onMoveEvent, true );
|
|
150
|
-
|
|
151
|
-
window.addEventListener( 'dragover', this._onMoveEvent, true );
|
|
152
|
-
|
|
153
|
-
return this;
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const pointer = new PointerMonitor().start();
|
|
160
|
-
|
|
161
|
-
const draggableDOM = ( dom, callback = null, settings = {} ) => {
|
|
162
|
-
|
|
163
|
-
settings = Object.assign( {
|
|
164
|
-
className: 'dragging',
|
|
165
|
-
click: false,
|
|
166
|
-
bypass: false
|
|
167
|
-
}, settings );
|
|
168
|
-
|
|
169
|
-
let dragData = null;
|
|
170
|
-
|
|
171
|
-
const { className, click, bypass } = settings;
|
|
172
|
-
|
|
173
|
-
const getZoom = () => {
|
|
174
|
-
|
|
175
|
-
let zoomDOM = dom;
|
|
176
|
-
|
|
177
|
-
while ( zoomDOM && zoomDOM !== document ) {
|
|
178
|
-
|
|
179
|
-
const zoom = zoomDOM.style.zoom;
|
|
180
|
-
|
|
181
|
-
if ( zoom ) {
|
|
182
|
-
|
|
183
|
-
return Number( zoom );
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
zoomDOM = zoomDOM.parentNode;
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return 1;
|
|
192
|
-
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
const onMouseDown = ( e ) => {
|
|
196
|
-
|
|
197
|
-
const event = e.touches ? e.touches[ 0 ] : e;
|
|
198
|
-
|
|
199
|
-
if ( bypass === false ) e.stopImmediatePropagation();
|
|
200
|
-
|
|
201
|
-
dragData = {
|
|
202
|
-
client: { x: event.clientX, y: event.clientY },
|
|
203
|
-
delta: { x: 0, y: 0 },
|
|
204
|
-
start: { x: dom.offsetLeft, y: dom.offsetTop },
|
|
205
|
-
frame: 0,
|
|
206
|
-
isDown: true,
|
|
207
|
-
dragging: false,
|
|
208
|
-
isTouch: !! e.touches
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
if ( click === true ) {
|
|
212
|
-
|
|
213
|
-
callback( dragData );
|
|
214
|
-
|
|
215
|
-
dragData.frame ++;
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
window.addEventListener( 'mousemove', onGlobalMouseMove );
|
|
220
|
-
window.addEventListener( 'mouseup', onGlobalMouseUp );
|
|
221
|
-
|
|
222
|
-
window.addEventListener( 'touchmove', onGlobalMouseMove );
|
|
223
|
-
window.addEventListener( 'touchend', onGlobalMouseUp );
|
|
224
|
-
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const onGlobalMouseMove = ( e ) => {
|
|
228
|
-
|
|
229
|
-
const { start, delta, client } = dragData;
|
|
230
|
-
|
|
231
|
-
const event = e.touches ? e.touches[ 0 ] : e;
|
|
232
|
-
|
|
233
|
-
const zoom = getZoom();
|
|
234
|
-
|
|
235
|
-
delta.x = ( event.clientX - client.x ) / zoom;
|
|
236
|
-
delta.y = ( event.clientY - client.y ) / zoom;
|
|
237
|
-
|
|
238
|
-
dragData.x = start.x + delta.x;
|
|
239
|
-
dragData.y = start.y + delta.y;
|
|
240
|
-
|
|
241
|
-
if ( dragData.dragging === true ) {
|
|
242
|
-
|
|
243
|
-
if ( callback !== null ) {
|
|
244
|
-
|
|
245
|
-
callback( dragData );
|
|
246
|
-
|
|
247
|
-
dragData.frame ++;
|
|
248
|
-
|
|
249
|
-
} else {
|
|
250
|
-
|
|
251
|
-
dom.style.cssText += `; left: ${ dragData.x }px; top: ${ dragData.y }px;`;
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if ( bypass === false ) e.stopImmediatePropagation();
|
|
256
|
-
|
|
257
|
-
} else {
|
|
258
|
-
|
|
259
|
-
if ( Math.abs( delta.x ) > 2 || Math.abs( delta.y ) > 2 ) {
|
|
260
|
-
|
|
261
|
-
dragData.dragging = true;
|
|
262
|
-
|
|
263
|
-
dom.classList.add( 'drag' );
|
|
264
|
-
|
|
265
|
-
if ( className ) document.body.classList.add( ...className.split( ' ' ) );
|
|
266
|
-
|
|
267
|
-
if ( bypass === false ) e.stopImmediatePropagation();
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
const onGlobalMouseUp = ( e ) => {
|
|
276
|
-
|
|
277
|
-
if ( bypass === false ) e.stopImmediatePropagation();
|
|
278
|
-
|
|
279
|
-
dom.classList.remove( 'drag' );
|
|
280
|
-
|
|
281
|
-
if ( className ) document.body.classList.remove( ...className.split( ' ' ) );
|
|
282
|
-
|
|
283
|
-
window.removeEventListener( 'mousemove', onGlobalMouseMove );
|
|
284
|
-
window.removeEventListener( 'mouseup', onGlobalMouseUp );
|
|
285
|
-
|
|
286
|
-
window.removeEventListener( 'touchmove', onGlobalMouseMove );
|
|
287
|
-
window.removeEventListener( 'touchend', onGlobalMouseUp );
|
|
288
|
-
|
|
289
|
-
if ( callback === null ) {
|
|
290
|
-
|
|
291
|
-
dom.removeEventListener( 'mousedown', onMouseDown );
|
|
292
|
-
dom.removeEventListener( 'touchstart', onMouseDown );
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
dragData.dragging = false;
|
|
297
|
-
dragData.isDown = false;
|
|
298
|
-
|
|
299
|
-
if ( callback !== null ) {
|
|
300
|
-
|
|
301
|
-
callback( dragData );
|
|
302
|
-
|
|
303
|
-
dragData.frame ++;
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
if ( dom instanceof Event ) {
|
|
310
|
-
|
|
311
|
-
const e = dom;
|
|
312
|
-
dom = e.target;
|
|
313
|
-
|
|
314
|
-
onMouseDown( e );
|
|
315
|
-
|
|
316
|
-
} else {
|
|
317
|
-
|
|
318
|
-
dom.addEventListener( 'mousedown', onMouseDown );
|
|
319
|
-
dom.addEventListener( 'touchstart', onMouseDown );
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
const dispatchEventList = ( list, ...params ) => {
|
|
326
|
-
|
|
327
|
-
for ( const callback of list ) {
|
|
328
|
-
|
|
329
|
-
if ( callback( ...params ) === false ) {
|
|
330
|
-
|
|
331
|
-
return false;
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return true;
|
|
338
|
-
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
const numberToPX = ( val ) => {
|
|
342
|
-
|
|
343
|
-
if ( isNaN( val ) === false ) {
|
|
344
|
-
|
|
345
|
-
val = `${ val }px`;
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return val;
|
|
350
|
-
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const numberToHex = ( val ) => {
|
|
354
|
-
|
|
355
|
-
if ( isNaN( val ) === false ) {
|
|
356
|
-
|
|
357
|
-
val = `#${ val.toString( 16 ).padStart( 6, '0' ) }`;
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return val;
|
|
362
|
-
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
const rgbaToArray = ( rgba ) => {
|
|
366
|
-
|
|
367
|
-
const values = rgba.substring( rgba.indexOf( '(' ) + 1, rgba.indexOf( ')' ) )
|
|
368
|
-
.split( ',' )
|
|
369
|
-
.map( num => parseInt( num.trim() ) );
|
|
370
|
-
|
|
371
|
-
return values;
|
|
372
|
-
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
const removeDOMClass = ( dom, classList ) => {
|
|
376
|
-
|
|
377
|
-
if ( classList ) classList.split( ' ' ).forEach( alignClass => dom.classList.remove( alignClass ) );
|
|
378
|
-
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
const addDOMClass = ( dom, classList ) => {
|
|
382
|
-
|
|
383
|
-
if ( classList ) classList.split( ' ' ).forEach( alignClass => dom.classList.add( alignClass ) );
|
|
384
|
-
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
var Utils = /*#__PURE__*/Object.freeze({
|
|
388
|
-
__proto__: null,
|
|
389
|
-
pointer: pointer,
|
|
390
|
-
draggableDOM: draggableDOM,
|
|
391
|
-
dispatchEventList: dispatchEventList,
|
|
392
|
-
numberToPX: numberToPX,
|
|
393
|
-
numberToHex: numberToHex,
|
|
394
|
-
rgbaToArray: rgbaToArray,
|
|
395
|
-
removeDOMClass: removeDOMClass,
|
|
396
|
-
addDOMClass: addDOMClass
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
class Link {
|
|
400
|
-
|
|
401
|
-
constructor( inputElement = null, outputElement = null ) {
|
|
402
|
-
|
|
403
|
-
this.inputElement = inputElement;
|
|
404
|
-
this.outputElement = outputElement;
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
get lioElement() {
|
|
409
|
-
|
|
410
|
-
if ( Link.InputDirection === 'left' ) {
|
|
411
|
-
|
|
412
|
-
return this.outputElement;
|
|
413
|
-
|
|
414
|
-
} else {
|
|
415
|
-
|
|
416
|
-
return this.inputElement;
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
get rioElement() {
|
|
423
|
-
|
|
424
|
-
if ( Link.InputDirection === 'left' ) {
|
|
425
|
-
|
|
426
|
-
return this.inputElement;
|
|
427
|
-
|
|
428
|
-
} else {
|
|
429
|
-
|
|
430
|
-
return this.outputElement;
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
//Link.InputDirection = 'right';
|
|
439
|
-
Link.InputDirection = 'left';
|
|
440
|
-
|
|
441
|
-
let selected = null;
|
|
442
|
-
|
|
443
|
-
class Element extends Serializer {
|
|
444
|
-
|
|
445
|
-
constructor( draggable = false ) {
|
|
446
|
-
|
|
447
|
-
super();
|
|
448
|
-
|
|
449
|
-
const dom = document.createElement( 'f-element' );
|
|
450
|
-
dom.element = this;
|
|
451
|
-
|
|
452
|
-
const onSelect = ( e ) => {
|
|
453
|
-
|
|
454
|
-
let element = this;
|
|
455
|
-
|
|
456
|
-
if ( e.changedTouches && e.changedTouches.length > 0 ) {
|
|
457
|
-
|
|
458
|
-
const touch = e.changedTouches[ 0 ];
|
|
459
|
-
|
|
460
|
-
let overDOM = document.elementFromPoint( touch.clientX, touch.clientY );
|
|
461
|
-
|
|
462
|
-
while ( overDOM && ( ! overDOM.element || ! overDOM.element.isElement ) ) {
|
|
463
|
-
|
|
464
|
-
overDOM = overDOM.parentNode;
|
|
465
|
-
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
element = overDOM ? overDOM.element : null;
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
const type = e.type;
|
|
473
|
-
|
|
474
|
-
if ( ( type === 'mouseout' ) && selected === element ) {
|
|
475
|
-
|
|
476
|
-
selected = null;
|
|
477
|
-
|
|
478
|
-
} else {
|
|
479
|
-
|
|
480
|
-
selected = element;
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
if ( draggable === false ) {
|
|
487
|
-
|
|
488
|
-
dom.ontouchstart = dom.onmousedown = ( e ) => {
|
|
489
|
-
|
|
490
|
-
e.stopPropagation();
|
|
491
|
-
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
dom.addEventListener( 'mouseup', onSelect, true );
|
|
497
|
-
dom.addEventListener( 'mouseover', onSelect );
|
|
498
|
-
dom.addEventListener( 'mouseout', onSelect );
|
|
499
|
-
dom.addEventListener( 'touchmove', onSelect );
|
|
500
|
-
dom.addEventListener( 'touchend', onSelect );
|
|
501
|
-
|
|
502
|
-
this.inputs = [];
|
|
503
|
-
|
|
504
|
-
this.links = [];
|
|
505
|
-
|
|
506
|
-
this.dom = dom;
|
|
507
|
-
|
|
508
|
-
this.lioLength = 0;
|
|
509
|
-
this.rioLength = 0;
|
|
510
|
-
|
|
511
|
-
this.events = {
|
|
512
|
-
'connect': [],
|
|
513
|
-
'connectChildren': [],
|
|
514
|
-
'valid': []
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
this.node = null;
|
|
518
|
-
|
|
519
|
-
this.style = '';
|
|
520
|
-
this.color = null;
|
|
521
|
-
|
|
522
|
-
this.object = null;
|
|
523
|
-
this.objectCallback = null;
|
|
524
|
-
|
|
525
|
-
this.enabledInputs = true;
|
|
526
|
-
|
|
527
|
-
this.visible = true;
|
|
528
|
-
|
|
529
|
-
this.inputsDOM = dom;
|
|
530
|
-
|
|
531
|
-
this.disconnectDOM = null;
|
|
532
|
-
|
|
533
|
-
this.lioDOM = this._createIO( 'lio' );
|
|
534
|
-
this.rioDOM = this._createIO( 'rio' );
|
|
535
|
-
|
|
536
|
-
this.dom.classList.add( `input-${ Link.InputDirection }` );
|
|
537
|
-
|
|
538
|
-
this.addEventListener( 'connect', ( ) => {
|
|
539
|
-
|
|
540
|
-
dispatchEventList( this.events.connect, this );
|
|
541
|
-
|
|
542
|
-
} );
|
|
543
|
-
|
|
544
|
-
this.addEventListener( 'connectChildren', ( ) => {
|
|
545
|
-
|
|
546
|
-
dispatchEventList( this.events.connectChildren, this );
|
|
547
|
-
|
|
548
|
-
} );
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
setAttribute( name, value ) {
|
|
553
|
-
|
|
554
|
-
this.dom.setAttribute( name, value );
|
|
555
|
-
|
|
556
|
-
return this;
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
onValid( callback ) {
|
|
561
|
-
|
|
562
|
-
this.events.valid.push( callback );
|
|
563
|
-
|
|
564
|
-
return this;
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
onConnect( callback, childrens = false ) {
|
|
569
|
-
|
|
570
|
-
this.events.connect.push( callback );
|
|
571
|
-
|
|
572
|
-
if ( childrens ) {
|
|
573
|
-
|
|
574
|
-
this.events.connectChildren.push( callback );
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
return this;
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
setObjectCallback( callback ) {
|
|
583
|
-
|
|
584
|
-
this.objectCallback = callback;
|
|
585
|
-
|
|
586
|
-
return this;
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
setObject( value ) {
|
|
591
|
-
|
|
592
|
-
this.object = value;
|
|
593
|
-
|
|
594
|
-
return this;
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
getObject( output = null ) {
|
|
599
|
-
|
|
600
|
-
return this.objectCallback ? this.objectCallback( output ) : this.object;
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
setVisible( value ) {
|
|
605
|
-
|
|
606
|
-
this.visible = value;
|
|
607
|
-
|
|
608
|
-
this.dom.style.display = value ? '' : 'none';
|
|
609
|
-
|
|
610
|
-
return this;
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
getVisible() {
|
|
615
|
-
|
|
616
|
-
return this.visible;
|
|
617
|
-
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
setEnabledInputs( value ) {
|
|
621
|
-
|
|
622
|
-
const dom = this.dom;
|
|
623
|
-
|
|
624
|
-
if ( ! this.enabledInputs ) dom.classList.remove( 'inputs-disable' );
|
|
625
|
-
|
|
626
|
-
if ( ! value ) dom.classList.add( 'inputs-disable' );
|
|
627
|
-
|
|
628
|
-
this.enabledInputs = value;
|
|
629
|
-
|
|
630
|
-
return this;
|
|
631
|
-
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
getEnabledInputs() {
|
|
635
|
-
|
|
636
|
-
return this.enabledInputs;
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
setColor( color ) {
|
|
641
|
-
|
|
642
|
-
this.dom.style[ 'background-color' ] = numberToHex( color );
|
|
643
|
-
this.color = null;
|
|
644
|
-
|
|
645
|
-
return this;
|
|
646
|
-
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
getColor() {
|
|
650
|
-
|
|
651
|
-
if ( this.color === null ) {
|
|
652
|
-
|
|
653
|
-
const css = window.getComputedStyle( this.dom );
|
|
654
|
-
|
|
655
|
-
this.color = css.getPropertyValue( 'background-color' );
|
|
656
|
-
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
return this.color;
|
|
660
|
-
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
setStyle( style ) {
|
|
664
|
-
|
|
665
|
-
const dom = this.dom;
|
|
666
|
-
|
|
667
|
-
if ( this.style ) dom.classList.remove( this.style );
|
|
668
|
-
|
|
669
|
-
if ( style ) dom.classList.add( style );
|
|
670
|
-
|
|
671
|
-
this.style = style;
|
|
672
|
-
this.color = null;
|
|
673
|
-
|
|
674
|
-
return this;
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
setInput( length ) {
|
|
679
|
-
|
|
680
|
-
if ( Link.InputDirection === 'left' ) {
|
|
681
|
-
|
|
682
|
-
return this.setLIO( length );
|
|
683
|
-
|
|
684
|
-
} else {
|
|
685
|
-
|
|
686
|
-
return this.setRIO( length );
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
setInputColor( color ) {
|
|
693
|
-
|
|
694
|
-
if ( Link.InputDirection === 'left' ) {
|
|
695
|
-
|
|
696
|
-
return this.setLIOColor( color );
|
|
697
|
-
|
|
698
|
-
} else {
|
|
699
|
-
|
|
700
|
-
return this.setRIOColor( color );
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
setOutput( length ) {
|
|
707
|
-
|
|
708
|
-
if ( Link.InputDirection === 'left' ) {
|
|
709
|
-
|
|
710
|
-
return this.setRIO( length );
|
|
711
|
-
|
|
712
|
-
} else {
|
|
713
|
-
|
|
714
|
-
return this.setLIO( length );
|
|
715
|
-
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
setOutputColor( color ) {
|
|
721
|
-
|
|
722
|
-
if ( Link.InputDirection === 'left' ) {
|
|
723
|
-
|
|
724
|
-
return this.setRIOColor( color );
|
|
725
|
-
|
|
726
|
-
} else {
|
|
727
|
-
|
|
728
|
-
return this.setLIOColor( color );
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
get inputLength() {
|
|
735
|
-
|
|
736
|
-
if ( Link.InputDirection === 'left' ) {
|
|
737
|
-
|
|
738
|
-
return this.lioLength;
|
|
739
|
-
|
|
740
|
-
} else {
|
|
741
|
-
|
|
742
|
-
return this.rioLength;
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
get outputLength() {
|
|
749
|
-
|
|
750
|
-
if ( Link.InputDirection === 'left' ) {
|
|
751
|
-
|
|
752
|
-
return this.rioLength;
|
|
753
|
-
|
|
754
|
-
} else {
|
|
755
|
-
|
|
756
|
-
return this.lioLength;
|
|
757
|
-
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
setLIOColor( color ) {
|
|
763
|
-
|
|
764
|
-
this.lioDOM.style[ 'border-color' ] = numberToHex( color );
|
|
765
|
-
|
|
766
|
-
return this;
|
|
767
|
-
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
setLIO( length ) {
|
|
771
|
-
|
|
772
|
-
this.lioLength = length;
|
|
773
|
-
|
|
774
|
-
this.lioDOM.style.visibility = length > 0 ? '' : 'hidden';
|
|
775
|
-
|
|
776
|
-
if ( length > 0 ) {
|
|
777
|
-
|
|
778
|
-
this.dom.classList.add( 'lio' );
|
|
779
|
-
this.dom.prepend( this.lioDOM );
|
|
780
|
-
|
|
781
|
-
} else {
|
|
782
|
-
|
|
783
|
-
this.dom.classList.remove( 'lio' );
|
|
784
|
-
this.lioDOM.remove();
|
|
785
|
-
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
return this;
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
getLIOColor() {
|
|
793
|
-
|
|
794
|
-
return this.lioDOM.style[ 'border-color' ];
|
|
795
|
-
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
setRIOColor( color ) {
|
|
799
|
-
|
|
800
|
-
this.rioDOM.style[ 'border-color' ] = numberToHex( color );
|
|
801
|
-
|
|
802
|
-
return this;
|
|
803
|
-
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
getRIOColor() {
|
|
807
|
-
|
|
808
|
-
return this.rioDOM.style[ 'border-color' ];
|
|
809
|
-
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
setRIO( length ) {
|
|
813
|
-
|
|
814
|
-
this.rioLength = length;
|
|
815
|
-
|
|
816
|
-
this.rioDOM.style.visibility = length > 0 ? '' : 'hidden';
|
|
817
|
-
|
|
818
|
-
if ( length > 0 ) {
|
|
819
|
-
|
|
820
|
-
this.dom.classList.add( 'rio' );
|
|
821
|
-
this.dom.prepend( this.rioDOM );
|
|
822
|
-
|
|
823
|
-
} else {
|
|
824
|
-
|
|
825
|
-
this.dom.classList.remove( 'rio' );
|
|
826
|
-
this.rioDOM.remove();
|
|
827
|
-
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
return this;
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
add( input ) {
|
|
835
|
-
|
|
836
|
-
this.inputs.push( input );
|
|
837
|
-
|
|
838
|
-
input.element = this;
|
|
839
|
-
|
|
840
|
-
this.inputsDOM.append( input.dom );
|
|
841
|
-
|
|
842
|
-
return this;
|
|
843
|
-
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
setHeight( val ) {
|
|
847
|
-
|
|
848
|
-
this.dom.style.height = numberToPX( val );
|
|
849
|
-
|
|
850
|
-
return this;
|
|
851
|
-
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
getHeight() {
|
|
855
|
-
|
|
856
|
-
return this.dom.style.height;
|
|
857
|
-
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
connect( element = null ) {
|
|
861
|
-
|
|
862
|
-
if ( this.disconnectDOM !== null ) {
|
|
863
|
-
|
|
864
|
-
// remove the current input
|
|
865
|
-
|
|
866
|
-
this.disconnectDOM.dispatchEvent( new Event( 'disconnect' ) );
|
|
867
|
-
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
if ( element !== null ) {
|
|
871
|
-
|
|
872
|
-
element = element.baseElement || element;
|
|
873
|
-
|
|
874
|
-
if ( dispatchEventList( this.events.valid, this, element, 'connect' ) === false ) {
|
|
875
|
-
|
|
876
|
-
return false;
|
|
877
|
-
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
const link = new Link( this, element );
|
|
881
|
-
|
|
882
|
-
this.links.push( link );
|
|
883
|
-
|
|
884
|
-
if ( this.disconnectDOM === null ) {
|
|
885
|
-
|
|
886
|
-
this.disconnectDOM = document.createElement( 'f-disconnect' );
|
|
887
|
-
this.disconnectDOM.innerHTML = Styles.icons.unlink ? `<i class='${ Styles.icons.unlink }'></i>` : '✖';
|
|
888
|
-
|
|
889
|
-
this.dom.append( this.disconnectDOM );
|
|
890
|
-
|
|
891
|
-
const onDisconnect = () => {
|
|
892
|
-
|
|
893
|
-
this.links = [];
|
|
894
|
-
this.dom.removeChild( this.disconnectDOM );
|
|
895
|
-
|
|
896
|
-
this.disconnectDOM.removeEventListener( 'mousedown', onClick, true );
|
|
897
|
-
this.disconnectDOM.removeEventListener( 'touchstart', onClick, true );
|
|
898
|
-
this.disconnectDOM.removeEventListener( 'disconnect', onDisconnect, true );
|
|
899
|
-
|
|
900
|
-
element.removeEventListener( 'connect', onConnect );
|
|
901
|
-
element.removeEventListener( 'connectChildren', onConnect );
|
|
902
|
-
element.removeEventListener( 'nodeConnect', onConnect );
|
|
903
|
-
element.removeEventListener( 'nodeConnectChildren', onConnect );
|
|
904
|
-
element.removeEventListener( 'dispose', onDispose );
|
|
905
|
-
|
|
906
|
-
this.disconnectDOM = null;
|
|
907
|
-
|
|
908
|
-
};
|
|
909
|
-
|
|
910
|
-
const onConnect = () => {
|
|
911
|
-
|
|
912
|
-
this.dispatchEvent( new Event( 'connectChildren' ) );
|
|
913
|
-
|
|
914
|
-
};
|
|
915
|
-
|
|
916
|
-
const onDispose = () => {
|
|
917
|
-
|
|
918
|
-
this.connect();
|
|
919
|
-
|
|
920
|
-
};
|
|
921
|
-
|
|
922
|
-
const onClick = ( e ) => {
|
|
923
|
-
|
|
924
|
-
e.stopPropagation();
|
|
925
|
-
|
|
926
|
-
this.connect();
|
|
927
|
-
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
this.disconnectDOM.addEventListener( 'mousedown', onClick, true );
|
|
931
|
-
this.disconnectDOM.addEventListener( 'touchstart', onClick, true );
|
|
932
|
-
this.disconnectDOM.addEventListener( 'disconnect', onDisconnect, true );
|
|
933
|
-
|
|
934
|
-
element.addEventListener( 'connect', onConnect );
|
|
935
|
-
element.addEventListener( 'connectChildren', onConnect );
|
|
936
|
-
element.addEventListener( 'nodeConnect', onConnect );
|
|
937
|
-
element.addEventListener( 'nodeConnectChildren', onConnect );
|
|
938
|
-
element.addEventListener( 'dispose', onDispose );
|
|
939
|
-
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
this.dispatchEvent( new Event( 'connect' ) );
|
|
945
|
-
|
|
946
|
-
return true;
|
|
947
|
-
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
dispose() {
|
|
951
|
-
|
|
952
|
-
this.dispatchEvent( new Event( 'dispose' ) );
|
|
953
|
-
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
serialize( data ) {
|
|
957
|
-
|
|
958
|
-
const height = this.getHeight();
|
|
959
|
-
|
|
960
|
-
const inputs = [];
|
|
961
|
-
const links = [];
|
|
962
|
-
|
|
963
|
-
for ( const input of this.inputs ) {
|
|
964
|
-
|
|
965
|
-
inputs.push( input.toJSON( data ).id );
|
|
966
|
-
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
for ( const link of this.links ) {
|
|
970
|
-
|
|
971
|
-
if ( link.inputElement !== null && link.outputElement !== null ) {
|
|
972
|
-
|
|
973
|
-
links.push( link.outputElement.toJSON( data ).id );
|
|
974
|
-
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
if ( this.inputLength > 0 ) data.inputLength = this.inputLength;
|
|
980
|
-
if ( this.outputLength > 0 ) data.outputLength = this.outputLength;
|
|
981
|
-
|
|
982
|
-
if ( inputs.length > 0 ) data.inputs = inputs;
|
|
983
|
-
if ( links.length > 0 ) data.links = links;
|
|
984
|
-
|
|
985
|
-
if ( this.style !== '' ) {
|
|
986
|
-
|
|
987
|
-
data.style = this.style;
|
|
988
|
-
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
if ( height !== '' ) {
|
|
992
|
-
|
|
993
|
-
data.height = height;
|
|
994
|
-
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
deserialize( data ) {
|
|
1000
|
-
|
|
1001
|
-
if ( data.inputLength !== undefined ) this.setInput( data.inputLength );
|
|
1002
|
-
if ( data.outputLength !== undefined ) this.setOutput( data.outputLength );
|
|
1003
|
-
|
|
1004
|
-
if ( data.inputs !== undefined ) {
|
|
1005
|
-
|
|
1006
|
-
const inputs = this.inputs;
|
|
1007
|
-
|
|
1008
|
-
if ( inputs.length > 0 ) {
|
|
1009
|
-
|
|
1010
|
-
let index = 0;
|
|
1011
|
-
|
|
1012
|
-
for ( const id of data.inputs ) {
|
|
1013
|
-
|
|
1014
|
-
data.objects[ id ] = inputs[ index ++ ];
|
|
1015
|
-
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
} else {
|
|
1019
|
-
|
|
1020
|
-
for ( const id of data.inputs ) {
|
|
1021
|
-
|
|
1022
|
-
this.add( data.objects[ id ] );
|
|
1023
|
-
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
if ( data.links !== undefined ) {
|
|
1031
|
-
|
|
1032
|
-
for ( const id of data.links ) {
|
|
1033
|
-
|
|
1034
|
-
this.connect( data.objects[ id ] );
|
|
1035
|
-
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
if ( data.style !== undefined ) {
|
|
1041
|
-
|
|
1042
|
-
this.setStyle( data.style );
|
|
1043
|
-
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
if ( data.height !== undefined ) {
|
|
1047
|
-
|
|
1048
|
-
this.setHeight( data.height );
|
|
1049
|
-
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
getLinkedObject( output = null ) {
|
|
1055
|
-
|
|
1056
|
-
const linkedElement = this.getLinkedElement();
|
|
1057
|
-
|
|
1058
|
-
return linkedElement ? linkedElement.getObject( output ) : null;
|
|
1059
|
-
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
getLinkedElement() {
|
|
1063
|
-
|
|
1064
|
-
const link = this.getLink();
|
|
1065
|
-
|
|
1066
|
-
return link ? link.outputElement : null;
|
|
1067
|
-
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
getLink() {
|
|
1071
|
-
|
|
1072
|
-
return this.links[ 0 ];
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
_createIO( type ) {
|
|
1077
|
-
|
|
1078
|
-
const { dom } = this;
|
|
1079
|
-
|
|
1080
|
-
const ioDOM = document.createElement( 'f-io' );
|
|
1081
|
-
ioDOM.style.visibility = 'hidden';
|
|
1082
|
-
ioDOM.className = type;
|
|
1083
|
-
|
|
1084
|
-
const onConnectEvent = ( e ) => {
|
|
1085
|
-
|
|
1086
|
-
e.preventDefault();
|
|
1087
|
-
|
|
1088
|
-
e.stopPropagation();
|
|
1089
|
-
|
|
1090
|
-
selected = null;
|
|
1091
|
-
|
|
1092
|
-
const nodeDOM = this.node.dom;
|
|
1093
|
-
|
|
1094
|
-
nodeDOM.classList.add( 'io-connect' );
|
|
1095
|
-
|
|
1096
|
-
ioDOM.classList.add( 'connect' );
|
|
1097
|
-
dom.classList.add( 'select' );
|
|
1098
|
-
|
|
1099
|
-
const defaultOutput = Link.InputDirection === 'left' ? 'lio' : 'rio';
|
|
1100
|
-
|
|
1101
|
-
const link = type === defaultOutput ? new Link( this ) : new Link( null, this );
|
|
1102
|
-
const previewLink = new Link( link.inputElement, link.outputElement );
|
|
1103
|
-
|
|
1104
|
-
this.links.push( link );
|
|
1105
|
-
|
|
1106
|
-
draggableDOM( e, ( data ) => {
|
|
1107
|
-
|
|
1108
|
-
if ( previewLink.outputElement )
|
|
1109
|
-
previewLink.outputElement.dom.classList.remove( 'invalid' );
|
|
1110
|
-
|
|
1111
|
-
if ( previewLink.inputElement )
|
|
1112
|
-
previewLink.inputElement.dom.classList.remove( 'invalid' );
|
|
1113
|
-
|
|
1114
|
-
previewLink.inputElement = link.inputElement;
|
|
1115
|
-
previewLink.outputElement = link.outputElement;
|
|
1116
|
-
|
|
1117
|
-
if ( type === defaultOutput ) {
|
|
1118
|
-
|
|
1119
|
-
previewLink.outputElement = selected;
|
|
1120
|
-
|
|
1121
|
-
} else {
|
|
1122
|
-
|
|
1123
|
-
previewLink.inputElement = selected;
|
|
1124
|
-
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
const isInvalid = previewLink.inputElement !== null && previewLink.outputElement !== null &&
|
|
1128
|
-
previewLink.inputElement.inputLength > 0 && previewLink.outputElement.outputLength > 0 &&
|
|
1129
|
-
dispatchEventList( previewLink.inputElement.events.valid, previewLink.inputElement, previewLink.outputElement, data.dragging ? 'dragging' : 'dragged' ) === false;
|
|
1130
|
-
|
|
1131
|
-
if ( data.dragging && isInvalid ) {
|
|
1132
|
-
|
|
1133
|
-
if ( type === defaultOutput ) {
|
|
1134
|
-
|
|
1135
|
-
if ( previewLink.outputElement )
|
|
1136
|
-
previewLink.outputElement.dom.classList.add( 'invalid' );
|
|
1137
|
-
|
|
1138
|
-
} else {
|
|
1139
|
-
|
|
1140
|
-
if ( previewLink.inputElement )
|
|
1141
|
-
previewLink.inputElement.dom.classList.add( 'invalid' );
|
|
1142
|
-
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
return;
|
|
1146
|
-
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
if ( ! data.dragging ) {
|
|
1150
|
-
|
|
1151
|
-
nodeDOM.classList.remove( 'io-connect' );
|
|
1152
|
-
|
|
1153
|
-
ioDOM.classList.remove( 'connect' );
|
|
1154
|
-
dom.classList.remove( 'select' );
|
|
1155
|
-
|
|
1156
|
-
this.links.splice( this.links.indexOf( link ), 1 );
|
|
1157
|
-
|
|
1158
|
-
if ( selected !== null && ! isInvalid ) {
|
|
1159
|
-
|
|
1160
|
-
link.inputElement = previewLink.inputElement;
|
|
1161
|
-
link.outputElement = previewLink.outputElement;
|
|
1162
|
-
|
|
1163
|
-
// check if is an is circular link
|
|
1164
|
-
|
|
1165
|
-
if ( link.outputElement.node.isCircular( link.inputElement.node ) ) {
|
|
1166
|
-
|
|
1167
|
-
return;
|
|
1168
|
-
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
//
|
|
1172
|
-
|
|
1173
|
-
if ( link.inputElement.inputLength > 0 && link.outputElement.outputLength > 0 ) {
|
|
1174
|
-
|
|
1175
|
-
link.inputElement.connect( link.outputElement );
|
|
1176
|
-
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
}, { className: 'connecting' } );
|
|
1184
|
-
|
|
1185
|
-
};
|
|
1186
|
-
|
|
1187
|
-
ioDOM.addEventListener( 'mousedown', onConnectEvent, true );
|
|
1188
|
-
ioDOM.addEventListener( 'touchstart', onConnectEvent, true );
|
|
1189
|
-
|
|
1190
|
-
return ioDOM;
|
|
1191
|
-
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
Element.prototype.isElement = true;
|
|
1197
|
-
|
|
1198
|
-
class Input extends Serializer {
|
|
1199
|
-
|
|
1200
|
-
constructor( dom ) {
|
|
1201
|
-
|
|
1202
|
-
super();
|
|
1203
|
-
|
|
1204
|
-
this.dom = dom;
|
|
1205
|
-
|
|
1206
|
-
this.element = null;
|
|
1207
|
-
|
|
1208
|
-
this.extra = null;
|
|
1209
|
-
|
|
1210
|
-
this.tagColor = null;
|
|
1211
|
-
|
|
1212
|
-
this.events = {
|
|
1213
|
-
'change': [],
|
|
1214
|
-
'click': []
|
|
1215
|
-
};
|
|
1216
|
-
|
|
1217
|
-
this.addEventListener( 'change', ( ) => {
|
|
1218
|
-
|
|
1219
|
-
dispatchEventList( this.events.change, this );
|
|
1220
|
-
|
|
1221
|
-
} );
|
|
1222
|
-
|
|
1223
|
-
this.addEventListener( 'click', ( ) => {
|
|
1224
|
-
|
|
1225
|
-
dispatchEventList( this.events.click, this );
|
|
1226
|
-
|
|
1227
|
-
} );
|
|
1228
|
-
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
setExtra( value ) {
|
|
1232
|
-
|
|
1233
|
-
this.extra = value;
|
|
1234
|
-
|
|
1235
|
-
return this;
|
|
1236
|
-
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
getExtra() {
|
|
1240
|
-
|
|
1241
|
-
return this.extra;
|
|
1242
|
-
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
setTagColor( color ) {
|
|
1246
|
-
|
|
1247
|
-
this.tagColor = color;
|
|
1248
|
-
|
|
1249
|
-
this.dom.style[ 'border-left' ] = `2px solid ${color}`;
|
|
1250
|
-
|
|
1251
|
-
return this;
|
|
1252
|
-
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
getTagColor() {
|
|
1256
|
-
|
|
1257
|
-
return this.tagColor;
|
|
1258
|
-
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
setToolTip( text ) {
|
|
1262
|
-
|
|
1263
|
-
const div = document.createElement( 'f-tooltip' );
|
|
1264
|
-
div.innerText = text;
|
|
1265
|
-
|
|
1266
|
-
this.dom.append( div );
|
|
1267
|
-
|
|
1268
|
-
return this;
|
|
1269
|
-
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
onChange( callback ) {
|
|
1273
|
-
|
|
1274
|
-
this.events.change.push( callback );
|
|
1275
|
-
|
|
1276
|
-
return this;
|
|
1277
|
-
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
onClick( callback ) {
|
|
1281
|
-
|
|
1282
|
-
this.events.click.push( callback );
|
|
1283
|
-
|
|
1284
|
-
return this;
|
|
1285
|
-
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
setReadOnly( value ) {
|
|
1289
|
-
|
|
1290
|
-
this.dom.readOnly = value;
|
|
1291
|
-
|
|
1292
|
-
return this;
|
|
1293
|
-
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
getReadOnly() {
|
|
1297
|
-
|
|
1298
|
-
return this.dom.readOnly;
|
|
1299
|
-
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
setValue( value, dispatch = true ) {
|
|
1303
|
-
|
|
1304
|
-
this.dom.value = value;
|
|
1305
|
-
|
|
1306
|
-
if ( dispatch ) this.dispatchEvent( new Event( 'change' ) );
|
|
1307
|
-
|
|
1308
|
-
return this;
|
|
1309
|
-
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
getValue() {
|
|
1313
|
-
|
|
1314
|
-
return this.dom.value;
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
serialize( data ) {
|
|
1319
|
-
|
|
1320
|
-
data.value = this.getValue();
|
|
1321
|
-
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
deserialize( data ) {
|
|
1325
|
-
|
|
1326
|
-
this.setValue( data.value );
|
|
1327
|
-
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
Input.prototype.isInput = true;
|
|
1333
|
-
|
|
1334
|
-
class Node extends Serializer {
|
|
1335
|
-
|
|
1336
|
-
constructor() {
|
|
1337
|
-
|
|
1338
|
-
super();
|
|
1339
|
-
|
|
1340
|
-
const dom = document.createElement( 'f-node' );
|
|
1341
|
-
|
|
1342
|
-
const onDown = () => {
|
|
1343
|
-
|
|
1344
|
-
const canvas = this.canvas;
|
|
1345
|
-
|
|
1346
|
-
if ( canvas !== null ) {
|
|
1347
|
-
|
|
1348
|
-
canvas.select( this );
|
|
1349
|
-
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
};
|
|
1353
|
-
|
|
1354
|
-
dom.addEventListener( 'mousedown', onDown, true );
|
|
1355
|
-
dom.addEventListener( 'touchstart', onDown, true );
|
|
1356
|
-
|
|
1357
|
-
this._onConnect = ( e ) => {
|
|
1358
|
-
|
|
1359
|
-
const { target } = e;
|
|
1360
|
-
|
|
1361
|
-
for ( const element of this.elements ) {
|
|
1362
|
-
|
|
1363
|
-
if ( element !== target ) {
|
|
1364
|
-
|
|
1365
|
-
element.dispatchEvent( new Event( 'nodeConnect' ) );
|
|
1366
|
-
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
};
|
|
1372
|
-
|
|
1373
|
-
this._onConnectChildren = ( e ) => {
|
|
1374
|
-
|
|
1375
|
-
const { target } = e;
|
|
1376
|
-
|
|
1377
|
-
for ( const element of this.elements ) {
|
|
1378
|
-
|
|
1379
|
-
if ( element !== target ) {
|
|
1380
|
-
|
|
1381
|
-
element.dispatchEvent( new Event( 'nodeConnectChildren' ) );
|
|
1382
|
-
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
};
|
|
1388
|
-
|
|
1389
|
-
this.dom = dom;
|
|
1390
|
-
|
|
1391
|
-
this.style = '';
|
|
1392
|
-
|
|
1393
|
-
this.canvas = null;
|
|
1394
|
-
|
|
1395
|
-
this.elements = [];
|
|
1396
|
-
|
|
1397
|
-
this.events = {
|
|
1398
|
-
'focus': [],
|
|
1399
|
-
'blur': []
|
|
1400
|
-
};
|
|
1401
|
-
|
|
1402
|
-
this.setWidth( 300 ).setPosition( 0, 0 );
|
|
1403
|
-
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
get baseElement() {
|
|
1407
|
-
|
|
1408
|
-
return this.elements[ 0 ];
|
|
1409
|
-
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
onFocus( callback ) {
|
|
1413
|
-
|
|
1414
|
-
this.events.focus.push( callback );
|
|
1415
|
-
|
|
1416
|
-
return this;
|
|
1417
|
-
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
onBlur( callback ) {
|
|
1421
|
-
|
|
1422
|
-
this.events.blur.push( callback );
|
|
1423
|
-
|
|
1424
|
-
return this;
|
|
1425
|
-
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
setStyle( style ) {
|
|
1429
|
-
|
|
1430
|
-
const dom = this.dom;
|
|
1431
|
-
|
|
1432
|
-
if ( this.style ) dom.classList.remove( this.style );
|
|
1433
|
-
|
|
1434
|
-
if ( style ) dom.classList.add( style );
|
|
1435
|
-
|
|
1436
|
-
this.style = style;
|
|
1437
|
-
|
|
1438
|
-
return this;
|
|
1439
|
-
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
setPosition( x, y ) {
|
|
1443
|
-
|
|
1444
|
-
const dom = this.dom;
|
|
1445
|
-
|
|
1446
|
-
dom.style.left = numberToPX( x );
|
|
1447
|
-
dom.style.top = numberToPX( y );
|
|
1448
|
-
|
|
1449
|
-
return this;
|
|
1450
|
-
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
getPosition() {
|
|
1454
|
-
|
|
1455
|
-
const dom = this.dom;
|
|
1456
|
-
|
|
1457
|
-
return {
|
|
1458
|
-
x: parseInt( dom.style.left ),
|
|
1459
|
-
y: parseInt( dom.style.top )
|
|
1460
|
-
};
|
|
1461
|
-
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
setWidth( val ) {
|
|
1465
|
-
|
|
1466
|
-
this.dom.style.width = numberToPX( val );
|
|
1467
|
-
|
|
1468
|
-
return this;
|
|
1469
|
-
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
getWidth() {
|
|
1473
|
-
|
|
1474
|
-
return parseInt( this.dom.style.width );
|
|
1475
|
-
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
getHeight() {
|
|
1479
|
-
|
|
1480
|
-
return this.dom.offsetHeight;
|
|
1481
|
-
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
getBound() {
|
|
1485
|
-
|
|
1486
|
-
const { x, y } = this.getPosition();
|
|
1487
|
-
const width = this.getWidth();
|
|
1488
|
-
const height = this.getHeight();
|
|
1489
|
-
|
|
1490
|
-
return { x, y, width, height };
|
|
1491
|
-
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
add( element ) {
|
|
1495
|
-
|
|
1496
|
-
this.elements.push( element );
|
|
1497
|
-
|
|
1498
|
-
element.node = this;
|
|
1499
|
-
element.addEventListener( 'connect', this._onConnect );
|
|
1500
|
-
element.addEventListener( 'connectChildren', this._onConnectChildren );
|
|
1501
|
-
|
|
1502
|
-
this.dom.append( element.dom );
|
|
1503
|
-
|
|
1504
|
-
return this;
|
|
1505
|
-
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
remove( element ) {
|
|
1509
|
-
|
|
1510
|
-
this.elements.splice( this.elements.indexOf( element ), 1 );
|
|
1511
|
-
|
|
1512
|
-
element.node = null;
|
|
1513
|
-
element.removeEventListener( 'connect', this._onConnect );
|
|
1514
|
-
element.removeEventListener( 'connectChildren', this._onConnectChildren );
|
|
1515
|
-
|
|
1516
|
-
this.dom.removeChild( element.dom );
|
|
1517
|
-
|
|
1518
|
-
return this;
|
|
1519
|
-
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
dispose() {
|
|
1523
|
-
|
|
1524
|
-
const canvas = this.canvas;
|
|
1525
|
-
|
|
1526
|
-
if ( canvas !== null ) canvas.remove( this );
|
|
1527
|
-
|
|
1528
|
-
for ( const element of this.elements ) {
|
|
1529
|
-
|
|
1530
|
-
element.dispose();
|
|
1531
|
-
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
this.dispatchEvent( new Event( 'dispose' ) );
|
|
1535
|
-
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
isCircular( node ) {
|
|
1539
|
-
|
|
1540
|
-
if ( node === this ) return true;
|
|
1541
|
-
|
|
1542
|
-
const links = this.getLinks();
|
|
1543
|
-
|
|
1544
|
-
for ( const link of links ) {
|
|
1545
|
-
|
|
1546
|
-
if ( link.outputElement.node.isCircular( node ) ) {
|
|
1547
|
-
|
|
1548
|
-
return true;
|
|
1549
|
-
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
|
-
return false;
|
|
1555
|
-
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
getLinks() {
|
|
1559
|
-
|
|
1560
|
-
const links = [];
|
|
1561
|
-
|
|
1562
|
-
for ( const element of this.elements ) {
|
|
1563
|
-
|
|
1564
|
-
links.push( ...element.links );
|
|
1565
|
-
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
return links;
|
|
1569
|
-
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
getColor() {
|
|
1573
|
-
|
|
1574
|
-
return this.elements[ 0 ]?.getColor();
|
|
1575
|
-
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
serialize( data ) {
|
|
1579
|
-
|
|
1580
|
-
const { x, y } = this.getPosition();
|
|
1581
|
-
|
|
1582
|
-
const elements = [];
|
|
1583
|
-
|
|
1584
|
-
for ( const element of this.elements ) {
|
|
1585
|
-
|
|
1586
|
-
elements.push( element.toJSON( data ).id );
|
|
1587
|
-
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
data.x = x;
|
|
1591
|
-
data.y = y;
|
|
1592
|
-
data.width = this.getWidth();
|
|
1593
|
-
data.elements = elements;
|
|
1594
|
-
|
|
1595
|
-
if ( this.style !== '' ) {
|
|
1596
|
-
|
|
1597
|
-
data.style = this.style;
|
|
1598
|
-
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
|
-
deserialize( data ) {
|
|
1604
|
-
|
|
1605
|
-
this.setPosition( data.x, data.y );
|
|
1606
|
-
this.setWidth( data.width );
|
|
1607
|
-
|
|
1608
|
-
if ( data.style !== undefined ) {
|
|
1609
|
-
|
|
1610
|
-
this.setStyle( data.style );
|
|
1611
|
-
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
const elements = this.elements;
|
|
1615
|
-
|
|
1616
|
-
if ( elements.length > 0 ) {
|
|
1617
|
-
|
|
1618
|
-
let index = 0;
|
|
1619
|
-
|
|
1620
|
-
for ( const id of data.elements ) {
|
|
1621
|
-
|
|
1622
|
-
data.objects[ id ] = elements[ index ++ ];
|
|
1623
|
-
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
} else {
|
|
1627
|
-
|
|
1628
|
-
for ( const id of data.elements ) {
|
|
1629
|
-
|
|
1630
|
-
this.add( data.objects[ id ] );
|
|
1631
|
-
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
Node.prototype.isNode = true;
|
|
1641
|
-
|
|
1642
|
-
class DraggableElement extends Element {
|
|
1643
|
-
|
|
1644
|
-
constructor( draggable = true ) {
|
|
1645
|
-
|
|
1646
|
-
super( true );
|
|
1647
|
-
|
|
1648
|
-
this.draggable = draggable;
|
|
1649
|
-
|
|
1650
|
-
const onDrag = ( e ) => {
|
|
1651
|
-
|
|
1652
|
-
e.preventDefault();
|
|
1653
|
-
|
|
1654
|
-
if ( this.draggable === true ) {
|
|
1655
|
-
|
|
1656
|
-
draggableDOM( this.node.dom, null, { className: 'dragging node' } );
|
|
1657
|
-
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
};
|
|
1661
|
-
|
|
1662
|
-
const { dom } = this;
|
|
1663
|
-
|
|
1664
|
-
dom.addEventListener( 'mousedown', onDrag, true );
|
|
1665
|
-
dom.addEventListener( 'touchstart', onDrag, true );
|
|
1666
|
-
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
class TitleElement extends DraggableElement {
|
|
1672
|
-
|
|
1673
|
-
constructor( title, draggable = true ) {
|
|
1674
|
-
|
|
1675
|
-
super( draggable );
|
|
1676
|
-
|
|
1677
|
-
const { dom } = this;
|
|
1678
|
-
|
|
1679
|
-
dom.className = 'title';
|
|
1680
|
-
|
|
1681
|
-
const dbClick = () => {
|
|
1682
|
-
|
|
1683
|
-
this.node.canvas.focusSelected = ! this.node.canvas.focusSelected;
|
|
1684
|
-
|
|
1685
|
-
};
|
|
1686
|
-
|
|
1687
|
-
dom.addEventListener( 'dblclick', dbClick );
|
|
1688
|
-
|
|
1689
|
-
const titleDOM = document.createElement( 'f-title' );
|
|
1690
|
-
titleDOM.innerText = title;
|
|
1691
|
-
|
|
1692
|
-
const iconDOM = document.createElement( 'i' );
|
|
1693
|
-
|
|
1694
|
-
const toolbarDOM = document.createElement( 'f-toolbar' );
|
|
1695
|
-
|
|
1696
|
-
this.buttons = [];
|
|
1697
|
-
|
|
1698
|
-
this.titleDOM = titleDOM;
|
|
1699
|
-
this.iconDOM = iconDOM;
|
|
1700
|
-
this.toolbarDOM = toolbarDOM;
|
|
1701
|
-
|
|
1702
|
-
dom.append( titleDOM );
|
|
1703
|
-
dom.append( iconDOM );
|
|
1704
|
-
dom.append( toolbarDOM );
|
|
1705
|
-
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
|
-
setIcon( value ) {
|
|
1709
|
-
|
|
1710
|
-
this.iconDOM.className = value;
|
|
1711
|
-
|
|
1712
|
-
return this;
|
|
1713
|
-
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
getIcon() {
|
|
1717
|
-
|
|
1718
|
-
return this.iconDOM.className;
|
|
1719
|
-
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
setTitle( value ) {
|
|
1723
|
-
|
|
1724
|
-
this.titleDOM.innerText = value;
|
|
1725
|
-
|
|
1726
|
-
return this;
|
|
1727
|
-
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
getTitle() {
|
|
1731
|
-
|
|
1732
|
-
return this.titleDOM.innerText;
|
|
1733
|
-
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
addButton( button ) {
|
|
1737
|
-
|
|
1738
|
-
this.buttons.push( button );
|
|
1739
|
-
|
|
1740
|
-
this.toolbarDOM.append( button.dom );
|
|
1741
|
-
|
|
1742
|
-
return this;
|
|
1743
|
-
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
serialize( data ) {
|
|
1747
|
-
|
|
1748
|
-
super.serialize( data );
|
|
1749
|
-
|
|
1750
|
-
const title = this.getTitle();
|
|
1751
|
-
const icon = this.getIcon();
|
|
1752
|
-
|
|
1753
|
-
data.title = title;
|
|
1754
|
-
|
|
1755
|
-
if ( icon !== '' ) {
|
|
1756
|
-
|
|
1757
|
-
data.icon = icon;
|
|
1758
|
-
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
}
|
|
1762
|
-
|
|
1763
|
-
deserialize( data ) {
|
|
1764
|
-
|
|
1765
|
-
super.deserialize( data );
|
|
1766
|
-
|
|
1767
|
-
this.setTitle( data.title );
|
|
1768
|
-
|
|
1769
|
-
if ( data.icon !== undefined ) {
|
|
1770
|
-
|
|
1771
|
-
this.setIcon( data.icon );
|
|
1772
|
-
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
const drawLine = ( p1x, p1y, p2x, p2y, invert, size, colorA, ctx, colorB = null ) => {
|
|
1780
|
-
|
|
1781
|
-
const dx = p2x - p1x;
|
|
1782
|
-
const dy = p2y - p1y;
|
|
1783
|
-
const offset = Math.sqrt( ( dx * dx ) + ( dy * dy ) ) * ( invert ? - .3 : .3 );
|
|
1784
|
-
|
|
1785
|
-
ctx.beginPath();
|
|
1786
|
-
|
|
1787
|
-
ctx.moveTo( p1x, p1y );
|
|
1788
|
-
|
|
1789
|
-
ctx.bezierCurveTo(
|
|
1790
|
-
p1x + offset, p1y,
|
|
1791
|
-
p2x - offset, p2y,
|
|
1792
|
-
p2x, p2y
|
|
1793
|
-
);
|
|
1794
|
-
|
|
1795
|
-
if ( colorB !== null && colorA !== colorB ) {
|
|
1796
|
-
|
|
1797
|
-
const gradient = ctx.createLinearGradient( p1x, p1y, p2x, p2y );
|
|
1798
|
-
gradient.addColorStop( 0, colorA );
|
|
1799
|
-
gradient.addColorStop( 1, colorB );
|
|
1800
|
-
|
|
1801
|
-
ctx.strokeStyle = gradient;
|
|
1802
|
-
|
|
1803
|
-
} else {
|
|
1804
|
-
|
|
1805
|
-
ctx.strokeStyle = colorA;
|
|
1806
|
-
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
ctx.lineWidth = size;
|
|
1810
|
-
ctx.stroke();
|
|
1811
|
-
|
|
1812
|
-
};
|
|
1813
|
-
|
|
1814
|
-
const colors = [
|
|
1815
|
-
'#ff4444',
|
|
1816
|
-
'#44ff44',
|
|
1817
|
-
'#4444ff'
|
|
1818
|
-
];
|
|
1819
|
-
|
|
1820
|
-
const dropNode = new Node().add( new TitleElement( 'File' ) ).setWidth( 250 );
|
|
1821
|
-
|
|
1822
|
-
class Canvas extends Serializer {
|
|
1823
|
-
|
|
1824
|
-
constructor() {
|
|
1825
|
-
|
|
1826
|
-
super();
|
|
1827
|
-
|
|
1828
|
-
const dom = document.createElement( 'f-canvas' );
|
|
1829
|
-
const contentDOM = document.createElement( 'f-content' );
|
|
1830
|
-
const areaDOM = document.createElement( 'f-area' );
|
|
1831
|
-
const dropDOM = document.createElement( 'f-drop' );
|
|
1832
|
-
|
|
1833
|
-
const canvas = document.createElement( 'canvas' );
|
|
1834
|
-
const frontCanvas = document.createElement( 'canvas' );
|
|
1835
|
-
const mapCanvas = document.createElement( 'canvas' );
|
|
1836
|
-
|
|
1837
|
-
const context = canvas.getContext( '2d' );
|
|
1838
|
-
const frontContext = frontCanvas.getContext( '2d' );
|
|
1839
|
-
const mapContext = mapCanvas.getContext( '2d' );
|
|
1840
|
-
|
|
1841
|
-
this.dom = dom;
|
|
1842
|
-
|
|
1843
|
-
this.contentDOM = contentDOM;
|
|
1844
|
-
this.areaDOM = areaDOM;
|
|
1845
|
-
this.dropDOM = dropDOM;
|
|
1846
|
-
|
|
1847
|
-
this.canvas = canvas;
|
|
1848
|
-
this.frontCanvas = frontCanvas;
|
|
1849
|
-
this.mapCanvas = mapCanvas;
|
|
1850
|
-
|
|
1851
|
-
this.context = context;
|
|
1852
|
-
this.frontContext = frontContext;
|
|
1853
|
-
this.mapContext = mapContext;
|
|
1854
|
-
|
|
1855
|
-
this.clientX = 0;
|
|
1856
|
-
this.clientY = 0;
|
|
1857
|
-
|
|
1858
|
-
this.relativeClientX = 0;
|
|
1859
|
-
this.relativeClientY = 0;
|
|
1860
|
-
|
|
1861
|
-
this.nodes = [];
|
|
1862
|
-
|
|
1863
|
-
this.selected = null;
|
|
1864
|
-
|
|
1865
|
-
this.updating = false;
|
|
1866
|
-
|
|
1867
|
-
this.droppedItems = [];
|
|
1868
|
-
|
|
1869
|
-
this.events = {
|
|
1870
|
-
'drop': []
|
|
1871
|
-
};
|
|
1872
|
-
|
|
1873
|
-
this._scrollLeft = 0;
|
|
1874
|
-
this._scrollTop = 0;
|
|
1875
|
-
this._zoom = 1;
|
|
1876
|
-
this._width = 0;
|
|
1877
|
-
this._height = 0;
|
|
1878
|
-
this._focusSelected = false;
|
|
1879
|
-
this._mapInfo = {
|
|
1880
|
-
scale: 1,
|
|
1881
|
-
screen: {}
|
|
1882
|
-
};
|
|
1883
|
-
|
|
1884
|
-
canvas.className = 'background';
|
|
1885
|
-
frontCanvas.className = 'frontground';
|
|
1886
|
-
mapCanvas.className = 'map';
|
|
1887
|
-
|
|
1888
|
-
dropDOM.innerHTML = '<span>drop your file</span>';
|
|
1889
|
-
|
|
1890
|
-
dom.append( dropDOM );
|
|
1891
|
-
dom.append( canvas );
|
|
1892
|
-
dom.append( frontCanvas );
|
|
1893
|
-
dom.append( contentDOM );
|
|
1894
|
-
dom.append( areaDOM );
|
|
1895
|
-
dom.append( mapCanvas );
|
|
1896
|
-
|
|
1897
|
-
const zoomTo = ( zoom, clientX = this.clientX, clientY = this.clientY ) => {
|
|
1898
|
-
|
|
1899
|
-
zoom = Math.min( Math.max( zoom, .2 ), 1 );
|
|
1900
|
-
|
|
1901
|
-
this.scrollLeft -= ( clientX / this.zoom ) - ( clientX / zoom );
|
|
1902
|
-
this.scrollTop -= ( clientY / this.zoom ) - ( clientY / zoom );
|
|
1903
|
-
this.zoom = zoom;
|
|
1904
|
-
|
|
1905
|
-
};
|
|
1906
|
-
|
|
1907
|
-
let touchData = null;
|
|
1908
|
-
|
|
1909
|
-
const onTouchStart = () => {
|
|
1910
|
-
|
|
1911
|
-
touchData = null;
|
|
1912
|
-
|
|
1913
|
-
};
|
|
1914
|
-
|
|
1915
|
-
const onMouseZoom = ( e ) => {
|
|
1916
|
-
|
|
1917
|
-
e.preventDefault();
|
|
1918
|
-
|
|
1919
|
-
e.stopImmediatePropagation();
|
|
1920
|
-
|
|
1921
|
-
const delta = e.deltaY * .003;
|
|
1922
|
-
|
|
1923
|
-
zoomTo( this.zoom - delta );
|
|
1924
|
-
|
|
1925
|
-
};
|
|
1926
|
-
|
|
1927
|
-
const onTouchZoom = ( e ) => {
|
|
1928
|
-
|
|
1929
|
-
if ( e.touches && e.touches.length === 2 ) {
|
|
1930
|
-
|
|
1931
|
-
e.preventDefault();
|
|
1932
|
-
|
|
1933
|
-
e.stopImmediatePropagation();
|
|
1934
|
-
|
|
1935
|
-
const clientX = ( e.touches[ 0 ].clientX + e.touches[ 1 ].clientX ) / 2;
|
|
1936
|
-
const clientY = ( e.touches[ 0 ].clientY + e.touches[ 1 ].clientY ) / 2;
|
|
1937
|
-
|
|
1938
|
-
const distance = Math.hypot(
|
|
1939
|
-
e.touches[ 0 ].clientX - e.touches[ 1 ].clientX,
|
|
1940
|
-
e.touches[ 0 ].clientY - e.touches[ 1 ].clientY
|
|
1941
|
-
);
|
|
1942
|
-
|
|
1943
|
-
if ( touchData === null ) {
|
|
1944
|
-
|
|
1945
|
-
touchData = {
|
|
1946
|
-
distance
|
|
1947
|
-
};
|
|
1948
|
-
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
const delta = ( touchData.distance - distance ) * .003;
|
|
1952
|
-
touchData.distance = distance;
|
|
1953
|
-
|
|
1954
|
-
zoomTo( this.zoom - delta, clientX, clientY );
|
|
1955
|
-
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
|
-
};
|
|
1959
|
-
|
|
1960
|
-
const onTouchMove = ( e ) => {
|
|
1961
|
-
|
|
1962
|
-
if ( e.touches && e.touches.length === 1 ) {
|
|
1963
|
-
|
|
1964
|
-
e.preventDefault();
|
|
1965
|
-
|
|
1966
|
-
e.stopImmediatePropagation();
|
|
1967
|
-
|
|
1968
|
-
const clientX = e.touches[ 0 ].clientX;
|
|
1969
|
-
const clientY = e.touches[ 0 ].clientY;
|
|
1970
|
-
|
|
1971
|
-
if ( touchData === null ) {
|
|
1972
|
-
|
|
1973
|
-
const { scrollLeft, scrollTop } = this;
|
|
1974
|
-
|
|
1975
|
-
touchData = {
|
|
1976
|
-
scrollLeft,
|
|
1977
|
-
scrollTop,
|
|
1978
|
-
clientX,
|
|
1979
|
-
clientY
|
|
1980
|
-
};
|
|
1981
|
-
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
const zoom = this.zoom;
|
|
1985
|
-
|
|
1986
|
-
this.scrollLeft = touchData.scrollLeft + ( ( clientX - touchData.clientX ) / zoom );
|
|
1987
|
-
this.scrollTop = touchData.scrollTop + ( ( clientY - touchData.clientY ) / zoom );
|
|
1988
|
-
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
};
|
|
1992
|
-
|
|
1993
|
-
dom.addEventListener( 'wheel', onMouseZoom );
|
|
1994
|
-
dom.addEventListener( 'touchmove', onTouchZoom );
|
|
1995
|
-
dom.addEventListener( 'touchstart', onTouchStart );
|
|
1996
|
-
canvas.addEventListener( 'touchmove', onTouchMove );
|
|
1997
|
-
|
|
1998
|
-
let dropEnterCount = 0;
|
|
1999
|
-
|
|
2000
|
-
const dragState = ( enter ) => {
|
|
2001
|
-
|
|
2002
|
-
if ( enter ) {
|
|
2003
|
-
|
|
2004
|
-
if ( dropEnterCount ++ === 0 ) {
|
|
2005
|
-
|
|
2006
|
-
this.droppedItems = [];
|
|
2007
|
-
|
|
2008
|
-
dropDOM.classList.add( 'visible' );
|
|
2009
|
-
|
|
2010
|
-
this.add( dropNode );
|
|
2011
|
-
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
} else if ( -- dropEnterCount === 0 ) {
|
|
2015
|
-
|
|
2016
|
-
dropDOM.classList.remove( 'visible' );
|
|
2017
|
-
|
|
2018
|
-
this.remove( dropNode );
|
|
2019
|
-
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
};
|
|
2023
|
-
|
|
2024
|
-
dom.addEventListener( 'dragenter', () => {
|
|
2025
|
-
|
|
2026
|
-
dragState( true );
|
|
2027
|
-
|
|
2028
|
-
} );
|
|
2029
|
-
|
|
2030
|
-
dom.addEventListener( 'dragleave', () => {
|
|
2031
|
-
|
|
2032
|
-
dragState( false );
|
|
2033
|
-
|
|
2034
|
-
} );
|
|
2035
|
-
|
|
2036
|
-
dom.addEventListener( 'dragover', ( e ) => {
|
|
2037
|
-
|
|
2038
|
-
e.preventDefault();
|
|
2039
|
-
|
|
2040
|
-
const { relativeClientX, relativeClientY } = this;
|
|
2041
|
-
|
|
2042
|
-
const centerNodeX = dropNode.getWidth() / 2;
|
|
2043
|
-
|
|
2044
|
-
dropNode.setPosition( relativeClientX - centerNodeX, relativeClientY - 20 );
|
|
2045
|
-
|
|
2046
|
-
} );
|
|
2047
|
-
|
|
2048
|
-
dom.addEventListener( 'drop', ( e ) => {
|
|
2049
|
-
|
|
2050
|
-
e.preventDefault();
|
|
2051
|
-
|
|
2052
|
-
dragState( false );
|
|
2053
|
-
|
|
2054
|
-
this.droppedItems = e.dataTransfer.items;
|
|
2055
|
-
|
|
2056
|
-
dispatchEventList( this.events.drop, this );
|
|
2057
|
-
|
|
2058
|
-
} );
|
|
2059
|
-
|
|
2060
|
-
draggableDOM( dom, ( data ) => {
|
|
2061
|
-
|
|
2062
|
-
const { delta, isTouch } = data;
|
|
2063
|
-
|
|
2064
|
-
if ( ! isTouch ) {
|
|
2065
|
-
|
|
2066
|
-
if ( data.scrollTop === undefined ) {
|
|
2067
|
-
|
|
2068
|
-
data.scrollLeft = this.scrollLeft;
|
|
2069
|
-
data.scrollTop = this.scrollTop;
|
|
2070
|
-
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
|
-
const zoom = this.zoom;
|
|
2074
|
-
|
|
2075
|
-
this.scrollLeft = data.scrollLeft + ( delta.x / zoom );
|
|
2076
|
-
this.scrollTop = data.scrollTop + ( delta.y / zoom );
|
|
2077
|
-
|
|
2078
|
-
}
|
|
2079
|
-
|
|
2080
|
-
if ( data.dragging ) {
|
|
2081
|
-
|
|
2082
|
-
dom.classList.add( 'grabbing' );
|
|
2083
|
-
|
|
2084
|
-
} else {
|
|
2085
|
-
|
|
2086
|
-
dom.classList.remove( 'grabbing' );
|
|
2087
|
-
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
}, { className: 'dragging-canvas' } );
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
draggableDOM( mapCanvas, ( data ) => {
|
|
2094
|
-
|
|
2095
|
-
const { scale, screen } = this._mapInfo;
|
|
2096
|
-
|
|
2097
|
-
if ( data.scrollLeft === undefined ) {
|
|
2098
|
-
|
|
2099
|
-
const rect = this.mapCanvas.getBoundingClientRect();
|
|
2100
|
-
|
|
2101
|
-
const clientMapX = data.client.x - rect.left;
|
|
2102
|
-
const clientMapY = data.client.y - rect.top;
|
|
2103
|
-
|
|
2104
|
-
const overMapScreen =
|
|
2105
|
-
clientMapX > screen.x && clientMapY > screen.y &&
|
|
2106
|
-
clientMapX < screen.x + screen.width && clientMapY < screen.y + screen.height;
|
|
2107
|
-
|
|
2108
|
-
if ( overMapScreen === false ) {
|
|
2109
|
-
|
|
2110
|
-
const scaleX = this._mapInfo.width / this.mapCanvas.width;
|
|
2111
|
-
|
|
2112
|
-
let scrollLeft = - this._mapInfo.left - ( clientMapX * scaleX );
|
|
2113
|
-
let scrollTop = - this._mapInfo.top - ( clientMapY * ( this._mapInfo.height / this.mapCanvas.height ) );
|
|
2114
|
-
|
|
2115
|
-
scrollLeft += ( screen.width / 2 ) / scale;
|
|
2116
|
-
scrollTop += ( screen.height / 2 ) / scale;
|
|
2117
|
-
|
|
2118
|
-
this.scrollLeft = scrollLeft;
|
|
2119
|
-
this.scrollTop = scrollTop;
|
|
2120
|
-
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
data.scrollLeft = this.scrollLeft;
|
|
2124
|
-
data.scrollTop = this.scrollTop;
|
|
2125
|
-
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
this.scrollLeft = data.scrollLeft - ( data.delta.x / scale );
|
|
2129
|
-
this.scrollTop = data.scrollTop - ( data.delta.y / scale );
|
|
2130
|
-
|
|
2131
|
-
}, { click: true } );
|
|
2132
|
-
|
|
2133
|
-
this._onMoveEvent = ( e ) => {
|
|
2134
|
-
|
|
2135
|
-
const event = e.touches ? e.touches[ 0 ] : e;
|
|
2136
|
-
const { zoom, rect } = this;
|
|
2137
|
-
|
|
2138
|
-
this.clientX = event.clientX;
|
|
2139
|
-
this.clientY = event.clientY;
|
|
2140
|
-
|
|
2141
|
-
const rectClientX = ( this.clientX - rect.left ) / zoom;
|
|
2142
|
-
const rectClientY = ( this.clientY - rect.top ) / zoom;
|
|
2143
|
-
|
|
2144
|
-
this.relativeClientX = rectClientX - this.scrollLeft;
|
|
2145
|
-
this.relativeClientY = rectClientY - this.scrollTop;
|
|
2146
|
-
|
|
2147
|
-
};
|
|
2148
|
-
|
|
2149
|
-
this._onUpdate = () => {
|
|
2150
|
-
|
|
2151
|
-
this.update();
|
|
2152
|
-
|
|
2153
|
-
};
|
|
2154
|
-
|
|
2155
|
-
this.start();
|
|
2156
|
-
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
getBounds() {
|
|
2160
|
-
|
|
2161
|
-
const bounds = { x: Infinity, y: Infinity, width: - Infinity, height: - Infinity };
|
|
2162
|
-
|
|
2163
|
-
for ( const node of this.nodes ) {
|
|
2164
|
-
|
|
2165
|
-
const { x, y, width, height } = node.getBound();
|
|
2166
|
-
|
|
2167
|
-
bounds.x = Math.min( bounds.x, x );
|
|
2168
|
-
bounds.y = Math.min( bounds.y, y );
|
|
2169
|
-
bounds.width = Math.max( bounds.width, x + width );
|
|
2170
|
-
bounds.height = Math.max( bounds.height, y + height );
|
|
2171
|
-
|
|
2172
|
-
}
|
|
2173
|
-
|
|
2174
|
-
bounds.x = Math.round( bounds.x );
|
|
2175
|
-
bounds.y = Math.round( bounds.y );
|
|
2176
|
-
bounds.width = Math.round( bounds.width );
|
|
2177
|
-
bounds.height = Math.round( bounds.height );
|
|
2178
|
-
|
|
2179
|
-
return bounds;
|
|
2180
|
-
|
|
2181
|
-
}
|
|
2182
|
-
|
|
2183
|
-
get width() {
|
|
2184
|
-
|
|
2185
|
-
return this._width;
|
|
2186
|
-
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
get height() {
|
|
2190
|
-
|
|
2191
|
-
return this._height;
|
|
2192
|
-
|
|
2193
|
-
}
|
|
2194
|
-
|
|
2195
|
-
get rect() {
|
|
2196
|
-
|
|
2197
|
-
return this.dom.getBoundingClientRect();
|
|
2198
|
-
|
|
2199
|
-
}
|
|
2200
|
-
|
|
2201
|
-
get zoom() {
|
|
2202
|
-
|
|
2203
|
-
return this._zoom;
|
|
2204
|
-
|
|
2205
|
-
}
|
|
2206
|
-
|
|
2207
|
-
set zoom( val ) {
|
|
2208
|
-
|
|
2209
|
-
this._zoom = val;
|
|
2210
|
-
this.contentDOM.style.zoom = val;
|
|
2211
|
-
|
|
2212
|
-
}
|
|
2213
|
-
|
|
2214
|
-
set scrollLeft( val ) {
|
|
2215
|
-
|
|
2216
|
-
this._scrollLeft = val;
|
|
2217
|
-
this.contentDOM.style.left = numberToPX( val );
|
|
2218
|
-
|
|
2219
|
-
}
|
|
2220
|
-
|
|
2221
|
-
get scrollLeft() {
|
|
2222
|
-
|
|
2223
|
-
return this._scrollLeft;
|
|
2224
|
-
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2227
|
-
set scrollTop( val ) {
|
|
2228
|
-
|
|
2229
|
-
this._scrollTop = val;
|
|
2230
|
-
this.contentDOM.style.top = numberToPX( val );
|
|
2231
|
-
|
|
2232
|
-
}
|
|
2233
|
-
|
|
2234
|
-
get scrollTop() {
|
|
2235
|
-
|
|
2236
|
-
return this._scrollTop;
|
|
2237
|
-
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
|
-
set focusSelected( value ) {
|
|
2241
|
-
|
|
2242
|
-
if ( this._focusSelected === value ) return;
|
|
2243
|
-
|
|
2244
|
-
const classList = this.dom.classList;
|
|
2245
|
-
|
|
2246
|
-
this._focusSelected = value;
|
|
2247
|
-
|
|
2248
|
-
if ( value ) {
|
|
2249
|
-
|
|
2250
|
-
classList.add( 'focusing' );
|
|
2251
|
-
|
|
2252
|
-
} else {
|
|
2253
|
-
|
|
2254
|
-
classList.remove( 'focusing' );
|
|
2255
|
-
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
get focusSelected() {
|
|
2261
|
-
|
|
2262
|
-
return this._focusSelected;
|
|
2263
|
-
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
|
-
onDrop( callback ) {
|
|
2267
|
-
|
|
2268
|
-
this.events.drop.push( callback );
|
|
2269
|
-
|
|
2270
|
-
return this;
|
|
2271
|
-
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
start() {
|
|
2275
|
-
|
|
2276
|
-
this.updating = true;
|
|
2277
|
-
|
|
2278
|
-
document.addEventListener( 'wheel', this._onMoveEvent, true );
|
|
2279
|
-
|
|
2280
|
-
document.addEventListener( 'mousedown', this._onMoveEvent, true );
|
|
2281
|
-
document.addEventListener( 'touchstart', this._onMoveEvent, true );
|
|
2282
|
-
|
|
2283
|
-
document.addEventListener( 'mousemove', this._onMoveEvent, true );
|
|
2284
|
-
document.addEventListener( 'touchmove', this._onMoveEvent, true );
|
|
2285
|
-
|
|
2286
|
-
document.addEventListener( 'dragover', this._onMoveEvent, true );
|
|
2287
|
-
|
|
2288
|
-
requestAnimationFrame( this._onUpdate );
|
|
2289
|
-
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
|
-
stop() {
|
|
2293
|
-
|
|
2294
|
-
this.updating = false;
|
|
2295
|
-
|
|
2296
|
-
document.removeEventListener( 'wheel', this._onMoveEvent, true );
|
|
2297
|
-
|
|
2298
|
-
document.removeEventListener( 'mousedown', this._onMoveEvent, true );
|
|
2299
|
-
document.removeEventListener( 'touchstart', this._onMoveEvent, true );
|
|
2300
|
-
|
|
2301
|
-
document.removeEventListener( 'mousemove', this._onMoveEvent, true );
|
|
2302
|
-
document.removeEventListener( 'touchmove', this._onMoveEvent, true );
|
|
2303
|
-
|
|
2304
|
-
document.removeEventListener( 'dragover', this._onMoveEvent, true );
|
|
2305
|
-
|
|
2306
|
-
}
|
|
2307
|
-
|
|
2308
|
-
add( node ) {
|
|
2309
|
-
|
|
2310
|
-
if ( node.canvas === this ) return;
|
|
2311
|
-
|
|
2312
|
-
this.nodes.push( node );
|
|
2313
|
-
|
|
2314
|
-
node.canvas = this;
|
|
2315
|
-
|
|
2316
|
-
this.contentDOM.append( node.dom );
|
|
2317
|
-
|
|
2318
|
-
return this;
|
|
2319
|
-
|
|
2320
|
-
}
|
|
2321
|
-
|
|
2322
|
-
remove( node ) {
|
|
2323
|
-
|
|
2324
|
-
if ( node === this.selected ) {
|
|
2325
|
-
|
|
2326
|
-
this.select();
|
|
2327
|
-
|
|
2328
|
-
}
|
|
2329
|
-
|
|
2330
|
-
this.unlink( node );
|
|
2331
|
-
|
|
2332
|
-
const nodes = this.nodes;
|
|
2333
|
-
|
|
2334
|
-
nodes.splice( nodes.indexOf( node ), 1 );
|
|
2335
|
-
|
|
2336
|
-
node.canvas = null;
|
|
2337
|
-
|
|
2338
|
-
this.contentDOM.removeChild( node.dom );
|
|
2339
|
-
|
|
2340
|
-
node.dispatchEvent( new Event( 'remove' ) );
|
|
2341
|
-
|
|
2342
|
-
return this;
|
|
2343
|
-
|
|
2344
|
-
}
|
|
2345
|
-
|
|
2346
|
-
clear() {
|
|
2347
|
-
|
|
2348
|
-
const nodes = this.nodes;
|
|
2349
|
-
|
|
2350
|
-
while ( nodes.length > 0 ) {
|
|
2351
|
-
|
|
2352
|
-
this.remove( nodes[ 0 ] );
|
|
2353
|
-
|
|
2354
|
-
}
|
|
2355
|
-
|
|
2356
|
-
return this;
|
|
2357
|
-
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
unlink( node ) {
|
|
2361
|
-
|
|
2362
|
-
const links = this.getLinks();
|
|
2363
|
-
|
|
2364
|
-
for ( const link of links ) {
|
|
2365
|
-
|
|
2366
|
-
if ( link.inputElement && link.outputElement ) {
|
|
2367
|
-
|
|
2368
|
-
if ( link.inputElement.node === node ) {
|
|
2369
|
-
|
|
2370
|
-
link.inputElement.connect();
|
|
2371
|
-
|
|
2372
|
-
} else if ( link.outputElement.node === node ) {
|
|
2373
|
-
|
|
2374
|
-
link.inputElement.connect();
|
|
2375
|
-
|
|
2376
|
-
}
|
|
2377
|
-
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
}
|
|
2381
|
-
|
|
2382
|
-
}
|
|
2383
|
-
|
|
2384
|
-
getLinks() {
|
|
2385
|
-
|
|
2386
|
-
const links = [];
|
|
2387
|
-
|
|
2388
|
-
for ( const node of this.nodes ) {
|
|
2389
|
-
|
|
2390
|
-
links.push( ...node.getLinks() );
|
|
2391
|
-
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
return links;
|
|
2395
|
-
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
centralize() {
|
|
2399
|
-
|
|
2400
|
-
const bounds = this.getBounds();
|
|
2401
|
-
|
|
2402
|
-
this.scrollLeft = ( this.canvas.width / 2 ) - ( ( - bounds.x + bounds.width ) / 2 );
|
|
2403
|
-
this.scrollTop = ( this.canvas.height / 2 ) - ( ( - bounds.y + bounds.height ) / 2 );
|
|
2404
|
-
|
|
2405
|
-
return this;
|
|
2406
|
-
|
|
2407
|
-
}
|
|
2408
|
-
|
|
2409
|
-
setSize( width, height ) {
|
|
2410
|
-
|
|
2411
|
-
this._width = width;
|
|
2412
|
-
this._height = height;
|
|
2413
|
-
|
|
2414
|
-
this.update();
|
|
2415
|
-
|
|
2416
|
-
return this;
|
|
2417
|
-
|
|
2418
|
-
}
|
|
2419
|
-
|
|
2420
|
-
select( node = null ) {
|
|
2421
|
-
|
|
2422
|
-
if ( node === this.selected ) return;
|
|
2423
|
-
|
|
2424
|
-
const previousNode = this.selected;
|
|
2425
|
-
|
|
2426
|
-
if ( previousNode !== null ) {
|
|
2427
|
-
|
|
2428
|
-
this.focusSelected = false;
|
|
2429
|
-
|
|
2430
|
-
previousNode.dom.classList.remove( 'selected' );
|
|
2431
|
-
|
|
2432
|
-
this.selected = null;
|
|
2433
|
-
|
|
2434
|
-
dispatchEventList( previousNode.events.blur, previousNode );
|
|
2435
|
-
|
|
2436
|
-
}
|
|
2437
|
-
|
|
2438
|
-
if ( node !== null ) {
|
|
2439
|
-
|
|
2440
|
-
node.dom.classList.add( 'selected' );
|
|
2441
|
-
|
|
2442
|
-
this.selected = node;
|
|
2443
|
-
|
|
2444
|
-
dispatchEventList( node.events.focus, node );
|
|
2445
|
-
|
|
2446
|
-
}
|
|
2447
|
-
|
|
2448
|
-
}
|
|
2449
|
-
|
|
2450
|
-
updateMap() {
|
|
2451
|
-
|
|
2452
|
-
const { nodes, mapCanvas, mapContext, scrollLeft, scrollTop, canvas, zoom, _mapInfo } = this;
|
|
2453
|
-
|
|
2454
|
-
const bounds = this.getBounds();
|
|
2455
|
-
|
|
2456
|
-
mapCanvas.width = 300;
|
|
2457
|
-
mapCanvas.height = 200;
|
|
2458
|
-
|
|
2459
|
-
mapContext.clearRect( 0, 0, mapCanvas.width, mapCanvas.height );
|
|
2460
|
-
|
|
2461
|
-
mapContext.fillStyle = 'rgba( 0, 0, 0, 0 )';
|
|
2462
|
-
mapContext.fillRect( 0, 0, mapCanvas.width, mapCanvas.height );
|
|
2463
|
-
|
|
2464
|
-
const boundsWidth = - bounds.x + bounds.width;
|
|
2465
|
-
const boundsHeight = - bounds.y + bounds.height;
|
|
2466
|
-
|
|
2467
|
-
const mapScale = Math.min( mapCanvas.width / boundsWidth, mapCanvas.height / boundsHeight ) * .5;
|
|
2468
|
-
|
|
2469
|
-
const boundsMapWidth = boundsWidth * mapScale;
|
|
2470
|
-
const boundsMapHeight = boundsHeight * mapScale;
|
|
2471
|
-
|
|
2472
|
-
const boundsOffsetX = ( mapCanvas.width / 2 ) - ( boundsMapWidth / 2 );
|
|
2473
|
-
const boundsOffsetY = ( mapCanvas.height / 2 ) - ( boundsMapHeight / 2 );
|
|
2474
|
-
|
|
2475
|
-
let selectedNode = null;
|
|
2476
|
-
|
|
2477
|
-
for ( const node of nodes ) {
|
|
2478
|
-
|
|
2479
|
-
const nodeBound = node.getBound();
|
|
2480
|
-
const nodeColor = node.getColor();
|
|
2481
|
-
|
|
2482
|
-
nodeBound.x += - bounds.x;
|
|
2483
|
-
nodeBound.y += - bounds.y;
|
|
2484
|
-
|
|
2485
|
-
nodeBound.x *= mapScale;
|
|
2486
|
-
nodeBound.y *= mapScale;
|
|
2487
|
-
nodeBound.width *= mapScale;
|
|
2488
|
-
nodeBound.height *= mapScale;
|
|
2489
|
-
|
|
2490
|
-
nodeBound.x += boundsOffsetX;
|
|
2491
|
-
nodeBound.y += boundsOffsetY;
|
|
2492
|
-
|
|
2493
|
-
if ( node !== this.selected ) {
|
|
2494
|
-
|
|
2495
|
-
mapContext.fillStyle = nodeColor;
|
|
2496
|
-
mapContext.fillRect( nodeBound.x, nodeBound.y, nodeBound.width, nodeBound.height );
|
|
2497
|
-
|
|
2498
|
-
} else {
|
|
2499
|
-
|
|
2500
|
-
selectedNode = {
|
|
2501
|
-
nodeBound,
|
|
2502
|
-
nodeColor
|
|
2503
|
-
};
|
|
2504
|
-
|
|
2505
|
-
}
|
|
2506
|
-
|
|
2507
|
-
}
|
|
2508
|
-
|
|
2509
|
-
if ( selectedNode !== null ) {
|
|
2510
|
-
|
|
2511
|
-
const { nodeBound, nodeColor } = selectedNode;
|
|
2512
|
-
|
|
2513
|
-
mapContext.fillStyle = nodeColor;
|
|
2514
|
-
mapContext.fillRect( nodeBound.x, nodeBound.y, nodeBound.width, nodeBound.height );
|
|
2515
|
-
|
|
2516
|
-
}
|
|
2517
|
-
|
|
2518
|
-
const screenMapX = ( - ( scrollLeft + bounds.x ) * mapScale ) + boundsOffsetX;
|
|
2519
|
-
const screenMapY = ( - ( scrollTop + bounds.y ) * mapScale ) + boundsOffsetY;
|
|
2520
|
-
const screenMapWidth = ( canvas.width * mapScale ) / zoom;
|
|
2521
|
-
const screenMapHeight = ( canvas.height * mapScale ) / zoom;
|
|
2522
|
-
|
|
2523
|
-
mapContext.fillStyle = 'rgba( 200, 200, 200, 0.1 )';
|
|
2524
|
-
mapContext.fillRect( screenMapX, screenMapY, screenMapWidth, screenMapHeight );
|
|
2525
|
-
|
|
2526
|
-
//
|
|
2527
|
-
|
|
2528
|
-
_mapInfo.scale = mapScale;
|
|
2529
|
-
_mapInfo.left = ( - boundsOffsetX / mapScale ) + bounds.x;
|
|
2530
|
-
_mapInfo.top = ( - boundsOffsetY / mapScale ) + bounds.y;
|
|
2531
|
-
_mapInfo.width = mapCanvas.width / mapScale;
|
|
2532
|
-
_mapInfo.height = mapCanvas.height / mapScale;
|
|
2533
|
-
_mapInfo.screen.x = screenMapX;
|
|
2534
|
-
_mapInfo.screen.y = screenMapY;
|
|
2535
|
-
_mapInfo.screen.width = screenMapWidth;
|
|
2536
|
-
_mapInfo.screen.height = screenMapHeight;
|
|
2537
|
-
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
updateLines() {
|
|
2541
|
-
|
|
2542
|
-
const { dom, zoom, canvas, frontCanvas, frontContext, context, _width, _height } = this;
|
|
2543
|
-
|
|
2544
|
-
const domRect = this.rect;
|
|
2545
|
-
|
|
2546
|
-
if ( canvas.width !== _width || canvas.height !== _height ) {
|
|
2547
|
-
|
|
2548
|
-
canvas.width = _width;
|
|
2549
|
-
canvas.height = _height;
|
|
2550
|
-
|
|
2551
|
-
frontCanvas.width = _width;
|
|
2552
|
-
frontCanvas.height = _height;
|
|
2553
|
-
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
|
-
context.clearRect( 0, 0, _width, _height );
|
|
2557
|
-
frontContext.clearRect( 0, 0, _width, _height );
|
|
2558
|
-
|
|
2559
|
-
//
|
|
2560
|
-
|
|
2561
|
-
context.globalCompositeOperation = 'lighter';
|
|
2562
|
-
frontContext.globalCompositeOperation = 'source-over';
|
|
2563
|
-
|
|
2564
|
-
const links = this.getLinks();
|
|
2565
|
-
|
|
2566
|
-
const aPos = { x: 0, y: 0 };
|
|
2567
|
-
const bPos = { x: 0, y: 0 };
|
|
2568
|
-
|
|
2569
|
-
const offsetIORadius = 10;
|
|
2570
|
-
|
|
2571
|
-
let dragging = '';
|
|
2572
|
-
|
|
2573
|
-
for ( const link of links ) {
|
|
2574
|
-
|
|
2575
|
-
const { lioElement, rioElement } = link;
|
|
2576
|
-
|
|
2577
|
-
let draggingLink = '';
|
|
2578
|
-
let length = 0;
|
|
2579
|
-
|
|
2580
|
-
if ( lioElement !== null ) {
|
|
2581
|
-
|
|
2582
|
-
const rect = lioElement.dom.getBoundingClientRect();
|
|
2583
|
-
|
|
2584
|
-
length = Math.max( length, lioElement.rioLength );
|
|
2585
|
-
|
|
2586
|
-
aPos.x = rect.x + rect.width;
|
|
2587
|
-
aPos.y = rect.y + ( rect.height / 2 );
|
|
2588
|
-
|
|
2589
|
-
} else {
|
|
2590
|
-
|
|
2591
|
-
aPos.x = this.clientX;
|
|
2592
|
-
aPos.y = this.clientY;
|
|
2593
|
-
|
|
2594
|
-
draggingLink = 'lio';
|
|
2595
|
-
|
|
2596
|
-
}
|
|
2597
|
-
|
|
2598
|
-
if ( rioElement !== null ) {
|
|
2599
|
-
|
|
2600
|
-
const rect = rioElement.dom.getBoundingClientRect();
|
|
2601
|
-
|
|
2602
|
-
length = Math.max( length, rioElement.lioLength );
|
|
2603
|
-
|
|
2604
|
-
bPos.x = rect.x;
|
|
2605
|
-
bPos.y = rect.y + ( rect.height / 2 );
|
|
2606
|
-
|
|
2607
|
-
} else {
|
|
2608
|
-
|
|
2609
|
-
bPos.x = this.clientX;
|
|
2610
|
-
bPos.y = this.clientY;
|
|
2611
|
-
|
|
2612
|
-
draggingLink = 'rio';
|
|
2613
|
-
|
|
2614
|
-
}
|
|
2615
|
-
|
|
2616
|
-
dragging = dragging || draggingLink;
|
|
2617
|
-
|
|
2618
|
-
const drawContext = draggingLink ? frontContext : context;
|
|
2619
|
-
|
|
2620
|
-
if ( draggingLink || length === 1 ) {
|
|
2621
|
-
|
|
2622
|
-
let colorA = null,
|
|
2623
|
-
colorB = null;
|
|
2624
|
-
|
|
2625
|
-
if ( draggingLink === 'rio' ) {
|
|
2626
|
-
|
|
2627
|
-
colorA = colorB = lioElement.getRIOColor();
|
|
2628
|
-
|
|
2629
|
-
aPos.x += offsetIORadius;
|
|
2630
|
-
bPos.x /= zoom;
|
|
2631
|
-
bPos.y /= zoom;
|
|
2632
|
-
|
|
2633
|
-
} else if ( draggingLink === 'lio' ) {
|
|
2634
|
-
|
|
2635
|
-
colorA = colorB = rioElement.getLIOColor();
|
|
2636
|
-
|
|
2637
|
-
bPos.x -= offsetIORadius;
|
|
2638
|
-
aPos.x /= zoom;
|
|
2639
|
-
aPos.y /= zoom;
|
|
2640
|
-
|
|
2641
|
-
} else {
|
|
2642
|
-
|
|
2643
|
-
colorA = lioElement.getRIOColor();
|
|
2644
|
-
colorB = rioElement.getLIOColor();
|
|
2645
|
-
|
|
2646
|
-
}
|
|
2647
|
-
|
|
2648
|
-
drawLine(
|
|
2649
|
-
aPos.x * zoom, aPos.y * zoom,
|
|
2650
|
-
bPos.x * zoom, bPos.y * zoom,
|
|
2651
|
-
false, 2, colorA || '#ffffff', drawContext, colorB || '#ffffff'
|
|
2652
|
-
);
|
|
2653
|
-
|
|
2654
|
-
} else {
|
|
2655
|
-
|
|
2656
|
-
length = Math.min( length, 4 );
|
|
2657
|
-
|
|
2658
|
-
for ( let i = 0; i < length; i ++ ) {
|
|
2659
|
-
|
|
2660
|
-
const color = colors[ i ] || '#ffffff';
|
|
2661
|
-
|
|
2662
|
-
const marginY = 4;
|
|
2663
|
-
|
|
2664
|
-
const rioLength = Math.min( lioElement.rioLength, length );
|
|
2665
|
-
const lioLength = Math.min( rioElement.lioLength, length );
|
|
2666
|
-
|
|
2667
|
-
const colorA = lioElement.getRIOColor() || color;
|
|
2668
|
-
const colorB = rioElement.getLIOColor() || color;
|
|
2669
|
-
|
|
2670
|
-
const aCenterY = ( ( rioLength * marginY ) * .5 ) - ( marginY / 2 );
|
|
2671
|
-
const bCenterY = ( ( lioLength * marginY ) * .5 ) - ( marginY / 2 );
|
|
2672
|
-
|
|
2673
|
-
const aIndex = Math.min( i, rioLength - 1 );
|
|
2674
|
-
const bIndex = Math.min( i, lioLength - 1 );
|
|
2675
|
-
|
|
2676
|
-
const aPosY = ( aIndex * marginY ) - 1;
|
|
2677
|
-
const bPosY = ( bIndex * marginY ) - 1;
|
|
2678
|
-
|
|
2679
|
-
drawLine(
|
|
2680
|
-
aPos.x * zoom, ( ( aPos.y + aPosY ) - aCenterY ) * zoom,
|
|
2681
|
-
bPos.x * zoom, ( ( bPos.y + bPosY ) - bCenterY ) * zoom,
|
|
2682
|
-
false, 2, colorA, drawContext, colorB
|
|
2683
|
-
);
|
|
2684
|
-
|
|
2685
|
-
}
|
|
2686
|
-
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
|
-
}
|
|
2690
|
-
|
|
2691
|
-
context.globalCompositeOperation = 'destination-in';
|
|
2692
|
-
|
|
2693
|
-
context.fillRect( domRect.x, domRect.y, domRect.width, domRect.height );
|
|
2694
|
-
|
|
2695
|
-
if ( dragging !== '' ) {
|
|
2696
|
-
|
|
2697
|
-
dom.classList.add( 'dragging-' + dragging );
|
|
2698
|
-
|
|
2699
|
-
} else {
|
|
2700
|
-
|
|
2701
|
-
dom.classList.remove( 'dragging-lio' );
|
|
2702
|
-
dom.classList.remove( 'dragging-rio' );
|
|
2703
|
-
|
|
2704
|
-
}
|
|
2705
|
-
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
update() {
|
|
2710
|
-
|
|
2711
|
-
if ( this.updating === false ) return;
|
|
2712
|
-
|
|
2713
|
-
requestAnimationFrame( this._onUpdate );
|
|
2714
|
-
|
|
2715
|
-
this.updateLines();
|
|
2716
|
-
this.updateMap();
|
|
2717
|
-
|
|
2718
|
-
}
|
|
2719
|
-
|
|
2720
|
-
serialize( data ) {
|
|
2721
|
-
|
|
2722
|
-
const nodes = [];
|
|
2723
|
-
|
|
2724
|
-
for ( const node of this.nodes ) {
|
|
2725
|
-
|
|
2726
|
-
nodes.push( node.toJSON( data ).id );
|
|
2727
|
-
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2730
|
-
data.nodes = nodes;
|
|
2731
|
-
|
|
2732
|
-
}
|
|
2733
|
-
|
|
2734
|
-
deserialize( data ) {
|
|
2735
|
-
|
|
2736
|
-
for ( const id of data.nodes ) {
|
|
2737
|
-
|
|
2738
|
-
this.add( data.objects[ id ] );
|
|
2739
|
-
|
|
2740
|
-
}
|
|
2741
|
-
|
|
2742
|
-
}
|
|
2743
|
-
|
|
2744
|
-
}
|
|
2745
|
-
|
|
2746
|
-
class ButtonInput extends Input {
|
|
2747
|
-
|
|
2748
|
-
constructor( innterText = '' ) {
|
|
2749
|
-
|
|
2750
|
-
const dom = document.createElement( 'button' );
|
|
2751
|
-
|
|
2752
|
-
const spanDOM = document.createElement( 'span' );
|
|
2753
|
-
dom.append( spanDOM );
|
|
2754
|
-
|
|
2755
|
-
const iconDOM = document.createElement( 'i' );
|
|
2756
|
-
dom.append( iconDOM );
|
|
2757
|
-
|
|
2758
|
-
super( dom );
|
|
2759
|
-
|
|
2760
|
-
this.spanDOM = spanDOM;
|
|
2761
|
-
this.iconDOM = iconDOM;
|
|
2762
|
-
|
|
2763
|
-
spanDOM.innerText = innterText;
|
|
2764
|
-
|
|
2765
|
-
dom.onmouseover = () => {
|
|
2766
|
-
|
|
2767
|
-
this.dispatchEvent( new Event( 'mouseover' ) );
|
|
2768
|
-
|
|
2769
|
-
};
|
|
2770
|
-
|
|
2771
|
-
dom.onclick = dom.ontouchstart = ( e ) => {
|
|
2772
|
-
|
|
2773
|
-
e.preventDefault();
|
|
2774
|
-
|
|
2775
|
-
e.stopPropagation();
|
|
2776
|
-
|
|
2777
|
-
this.dispatchEvent( new Event( 'click' ) );
|
|
2778
|
-
|
|
2779
|
-
};
|
|
2780
|
-
|
|
2781
|
-
}
|
|
2782
|
-
|
|
2783
|
-
setIcon( className ) {
|
|
2784
|
-
|
|
2785
|
-
this.iconDOM.className = className;
|
|
2786
|
-
|
|
2787
|
-
return this;
|
|
2788
|
-
|
|
2789
|
-
}
|
|
2790
|
-
|
|
2791
|
-
setValue( val ) {
|
|
2792
|
-
|
|
2793
|
-
this.spanDOM.innerText = val;
|
|
2794
|
-
|
|
2795
|
-
return this;
|
|
2796
|
-
|
|
2797
|
-
}
|
|
2798
|
-
|
|
2799
|
-
getValue() {
|
|
2800
|
-
|
|
2801
|
-
return this.spanDOM.innerText;
|
|
2802
|
-
|
|
2803
|
-
}
|
|
2804
|
-
|
|
2805
|
-
}
|
|
2806
|
-
|
|
2807
|
-
class ObjectNode extends Node {
|
|
2808
|
-
|
|
2809
|
-
constructor( name, inputLength, callback = null, width = 300 ) {
|
|
2810
|
-
|
|
2811
|
-
super();
|
|
2812
|
-
|
|
2813
|
-
this.setWidth( width );
|
|
2814
|
-
|
|
2815
|
-
const title = new TitleElement( name )
|
|
2816
|
-
.setObjectCallback( callback )
|
|
2817
|
-
.setSerializable( false )
|
|
2818
|
-
.setOutput( inputLength );
|
|
2819
|
-
|
|
2820
|
-
const closeButton = new ButtonInput( Styles.icons.close || '✕' ).onClick( () => {
|
|
2821
|
-
|
|
2822
|
-
this.dispose();
|
|
2823
|
-
|
|
2824
|
-
} ).setIcon( Styles.icons.close );
|
|
2825
|
-
|
|
2826
|
-
title.addButton( closeButton );
|
|
2827
|
-
|
|
2828
|
-
this.add( title );
|
|
2829
|
-
|
|
2830
|
-
this.title = title;
|
|
2831
|
-
this.closeButton = closeButton;
|
|
2832
|
-
|
|
2833
|
-
}
|
|
2834
|
-
|
|
2835
|
-
setName( value ) {
|
|
2836
|
-
|
|
2837
|
-
this.title.setTitle( value );
|
|
2838
|
-
|
|
2839
|
-
return this;
|
|
2840
|
-
|
|
2841
|
-
}
|
|
2842
|
-
|
|
2843
|
-
getName() {
|
|
2844
|
-
|
|
2845
|
-
return this.title.getTitle();
|
|
2846
|
-
|
|
2847
|
-
}
|
|
2848
|
-
|
|
2849
|
-
setObjectCallback( callback ) {
|
|
2850
|
-
|
|
2851
|
-
this.title.setObjectCallback( callback );
|
|
2852
|
-
|
|
2853
|
-
return this;
|
|
2854
|
-
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2857
|
-
getObject( callback ) {
|
|
2858
|
-
|
|
2859
|
-
return this.title.getObject( callback );
|
|
2860
|
-
|
|
2861
|
-
}
|
|
2862
|
-
|
|
2863
|
-
setColor( color ) {
|
|
2864
|
-
|
|
2865
|
-
return this.title.setColor( color );
|
|
2866
|
-
|
|
2867
|
-
}
|
|
2868
|
-
|
|
2869
|
-
setOutputColor( color ) {
|
|
2870
|
-
|
|
2871
|
-
return this.title.setOutputColor( color );
|
|
2872
|
-
|
|
2873
|
-
}
|
|
2874
|
-
|
|
2875
|
-
invalidate() {
|
|
2876
|
-
|
|
2877
|
-
this.title.dispatchEvent( new Event( 'connect' ) );
|
|
2878
|
-
|
|
2879
|
-
}
|
|
2880
|
-
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
|
-
const ENTER_KEY$2 = 13;
|
|
2884
|
-
|
|
2885
|
-
class StringInput extends Input {
|
|
2886
|
-
|
|
2887
|
-
constructor( value = '' ) {
|
|
2888
|
-
|
|
2889
|
-
const dom = document.createElement( 'input' );
|
|
2890
|
-
super( dom );
|
|
2891
|
-
|
|
2892
|
-
dom.type = 'text';
|
|
2893
|
-
dom.value = value;
|
|
2894
|
-
dom.spellcheck = false;
|
|
2895
|
-
dom.autocomplete = 'off';
|
|
2896
|
-
|
|
2897
|
-
dom.onblur = () => {
|
|
2898
|
-
|
|
2899
|
-
this.dispatchEvent( new Event( 'blur' ) );
|
|
2900
|
-
|
|
2901
|
-
};
|
|
2902
|
-
|
|
2903
|
-
dom.onchange = () => {
|
|
2904
|
-
|
|
2905
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
2906
|
-
|
|
2907
|
-
};
|
|
2908
|
-
|
|
2909
|
-
dom.onkeyup = ( e ) => {
|
|
2910
|
-
|
|
2911
|
-
if ( e.keyCode === ENTER_KEY$2 ) {
|
|
2912
|
-
|
|
2913
|
-
e.target.blur();
|
|
2914
|
-
|
|
2915
|
-
}
|
|
2916
|
-
|
|
2917
|
-
e.stopPropagation();
|
|
2918
|
-
|
|
2919
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
2920
|
-
|
|
2921
|
-
};
|
|
2922
|
-
|
|
2923
|
-
}
|
|
2924
|
-
|
|
2925
|
-
}
|
|
2926
|
-
|
|
2927
|
-
const ENTER_KEY$1 = 13;
|
|
2928
|
-
|
|
2929
|
-
class NumberInput extends Input {
|
|
2930
|
-
|
|
2931
|
-
constructor( value = 0, min = - Infinity, max = Infinity, step = .01 ) {
|
|
2932
|
-
|
|
2933
|
-
const dom = document.createElement( 'input' );
|
|
2934
|
-
super( dom );
|
|
2935
|
-
|
|
2936
|
-
this.min = min;
|
|
2937
|
-
this.max = max;
|
|
2938
|
-
this.step = step;
|
|
2939
|
-
|
|
2940
|
-
this.integer = false;
|
|
2941
|
-
|
|
2942
|
-
dom.type = 'text';
|
|
2943
|
-
dom.className = 'number';
|
|
2944
|
-
dom.value = this._getString( value );
|
|
2945
|
-
dom.spellcheck = false;
|
|
2946
|
-
dom.autocomplete = 'off';
|
|
2947
|
-
|
|
2948
|
-
dom.ondragstart = dom.oncontextmenu = ( e ) => {
|
|
2949
|
-
|
|
2950
|
-
e.preventDefault();
|
|
2951
|
-
|
|
2952
|
-
e.stopPropagation();
|
|
2953
|
-
|
|
2954
|
-
};
|
|
2955
|
-
|
|
2956
|
-
dom.onfocus = dom.onclick = () => {
|
|
2957
|
-
|
|
2958
|
-
dom.select();
|
|
2959
|
-
|
|
2960
|
-
};
|
|
2961
|
-
|
|
2962
|
-
dom.onblur = () => {
|
|
2963
|
-
|
|
2964
|
-
this.dom.value = this._getString( this.dom.value );
|
|
2965
|
-
|
|
2966
|
-
this.dispatchEvent( new Event( 'blur' ) );
|
|
2967
|
-
|
|
2968
|
-
};
|
|
2969
|
-
|
|
2970
|
-
dom.onchange = () => {
|
|
2971
|
-
|
|
2972
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
2973
|
-
|
|
2974
|
-
};
|
|
2975
|
-
|
|
2976
|
-
dom.onkeydown = ( e ) => {
|
|
2977
|
-
|
|
2978
|
-
if ( e.key.length === 1 && /\d|\./.test( e.key ) !== true ) {
|
|
2979
|
-
|
|
2980
|
-
return false;
|
|
2981
|
-
|
|
2982
|
-
}
|
|
2983
|
-
|
|
2984
|
-
if ( e.keyCode === ENTER_KEY$1 ) {
|
|
2985
|
-
|
|
2986
|
-
e.target.blur();
|
|
2987
|
-
|
|
2988
|
-
}
|
|
2989
|
-
|
|
2990
|
-
e.stopPropagation();
|
|
2991
|
-
|
|
2992
|
-
};
|
|
2993
|
-
|
|
2994
|
-
draggableDOM( dom, ( data ) => {
|
|
2995
|
-
|
|
2996
|
-
const { delta } = data;
|
|
2997
|
-
|
|
2998
|
-
if ( dom.readOnly === true ) return;
|
|
2999
|
-
|
|
3000
|
-
if ( data.value === undefined ) {
|
|
3001
|
-
|
|
3002
|
-
data.value = this.getValue();
|
|
3003
|
-
|
|
3004
|
-
}
|
|
3005
|
-
|
|
3006
|
-
const diff = delta.x - delta.y;
|
|
3007
|
-
|
|
3008
|
-
const value = data.value + ( diff * this.step );
|
|
3009
|
-
|
|
3010
|
-
dom.value = this._getString( value.toFixed( this.precision ) );
|
|
3011
|
-
|
|
3012
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
3013
|
-
|
|
3014
|
-
} );
|
|
3015
|
-
|
|
3016
|
-
}
|
|
3017
|
-
|
|
3018
|
-
setStep( step ) {
|
|
3019
|
-
|
|
3020
|
-
this.step = step;
|
|
3021
|
-
|
|
3022
|
-
return this;
|
|
3023
|
-
|
|
3024
|
-
}
|
|
3025
|
-
|
|
3026
|
-
setRange( min, max, step ) {
|
|
3027
|
-
|
|
3028
|
-
this.min = min;
|
|
3029
|
-
this.max = max;
|
|
3030
|
-
this.step = step;
|
|
3031
|
-
|
|
3032
|
-
this.dispatchEvent( new Event( 'range' ) );
|
|
3033
|
-
|
|
3034
|
-
return this.setValue( this.getValue() );
|
|
3035
|
-
|
|
3036
|
-
}
|
|
3037
|
-
|
|
3038
|
-
get precision() {
|
|
3039
|
-
|
|
3040
|
-
if ( this.integer === true ) return 0;
|
|
3041
|
-
|
|
3042
|
-
const fract = this.step % 1;
|
|
3043
|
-
|
|
3044
|
-
return fract !== 0 ? fract.toString().split( '.' )[ 1 ].length : 1;
|
|
3045
|
-
|
|
3046
|
-
}
|
|
3047
|
-
|
|
3048
|
-
setValue( val, dispatch = true ) {
|
|
3049
|
-
|
|
3050
|
-
return super.setValue( this._getString( val ), dispatch );
|
|
3051
|
-
|
|
3052
|
-
}
|
|
3053
|
-
|
|
3054
|
-
getValue() {
|
|
3055
|
-
|
|
3056
|
-
return Number( this.dom.value );
|
|
3057
|
-
|
|
3058
|
-
}
|
|
3059
|
-
|
|
3060
|
-
serialize( data ) {
|
|
3061
|
-
|
|
3062
|
-
const { min, max } = this;
|
|
3063
|
-
|
|
3064
|
-
if ( min !== - Infinity && max !== Infinity ) {
|
|
3065
|
-
|
|
3066
|
-
data.min = this.min;
|
|
3067
|
-
data.max = this.max;
|
|
3068
|
-
data.step = this.step;
|
|
3069
|
-
|
|
3070
|
-
}
|
|
3071
|
-
|
|
3072
|
-
super.serialize( data );
|
|
3073
|
-
|
|
3074
|
-
}
|
|
3075
|
-
|
|
3076
|
-
deserialize( data ) {
|
|
3077
|
-
|
|
3078
|
-
if ( data.min !== undefined ) {
|
|
3079
|
-
|
|
3080
|
-
const { min, max, step } = this;
|
|
3081
|
-
|
|
3082
|
-
this.setRange( min, max, step );
|
|
3083
|
-
|
|
3084
|
-
}
|
|
3085
|
-
|
|
3086
|
-
super.deserialize( data );
|
|
3087
|
-
|
|
3088
|
-
}
|
|
3089
|
-
|
|
3090
|
-
_getString( value ) {
|
|
3091
|
-
|
|
3092
|
-
const num = Math.min( Math.max( Number( value ), this.min ), this.max );
|
|
3093
|
-
|
|
3094
|
-
if ( this.integer === true ) {
|
|
3095
|
-
|
|
3096
|
-
return Math.floor( num );
|
|
3097
|
-
|
|
3098
|
-
} else {
|
|
3099
|
-
|
|
3100
|
-
return num + ( num % 1 ? '' : '.0' );
|
|
3101
|
-
|
|
3102
|
-
}
|
|
3103
|
-
|
|
3104
|
-
}
|
|
3105
|
-
|
|
3106
|
-
}
|
|
3107
|
-
|
|
3108
|
-
const getStep = ( min, max ) => {
|
|
3109
|
-
|
|
3110
|
-
const sensibility = .001;
|
|
3111
|
-
|
|
3112
|
-
return ( max - min ) * sensibility;
|
|
3113
|
-
|
|
3114
|
-
};
|
|
3115
|
-
|
|
3116
|
-
class SliderInput extends Input {
|
|
3117
|
-
|
|
3118
|
-
constructor( value = 0, min = 0, max = 100 ) {
|
|
3119
|
-
|
|
3120
|
-
const dom = document.createElement( 'f-subinputs' );
|
|
3121
|
-
super( dom );
|
|
3122
|
-
|
|
3123
|
-
value = Math.min( Math.max( value, min ), max );
|
|
3124
|
-
|
|
3125
|
-
const step = getStep( min, max );
|
|
3126
|
-
|
|
3127
|
-
const rangeDOM = document.createElement( 'input' );
|
|
3128
|
-
rangeDOM.type = 'range';
|
|
3129
|
-
rangeDOM.min = min;
|
|
3130
|
-
rangeDOM.max = max;
|
|
3131
|
-
rangeDOM.step = step;
|
|
3132
|
-
rangeDOM.value = value;
|
|
3133
|
-
|
|
3134
|
-
const field = new NumberInput( value, min, max, step );
|
|
3135
|
-
field.dom.className = 'range-value';
|
|
3136
|
-
field.onChange( () => {
|
|
3137
|
-
|
|
3138
|
-
rangeDOM.value = field.getValue();
|
|
3139
|
-
|
|
3140
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
3141
|
-
|
|
3142
|
-
} );
|
|
3143
|
-
|
|
3144
|
-
field.addEventListener( 'range', () => {
|
|
3145
|
-
|
|
3146
|
-
rangeDOM.min = field.min;
|
|
3147
|
-
rangeDOM.max = field.max;
|
|
3148
|
-
rangeDOM.step = field.step;
|
|
3149
|
-
rangeDOM.value = field.getValue();
|
|
3150
|
-
|
|
3151
|
-
} );
|
|
3152
|
-
|
|
3153
|
-
dom.append( rangeDOM );
|
|
3154
|
-
dom.append( field.dom );
|
|
3155
|
-
|
|
3156
|
-
this.rangeDOM = rangeDOM;
|
|
3157
|
-
this.field = field;
|
|
3158
|
-
|
|
3159
|
-
const updateRangeValue = () => {
|
|
3160
|
-
|
|
3161
|
-
let value = Number( rangeDOM.value );
|
|
3162
|
-
|
|
3163
|
-
if ( value !== this.max && value + this.step >= this.max ) {
|
|
3164
|
-
|
|
3165
|
-
// fix not end range fraction
|
|
3166
|
-
|
|
3167
|
-
rangeDOM.value = value = this.max;
|
|
3168
|
-
|
|
3169
|
-
}
|
|
3170
|
-
|
|
3171
|
-
this.field.setValue( value );
|
|
3172
|
-
|
|
3173
|
-
};
|
|
3174
|
-
|
|
3175
|
-
draggableDOM( rangeDOM, () => {
|
|
3176
|
-
|
|
3177
|
-
updateRangeValue();
|
|
3178
|
-
|
|
3179
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
3180
|
-
|
|
3181
|
-
}, { className: '' } );
|
|
3182
|
-
|
|
3183
|
-
}
|
|
3184
|
-
|
|
3185
|
-
get min() {
|
|
3186
|
-
|
|
3187
|
-
return this.field.min;
|
|
3188
|
-
|
|
3189
|
-
}
|
|
3190
|
-
|
|
3191
|
-
get max() {
|
|
3192
|
-
|
|
3193
|
-
return this.field.max;
|
|
3194
|
-
|
|
3195
|
-
}
|
|
3196
|
-
|
|
3197
|
-
get step() {
|
|
3198
|
-
|
|
3199
|
-
return this.field.step;
|
|
3200
|
-
|
|
3201
|
-
}
|
|
3202
|
-
|
|
3203
|
-
setRange( min, max ) {
|
|
3204
|
-
|
|
3205
|
-
this.field.setRange( min, max, getStep( min, max ) );
|
|
3206
|
-
|
|
3207
|
-
this.dispatchEvent( new Event( 'range' ) );
|
|
3208
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
3209
|
-
|
|
3210
|
-
return this;
|
|
3211
|
-
|
|
3212
|
-
}
|
|
3213
|
-
|
|
3214
|
-
setValue( val, dispatch = true ) {
|
|
3215
|
-
|
|
3216
|
-
this.field.setValue( val );
|
|
3217
|
-
this.rangeDOM.value = val;
|
|
3218
|
-
|
|
3219
|
-
if ( dispatch ) this.dispatchEvent( new Event( 'change' ) );
|
|
3220
|
-
|
|
3221
|
-
return this;
|
|
3222
|
-
|
|
3223
|
-
}
|
|
3224
|
-
|
|
3225
|
-
getValue() {
|
|
3226
|
-
|
|
3227
|
-
return this.field.getValue();
|
|
3228
|
-
|
|
3229
|
-
}
|
|
3230
|
-
|
|
3231
|
-
serialize( data ) {
|
|
3232
|
-
|
|
3233
|
-
data.min = this.min;
|
|
3234
|
-
data.max = this.max;
|
|
3235
|
-
|
|
3236
|
-
super.serialize( data );
|
|
3237
|
-
|
|
3238
|
-
}
|
|
3239
|
-
|
|
3240
|
-
deserialize( data ) {
|
|
3241
|
-
|
|
3242
|
-
const { min, max } = data;
|
|
3243
|
-
|
|
3244
|
-
this.setRange( min, max );
|
|
3245
|
-
|
|
3246
|
-
super.deserialize( data );
|
|
3247
|
-
|
|
3248
|
-
}
|
|
3249
|
-
|
|
3250
|
-
}
|
|
3251
|
-
|
|
3252
|
-
class ColorInput extends Input {
|
|
3253
|
-
|
|
3254
|
-
constructor( value = 0x0099ff ) {
|
|
3255
|
-
|
|
3256
|
-
const dom = document.createElement( 'input' );
|
|
3257
|
-
super( dom );
|
|
3258
|
-
|
|
3259
|
-
dom.type = 'color';
|
|
3260
|
-
dom.value = numberToHex( value );
|
|
3261
|
-
|
|
3262
|
-
dom.oninput = () => {
|
|
3263
|
-
|
|
3264
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
3265
|
-
|
|
3266
|
-
};
|
|
3267
|
-
|
|
3268
|
-
}
|
|
3269
|
-
|
|
3270
|
-
setValue( value, dispatch = true ) {
|
|
3271
|
-
|
|
3272
|
-
return super.setValue( numberToHex( value ), dispatch );
|
|
3273
|
-
|
|
3274
|
-
}
|
|
3275
|
-
|
|
3276
|
-
getValue() {
|
|
3277
|
-
|
|
3278
|
-
return parseInt( super.getValue().substr( 1 ), 16 );
|
|
3279
|
-
|
|
3280
|
-
}
|
|
3281
|
-
|
|
3282
|
-
}
|
|
3283
|
-
|
|
3284
|
-
const ENTER_KEY = 13;
|
|
3285
|
-
|
|
3286
|
-
class TextInput extends Input {
|
|
3287
|
-
|
|
3288
|
-
constructor( innerText = '' ) {
|
|
3289
|
-
|
|
3290
|
-
const dom = document.createElement( 'textarea' );
|
|
3291
|
-
super( dom );
|
|
3292
|
-
|
|
3293
|
-
dom.innerText = innerText;
|
|
3294
|
-
|
|
3295
|
-
dom.onblur = () => {
|
|
3296
|
-
|
|
3297
|
-
this.dispatchEvent( new Event( 'blur' ) );
|
|
3298
|
-
|
|
3299
|
-
};
|
|
3300
|
-
|
|
3301
|
-
dom.onchange = () => {
|
|
3302
|
-
|
|
3303
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
3304
|
-
|
|
3305
|
-
};
|
|
3306
|
-
|
|
3307
|
-
dom.onkeyup = ( e ) => {
|
|
3308
|
-
|
|
3309
|
-
if ( e.keyCode === ENTER_KEY ) {
|
|
3310
|
-
|
|
3311
|
-
e.target.blur();
|
|
3312
|
-
|
|
3313
|
-
}
|
|
3314
|
-
|
|
3315
|
-
e.stopPropagation();
|
|
3316
|
-
|
|
3317
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
3318
|
-
|
|
3319
|
-
};
|
|
3320
|
-
|
|
3321
|
-
}
|
|
3322
|
-
|
|
3323
|
-
}
|
|
3324
|
-
|
|
3325
|
-
class LabelElement extends Element {
|
|
3326
|
-
|
|
3327
|
-
constructor( label = '', align = '' ) {
|
|
3328
|
-
|
|
3329
|
-
super();
|
|
3330
|
-
|
|
3331
|
-
this.labelDOM = document.createElement( 'f-label' );
|
|
3332
|
-
this.inputsDOM = document.createElement( 'f-inputs' );
|
|
3333
|
-
|
|
3334
|
-
const spanDOM = document.createElement( 'span' );
|
|
3335
|
-
|
|
3336
|
-
this.spanDOM = spanDOM;
|
|
3337
|
-
this.iconDOM = null;
|
|
3338
|
-
|
|
3339
|
-
this.labelDOM.append( spanDOM );
|
|
3340
|
-
|
|
3341
|
-
this.dom.append( this.labelDOM );
|
|
3342
|
-
this.dom.append( this.inputsDOM );
|
|
3343
|
-
|
|
3344
|
-
this.serializeLabel = false;
|
|
3345
|
-
|
|
3346
|
-
this.setLabel( label );
|
|
3347
|
-
this.setAlign( align );
|
|
3348
|
-
|
|
3349
|
-
}
|
|
3350
|
-
|
|
3351
|
-
setIcon( value ) {
|
|
3352
|
-
|
|
3353
|
-
this.iconDOM = this.iconDOM || document.createElement( 'i' );
|
|
3354
|
-
this.iconDOM.className = value;
|
|
3355
|
-
|
|
3356
|
-
if ( value ) this.labelDOM.prepend( this.iconDOM );
|
|
3357
|
-
else this.iconDOM.remove();
|
|
3358
|
-
|
|
3359
|
-
return this;
|
|
3360
|
-
|
|
3361
|
-
}
|
|
3362
|
-
|
|
3363
|
-
getIcon() {
|
|
3364
|
-
|
|
3365
|
-
return this.iconDOM?.className;
|
|
3366
|
-
|
|
3367
|
-
}
|
|
3368
|
-
|
|
3369
|
-
setAlign( align ) {
|
|
3370
|
-
|
|
3371
|
-
this.labelDOM.className = align;
|
|
3372
|
-
|
|
3373
|
-
}
|
|
3374
|
-
|
|
3375
|
-
setLabel( val ) {
|
|
3376
|
-
|
|
3377
|
-
this.spanDOM.innerText = val;
|
|
3378
|
-
|
|
3379
|
-
}
|
|
3380
|
-
|
|
3381
|
-
getLabel() {
|
|
3382
|
-
|
|
3383
|
-
return this.spanDOM.innerText;
|
|
3384
|
-
|
|
3385
|
-
}
|
|
3386
|
-
|
|
3387
|
-
serialize( data ) {
|
|
3388
|
-
|
|
3389
|
-
super.serialize( data );
|
|
3390
|
-
|
|
3391
|
-
if ( this.serializeLabel ) {
|
|
3392
|
-
|
|
3393
|
-
const label = this.getLabel();
|
|
3394
|
-
const icon = this.getIcon();
|
|
3395
|
-
|
|
3396
|
-
data.label = label;
|
|
3397
|
-
|
|
3398
|
-
if ( icon !== '' ) {
|
|
3399
|
-
|
|
3400
|
-
data.icon = icon;
|
|
3401
|
-
|
|
3402
|
-
}
|
|
3403
|
-
|
|
3404
|
-
}
|
|
3405
|
-
|
|
3406
|
-
}
|
|
3407
|
-
|
|
3408
|
-
deserialize( data ) {
|
|
3409
|
-
|
|
3410
|
-
super.deserialize( data );
|
|
3411
|
-
|
|
3412
|
-
if ( this.serializeLabel ) {
|
|
3413
|
-
|
|
3414
|
-
this.setLabel( data.label );
|
|
3415
|
-
|
|
3416
|
-
if ( data.icon !== undefined ) {
|
|
3417
|
-
|
|
3418
|
-
this.setIcon( data.icon );
|
|
3419
|
-
|
|
3420
|
-
}
|
|
3421
|
-
|
|
3422
|
-
}
|
|
3423
|
-
|
|
3424
|
-
}
|
|
3425
|
-
|
|
3426
|
-
}
|
|
3427
|
-
|
|
3428
|
-
class PanelNode extends Node {
|
|
3429
|
-
|
|
3430
|
-
constructor( title = 'Panel', align = 'top-right' ) {
|
|
3431
|
-
|
|
3432
|
-
super();
|
|
3433
|
-
|
|
3434
|
-
const titleElement = new TitleElement( title );
|
|
3435
|
-
this.add( titleElement );
|
|
3436
|
-
|
|
3437
|
-
const collapseButton = new ButtonInput( '🗕' );
|
|
3438
|
-
collapseButton.onClick( () => {
|
|
3439
|
-
|
|
3440
|
-
this.setCollapse( ! this.collapsed );
|
|
3441
|
-
|
|
3442
|
-
} );
|
|
3443
|
-
|
|
3444
|
-
titleElement.addButton( collapseButton );
|
|
3445
|
-
|
|
3446
|
-
this.collapseButton = collapseButton;
|
|
3447
|
-
this.titleElement = titleElement;
|
|
3448
|
-
this.align = align;
|
|
3449
|
-
this.collapsed = false;
|
|
3450
|
-
|
|
3451
|
-
this.setAlign( align );
|
|
3452
|
-
this.setStyle( 'rouded' );
|
|
3453
|
-
|
|
3454
|
-
}
|
|
3455
|
-
|
|
3456
|
-
setCollapse( value ) {
|
|
3457
|
-
|
|
3458
|
-
const cssClass = 'closed';
|
|
3459
|
-
|
|
3460
|
-
this.dom.classList.remove( cssClass );
|
|
3461
|
-
|
|
3462
|
-
this.collapsed = value;
|
|
3463
|
-
|
|
3464
|
-
this.collapseButton.value = value ? '🗖' : '🗕';
|
|
3465
|
-
|
|
3466
|
-
if ( value === true ) {
|
|
3467
|
-
|
|
3468
|
-
this.dom.classList.add( cssClass );
|
|
3469
|
-
|
|
3470
|
-
}
|
|
3471
|
-
|
|
3472
|
-
return this;
|
|
3473
|
-
|
|
3474
|
-
}
|
|
3475
|
-
|
|
3476
|
-
setAlign( align ) {
|
|
3477
|
-
|
|
3478
|
-
if ( this.align ) this.dom.classList.remove( this.align );
|
|
3479
|
-
this.dom.classList.add( align );
|
|
3480
|
-
|
|
3481
|
-
this.align = align;
|
|
3482
|
-
|
|
3483
|
-
return this;
|
|
3484
|
-
|
|
3485
|
-
}
|
|
3486
|
-
|
|
3487
|
-
addInput( inputClass, object, property, ...params ) {
|
|
3488
|
-
|
|
3489
|
-
const value = object[ property ];
|
|
3490
|
-
|
|
3491
|
-
const input = new inputClass( value, ...params );
|
|
3492
|
-
input.onChange( () => {
|
|
3493
|
-
|
|
3494
|
-
object[ property ] = input.value;
|
|
3495
|
-
|
|
3496
|
-
} );
|
|
3497
|
-
|
|
3498
|
-
this.add( new LabelElement( property ).add( input ) );
|
|
3499
|
-
|
|
3500
|
-
return input;
|
|
3501
|
-
|
|
3502
|
-
}
|
|
3503
|
-
|
|
3504
|
-
addSlider( object, property, min, max ) {
|
|
3505
|
-
|
|
3506
|
-
return this.addInput( SliderInput, object, property, min, max );
|
|
3507
|
-
|
|
3508
|
-
}
|
|
3509
|
-
|
|
3510
|
-
addNumber( object, property ) {
|
|
3511
|
-
|
|
3512
|
-
return this.addInput( NumberInput, object, property );
|
|
3513
|
-
|
|
3514
|
-
}
|
|
3515
|
-
|
|
3516
|
-
addColor( object, property ) {
|
|
3517
|
-
|
|
3518
|
-
return this.addInput( ColorInput, object, property );
|
|
3519
|
-
|
|
3520
|
-
}
|
|
3521
|
-
|
|
3522
|
-
addString( object, property ) {
|
|
3523
|
-
|
|
3524
|
-
return this.addInput( StringInput, object, property );
|
|
3525
|
-
|
|
3526
|
-
}
|
|
3527
|
-
|
|
3528
|
-
addText( object, property ) {
|
|
3529
|
-
|
|
3530
|
-
const input = this.addInput( TextInput, object, property );
|
|
3531
|
-
input.element.setHeight( 70 );
|
|
3532
|
-
|
|
3533
|
-
return input;
|
|
3534
|
-
|
|
3535
|
-
}
|
|
3536
|
-
|
|
3537
|
-
addButton( name ) {
|
|
3538
|
-
|
|
3539
|
-
const input = new ButtonInput( name );
|
|
3540
|
-
|
|
3541
|
-
this.add( new Element().setHeight( 34 ).add( input ) );
|
|
3542
|
-
|
|
3543
|
-
return input;
|
|
3544
|
-
|
|
3545
|
-
}
|
|
3546
|
-
|
|
3547
|
-
}
|
|
3548
|
-
|
|
3549
|
-
class Menu extends EventTarget {
|
|
3550
|
-
|
|
3551
|
-
constructor( className ) {
|
|
3552
|
-
|
|
3553
|
-
super();
|
|
3554
|
-
|
|
3555
|
-
const dom = document.createElement( 'f-menu' );
|
|
3556
|
-
dom.className = className + ' bottom left hidden';
|
|
3557
|
-
|
|
3558
|
-
const listDOM = document.createElement( 'f-list' );
|
|
3559
|
-
|
|
3560
|
-
dom.append( listDOM );
|
|
3561
|
-
|
|
3562
|
-
this.dom = dom;
|
|
3563
|
-
this.listDOM = listDOM;
|
|
3564
|
-
|
|
3565
|
-
this.visible = false;
|
|
3566
|
-
|
|
3567
|
-
this.align = 'bottom left';
|
|
3568
|
-
|
|
3569
|
-
this.subMenus = new WeakMap();
|
|
3570
|
-
this.domButtons = new WeakMap();
|
|
3571
|
-
|
|
3572
|
-
this.buttons = [];
|
|
3573
|
-
|
|
3574
|
-
this.events = {};
|
|
3575
|
-
|
|
3576
|
-
}
|
|
3577
|
-
|
|
3578
|
-
onContext( callback ) {
|
|
3579
|
-
|
|
3580
|
-
this.events.context.push( callback );
|
|
3581
|
-
|
|
3582
|
-
return this;
|
|
3583
|
-
|
|
3584
|
-
}
|
|
3585
|
-
|
|
3586
|
-
setAlign( align ) {
|
|
3587
|
-
|
|
3588
|
-
const dom = this.dom;
|
|
3589
|
-
|
|
3590
|
-
removeDOMClass( dom, this.align );
|
|
3591
|
-
addDOMClass( dom, align );
|
|
3592
|
-
|
|
3593
|
-
this.align = align;
|
|
3594
|
-
|
|
3595
|
-
return this;
|
|
3596
|
-
|
|
3597
|
-
}
|
|
3598
|
-
|
|
3599
|
-
getAlign() {
|
|
3600
|
-
|
|
3601
|
-
return this.align;
|
|
3602
|
-
|
|
3603
|
-
}
|
|
3604
|
-
|
|
3605
|
-
show() {
|
|
3606
|
-
|
|
3607
|
-
this.dom.classList.remove( 'hidden' );
|
|
3608
|
-
|
|
3609
|
-
this.visible = true;
|
|
3610
|
-
|
|
3611
|
-
this.dispatchEvent( new Event( 'show' ) );
|
|
3612
|
-
|
|
3613
|
-
return this;
|
|
3614
|
-
|
|
3615
|
-
}
|
|
3616
|
-
|
|
3617
|
-
hide() {
|
|
3618
|
-
|
|
3619
|
-
this.dom.classList.add( 'hidden' );
|
|
3620
|
-
|
|
3621
|
-
this.dispatchEvent( new Event( 'hide' ) );
|
|
3622
|
-
|
|
3623
|
-
this.visible = false;
|
|
3624
|
-
|
|
3625
|
-
}
|
|
3626
|
-
|
|
3627
|
-
add( button, submenu = null ) {
|
|
3628
|
-
|
|
3629
|
-
const liDOM = document.createElement( 'f-item' );
|
|
3630
|
-
|
|
3631
|
-
if ( submenu !== null ) {
|
|
3632
|
-
|
|
3633
|
-
liDOM.classList.add( 'submenu' );
|
|
3634
|
-
|
|
3635
|
-
liDOM.append( submenu.dom );
|
|
3636
|
-
|
|
3637
|
-
this.subMenus.set( button, submenu );
|
|
3638
|
-
|
|
3639
|
-
button.dom.addEventListener( 'mouseover', () => submenu.show() );
|
|
3640
|
-
button.dom.addEventListener( 'mouseout', () => submenu.hide() );
|
|
3641
|
-
|
|
3642
|
-
}
|
|
3643
|
-
|
|
3644
|
-
liDOM.append( button.dom );
|
|
3645
|
-
|
|
3646
|
-
this.buttons.push( button );
|
|
3647
|
-
|
|
3648
|
-
this.listDOM.append( liDOM );
|
|
3649
|
-
|
|
3650
|
-
this.domButtons.set( button, liDOM );
|
|
3651
|
-
|
|
3652
|
-
return this;
|
|
3653
|
-
|
|
3654
|
-
}
|
|
3655
|
-
|
|
3656
|
-
clear() {
|
|
3657
|
-
|
|
3658
|
-
this.buttons = [];
|
|
3659
|
-
|
|
3660
|
-
this.subMenus = new WeakMap();
|
|
3661
|
-
this.domButtons = new WeakMap();
|
|
3662
|
-
|
|
3663
|
-
while ( this.listDOM.firstChild ) {
|
|
3664
|
-
|
|
3665
|
-
this.listDOM.firstChild.remove();
|
|
3666
|
-
|
|
3667
|
-
}
|
|
3668
|
-
|
|
3669
|
-
}
|
|
3670
|
-
|
|
3671
|
-
}
|
|
3672
|
-
|
|
3673
|
-
let lastContext = null;
|
|
3674
|
-
|
|
3675
|
-
const onCloseLastContext = ( e ) => {
|
|
3676
|
-
|
|
3677
|
-
if ( lastContext && lastContext.visible === true && e.target.closest( 'f-menu.context' ) === null ) {
|
|
3678
|
-
|
|
3679
|
-
lastContext.hide();
|
|
3680
|
-
|
|
3681
|
-
}
|
|
3682
|
-
|
|
3683
|
-
};
|
|
3684
|
-
|
|
3685
|
-
document.body.addEventListener( 'mousedown', onCloseLastContext, true );
|
|
3686
|
-
document.body.addEventListener( 'touchstart', onCloseLastContext, true );
|
|
3687
|
-
|
|
3688
|
-
class ContextMenu extends Menu {
|
|
3689
|
-
|
|
3690
|
-
constructor( target = null ) {
|
|
3691
|
-
|
|
3692
|
-
super( 'context', target );
|
|
3693
|
-
|
|
3694
|
-
this.events.context = [];
|
|
3695
|
-
|
|
3696
|
-
this._lastButtonClick = null;
|
|
3697
|
-
|
|
3698
|
-
this._onButtonClick = ( e = null ) => {
|
|
3699
|
-
|
|
3700
|
-
const button = e ? e.target : null;
|
|
3701
|
-
|
|
3702
|
-
if ( this._lastButtonClick ) {
|
|
3703
|
-
|
|
3704
|
-
this._lastButtonClick.dom.parentElement.classList.remove( 'active' );
|
|
3705
|
-
|
|
3706
|
-
}
|
|
3707
|
-
|
|
3708
|
-
this._lastButtonClick = button;
|
|
3709
|
-
|
|
3710
|
-
if ( button ) {
|
|
3711
|
-
|
|
3712
|
-
if ( this.subMenus.has( button ) ) {
|
|
3713
|
-
|
|
3714
|
-
this.subMenus.get( button )._onButtonClick();
|
|
3715
|
-
|
|
3716
|
-
}
|
|
3717
|
-
|
|
3718
|
-
button.dom.parentElement.classList.add( 'active' );
|
|
3719
|
-
|
|
3720
|
-
}
|
|
3721
|
-
|
|
3722
|
-
};
|
|
3723
|
-
|
|
3724
|
-
this._onButtonMouseOver = ( e ) => {
|
|
3725
|
-
|
|
3726
|
-
const button = e.target;
|
|
3727
|
-
|
|
3728
|
-
if ( this.subMenus.has( button ) && this._lastButtonClick !== button ) {
|
|
3729
|
-
|
|
3730
|
-
this._onButtonClick();
|
|
3731
|
-
|
|
3732
|
-
}
|
|
3733
|
-
|
|
3734
|
-
};
|
|
3735
|
-
|
|
3736
|
-
this.addEventListener( 'context', ( ) => {
|
|
3737
|
-
|
|
3738
|
-
dispatchEventList( this.events.context, this );
|
|
3739
|
-
|
|
3740
|
-
} );
|
|
3741
|
-
|
|
3742
|
-
this.setTarget( target );
|
|
3743
|
-
|
|
3744
|
-
}
|
|
3745
|
-
|
|
3746
|
-
openFrom( dom ) {
|
|
3747
|
-
|
|
3748
|
-
const rect = dom.getBoundingClientRect();
|
|
3749
|
-
|
|
3750
|
-
return this.open( rect.x + ( rect.width / 2 ), rect.y + ( rect.height / 2 ) );
|
|
3751
|
-
|
|
3752
|
-
}
|
|
3753
|
-
|
|
3754
|
-
open( x = pointer.x, y = pointer.y ) {
|
|
3755
|
-
|
|
3756
|
-
if ( lastContext !== null ) {
|
|
3757
|
-
|
|
3758
|
-
lastContext.hide();
|
|
3759
|
-
|
|
3760
|
-
}
|
|
3761
|
-
|
|
3762
|
-
lastContext = this;
|
|
3763
|
-
|
|
3764
|
-
this.setPosition( x, y );
|
|
3765
|
-
|
|
3766
|
-
document.body.append( this.dom );
|
|
3767
|
-
|
|
3768
|
-
return this.show();
|
|
3769
|
-
|
|
3770
|
-
}
|
|
3771
|
-
|
|
3772
|
-
setPosition( x, y ) {
|
|
3773
|
-
|
|
3774
|
-
const dom = this.dom;
|
|
3775
|
-
|
|
3776
|
-
dom.style.left = numberToPX( x );
|
|
3777
|
-
dom.style.top = numberToPX( y );
|
|
3778
|
-
|
|
3779
|
-
return this;
|
|
3780
|
-
|
|
3781
|
-
}
|
|
3782
|
-
|
|
3783
|
-
setTarget( target = null ) {
|
|
3784
|
-
|
|
3785
|
-
if ( target !== null ) {
|
|
3786
|
-
|
|
3787
|
-
const onContextMenu = ( e ) => {
|
|
3788
|
-
|
|
3789
|
-
e.preventDefault();
|
|
3790
|
-
|
|
3791
|
-
if ( e.pointerType !== 'mouse' || ( e.pageX === 0 && e.pageY === 0 ) ) return;
|
|
3792
|
-
|
|
3793
|
-
this.dispatchEvent( new Event( 'context' ) );
|
|
3794
|
-
|
|
3795
|
-
this.open();
|
|
3796
|
-
|
|
3797
|
-
};
|
|
3798
|
-
|
|
3799
|
-
this.target = target;
|
|
3800
|
-
|
|
3801
|
-
target.addEventListener( 'contextmenu', onContextMenu, false );
|
|
3802
|
-
|
|
3803
|
-
}
|
|
3804
|
-
|
|
3805
|
-
return this;
|
|
3806
|
-
|
|
3807
|
-
}
|
|
3808
|
-
|
|
3809
|
-
show() {
|
|
3810
|
-
|
|
3811
|
-
if ( ! this.opened ) {
|
|
3812
|
-
|
|
3813
|
-
this.dom.style.left = '';
|
|
3814
|
-
this.dom.style.transform = '';
|
|
3815
|
-
|
|
3816
|
-
}
|
|
3817
|
-
|
|
3818
|
-
const domRect = this.dom.getBoundingClientRect();
|
|
3819
|
-
|
|
3820
|
-
let offsetX = Math.min( window.innerWidth - ( domRect.x + domRect.width + 10 ), 0 );
|
|
3821
|
-
let offsetY = Math.min( window.innerHeight - ( domRect.y + domRect.height + 10 ), 0 );
|
|
3822
|
-
|
|
3823
|
-
if ( this.opened ) {
|
|
3824
|
-
|
|
3825
|
-
if ( offsetX < 0 ) offsetX = - domRect.width;
|
|
3826
|
-
if ( offsetY < 0 ) offsetY = - domRect.height;
|
|
3827
|
-
|
|
3828
|
-
this.setPosition( domRect.x + offsetX, domRect.y + offsetY );
|
|
3829
|
-
|
|
3830
|
-
} else {
|
|
3831
|
-
|
|
3832
|
-
// flip submenus
|
|
3833
|
-
|
|
3834
|
-
if ( offsetX < 0 ) this.dom.style.left = '-100%';
|
|
3835
|
-
if ( offsetY < 0 ) this.dom.style.transform = 'translateY( calc( 32px - 100% ) )';
|
|
3836
|
-
|
|
3837
|
-
}
|
|
3838
|
-
|
|
3839
|
-
return super.show();
|
|
3840
|
-
|
|
3841
|
-
}
|
|
3842
|
-
|
|
3843
|
-
hide() {
|
|
3844
|
-
|
|
3845
|
-
if ( this.opened ) {
|
|
3846
|
-
|
|
3847
|
-
lastContext = null;
|
|
3848
|
-
|
|
3849
|
-
}
|
|
3850
|
-
|
|
3851
|
-
return super.hide();
|
|
3852
|
-
|
|
3853
|
-
}
|
|
3854
|
-
|
|
3855
|
-
add( button, submenu = null ) {
|
|
3856
|
-
|
|
3857
|
-
button.addEventListener( 'click', this._onButtonClick );
|
|
3858
|
-
button.addEventListener( 'mouseover', this._onButtonMouseOver );
|
|
3859
|
-
|
|
3860
|
-
return super.add( button, submenu );
|
|
3861
|
-
|
|
3862
|
-
}
|
|
3863
|
-
|
|
3864
|
-
get opened() {
|
|
3865
|
-
|
|
3866
|
-
return lastContext === this;
|
|
3867
|
-
|
|
3868
|
-
}
|
|
3869
|
-
|
|
3870
|
-
}
|
|
3871
|
-
|
|
3872
|
-
class CircleMenu extends Menu {
|
|
3873
|
-
|
|
3874
|
-
constructor( target = null ) {
|
|
3875
|
-
|
|
3876
|
-
super( 'circle', target );
|
|
3877
|
-
|
|
3878
|
-
}
|
|
3879
|
-
|
|
3880
|
-
}
|
|
3881
|
-
|
|
3882
|
-
class Tips extends EventTarget {
|
|
3883
|
-
|
|
3884
|
-
constructor() {
|
|
3885
|
-
|
|
3886
|
-
super();
|
|
3887
|
-
|
|
3888
|
-
const dom = document.createElement( 'f-tips' );
|
|
3889
|
-
|
|
3890
|
-
this.dom = dom;
|
|
3891
|
-
|
|
3892
|
-
this.time = 0;
|
|
3893
|
-
this.duration = 3000;
|
|
3894
|
-
|
|
3895
|
-
}
|
|
3896
|
-
|
|
3897
|
-
message( str ) {
|
|
3898
|
-
|
|
3899
|
-
return this.tip( str );
|
|
3900
|
-
|
|
3901
|
-
}
|
|
3902
|
-
|
|
3903
|
-
error( str ) {
|
|
3904
|
-
|
|
3905
|
-
return this.tip( str, 'error' );
|
|
3906
|
-
|
|
3907
|
-
}
|
|
3908
|
-
|
|
3909
|
-
tip( html, className = '' ) {
|
|
3910
|
-
|
|
3911
|
-
const dom = document.createElement( 'f-tip' );
|
|
3912
|
-
dom.className = className;
|
|
3913
|
-
dom.innerHTML = html;
|
|
3914
|
-
|
|
3915
|
-
this.dom.prepend( dom );
|
|
3916
|
-
|
|
3917
|
-
//requestAnimationFrame( () => dom.style.opacity = 1 );
|
|
3918
|
-
|
|
3919
|
-
this.time = Math.min( this.time + this.duration, this.duration );
|
|
3920
|
-
|
|
3921
|
-
setTimeout( () => {
|
|
3922
|
-
|
|
3923
|
-
this.time = Math.max( this.time - this.duration, 0 );
|
|
3924
|
-
|
|
3925
|
-
dom.style.opacity = 0;
|
|
3926
|
-
|
|
3927
|
-
setTimeout( () => dom.remove(), 250 );
|
|
3928
|
-
|
|
3929
|
-
}, this.time );
|
|
3930
|
-
|
|
3931
|
-
return this;
|
|
3932
|
-
|
|
3933
|
-
}
|
|
3934
|
-
|
|
3935
|
-
}
|
|
3936
|
-
|
|
3937
|
-
const filterString = ( str ) => {
|
|
3938
|
-
|
|
3939
|
-
return str.trim().toLowerCase().replace( /\s\s+/g, ' ' );
|
|
3940
|
-
|
|
3941
|
-
};
|
|
3942
|
-
|
|
3943
|
-
class Search extends Menu {
|
|
3944
|
-
|
|
3945
|
-
constructor() {
|
|
3946
|
-
|
|
3947
|
-
super( 'search' );
|
|
3948
|
-
|
|
3949
|
-
this.events.submit = [];
|
|
3950
|
-
this.events.filter = [];
|
|
3951
|
-
|
|
3952
|
-
this.tags = new WeakMap();
|
|
3953
|
-
|
|
3954
|
-
const inputDOM = document.createElement( 'input' );
|
|
3955
|
-
inputDOM.placeholder = 'Type here';
|
|
3956
|
-
|
|
3957
|
-
let filter = true;
|
|
3958
|
-
let filterNeedUpdate = true;
|
|
3959
|
-
|
|
3960
|
-
inputDOM.addEventListener( 'focusout', () => {
|
|
3961
|
-
|
|
3962
|
-
filterNeedUpdate = true;
|
|
3963
|
-
|
|
3964
|
-
this.setValue( '' );
|
|
3965
|
-
|
|
3966
|
-
} );
|
|
3967
|
-
|
|
3968
|
-
inputDOM.onkeydown = ( e ) => {
|
|
3969
|
-
|
|
3970
|
-
const keyCode = e.keyCode;
|
|
3971
|
-
|
|
3972
|
-
if ( keyCode === 38 ) {
|
|
3973
|
-
|
|
3974
|
-
const index = this.filteredIndex;
|
|
3975
|
-
|
|
3976
|
-
if ( this.forceAutoComplete ) {
|
|
3977
|
-
|
|
3978
|
-
this.filteredIndex = index !== null ? ( index + 1 ) % ( this.filtered.length || 1 ) : 0;
|
|
3979
|
-
|
|
3980
|
-
} else {
|
|
3981
|
-
|
|
3982
|
-
this.filteredIndex = index !== null ? Math.min( index + 1, this.filtered.length - 1 ) : 0;
|
|
3983
|
-
|
|
3984
|
-
}
|
|
3985
|
-
|
|
3986
|
-
e.preventDefault();
|
|
3987
|
-
|
|
3988
|
-
filter = false;
|
|
3989
|
-
|
|
3990
|
-
} else if ( keyCode === 40 ) {
|
|
3991
|
-
|
|
3992
|
-
const index = this.filteredIndex;
|
|
3993
|
-
|
|
3994
|
-
if ( this.forceAutoComplete ) {
|
|
3995
|
-
|
|
3996
|
-
this.filteredIndex = index - 1;
|
|
3997
|
-
|
|
3998
|
-
if ( this.filteredIndex === null ) this.filteredIndex = this.filtered.length - 1;
|
|
3999
|
-
|
|
4000
|
-
} else {
|
|
4001
|
-
|
|
4002
|
-
this.filteredIndex = index !== null ? index - 1 : null;
|
|
4003
|
-
|
|
4004
|
-
}
|
|
4005
|
-
|
|
4006
|
-
e.preventDefault();
|
|
4007
|
-
|
|
4008
|
-
filter = false;
|
|
4009
|
-
|
|
4010
|
-
} else if ( keyCode === 13 ) {
|
|
4011
|
-
|
|
4012
|
-
this.value = this.currentFiltered ? this.currentFiltered.button.getValue() : inputDOM.value;
|
|
4013
|
-
|
|
4014
|
-
this.submit();
|
|
4015
|
-
|
|
4016
|
-
e.preventDefault();
|
|
4017
|
-
|
|
4018
|
-
filter = false;
|
|
4019
|
-
|
|
4020
|
-
} else {
|
|
4021
|
-
|
|
4022
|
-
filter = true;
|
|
4023
|
-
|
|
4024
|
-
}
|
|
4025
|
-
|
|
4026
|
-
};
|
|
4027
|
-
|
|
4028
|
-
inputDOM.onkeyup = () => {
|
|
4029
|
-
|
|
4030
|
-
if ( filter ) {
|
|
4031
|
-
|
|
4032
|
-
if ( filterNeedUpdate ) {
|
|
4033
|
-
|
|
4034
|
-
this.dispatchEvent( new Event( 'filter' ) );
|
|
4035
|
-
|
|
4036
|
-
filterNeedUpdate = false;
|
|
4037
|
-
|
|
4038
|
-
}
|
|
4039
|
-
|
|
4040
|
-
this.filter( inputDOM.value );
|
|
4041
|
-
|
|
4042
|
-
}
|
|
4043
|
-
|
|
4044
|
-
};
|
|
4045
|
-
|
|
4046
|
-
this.filtered = [];
|
|
4047
|
-
this.currentFiltered = null;
|
|
4048
|
-
|
|
4049
|
-
this.value = '';
|
|
4050
|
-
|
|
4051
|
-
this.forceAutoComplete = false;
|
|
4052
|
-
|
|
4053
|
-
this.dom.append( inputDOM );
|
|
4054
|
-
|
|
4055
|
-
this.inputDOM = inputDOM;
|
|
4056
|
-
|
|
4057
|
-
this.addEventListener( 'filter', ( ) => {
|
|
4058
|
-
|
|
4059
|
-
dispatchEventList( this.events.filter, this );
|
|
4060
|
-
|
|
4061
|
-
} );
|
|
4062
|
-
|
|
4063
|
-
this.addEventListener( 'submit', ( ) => {
|
|
4064
|
-
|
|
4065
|
-
dispatchEventList( this.events.submit, this );
|
|
4066
|
-
|
|
4067
|
-
} );
|
|
4068
|
-
|
|
4069
|
-
}
|
|
4070
|
-
|
|
4071
|
-
submit() {
|
|
4072
|
-
|
|
4073
|
-
this.dispatchEvent( new Event( 'submit' ) );
|
|
4074
|
-
|
|
4075
|
-
return this.setValue( '' );
|
|
4076
|
-
|
|
4077
|
-
}
|
|
4078
|
-
|
|
4079
|
-
setValue( value ) {
|
|
4080
|
-
|
|
4081
|
-
this.inputDOM.value = value;
|
|
4082
|
-
|
|
4083
|
-
this.filter( value );
|
|
4084
|
-
|
|
4085
|
-
return this;
|
|
4086
|
-
|
|
4087
|
-
}
|
|
4088
|
-
|
|
4089
|
-
getValue() {
|
|
4090
|
-
|
|
4091
|
-
return this.value;
|
|
4092
|
-
|
|
4093
|
-
}
|
|
4094
|
-
|
|
4095
|
-
onFilter( callback ) {
|
|
4096
|
-
|
|
4097
|
-
this.events.filter.push( callback );
|
|
4098
|
-
|
|
4099
|
-
return this;
|
|
4100
|
-
|
|
4101
|
-
}
|
|
4102
|
-
|
|
4103
|
-
onSubmit( callback ) {
|
|
4104
|
-
|
|
4105
|
-
this.events.submit.push( callback );
|
|
4106
|
-
|
|
4107
|
-
return this;
|
|
4108
|
-
|
|
4109
|
-
}
|
|
4110
|
-
|
|
4111
|
-
getFilterByButton( button ) {
|
|
4112
|
-
|
|
4113
|
-
for ( const filter of this.filtered ) {
|
|
4114
|
-
|
|
4115
|
-
if ( filter.button === button ) {
|
|
4116
|
-
|
|
4117
|
-
return filter;
|
|
4118
|
-
|
|
4119
|
-
}
|
|
4120
|
-
|
|
4121
|
-
}
|
|
4122
|
-
|
|
4123
|
-
return null;
|
|
4124
|
-
|
|
4125
|
-
}
|
|
4126
|
-
|
|
4127
|
-
add( button ) {
|
|
4128
|
-
|
|
4129
|
-
super.add( button );
|
|
4130
|
-
|
|
4131
|
-
const onDown = () => {
|
|
4132
|
-
|
|
4133
|
-
const filter = this.getFilterByButton( button );
|
|
4134
|
-
|
|
4135
|
-
this.filteredIndex = this.filtered.indexOf( filter );
|
|
4136
|
-
this.value = button.getValue();
|
|
4137
|
-
|
|
4138
|
-
this.submit();
|
|
4139
|
-
|
|
4140
|
-
};
|
|
4141
|
-
|
|
4142
|
-
button.dom.addEventListener( 'mousedown', onDown );
|
|
4143
|
-
button.dom.addEventListener( 'touchstart', onDown );
|
|
4144
|
-
|
|
4145
|
-
this.domButtons.get( button ).remove();
|
|
4146
|
-
|
|
4147
|
-
return this;
|
|
4148
|
-
|
|
4149
|
-
}
|
|
4150
|
-
|
|
4151
|
-
set filteredIndex( index ) {
|
|
4152
|
-
|
|
4153
|
-
if ( this.currentFiltered ) {
|
|
4154
|
-
|
|
4155
|
-
const buttonDOM = this.domButtons.get( this.currentFiltered.button );
|
|
4156
|
-
|
|
4157
|
-
buttonDOM.classList.remove( 'active' );
|
|
4158
|
-
|
|
4159
|
-
this.currentFiltered = null;
|
|
4160
|
-
|
|
4161
|
-
}
|
|
4162
|
-
|
|
4163
|
-
const filteredItem = this.filtered[ index ];
|
|
4164
|
-
|
|
4165
|
-
if ( filteredItem ) {
|
|
4166
|
-
|
|
4167
|
-
const buttonDOM = this.domButtons.get( filteredItem.button );
|
|
4168
|
-
|
|
4169
|
-
buttonDOM.classList.add( 'active' );
|
|
4170
|
-
|
|
4171
|
-
this.currentFiltered = filteredItem;
|
|
4172
|
-
|
|
4173
|
-
}
|
|
4174
|
-
|
|
4175
|
-
this.updateFilter();
|
|
4176
|
-
|
|
4177
|
-
}
|
|
4178
|
-
|
|
4179
|
-
get filteredIndex() {
|
|
4180
|
-
|
|
4181
|
-
return this.currentFiltered ? this.filtered.indexOf( this.currentFiltered ) : null;
|
|
4182
|
-
|
|
4183
|
-
}
|
|
4184
|
-
|
|
4185
|
-
setTag( button, tags ) {
|
|
4186
|
-
|
|
4187
|
-
this.tags.set( button, tags );
|
|
4188
|
-
|
|
4189
|
-
}
|
|
4190
|
-
|
|
4191
|
-
filter( text ) {
|
|
4192
|
-
|
|
4193
|
-
text = filterString( text );
|
|
4194
|
-
|
|
4195
|
-
const tags = this.tags;
|
|
4196
|
-
const filtered = [];
|
|
4197
|
-
|
|
4198
|
-
for ( const button of this.buttons ) {
|
|
4199
|
-
|
|
4200
|
-
const buttonDOM = this.domButtons.get( button );
|
|
4201
|
-
|
|
4202
|
-
buttonDOM.remove();
|
|
4203
|
-
|
|
4204
|
-
const buttonTags = tags.has( button ) ? ' ' + tags.get( button ) : '';
|
|
4205
|
-
|
|
4206
|
-
const label = filterString( button.getValue() + buttonTags );
|
|
4207
|
-
|
|
4208
|
-
if ( text && label.includes( text ) === true ) {
|
|
4209
|
-
|
|
4210
|
-
const score = text.length / label.length;
|
|
4211
|
-
|
|
4212
|
-
filtered.push( {
|
|
4213
|
-
button,
|
|
4214
|
-
score
|
|
4215
|
-
} );
|
|
4216
|
-
|
|
4217
|
-
}
|
|
4218
|
-
|
|
4219
|
-
}
|
|
4220
|
-
|
|
4221
|
-
filtered.sort( ( a, b ) => b.score - a.score );
|
|
4222
|
-
|
|
4223
|
-
this.filtered = filtered;
|
|
4224
|
-
this.filteredIndex = this.forceAutoComplete ? 0 : null;
|
|
4225
|
-
|
|
4226
|
-
}
|
|
4227
|
-
|
|
4228
|
-
updateFilter() {
|
|
4229
|
-
|
|
4230
|
-
const filteredIndex = Math.min( this.filteredIndex, this.filteredIndex - 3 );
|
|
4231
|
-
|
|
4232
|
-
for ( let i = 0; i < this.filtered.length; i ++ ) {
|
|
4233
|
-
|
|
4234
|
-
const button = this.filtered[ i ].button;
|
|
4235
|
-
const buttonDOM = this.domButtons.get( button );
|
|
4236
|
-
|
|
4237
|
-
buttonDOM.remove();
|
|
4238
|
-
|
|
4239
|
-
if ( i >= filteredIndex ) {
|
|
4240
|
-
|
|
4241
|
-
this.listDOM.append( buttonDOM );
|
|
4242
|
-
|
|
4243
|
-
}
|
|
4244
|
-
|
|
4245
|
-
}
|
|
4246
|
-
|
|
4247
|
-
}
|
|
4248
|
-
|
|
4249
|
-
}
|
|
4250
|
-
|
|
4251
|
-
class SelectInput extends Input {
|
|
4252
|
-
|
|
4253
|
-
constructor( options = [], value = null ) {
|
|
4254
|
-
|
|
4255
|
-
const dom = document.createElement( 'select' );
|
|
4256
|
-
super( dom );
|
|
4257
|
-
|
|
4258
|
-
dom.onchange = () => {
|
|
4259
|
-
|
|
4260
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
4261
|
-
|
|
4262
|
-
};
|
|
4263
|
-
|
|
4264
|
-
dom.onmousedown = dom.ontouchstart = () => {
|
|
4265
|
-
|
|
4266
|
-
this.dispatchEvent( new Event( 'click' ) );
|
|
4267
|
-
|
|
4268
|
-
};
|
|
4269
|
-
|
|
4270
|
-
this.setOptions( options, value );
|
|
4271
|
-
|
|
4272
|
-
}
|
|
4273
|
-
|
|
4274
|
-
setOptions( options, value = null ) {
|
|
4275
|
-
|
|
4276
|
-
const dom = this.dom;
|
|
4277
|
-
const defaultValue = dom.value;
|
|
4278
|
-
|
|
4279
|
-
let containsDefaultValue = false;
|
|
4280
|
-
|
|
4281
|
-
this.options = options;
|
|
4282
|
-
dom.innerHTML = '';
|
|
4283
|
-
|
|
4284
|
-
for ( let index = 0; index < options.length; index ++ ) {
|
|
4285
|
-
|
|
4286
|
-
let opt = options[ index ];
|
|
4287
|
-
|
|
4288
|
-
if ( typeof opt === 'string' ) {
|
|
4289
|
-
|
|
4290
|
-
opt = { name: opt, value: index };
|
|
4291
|
-
|
|
4292
|
-
}
|
|
4293
|
-
|
|
4294
|
-
const option = document.createElement( 'option' );
|
|
4295
|
-
option.innerText = opt.name;
|
|
4296
|
-
option.value = opt.value;
|
|
4297
|
-
|
|
4298
|
-
if ( containsDefaultValue === false && defaultValue === opt.value ) {
|
|
4299
|
-
|
|
4300
|
-
containsDefaultValue = true;
|
|
4301
|
-
|
|
4302
|
-
}
|
|
4303
|
-
|
|
4304
|
-
dom.append( option );
|
|
4305
|
-
|
|
4306
|
-
}
|
|
4307
|
-
|
|
4308
|
-
dom.value = value !== null ? value : containsDefaultValue ? defaultValue : '';
|
|
4309
|
-
|
|
4310
|
-
return this;
|
|
4311
|
-
|
|
4312
|
-
}
|
|
4313
|
-
|
|
4314
|
-
getOptions() {
|
|
4315
|
-
|
|
4316
|
-
return this._options;
|
|
4317
|
-
|
|
4318
|
-
}
|
|
4319
|
-
|
|
4320
|
-
serialize( data ) {
|
|
4321
|
-
|
|
4322
|
-
data.options = [ ...this.options ];
|
|
4323
|
-
|
|
4324
|
-
super.serialize( data );
|
|
4325
|
-
|
|
4326
|
-
}
|
|
4327
|
-
|
|
4328
|
-
deserialize( data ) {
|
|
4329
|
-
|
|
4330
|
-
const currentOptions = this.options;
|
|
4331
|
-
|
|
4332
|
-
if ( currentOptions.length === 0 ) {
|
|
4333
|
-
|
|
4334
|
-
this.setOptions( data.options );
|
|
4335
|
-
|
|
4336
|
-
}
|
|
4337
|
-
|
|
4338
|
-
super.deserialize( data );
|
|
4339
|
-
|
|
4340
|
-
}
|
|
4341
|
-
|
|
4342
|
-
}
|
|
4343
|
-
|
|
4344
|
-
class ToggleInput extends Input {
|
|
4345
|
-
|
|
4346
|
-
constructor( value = false ) {
|
|
4347
|
-
|
|
4348
|
-
const dom = document.createElement( 'input' );
|
|
4349
|
-
super( dom );
|
|
4350
|
-
|
|
4351
|
-
dom.type = 'checkbox';
|
|
4352
|
-
dom.className = 'toggle';
|
|
4353
|
-
dom.checked = value;
|
|
4354
|
-
|
|
4355
|
-
dom.onclick = () => this.dispatchEvent( new Event( 'click' ) );
|
|
4356
|
-
dom.onchange = () => this.dispatchEvent( new Event( 'change' ) );
|
|
4357
|
-
|
|
4358
|
-
}
|
|
4359
|
-
|
|
4360
|
-
setValue( val ) {
|
|
4361
|
-
|
|
4362
|
-
this.dom.checked = val;
|
|
4363
|
-
|
|
4364
|
-
this.dispatchEvent( new Event( 'change' ) );
|
|
4365
|
-
|
|
4366
|
-
return this;
|
|
4367
|
-
|
|
4368
|
-
}
|
|
4369
|
-
|
|
4370
|
-
getValue() {
|
|
4371
|
-
|
|
4372
|
-
return this.dom.checked;
|
|
4373
|
-
|
|
4374
|
-
}
|
|
4375
|
-
|
|
4376
|
-
}
|
|
4377
|
-
|
|
4378
|
-
var Flow = /*#__PURE__*/Object.freeze({
|
|
4379
|
-
__proto__: null,
|
|
4380
|
-
Element: Element,
|
|
4381
|
-
Input: Input,
|
|
4382
|
-
Node: Node,
|
|
4383
|
-
Canvas: Canvas,
|
|
4384
|
-
Serializer: Serializer,
|
|
4385
|
-
Styles: Styles,
|
|
4386
|
-
ObjectNode: ObjectNode,
|
|
4387
|
-
PanelNode: PanelNode,
|
|
4388
|
-
Menu: Menu,
|
|
4389
|
-
ContextMenu: ContextMenu,
|
|
4390
|
-
CircleMenu: CircleMenu,
|
|
4391
|
-
Tips: Tips,
|
|
4392
|
-
Search: Search,
|
|
4393
|
-
DraggableElement: DraggableElement,
|
|
4394
|
-
LabelElement: LabelElement,
|
|
4395
|
-
TitleElement: TitleElement,
|
|
4396
|
-
ButtonInput: ButtonInput,
|
|
4397
|
-
ColorInput: ColorInput,
|
|
4398
|
-
NumberInput: NumberInput,
|
|
4399
|
-
SelectInput: SelectInput,
|
|
4400
|
-
SliderInput: SliderInput,
|
|
4401
|
-
StringInput: StringInput,
|
|
4402
|
-
TextInput: TextInput,
|
|
4403
|
-
ToggleInput: ToggleInput
|
|
4404
|
-
});
|
|
4405
|
-
|
|
4406
|
-
class Loader extends EventTarget {
|
|
4407
|
-
|
|
4408
|
-
constructor( parseType = Loader.DEFAULT ) {
|
|
4409
|
-
|
|
4410
|
-
super();
|
|
4411
|
-
|
|
4412
|
-
this.parseType = parseType;
|
|
4413
|
-
|
|
4414
|
-
this.events = {
|
|
4415
|
-
'load': []
|
|
4416
|
-
};
|
|
4417
|
-
|
|
4418
|
-
}
|
|
4419
|
-
|
|
4420
|
-
setParseType( type ) {
|
|
4421
|
-
|
|
4422
|
-
this.parseType = type;
|
|
4423
|
-
|
|
4424
|
-
return this;
|
|
4425
|
-
|
|
4426
|
-
}
|
|
4427
|
-
|
|
4428
|
-
getParseType() {
|
|
4429
|
-
|
|
4430
|
-
return this.parseType;
|
|
4431
|
-
|
|
4432
|
-
}
|
|
4433
|
-
|
|
4434
|
-
onLoad( callback ) {
|
|
4435
|
-
|
|
4436
|
-
this.events.load.push( callback );
|
|
4437
|
-
|
|
4438
|
-
return this;
|
|
4439
|
-
|
|
4440
|
-
}
|
|
4441
|
-
|
|
4442
|
-
async load( url, lib = null ) {
|
|
4443
|
-
|
|
4444
|
-
return await fetch( url )
|
|
4445
|
-
.then( response => response.json() )
|
|
4446
|
-
.then( result => {
|
|
4447
|
-
|
|
4448
|
-
this.data = this.parse( result, lib );
|
|
4449
|
-
|
|
4450
|
-
dispatchEventList( this.events.load, this );
|
|
4451
|
-
|
|
4452
|
-
return this.data;
|
|
4453
|
-
|
|
4454
|
-
} )
|
|
4455
|
-
.catch( err => {
|
|
4456
|
-
|
|
4457
|
-
console.error( 'Loader:', err );
|
|
4458
|
-
|
|
4459
|
-
} );
|
|
4460
|
-
|
|
4461
|
-
}
|
|
4462
|
-
|
|
4463
|
-
parse( json, lib = null ) {
|
|
4464
|
-
|
|
4465
|
-
json = this._parseObjects( json, lib );
|
|
4466
|
-
|
|
4467
|
-
const parseType = this.parseType;
|
|
4468
|
-
|
|
4469
|
-
if ( parseType === Loader.DEFAULT ) {
|
|
4470
|
-
|
|
4471
|
-
const flowObj = new Flow[ json.type ]();
|
|
4472
|
-
|
|
4473
|
-
if ( flowObj.getSerializable() ) {
|
|
4474
|
-
|
|
4475
|
-
flowObj.deserialize( json );
|
|
4476
|
-
|
|
4477
|
-
}
|
|
4478
|
-
|
|
4479
|
-
return flowObj;
|
|
4480
|
-
|
|
4481
|
-
} else if ( parseType === Loader.OBJECTS ) {
|
|
4482
|
-
|
|
4483
|
-
return json;
|
|
4484
|
-
|
|
4485
|
-
}
|
|
4486
|
-
|
|
4487
|
-
}
|
|
4488
|
-
|
|
4489
|
-
_parseObjects( json, lib = null ) {
|
|
4490
|
-
|
|
4491
|
-
json = { ...json };
|
|
4492
|
-
|
|
4493
|
-
const objects = {};
|
|
4494
|
-
|
|
4495
|
-
for ( const id in json.objects ) {
|
|
4496
|
-
|
|
4497
|
-
const obj = json.objects[ id ];
|
|
4498
|
-
obj.objects = objects;
|
|
4499
|
-
|
|
4500
|
-
const Class = lib && lib[ obj.type ] ? lib[ obj.type ] : Flow[ obj.type ];
|
|
4501
|
-
|
|
4502
|
-
if ( ! Class ) {
|
|
4503
|
-
|
|
4504
|
-
console.error( `Class "${ obj.type }" not found!` );
|
|
4505
|
-
|
|
4506
|
-
}
|
|
4507
|
-
|
|
4508
|
-
objects[ id ] = new Class();
|
|
4509
|
-
|
|
4510
|
-
}
|
|
4511
|
-
|
|
4512
|
-
const ref = new WeakMap();
|
|
4513
|
-
|
|
4514
|
-
const deserializePass = ( prop = null ) => {
|
|
4515
|
-
|
|
4516
|
-
for ( const id in json.objects ) {
|
|
4517
|
-
|
|
4518
|
-
const newObject = objects[ id ];
|
|
4519
|
-
|
|
4520
|
-
if ( ref.has( newObject ) === false && ( prop === null || newObject[ prop ] === true ) ) {
|
|
4521
|
-
|
|
4522
|
-
ref.set( newObject, true );
|
|
4523
|
-
|
|
4524
|
-
if ( newObject.getSerializable() ) {
|
|
4525
|
-
|
|
4526
|
-
newObject.deserialize( json.objects[ id ] );
|
|
4527
|
-
|
|
4528
|
-
}
|
|
4529
|
-
|
|
4530
|
-
}
|
|
4531
|
-
|
|
4532
|
-
}
|
|
4533
|
-
|
|
4534
|
-
};
|
|
4535
|
-
|
|
4536
|
-
deserializePass( 'isNode' );
|
|
4537
|
-
deserializePass( 'isElement' );
|
|
4538
|
-
deserializePass( 'isInput' );
|
|
4539
|
-
deserializePass();
|
|
4540
|
-
|
|
4541
|
-
json.objects = objects;
|
|
4542
|
-
|
|
4543
|
-
return json;
|
|
4544
|
-
|
|
4545
|
-
}
|
|
4546
|
-
|
|
4547
|
-
}
|
|
4548
|
-
|
|
4549
|
-
Loader.DEFAULT = 'default';
|
|
4550
|
-
Loader.OBJECTS = 'objects';
|
|
4551
|
-
|
|
4552
|
-
export { ButtonInput, Canvas, CircleMenu, ColorInput, ContextMenu, DraggableElement, Element, Input, LabelElement, Loader, Menu, Node, NumberInput, ObjectNode, PanelNode, REVISION, Search, SelectInput, Serializer, SliderInput, StringInput, Styles, TextInput, Tips, TitleElement, ToggleInput, Utils };
|