1
+ #ifndef XTHREE_ANIMATION_ACTION_HPP
2
+ #define XTHREE_ANIMATION_ACTION_HPP
3
+
4
+ #include " xtl/xoptional.hpp"
5
+ #include " xwidgets/xeither.hpp"
6
+ #include " xwidgets/xwidget.hpp"
7
+ #include " xwidgets/xtransport.hpp"
8
+
9
+ #include " ../base/xenums.hpp"
10
+ #include " ../base/xthree_types.hpp"
11
+ #include " ../base/xthree.hpp"
12
+
13
+ namespace xthree
14
+ {
15
+ //
16
+ // animation_action declaration
17
+ //
18
+
19
+ template <class D >
20
+ class xanimation_action : public xw ::xwidget<D>
21
+ {
22
+ public:
23
+ // using base_type_1 = xanimation_action_base<D>;
24
+ using base_type = xw::xwidget<D>;
25
+ using derived_type = D;
26
+
27
+ void serialize_state (xeus::xjson&, xeus::buffer_sequence&) const ;
28
+ void apply_patch (const xeus::xjson&, const xeus::buffer_sequence&);
29
+
30
+ XPROPERTY (xtl::xoptional<xw::xholder<xthree_widget>>, derived_type, mixer);
31
+ XPROPERTY (xtl::xoptional<xw::xholder<xthree_widget>>, derived_type, clip);
32
+ XPROPERTY (xtl::xoptional<xw::xholder<xthree_widget>>, derived_type, localRoot);
33
+ XPROPERTY (bool , derived_type, clampWhenFinished, false );
34
+ XPROPERTY (bool , derived_type, enabled, true );
35
+ XPROPERTY (std::string, derived_type, loop, " LoopRepeat" , xenums::LoopModes);
36
+ XPROPERTY (bool , derived_type, paused, false );
37
+ XPROPERTY (int , derived_type, repititions, 1e15 );
38
+ XPROPERTY (double , derived_type, time, 0 );
39
+ XPROPERTY (double , derived_type, timeScale, 1 );
40
+ XPROPERTY (double , derived_type, weigth, 1 );
41
+ XPROPERTY (bool , derived_type, zeroSlopeAtEnd, true );
42
+ XPROPERTY (bool , derived_type, zeroSlopeAtStart, true );
43
+
44
+ // TODO: add repetitions
45
+
46
+ protected:
47
+
48
+ xanimation_action ();
49
+ using base_type::base_type;
50
+
51
+ private:
52
+
53
+ void set_defaults ();
54
+ };
55
+
56
+ using animation_action = xw::xmaterialize<xanimation_action>;
57
+
58
+ using animation_action_generator = xw::xgenerator<xanimation_action>;
59
+
60
+ //
61
+ // animation_action implementation
62
+ //
63
+
64
+ template <class D >
65
+ inline void xanimation_action<D>::serialize_state(xeus::xjson& state, xeus::buffer_sequence& buffers) const
66
+ {
67
+ base_type::serialize_state (state, buffers);
68
+
69
+ xw::set_patch_from_property (mixer, state, buffers);
70
+ xw::set_patch_from_property (clip, state, buffers);
71
+ xw::set_patch_from_property (localRoot, state, buffers);
72
+ xw::set_patch_from_property (clampWhenFinished, state, buffers);
73
+ xw::set_patch_from_property (enabled, state, buffers);
74
+ xw::set_patch_from_property (loop, state, buffers);
75
+ xw::set_patch_from_property (paused, state, buffers);
76
+ xw::set_patch_from_property (repititions, state, buffers);
77
+ xw::set_patch_from_property (time , state, buffers);
78
+ xw::set_patch_from_property (timeScale, state, buffers);
79
+ xw::set_patch_from_property (weigth, state, buffers);
80
+ xw::set_patch_from_property (zeroSlopeAtEnd, state, buffers);
81
+ xw::set_patch_from_property (zeroSlopeAtStart, state, buffers);
82
+ }
83
+
84
+ template <class D >
85
+ inline void xanimation_action<D>::apply_patch(const xeus::xjson& patch, const xeus::buffer_sequence& buffers)
86
+ {
87
+ base_type::apply_patch (patch, buffers);
88
+
89
+ xw::set_property_from_patch (mixer, patch, buffers);
90
+ xw::set_property_from_patch (clip, patch, buffers);
91
+ xw::set_property_from_patch (localRoot, patch, buffers);
92
+ xw::set_property_from_patch (clampWhenFinished, patch, buffers);
93
+ xw::set_property_from_patch (enabled, patch, buffers);
94
+ xw::set_property_from_patch (loop, patch, buffers);
95
+ xw::set_property_from_patch (paused, patch, buffers);
96
+ xw::set_property_from_patch (repititions, patch, buffers);
97
+ xw::set_property_from_patch (time , patch, buffers);
98
+ xw::set_property_from_patch (timeScale, patch, buffers);
99
+ xw::set_property_from_patch (weigth, patch, buffers);
100
+ xw::set_property_from_patch (zeroSlopeAtEnd, patch, buffers);
101
+ xw::set_property_from_patch (zeroSlopeAtStart, patch, buffers);
102
+ }
103
+
104
+ template <class D >
105
+ inline xanimation_action<D>::xanimation_action()
106
+ : base_type()
107
+ {
108
+ set_defaults ();
109
+ }
110
+
111
+ template <class D >
112
+ inline void xanimation_action<D>::set_defaults()
113
+ {
114
+ this ->_model_name () = " AnimationActionModel" ;
115
+ this ->_model_module () = " jupyter-threejs" ;
116
+ this ->_model_module_version () = " 1.0.0-beta.3" ;
117
+ this ->_view_name () = " AnimationActionView" ;
118
+ this ->_view_module () = " jupyter-threejs" ;
119
+ this ->_view_module_version () = " 1.0.0-beta.3" ;
120
+ }
121
+ }
122
+
123
+ /* ********************
124
+ * precompiled types *
125
+ *********************/
126
+
127
+ #ifdef XTHREEJS_PRECOMPILED
128
+ #ifndef _WIN32
129
+ extern template class xw ::xmaterialize<xthree::xanimation_action>;
130
+ extern template xw::xmaterialize<xthree::xanimation_action>::xmaterialize();
131
+ extern template class xw ::xtransport<xw::xmaterialize<xthree::xanimation_action>>;
132
+ extern template class xw ::xgenerator<xthree::xanimation_action>;
133
+ extern template xw::xgenerator<xthree::xanimation_action>::xgenerator();
134
+ extern template class xw ::xtransport<xw::xgenerator<xthree::xanimation_action>>;
135
+ #endif
136
+ #endif
137
+
138
+ #endif
0 commit comments