113 {
114 if (GetBackend() == PlaygroundBackend::kVulkan) {
115 GTEST_SKIP_("Temporarily disabled.");
116 }
117 auto allocator = GetContext()->GetResourceAllocator();
118
119 auto mapping =
121 ASSERT_NE(mapping, nullptr);
122
123 std::shared_ptr<Node> gltf_scene =
124 Node::MakeFromFlatbuffer(*mapping, *allocator);
125 ASSERT_NE(gltf_scene, nullptr);
126
127 auto animation = gltf_scene->FindAnimationByName("Metronome");
128 ASSERT_NE(animation, nullptr);
129
130 AnimationClip* metronome_clip = gltf_scene->AddAnimation(animation);
131 ASSERT_NE(metronome_clip, nullptr);
133 metronome_clip->
Play();
134
135 auto scene_context = std::make_shared<SceneContext>(GetContext());
136 auto scene =
Scene(scene_context);
137 scene.GetRoot().AddChild(std::move(gltf_scene));
138
140 ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
141 {
142 static Scalar playback_time_scale = 1;
144 static bool loop = true;
145
146 ImGui::SliderFloat("Playback time scale", &playback_time_scale, -5, 5);
147 ImGui::SliderFloat("Weight", &weight, -2, 2);
148 ImGui::Checkbox("Loop", &loop);
149 if (ImGui::Button("Play")) {
150 metronome_clip->
Play();
151 }
152 if (ImGui::Button("Pause")) {
153 metronome_clip->
Pause();
154 }
155 if (ImGui::Button("Stop")) {
156 metronome_clip->
Stop();
157 }
158
162 }
163
164 ImGui::End();
165 Node& node = *scene.GetRoot().GetChildren()[0];
166 node.SetLocalTransform(node.GetLocalTransform() *
167 Matrix::MakeRotation(Radians(0.02), {0, 1, 0, 0}));
168
169 static ImVec2 mouse_pos_prev = ImGui::GetMousePos();
170 ImVec2 mouse_pos = ImGui::GetMousePos();
172 Vector2(mouse_pos.x - mouse_pos_prev.x, mouse_pos.y - mouse_pos_prev.y);
173
174 static Vector3 position(0, 1, -5);
175 static Vector3 cam_position = position;
176 auto strafe =
177 Vector3(ImGui::IsKeyDown(ImGuiKey_D) - ImGui::IsKeyDown(ImGuiKey_A),
178 ImGui::IsKeyDown(ImGuiKey_E) - ImGui::IsKeyDown(ImGuiKey_Q),
179 ImGui::IsKeyDown(ImGuiKey_W) - ImGui::IsKeyDown(ImGuiKey_S));
180 position += strafe * 0.5;
181 cam_position = cam_position.Lerp(position, 0.02);
182
183
184 auto camera = Camera::MakePerspective(
186 cam_position)
187 .LookAt(
188 cam_position + Vector3(0, 0, 1),
189 {0, 1, 0});
190
191 scene.Render(render_target, camera);
192 return true;
193 };
194
196}