protected FluidSimulationComponent(IEmbeddedResources embeddedResources)
        {
            this.embeddedResources = embeddedResources;
            //var size = new IntSize3(20, 20, 1);
            //var cellSize = 0.40f;
            //var particleRadius = 0.25f;
            fluidSimulation = new FluidSimulation(1f, 1f, 0.25f);

            visualElements   = new List <IVisualElement>();
            interactionElems = new IInteractionElement[]
            {
                //new SelectOnClickInteractionElement(this, viewService),
                new ActionOnEventInteractionElement(
                    args => args is IMouseEvent m && m.IsRightClickEvent() && m.KeyModifiers == KeyModifiers.None,
                    () =>
                {
                    if (simulationRunning)
                    {
                        fluidSimulation.Stop();
                    }
                    else
                    {
                        if (firstTime)
                        {
                            fluidSimulation.Reset(CreateConfig());
                            Reset();
                            firstTime = false;
                        }
                        prevFrame = nextFrame = null;
                        fluidSimulation.Run(simulationTimestamp + 5);
                    }
                    simulationRunning = !simulationRunning;
                }),
                new ActionOnEventInteractionElement(
                    args => args is IMouseEvent m && m.IsRightClickEvent() && m.KeyModifiers == KeyModifiers.Shift,
                    () =>
                {
                    Reset();
                }),
            };

            hittable = new SphereHittable <FluidSimulationComponent>(this, c => c.model.BoundingSphere * c.Node.GlobalTransform);

            Width         = 20;
            Height        = 20;
            CellSize      = 0.8f;
            LevelSetScale = 16;
            SurfaceType   = FluidSurfaceType.Hybrid;
            Reset();
        }
        private void Reset()
        {
            simulationRunning   = false;
            simulationTimestamp = 0;
            prevQueue           = new Queue <FluidSimulationFrame>();
            var size     = new IntSize3(Width, Height, 1);
            var cellSize = CellSize;

            fluidSimulation.Reset(CreateConfig());
            model             = CreateModel(size, cellSize, fluidSimulation.Particles.Length);
            levelSetImageData = new byte[fluidSimulation.LevelSet.Size.Width * fluidSimulation.LevelSet.Size.Height * 4];
            levelSetImage     = new RawImage(ResourceVolatility.Volatile, new IntSize2(fluidSimulation.LevelSet.Size.Width, fluidSimulation.LevelSet.Size.Height), true, levelSetImageData);
            squareModel       = embeddedResources.SimplePlaneXyModel();
            visualElements.Clear();
            visualElements.Add(ModelVisualElement.New()
                               .SetModel(model)
                               .SetMaterial(StandardMaterial.New()
                                            .SetDiffuseColor(Color4.Yellow)
                                            .SetIgnoreLighting(true)
                                            .FromGlobalCache()));
            visualElements.Add(ModelVisualElement.New()
                               .SetModel(model)
                               .SetModelPartIndex(1)
                               .SetMaterial(StandardMaterial.New()
                                            .SetDiffuseColor(Color4.White)
                                            .SetIgnoreLighting(true)
                                            .FromGlobalCache())
                               .SetRenderState(StandardRenderState.New()
                                               .SetPointSize(3)
                                               .FromGlobalCache()));
            visualElements.Add(ModelVisualElement.New()
                               .SetModel(squareModel)
                               .SetMaterial(StandardMaterial.New()
                                            .SetDiffuseMap(levelSetImage)
                                            .SetIgnoreLighting(true)
                                            .FromGlobalCache())
                               .SetTransform(new Transform(cellSize * size.Width / 2, Quaternion.Identity, new Vector3(cellSize * size.Width / 2, cellSize * size.Height / 2, -0.1f))));
        }