This commit is contained in:
trung09122002
2026-09-21 09:30:17 +07:00
parent 0e4ad198ff
commit 5080195ceb

View File

@@ -198,7 +198,18 @@ function v3dBuildRobot(r) {
// toa do map voi san la 0.
g.position.y = r.wheel_radius;
const bodyMat = new THREE.MeshLambertMaterial({ color: 0x1a6ea8 });
// Than robot TRONG SUOT mac dinh.
//
// LiDAR o 0.13 m va camera o 0.31 m deu NAM TRONG khoi hop 0.85 m. Ve than
// dac thi khong bao gio thay duoc hai cam bien do -- ma vi tri cua chung so
// voi nhau chinh la thu hay sai nhat trong cau hinh, va la thu can nhin
// thay nhat.
//
// depthWrite = false la phan bat buoc: thieu no thi mat trong suot van ghi
// vao depth buffer va van che moi thu ve SAU no, tuc cam bien van bien mat
// du da nhin xuyen duoc qua than.
const bodyMat = new THREE.MeshLambertMaterial({
color: 0x1a6ea8, transparent: true, opacity: 0.22, depthWrite: false });
const darkMat = new THREE.MeshLambertMaterial({ color: 0x20262e });
// Than: KHOI HOP, dung kich thuoc that tu robot.yaml.
@@ -242,7 +253,8 @@ function v3dBuildRobot(r) {
// LiDAR: tru nho o dung vi tri trong robot.yaml.
const lidar = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.035, 0.06, 16),
// To hon ban goc (0.035 x 0.06): phai nhin ro xuyen qua than trong suot.
new THREE.CylinderGeometry(0.055, 0.055, 0.09, 16),
new THREE.MeshLambertMaterial({ color: 0xe2574c }));
lidar.position.copy(toScene(r.laser_x, r.laser_y, r.laser_z));
g.add(lidar);
@@ -809,34 +821,10 @@ function v3dSetBodyVisible(on) {
}
function v3dSetFramesVisible(on) {
// Chi bat/tat bo truc. Than robot da TRONG SUOT san (xem v3dBuildRobot),
// nen khong can lam mo them o day -- hai co che cung dieu khien mot vat
// lieu se danh nhau ngay lan sua thu ba.
if (V3D.framesMesh) V3D.framesMesh.visible = !!on;
// Khi hien TF thi lam THAN robot trong suot.
//
// Than la khoi hop 0.85 m; LiDAR o 0.13 m va camera o 0.31 m deu NAM TRONG
// no, nen o che do dac thi khong thay bo truc nao ca. Bat/tat han thi lai
// mat ngu canh -- khong biet cam bien nam dau so voi than.
//
// depthWrite = false la phan bat buoc: thieu no thi mat trong suot van ghi
// vao depth buffer va van che nhung gi ve SAU no, tuc bo truc bien mat du
// da nhin xuyen duoc qua than.
if (!V3D.bodyMesh) return;
V3D.bodyMesh.traverse((o) => {
if (!o.material) return;
if (!o.userData.matSolid) o.userData.matSolid = o.material;
if (on) {
if (!o.userData.matGhost) {
const m = o.material.clone();
m.transparent = true;
m.opacity = 0.18;
m.depthWrite = false;
o.userData.matGhost = m;
}
o.material = o.userData.matGhost;
} else {
o.material = o.userData.matSolid;
}
});
}
function v3dSetOverlays(on) {