mirror of https://github.com/teverse/teverse
Merge branch 'master' into master
This commit is contained in:
commit
9b3a9e4edd
create
|
@ -7,6 +7,7 @@ selectionController.selectable = true
|
|||
|
||||
local propertyEditor = require("tevgit:create/controllers/propertyEditor.lua")
|
||||
local lights = require("tevgit:create/controllers/lights.lua")
|
||||
local helpers = require("tevgit:create/helpers.lua")
|
||||
|
||||
selectionController.boundingBox = engine.construct("block", nil, {
|
||||
name = "_CreateMode_boundingBox",
|
||||
|
@ -36,17 +37,6 @@ selectionController.addBoundingListener = function(block)
|
|||
table.insert(selectionController.boundingBoxListeners, {block, block:changed(selectionController.calculateBoundingBox)})
|
||||
end
|
||||
|
||||
function calculateVertices(block)
|
||||
local vertices = {}
|
||||
for x = -1,1,2 do
|
||||
for y = -1,1,2 do
|
||||
for z = -1,1,2 do
|
||||
table.insert(vertices, block.position + block.rotation* (vector3(x,y,z) *block.size/2))
|
||||
end
|
||||
end
|
||||
end
|
||||
return vertices
|
||||
end
|
||||
|
||||
selectionController.calculateBounding = function(items)
|
||||
|
||||
|
@ -61,7 +51,6 @@ selectionController.calculateBounding = function(items)
|
|||
max = max:max(v)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
if max ~= nil and min ~= nil then
|
||||
return (max-min), (max - (max-min)/2)
|
||||
|
|
|
@ -40,7 +40,7 @@ uiController.createWindow = function(parent, pos, size, title, dontDock)
|
|||
local closeButton = uiController.create("guiImage", titleBar, {
|
||||
name = "Close",
|
||||
texture = "fa:s-times",
|
||||
position = guiCoord(0.94 ,0 ,0,0),
|
||||
position = guiCoord(1 , -20 ,0,3),
|
||||
hoverCursor = "fa:s-hand-pointer",
|
||||
size = guiCoord(0, 15, 0, 15),
|
||||
})
|
||||
|
|
|
@ -8,6 +8,19 @@ function controller.roundToMultiple(number, multiple)
|
|||
return ((number % multiple) > multiple/2) and number + multiple - number%multiple or number - number%multiple
|
||||
end
|
||||
|
||||
function controller.calculateVertices(block)
|
||||
local vertices = {}
|
||||
for x = -1,1,2 do
|
||||
for y = -1,1,2 do
|
||||
for z = -1,1,2 do
|
||||
table.insert(vertices, block.position + block.rotation* (vector3(x,y,z) *block.size/2))
|
||||
end
|
||||
end
|
||||
end
|
||||
return vertices
|
||||
end
|
||||
|
||||
|
||||
function controller.roundVectorToMultiple(vec, multiple)
|
||||
return vector3(controller.roundToMultiple(vec.x, multiple),
|
||||
controller.roundToMultiple(vec.y, multiple),
|
||||
|
|
|
@ -12,8 +12,8 @@ return function(workshop)
|
|||
tool = require("tevgit:create/controllers/tool.lua"),
|
||||
property = require("tevgit:create/controllers/propertyEditor.lua"),
|
||||
hotkeys = require("tevgit:create/controllers/hotkeys.lua"),
|
||||
themeSwitcher = require("tevgit:create/controllers/themeSwitcher.lua")
|
||||
history = require("tevgit:create/controllers/history.lua")
|
||||
themeSwitcher = require("tevgit:create/controllers/themeSwitcher.lua"),
|
||||
-- history = require("tevgit:create/controllers/history.lua")
|
||||
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,12 @@ return function(workshop)
|
|||
select = require("tevgit:create/tools/select.lua"),
|
||||
move = require("tevgit:create/tools/move.lua"),
|
||||
resize = require("tevgit:create/tools/resize.lua"),
|
||||
paint = require("tevgit:create/tools/paint.lua"),
|
||||
--rotate = require("tevgit:create/tools/rotate.lua")
|
||||
|
||||
-- WIP by jay:
|
||||
--rotate = require("tevgit:create/tools/rotate.lua"),
|
||||
|
||||
-- commented as there's a stack overflow issue:
|
||||
--paint = require("tevgit:create/tools/paint.lua"),
|
||||
}
|
||||
|
||||
-- create default environment
|
||||
|
|
|
@ -133,7 +133,7 @@ return toolsController:register({
|
|||
icon = TOOL_ICON,
|
||||
description = TOOL_DESCRIPTION,
|
||||
|
||||
hotKey = enums.key.number5,
|
||||
hotKey = enums.key.number6,
|
||||
|
||||
activated = onToolActivated,
|
||||
deactivated = onToolDeactivated
|
||||
|
|
|
@ -57,7 +57,8 @@ local function onToolActivated(toolId)
|
|||
size = vector3(0.1, 0.1, 0.1),
|
||||
colour = colour(c==1 and 1 or 0, c==2 and 1 or 0, c==3 and 1 or 0),
|
||||
emissiveColour = colour(c==1 and .8 or 0, c==2 and .8 or 0, c==3 and .8 or 0),
|
||||
workshopLocked = true
|
||||
workshopLocked = true,
|
||||
mesh = "primitive:sphere"
|
||||
})
|
||||
|
||||
handle:mouseLeftPressed(function()
|
||||
|
|
|
@ -5,28 +5,103 @@
|
|||
--]]
|
||||
|
||||
TOOL_NAME = "Rotate"
|
||||
TOOL_ICON = "local:rotate.png"
|
||||
TOOL_DESCRIPTION = "Use this to rotate primitives."
|
||||
TOOL_ICON = "fa:s-sync-alt"
|
||||
TOOL_DESCRIPTION = "Use this to rotate objects"
|
||||
|
||||
local toolsController = require("tevgit:create/controllers/tool.lua")
|
||||
local selectionController = require("tevgit:create/controllers/select.lua")
|
||||
local toolSettings = require("tevgit:create/controllers/toolSettings.lua")
|
||||
|
||||
local helpers = require("tevgit:create/helpers.lua")
|
||||
local history = require("tevgit:create/controllers/history.lua")
|
||||
|
||||
local arrows = {
|
||||
{},
|
||||
{},
|
||||
{}
|
||||
}
|
||||
|
||||
-- Each axis gets four arrows...
|
||||
-- This table maps each arrow index to an vertice index
|
||||
local arrowsVerticesMap = {
|
||||
{2, 4, 3, 1}, --x
|
||||
{2, 1, 5, 6}, --y
|
||||
{5, 7, 3, 1} --z
|
||||
}
|
||||
|
||||
local function positionArrows()
|
||||
if selectionController.boundingBox.size == vector3(0,0,0) then
|
||||
for _,v in pairs(arrows) do
|
||||
for i,arrow in pairs(v) do
|
||||
arrow.physics = false
|
||||
arrow.opacity = 0
|
||||
end
|
||||
end
|
||||
else
|
||||
local vertices = helpers.calculateVertices(selectionController.boundingBox)
|
||||
|
||||
for a,v in pairs(arrows) do
|
||||
for i,arrow in pairs(v) do
|
||||
arrow.physics = true
|
||||
arrow.opacity = 1
|
||||
arrow.position = vertices[arrowsVerticesMap[a][i]]
|
||||
if a == 1 then
|
||||
arrow.rotation = quaternion:setEuler(math.rad((i-1)*-90), 0, math.rad(90))
|
||||
elseif a == 2 then
|
||||
arrow.rotation = quaternion:setEuler(0, math.rad((i-1)*-90), 0)
|
||||
else
|
||||
arrow.rotation = quaternion:setEuler(math.rad((i-1)*-90), math.rad(90), math.rad(90))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function onToolActivated(toolId)
|
||||
|
||||
for axis = 1, 3 do
|
||||
for arrow = 1, 4 do
|
||||
local newArrow = engine.construct("block", engine.workspace, {
|
||||
name = "_CreateMode_",
|
||||
castsShadows = false,
|
||||
opacity = 0,
|
||||
renderQueue=1,
|
||||
doNotSerialise=true,
|
||||
size = vector3(.4, 0.1, .4),
|
||||
colour = colour(axis == 1 and 1 or 0, axis == 2 and 1 or 0, axis == 3 and 1 or 0),
|
||||
emissiveColour = colour(axis == 1 and 0.8 or 0, axis == 2 and 0.8 or 0, axis == 3 and 0.8 or 0),
|
||||
workshopLocked = true,
|
||||
mesh = "tevurl:3d/arrowCurved.glb"
|
||||
})
|
||||
|
||||
table.insert(arrows[axis], newArrow)
|
||||
end
|
||||
end
|
||||
|
||||
positionArrows()
|
||||
end
|
||||
|
||||
local function onToolDeactivated(toolId)
|
||||
|
||||
for _,v in pairs(arrows) do
|
||||
for _,arrow in pairs(v) do
|
||||
print(arrow)
|
||||
arrow:destroy()
|
||||
end
|
||||
end
|
||||
|
||||
arrows = {
|
||||
{},
|
||||
{},
|
||||
{}
|
||||
}
|
||||
end
|
||||
|
||||
return toolsController:register({
|
||||
|
||||
name = TOOL_NAME,
|
||||
icon = TOOL_ICON,
|
||||
description = TOOL_DESCRIPTION,
|
||||
|
||||
hotKey = enums.key.number6,
|
||||
description = TOOL_DESCRIPTION,
|
||||
|
||||
hotKey = enums.key.number5,
|
||||
|
||||
activated = onToolActivated,
|
||||
deactivated = onToolDeactivated
|
||||
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue