The camera flies between the stadium and its surroundings
Coming from the other view of the model, or laying the view back, the picture moves and zooms there in 0.7 seconds; with reduced motion it stands there at once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
c60b0e9b2c
commit
d9b0590705
3 files changed
+35
-3
No files matched your search
@@ -43,6 +43,18 @@ bool App::stadium_focus_action(const std::string &action,Rml::Element *target) {
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
// The camera on its way: slow at both ends, only the place of the picture changes.
|
||||
void App::stadium_flight_tick() {
|
||||
if(menu_!="stadium"){stadium_seen_.clear();stadium_flying_=false;return;}
|
||||
if(!stadium_flying_)return;
|
||||
auto *world=element("stadium-world");
|
||||
if(!world){stadium_flying_=false;return;}
|
||||
const double t=std::min(1.0,double(SDL_GetTicks64()-stadium_flight_start_)/700.0),eased=t<.5?4*t*t*t:1-std::pow(-2*t+2,3)/2;
|
||||
for(size_t i=0;i<3;++i)stadium_now_[i]=stadium_from_[i]+(stadium_to_[i]-stadium_from_[i])*eased;
|
||||
if(t>=1){stadium_now_=stadium_to_;stadium_flying_=false;}
|
||||
world->SetProperty("left",pg(stadium_now_[1]));world->SetProperty("top",pg(stadium_now_[2]));world->SetProperty("transform","scale("+scalar(stadium_now_[0])+")");
|
||||
dirty_=true;
|
||||
}
|
||||
// Looking around on the stage: the wheel zooms towards the pointer, dragging moves the view,
|
||||
// and the pointer over a part shows what stands there. Only the place of the picture changes;
|
||||
// nothing is drawn anew.
|
||||
@@ -51,6 +63,8 @@ bool App::stadium_stage_event(Rml::Event &event) {
|
||||
if(!stage||!world)return false;
|
||||
const auto type=event.GetType();
|
||||
if(type!="mousemove"&&type!="mousedown"&&type!="mouseup"&&type!="mousescroll")return false;
|
||||
// while the camera flies the picture is not where the pointer would look for it
|
||||
if(stadium_flying_)return false;
|
||||
const bool outer=stadium_view_.value("view",std::string())=="panorama";
|
||||
// the pointer on the stage, in units of the page
|
||||
const double mx=(event.GetParameter<float>("mouse_x",0)-stage->GetAbsoluteLeft())/scale_/2.25,my=(event.GetParameter<float>("mouse_y",0)-stage->GetAbsoluteTop())/scale_/2.25;
|
||||
@@ -81,7 +95,7 @@ bool App::stadium_stage_event(Rml::Event &event) {
|
||||
cam[0]=std::clamp(cam[0],.75,3.2);
|
||||
cam[1]=std::clamp(cam[1],std::min(240.0,w-w*cam[0]-240),std::max(240.0,w-w*cam[0]-240));
|
||||
cam[2]=std::clamp(cam[2],std::min(240.0,h-h*cam[0]-240),std::max(240.0,h-h*cam[0]-240));
|
||||
stadium_cams_[outer?"panorama":"inside"]=cam;
|
||||
stadium_cams_[outer?"panorama":"inside"]=cam;stadium_now_=cam;
|
||||
world->SetProperty("left",pg(cam[1]));world->SetProperty("top",pg(cam[2]));world->SetProperty("transform","scale("+scalar(cam[0])+")");
|
||||
dirty_=true;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user