From baf3ce68653fd8162e29e25b2247a0edcaed7ebf Mon Sep 17 00:00:00 2001 From: 4DBug <115124145+4DBug@users.noreply.github.com> Date: Sat, 17 Oct 2026 06:06:17 -0500 Subject: [PATCH] example: demo window only --- README.md | 2 +- examples/roblox/main.client.luau | 45 ++------------------------------ 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 36d3429..ff561cb 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ ImGui.End() ImPlot3D.ShowDemoWindow(true) ``` -Full LocalScript: `examples/roblox/main.client.luau` (rotating surface + demo windows). +Full LocalScript: `examples/roblox/main.client.luau` (ImPlot3D demo window). ## API differences from C++ diff --git a/examples/roblox/main.client.luau b/examples/roblox/main.client.luau index bd5bf5a..bf80ae7 100644 --- a/examples/roblox/main.client.luau +++ b/examples/roblox/main.client.luau @@ -1,4 +1,4 @@ --- Rotating surface + ImPlot3D / ImGui demo windows. +-- ImPlot3D demo window. local RS = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local G = require(RS:WaitForChild("ImGui")) @@ -6,54 +6,13 @@ local ImPlot3D = require(RS:WaitForChild("ImPlot3D"))(G) require(RS:WaitForChild("ImPlot3DDemo"))(G, ImPlot3D) local ImGui = G.ImGui -local N = 30 -local Xs, Ys, Zs = table.create(N * N, 0), table.create(N * N, 0), table.create(N * N, 0) -for j = 0, N - 1 do - for i = 0, N - 1 do - Xs[j * N + i + 1], Ys[j * N + i + 1] = i / (N - 1) * 2 - 1, j / (N - 1) * 2 - 1 - end -end -local Speed, ShowImPlot3DDemo, ShowImGuiDemo = 30, true, false -local StartClock = os.clock() - -local function RenderDemo() - local Time = os.clock() - StartClock - for k = 1, N * N do - local x, y = Xs[k], Ys[k] - Zs[k] = math.sin(3 * math.sqrt(x * x + y * y) - 2 * Time) * 0.5 - end - - ImGui.SetNextWindowSize(G.ImVec2(500, 500), G.ImGuiCond.FirstUseEver) - ImGui.Begin("Rotating Surface") - _, ShowImPlot3DDemo = ImGui.Checkbox("ImPlot3D Demo", ShowImPlot3DDemo) - ImGui.SameLine() - _, ShowImGuiDemo = ImGui.Checkbox("ImGui Demo", ShowImGuiDemo) - Speed = ImGui.SliderFloat("Speed (deg/s)", Speed, -180, 180) - if ImPlot3D.BeginPlot("##Surface", G.ImVec2(-1, -1)) then - ImPlot3D.SetupAxesLimits(-1, 1, -1, 1, -1, 1) - ImPlot3D.SetupBoxRotation(25, (Time * Speed) % 360 - 180, false, ImPlot3D.ImPlot3DCond.Always) - ImPlot3D.PushColormap(ImPlot3D.ImPlot3DColormap.Viridis) - ImPlot3D.PlotSurface("wave", Xs, Ys, Zs, N, N, { Flags = ImPlot3D.ImPlot3DSurfaceFlags.NoMarkers }) - ImPlot3D.PopColormap() - ImPlot3D.EndPlot() - end - ImGui.End() - - if ShowImPlot3DDemo then - ShowImPlot3DDemo = ImPlot3D.ShowDemoWindow(ShowImPlot3DDemo) - end - if ShowImGuiDemo then - ShowImGuiDemo = ImGui.ShowDemoWindow(ShowImGuiDemo) - end -end - ImGui.CreateContext() ImPlot3D.CreateContext() G.ImGui_ImplRoblox.Init() -- defaults to LocalPlayer.PlayerGui RunService.RenderStepped:Connect(function() G.ImGui_ImplRoblox.NewFrame() ImGui.NewFrame() - RenderDemo() + ImPlot3D.ShowDemoWindow() ImGui.Render() G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData()) end)