Compare commits
38
Commits
master
..
728156744d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
728156744d | ||
|
|
bf7c912b24 | ||
|
|
166dc11a4a | ||
|
|
f53adea974 | ||
|
|
ddf53e2616 | ||
|
|
9650439e40 | ||
|
|
160d484991 | ||
|
|
904f33d8d5 | ||
|
|
b3d1a45623 | ||
|
|
7aef09938d | ||
|
|
f0a0e15a25 | ||
|
|
cf7b571258 | ||
|
|
dae16d0de6 | ||
|
|
a5f1c9f8b7 | ||
|
|
55ac231fba | ||
|
|
0e6847dac8 | ||
|
|
2c4a449803 | ||
|
|
22f61b640d | ||
|
|
92f6bbd5d9 | ||
|
|
7e8cfd3201 | ||
|
|
571516b876 | ||
|
|
2f47c8fa87 | ||
|
|
24e97c6c50 | ||
|
|
1c7ef54aa4 | ||
|
|
26c166c325 | ||
|
|
05d0ada276 | ||
|
|
91cbbd19b2 | ||
|
|
45f4f92cc4 | ||
|
|
b309342400 | ||
|
|
dcebea372b | ||
|
|
788e66931b | ||
|
|
99ab6b705e | ||
|
|
9a03d3b9b3 | ||
|
|
8ba623047f | ||
|
|
568cf0212c | ||
|
|
237b2dd627 | ||
|
|
3aea9793f6 | ||
|
|
3f1c0da8a4 |
No files matched your search
@@ -1,3 +1,2 @@
|
||||
.gitattributes export-ignore
|
||||
tools/upstream/** linguist-vendored=true
|
||||
love/** linguist-generated=true
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
[submodule "tools/core"]
|
||||
path = tools/core
|
||||
url = https://github.com/4DBug/imgui-luau.git
|
||||
url = https://git.bug.tools/bug/imgui-luau.git
|
||||
+8
-60
@@ -255,7 +255,6 @@ return function(G)
|
||||
function internal.ImHasFlag(set, flag) return bit32.band(set, flag) == flag end
|
||||
local DBL_MAX = G.DBL_MAX
|
||||
-- Returns true if val is NAN or INFINITY
|
||||
@native
|
||||
function internal.ImNanOrInf(val) return not (val >= -DBL_MAX and val <= DBL_MAX) end
|
||||
-- Turns NANs to 0s
|
||||
function internal.ImConstrainNan(val) if val ~= val then return 0 end return val end
|
||||
@@ -286,7 +285,6 @@ return function(G)
|
||||
-- ImPlot3DPoint: 3D vector to store points in 3D space
|
||||
local PointMT = {}
|
||||
local PointMethods = {}
|
||||
@native
|
||||
local function ImPlot3DPoint(x, y, z)
|
||||
return setmetatable({ x = x or 0.0, y = y or 0.0, z = z or 0.0 }, PointMT)
|
||||
end
|
||||
@@ -295,14 +293,12 @@ return function(G)
|
||||
-- Accessors
|
||||
-- [Port] operator[]: 0 -> x, 1 -> y, 2 -> z
|
||||
local idx_keys = { [0] = "x", [1] = "y", [2] = "z" }
|
||||
@native
|
||||
function PointMT.__index(self, k)
|
||||
PointMT.__index = function(self, k)
|
||||
local f = idx_keys[k]
|
||||
if f then return rawget(self, f) end
|
||||
return PointMethods[k]
|
||||
end
|
||||
@native
|
||||
function PointMT.__newindex(self, k, v)
|
||||
PointMT.__newindex = function(self, k, v)
|
||||
local f = idx_keys[k]
|
||||
IM_ASSERT(f ~= nil)
|
||||
rawset(self, f, v)
|
||||
@@ -310,25 +306,20 @@ return function(G)
|
||||
|
||||
-- Binary operators
|
||||
-- [Port] operator*(double) / operator*(ImPlot3DPoint) / friend operator*(double, ImPlot3DPoint) overloads
|
||||
@native
|
||||
function PointMT.__mul(a, b)
|
||||
PointMT.__mul = function(a, b)
|
||||
if type(a) == "number" then return ImPlot3DPoint(a * b.x, a * b.y, a * b.z) end
|
||||
if type(b) == "number" then return ImPlot3DPoint(a.x * b, a.y * b, a.z * b) end
|
||||
return ImPlot3DPoint(a.x * b.x, a.y * b.y, a.z * b.z)
|
||||
end
|
||||
@native
|
||||
function PointMT.__div(a, b)
|
||||
PointMT.__div = function(a, b)
|
||||
if type(b) == "number" then return ImPlot3DPoint(a.x / b, a.y / b, a.z / b) end
|
||||
return ImPlot3DPoint(a.x / b.x, a.y / b.y, a.z / b.z)
|
||||
end
|
||||
@native
|
||||
function PointMT.__add(a, b) return ImPlot3DPoint(a.x + b.x, a.y + b.y, a.z + b.z) end
|
||||
@native
|
||||
function PointMT.__sub(a, b) return ImPlot3DPoint(a.x - b.x, a.y - b.y, a.z - b.z) end
|
||||
PointMT.__add = function(a, b) return ImPlot3DPoint(a.x + b.x, a.y + b.y, a.z + b.z) end
|
||||
PointMT.__sub = function(a, b) return ImPlot3DPoint(a.x - b.x, a.y - b.y, a.z - b.z) end
|
||||
|
||||
-- Unary operator
|
||||
@native
|
||||
function PointMT.__unm(a) return ImPlot3DPoint(-a.x, -a.y, -a.z) end
|
||||
PointMT.__unm = function(a) return ImPlot3DPoint(-a.x, -a.y, -a.z) end
|
||||
|
||||
-- Comparison operators
|
||||
PointMT.__eq = function(a, b) return a.x == b.x and a.y == b.y and a.z == b.z end
|
||||
@@ -336,17 +327,14 @@ return function(G)
|
||||
PointMT.__tostring = function(a) return string.format("ImPlot3DPoint(%g, %g, %g)", a.x, a.y, a.z) end
|
||||
|
||||
-- Dot product
|
||||
@native
|
||||
function PointMethods:Dot(rhs) return self.x * rhs.x + self.y * rhs.y + self.z * rhs.z end
|
||||
|
||||
-- Cross product
|
||||
@native
|
||||
function PointMethods:Cross(rhs)
|
||||
return ImPlot3DPoint(self.y * rhs.z - self.z * rhs.y, self.z * rhs.x - self.x * rhs.z, self.x * rhs.y - self.y * rhs.x)
|
||||
end
|
||||
|
||||
-- Get vector length
|
||||
@native
|
||||
function PointMethods:Length() return sqrt(self.x * self.x + self.y * self.y + self.z * self.z) end
|
||||
|
||||
-- Get vector squared length
|
||||
@@ -575,8 +563,7 @@ return function(G)
|
||||
|
||||
-- Binary operators
|
||||
-- [Port] operator*(ImPlot3DQuat) quaternion multiplication / operator*(ImPlot3DPoint) rotate a 3D point
|
||||
@native
|
||||
function QuatMT.__mul(q, rhs)
|
||||
QuatMT.__mul = function(q, rhs)
|
||||
local x, y, z, w = q.x, q.y, q.z, q.w
|
||||
if getmetatable(rhs) == PointMT then
|
||||
-- Extract vector part of the quaternion
|
||||
@@ -1024,7 +1011,6 @@ return function(G)
|
||||
function CM:GetTableSize(cmap) return self.TableSizes[cmap + 1] end
|
||||
function CM:GetTableColor(cmap, idx) return self.Tables[self.TableOffsets[cmap + 1] + idx + 1] end
|
||||
|
||||
@native
|
||||
function CM:LerpTable(cmap, t)
|
||||
local off = self.TableOffsets[cmap + 1]
|
||||
local siz = self.TableSizes[cmap + 1]
|
||||
@@ -1204,7 +1190,6 @@ return function(G)
|
||||
|
||||
function ImPlot3D.NextColormapColor() return ImGui.ColorConvertU32ToFloat4(internal.NextColormapColorU32()) end
|
||||
|
||||
@native
|
||||
local function ResolveCmap(gp, cmap)
|
||||
if cmap == nil or cmap == IMPLOT3D_AUTO then cmap = gp.Style.Colormap end
|
||||
IM_ASSERT(cmap >= 0 and cmap < gp.ColormapData.Count, "Invalid colormap index!")
|
||||
@@ -1226,7 +1211,6 @@ return function(G)
|
||||
|
||||
function ImPlot3D.GetColormapColor(idx, cmap) return ImGui.ColorConvertU32ToFloat4(internal.GetColormapColorU32(idx, cmap)) end
|
||||
|
||||
@native
|
||||
function internal.SampleColormapU32(t, cmap)
|
||||
local gp = GImPlot3D
|
||||
cmap = ResolveCmap(gp, cmap)
|
||||
@@ -1554,7 +1538,6 @@ return function(G)
|
||||
end
|
||||
end
|
||||
|
||||
@native
|
||||
function Axis:PlotToNDC(plt)
|
||||
if self.TransformForward ~= nil then
|
||||
local s = self.TransformForward(plt, self.TransformData)
|
||||
@@ -1623,7 +1606,6 @@ return function(G)
|
||||
function Axis:HasTickMarks() return not ImHasFlag(self.Flags, AxisFlags.NoTickMarks) end
|
||||
function Axis:IsAutoFitting() return ImHasFlag(self.Flags, AxisFlags.AutoFit) end
|
||||
|
||||
@native
|
||||
function Axis:ExtendFit(value)
|
||||
-- Only extend fit with values within the constraint range (log scale ignores <= 0)
|
||||
if not ImNanOrInf(value) and value >= self.ConstraintRange.Min and value <= self.ConstraintRange.Max then
|
||||
@@ -1721,7 +1703,6 @@ return function(G)
|
||||
end
|
||||
|
||||
-- Constant to convert from NDC coordinates to pixels coordinates
|
||||
@native
|
||||
function Plot:GetViewScale()
|
||||
return math.min(self.PlotRect:GetWidth(), self.PlotRect:GetHeight()) / 1.8 * GImPlot3D.Style.ViewScaleFactor
|
||||
end
|
||||
@@ -1910,7 +1891,6 @@ return function(G)
|
||||
end
|
||||
|
||||
-- Convert a position in the plot's NDC to pixels
|
||||
@native
|
||||
function internal.NDCToPixels(plot, point)
|
||||
local center = plot.PlotRect:GetCenter()
|
||||
local point_pix = plot:GetViewScale() * (plot.Rotation * point)
|
||||
@@ -1918,7 +1898,6 @@ return function(G)
|
||||
end
|
||||
|
||||
-- Convert a position in the plot's coordinate system to NDC
|
||||
@native
|
||||
function internal.PlotToNDC(plot, point)
|
||||
local ndc = P(0, 0, 0)
|
||||
for i = 0, 2 do
|
||||
@@ -3253,7 +3232,6 @@ return function(G)
|
||||
local HUGE = math.huge
|
||||
|
||||
-- Indexers / Getters
|
||||
@native
|
||||
local function GetXYZ(g, idx)
|
||||
local s, off = g.Stride, g.Offset
|
||||
local i = (if off == 0 then idx else (off + idx) % g.Count) * s + 1
|
||||
@@ -3263,16 +3241,12 @@ return function(G)
|
||||
return { Xs = xs, Ys = ys, Zs = zs, Count = count, Offset = if count > 0 then internal.ImPosMod(offset or 0, count) else 0,
|
||||
Stride = stride or 1, Get = GetXYZ }
|
||||
end
|
||||
@native
|
||||
local function GetLoop(g, idx) local inner = g.Getter return inner.Get(inner, idx % (g.Count - 1)) end
|
||||
function internal.GetterLoop(getter) return { Getter = getter, Count = getter.Count + 1, Get = GetLoop } end
|
||||
@native
|
||||
local function GetTriLines(g, idx) local inner = g.Getter return inner.Get(inner, ((idx % 6 + 1) // 2) % 3 + idx // 6 * 3) end
|
||||
function internal.GetterTriangleLines(getter) return { Getter = getter, Count = getter.Count * 2, Get = GetTriLines } end
|
||||
@native
|
||||
local function GetQuadLines(g, idx) local inner = g.Getter return inner.Get(inner, ((idx % 8 + 1) // 2) % 4 + idx // 8 * 4) end
|
||||
function internal.GetterQuadLines(getter) return { Getter = getter, Count = getter.Count * 2, Get = GetQuadLines } end
|
||||
@native
|
||||
local function GetSurfaceLines(g, idx)
|
||||
local endpoint_i, segment_i, xc = idx % 2, idx // 2, g.XCount
|
||||
local horizontal_segments = (xc - 1) * g.YCount
|
||||
@@ -3293,7 +3267,6 @@ return function(G)
|
||||
Count = ((x_count - 1) * y_count + (y_count - 1) * x_count) * 2 }
|
||||
end
|
||||
-- [Port] idx is a 1-based Lua array of 0-based vertex indices (upstream semantics)
|
||||
@native
|
||||
local function GetMeshTri(g, i) local v = g.Getter return v.Get(v, g.Idx[i + 1]) end
|
||||
function internal.GetterMeshTriangles(vtx_getter, idx, idx_count)
|
||||
return { Getter = vtx_getter, Idx = idx, TriCount = idx_count // 3, Count = idx_count, Get = GetMeshTri }
|
||||
@@ -3317,25 +3290,21 @@ return function(G)
|
||||
local c = plot.PlotRect:GetCenter()
|
||||
cx, cy = c.x, c.y
|
||||
end
|
||||
@native
|
||||
local function Rotate(x, y, z)
|
||||
local ux, uy, uz = qy * z - qz * y, qz * x - qx * z, qx * y - qy * x
|
||||
local vx, vy, vz = qy * uz - qz * uy, qz * ux - qx * uz, qx * uy - qy * ux
|
||||
return x + 2 * (qw * ux + vx), y + 2 * (qw * uy + vy), z + 2 * (qw * uz + vz)
|
||||
end
|
||||
@native
|
||||
local function NDC(i, v)
|
||||
local tf = ax_tf[i]
|
||||
if tf ~= nil then v = tf(v, ax_td[i]) end
|
||||
local t = (v - ax_min[i]) / ax_size[i]
|
||||
return (if ax_inv[i] then 0.5 - t else t - 0.5) * ax_ndc[i]
|
||||
end
|
||||
@native
|
||||
local function ToPixels(x, y, z)
|
||||
local rx, ry = Rotate(NDC(0, x), NDC(1, y), NDC(2, z))
|
||||
return rx * vscale + cx, -ry * vscale + cy
|
||||
end
|
||||
@native
|
||||
local function Depth(x, y, z)
|
||||
if ax_inv[0] then x = -x end
|
||||
if ax_inv[1] then y = -y end
|
||||
@@ -3349,7 +3318,6 @@ return function(G)
|
||||
-- [Port] upstream lambda -> module-level helper on ct0/ct1 (no closure per call)
|
||||
local bx0, by0, bz0, bx1, by1, bz1 = 0, 0, 0, 0, 0, 0
|
||||
local ct0, ct1 = 0.0, 1.0
|
||||
@native
|
||||
local function upd(p, q)
|
||||
if p == 0.0 then return q >= 0.0 end
|
||||
local r = q / p
|
||||
@@ -3362,7 +3330,6 @@ return function(G)
|
||||
end
|
||||
return true
|
||||
end
|
||||
@native
|
||||
local function Clip(x0, y0, z0, x1, y1, z1)
|
||||
if x0 >= bx0 and x0 <= bx1 and y0 >= by0 and y0 <= by1 and z0 >= bz0 and z0 <= bz1
|
||||
and x1 >= bx0 and x1 <= bx1 and y1 >= by0 and y1 <= by1 and z1 >= bz0 and z1 <= bz1 then
|
||||
@@ -3377,13 +3344,11 @@ return function(G)
|
||||
|
||||
-- [Port] ColorConvertU32ToFloat4 -> c.w *= alpha -> ColorConvertFloat4ToU32, without the ImVec4
|
||||
local band, bor, lshift, rshift, floor = bit32.band, bit32.bor, bit32.lshift, bit32.rshift, math.floor
|
||||
@native
|
||||
local function MulAlpha(col, alpha)
|
||||
return bor(band(col, 0x00FFFFFF), lshift(floor(rshift(col, 24) * alpha + 0.5), 24))
|
||||
end
|
||||
internal.MulAlpha = MulAlpha
|
||||
|
||||
@native
|
||||
local function GetCol(r, prim)
|
||||
local cols = r.Cols
|
||||
if cols == nil then return r.Col end
|
||||
@@ -3392,7 +3357,6 @@ return function(G)
|
||||
return col
|
||||
end
|
||||
|
||||
@native
|
||||
local function PrimLine(dl, x1, y1, x2, y2, hw, col, u0, v0, u1, v1, z)
|
||||
local dx, dy = x2 - x1, y2 - y1
|
||||
local d2 = dx * dx + dy * dy
|
||||
@@ -3425,7 +3389,6 @@ return function(G)
|
||||
end
|
||||
|
||||
-- Shared segment render: clip, project, emit (P1 -> P2)
|
||||
@native
|
||||
local function Segment(r, dl, prim, x1, y1, z1, x2, y2, z2)
|
||||
local t0, t1 = Clip(x1, y1, z1, x2, y2, z2)
|
||||
if t0 == nil then return false end
|
||||
@@ -3437,7 +3400,6 @@ return function(G)
|
||||
return true
|
||||
end
|
||||
|
||||
@native
|
||||
local function LineStripRender(r, dl, prim)
|
||||
local g = r.Getter
|
||||
local x2, y2, z2 = g.Get(g, prim + 1)
|
||||
@@ -3445,7 +3407,6 @@ return function(G)
|
||||
r.X1, r.Y1, r.Z1 = x2, y2, z2
|
||||
return vis
|
||||
end
|
||||
@native
|
||||
local function LineStripSkipRender(r, dl, prim)
|
||||
local g = r.Getter
|
||||
local x2, y2, z2 = g.Get(g, prim + 1)
|
||||
@@ -3457,7 +3418,6 @@ return function(G)
|
||||
if x2 == x2 and y2 == y2 and z2 == z2 then r.X1, r.Y1, r.Z1 = x2, y2, z2 end
|
||||
return vis
|
||||
end
|
||||
@native
|
||||
local function LineSegmentsRender(r, dl, prim)
|
||||
local g = r.Getter
|
||||
local x1, y1, z1 = g.Get(g, prim * 2)
|
||||
@@ -3477,7 +3437,6 @@ return function(G)
|
||||
return r
|
||||
end
|
||||
|
||||
@native
|
||||
local function MarkersFillRender(r, dl, prim)
|
||||
local g = r.Getter
|
||||
local x, y, z = g.Get(g, prim)
|
||||
@@ -3507,7 +3466,6 @@ return function(G)
|
||||
Getter = getter, Marker = marker, Count = count, Init = WhiteInit, Render = MarkersFillRender }
|
||||
end
|
||||
|
||||
@native
|
||||
local function MarkersLineRender(r, dl, prim)
|
||||
local g = r.Getter
|
||||
local x, y, z = g.Get(g, prim)
|
||||
@@ -3528,15 +3486,12 @@ return function(G)
|
||||
Init = LineInit, Render = MarkersLineRender }
|
||||
end
|
||||
|
||||
@native
|
||||
local function InBox(x, y, z) return x >= bx0 and x <= bx1 and y >= by0 and y <= by1 and z >= bz0 and z <= bz1 end
|
||||
@native
|
||||
local function Vtx(b, o, x, y, z, u, v, col)
|
||||
local px, py = ToPixels(x, y, z)
|
||||
writef64(b, o, px); writef64(b, o + 8, py); writef64(b, o + 16, u); writef64(b, o + 24, v); writeu32(b, o + 32, col)
|
||||
end
|
||||
-- Two triangles (0,1,2) (0,2,3) for the 4 vertices just written
|
||||
@native
|
||||
local function QuadIdx(dl, z0, z1)
|
||||
local idx, id, iw = dl._VtxCurrentIdx, dl.IdxBuffer, dl._IdxWritePtr
|
||||
id[iw] = idx; id[iw + 1] = idx + 1; id[iw + 2] = idx + 2
|
||||
@@ -3546,7 +3501,6 @@ return function(G)
|
||||
dl._VtxWritePtr += 4; dl._IdxWritePtr = iw + 6; dl._VtxCurrentIdx = idx + 4; dl._ZWritePtr = zw + 2
|
||||
end
|
||||
|
||||
@native
|
||||
local function TriangleFillRender(r, dl, prim)
|
||||
local g, i = r.Getter, 3 * prim
|
||||
local x0, y0, z0 = g.Get(g, i)
|
||||
@@ -3567,7 +3521,6 @@ return function(G)
|
||||
return { Getter = getter, Prims = getter.Count // 3, IdxConsumed = 3, VtxConsumed = 3, Init = WhiteInit, Render = TriangleFillRender }
|
||||
end
|
||||
|
||||
@native
|
||||
local function QuadFillRender(r, dl, prim)
|
||||
local g, i = r.Getter, 4 * prim
|
||||
local x0, y0, z0 = g.Get(g, i)
|
||||
@@ -3606,7 +3559,6 @@ return function(G)
|
||||
Render = QuadFillRender, TexRef = tex_ref, UVs = uvs, Col = col }
|
||||
end
|
||||
|
||||
@native
|
||||
local function SurfaceInit(r)
|
||||
WhiteInit(r)
|
||||
-- Compute min and max values for the colormap (if not solid fill)
|
||||
@@ -3622,7 +3574,6 @@ return function(G)
|
||||
end
|
||||
end
|
||||
local SampleU32
|
||||
@native
|
||||
local function SurfaceCol(r, vi, z)
|
||||
local s = r.N.Spec
|
||||
if s.FillColors ~= nil then return MulAlpha(s.FillColors[vi + 1], s.FillAlpha) end
|
||||
@@ -3635,7 +3586,6 @@ return function(G)
|
||||
end
|
||||
return r.Col
|
||||
end
|
||||
@native
|
||||
local function SurfaceFillRender(r, dl, prim)
|
||||
local xc = r.XCount
|
||||
local x, y = prim % (xc - 1), prim // (xc - 1)
|
||||
@@ -3662,7 +3612,6 @@ return function(G)
|
||||
end
|
||||
|
||||
-- [Port] color getter (GetterConstColor/GetterIdxColor) and size getter folded into renderer fields
|
||||
@native
|
||||
function internal.RenderPrimitivesEx(r, col, cols, alpha, size, sizes)
|
||||
local plot = GImPlot3D.CurrentPlot
|
||||
local dl = plot.DrawList
|
||||
@@ -4167,7 +4116,6 @@ return function(G)
|
||||
end
|
||||
|
||||
-- Move triangles to the current window draw list, sorted by depth
|
||||
@native
|
||||
function DL3:SortedMoveToImGuiDrawList()
|
||||
local draw_list = ImGui.GetWindowDrawList()
|
||||
local tri_count = self.ZSize
|
||||
|
||||
@@ -34,7 +34,7 @@ ImGui.End()
|
||||
ImPlot3D.ShowDemoWindow(true)
|
||||
```
|
||||
|
||||
Full LocalScript: `examples/roblox/main.client.luau` (ImPlot3D demo window).
|
||||
Full LocalScript: `examples/roblox/main.client.luau` (rotating surface + demo windows).
|
||||
|
||||
## API differences from C++
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-- ImPlot3D demo window.
|
||||
-- Rotating surface + ImPlot3D / ImGui demo windows.
|
||||
local RS = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local G = require(RS:WaitForChild("ImGui"))
|
||||
@@ -6,13 +6,54 @@ 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()
|
||||
ImPlot3D.ShowDemoWindow()
|
||||
RenderDemo()
|
||||
ImGui.Render()
|
||||
G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData())
|
||||
end)
|
||||
-4956
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Regenerates love/: Lua 5.1 (LÖVE/LuaJIT) copies of the Luau sources. Needs darklua + python3.
|
||||
set -e
|
||||
cd "$(dirname "$0")/.."
|
||||
mkdir -p love
|
||||
CFG=$(mktemp)
|
||||
echo '{ "generator": "retain_lines", "rules": ["remove_types", "remove_compound_assignment", "remove_if_expression", "remove_continue", "remove_interpolated_string", "remove_floor_division"] }' > "$CFG"
|
||||
for f in ImPlot3D.lua ImPlot3DDemo.lua; do
|
||||
out="love/$(basename "$f")"
|
||||
darklua process -c "$CFG" "$f" "$out"
|
||||
python3 - "$out" <<'PY'
|
||||
import re, sys
|
||||
p = sys.argv[1]; src = open(p).read()
|
||||
src = re.sub(r"^\s*@native\s*$", "", src, flags=re.M)
|
||||
# Luau generalized iteration: for k, v in t do -> for k, v in __iter(t) do
|
||||
src = re.sub(r"^([ \t]*for[ \t]+[\w][\w, \t]*[ \t]in[ \t]+)([^\n]*?)([ \t]+do\b)", r"\1__iter(\2)\3", src, flags=re.M)
|
||||
head = ("-- GENERATED by tools/love.sh from the Luau source - do not edit\n"
|
||||
"local function __iter(t, ...) if type(t) ~= 'table' or (getmetatable(t) and getmetatable(t).__call) then return t, ... end "
|
||||
"local n, i, k = #t, 0, nil return function() if i < n then i = i + 1 return i, t[i] end "
|
||||
"repeat k = next(t, k) until k == nil or type(k) ~= 'number' or k < 1 or k > n or k % 1 ~= 0 if k ~= nil then return k, t[k] end end end "
|
||||
"table.create = table.create or function(n, v) local t = {} if v ~= nil then for i = 1, n do t[i] = v end end return t end "
|
||||
"table.clone = table.clone or function(t) local c = {} for k, v in pairs(t) do c[k] = v end return setmetatable(c, getmetatable(t)) end "
|
||||
"math.clamp = math.clamp or function(x, a, b) return math.max(a, math.min(b, x)) end "
|
||||
"math.sign = math.sign or function(x) return x > 0 and 1 or (x < 0 and -1 or 0) end "
|
||||
"math.round = math.round or function(x) return x >= 0 and math.floor(x + 0.5) or math.ceil(x - 0.5) end\n")
|
||||
open(p, "w").write(head + src)
|
||||
PY
|
||||
done
|
||||
rm -f "$CFG"
|
||||
Reference in new issue
Block a user