diff options
author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2024-08-12 19:43:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-12 19:43:03 +0300 |
commit | bc7254c0029d730e891eb05a257c8af034db10ec (patch) | |
tree | 227d8340cc558795f373f363aba6c6a2aa9942b0 /indra/newview/scripts | |
parent | 926a32aa0a9518fe7f19d0c63b30b12a66469f2d (diff) | |
parent | ff601107f093e33f70e08a9453ed329e064ce45c (diff) |
Merge branch 'release/luau-scripting' into lua-groupchat
Diffstat (limited to 'indra/newview/scripts')
-rw-r--r-- | indra/newview/scripts/lua/test_flycam.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/test_flycam.lua b/indra/newview/scripts/lua/test_flycam.lua new file mode 100644 index 0000000000..05c3c37b93 --- /dev/null +++ b/indra/newview/scripts/lua/test_flycam.lua @@ -0,0 +1,38 @@ +-- Make camera fly around the subject avatar for a few seconds. + +local LLAgent = require 'LLAgent' +local startup = require 'startup' +local timers = require 'timers' + +local height = 2.0 -- meters +local radius = 4.0 -- meters +local speed = 1.0 -- meters/second along circle +local start = os.clock() +local stop = os.clock() + 30 -- seconds + +local function cameraPos(t) + local agent = LLAgent.getRegionPosition() + local radians = speed * t + return { + agent[1] + radius * math.cos(radians), + agent[2] + radius * math.sin(radians), + agent[3] + height + } +end + +local function moveCamera() + if os.clock() < stop then + -- usual case + LLAgent.setCamera{ camera_pos=cameraPos(os.clock() - start), camera_locked=true } + return nil + else + -- last time + LLAgent.removeCamParams() + LLAgent.setFollowCamActive(false) + return true + end +end + +startup.wait('STATE_STARTED') +-- call moveCamera() repeatedly until it returns true +local timer = timers.Timer(0.1, moveCamera, true) |