remove ctx:slope()
This commit is contained in:
parent
51bb937344
commit
240419ee9f
@ -17,7 +17,7 @@ function mtscad.create_context(opts)
|
||||
scale_pos = opts.scale_pos or vector.new(1,1,1),
|
||||
rotation = opts.rotation or mtscad.rotation_matrix_x(0),
|
||||
nodefactory = opts.nodefactory,
|
||||
param2 = opts.param2 or 0,
|
||||
node_param2 = opts.node_param2 or 0,
|
||||
job_context = job_context,
|
||||
-- global session info
|
||||
session = opts.session or {
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
function mtscad.Context:param2(param2)
|
||||
local ctx = self:clone()
|
||||
ctx.param2 = param2
|
||||
ctx.node_param2 = param2
|
||||
return ctx
|
||||
end
|
||||
|
||||
|
@ -3,14 +3,14 @@ function mtscad.Context:polygon(points)
|
||||
for i=2, #points do
|
||||
local p1 = points[i-1]
|
||||
local p2 = points[i]
|
||||
local p1_pos = vector.new(p1[1], p1[2], p1[3])
|
||||
local p2_pos = vector.new(p2[1], p2[2], p2[3])
|
||||
local p1_pos = vector.new(p1[1], p1[2], 0)
|
||||
local p2_pos = vector.new(p2[1], p2[2], 0)
|
||||
|
||||
local rel_p2 = vector.subtract(p2_pos, p1_pos)
|
||||
|
||||
self
|
||||
:translate(p1[1], p1[2], p1[3])
|
||||
:line(rel_p2.x, rel_p2.y, rel_p2.z)
|
||||
:translate(p1[1], p1[2], 0)
|
||||
:line(rel_p2.x, rel_p2.y, 0)
|
||||
end
|
||||
return self
|
||||
end
|
@ -1,8 +1,8 @@
|
||||
function mtscad.Context:set_node()
|
||||
-- get node name and param2
|
||||
local node = self.nodefactory and self.nodefactory(self.param2) or { name="air" }
|
||||
if not node.param2 and self.param2 then
|
||||
node.param2 = self.param2
|
||||
if not node.node_param2 and self.node_param2 then
|
||||
node.param2 = self.node_param2
|
||||
end
|
||||
|
||||
-- rotate param2
|
||||
|
@ -1,23 +0,0 @@
|
||||
|
||||
|
||||
local slope_param2 = {
|
||||
["1,1,0"] = 3,
|
||||
["-1,0,-1"] = 9,
|
||||
["-1,0,1"] = 5,
|
||||
["1,0,-1"] = 11,
|
||||
["1,0,1"] = 14,
|
||||
["1,-1,0"] = 21,
|
||||
["0,1,1"] = 2,
|
||||
["0,-1,1"] = 22,
|
||||
["-1,1,0"] = 1,
|
||||
["-1,-1,0"] = 23,
|
||||
["0,1,-1"] = 0,
|
||||
["0,-1,-1"] = 20
|
||||
}
|
||||
|
||||
function mtscad.Context:slope(x, y, z)
|
||||
local ctx = self:clone()
|
||||
ctx.param2 = slope_param2[x .. "," .. y .. "," .. z]
|
||||
return ctx
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ end
|
||||
|
||||
function mtscad.Context:with(def)
|
||||
local ctx = self:clone()
|
||||
ctx.nodefactory = create_nodefactory(def, self.param2)
|
||||
ctx.nodefactory = create_nodefactory(def, self.node_param2)
|
||||
return ctx
|
||||
end
|
||||
|
||||
|
1
init.lua
1
init.lua
@ -13,7 +13,6 @@ dofile(MP .. "/context/polygon.lua")
|
||||
dofile(MP .. "/context/cube.lua")
|
||||
dofile(MP .. "/context/sphere.lua")
|
||||
dofile(MP .. "/context/dome.lua")
|
||||
dofile(MP .. "/context/slope.lua")
|
||||
dofile(MP .. "/context/scale.lua")
|
||||
dofile(MP .. "/context/param2.lua")
|
||||
dofile(MP .. "/context/cylinder.lua")
|
||||
|
@ -1,6 +1,6 @@
|
||||
return function(ctx)
|
||||
ctx
|
||||
:with("default:mese")
|
||||
:slope(1,1,0)
|
||||
:param2(3)
|
||||
:line(10,10,10)
|
||||
end
|
@ -2,7 +2,7 @@ local function fn(ctx)
|
||||
ctx
|
||||
:translate(2, 0, 1)
|
||||
:with("default:mese")
|
||||
:slope(1, 1, 0)
|
||||
:param2(3)
|
||||
:set_node()
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user