Skip to content

Commit

Permalink
added SimpleFreeFlyController
Browse files Browse the repository at this point in the history
  • Loading branch information
aardvark-platform committed Oct 27, 2024
1 parent c85e476 commit e549df1
Show file tree
Hide file tree
Showing 11 changed files with 466 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"rollForward": false
},
"adaptify": {
"version": "1.3.0",
"version": "1.3.4",
"commands": [
"adaptify"
],
Expand Down
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 1.0.8
* added SimpleFreeFlyController

### 1.0.7
* fixed `Aardvark.Dom.Utilites` package name typo

Expand Down
4 changes: 2 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nuget Aardvark.Rendering.Vulkan ~> 5.5.1
nuget Aardvark.Application.Slim.Vulkan ~> 5.5.1
nuget Aardvark.Rendering.Text ~> 5.5.1

nuget Adaptify.Core ~> 1.3.3
nuget Adaptify.MSBuild ~> 1.3.3
nuget Adaptify.Core ~> 1.3.4
nuget Adaptify.MSBuild ~> 1.3.4

nuget Giraffe ~> 7.0.0
41 changes: 12 additions & 29 deletions paket.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
STORAGE: NONE
RESTRICTION: || (== net8.0) (== netstandard2.0)
RESTRICTION: == net8.0
NUGET
remote: https://api.nuget.org/v3/index.json
Aardvark.Application (5.5.2)
Expand Down Expand Up @@ -139,10 +139,10 @@ NUGET
FShade.Core (>= 5.6 < 5.7)
FShade.GLSL (>= 5.6)
FSharp.Core (>= 8.0)
Adaptify.Core (1.3.3)
Adaptify.Core (1.3.4)
FSharp.Data.Adaptive (>= 1.2.14 < 1.3)
Adaptify.MSBuild (1.3.3)
Adaptify.Core (1.3.3)
Adaptify.MSBuild (1.3.4)
Adaptify.Core (1.3.4)
CommonMark.NET (0.15.1)
FShade (5.6)
FShade.Core (5.6)
Expand Down Expand Up @@ -175,36 +175,32 @@ NUGET
FSharp.Data.Adaptive (1.2.15)
FSharp.Core (>= 4.7)
System.Reflection.Emit.Lightweight (>= 4.6)
FSharp.SystemTextJson (1.3.13) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net6.0))
FSharp.SystemTextJson (1.3.13)
FSharp.Core (>= 4.7)
System.Text.Json (>= 6.0)
FsPickler (5.3.2)
FSharp.Core (>= 4.3.2)
System.Reflection.Emit.Lightweight (>= 4.3)
FuzzySharp (2.0.2)
Giraffe (7.0.2)
FSharp.Core (>= 6.0) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net6.0))
FSharp.SystemTextJson (>= 1.3.13) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net6.0))
Giraffe.ViewEngine (>= 1.4) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net6.0))
Microsoft.IO.RecyclableMemoryStream (>= 3.0.1) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net6.0))
System.Text.Json (>= 8.0.5) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net6.0))
Giraffe.ViewEngine (1.4) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net6.0))
FSharp.Core (>= 6.0)
FSharp.SystemTextJson (>= 1.3.13)
Giraffe.ViewEngine (>= 1.4)
Microsoft.IO.RecyclableMemoryStream (>= 3.0.1)
System.Text.Json (>= 8.0.5)
Giraffe.ViewEngine (1.4)
FSharp.Core (>= 5.0)
GLSLangSharp (0.4.15)
FSharp.Core (>= 5.0)
Microsoft.Bcl.HashCode (1.1.1) - restriction: || (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
Microsoft.CSharp (4.7)
Microsoft.DotNet.PlatformAbstractions (3.1.6)
Microsoft.Extensions.DependencyModel (8.0.1)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Text.Encodings.Web (>= 8.0)
System.Text.Json (>= 8.0.4)
Microsoft.IO.RecyclableMemoryStream (3.0.1) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net6.0))
Microsoft.IO.RecyclableMemoryStream (3.0.1)
Microsoft.NETCore.Platforms (7.0.4)
Microsoft.NETCore.Targets (5.0)
Silk.NET.Core (2.15)
Microsoft.Bcl.HashCode (>= 1.1.1) - restriction: || (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
Microsoft.CSharp (>= 4.7)
Microsoft.DotNet.PlatformAbstractions (>= 3.1.6)
Microsoft.Extensions.DependencyModel (>= 5.0)
Expand All @@ -215,15 +211,11 @@ NUGET
Silk.NET.Core (>= 2.15)
Ultz.Native.GLFW (>= 3.3.3.1)
SingleFileExtractor.Core (2.2.1)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
System.Buffers (4.5.1) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Collections (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.NETCore.Targets (>= 1.1)
System.Runtime (>= 4.3)
System.Collections.Immutable (8.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Diagnostics.Debug (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.NETCore.Targets (>= 1.1)
Expand Down Expand Up @@ -278,9 +270,6 @@ NUGET
System.Runtime.Extensions (>= 4.3)
System.Threading (>= 4.3)
System.Memory (4.5.5)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= xamarinios)) (&& (== net8.0) (>= xamarinmac)) (&& (== net8.0) (>= xamarintvos)) (&& (== net8.0) (>= xamarinwatchos)) (== netstandard2.0)
System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net8.0) (< netcoreapp2.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (< netcoreapp2.1)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= uap10.1)) (&& (== net8.0) (>= xamarinios)) (&& (== net8.0) (>= xamarinmac)) (&& (== net8.0) (>= xamarintvos)) (&& (== net8.0) (>= xamarinwatchos)) (== netstandard2.0)
System.Numerics.Vectors (4.5)
System.ObjectModel (4.3)
System.Collections (>= 4.3)
Expand All @@ -295,18 +284,15 @@ NUGET
System.Reflection.Primitives (>= 4.3)
System.Runtime (>= 4.3)
System.Reflection.Emit (4.7)
System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net8.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= uap10.1)) (== netstandard2.0)
System.Reflection.Emit.ILGeneration (4.7)
System.Reflection.Emit.Lightweight (4.7)
System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net8.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (< portable-net45+wp8)) (&& (== net8.0) (>= uap10.1)) (== netstandard2.0)
System.Reflection.Extensions (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.NETCore.Targets (>= 1.1)
System.Reflection (>= 4.3)
System.Runtime (>= 4.3)
System.Reflection.Metadata (8.0)
System.Collections.Immutable (>= 8.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Reflection.Primitives (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.NETCore.Targets (>= 1.1)
Expand All @@ -331,9 +317,6 @@ NUGET
Microsoft.NETCore.Targets (>= 1.1)
System.Runtime (>= 4.3)
System.Text.Encodings.Web (8.0)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Text.Json (8.0.5)
System.Threading (4.3)
System.Runtime (>= 4.3)
Expand Down
6 changes: 6 additions & 0 deletions src/Aardvark.Dom.Utilities/Aardvark.Dom.Utilities.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<OutputPath>..\..\bin\$(Configuration)\</OutputPath>
<LocalAdaptify>true</LocalAdaptify>
</PropertyGroup>
<ItemGroup>
<None Include="paket.references" />
<None Include="paket.template" />
<Compile Include="Utilites.fs" />
<Compile Include="OrbitController\OrbitState.fs" />
<Compile Include="OrbitController\OrbitState.g.fs" />
<Compile Include="OrbitController\OrbitController.fs" />
<Compile Include="OrbitController\RenderControlExtensions.fs" />
<Compile Include="FreeFlyController\FreeFlyModel.fs" />
<Compile Include="FreeFlyController\FreeFlyModel.g.fs" />
<Compile Include="FreeFlyController\FreeFlyController.fs" />
<Compile Include="FreeFlyController\FreeFlyControlExtensions.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Aardvark.Dom.Elm\Aardvark.Dom.Elm.fsproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
namespace Aardvark.Dom.Utilities

open System
open FSharp.Data.Adaptive
open Aardvark.Rendering
open Aardvark.Base
open Aardvark.Dom
open Aardvark.Dom.Utilities
open Aardvark.Dom.Utilities.FreeFlyController

type SimpleFreeFlyConfig =
{
Location : V3d
LookAt : V3d
Sky : V3d
}

type SimpleFreeFlyController = SimpleFreeFlyController of SimpleFreeFlyConfig

[<AutoOpen>]
module RenderControlFreeFlyExtensions =

let private freeFly (SimpleFreeFlyController config) : NodeBuilderHelpers.RenderControlBuilder<aval<Trafo3d>> =

let mutable state =
{
LastRender = TimeSpan.Zero
Position = config.Location
Sky = config.Sky
Forward = Vec.normalize (config.LookAt - config.Location)

MoveSpeed = 1.0
Damping = 20.0

MoveVec = V3i.Zero
Momentum = V3d.Zero
TargetTurn = V2d.Zero
Camera = CameraView.lookAt config.Location config.LookAt config.Sky
}
let astate = AdaptiveFreeFlyState state

let coll = AsyncBlockingCollection<_>()

let env =
{ new Env<FreeFlyMessage> with
member this.Emit(messages: FreeFlyMessage seq): unit =
coll.Add messages
member this.Run(js: string, arg1: (System.Text.Json.JsonElement -> unit) option): unit =
raise (System.NotImplementedException())
member this.RunModal(modal: System.IDisposable -> DomNode): System.IDisposable =
raise (System.NotImplementedException())
member this.Runtime: IRuntime =
failwith ""
member this.StartWorker(): System.Threading.Tasks.Task<WorkerInstance<'b,'a>> =
raise (System.NotImplementedException())
}
let runner =
task {
while true do
let! msgs = coll.Take()
for msg in msgs do
state <- FreeFlyController.update state msg
transact (fun () -> astate.Update state)


}

let view = astate.Camera |> AVal.map CameraView.viewTrafo
let run =
renderControlExt {
RenderControl.OnRendered (fun _ -> env.Emit [FreeFlyMessage.Rendered])
FreeFlyController.getAttributes env
Sg.View view
}
fun a -> run a; view

type RenderControlBuilder with


member x.Yield(config : SimpleFreeFlyController) =
x.Yield (freeFly config >> ignore)

member x.Bind(config : SimpleFreeFlyController, cont : aval<Trafo3d> -> _) =
x.Bind(freeFly config, cont)









Loading

0 comments on commit e549df1

Please sign in to comment.