Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimistic voxel updates #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
<RealityView audibleClicks>
<Attachment id="palette" template="attachments">
<.palette color={@color} />
</Attachment>
<ViewAttachmentEntity
attachment="palette"
transform:translation={[0, -@scale / 2, @scale / 2 + 0.03]}
transform:rotation={Nx.to_list(Quaternion.euler(-:math.pi / 2, 0, 0))}
/>
<%!-- <Attachment id="templates" template="attachments">
<HStack style="controlSize(.mini); padding(8); glassBackgroundEffect();">
<Button
:for={template <- @templates}
phx-click="load"
phx-value-template={template}
>
<%= template %>
</Button>
<Button
phx-click="clear"
style="tint(.red); buttonStyle(.borderedProminent);"
>
<Label systemImage="trash">Clear</Label>
</Button>
</HStack>
</Attachment> --%>
<%!-- <ViewAttachmentEntity
attachment="templates"
transform:translation={[@scale / 2 + 0.03, -@scale / 2, 0]}
transform:rotation={Nx.to_list(Quaternion.euler(-:math.pi / 2, -:math.pi / 2, 0))}
/> --%>
<.world
blocks={@blocks}

width={@width}
height={@height}
depth={@depth}

scale={@scale}
rotation={@rotation}
/>
</RealityView>
<OptimisticVoxelContext color={@color}>
<RealityView audibleClicks>
<Attachment id="palette" template="attachments">
<.palette color={@color} />
</Attachment>
<ViewAttachmentEntity
attachment="palette"
transform:translation={[0, -@scale / 2, @scale / 2 + 0.03]}
transform:rotation={Nx.to_list(Quaternion.euler(-:math.pi / 2, 0, 0))}
/>
<%!-- <Attachment id="templates" template="attachments">
<HStack style="controlSize(.mini); padding(8); glassBackgroundEffect();">
<Button
:for={template <- @templates}
phx-click="load"
phx-value-template={template}
>
<%= template %>
</Button>
<Button
phx-click="clear"
style="tint(.red); buttonStyle(.borderedProminent);"
>
<Label systemImage="trash">Clear</Label>
</Button>
</HStack>
</Attachment> --%>
<%!-- <ViewAttachmentEntity
attachment="templates"
transform:translation={[@scale / 2 + 0.03, -@scale / 2, 0]}
transform:rotation={Nx.to_list(Quaternion.euler(-:math.pi / 2, -:math.pi / 2, 0))}
/> --%>
<.world
blocks={@blocks}

width={@width}
height={@height}
depth={@depth}

scale={@scale}
rotation={@rotation}
/>
</RealityView>
</OptimisticVoxelContext>
38 changes: 20 additions & 18 deletions lib/elixirconf_voxels_web/live/swiftui/voxels_live.swiftui.neex
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<Group style='inspector(isPresented: attr("inspector-open"), content: :inspector)' inspector-open>
<RealityView
camera="virtual"
style="realityViewCameraControls(.orbit); safeAreaInset(edge: .bottom, content: :palette)"
>
<.world
blocks={@blocks}

width={@width}
height={@height}
depth={@depth}

scale={@scale}
rotation={@rotation}
/>
<OptimisticVoxelContext color={@color}>
<RealityView
camera="virtual"
style="realityViewCameraControls(.orbit); safeAreaInset(edge: .bottom, content: :palette)"
>
<.world
blocks={@blocks}

width={@width}
height={@height}
depth={@depth}

scale={@scale}
rotation={@rotation}
/>

<Group template="palette" style="background(.bar, in: .capsule)">
<.palette color={@color} />
</Group>
</RealityView>
<Group template="palette" style="background(.bar, in: .capsule)">
<.palette color={@color} />
</Group>
</RealityView>
</OptimisticVoxelContext>

<List template="inspector" style="interactiveDismissDisabled(true)">
<Section>
Expand Down
12 changes: 7 additions & 5 deletions lib/elixirconf_voxels_web/live/voxels_live.swiftui.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ defmodule ElixirconfVoxelsWeb.VoxelsLive.SwiftUI do

generateCollisionShapes
generateCollisionShapes:static

phx-click="set-block-relative"
phx-value-x={x}
phx-value-y={y}
phx-value-z={z}
>
<SimpleMaterial
template="materials"
Expand All @@ -85,6 +80,13 @@ defmodule ElixirconfVoxelsWeb.VoxelsLive.SwiftUI do
/>
<Group template="components">
<HoverEffectComponent />
<OptimisticVoxel
phx-click="set-block-relative"
phx-value-x={x}
phx-value-y={y}
phx-value-z={z}
phx-value-rotation={@rotation}
/>
</Group>
</ModelEntity>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
"floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"},
"gettext": {:hex, :gettext, "0.24.0", "6f4d90ac5f3111673cbefc4ebee96fe5f37a114861ab8c7b7d5b30a1108ce6d8", [:mix], [{:expo, "~> 0.5.1", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "bdf75cdfcbe9e4622dd18e034b227d77dd17f0f133853a1c73b97b3d6c770e8b"},
"heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "88ab3a0d790e6a47404cba02800a6b25d2afae50", [tag: "v2.1.1", sparse: "optimized", depth: 1]},
"heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "88ab3a0d790e6a47404cba02800a6b25d2afae50", [tag: "v2.1.1", sparse: "optimized"]},
"hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"live_view_native": {:hex, :live_view_native, "0.3.0-rc.4", "f79f5367f3349285db18475f3486ff044fa6e79c5d347ee47fd545ce5cf16cd1", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.20.10", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0.4", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.15", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.5", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.5", [hex: :sourceror, repo: "hexpm", optional: false]}, {:text_diff, "~> 0.1", [hex: :text_diff, repo: "hexpm", optional: false]}], "hexpm", "07217194a59e3f32f16a77b2acb6f01fccb65349f3813d2c4e924bc8e9a659de"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import LiveViewNativeRealityKit

struct ContentView: View {
var body: some View {
#LiveView(
.automatic(
development: .localhost,
// production: URL(string: "https://example.com")!
production: .localhost
),
addons: [.realityKit]
LiveView(
registry: ElixirconfVoxelsRegistry.self,
// .automatic(
// development: .localhost,
//// production: URL(string: "https://example.com")!
// production: .localhost
// ),
// URL(string: "https://elixirconf-voxels.fly.dev/")!
.localhost
) {
ConnectingView()
} disconnected: {
Expand Down
Loading