@@ -306,7 +306,7 @@ App::App(cxxopts::ParseResult& args) {
306
306
this ->spotShadowCamera ->orbitDist (5 .0f );
307
307
this ->spotShadowCamera ->orbitTheta (tau4);
308
308
this ->spotShadowCamera ->orbitPhi (0 .0f );
309
- entt::entity e = this ->makeSpotLight (
309
+ this -> eSpotLight = this ->makeSpotLight (
310
310
this ->spotShadowCamera ->pos ,
311
311
-direction (this ->spotShadowCamera ->rot ),
312
312
Vector3f (1 .0f , 1 .0f , 0 .9f ),
@@ -615,6 +615,7 @@ void App::onClick(int button, bool pressed) {
615
615
case GLFW_MOUSE_BUTTON_LEFT:
616
616
this ->mouseLeft = pressed;
617
617
this ->camera ->dragStart ();
618
+ this ->spotShadowCamera ->dragStart ();
618
619
break ;
619
620
case GLFW_MOUSE_BUTTON_RIGHT:
620
621
this ->mouseRight = pressed;
@@ -745,7 +746,14 @@ void App::simulate(float dt) {
745
746
dragDelta = panDelta * 2 .0f ;
746
747
dragDelta.y () *= -1 .0f ;
747
748
}
748
- this ->camera ->control (-this ->mouseDeltaPos * dt * 0 .15f , dragDelta, keyboardDelta * dt * 20 .0f );
749
+ if (this ->pressedKeys .count (GLFW_KEY_LEFT_SHIFT)) {
750
+ this ->spotShadowCamera ->control (-this ->mouseDeltaPos * dt * 0 .15f , dragDelta, keyboardDelta * dt * 20 .0f );
751
+ Light& spotLight = this ->reg .get <Light>(this ->eSpotLight );
752
+ spotLight.pos = this ->spotShadowCamera ->pos ;
753
+ spotLight.dir = -direction (this ->spotShadowCamera ->rot );
754
+ } else {
755
+ this ->camera ->control (-this ->mouseDeltaPos * dt * 0 .15f , dragDelta, keyboardDelta * dt * 20 .0f );
756
+ }
749
757
750
758
// Physics simulation
751
759
// constexpr float dampingFactor = 0.25f;
@@ -1189,15 +1197,15 @@ entt::entity App::makeSpotLight(const Vector3f& pos, const Vector3f& dir, const
1189
1197
1190
1198
this ->reg .emplace <uLight>(e);
1191
1199
1192
- DebugRay& debugRay = this ->reg .emplace <DebugRay>(e);
1193
- debugRay.pos = pos;
1194
- debugRay.rot = vec3 (pointSphere (dir));
1200
+ // DebugRay& debugRay = this->reg.emplace<DebugRay>(e);
1201
+ // debugRay.pos = pos;
1202
+ // debugRay.rot = vec3(pointSphere(dir));
1195
1203
1196
- RayTransform& rayTransform = this ->reg .emplace <RayTransform>(e);
1197
- rayTransform.transform = debugRay.transform ();
1204
+ // RayTransform& rayTransform = this->reg.emplace<RayTransform>(e);
1205
+ // rayTransform.transform = debugRay.transform();
1198
1206
1199
- DebugColor& debugColor = this ->reg .emplace <DebugColor>(e);
1200
- debugColor.color = {1 .0f , 1 .0f , 0 .2f , 1 .0f };
1207
+ // DebugColor& debugColor = this->reg.emplace<DebugColor>(e);
1208
+ // debugColor.color = {1.0f, 1.0f, 0.2f, 1.0f};
1201
1209
1202
1210
return e;
1203
1211
}
0 commit comments