Roblox example: rotating surface + ImPlot3D demo window; test.sh runs it

This commit is contained in:
4DBug committed 2026-10-17 05:50:21 -05:00
1 parent e851553b01
commit 815359cd4b
2 files changed
+50 -2

No files matched your search

+46 -2
View File
@@ -1,15 +1,59 @@
-- Rotating surface + ImPlot3D / ImGui demo windows.
local RS = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local G = require(RS:WaitForChild("ImGui"))
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()
G.ImGui_ImplRoblox.Init()
ImPlot3D.CreateContext()
G.ImGui_ImplRoblox.Init() -- defaults to LocalPlayer.PlayerGui
RunService.RenderStepped:Connect(function()
G.ImGui_ImplRoblox.NewFrame()
ImGui.NewFrame()
-- ImPlot3D example goes here
RenderDemo()
ImGui.Render()
G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData())
end)
+4
View File
@@ -6,4 +6,8 @@ for t in tests/t_*.luau; do
out=$(python3 tools/core/tools/test/run.py --module ImPlot3D=ImPlot3D.lua --module ImPlot3DDemo=ImPlot3DDemo.lua --main "$t" --quiet --roblox 2>&1)
if echo "$out" | grep -q "^OK"; then echo "PASS $t"; else echo "FAIL $t"; echo "$out" | tail -20; fail=1; fi
done
# example LocalScript: 400 frames of random input (mock drives Stepped, not RenderStepped)
ex=$(mktemp --suffix=.luau); sed 's/RenderStepped/Stepped/' examples/roblox/main.client.luau > "$ex"
out=$(python3 tools/core/tools/test/run.py --module ImPlot3D=ImPlot3D.lua --module ImPlot3DDemo=ImPlot3DDemo.lua --main "$ex" --roblox 2>&1); rm -f "$ex"
if echo "$out" | grep -q "^avg frame"; then echo "PASS examples/roblox/main.client.luau"; else echo "FAIL examples/roblox/main.client.luau"; echo "$out" | tail -20; fail=1; fi
exit $fail