1
0
mirror of https://github.com/teverse/teverse synced 2025-08-25 15:44:46 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
teverse
0aee56b9ce merge 2019-11-05 22:30:59 +00:00
teverse
3965e10cd5 merge 2019-11-05 22:30:31 +00:00
teverse
7b85123995 add grid to select too 2019-11-05 22:30:01 +00:00
2 changed files with 36 additions and 1 deletions

View File

@ -43,6 +43,33 @@ return {
position = vector3(0.5, 1, 0),
mesh = "primitive:sphere"
})
-- this debug code needs to be moved elsewhere
-- block:on("collisionStarted", function (collidingWith, hit, normal)
-- local b = engine.construct("block", workspace, {
-- position = hit,
-- physics = false,
-- size = vector3(0.1, 0.1, 0.1),
-- mesh = "primitive:sphere"
-- })
-- wait(1)
-- b:destroy()
-- end)
-- spawnThread(function ( ... )
-- while wait() do
-- local mouseHit = engine.physics:rayTestScreen( engine.input.mousePosition )
-- if mouseHit then
-- local b = engine.construct("block", workspace, {
-- position = mouseHit.hitPosition,
-- physics = false,
-- size = vector3(0.1, 0.1, 0.1),
-- mesh = "primitive:sphere"
-- })
-- end
-- end
-- end)
end,
setupEnvironment = function ()

View File

@ -47,14 +47,21 @@ return {
-- tell history to monitor changes we make to selected items
history.beginAction(selection.selection, "Hand tool drag")
local grid = engine.construct("grid", workspace, {
step = 0.5,
colour = colour(1,0,0),
size = 10
})
while engine.input:isMouseButtonDown(enums.mouseButton.left) do
-- fire a ray, exclude selected items.
local hits, didExclude = engine.physics:rayTestScreenAllHits(engine.input.mousePosition, selection.selection)
if (#hits > 0) then
local newCentre = hits[1].hitPosition + mouseOffset
grid.position = newCentre
for _,v in pairs(selection.selection) do
if offsets[v] then
v.position = offsets[v] + newCentre
v.position = newCentre - offsets[v]
end
end
end
@ -63,6 +70,7 @@ return {
history.endAction()
grid:destroy()
else
-- user clicked an unselected object, let's select it
if engine.input:isKeyDown(enums.key.leftShift) then