🎯 MỤC TIÊU:
-
✅ Camera xoay vòng tự động (autorotate)
-
✅ Sau khi xoay hết một vòng (hoặc gần đủ), chuyển sang scene tiếp theo
-
✅ Tùy chỉnh thời gian/delay/mượt
✅ CÁCH THỰC HIỆN
1. 🔁 Cấu hình autorotate (xoay chậm, mượt)
<autorotate enabled="true"
waittime="1.0"
speed="3.0"
accel="0.0"
horizon="0.0"
returntohorizon="true"
/>
🔹
speed="3.0": tốc độ xoay (giảm để chậm hơn)
🔹waittime="1.0": đợi 1 giây rồi bắt đầu xoay
🔹returntohorizon="true": giữ camera không lệch trục
2. 🧠 Xử lý chuyển scene sau khi xoay đủ góc
Chúng ta dùng lookat(h) để kiểm tra góc nhìn ngang (hlookat). Khi xoay đến một góc nhất định (ví dụ từ 0 → 360), ta chuyển scene.
3. ✅ TẠO ACTION THEO DÕI XOAY
<action name=”start_autotour_scene1″>
set(autorotate.enabled, true);
delayedcall(10, check_hlookat_for_scene2());
</action><action name=”check_hlookat_for_scene2″>
copy(h, view.hlookat);
abs(h); <!– lấy trị tuyệt đối –>
if(h GT 350,
set(autorotate.enabled, false);
loadscene(scene2, null, MERGE, BLEND(2));
,
delayedcall(1, check_hlookat_for_scene2());
);
</action>
4. ✅ GỌI KHI LOAD SCENE
<scene name=”scene1″ title=”Cảnh 1″ onstart=”start_autotour_scene1();”>
<view hlookat=”0″ vlookat=”0″ fov=”90″ />
<image><cube url=”panos/scene1_%s.jpg” /></image>
</scene><scene name=”scene2″ title=”Cảnh 2″ onstart=”start_autotour_scene2();”>
<view hlookat=”0″ vlookat=”0″ fov=”90″ />
<image><cube url=”panos/scene2_%s.jpg” /></image>
</scene>
5. 🔁 TƯƠNG TỰ CHO CÁC SCENE SAU
<action name=”start_autotour_scene2″>
set(autorotate.enabled, true);
delayedcall(10, check_hlookat_for_scene3());
</action><action name=”check_hlookat_for_scene3″>
copy(h, view.hlookat);
abs(h);
if(h GT 350,
set(autorotate.enabled, false);
loadscene(scene3, null, MERGE, BLEND(2));
,
delayedcall(1, check_hlookat_for_scene3());
);
</action>
✅ GIẢI THÍCH CÁCH HOẠT ĐỘNG:
-
Krpano xoay camera tự động theo
autorotate -
Action liên tục kiểm tra biến
view.hlookat(góc quay ngang) -
Khi hlookat > ~350° (gần hết vòng xoay), ta dừng autorotate và chuyển scene
🔧 GỢI Ý TÙY BIẾN:
| Mục | Gợi ý |
|---|---|
| Muốn chuyển sớm hơn | Đổi if(h GT 350) thành if(h GT 180) |
| Muốn tăng độ mượt | Thêm lookto() trước khi chuyển |
| Muốn quay rồi pause | set(autorotate.enabled, false); sau khi xoay xong |
🧠 Nâng cao:
Bạn có thể chuyển cảnh theo góc nhìn cụ thể, ví dụ:
if(view.hlookat GT 90 AND view.hlookat LT 110,
loadscene(sceneX);
);
























