-
Notifications
You must be signed in to change notification settings - Fork 6
/
cameraLight.m
44 lines (39 loc) · 1.21 KB
/
cameraLight.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function hL = cameraLight
% CAMERALIGHT Adds light to the current axis.
% Usage:
% cameralight
% cameralight(param1, Value1, ..., ParamN, ValueN)
% L = cameralight(...)
%
% CAMERALIGHT Positions a light object at the camera position and listens
% to update the position whenever the camera moves. For parameter-value
% pairs see light.
%
% Author: Steven Williams (2014)
% Modifications -
% Changed listener to 'MarkedClean' after R2014b removed the ability to
% listen post-set to handle graphic object properties
% - Steven Williams (2016)
%
% Info on Code Testing:
% ---------------------------------------------------------------
% test code
% ---------------------------------------------------------------
%
% ---------------------------------------------------------------
% code
% ---------------------------------------------------------------
hAx = gca();
hL = camlight();
positionLight();
el_global = addlistener(hAx, 'MarkedClean', @positionLight);
function positionLight(varargin)
campos = get(hAx, 'cameraposition');
try
set(hL, 'position', campos);
catch
disp('About to delete the listener');
delete(el_global);
end
end
end