summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-08-07 16:12:23 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-08-07 16:12:23 -0400
commit3102dc0db472acac7c4007e7423e405a889d665a (patch)
treec2e405b2cf2c6ad2d3f6117bb66585b852a00ce3 /indra/newview/scripts/lua
parent08def53d8bf07beaa56db80e95aa76f3682c557c (diff)
Allow smaller minimum timer intervals.
Add test_flycam.lua to exercise the smaller intervals.
Diffstat (limited to 'indra/newview/scripts/lua')
-rw-r--r--indra/newview/scripts/lua/test_flycam.lua38
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..4fb5608b33
--- /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 initial = LLAgent.getRegionPosition()
+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 radians = speed * t
+ return {
+ initial[1] + radius * math.cos(radians),
+ initial[2] + radius * math.sin(radians),
+ initial[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)