<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>スズキ MITRA の3D（足回りが動く・試作） | Pixels to Motors</title>
<meta name="description" content="スズキの多目的電動台車 MITRA を、広報資料の寸法図・写真と発表会の動画から3Dに起こした試作。ばね・前輪の切れ角・タイヤが動き、オプションのアルミフレームを出し入れできる。寸法ごとに、どこから取った値かを表にしている。">
<link rel="canonical" href="https://pixelstomotors.com/sim/mitra-3d/">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter+Tight:wght@600&family=Noto+Sans+JP:wght@400;700&display=swap" rel="stylesheet">
<style>
/* VOICE: 計測の記録。落ち着いて、数字を正確に
   IDEA: 試験台の上の台車。動かすつまみと、測った値の札
   PICTURE: 足回りが動く MITRA の3D を大きく
   COLOUR and TYPE: 鋼の灰の板、黒、白、警告の赤（仮の値）。Inter Tight + Noto Sans JP
   LAYOUT: 3D を主役に、右につまみ、下に寸法の表 */
:root{color-scheme:light dark;--bg:light-dark(#d5dbe0,#16191c);--panel:light-dark(#ffffff,#22262a);--ink:light-dark(#0d0f11,#eef1f3);--mute:light-dark(#4a535b,#a7b0b8);--line:light-dark(#b8c1c8,#3a4046);--red:#e8251a}
:root[data-theme=light]{color-scheme:light}:root[data-theme=dark]{color-scheme:dark}
*{box-sizing:border-box;min-width:0}
body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.55 "Noto Sans JP",system-ui,sans-serif;overflow-x:clip}
h1,h2{font-family:"Inter Tight","Noto Sans JP",sans-serif;font-weight:600;line-height:1.1;text-wrap:balance;margin:0}
.band{padding:clamp(20px,3vw,40px) max(4vw,16px)}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}
</style>
</head>
<body>
<style>
.top{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:16px;max-width:1400px;margin:auto}
.stage{position:relative;background:var(--panel);border:1px solid var(--line);min-height:420px;height:min(68vh,640px)}
.stage canvas{display:block;width:100%;height:100%;touch-action:none}
#load{position:absolute;left:16px;top:14px;color:var(--mute);font-size:14px}
.views{position:absolute;left:12px;bottom:12px;display:flex;gap:6px;flex-wrap:wrap}
.ctl{background:var(--panel);border:1px solid var(--line);padding:16px}
h1{font-size:clamp(26px,3.2vw,38px);margin-bottom:6px}
.lead{color:var(--mute);margin:0 0 14px;max-width:70ch}
button{font:600 15px "Noto Sans JP",sans-serif;min-height:44px;padding:0 14px;border:1px solid var(--line);background:var(--panel);color:var(--ink);cursor:pointer}
button.on{background:var(--ink);color:var(--panel)}
button:focus-visible,input:focus-visible{outline:3px solid var(--red);outline-offset:2px}
.row{margin:12px 0}
.row label{display:flex;justify-content:space-between;font-size:14px}
.row output{font-variant-numeric:tabular-nums;white-space:nowrap}
input[type=range]{width:100%;height:32px;accent-color:#0d0f11}
.big{font:600 28px "Inter Tight",sans-serif;font-variant-numeric:tabular-nums}
.note{font-size:13px;color:var(--mute)}
.btns{display:flex;gap:8px;flex-wrap:wrap}
@media(max-width:900px){.top{grid-template-columns:minmax(0,1fr)}.stage{height:58vh}}
</style>
<div class="band">
<div class="top">
 <div>
  <p class="note" style="margin:0 0 8px"><a href="/record/mitra-3d-model-from-drawing-and-video" style="color:inherit">← 作り方と測った値の記録</a>　<a href="/series10" style="color:inherit">シリーズの一覧</a></p>
  <h1>MITRA の3D：ばね・切れ角・タイヤが動く</h1>
  <p class="lead">スズキの広報資料の寸法図・写真と、発表会の動画のコマから作った MITRA（試作段階の値）。4輪それぞれ上下し、前の2輪は向きを変え、4輪とも回る。荷台の上の面は、黒い丸パイプの枠で355mm、オプションのアルミフレームを載せると約398mm。</p>
  <div class="stage" id="stage"><div id="load">読み込み中…</div>
   <div class="views" id="views">
    <button data-v="iso" class="on">斜め</button><button data-v="side">横</button><button data-v="front">正面</button><button data-v="top">上</button><button data-v="under">下から</button><button data-v="deck">荷台</button><button data-v="rear">後ろ</button><button data-v="tire">タイヤ</button>
   </div>
  </div>
 </div>
 <div class="ctl">
  <h2 style="font-size:20px">動かす</h2>
  <div class="row"><label for="steer">ハンドル（左 − ／ 右 ＋）<output id="steerO">0</output></label><input type="range" id="steer" min="-1" max="1" step="0.01" value="0"></div>
  <div class="big" id="angles">左 0.0° ／ 右 0.0°</div>
  <p class="note" id="radius">まっすぐ</p>
  <div id="sus"></div>
  <div class="row"><label for="opt" style="justify-content:flex-start;gap:10px;align-items:center;min-height:44px"><input type="checkbox" id="opt" checked style="width:22px;height:22px">アルミフレーム（オプション）を載せる</label></div>
  <div class="btns">
   <button id="drive">走る</button><button id="bump">段差を越える</button><button id="reset">元に戻す</button>
  </div>
  <p class="note">ハンドルをいっぱいに切ると、広報資料の最小回転半径 950mm になる角度（内側 74.6°・外側 45.7°）。ばねの動く量（上下 ±35mm）、下のパイプの通り道、電池の向きは、資料から決めきれていない仮の値。</p>
 </div>
</div>
</div>

<style>
.dims{max-width:1400px;margin:auto}
table{width:100%;border-collapse:collapse;background:var(--panel);font-size:15px}
th,td{border-bottom:1px solid var(--line);padding:8px 10px;text-align:left;vertical-align:top}
td.n{text-align:right;font-variant-numeric:tabular-nums;max-width:28em}
.src{font-size:13px;white-space:nowrap}.src.assumed{color:var(--red);font-weight:700}
.legend{margin:8px 0 14px;font-size:14px;color:var(--mute)}
</style>
<div class="band dims">
 <h2 style="font-size:24px;margin-bottom:6px">寸法（mm）と、どこから取ったか</h2>
 <p class="legend">座標の原点は、前後の車軸の中間の真下の地面。前が＋、右が＋。資料＝広報資料に書かれた値 ／ 図＝寸法図を画素で測った値（0.5365mm／画素） ／ 写真＝写真から読んだ形 ／ 動画＝動画のコマから読んだ形 ／ 仮＝資料にない値</p>
 <div class="scroll"><table class="stack"><thead><tr><th>部分</th><th>項目</th><th>値</th><th>元</th><th>メモ</th></tr></thead><tbody id="tb"></tbody></table></div>
 <p class="note" id="steernote"></p>
</div>

<script src="three.min.js"></script>
<script src="GLTFLoader.js"></script>
<script src="OrbitControls.js"></script>
<script>
{
const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
const SEC={spec:'書かれた値',derived:'車軸と荷台',deck:'荷台とオプション',chassis:'黒い枠',front_bar:'前の棒',rear_handle:'後ろの取っ手',battery_box:'電池の箱',front_suspension:'前の足',rear_suspension:'後ろの足',wheel:'車輪'};
const SRC={spec:'資料',drawing:'図',photo:'写真',video:'動画',assumed:'仮'};
fetch('mitra_dims.json').then(r=>r.json()).then(D=>{
  const rows=[];
  for(const [s,lab] of Object.entries(SEC)){const o=D[s];if(!o)continue;
    for(const [k,x] of Object.entries(o)){ if(!x||typeof x!=='object'||!('v' in x))continue;
      const val=Array.isArray(x.v)?(Array.isArray(x.v[0])?x.v.map(q=>q.join('→')).join(' / '):x.v.join(', ')):x.v;
      rows.push(`<tr><td>${esc(lab)}</td><td>${esc(k)}</td><td class="n">${esc(val)}</td><td class="src ${x.src==='assumed'?'assumed':''}">${esc(SRC[x.src]||'計算')}</td><td>${esc(x.note||'')}</td></tr>`);}}
  document.getElementById('tb').innerHTML=rows.join('');
  document.getElementById('steernote').textContent=D.steering_check?.note||'';
}).catch(()=>{document.getElementById('tb').innerHTML='<tr><td colspan="5">寸法表を読めなかった</td></tr>'});

const stage=document.getElementById('stage');
const renderer=new THREE.WebGLRenderer({antialias:true});
renderer.setPixelRatio(Math.min(devicePixelRatio,2));renderer.outputEncoding=THREE.sRGBEncoding;renderer.shadowMap.enabled=true;
stage.prepend(renderer.domElement);
const scene=new THREE.Scene();
const dark=matchMedia('(prefers-color-scheme: dark)').matches&&document.documentElement.dataset.theme!=='light'||document.documentElement.dataset.theme==='dark';
scene.background=new THREE.Color(dark?0x22262a:0xf4f6f7);
const cam=new THREE.PerspectiveCamera(35,1,0.01,50);cam.position.set(1.6,1.1,1.7);
const ctr=new THREE.OrbitControls(cam,renderer.domElement);ctr.target.set(0,0.18,0);ctr.enableDamping=true;
scene.add(new THREE.HemisphereLight(0xffffff,0x667788,0.75));
const sun=new THREE.DirectionalLight(0xffffff,0.9);sun.position.set(2,4,2);sun.castShadow=true;sun.shadow.mapSize.set(2048,2048);
Object.assign(sun.shadow.camera,{left:-2,right:2,top:2,bottom:-2});scene.add(sun);
const grid=new THREE.GridHelper(8,80,dark?0x555c63:0xaab3ba,dark?0x33383d:0xd3d9dd);scene.add(grid);
const floor=new THREE.Mesh(new THREE.PlaneGeometry(8,8),new THREE.ShadowMaterial({opacity:0.18}));floor.rotation.x=-Math.PI/2;floor.receiveShadow=true;scene.add(floor);
const bumpMesh=new THREE.Mesh(new THREE.BoxGeometry(0.2,0.03,0.12),new THREE.MeshStandardMaterial({color:0xe8251a}));bumpMesh.visible=false;scene.add(bumpMesh);

function size(){const w=stage.clientWidth,h=stage.clientHeight;renderer.setSize(w,h,false);cam.aspect=w/h;cam.updateProjectionMatrix();}
const ro=new ResizeObserver(size);ro.observe(stage);size();

const N={};let root=null;
const K=['FL','FR','RL','RR'], LAB={FL:'左前',FR:'右前',RL:'左後',RR:'右後'};
const travel={FL:0,FR:0,RL:0,RR:0};
document.getElementById('sus').innerHTML=K.map(k=>`<div class="row"><label for="t${k}">${LAB[k]}のばね（上 ＋）<output id="o${k}">0 mm</output></label><input type="range" id="t${k}" min="-35" max="35" step="1" value="0"></div>`).join('');
K.forEach(k=>document.getElementById('t'+k).addEventListener('input',e=>{travel[k]=+e.target.value;}));

new THREE.GLTFLoader().load('mitra_v1.glb',g=>{
  root=g.scene;root.traverse(o=>{if(o.name)N[o.name]=o;if(o.isMesh){o.castShadow=true;o.receiveShadow=true;}});
  scene.add(root);document.getElementById('load').remove();
},x=>{if(x.total)document.getElementById('load').textContent=`読み込み中… ${Math.round(x.loaded/1024)} / ${Math.round(x.total/1024)} KB`;},
()=>{document.getElementById('load').textContent='3D を読めなかった';});

// 足回りの形（mm）
const WB=585,KZ=205,HALF=252.5,FARM=177.5,RARM=205.7,R=0.13,CMIN=366;
let steer=0;
function steerAngles(s){
  if(Math.abs(s)<1e-3)return {l:0,r:0,C:Infinity};
  const C=CMIN/Math.abs(s), inn=Math.atan2(WB,C-KZ), out=Math.atan2(WB,C+KZ), sg=Math.sign(s);
  // 左へ切る（s<0）：左が内側。三次元の向き：左へ＝+Y まわり
  return sg<0?{l:inn,r:out,C,sg}:{l:-out,r:-inn,C,sg};
}
const steerEl=document.getElementById('steer');
steerEl.addEventListener('input',()=>{steer=+steerEl.value;});

document.getElementById('opt').addEventListener('change',e=>{if(N.option_deck)N.option_deck.visible=e.target.checked;});
// 走る・段差
let driving=false,bumpT=-1;const pose={x:0,z:0,yaw:0};
document.getElementById('drive').addEventListener('click',e=>{driving=!driving;e.target.classList.toggle('on',driving);e.target.textContent=driving?'止める':'走る';});
document.getElementById('bump').addEventListener('click',()=>{bumpT=0;
  // 段（高さ30mm・長さ200mm）を左の前輪の 0.4m 先に置く。車輪は進んだ距離 0.2〜0.6m で乗り越える
  const f=new THREE.Vector3(Math.cos(pose.yaw),0,-Math.sin(pose.yaw)),l=new THREE.Vector3(-Math.sin(pose.yaw),0,-Math.cos(pose.yaw));
  bumpMesh.position.set(pose.x,0.015,pose.z).addScaledVector(f,0.2925+0.4).addScaledVector(l,0.2525);bumpMesh.rotation.y=pose.yaw;bumpMesh.visible=true;});
document.getElementById('reset').addEventListener('click',()=>{steer=0;steerEl.value=0;K.forEach(k=>{travel[k]=0;document.getElementById('t'+k).value=0});pose.x=pose.z=pose.yaw=0;bumpT=-1;bumpMesh.visible=false;driving=false;const b=document.getElementById('drive');b.classList.remove('on');b.textContent='走る';});

// 視点
const VIEWS={iso:[1.6,1.1,1.7],side:[0,0.2,2.4],front:[2.4,0.2,0],top:[0,2.6,0.001],under:[0.6,-1.4,0.9],tire:{p:[-0.75,0.22,-0.75],t:[-0.29,0.13,-0.25]},rear:{p:[-1.5,0.16,0],t:[0,0.17,0]},deck:{p:[0.95,0.62,-0.6],t:[0.3,0.36,-0.1]}};
function setView(v){const V=VIEWS[v];if(!V)return;
  document.querySelectorAll('#views button').forEach(b=>b.classList.toggle('on',b.dataset.v===v));
  const p=V.p||V,t=V.t||[0,0,0],c=Math.cos(pose.yaw),sn=Math.sin(pose.yaw);
  const w=a=>[pose.x+a[0]*c+a[2]*sn,a[1],pose.z-a[0]*sn+a[2]*c];
  const P=w(p),T=w(t);cam.position.set(P[0],P[1]+(V.p?0:0.18),P[2]);ctr.target.set(T[0],V.t?T[1]:0.18,T[2]);}
document.getElementById('views').addEventListener('click',e=>{if(e.target.dataset.v)setView(e.target.dataset.v);});
if(VIEWS[location.hash.slice(1)])setTimeout(()=>setView(location.hash.slice(1)),0);

const tmpA=new THREE.Vector3(),tmpB=new THREE.Vector3(),Y=new THREE.Vector3(0,1,0);
function bumpProfile(t,start){const u=(t-start)/0.4;return (u>0&&u<1)?30*Math.sin(Math.PI*u):0;}
let last=performance.now();
function tick(now){
  const dt=Math.min(0.05,(now-last)/1000);last=now;
  if(root){
    const a=steerAngles(steer);
    document.getElementById('steerO').textContent=steer.toFixed(2);
    document.getElementById('angles').textContent=`左 ${(a.l*180/Math.PI).toFixed(1)}° ／ 右 ${(a.r*180/Math.PI).toFixed(1)}°`;
    document.getElementById('radius').textContent=isFinite(a.C)?`回る中心：後ろの車軸の線上、車体の中心から${Math.round(a.C)}mm`:'まっすぐ';
    let v=driving?0.6:0;
    if(bumpT>=0){ // 0.6m/s で左の前輪→左の後輪の順に高さ30mm の段を越える
      bumpT+=dt;v=0.6;const d=0.6*bumpT; // 進んだ距離 m
      travel.FL=bumpProfile(d,0.20);travel.RL=bumpProfile(d,0.20+WB/1000);
      document.getElementById('tFL').value=travel.FL;document.getElementById('tRL').value=travel.RL;
      bumpMesh.visible=true;
      if(bumpT>3.2){bumpT=-1;travel.FL=travel.RL=0;bumpMesh.visible=false;document.getElementById('tFL').value=0;document.getElementById('tRL').value=0;}
    }
    // 車体の位置（後ろの車軸の中心を基準に弧を描く）
    const ds=v*dt;
    if(ds>0){
      if(isFinite(a.C)){pose.yaw+=-a.sg*ds/(a.C/1000);}
      const ra={x:pose.x-0.2925*Math.cos(pose.yaw),z:pose.z+0.2925*Math.sin(pose.yaw)};
      ra.x+=ds*Math.cos(pose.yaw);ra.z-=ds*Math.sin(pose.yaw);
      pose.x=ra.x+0.2925*Math.cos(pose.yaw);pose.z=ra.z-0.2925*Math.sin(pose.yaw);
      ctr.target.x+=pose.x-root.position.x;ctr.target.z+=pose.z-root.position.z;
      cam.position.x+=pose.x-root.position.x;cam.position.z+=pose.z-root.position.z;
    }
    root.position.set(pose.x,0,pose.z);root.rotation.y=pose.yaw;
    // 足回り
    const s=t=>Math.asin(Math.max(-1,Math.min(1,t)));
    if(N.susp_FL)N.susp_FL.rotation.x=s(travel.FL/FARM);
    if(N.susp_FR)N.susp_FR.rotation.x=-s(travel.FR/FARM);
    if(N.susp_RL)N.susp_RL.rotation.z=s(-travel.RL/RARM);
    if(N.susp_RR)N.susp_RR.rotation.z=s(-travel.RR/RARM);
    if(N.steer_FL)N.steer_FL.rotation.y=a.l;
    if(N.steer_FR)N.steer_FR.rotation.y=a.r;
    K.forEach(k=>document.getElementById('o'+k).textContent=`${Math.round(travel[k])} mm`);
    // タイヤの回転（それぞれの車輪が進む距離から）
    const C=a.C/1000,sg=a.sg||0;
    const dist={FL:1,FR:1,RL:1,RR:1};
    if(isFinite(C)){const ci=sg; // 左へ（sg<0）なら左が内側＝短い
      dist.RL=(C+ci*HALF/1000)/C;dist.RR=(C-ci*HALF/1000)/C;
      dist.FL=Math.hypot(WB/1000,C+ci*KZ/1000)/C;dist.FR=Math.hypot(WB/1000,C-ci*KZ/1000)/C;}
    K.forEach(k=>{const w=N['wheel_'+k];if(w)w.rotation.z-=ds*dist[k]/R;});
    // ばねを両端の印に合わせる
    const body=N.body;
    if(body){K.forEach(k=>{const sp=N['spring_'+k],b=N['spring_bot_'+k],t=N['spring_top_'+k];if(!sp||!b||!t)return;
      b.getWorldPosition(tmpA);t.getWorldPosition(tmpB);body.worldToLocal(tmpA);body.worldToLocal(tmpB);
      const d=tmpB.clone().sub(tmpA),len=d.length();sp.position.copy(tmpA);sp.quaternion.setFromUnitVectors(Y,d.normalize());sp.scale.set(1,len,1);});}
  }
  ctr.update();renderer.render(scene,cam);requestAnimationFrame(tick);
window.__mitra={cam,ctr,N,travel,pose,setSteer:v=>{steer=v;steerEl.value=v;}};   // 画面写真を撮るときに外から視点と姿勢を決めるための口
}
requestAnimationFrame(tick);
window.__mitra={cam,ctr,N,travel,pose,setSteer:v=>{steer=v;steerEl.value=v;}};   // 画面写真を撮るときに外から視点と姿勢を決めるための口
}
</script>
</body>
</html>
