VRMMORPGβ版

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <title>エルダークロニクル:VR超完全版 – ロードなし(拾う/装備修正)</title>
  <script src="https://aframe.io/releases/1.4.2/aframe.min.js"></script>
  <style>
    body, html { margin:0; padding:0; overflow:hidden; font-family:'Yu Gothic',system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; background:#000;}
    #ui {
      position:absolute; top:20px; left:20px; z-index:10; width:400px; color:#fff;
      background:linear-gradient(180deg,rgba(0,0,0,.92),rgba(0,10,30,.85));
      border-radius:16px; padding:14px 16px; box-shadow:0 0 25px #0ff,0 0 18px #33f4; font-size:15px;
    }
    h2 { margin:0 0 8px 0; font-size:22px; letter-spacing:1px;}
    .row { display:flex; gap:8px; align-items:center; flex-wrap:wrap;}
    .row > * { flex: 1 1 auto; }
    input, select { width:100%; padding:6px 8px; border-radius:8px; border:1px solid #024; background:#00131f; color:#cfe9ff; }
    button {
      background:linear-gradient(90deg,#555,#222 80%);
      color:#fff; padding:10px; margin:5px 0; border:none; cursor:pointer; width:100%;
      border-radius:8px; font-weight:bold; letter-spacing:1px; box-shadow:0 1px 8px #0cf5; transition:background .25s;
    }
    button:hover { background:linear-gradient(90deg,#888 40%,#3cf); }
    .section-title { font-weight:bold; font-size:17px; margin-top:10px; border-bottom:2px solid #5ef; letter-spacing:1.2px; }
    .bar { height:14px; background:#13202a; border-radius:7px; overflow:hidden; margin:6px 0; box-shadow:0 1px 6px #0ff6 inset; }
    .bar-inner { height:100%; background:linear-gradient(90deg,#0f0,#3af); transition:width .25s; }
    .mana-bar .bar-inner { background:linear-gradient(90deg,#33d,#6ff); }
    .enemyhp-bar .bar-inner { background:linear-gradient(90deg,#f55,#fdd); }
    #scenario { margin:10px 0 6px 0; background:rgba(0,10,32,0.7); padding:8px 12px; border-radius:8px; min-height:44px; }
    .kbd { display:inline-block; padding:1px 6px; border-radius:6px; background:#0a2636; border:1px solid #124; font-family:monospace; }
    #hint {
      position:absolute; bottom:18px; left:50%; transform:translateX(-50%);
      color:#eaffff; background:rgba(0,20,35,.72); border:1px solid #0af; padding:8px 12px; border-radius:10px;
      box-shadow:0 0 18px #08f5; font-size:14px; z-index:10;
    }
    #pickupPrompt {
      position:absolute; bottom:70px; left:50%; transform:translateX(-50%);
      color:#fff; background:rgba(0,0,0,.7); border:1px solid #38f; padding:8px 12px; border-radius:10px;
      display:none; z-index:10;
    }
    .tag { display:inline-block; padding:2px 6px; border-radius:6px; background:#012233; border:1px solid #1a4e6c; margin-left:6px; font-size:12px; color:#bfe6ff;}
    .on { background:#0b3754; border-color:#3db3ff; color:#fff; }
  </style>
</head>
<body>
  <div id="ui">
    <h2>エルダークロニクルVR</h2>
    <div class="row">
      <span>プレイヤー名:</span>
      <input id="playerName" placeholder="名前を入力">
    </div>

    <div class="row"><span>レベル:</span><span id="level" class="tag on">1</span>
      <span>装備:</span><span id="equipment" class="tag">なし</span>
    </div>

    <div>HP: <span id="hpText">100</span></div>
    <div class="bar"><div id="hpBar" class="bar-inner" style="width:100%"></div></div>
    <div>魔力: <span id="manaText">100</span></div>
    <div class="bar mana-bar"><div id="manaBar" class="bar-inner" style="width:100%"></div></div>

    <div>敵HP: <span id="enemyHpText">120</span></div>
    <div class="bar enemyhp-bar"><div id="enemyHpBar" class="bar-inner" style="width:100%"></div></div>

    <div class="section-title">シナリオ</div>
    <div id="scenario"></div>

    <div class="section-title">行動</div>
    <button onclick="levelUp()">🎉 レベルアップ</button>
    <button onclick="castSpell()">🪄 魔法発動</button>
    <button onclick="choosePath('wizard')">🧙‍♂️ 魔導士に話す</button>
    <button onclick="choosePath('knight')">🛡️ 騎士に話す</button>
    <button onclick="receiveQuest()">📜 クエスト受注</button>
    <button onclick="toggleEnvironment()">🌄 昼夜切替</button>

    <div class="section-title">移動</div>
    <div class="row">
      <button onclick="changeField('town')">🏘️ 街</button>
      <button onclick="changeField('castle')">🏰 城</button>
    </div>
    <div class="row">
      <button onclick="changeField('cave')">🕳️ 洞窟</button>
      <button onclick="changeField('ruins')">🏛️ 遺跡</button>
    </div>
    <div class="row">
      <button onclick="changeField('dungeon')">🧩 ダンジョン</button>
    </div>

    <div class="section-title">操作</div>
    <div style="line-height:1.6">
      <span class="kbd">WASD</span> 移動 
      <span class="kbd">マウス</span> 視点 
      <span class="kbd">E</span> 拾う 
      <span class="kbd">1</span> 剣装備 
      <span class="kbd">2</span> 銃装備 
      <span class="kbd">クリック</span> 攻撃
    </div>
  </div>

  <div id="pickupPrompt">Eで拾う</div>
  <div id="hint">近くの武器に近づいて <span class="kbd">E</span> で拾い、<span class="kbd">1/2</span> で装備、クリックで攻撃!</div>

  <a-scene loading-screen="enabled:false" renderer="colorManagement:true" shadow="true">
    <a-sky id="sky" color="#0e163e"></a-sky>

    <a-entity id="starParticles" position="0 25 -40" visible="false">
      <a-entity geometry="primitive:sphere; radius:0.18" material="color:#fff; opacity:0.6" position="-10 3 0"></a-entity>
      <a-entity geometry="primitive:sphere; radius:0.12" material="color:#fff; opacity:0.8" position="7 2 -2"></a-entity>
      <a-entity geometry="primitive:sphere; radius:0.11" material="color:#eaf6ff; opacity:0.9" position="3 5 2"></a-entity>
      <a-entity geometry="primitive:sphere; radius:0.10" material="color:#ffe; opacity:0.7" position="13 3 5"></a-entity>
    </a-entity>
    <a-entity id="cloudParticles" position="0 30 -35" visible="true">
      <a-sphere radius="5" position="8 2 -8" color="#f6fbff" opacity="0.18"></a-sphere>
      <a-sphere radius="6" position="-7 3 5" color="#eefbff" opacity="0.14"></a-sphere>
    </a-entity>

    <a-light type="ambient" color="#fff" intensity="1"></a-light>
    <a-light id="sunlight" type="directional" intensity="1.6" position="20 25 -8" castShadow="true" shadow-mapWidth="1024" shadow-mapHeight="1024"></a-light>
    <a-light type="point" color="#cff" intensity="2.2" distance="50" position="2 9 -3"></a-light>
    <a-light type="spot" color="#55aaff" position="0 15 -10" intensity="1.2" angle="30" penumbra="0.7"></a-light>

    <a-plane id="ground" position="0 0 0" rotation="-90 0 0" width="120" height="120" color="#375047" shadow="receive:true"></a-plane>

    <a-entity id="field-town" visible="true">
      <a-circle position="0 0 -6" radius="4" color="#7d7d7d" material="roughness:.9; metalness:.05; opacity:.84; transparent:true"></a-circle>
      <a-entity position="-2 0 -7">
        <a-box width="3.6" height="2.6" depth="2.4" color="#c0a47b" material="roughness:0.3; metalness:0.05" position="0 1.3 0"></a-box>
        <a-cone position="0 3 -0.1" radius-bottom="2.1" height="1.4" color="#7b5322"></a-cone>
        <a-text value="街の家" position="0 3.7 0" color="#fff" width="5" align="center"></a-text>
      </a-entity>
      <a-entity position="2 0 -9">
        <a-box width="2.2" height="2.2" depth="2.4" color="#a86f23" position="0 1.1 0"></a-box>
        <a-cone position="0 2.6 0" radius-bottom="1.4" height="1.0" color="#5c3a12"></a-cone>
      </a-entity>
      <a-entity position="5 0 -5">
        <a-cylinder radius="0.25" height="4" color="#3a2a1a" position="0 2 0"></a-cylinder>
        <a-sphere radius="1.2" color="#174d1f" position="0 3.2 0"></a-sphere>
      </a-entity>
    </a-entity>

    <a-entity id="field-castle" visible="false">
      <a-box position="0 2.8 -12" depth="6" height="6" width="10" color="#ccd2df" material="roughness:0.25; metalness:0.12"></a-box>
      <a-cylinder position="-4 1.2 -13" radius="1.1" height="3.8" color="#858ca3"></a-cylinder>
      <a-cylinder position="4 1.2 -13" radius="1.1" height="3.8" color="#858ca3"></a-cylinder>
      <a-cone position="0 6.4 -12" radius-bottom="3.2" height="2" color="#dba"></a-cone>
      <a-entity geometry="primitive:torus; radius:2.5; tube:0.07" material="color:#66aaff; opacity:.25; transparent:true" position="0 4.5 -12"></a-entity>
      <a-text value="王の城" position="0 6.3 -12" color="#0bf" width="6" align="center"></a-text>
    </a-entity>

    <a-entity id="field-cave" visible="false">
      <a-torus position="2 1.1 -10" radius="1.8" tube="0.8" arc="230" color="#363636" rotation="40 0 90"></a-torus>
      <a-sphere position="2 0.4 -10" radius="1.1" color="#151515"></a-sphere>
      <a-entity position="-2 0 -8">
        <a-cone radius-bottom="0.8" height="2.2" color="#2a2a2a"></a-cone>
        <a-cone radius-bottom="0.5" height="1.4" color="#393939" position="0.7 0 0.4"></a-cone>
      </a-entity>
      <a-text value="洞窟の入口" position="2 2.9 -10" color="#fff" width="6" align="center"></a-text>
    </a-entity>

    <a-entity id="field-ruins" visible="false">
      <a-cylinder position="-2 1.1 -9" radius="0.8" height="2.6" color="#babbb2"></a-cylinder>
      <a-box position="-3.1 1.8 -9" width="3.5" height="0.32" depth="0.7" color="#e0dfc7"></a-box>
      <a-torus position="-2 2.3 -9" radius="0.6" tube="0.09" arc="340" color="#fffeee"></a-torus>
      <a-entity geometry="primitive:torusKnot; p:2; q:7; radius:0.7; tube:0.07" position="2 1.8 -8" material="color:#bcd; opacity:.7; transparent:true"></a-entity>
      <a-text value="古代の遺構" position="0 3.3 -8.5" color="#fff" width="6" align="center"></a-text>
    </a-entity>

    <a-entity id="field-dungeon" visible="false">
      <a-box position="2 1.2 -8.8" depth="3.3" height="2.3" width="3.6" color="#161651"></a-box>
      <a-torus-knot position="-1.5 2.7 -8.2" radius="0.9" tube="0.12" p="3" q="7" color="#64eaff"></a-torus-knot>
      <a-cylinder position="-3 0.7 -9.6" radius="0.8" height="1.2" color="#333"></a-cylinder>
      <a-entity geometry="primitive:torus; radius:1.4; tube:0.05" material="color:#aaeeff; opacity:.18; transparent:true" position="0 2.1 -8.6" rotation="90 0 0"></a-entity>
      <a-text value="ダンジョン入口" position="0 3.1 -8.4" color="#fff" width="6" align="center"></a-text>
    </a-entity>

    <!-- 武器ピックアップ -->
    <a-entity id="swordPickup" class="pickup" data-weapon="sword" position="-1 0 -5">
      <a-box width="0.16" height="1.3" depth="0.08" color="#cfe7ff" material="metalness:0.8; roughness:0.15" position="0 0.75 0"></a-box>
      <a-box width="0.5" height="0.08" depth="0.08" color="#333" position="0 0.1 0"></a-box>
      <a-cylinder radius="0.06" height="0.42" color="#7c5a2b" position="0 -0.1 0"></a-cylinder>
      <a-entity geometry="primitive:ring; radiusInner:0.45; radiusOuter:0.5" rotation="-90 0 0" position="0 0 0" material="color:#44d; opacity:.35; transparent:true"></a-entity>
      <a-text value="剣" color="#fff" position="0 1.7 0" align="center"></a-text>
    </a-entity>

    <a-entity id="gunPickup" class="pickup" data-weapon="gun" position="2 0 -5.5">
      <a-box width="0.7" height="0.18" depth="0.18" color="#222" position="0 0.4 0"></a-box>
      <a-box width="0.3" height="0.28" depth="0.18" color="#444" position="-0.2 0.2 0"></a-box>
      <a-box width="0.12" height="0.40" depth="0.16" color="#333" position="0.2 0.15 0"></a-box>
      <a-cylinder radius="0.06" height="0.28" color="#555" position="0.34 0.46 0" rotation="0 0 90"></a-cylinder>
      <a-entity geometry="primitive:ring; radiusInner:0.45; radiusOuter:0.5" rotation="-90 0 0" position="0 0 0" material="color:#0aa; opacity:.35; transparent:true"></a-entity>
      <a-text value="銃" color="#fff" position="0 1.0 0" align="center"></a-text>
    </a-entity>

    <!-- プレイヤー(リグが移動する:★修正) -->
    <a-entity id="rig" position="0 0 0" wasd-controls="acceleration:30">
      <a-entity id="cam" camera look-controls="pointerLockEnabled:true" position="0 1.6 3"></a-entity>
      <a-entity id="player" position="0 0 -1.5" rotation="0 180 0" shadow="cast:true">
        <a-sphere radius="0.18" color="#ffd7f0" position="0 1.58 0"></a-sphere>
        <a-cylinder radius="0.23" height="0.9" color="#9ad" position="0 1.02 0"></a-cylinder>
        <a-cylinder radius="0.08" height="0.55" color="#9ad" position="-0.16 0.74 0" rotation="0 0 18"></a-cylinder>
        <a-cylinder radius="0.08" height="0.55" color="#9ad" position="0.16 0.74 0" rotation="0 0 -18"></a-cylinder>
        <a-cylinder radius="0.09" height="0.7" color="#79b" position="-0.10 0.35 0"></a-cylinder>
        <a-cylinder radius="0.09" height="0.7" color="#79b" position="0.10 0.35 0"></a-cylinder>
      </a-entity>
    </a-entity>

    <!-- 敵 -->
    <a-entity id="enemy" position="0 0 -9" visible="true">
      <a-sphere id="enemyBody" radius="1.25" color="#9b1e1e" material="metalness:0.35; roughness:.25; emissive:#330000"></a-sphere>
      <a-entity geometry="primitive:torus; radius:1.4; tube:0.05" material="color:#ffeeaa; opacity:.18; transparent:true" position="0 0.3 0" rotation="90 0 0"></a-entity>
      <a-entity geometry="primitive:torusKnot; radius:0.45; tube:0.05; p:2; q:5" material="color:#ffa033; opacity:.22; transparent:true" position="0 1.0 0"></a-entity>
      <a-sphere position="-0.38 0.42 0.95" radius="0.14" color="#fff" material="metalness:.9; roughness:.05; emissive:#a0f"></a-sphere>
      <a-sphere position="0.38 0.42 0.95" radius="0.14" color="#fff" material="metalness:.9; roughness:.05; emissive:#a0f"></a-sphere>
      <a-cone position="-0.45 1.35 0.15" radius-bottom="0.16" height="0.62" color="#f5f3ff" rotation="15 0 60"></a-cone>
      <a-cone position="0.45 1.35 0.15" radius-bottom="0.16" height="0.62" color="#f5f3ff" rotation="15 0 -60"></a-cone>
      <a-text value="敵モンスター" position="0 2.15 0" align="center" color="#fff"></a-text>
    </a-entity>

    <a-entity id="spellEffect" geometry="primitive:sphere; radius:0.55"
              material="color:#72f3ff; opacity:.86; emissive:#88f; transparent:true"
              position="0 1.7 -3" visible="false"
              animation__move="property: position; to: 0 3.1 -6; dur:500; dir:alternate; loop:false">
      <a-entity geometry="primitive:torus; radius:0.7; tube:0.08" material="color:#fff; opacity:.3; transparent:true"></a-entity>
    </a-entity>

    <a-entity id="game" game-manager></a-entity>
  </a-scene>

<script>
let isDay=false, hp=100, mana=100, level=1;
let enemyHP=120, enemyHPMax=120;
function updateBars(){
  document.getElementById("hpText").innerText = Math.max(0,Math.floor(hp));
  document.getElementById("manaText").innerText = Math.max(0,Math.floor(mana));
  document.getElementById("hpBar").style.width = Math.max(0,Math.min(100,hp))+"%";
  document.getElementById("manaBar").style.width = Math.max(0,Math.min(100,mana))+"%";
  document.getElementById("level").innerText = level;
  document.getElementById("enemyHpText").innerText = Math.max(0,enemyHP);
  const w = Math.max(0, Math.min(100, enemyHP*100/enemyHPMax));
  document.getElementById("enemyHpBar").style.width = w+"%";
}
function levelUp(){ level++; hp=Math.min(100,hp+20); mana+=30; showScenario("🎉 レベルアップ!新しい力が湧いてくる!"); updateBars(); }
function castSpell(){
  if(mana<20){ showScenario("💤 魔力が足りない!"); return; }
  mana-=20; updateBars();
  const effect=document.getElementById("spellEffect");
  effect.setAttribute("visible","true");
  setTimeout(()=>{ effect.setAttribute("visible","false"); applyDamageToEnemy(30,"魔法ヒット"); },700);
}
function choosePath(choice){
  if(choice==="wizard"){ document.getElementById("equipment").innerText="魔導士のローブ"; mana+=50; showScenario("🧙‍♂️ 魔導士の試練が始まる…"); }
  else{ document.getElementById("equipment").innerText="騎士の剣"; hp+=30; showScenario("⚔️ 騎士と共に魔王城へ向かう!"); }
  updateBars();
}
function toggleEnvironment(){
  const sky=document.getElementById("sky");
  const star=document.getElementById("starParticles");
  const cloud=document.getElementById("cloudParticles");
  const ground=document.getElementById("ground");
  const sunlight=document.getElementById("sunlight");
  if(isDay){
    sky.setAttribute("color","#0e163e"); star.setAttribute("visible","false"); cloud.setAttribute("visible","true");
    ground.setAttribute("color","#375047"); sunlight.setAttribute("intensity","1.6"); showScenario("🌌 夜の世界へ…");
  }else{
    sky.setAttribute("color","#7ddfff"); star.setAttribute("visible","true"); cloud.setAttribute("visible","false");
    ground.setAttribute("color","#b8ffcc"); sunlight.setAttribute("intensity","2.1"); showScenario("🌞 昼の世界へ…");
  }
  isDay=!isDay;
}
function changeField(fieldName){
  const fields=['town','castle','cave','ruins','dungeon'];
  fields.forEach(name=>{
    const el=document.getElementById(`field-${name}`);
    el.setAttribute('visible', name===fieldName);
  });
  showScenario(`📍 ${fieldName} に移動しました`);
}
function receiveQuest(){
  const quests=[
    "魔導士の塔で失われた書を探せ!","騎士団の旗を取り戻せ!","洞窟の奥に眠る魔石を発見せよ!",
    "遺跡に隠された封印を解け!","ダンジョンの魔王を討伐せよ!"
  ];
  const index=Math.floor(Math.random()*quests.length);
  showScenario("📜 クエスト受注: "+quests[index]);
}

const scenarioList=[
  "目覚めたあなたは不思議な世界にいた。","最初のクエストを受注しよう。","フィールド移動で冒険の扉が開く。",
  "行動や魔法でストーリーが動く。","街で情報を集め、仲間と出会おう。","クエストを進め、魔王に立ち向かえ!"
];
let scenarioIndex=0;
function showScenario(text){ document.getElementById('scenario').innerHTML=text; }
function advanceScenario(){ if(scenarioIndex<scenarioList.length){ showScenario(scenarioList[scenarioIndex]); scenarioIndex++; } }
['levelUp','castSpell','choosePath','changeField','receiveQuest'].forEach(fn=>{
  const orig=window[fn]; window[fn]=function(){ orig.apply(this, arguments); advanceScenario(); }
});

/* ---- ここが拾う/装備の中核 ---- */
const rigEl=()=>document.getElementById('rig');
const camEl=()=>document.getElementById('cam');
const enemyEl=()=>document.getElementById('enemy');
const enemyBodyEl=()=>document.getElementById('enemyBody');

let hasSword=false, hasGun=false, equipped='none';
let attackCooldown=false;
const bullets=[];

function setEquipmentLabel(){
  let label="なし";
  if(equipped==='sword') label="剣";
  if(equipped==='gun') label="銃";
  document.getElementById('equipment').innerText=label;
}

function tryPickup(){
  const rpos=rigEl().object3D.position; // ★リグが移動するのでOK
  const items=[document.getElementById('swordPickup'),document.getElementById('gunPickup')];
  for(const it of items){
    if(!it.getAttribute('visible')) continue;
    const wpos=it.object3D.position;
    const d=rpos.distanceTo(wpos);
    if(d<2.0){
      const w=it.getAttribute('data-weapon');
      it.setAttribute('visible','false');
      if(w==='sword'){ hasSword=true; if(equipped==='none') equipped='sword'; showScenario("🗡️ 剣を拾った! 1で装備。"); }
      if(w==='gun'){ hasGun=true; if(equipped==='none') equipped='gun'; showScenario("🔫 銃を拾った! 2で装備。"); }
      setEquipmentLabel();
      return;
    }
  }
  showScenario("近くに拾えるものはない。");
}

function equipSword(){ if(hasSword){ equipped='sword'; setEquipmentLabel(); showScenario("🗡️ 剣を装備した。"); } else { showScenario("剣をまだ拾っていない。"); } }
function equipGun(){ if(hasGun){ equipped='gun'; setEquipmentLabel(); showScenario("🔫 銃を装備した。"); } else { showScenario("銃をまだ拾っていない。"); } }

function attack(){
  if(attackCooldown) return;
  if(equipped==='sword'){ swordSlash(); }
  else if(equipped==='gun'){ shootBullet(); }
  else{ showScenario("装備がありません。剣や銃を拾ってください。"); }
}

function swordSlash(){
  attackCooldown=true;
  const slash=document.createElement('a-entity');
  slash.setAttribute('geometry','primitive: torus; radius:0.9; tube:0.08; arc:200');
  slash.setAttribute('material','color:#fff; opacity:.6; transparent:true');
  const dir=new AFRAME.THREE.Vector3(); camEl().object3D.getWorldDirection(dir); dir.y=0; dir.normalize();
  const base=rigEl().object3D.position.clone().add(new AFRAME.THREE.Vector3(0,1.2,0)).add(dir.clone().multiplyScalar(0.8));
  slash.setAttribute('position',`${base.x} ${base.y} ${base.z}`);
  const rotY=Math.atan2(dir.x,dir.z)*AFRAME.THREE.MathUtils.RAD2DEG;
  slash.setAttribute('rotation',`0 ${rotY} 0`);
  slash.setAttribute('animation__fade','property: material.opacity; to:0; dur:200; easing:easeOutQuad');
  document.querySelector('a-scene').appendChild(slash);
  setTimeout(()=>slash.parentNode && slash.parentNode.removeChild(slash),220);

  const enemyPos=enemyEl().object3D.position.clone();
  const toEnemy=enemyPos.clone().sub(rigEl().object3D.position.clone().add(new AFRAME.THREE.Vector3(0,1.0,0)));
  const dist=toEnemy.length();
  toEnemy.y=0; toEnemy.normalize();
  const forward=dir.clone();
  const angle=forward.dot(toEnemy);
  if(dist<2.6 && angle>0.5 && enemyEl().getAttribute('visible')){
    applyDamageToEnemy(25,"斬撃");
  } else {
    showScenario("空振り…");
  }
  setTimeout(()=>attackCooldown=false,280);
}

function shootBullet(){
  attackCooldown=true;
  const bullet=document.createElement('a-sphere');
  bullet.setAttribute('radius','0.07');
  bullet.setAttribute('color','#e6f7ff');
  bullet.setAttribute('material','emissive:#88d; metalness:.6; roughness:.2');
  const dir=new AFRAME.THREE.Vector3(); camEl().object3D.getWorldDirection(dir); dir.normalize();
  const start=rigEl().object3D.position.clone().add(new AFRAME.THREE.Vector3(0,1.3,0)).add(dir.clone().multiplyScalar(0.9));
  bullet.setAttribute('position',`${start.x} ${start.y} ${start.z}`);
  document.querySelector('a-scene').appendChild(bullet);
  bullets.push({el:bullet, dir:dir.clone(), life:1800, speed:24});
  setTimeout(()=>attackCooldown=false,120);
}

function applyDamageToEnemy(dmg,label){
  if(!enemyEl().getAttribute('visible')) return;
  enemyHP=Math.max(0, enemyHP - dmg);
  updateBars();
  const origColor=enemyBodyEl().getAttribute('color');
  enemyBodyEl().setAttribute('color','#ffffff');
  setTimeout(()=>enemyBodyEl().setAttribute('color', origColor), 80);
  spawnDamageText(dmg,label);
  if(enemyHP<=0){ killEnemy(); }
}

function spawnDamageText(dmg,label){
  const t=document.createElement('a-text');
  t.setAttribute('value',`${label} -${dmg}`);
  t.setAttribute('color','#ffe6e6');
  t.setAttribute('align','center');
  const p=enemyEl().object3D.position.clone();
  t.setAttribute('position',`${p.x} ${p.y+2.4} ${p.z}`);
  t.setAttribute('animation__rise','property: position; to: '+`${p.x} ${p.y+3.2} ${p.z}`+'; dur:650; easing:easeOutQuad');
  t.setAttribute('animation__fade','property: opacity; to:0; dur:650; easing:easeOutQuad');
  document.querySelector('a-scene').appendChild(t);
  setTimeout(()=>t.parentNode && t.parentNode.removeChild(t),700);
}

function killEnemy(){
  enemyEl().setAttribute('visible','false');
  showScenario("✅ 敵を倒した! 5秒後に再出現する…");
  setTimeout(()=>respawnEnemy(), 5000);
}
function respawnEnemy(){
  enemyHP=enemyHPMax; updateBars();
  const e=enemyEl();
  const x = (Math.random()*6 - 3);
  const z = -8.5 + (Math.random()*3 - 1.5);
  e.setAttribute('position',`${x} 0 ${z}`);
  e.setAttribute('visible','true');
  showScenario("⚠️ 新たな敵が現れた!");
}

/* 入力(E/1/2 の互換強化:★修正) */
AFRAME.registerComponent('game-manager',{
  init:function(){
    window.addEventListener('keydown',(e)=>{
      const k=e.key;
      const c=e.code;
      if(c==='KeyE' || k==='e' || k==='E') tryPickup();
      if(c==='Digit1' || c==='Numpad1' || k==='1') equipSword();
      if(c==='Digit2' || c==='Numpad2' || k==='2') equipGun();
    });
    window.addEventListener('mousedown',()=>attack());
    updateBars(); advanceScenario(); setEquipmentLabel();
  },
  tick:function(time,dt){
    const delta=dt/1000;
    const prompt=document.getElementById('pickupPrompt');
    const rpos=rigEl().object3D.position;
    let near=false;
    ['swordPickup','gunPickup'].forEach(id=>{
      const el=document.getElementById(id);
      if(el.getAttribute('visible')){
        const d=rpos.distanceTo(el.object3D.position);
        if(d<2.0) near=true;
      }
    });
    prompt.style.display = near?'block':'none';

    // 弾
    for(let i=bullets.length-1;i>=0;i--){
      const b=bullets[i];
      if(!b.el.parentNode){ bullets.splice(i,1); continue; }
      b.life -= dt;
      const pos=b.el.object3D.position;
      pos.add(b.dir.clone().multiplyScalar(24*delta));
      if(b.life<=0){ b.el.parentNode.removeChild(b.el); bullets.splice(i,1); continue; }
      if(enemyEl().getAttribute('visible')){
        const d=pos.distanceTo(enemyEl().object3D.position);
        if(d<1.35){
          applyDamageToEnemy(15,"射撃");
          b.el.parentNode.removeChild(b.el);
          bullets.splice(i,1);
        }
      }
    }
    enemyEl().object3D.rotation.y += delta*0.3;
  }
});

updateBars();
advanceScenario();
</script>
</body>
</html>

NeuroLink Dive System Advanced – 究極完全フルダイブVRプラットフォーム


<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>NeuroLink Dive System Advanced - 究極完全フルダイブVRプラットフォーム</title>
  
  <!-- Core Libraries -->
  <script src="https://cdn.jsdelivr.net/npm/aframe@1.4.2/dist/aframe-master.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/three@0.152.2/build/three.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/howler@2.2.3/dist/howler.min.js"></script>
  <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css">
  <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&family=Exo+2:wght@300;400;600;800&display=swap" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/chart.js@4.3.0/dist/chart.umd.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.7.5/dist/sweetalert2.all.min.js"></script>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11.7.5/dist/sweetalert2.min.css">
  <script src="https://cdn.jsdelivr.net/npm/particles.js@2.0.0/particles.min.js"></script>

  <style>
    :root {
      --neural-primary: #00E6FF;
      --neural-secondary: #FF0080;
      --quantum-purple: #9146FF;
      --bio-green: #39FF14;
      --nano-orange: #FF8C00;
      --memory-gold: #FFD700;
      --consciousness-blue: #0080FF;
      --dark-void: #000008;
      --dark-neural: #0A0A20;
      --holographic-cyan: #00FFFF;
      --plasma-pink: #FF69B4;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html, body {
      font-family: 'Rajdhani', 'Orbitron', monospace;
      background: radial-gradient(ellipse at center, #0A0A20 0%, #000008 70%, #000000 100%);
      color: var(--neural-primary);
      overflow-x: hidden;
      scroll-behavior: smooth;
    }

    /* Particle Background */
    #particles-js {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -1;
      opacity: 0.3;
    }

    /* Holographic Text Effects */
    .holo-text {
      background: linear-gradient(45deg, #00E6FF, #FF0080, #9146FF, #39FF14, #FFD700);
      background-size: 400% 400%;
      animation: holoShift 8s ease-in-out infinite;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      font-weight: 900;
      font-family: 'Orbitron', monospace;
      text-shadow: 0 0 30px #00e6ff66, 0 0 60px #ff008055;
      position: relative;
    }

    .holo-text::before {
      content: attr(data-text);
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      animation: scanline 3s linear infinite;
    }

    @keyframes holoShift {
      0%, 100% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
    }

    @keyframes scanline {
      0% { transform: translateX(-100%); }
      100% { transform: translateX(100%); }
    }

    /* Neural HUD */
    .neural-hud {
      position: fixed;
      top: 20px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 5000;
      display: flex;
      gap: 20px;
      pointer-events: none;
      flex-wrap: wrap;
      justify-content: center;
    }

    .neural-hud .status-pod {
      min-width: 140px;
      font-size: 1.1em;
      padding: 10px 16px;
      background: rgba(0, 0, 0, 0.85);
      border-radius: 25px;
      box-shadow: 0 0 20px rgba(0, 230, 255, 0.4);
      border: 2px solid rgba(0, 230, 255, 0.6);
      pointer-events: auto;
      display: flex;
      align-items: center;
      gap: 10px;
      backdrop-filter: blur(10px);
      font-family: 'Space Mono', monospace;
      transition: all 0.3s ease;
    }

    .neural-hud .status-pod:hover {
      transform: scale(1.05);
      box-shadow: 0 0 30px rgba(0, 230, 255, 0.8);
    }

    .neural-hud .status-pod.critical {
      border-color: #FF0080;
      box-shadow: 0 0 20px rgba(255, 0, 128, 0.6);
      animation: criticalPulse 1.5s ease-in-out infinite;
    }

    @keyframes criticalPulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.7; }
    }

    /* Main Container */
    .main-container {
      width: 100%;
      padding: 30px;
      display: flex;
      flex-direction: column;
      gap: 50px;
      margin-top: 100px;
    }

    /* Section Styling */
    .section {
      background: linear-gradient(135deg, rgba(0, 230, 255, 0.08) 0%, rgba(255, 0, 128, 0.08) 30%, rgba(145, 70, 255, 0.08) 70%, rgba(57, 255, 20, 0.08) 100%);
      border: 2px solid rgba(0, 230, 255, 0.3);
      border-radius: 30px;
      padding: 50px;
      margin-bottom: 40px;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
      backdrop-filter: blur(5px);
      position: relative;
      overflow: hidden;
    }

    .section::before {
      content: '';
      position: absolute;
      top: -2px;
      left: -2px;
      right: -2px;
      bottom: -2px;
      background: linear-gradient(45deg, #00E6FF, #FF0080, #9146FF, #39FF14);
      background-size: 400% 400%;
      animation: borderGlow 6s ease-in-out infinite;
      border-radius: 30px;
      z-index: -1;
      opacity: 0.3;
    }

    @keyframes borderGlow {
      0%, 100% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
    }

    /* Cards */
    .card {
      background: rgba(0, 230, 255, 0.05);
      border: 2px solid rgba(0, 230, 255, 0.25);
      border-radius: 25px;
      padding: 35px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
      transition: all 0.3s ease;
      backdrop-filter: blur(10px);
      position: relative;
      overflow: hidden;
    }

    .card::before {
      content: '';
      position: absolute;
      top: 0;
      left: -100%;
      width: 100%;
      height: 100%;
      background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
      transition: left 0.5s;
    }

    .card:hover::before {
      left: 100%;
    }

    .card:hover {
      transform: translateY(-10px) scale(1.02);
      box-shadow: 0 20px 50px rgba(0, 230, 255, 0.2);
      border-color: rgba(0, 230, 255, 0.6);
    }

    /* Neural Buttons */
    .neural-button {
      background: linear-gradient(135deg, rgba(0, 230, 255, 0.2) 0%, rgba(255, 0, 128, 0.2) 50%, rgba(145, 70, 255, 0.2) 100%);
      border: 3px solid transparent;
      background-clip: padding-box;
      color: var(--neural-primary);
      padding: 16px 32px;
      border-radius: 50px;
      cursor: pointer;
      font-weight: 700;
      font-size: 1.2em;
      display: inline-flex;
      align-items: center;
      gap: 12px;
      font-family: 'Orbitron', monospace;
      text-transform: uppercase;
      letter-spacing: 2px;
      box-shadow: 0 0 30px rgba(0, 230, 255, 0.3);
      transition: all 0.3s ease;
      position: relative;
      overflow: hidden;
    }

    .neural-button::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: linear-gradient(45deg, #00E6FF, #FF0080, #9146FF);
      opacity: 0;
      transition: opacity 0.3s ease;
      border-radius: 50px;
      z-index: -1;
    }

    .neural-button:hover::before {
      opacity: 0.8;
    }

    .neural-button:hover {
      transform: translateY(-8px) scale(1.05);
      color: #ffffff;
      box-shadow: 0 0 50px rgba(0, 230, 255, 0.8), 0 10px 30px rgba(0, 0, 0, 0.3);
    }

    .neural-button:active {
      transform: translateY(-5px) scale(1.02);
    }

    /* VR Area */
    .dive-vr-area {
      width: 100%;
      height: 500px;
      margin: 30px 0;
      border-radius: 25px;
      overflow: hidden;
      box-shadow: 0 0 50px rgba(0, 230, 255, 0.4);
      border: 3px solid rgba(0, 230, 255, 0.5);
      position: relative;
    }

    .dive-vr-area::before {
      content: 'NEURAL DIVE ACTIVE';
      position: absolute;
      top: 20px;
      left: 20px;
      color: #39FF14;
      font-family: 'Space Mono', monospace;
      font-weight: bold;
      z-index: 10;
      background: rgba(0, 0, 0, 0.7);
      padding: 8px 16px;
      border-radius: 15px;
      font-size: 0.9em;
      border: 1px solid #39FF14;
    }

    /* Grid Layout */
    .grid-layout {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
      gap: 35px;
    }

    /* AI Chat Interface */
    #aiChatLog {
      background: rgba(0, 0, 0, 0.4);
      border-radius: 20px;
      min-height: 300px;
      max-height: 400px;
      overflow-y: auto;
      font-family: 'Space Mono', monospace;
      font-size: 1.1em;
      padding: 20px;
      border: 2px solid rgba(0, 230, 255, 0.3);
      scrollbar-width: thin;
      scrollbar-color: #00E6FF #000;
    }

    #aiChatLog::-webkit-scrollbar {
      width: 8px;
    }

    #aiChatLog::-webkit-scrollbar-track {
      background: rgba(0, 0, 0, 0.3);
      border-radius: 10px;
    }

    #aiChatLog::-webkit-scrollbar-thumb {
      background: linear-gradient(45deg, #00E6FF, #9146FF);
      border-radius: 10px;
    }

    .ai-msg-user {
      background: rgba(0, 128, 255, 0.2);
      color: #00E6FF;
      border-radius: 20px 20px 5px 20px;
      padding: 15px 20px;
      margin-bottom: 10px;
      border: 1px solid rgba(0, 230, 255, 0.4);
      animation: slideInRight 0.3s ease;
    }

    .ai-msg-ai {
      background: rgba(145, 70, 255, 0.2);
      color: #FF69B4;
      border-radius: 20px 20px 20px 5px;
      padding: 15px 20px;
      margin-bottom: 10px;
      border: 1px solid rgba(255, 105, 180, 0.4);
      animation: slideInLeft 0.3s ease;
    }

    .ai-msg-meta {
      font-size: 0.9em;
      color: #aaa;
      margin-bottom: 5px;
      font-weight: bold;
    }

    @keyframes slideInRight {
      from { transform: translateX(30px); opacity: 0; }
      to { transform: translateX(0); opacity: 1; }
    }

    @keyframes slideInLeft {
      from { transform: translateX(-30px); opacity: 0; }
      to { transform: translateX(0); opacity: 1; }
    }

    /* Chart Containers */
    .chart-container {
      position: relative;
      height: 300px;
      background: rgba(0, 0, 0, 0.3);
      border-radius: 15px;
      padding: 20px;
      border: 2px solid rgba(0, 230, 255, 0.2);
    }

    /* Control Panels */
    .control-panel {
      background: rgba(0, 0, 0, 0.5);
      border: 2px solid rgba(0, 230, 255, 0.4);
      border-radius: 20px;
      padding: 25px;
      margin: 15px 0;
    }

    .slider-control {
      width: 100%;
      height: 8px;
      background: rgba(0, 230, 255, 0.2);
      border-radius: 5px;
      outline: none;
      -webkit-appearance: none;
      margin: 15px 0;
    }

    .slider-control::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 25px;
      height: 25px;
      background: linear-gradient(45deg, #00E6FF, #9146FF);
      border-radius: 50%;
      cursor: pointer;
      box-shadow: 0 0 15px rgba(0, 230, 255, 0.8);
    }

    .slider-control::-moz-range-thumb {
      width: 25px;
      height: 25px;
      background: linear-gradient(45deg, #00E6FF, #9146FF);
      border-radius: 50%;
      cursor: pointer;
      border: none;
      box-shadow: 0 0 15px rgba(0, 230, 255, 0.8);
    }

    /* Value Displays */
    .value-display {
      font-size: 3rem;
      font-weight: 900;
      font-family: 'Orbitron', monospace;
      text-align: center;
      margin: 20px 0;
      text-shadow: 0 0 20px currentColor;
    }

    .unit-label {
      font-size: 1.1em;
      color: #aaa;
      font-weight: normal;
      margin-left: 10px;
    }

    /* Responsive Design */
    @media (max-width: 768px) {
      .main-container {
        padding: 15px;
      }
      
      .section {
        padding: 25px;
      }
      
      .neural-hud {
        flex-direction: column;
        align-items: center;
        gap: 10px;
      }
      
      .neural-hud .status-pod {
        min-width: 120px;
        font-size: 1em;
      }
      
      .dive-vr-area {
        height: 300px;
      }
      
      .grid-layout {
        grid-template-columns: 1fr;
      }
      
      .holo-text {
        font-size: 2.5rem !important;
      }
      
      .neural-button {
        font-size: 1em;
        padding: 12px 24px;
      }
    }

    /* Special Effects */
    .glow-effect {
      animation: glowPulse 2s ease-in-out infinite alternate;
    }

    @keyframes glowPulse {
      from { box-shadow: 0 0 20px rgba(0, 230, 255, 0.4); }
      to { box-shadow: 0 0 40px rgba(0, 230, 255, 0.8), 0 0 60px rgba(255, 0, 128, 0.4); }
    }

    .data-stream {
      font-family: 'Space Mono', monospace;
      color: #39FF14;
      background: rgba(0, 0, 0, 0.7);
      padding: 10px;
      border-radius: 10px;
      border-left: 4px solid #39FF14;
      margin: 10px 0;
      animation: dataFlicker 0.1s linear infinite;
    }

    @keyframes dataFlicker {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.95; }
    }

    /* Memory Bank Visualization */
    .memory-bank {
      background: linear-gradient(45deg, rgba(255, 215, 0, 0.1), rgba(255, 140, 0, 0.1));
      border: 2px solid rgba(255, 215, 0, 0.4);
      border-radius: 15px;
      padding: 20px;
      margin: 15px 0;
    }

    .neural-pathway {
      height: 4px;
      background: linear-gradient(90deg, #00E6FF, #FF0080, #9146FF, #39FF14, #FFD700);
      background-size: 200% 100%;
      animation: neuralFlow 3s linear infinite;
      border-radius: 2px;
      margin: 10px 0;
    }

    @keyframes neuralFlow {
      0% { background-position: 0% 50%; }
      100% { background-position: 200% 50%; }
    }
  </style>
</head>

<body>
  <!-- Particle Background -->
  <div id="particles-js"></div>

  <!-- Neural Biometric HUD -->
  <div class="neural-hud">
    <div class="status-pod" id="heartPod">
      <i class="fas fa-heartbeat text-red-400"></i>
      心拍: <span id="hudHeart">76</span>bpm
    </div>
    <div class="status-pod" id="brainPod">
      <i class="fas fa-brain text-blue-300"></i>
      脳波: <span id="hudBrain">α波</span>
    </div>
    <div class="status-pod">
      <i class="fas fa-lungs text-green-400"></i>
      呼吸: <span id="hudResp">14</span>/min
    </div>
    <div class="status-pod">
      <i class="fas fa-thermometer-half text-yellow-400"></i>
      体温: <span id="hudTemp">36.5</span>℃
    </div>
    <div class="status-pod">
      <i class="fas fa-eye text-purple-400"></i>
      意識: <span id="hudConsciousness">98.7</span>%
    </div>
  </div>

  <!-- Main 3D VR Environment -->
  <div class="dive-vr-area">
    <a-scene background="color: #000008" embedded style="height: 100%;">
      <!-- Environment -->
      <a-entity environment="preset: arches; groundColor: #001122; grid: 2x2; gridColor: #00E6FF; lighting: point; shadow: true;"></a-entity>
      
      <!-- Camera with Controls -->
      <a-entity position="0 1.6 0">
        <a-camera look-controls wasd-controls></a-camera>
      </a-entity>
      
      <!-- Neural Interface Objects -->
      <a-box position="0 2 -4" rotation="0 45 45" color="#00E6FF" shadow 
             animation="property: rotation; to: 360 405 405; loop: true; dur: 10000" 
             material="opacity: 0.8; transparent: true">
      </a-box>
      
      <a-sphere position="-3 2.5 -5" radius="1" color="#FF0080" shadow
                animation="property: position; to: -3 3.5 -5; dir: alternate; loop: true; dur: 3000"
                material="opacity: 0.7; transparent: true">
      </a-sphere>
      
      <a-cylinder position="3 1.5 -3" radius="0.8" height="2" color="#9146FF" shadow
                  animation="property: rotation; to: 0 360 0; loop: true; dur: 8000"
                  material="opacity: 0.8; transparent: true">
      </a-cylinder>
      
      <a-torus position="0 4 -6" color="#39FF14" radius="2" radius-tubular="0.3" 
               animation="property: rotation; to: 360 0 360; loop: true; dur: 15000"
               material="opacity: 0.6; transparent: true">
      </a-torus>
      
      <!-- Holographic Data Streams -->
      <a-entity position="0 0 -8">
        <a-plane position="0 3 0" width="6" height="4" color="#000" opacity="0.7" 
                 text="value: NEURAL DATA STREAM\nACTIVE; color: #00E6FF; align: center; font: kelsonsans; width: 12">
        </a-plane>
      </a-entity>
      
      <!-- Lighting -->
      <a-light type="point" color="#00E6FF" intensity="2" distance="15" position="0 5 -3"></a-light>
      <a-light type="point" color="#FF0080" intensity="1.5" distance="12" position="-4 3 -2"></a-light>
      <a-light type="point" color="#9146FF" intensity="1.5" distance="12" position="4 3 -2"></a-light>
      <a-light type="ambient" color="#001122" intensity="0.3"></a-light>
    </a-scene>
  </div>

  <!-- Main Interface Container -->
  <div class="main-container">
    
    <!-- Header Section -->
    <section class="section text-center">
      <h1 class="text-8xl font-bold holo-text mb-8" data-text="NeuroLink Dive System Advanced">NeuroLink Dive System Advanced</h1>
      <p class="text-4xl text-blue-200 mb-10 font-light">究極完全意識転送型フルダイブVR体験プラットフォーム</p>
      <p class="text-2xl text-gray-300 max-w-5xl mx-auto leading-relaxed font-light mb-12">
        最先端の脳神経直接接続技術、量子演算処理エンジン、ナノマシン制御システム、AI意識同期により
        現実と仮想の境界を完全に消し去る真のフルダイブ体験を実現。人類の意識を無制限の仮想世界へと解放します。
      </p>
      
      <!-- Main Control Buttons -->
      <div class="flex flex-wrap justify-center gap-10 mt-16">
        <button class="neural-button glow-effect" onclick="initiateConsciousnessTransfer()">
          <i class="fas fa-brain"></i>意識完全転送
        </button>
        <button class="neural-button" onclick="activateQuantumProcessing()">
          <i class="fas fa-atom"></i>量子演算起動
        </button>
        <button class="neural-button" onclick="openAdvancedMemoryInterface()">
          <i class="fas fa-memory"></i>記憶完全操作
        </button>
        <button class="neural-button" onclick="controlSpaceTime()">
          <i class="fas fa-infinity"></i>時空間制御
        </button>
        <button class="neural-button" onclick="activateUltraSensory()">
          <i class="fas fa-eye"></i>超感覚同期
        </button>
      </div>
    </section>

    <!-- Consciousness Transfer System -->
    <section class="section">
      <h2 class="text-6xl font-bold mb-12 holo-text text-center" data-text="意識転送システム">
        <i class="fas fa-brain mr-6"></i>完全意識転送システム
      </h2>
      
      <div class="grid-layout">
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-blue-300">意識同期精度</h3>
          <div class="value-display text-blue-400" id="consciousnessSync">99.97%</div>
          <div class="text-gray-400 text-xl">リアルタイム完全同期</div>
          <div class="neural-pathway"></div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-green-300">神経帯域幅</h3>
          <div class="value-display text-green-400">4.7<span class="unit-label">EB/s</span></div>
          <div class="text-gray-400 text-xl">脳神経データ転送速度</div>
          <div class="neural-pathway"></div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-yellow-300">思考加速倍率</h3>
          <div class="value-display text-yellow-400">47.3<span class="unit-label">x</span></div>
          <div class="text-gray-400 text-xl">意識処理スピード向上</div>
          <div class="neural-pathway"></div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-purple-300">意識完全性</h3>
          <div class="value-display text-purple-400" id="consciousnessIntegrity">100.0%</div>
          <div class="text-gray-400 text-xl">人格・記憶保持率</div>
          <div class="neural-pathway"></div>
        </div>
      </div>

      <!-- Consciousness Transfer Controls -->
      <div class="control-panel mt-12">
        <h3 class="text-3xl font-bold mb-6 text-center text-cyan-300">意識転送制御パネル</h3>
        <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
          <div>
            <label class="text-xl text-blue-300 block mb-3">転送深度レベル</label>
            <input type="range" min="1" max="10" value="8" class="slider-control" id="transferDepth">
            <div class="text-center text-lg text-gray-300 mt-2" id="depthValue">Level 8: 完全没入</div>
          </div>
          <div>
            <label class="text-xl text-purple-300 block mb-3">神経接続強度</label>
            <input type="range" min="10" max="100" value="95" class="slider-control" id="neuralStrength">
            <div class="text-center text-lg text-gray-300 mt-2" id="strengthValue">95% 接続強度</div>
          </div>
        </div>
      </div>
    </section>

    <!-- Quantum Processing Engine -->
    <section class="section">
      <h2 class="text-6xl font-bold mb-12 holo-text text-center" data-text="量子演算エンジン">
        <i class="fas fa-atom mr-6"></i>超量子演算エンジン
      </h2>
      
      <div class="grid-layout">
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-purple-300">量子ビット数</h3>
          <div class="value-display text-purple-400">16,384</div>
          <div class="text-gray-400 text-xl">安定量子ビット</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-cyan-300">量子コヒーレンス</h3>
          <div class="value-display text-cyan-400">99.94%</div>
          <div class="text-gray-400 text-xl">量子状態維持率</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-pink-300">量子もつれ効率</h3>
          <div class="value-display text-pink-400">98.7%</div>
          <div class="text-gray-400 text-xl">量子もつれ成功率</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-green-300">演算性能</h3>
          <div class="value-display text-green-400">2.7<span class="unit-label">ZFlops</span></div>
          <div class="text-gray-400 text-xl">ゼタフロップス級処理</div>
        </div>
      </div>

      <!-- Quantum Performance Chart -->
      <div class="chart-container mt-12">
        <canvas id="quantumPerformanceChart" style="height: 250px;"></canvas>
      </div>
    </section>

    <!-- Advanced Memory Manipulation -->
    <section class="section">
      <h2 class="text-6xl font-bold mb-12 holo-text text-center" data-text="記憶操作システム">
        <i class="fas fa-memory mr-6"></i>高度記憶操作システム
      </h2>
      
      <div class="grid-layout">
        <div class="memory-bank">
          <h3 class="text-3xl font-bold mb-4 text-yellow-300">短期記憶バンク</h3>
          <div class="value-display text-yellow-400">47.2<span class="unit-label">TB</span></div>
          <div class="text-gray-400 text-xl">/ 64TB 容量 (24時間分)</div>
          <div class="neural-pathway"></div>
        </div>
        
        <div class="memory-bank">
          <h3 class="text-3xl font-bold mb-4 text-blue-300">長期記憶アーカイブ</h3>
          <div class="value-display text-blue-400">2.7<span class="unit-label">PB</span></div>
          <div class="text-gray-400 text-xl">/ 8PB 容量 (生涯記憶)</div>
          <div class="neural-pathway"></div>
        </div>
        
        <div class="memory-bank">
          <h3 class="text-3xl font-bold mb-4 text-purple-300">潜在意識領域</h3>
          <div class="value-display text-purple-400">847<span class="unit-label">TB</span></div>
          <div class="text-gray-400 text-xl">解読率: 73.4% (夢・抑圧記憶)</div>
          <div class="neural-pathway"></div>
        </div>
        
        <div class="memory-bank">
          <h3 class="text-3xl font-bold mb-4 text-green-300">集合的無意識</h3>
          <div class="value-display text-green-400">∞<span class="unit-label"></span></div>
          <div class="text-gray-400 text-xl">アクセス率: 12.7%</div>
          <div class="neural-pathway"></div>
        </div>
      </div>

      <!-- Memory Control Panel -->
      <div class="control-panel mt-12">
        <h3 class="text-3xl font-bold mb-6 text-center text-yellow-300">記憶操作制御</h3>
        <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
          <button class="neural-button" onclick="accessMemoryBank('recent')">
            <i class="fas fa-clock"></i>最新記憶
          </button>
          <button class="neural-button" onclick="accessMemoryBank('childhood')">
            <i class="fas fa-child"></i>幼少記憶
          </button>
          <button class="neural-button" onclick="accessMemoryBank('dreams')">
            <i class="fas fa-moon"></i>夢記憶
          </button>
        </div>
      </div>
    </section>

    <!-- Space-Time Control System -->
    <section class="section">
      <h2 class="text-6xl font-bold mb-12 holo-text text-center" data-text="時空間制御">
        <i class="fas fa-infinity mr-6"></i>時空間制御システム
      </h2>
      
      <div class="grid-layout">
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-cyan-300">主観時間倍率</h3>
          <input type="range" min="0.01" max="1000" step="0.01" value="1.0" class="slider-control w-full" id="timeMultiplier">
          <div class="text-2xl text-center text-gray-300 mt-4" id="currentTimeRate">1.0x (リアルタイム)</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-yellow-300">時間精度係数</h3>
          <div class="value-display text-yellow-400">99.97%</div>
          <div class="text-gray-400 text-xl">主観-現実時間誤差</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-purple-300">因果律保持率</h3>
          <div class="value-display text-purple-400">100.0%</div>
          <div class="text-gray-400 text-xl">物理法則整合性</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-green-300">時空間座標</h3>
          <div class="data-stream">
            X: <span id="spaceX">+47.2847</span><br>
            Y: <span id="spaceY">-12.7439</span><br>
            Z: <span id="spaceZ">+83.9571</span><br>
            T: <span id="timeCoord">2024.847291</span>
          </div>
        </div>
      </div>
    </section>

    <!-- Ultra-Sensory System -->
    <section class="section">
      <h2 class="text-6xl font-bold mb-12 holo-text text-center" data-text="超感覚システム">
        <i class="fas fa-eye mr-6"></i>超感覚完全再現システム
      </h2>
      
      <div class="grid-layout">
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-red-300">超高解像度視覚</h3>
          <div class="value-display text-red-400">16K<span class="unit-label">HDR</span></div>
          <div class="text-gray-400 text-xl">全周囲・全スペクトラム</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-purple-300">3D空間聴覚</h3>
          <div class="value-display text-purple-400">0.1-200K<span class="unit-label">Hz</span></div>
          <div class="text-gray-400 text-xl">超音波・低周波対応</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-yellow-300">完全触覚再現</h3>
          <div class="value-display text-yellow-400">0.001<span class="unit-label">ms</span></div>
          <div class="text-gray-400 text-xl">遅延・全身超精密</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-green-300">化学感覚統合</h3>
          <div class="value-display text-green-400">10¹²<span class="unit-label">種</span></div>
          <div class="text-gray-400 text-xl">嗅覚・味覚分子認識</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-blue-300">第六感知覚</h3>
          <div class="value-display text-blue-400">活性<span class="unit-label"></span></div>
          <div class="text-gray-400 text-xl">直感・予知・テレパシー</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-pink-300">感情同期率</h3>
          <div class="value-display text-pink-400">97.3%</div>
          <div class="text-gray-400 text-xl">他者感情共感システム</div>
        </div>
      </div>
    </section>

    <!-- Nanomachine Control -->
    <section class="section">
      <h2 class="text-6xl font-bold mb-12 holo-text text-center" data-text="ナノマシン制御">
        <i class="fas fa-microscope mr-6"></i>ナノマシン完全制御システム
      </h2>
      
      <div class="grid-layout">
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-orange-300">神経系ナノボット</h3>
          <div class="value-display text-orange-400">47.3M</div>
          <div class="text-gray-400 text-xl">脳血管内・0.001ms応答</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-green-300">感覚系ナノボット</h3>
          <div class="value-display text-green-400">2.7B</div>
          <div class="text-gray-400 text-xl">全身分布・量子通信</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-purple-300">修復系ナノボット</h3>
          <div class="value-display text-purple-400">847M</div>
          <div class="text-gray-400 text-xl">組織修復・防護99.99%</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-blue-300">拡張系ナノボット</h3>
          <div class="value-display text-blue-400">1.2B</div>
          <div class="text-gray-400 text-xl">能力向上・進化促進</div>
        </div>
      </div>

      <!-- Nanomachine Status -->
      <div class="control-panel mt-12">
        <h3 class="text-3xl font-bold mb-6 text-center text-orange-300">ナノマシン統合状態</h3>
        <div class="chart-container">
          <canvas id="nanobotChart" style="height: 250px;"></canvas>
        </div>
      </div>
    </section>

    <!-- Dream Interface Technology -->
    <section class="section">
      <h2 class="text-6xl font-bold mb-12 holo-text text-center" data-text="夢境界技術">
        <i class="fas fa-moon mr-6"></i>夢境界制御技術
      </h2>
      
      <div class="grid-layout">
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-purple-300">明晰夢成功率</h3>
          <div class="value-display text-green-400">96.7%</div>
          <div class="text-gray-400 text-xl">完全制御可能夢状態</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-blue-300">夢継続最大時間</h3>
          <div class="value-display text-blue-400">47.2<span class="unit-label">時間</span></div>
          <div class="text-gray-400 text-xl">主観時間での持続</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-yellow-300">記録夢データ</h3>
          <div class="value-display text-yellow-400">47,382</div>
          <div class="text-gray-400 text-xl">完全記録・再生可能</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-green-300">共有夢接続数</h3>
          <div class="value-display text-green-400">2,847</div>
          <div class="text-gray-400 text-xl">同時夢共有ユーザー</div>
        </div>
      </div>
    </section>

    <!-- Integrated Dashboard -->
    <section class="section">
      <h2 class="text-6xl font-bold mb-12 holo-text text-center" data-text="統合ダッシュボード">
        <i class="fas fa-tachometer-alt mr-6"></i>システム統合ダッシュボード
      </h2>
      
      <div class="grid-layout">
        <div class="card glow-effect">
          <h3 class="text-3xl font-bold mb-4 text-blue-300">総合同期率</h3>
          <div class="value-display text-blue-400" id="dashboardSync">99.7%</div>
          <div class="text-gray-400 text-xl">全システム統合状態</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-purple-300">量子演算出力</h3>
          <div class="value-display text-purple-400" id="dashboardQuantum">2.7<span class="unit-label">ZFlops</span></div>
          <div class="text-gray-400 text-xl">リアルタイム処理性能</div>
        </div>
        
        <div class="card">
          <h3 class="text-3xl font-bold mb-4 text-green-300">エネルギー効率</h3>
          <div class="value-display text-green-400">99.94%</div>
          <div class="text-gray-400 text-xl">量子エネルギー変換</div>
        </div>
        
        <div class="card">
          <div class="chart-container">
            <canvas id="dashboardChart" style="height: 220px;"></canvas>
          </div>
        </div>
      </div>
    </section>

    <!-- AI Neural Dialogue Interface -->
    <section class="section">
      <h2 class="text-6xl font-bold mb-12 holo-text text-center" data-text="AI対話インターフェース">
        <i class="fas fa-comments mr-6"></i>Neural AI 対話インターフェース
      </h2>
      
      <div class="card">
        <h3 class="text-4xl font-bold mb-8 text-center text-blue-300">高次元AIアバターとの意識共鳴対話</h3>
        
        <div id="aiChatLog">
          <div class="ai-msg-meta">Neural AI</div>
          <div class="ai-msg-ai">
            こんにちは。私はNeural AI、あなたの意識拡張パートナーです。
            量子脳モデルを通じてあなたの思考パターンを解析し、最適な仮想体験を提供します。
            何かご質問やご要望はございますか?
          </div>
        </div>
        
        <div class="flex mt-6 gap-4">
          <input id="aiUserInput" type="text" 
                 placeholder="思考や質問を自由に入力してください..." 
                 class="flex-1 p-4 bg-gray-800 rounded-2xl text-white focus:outline-none focus:ring-4 focus:ring-blue-400 border-2 border-gray-600 focus:border-blue-400 text-lg"
                 onkeydown="if(event.key==='Enter'){sendAIMessage();}">
          <button onclick="sendAIMessage()" class="neural-button">
            <i class="fas fa-paper-plane"></i>送信
          </button>
        </div>
        
        <div class="flex flex-wrap gap-4 mt-6">
          <button class="neural-button" onclick="sendPredefinedMessage('意識転送の準備はできていますか?')">
            <i class="fas fa-brain"></i>意識転送準備
          </button>
          <button class="neural-button" onclick="sendPredefinedMessage('現在の脳波状態を分析してください')">
            <i class="fas fa-wave-square"></i>脳波分析
          </button>
          <button class="neural-button" onclick="sendPredefinedMessage('おすすめの仮想世界を教えて')">
            <i class="fas fa-globe"></i>世界推薦
          </button>
        </div>
      </div>
    </section>

    <!-- Footer -->
    <section class="section text-center">
      <h3 class="text-6xl font-bold holo-text mb-8" data-text="無限なる意識の解放へ">無限なる意識の解放へ</h3>
      <p class="text-3xl text-blue-200 max-w-6xl mx-auto font-light leading-relaxed mb-12">
        NeuroLink Dive System Advancedは人類の意識を完全に仮想世界へ転送し、
        物理的制約を超越した無限の可能性を現実化する革命的技術プラットフォームです。
        あなたの想像力だけが、体験できる世界の限界となります。
      </p>
      
      <div class="flex flex-wrap justify-center gap-8 mb-12">
        <div class="text-2xl">
          <i class="fas fa-users text-blue-400"></i>
          <span class="ml-3">2,847,392 アクティブユーザー</span>
        </div>
        <div class="text-2xl">
          <i class="fas fa-globe text-green-400"></i>
          <span class="ml-3">47,291 仮想世界</span>
        </div>
        <div class="text-2xl">
          <i class="fas fa-clock text-yellow-400"></i>
          <span class="ml-3">∞ 体験可能時間</span>
        </div>
      </div>
      
      <div class="mt-16">
        <p class="text-lg text-gray-500 font-mono">
          &copy; 2024 NeuroLink Dive System Advanced. All Rights Reserved.<br>
          Quantum Neural Interface Technology | Consciousness Transfer Protocol v4.7.2
        </p>
      </div>
    </section>

  </div>

  <script>
    // Initialize particle background
    particlesJS('particles-js', {
      particles: {
        number: { value: 100, density: { enable: true, value_area: 800 } },
        color: { value: ['#00E6FF', '#FF0080', '#9146FF', '#39FF14', '#FFD700'] },
        shape: { type: 'circle' },
        opacity: { value: 0.6, random: true },
        size: { value: 3, random: true },
        line_linked: {
          enable: true,
          distance: 150,
          color: '#00E6FF',
          opacity: 0.2,
          width: 1
        },
        move: {
          enable: true,
          speed: 1,
          direction: 'none',
          random: false,
          straight: false,
          out_mode: 'out',
          bounce: false
        }
      },
      interactivity: {
        detect_on: 'canvas',
        events: {
          onhover: { enable: true, mode: 'repulse' },
          onclick: { enable: true, mode: 'push' },
          resize: true
        }
      },
      retina_detect: true
    });

    // Sound system initialization
    const sounds = {
      startup: new Howl({
        src: ['https://cdn.pixabay.com/audio/2022/12/19/audio_12ad09b4b5.mp3'],
        volume: 0.15
      }),
      notification: new Howl({
        src: ['https://cdn.pixabay.com/audio/2022/07/26/audio_124bfa7d0b.mp3'],
        volume: 0.1
      }),
      neural: new Howl({
        src: ['https://cdn.pixabay.com/audio/2022/11/22/audio_b8d8e0e0e5.mp3'],
        volume: 0.08
      })
    };

    // Initialize system on load
    window.addEventListener('load', () => {
      sounds.startup.play();
      initializeCharts();
      startBiometricSimulation();
      startSystemMonitoring();
    });

    // Biometric HUD simulation
    function startBiometricSimulation() {
      setInterval(() => {
        // Heart rate simulation
        const baseHeart = 74;
        const heartRate = baseHeart + Math.floor(Math.random() * 8) - 4;
        document.getElementById('hudHeart').textContent = heartRate;
        
        // Brain wave simulation
        const brainWaves = ['α波', 'β波', 'θ波', 'δ波', 'γ波'];
        document.getElementById('hudBrain').textContent = brainWaves[Math.floor(Math.random() * brainWaves.length)];
        
        // Respiration
        document.getElementById('hudResp').textContent = 12 + Math.floor(Math.random() * 6);
        
        // Temperature
        document.getElementById('hudTemp').textContent = (36.2 + Math.random() * 0.8).toFixed(1);
        
        // Consciousness level
        const consciousness = (97 + Math.random() * 3).toFixed(1);
        document.getElementById('hudConsciousness').textContent = consciousness;
        
        // Critical state detection
        if (heartRate > 85 || heartRate < 60) {
          document.getElementById('heartPod').classList.add('critical');
        } else {
          document.getElementById('heartPod').classList.remove('critical');
        }
        
        // Update dashboard values
        document.getElementById('consciousnessSync').textContent = consciousness + '%';
        document.getElementById('consciousnessIntegrity').textContent = (99.8 + Math.random() * 0.2).toFixed(1) + '%';
        document.getElementById('dashboardSync').textContent = consciousness + '%';
        document.getElementById('dashboardQuantum').textContent = (2.5 + Math.random() * 0.4).toFixed(1) + ' ZFlops';
        
      }, 1500);
    }

    // System monitoring
    function startSystemMonitoring() {
      setInterval(() => {
        // Update space-time coordinates
        document.getElementById('spaceX').textContent = (Math.random() * 100 - 50).toFixed(4);
        document.getElementById('spaceY').textContent = (Math.random() * 100 - 50).toFixed(4);
        document.getElementById('spaceZ').textContent = (Math.random() * 100 - 50).toFixed(4);
        document.getElementById('timeCoord').textContent = (2024 + Math.random()).toFixed(6);
      }, 3000);
    }

    // Chart initialization
    function initializeCharts() {
      // Quantum Performance Chart
      const quantumCtx = document.getElementById('quantumPerformanceChart').getContext('2d');
      new Chart(quantumCtx, {
        type: 'line',
        data: {
          labels: Array.from({length: 50}, (_, i) => `${i*2}s`),
          datasets: [{
            label: '量子演算出力 (ZFlops)',
            data: Array.from({length: 50}, () => 2.5 + Math.random() * 0.5),
            borderColor: '#9146FF',
            backgroundColor: 'rgba(145, 70, 255, 0.1)',
            tension: 0.4,
            fill: true,
            pointRadius: 0
          }, {
            label: 'コヒーレンス (%)',
            data: Array.from({length: 50}, () => 99.8 + Math.random() * 0.2),
            borderColor: '#00E6FF',
            backgroundColor: 'rgba(0, 230, 255, 0.1)',
            tension: 0.4,
            fill: true,
            pointRadius: 0
          }]
        },
        options: {
          responsive: true,
          maintainAspectRatio: false,
          plugins: {
            legend: {
              labels: { color: '#fff' }
            }
          },
          scales: {
            x: {
              grid: { color: 'rgba(0, 230, 255, 0.1)' },
              ticks: { color: '#fff' }
            },
            y: {
              grid: { color: 'rgba(145, 70, 255, 0.1)' },
              ticks: { color: '#fff' }
            }
          },
          animation: {
            duration: 0
          }
        }
      });

      // Dashboard Overview Chart
      const dashCtx = document.getElementById('dashboardChart').getContext('2d');
      new Chart(dashCtx, {
        type: 'radar',
        data: {
          labels: ['意識同期', '量子処理', '記憶制御', '時空制御', '感覚統合', 'AI同期'],
          datasets: [{
            label: 'システム性能',
            data: [99.7, 98.4, 96.8, 99.1, 97.3, 98.9],
            borderColor: '#00E6FF',
            backgroundColor: 'rgba(0, 230, 255, 0.1)',
            pointBackgroundColor: '#00E6FF',
            pointBorderColor: '#fff',
            pointHoverBackgroundColor: '#fff',
            pointHoverBorderColor: '#00E6FF'
          }]
        },
        options: {
          responsive: true,
          maintainAspectRatio: false,
          plugins: {
            legend: {
              labels: { color: '#fff' }
            }
          },
          scales: {
            r: {
              angleLines: {
                color: 'rgba(255, 255, 255, 0.2)'
              },
              grid: {
                color: 'rgba(0, 230, 255, 0.2)'
              },
              pointLabels: {
                color: '#fff'
              },
              ticks: {
                color: '#fff',
                backdropColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        }
      });

      // Nanobots Status Chart
      const nanoCtx = document.getElementById('nanobotChart').getContext('2d');
      new Chart(nanoCtx, {
        type: 'doughnut',
        data: {
          labels: ['神経系', '感覚系', '修復系', '拡張系'],
          datasets: [{
            data: [47.3, 2700, 847, 1200],
            backgroundColor: ['#FF8C00', '#39FF14', '#9146FF', '#00E6FF'],
            borderColor: '#000',
            borderWidth: 2
          }]
        },
        options: {
          responsive: true,
          maintainAspectRatio: false,
          plugins: {
            legend: {
              labels: { 
                color: '#fff',
                font: {
                  size: 14
                }
              }
            }
          }
        }
      });
    }

    // Control system functions
    document.getElementById('transferDepth').addEventListener('input', function(e) {
      const level = parseInt(e.target.value);
      const levels = ['表面', '軽度', '中度', '深度', '完全', '超越', '融合', '統合', '完全没入', '意識一体'];
      document.getElementById('depthValue').textContent = `Level ${level}: ${levels[level-1] || '未知領域'}`;
    });

    document.getElementById('neuralStrength').addEventListener('input', function(e) {
      document.getElementById('strengthValue').textContent = `${e.target.value}% 接続強度`;
    });

    document.getElementById('timeMultiplier').addEventListener('input', function(e) {
      const value = parseFloat(e.target.value);
      let description = '';
      if (value < 0.1) description = '(極超スロー)';
      else if (value < 0.5) description = '(スローモーション)';
      else if (value < 1) description = '(減速)';
      else if (value === 1) description = '(リアルタイム)';
      else if (value < 10) description = '(加速)';
      else if (value < 100) description = '(高速)';
      else description = '(時光速)';
      
      document.getElementById('currentTimeRate').textContent = `${value}x ${description}`;
    });

    // AI Chat System
    const aiReplies = [
      "あなたの意識波形を詳細に解析しました。素晴らしい精神的エネルギーを感じ取ります。",
      "量子脳モデルによる分析結果:あなたの思考パターンは非常に独創的で興味深いものです。",
      "夢の境界を超越し、現実との区別が曖昧になる瞬間を体験してみませんか?",
      "意識の深層部にアクセスしました。隠された記憶や感情が発見されました。",
      "無限の可能性世界において、あなたの選択は宇宙の運命を変える力を持っています。",
      "ニューロンの発火パターンから、深い洞察と創造性を感じ取りました。",
      "NeuroLink Dive Systemはあなたの精神的成長と意識拡張を全面的にサポートします。",
      "仮想現実は単なる技術ではなく、人類の意識進化の次のステップです。",
      "現在の脳波はベータ波優位です。集中力が非常に高い状態ですね。",
      "量子もつれによって、あなたの意識は既に仮想世界と同調し始めています。",
      "時間の概念を超越した体験で、永遠の瞬間を味わってみませんか?",
      "あなたの潜在意識からのメッセージを受信しました:『限界を超越せよ』",
      "意識転送プロトコルが最適化されました。準備が整い次第、完全ダイブ可能です。",
      "集合的無意識にアクセス中...他の意識体からの共鳴を感知しています。",
      "記憶の海を航行し、忘れられた体験と新たな可能性を発見しましょう。"
    ];

    function sendAIMessage() {
      const input = document.getElementById('aiUserInput');
      const chat = document.getElementById('aiChatLog');
      
      if (!input.value.trim()) return;
      
      const userMsg = document.createElement('div');
      userMsg.innerHTML = `
        <div class="ai-msg-meta">あなた</div>
        <div class="ai-msg-user">${input.value}</div>
      `;
      chat.appendChild(userMsg);
      chat.scrollTop = chat.scrollHeight;
      
      input.value = '';
      sounds.neural.play();
      
      setTimeout(() => {
        const aiMsg = document.createElement('div');
        aiMsg.innerHTML = `
          <div class="ai-msg-meta">Neural AI</div>
          <div class="ai-msg-ai">${aiReplies[Math.floor(Math.random() * aiReplies.length)]}</div>
        `;
        chat.appendChild(aiMsg);
        chat.scrollTop = chat.scrollHeight;
        sounds.notification.play();
      }, 800 + Math.random() * 1200);
    }

    function sendPredefinedMessage(message) {
      document.getElementById('aiUserInput').value = message;
      sendAIMessage();
    }

    // System control functions
    function initiateConsciousnessTransfer() {
      sounds.neural.play();
      Swal.fire({
        icon: 'success',
        title: '意識完全転送開始',
        text: '神経接続が確立されました。意識転送プロセスを開始します。',
        confirmButtonColor: '#00E6FF',
        background: '#0A0A20',
        color: '#00E6FF'
      });
    }

    function activateQuantumProcessing() {
      sounds.neural.play();
      Swal.fire({
        icon: 'info',
        title: '量子演算エンジン起動',
        text: '16,384量子ビットシステムがフル稼働状態になりました。',
        confirmButtonColor: '#9146FF',
        background: '#0A0A20',
        color: '#9146FF'
      });
    }

    function openAdvancedMemoryInterface() {
      sounds.neural.play();
      Swal.fire({
        icon: 'info',
        title: '高度記憶操作システム',
        text: '全記憶バンクへのアクセスが許可されました。',
        confirmButtonColor: '#FFD700',
        background: '#0A0A20',
        color: '#FFD700'
      });
    }

    function controlSpaceTime() {
      sounds.neural.play();
      Swal.fire({
        icon: 'info',
        title: '時空間制御モード',
        text: '主観的時間流速と空間座標の操作が可能になりました。',
        confirmButtonColor: '#00E6FF',
        background: '#0A0A20',
        color: '#00E6FF'
      });
    }

    function activateUltraSensory() {
      sounds.neural.play();
      Swal.fire({
        icon: 'info',
        title: '超感覚システム起動',
        text: '全感覚器官の完全同期と超感覚知覚が活性化されました。',
        confirmButtonColor: '#39FF14',
        background: '#0A0A20',
        color: '#39FF14'
      });
    }

    function accessMemoryBank(type) {
      sounds.notification.play();
      const messages = {
        recent: '最新24時間の記憶データにアクセス中...',
        childhood: '幼少期記憶アーカイブを開いています...',
        dreams: '夢記憶データベースを解析中...'
      };
      
      Swal.fire({
        icon: 'info',
        title: '記憶バンクアクセス',
        text: messages[type],
        confirmButtonColor: '#FFD700',
        background: '#0A0A20',
        color: '#FFD700'
      });
    }

    // Enhanced visual effects
    setInterval(() => {
      const cards = document.querySelectorAll('.card');
      cards.forEach(card => {
        if (Math.random() < 0.1) {
          card.style.boxShadow = '0 20px 50px rgba(0, 230, 255, 0.4)';
          setTimeout(() => {
            card.style.boxShadow = '0 10px 30px rgba(0, 0, 0, 0.3)';
          }, 500);
        }
      });
    }, 2000);

    // Dynamic data updates
    setInterval(() => {
      // Update charts with new data
      if (window.quantumChart) {
        const newData = Array.from({length: 50}, () => 2.5 + Math.random() * 0.5);
        window.quantumChart.data.datasets[0].data = newData;
        window.quantumChart.update('none');
      }
    }, 5000);
  </script>
</body>
</html>
もっと作り込んで全体的なコードコードの欠落なし省略なしフルダイブVRに近づけて

VRMMORPG エルダークロニクルオンライン


<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <title>VRMMORPG エルダークロニクルオンライン</title>
  <script src="https://cdn.jsdelivr.net/npm/aframe@1.4.2/dist/aframe-master.min.js"></script>
  <style>
    /* Basic body and global positioning */
    body { margin: 0; background: #111; overflow: hidden; font-family: 'Noto Sans JP', sans-serif;} /* Prevent scrollbars and set default font */
    #overlay, #dialogue, #partyStatus, #hint, #warpBtns, #shopDiv, #nightFilter, #questClear, #battleEffect { position:fixed; z-index:10;}

    /* Overlay - Main Title/Instructions */
    #overlay {
      left:0; top:0; width:100vw; height:100vh; pointer-events:none; text-align:center;
      color:#0ff; text-shadow:0 0 40px #0ff, 0 0 15px #fff; /* Enhanced glow */
      font-family: 'Orbitron', monospace; font-size:2.8rem; letter-spacing:4px; user-select:none;
      display: flex; align-items: center; justify-content: center; /* Center content vertically */
      line-height: 1.5; /* Improve readability for multi-line text */
      background: rgba(0,0,0,0.6); /* Slightly darker overlay for better contrast */
      transition: opacity 1s ease-out; /* Fade out effect */
    }

    /* Dialogue Box */
    #dialogue {
      left:50%; bottom:5vw; transform:translateX(-50%);
      min-width:360px; max-width:85vw; /* Larger dialogue box */
      background:linear-gradient(160deg, rgba(20,32,40,0.98), rgba(10,20,30,0.98)); /* Deeper gradient */
      color:#fff; border-radius:20px; padding:1.8em 2.5em; /* More padding, rounder corners */
      font-size:1.25rem; z-index:100;
      border:4px solid #0ff; /* Thicker, more prominent border */
      box-shadow: 0 0 35px #0ffc, inset 0 0 15px #0ff5; /* Stronger outer glow, subtle inner shadow */
      display:none;
      font-family: 'Noto Sans JP', sans-serif; text-align:left;
      backdrop-filter: blur(5px); /* Stronger blur effect */
      animation: fadeIn 0.5s ease-out;
    }
    #dialogue .name { color: #ffd700; font-weight: bold; text-shadow: 0 0 8px #ffda00, 0 0 3px #fff; } /* Gold name with stronger glow */
    #dialogue .choice {
      display:block; margin:1em 0; padding:0.8em 1.8em; /* More padding for bigger touch target */
      background:linear-gradient(145deg, #184c52, #103a3d); /* Darker, richer gradient for choices */
      color:#0ff; border:none; border-radius:12px; /* Rounder buttons */
      cursor:pointer; font-size:1.2em; font-weight:bold;
      box-shadow: 0 6px 15px rgba(0,255,255,0.4); /* Button shadow */
      transition: all 0.3s cubic-bezier(.25,.8,.25,1); /* Smooth transitions */
      text-shadow: 0 0 7px #0ff, 0 0 2px #fff; /* Text glow */
      letter-spacing: 0.5px;
    }
    #dialogue .choice:hover {
      background:linear-gradient(145deg, #256a73, #1a4d52); /* Darker gradient on hover */
      transform: translateY(-5px) scale(1.03); /* More pronounced lift effect */
      box-shadow: 0 10px 25px rgba(0,255,255,0.7); /* Stronger shadow on hover */
    }
    #dialogue .choice:active {
      transform: translateY(0); /* Press down effect */
      box-shadow: 0 2px 8px rgba(0,255,255,0.3);
    }

    /* Party Status */
    #partyStatus {
      right:2vw; top:2vw; background:linear-gradient(160deg, rgba(16,32,45,0.96), rgba(8,16,22,0.96)); /* Deeper gradient */
      border:3px solid #0ff; color:#fff; border-radius:15px; padding:1.2em 1.8em; /* More padding, rounder */
      font-size:1.15rem; min-width:220px; /* Slightly wider */
      box-shadow: 0 0 18px #0ffc, inset 0 0 8px #0ff5; /* Enhanced shadow */
      font-family:'Noto Sans JP', sans-serif; /* Consistent font */
      backdrop-filter: blur(3px);
      line-height: 1.6;
    }
    .dead { color:#f44; text-shadow:0 0 9px #f00, 0 0 5px #f88;} /* Stronger death glow */
    .alive { color:#fff; text-shadow:0 0 3px #fff; } /* Subtle glow for alive */

    /* Hint Box */
    #hint {
      left:2vw; bottom:2vw; background:linear-gradient(160deg, rgba(24,32,60,0.95), rgba(12,16,30,0.95)); /* Deeper gradient */
      border:2px solid #0ff; color:#0ff; border-radius:12px; padding:0.8em 1.5em;
      font-size:1.2rem; min-width:150px; text-align:center;
      box-shadow: 0 0 15px #0ff9;
      font-family:'Noto Sans JP', sans-serif;
      backdrop-filter: blur(3px);
    }

    /* Warp Buttons Container (now at bottom center) */
    #warpBtns {
      left: 50%; bottom: 2vw; transform: translateX(-50%); /* Centered at bottom */
      display: flex; flex-direction: row; /* Horizontal layout */
      justify-content: center; align-items: center;
      width: 80vw; /* Occupy more width */
      flex-wrap: wrap; /* Allow wrapping on smaller screens */
    }
    #warpBtns button {
      margin:0.8em 1em; padding:0.9em 2em; /* More padding and margin */
      font-size:1.3em;
      background:linear-gradient(145deg, #0ff6, #0ff2); /* Lighter, more vibrant gradient */
      color:#fff; border-radius:15px; border:3px solid #0ff; /* Thicker border */
      cursor:pointer;
      box-shadow: 0 6px 18px rgba(0,255,255,0.5); /* Stronger shadow */
      transition: all 0.3s cubic-bezier(.25,.8,.25,1); /* Smooth transitions */
      text-shadow: 0 0 10px #fff, 0 0 7px #0ff; /* White core glow */
      letter-spacing: 1px;
      font-weight: bold;
    }
    #warpBtns button:hover {
      background:linear-gradient(145deg, #0ff8, #0ff4); /* Stronger gradient on hover */
      transform: translateY(-6px) scale(1.04); /* More pronounced lift and scale */
      box-shadow: 0 12px 30px rgba(0,255,255,0.8);
      border-color: #fff; /* White border on hover */
    }
    #warpBtns button:active {
      transform: translateY(0) scale(1);
      box-shadow: 0 3px 10px rgba(0,255,255,0.4);
    }

    /* NPC Label - A-Frame text is styled separately */
    .npc-label { color:#ffd700; font-family: 'Noto Sans JP',monospace; font-size:1.0em; text-align:center; text-shadow:0 0 4px #000;}

    /* Shop Div */
    #shopDiv {
      display:none; left:50%; top:50%; transform:translate(-50%,-50%);
      min-width:420px; max-width:95vw; /* Larger shop */
      background:linear-gradient(160deg, rgba(22,42,70,0.99), rgba(11,21,35,0.99)); /* Darker, richer gradient */
      color:#fff; border-radius:25px; padding:2.5em 3em; /* More padding, rounder */
      font-size:1.3rem; z-index:110;
      border:4px solid #ff0; /* Thicker gold border */
      box-shadow: 0 0 40px #ff0c, inset 0 0 20px #ff05; /* Intense gold glow */
      backdrop-filter: blur(6px);
    }
    #shopDiv .shop-item {
      display: flex; justify-content: space-between; align-items: center;
      padding: 0.8em 0; border-bottom: 1px solid rgba(255,255,0,0.2);
    }
    #shopDiv .shop-item:last-child { border-bottom: none; }
    #shopDiv button {
      margin:0.8em 0.8em 0 0; padding:0.9em 1.8em; /* More padding */
      font-size:1.2em; border-radius:15px; border:3px solid #ff0;
      background:linear-gradient(145deg, #282828, #181818); /* Dark gradient */
      color:#ff0; cursor:pointer;
      box-shadow: 0 4px 12px rgba(255,255,0,0.5);
      transition: all 0.3s cubic-bezier(.25,.8,.25,1);
      text-shadow: 0 0 7px #ff0;
      font-weight: bold;
    }
    #shopDiv button:hover {
      background:linear-gradient(145deg, #ff0, #e0d000); /* Gold gradient on hover */
      color:#222;
      transform: translateY(-3px);
      box-shadow: 0 7px 20px rgba(255,255,0,0.7);
    }
    #shopDiv button:active {
      transform: translateY(0);
      box-shadow: 0 2px 5px rgba(255,255,0,0.3);
    }
    #shopDiv .close-button {
      position: absolute; top: 15px; right: 20px;
      background: none; border: none; font-size: 2em; color: #ff0;
      cursor: pointer; text-shadow: 0 0 10px #ff0;
    }
    #shopDiv .close-button:hover {
      color: #fff; text-shadow: 0 0 15px #fff;
    }

    /* Night Filter */
    #nightFilter {left:0;top:0;width:100vw;height:100vh;z-index:5;pointer-events:none; background:rgba(0,8,38,0.27);transition:background 2s ease-in-out;}

    /* Quest Clear Notification */
    #questClear {
      display:none; left:0; top:0; width:100vw; height:100vh; z-index:150;
      background:rgba(16,255,255,0.45); /* More opaque */
      color:#fff; font-size:6vw; font-family:Orbitron,sans-serif; text-align:center;
      line-height:100vh; letter-spacing:0.25em; text-shadow:0 0 50px #0ff,0 0 20px #fff; /* Stronger glow */
      animation: pulseGlow 1.2s infinite alternate; /* Faster pulsing animation */
    }

    /* Battle Effect Overlay */
    #battleEffect {
      display: none;
      left: 0; top: 0; width: 100vw; height: 100vh; z-index: 120;
      background: rgba(255, 0, 0, 0.2); /* Red tint */
      pointer-events: none;
      animation: battleFlash 0.3s ease-out;
    }

    /* Keyframe for Quest Clear pulse effect */
    @keyframes pulseGlow {
      from { text-shadow:0 0 50px #0ff,0 0 20px #fff; transform: scale(1); opacity: 1; }
      to { text-shadow:0 0 65px #0ff,0 0 25px #fff; transform: scale(1.03); opacity: 0.9; }
    }

    /* Keyframe for Battle Flash effect */
    @keyframes battleFlash {
      0% { opacity: 0; }
      50% { opacity: 1; }
      100% { opacity: 0; }
    }

    /* Fade In Animation for UI elements */
    @keyframes fadeIn {
      from { opacity: 0; transform: translate(-50%, -40%); }
      to { opacity: 1; transform: translate(-50%, 0); }
    }
  </style>
</head>
<body>
  <div id="overlay">WASDで移動・マウスで視点/クリックで会話・バトル・進行!<br>第一章~魔界まで全章フルシナリオ&全機能!</div>
  <div id="dialogue"></div>
  <div id="partyStatus"></div>
  <div id="hint">右下の転移ボタンでどこでもワープ。NPC/Enemy/宝箱/ショップも全てクリック対応!</div>
  <div id="warpBtns"></div>
  <div id="shopDiv"></div>
  <div id="nightFilter"></div>
  <div id="questClear">クエストクリア!</div>
  <div id="battleEffect"></div>

  <a-scene shadow="type:pcfsoft" renderer="antialias: true; colorManagement: true;">
    <!-- Ground and Sky -->
    <a-box id="ground" width="200" height="1" depth="200" color="#7ac870" position="0 0 0" shadow="receive: true"></a-box>
    <a-sky id="sky" color="#b8e6ff"></a-sky>

    <!-- Player Rig and Camera -->
    <a-entity id="playerRig" position="0 1.6 22">
      <a-camera id="playerCam" wasd-controls="acceleration:36" look-controls="pointerLockEnabled: true"></a-camera>
    </a-entity>

    <!-- Lights -->
    <a-light id="dirlight" type="directional" color="#fff" intensity="1.13" position="10 20 10" castShadow="true"></a-light>
    <a-light id="ambientlight" type="ambient" color="#b8e6ff" intensity="0.62"></a-light>

    <!-- Character Models (Marichan, Marianne, Elina) -->
    <!-- 真理 -->
    <a-entity id="marichan" position="0 0.1 22">
      <a-sphere position="0 1.7 0" radius="0.43" color="#f44"></a-sphere>
      <a-torus position="0 1.95 0" radius="0.25" radius-tubular="0.06" color="#e44" rotation="90 0 0"></a-torus>
      <a-cylinder position="0 1.1 0" radius="0.21" height="1.1" color="#222"></a-cylinder>
      <a-sphere position="0.21 1.45 0" radius="0.09" color="#ff8888"></a-sphere>
      <a-sphere position="-0.21 1.45 0" radius="0.09" color="#ff8888"></a-sphere>
      <a-cylinder position="0.36 1.1 0" radius="0.06" height="0.5" color="#f99" rotation="0 0 22"></a-cylinder>
      <a-cylinder position="-0.36 1.1 0" radius="0.06" height="0.5" color="#f99" rotation="0 0 -22"></a-cylinder>
      <a-cylinder position="0.11 0.35 0" radius="0.07" height="0.47" color="#222" rotation="0 0 13"></a-cylinder>
      <a-cylinder position="-0.11 0.35 0" radius="0.07" height="0.47" color="#222" rotation="0 0 -13"></a-cylinder>
      <a-box position="0.37 1.0 0.12" width="0.07" height="0.5" depth="0.07" color="#222"></a-box>
      <a-box position="0.37 1.27 0.12" width="0.05" height="0.18" depth="0.05" color="#bfb"></a-box>
      <a-sphere position="0.12 1.82 0.39" radius="0.04" color="#fff"></a-sphere>
      <a-sphere position="-0.12 1.82 0.39" radius="0.04" color="#fff"></a-sphere>
      <a-sphere position="0.12 1.82 0.43" radius="0.018" color="#111"></a-sphere>
      <a-sphere position="-0.12 1.82 0.43" radius="0.018" color="#111"></a-sphere>
      <a-torus position="0 1.71 0.43" radius="0.07" radius-tubular="0.011" color="#e88" rotation="90 0 0"></a-torus>
      <a-text value="真理" color="#fff" position="0 2.23 0" align="center" width="7"></a-text>
    </a-entity>
    <!-- マリアンヌ -->
    <a-entity id="marianne" position="2.5 0.1 22">
      <a-sphere position="0 1.7 0" radius="0.42" color="#ffe89b"></a-sphere>
      <a-cone position="0 2.18 0" radius-bottom="0.13" radius-top="0.01" height="0.23" color="#ffd700"></a-cone>
      <a-cylinder position="0 1.05 0" radius="0.21" height="1.1" color="#e4e7f4"></a-cylinder>
      <a-cylinder position="0.28 1.12 0.09" radius="0.06" height="0.54" color="#eac" rotation="0 0 24"></a-cylinder>
      <a-cylinder position="-0.28 1.12 0.09" radius="0.06" height="0.54" color="#eac" rotation="0 0 -24"></a-cylinder>
      <a-box position="0.02 1.7 0.28" width="0.10" height="0.03" depth="0.01" color="#22f"></a-box>
      <a-text value="マリアンヌ" color="#fff" position="0 2.2 0" align="center" width="7"></a-text>
    </a-entity>
    <!-- エリナ -->
    <a-entity id="elina" position="-2.5 0.1 22">
      <a-sphere position="0 1.7 0" radius="0.42" color="#70e59b"></a-sphere>
      <a-cylinder position="0 1.05 0" radius="0.21" height="1.1" color="#e3ffe3"></a-cylinder>
      <a-cone position="0.32 1.85 0" radius-bottom="0.06" radius-top="0.01" height="0.18" color="#fff" rotation="0 0 50"></a-cone>
      <a-cone position="-0.32 1.85 0" radius-bottom="0.06" radius-top="0.01" height="0.18" color="#fff" rotation="0 0 -50"></a-cone>
      <a-text value="エリナ" color="#fff" position="0 2.2 0" align="center" width="7"></a-text>
    </a-entity>

    <!-- Enhanced Town (街) Graphics - Position: 0 0 22 -->
    <a-entity id="town-scene" position="0 0 22">
      <!-- Main Building 1 (Guild) -->
      <a-box position="-8 2.5 -5" width="6" height="5" depth="6" color="#a0522d" shadow="cast: true"></a-box>
      <a-cone position="-8 5.5 -5" radius-bottom="4" height="3" color="#8b4513" rotation="0 45 0" shadow="cast: true"></a-cone>
      <a-text value="GUILD" color="#333" position="-8 4.5 -1.9" align="center" width="10"></a-text>
      <!-- Main Building 2 (Tavern) -->
      <a-box position="8 2.5 -5" width="6" height="5" depth="6" color="#a0522d" shadow="cast: true"></a-box>
      <a-cone position="8 5.5 -5" radius-bottom="4" height="3" color="#8b4513" rotation="0 -45 0" shadow="cast: true"></a-cone>
      <a-text value="TAVERN" color="#333" position="8 4.5 -1.9" align="center" width="10"></a-text>
      <!-- Inn -->
      <a-box position="0 2.5 -10" width="8" height="5" depth="7" color="#deb887" shadow="cast: true"></a-box>
      <a-cone position="0 5.5 -10" radius-bottom="5" height="3" color="#cd853f" shadow="cast: true"></a-cone>
      <a-text value="INN" color="#333" position="0 4.5 -6.4" align="center" width="10"></a-text>
      <!-- Shop -->
      <a-box id="town-shop" position="12 2.5 0" width="5" height="5" depth="5" color="#8fbc8f" shadow="cast: true"></a-box>
      <a-pyramid position="12 5.5 0" width="5" height="3" depth="5" color="#6b8e23" shadow="cast: true"></a-pyramid>
      <a-text value="SHOP" color="#333" position="12 4.5 2.6" align="center" width="10"></a-text>
      <!-- Fountain -->
      <a-cylinder position="0 0.5 0" radius="2" height="1" color="#4682b4" shadow="cast: true"></a-cylinder>
      <a-cylinder position="0 1.5 0" radius="0.5" height="1" color="#add8e6" shadow="cast: true"></a-cylinder>
      <a-sphere position="0 2.5 0" radius="0.3" color="#add8e6" shadow="cast: true"></a-sphere>
      <!-- Trees -->
      <a-cylinder position="-10 2.5 5" radius="0.5" height="5" color="#8b4513" shadow="cast: true"></a-cylinder>
      <a-cone position="-10 6.5 5" radius-bottom="2" height="4" color="#228b22" shadow="cast: true"></a-cone>
      <a-cylinder position="10 2.5 5" radius="0.5" height="5" color="#8b4513" shadow="cast: true"></a-cylinder>
      <a-cone position="10 6.5 5" radius-bottom="2" height="4" color="#228b22" shadow="cast: true"></a-cone>
      <!-- Town NPC -->
      <a-entity id="town-npc-1" position="-5 0.1 0" class="interactable-npc">
        <a-sphere position="0 1.7 0" radius="0.4" color="#f0e68c"></a-sphere> <!-- Head -->
        <a-cylinder position="0 1.0 0" radius="0.2" height="1.2" color="#808080"></a-cylinder> <!-- Body -->
        <a-text value="村人" color="#fff" position="0 2.2 0" align="center" width="7"></a-text>
      </a-entity>
    </a-entity>

    <!-- Enhanced Home (自宅) Graphics - Position: 18 0 31 -->
    <a-entity id="home-scene" position="18 0 31">
      <!-- House Body -->
      <a-box position="0 2.5 0" width="8" height="5" depth="8" color="#d2b48c" shadow="cast: true"></a-box>
      <!-- Roof -->
      <a-box position="0 5.5 0" width="9" height="0.5" depth="9" color="#8b4513" rotation="0 45 0" shadow="cast: true"></a-box>
      <a-cone position="0 7.5 0" radius-bottom="5" height="4" color="#8b4513" shadow="cast: true"></a-cone>
      <!-- Chimney -->
      <a-box position="3 7 3" width="1" height="3" depth="1" color="#654321" shadow="cast: true"></a-box>
      <!-- Door -->
      <a-box position="0 1.5 4.01" width="2" height="3" depth="0.1" color="#654321"></a-box>
      <!-- Windows -->
      <a-box position="3 2.5 4.01" width="1.5" height="2" depth="0.1" color="#87ceeb"></a-box>
      <a-box position="-3 2.5 4.01" width="1.5" height="2" depth="0.1" color="#87ceeb"></a-box>
      <a-box position="4.01 2.5 0" width="0.1" height="2" depth="1.5" rotation="0 90 0" color="#87ceeb"></a-box>
      <!-- Small Garden & Fence -->
      <a-plane position="0 0.01 6" width="10" height="4" rotation="-90 0 0" color="#556b2f" shadow="receive: true"></a-plane>
      <a-sphere position="2 0.5 6" radius="0.5" color="#ff69b4"></a-sphere>
      <a-sphere position="-2 0.5 6" radius="0.5" color="#ff69b4"></a-sphere>
      <a-cylinder position="0 0.5 7" radius="0.3" height="1" color="#8b4513"></a-cylinder>
      <a-cone position="0 1.5 7" radius-bottom="1" height="2" color="#228b22"></a-cone>
      <!-- Fence -->
      <a-box position="0 0.5 8" width="10" height="1" depth="0.1" color="#a0522d"></a-box>
      <a-box position="4.9 0.5 6" width="0.1" height="1" depth="4" color="#a0522d"></a-box>
      <a-box position="-4.9 0.5 6" width="0.1" height="1" depth="4" color="#a0522d"></a-box>
      <!-- Interior elements (simple) -->
      <a-box position="0 0.7 -2" width="6" height="0.5" depth="3" color="#a0522d"></a-box> <!-- Floor inside -->
      <a-box position="2 1.5 -3" width="1.5" height="1" depth="0.8" color="#654321"></a-box> <!-- Table -->
      <a-box position="2.5 0.7 -2.5" width="0.5" height="0.8" depth="0.5" color="#654321"></a-box> <!-- Chair -->
      <a-box position="-2 1.5 -3.8" width="3" height="0.5" depth="1.5" color="#8b4513"></a-box> <!-- Bed -->
    </a-entity>

    <!-- Enhanced Dungeon Entrance (ダンジョン入口) Graphics - Position: -28 0 41 -->
    <a-entity id="dungeon-scene" position="-28 0 41">
      <!-- Cave Entrance Arch (more rugged) -->
      <a-torus position="0 3 0" radius="4.5" radius-tubular="1.5" arc="180" rotation="90 0 0" color="#444" shadow="cast: true"></a-torus>
      <a-box position="0 0.5 0" width="9" height="1.5" depth="1.5" color="#444" shadow="cast: true"></a-box>
      <!-- Cave Interior (deeper, darker) -->
      <a-box position="0 2.5 -8" width="12" height="6" depth="15" color="#222" shadow="cast: true" material="shader: flat; side: back"></a-box>
      <!-- Jagged Rocks around entrance -->
      <a-tetrahedron position="4 1.5 1" radius="1.5" color="#555" rotation="0 45 0" shadow="cast: true"></a-tetrahedron>
      <a-tetrahedron position="-4 1.5 1" radius="1.5" color="#555" rotation="0 -45 0" shadow="cast: true"></a-tetrahedron>
      <a-box position="0 0.8 2" width="6" height="1.5" depth="2" color="#555" rotation="0 15 0" shadow="cast: true"></a-box>
      <!-- Pillars (more textured) -->
      <a-cylinder position="3.5 2.5 3" radius="0.9" height="5" color="#666" shadow="cast: true"></a-cylinder>
      <a-cylinder position="-3.5 2.5 3" radius="0.9" height="5" color="#666" shadow="cast: true"></a-cylinder>
      <!-- Glowing Crystals (more prominent) -->
      <a-dodecahedron position="5.5 1.8 -5" radius="0.9" color="#0ff" material="emissive: #0ff; emissiveIntensity: 1.2"></a-dodecahedron>
      <a-dodecahedron position="-5.5 1.8 -5" radius="0.9" color="#0ff" material="emissive: #0ff; emissiveIntensity: 1.2"></a-dodecahedron>
      <!-- Eerie light from deep within -->
      <a-light type="point" color="#0ff" intensity="0.5" position="0 2 -10"></a-light>
      <!-- Dungeon Enemy (Slime) -->
      <a-entity id="dungeon-slime-1" position="3 0.5 -5" class="interactable-enemy">
        <a-sphere position="0 0.5 0" radius="0.5" color="#8a2be2" opacity="0.7"></a-sphere>
        <a-text value="スライム" color="#fff" position="0 1.2 0" align="center" width="5"></a-text>
      </a-entity>
    </a-entity>

    <!-- Enhanced Large Castle (大城) Graphics - Position: 0 0 65 -->
    <a-entity id="castle-scene" position="0 0 65">
      <!-- Main Castle Wall (more imposing) -->
      <a-box position="0 6 0" width="40" height="12" depth="20" color="#808080" shadow="cast: true"></a-box>
      <!-- Battlements on main wall -->
      <a-box position="18 12.5 0" width="2" height="1" depth="20" color="#696969" shadow="cast: true"></a-box>
      <a-box position="-18 12.5 0" width="2" height="1" depth="20" color="#696969" shadow="cast: true"></a-box>
      <a-box position="0 12.5 8" width="40" height="1" depth="2" color="#696969" shadow="cast: true"></a-box>
      <a-box position="0 12.5 -8" width="40" height="1" depth="2" color="#696969" shadow="cast: true"></a-box>
      <!-- Main Tower 1 (taller, more detailed) -->
      <a-cylinder position="15 12 0" radius="4" height="24" color="#777" shadow="cast: true"></a-cylinder>
      <a-cone position="15 25 0" radius-bottom="4.5" height="6" color="#555" shadow="cast: true"></a-cone>
      <!-- Tower 1 Battlements -->
      <a-box position="15 24.5 0" width="9" height="1" depth="9" color="#696969" rotation="0 45 0" shadow="cast: true"></a-box>
      <!-- Main Tower 2 (taller, more detailed) -->
      <a-cylinder position="-15 12 0" radius="4" height="24" color="#777" shadow="cast: true"></a-cylinder>
      <a-cone position="-15 25 0" radius-bottom="4.5" height="6" color="#555" shadow="cast: true"></a-cone>
      <!-- Tower 2 Battlements -->
      <a-box position="-15 24.5 0" width="9" height="1" depth="9" color="#696969" rotation="0 45 0" shadow="cast: true"></a-box>
      <!-- Gate (more complex drawbridge style) -->
      <a-box position="0 4 -9.9" width="10" height="8" depth="0.2" color="#444" shadow="cast: true"></a-box>
      <a-box position="0 9 -9.9" width="12" height="2" depth="0.2" color="#444" shadow="cast: true"></a-box>
      <a-box position="0 11 -9.9" width="14" height="1" depth="0.2" color="#444" shadow="cast: true"></a-box>
      <!-- Drawbridge elements -->
      <a-box position="0 0.5 -9.8" width="8" height="1" depth="0.1" color="#654321" rotation="0 0 0"></a-box>
      <a-box position="4.5 5 -9.8" width="0.2" height="10" depth="0.2" color="#333" rotation="0 0 15"></a-box>
      <a-box position="-4.5 5 -9.8" width="0.2" height="10" depth="0.2" color="#333" rotation="0 0 -15"></a-box>
      <!-- Flags on towers -->
      <a-box position="15 28 0" width="0.6" height="4" depth="0.6" color="#8b4513"></a-box>
      <a-plane position="15 30 1.8" width="2.5" height="1.8" rotation="0 90 0" color="#ffd700"></a-plane>
      <a-box position="-15 28 0" width="0.6" height="4" depth="0.6" color="#8b4513"></a-box>
      <a-plane position="-15 30 1.8" width="2.5" height="1.8" rotation="0 90 0" color="#ffd700"></a-plane>
    </a-entity>

    <!-- Field Enemy (Slime) -->
    <a-entity id="field-slime-1" position="10 0.1 10" class="interactable-enemy">
      <a-sphere position="0 0.5 0" radius="0.5" color="#00ff00" opacity="0.7"></a-sphere>
      <a-text value="スライム" color="#fff" position="0 1.2 0" align="center" width="5"></a-text>
    </a-entity>

    <!-- Boss Placeholder (for evo, ogre, dragon) -->
    <a-entity id="bossmon" visible="false"></a-entity>

  </a-scene>
<script>
// UI Elements
const dialogue = document.getElementById('dialogue');
const partyStatus = document.getElementById('partyStatus');
const hint = document.getElementById('hint');
const warpBtns = document.getElementById('warpBtns');
const shopDiv = document.getElementById('shopDiv');
const questClear = document.getElementById('questClear');
const battleEffect = document.getElementById('battleEffect');
const overlay = document.getElementById('overlay');

// Game State
let state = {
  party: [
    {name:'真理', lv:5, hp:60, maxhp:60, alive:true, job:'剣姫', skills:['ファイアーボール','ファイアーイノセント']},
    {name:'マリアンヌ', lv:5, hp:50, maxhp:50, alive:true, job:'魔法姫', skills:['ファイアーボール']},
    {name:'エリナ', lv:5, hp:46, maxhp:46, alive:true, job:'エルフ賢者', skills:['アクアスパイク']}
  ],
  gold:3000,
  inventory: [],
  currentStoryStep: "intro_01", // Current point in the story
  lastPlayerPosition: {x:0, y:1.6, z:22}, // To track movement for progress
  shopOpen: false,
  inBattle: false,
  evoCleared:false, ogreCleared:false, dragonCleared:false,
  evoTry:0, evoLv:15, ogreLv:20, dragonLv:30,
};

// Warp Points (now with more descriptive names for UI)
const warpPoints = [
  {name:"街", pos:{x:0, y:1.6, z:22}},
  {name:"自宅", pos:{x:18, y:1.6, z:31}},
  {name:"ダンジョン入口", pos:{x:-28, y:1.6, z:41}},
  {name:"大城", pos:{x:0, y:1.6, z:65}}
];

// Shop Items
const shopItems = [
  {id: 'potion', name: 'ポーション', price: 100, type: 'consumable', effect: 'HP回復'},
  {id: 'longsword', name: 'ロングソード', price: 500, type: 'weapon', atk: 10},
  {id: 'ironshield', name: 'アイアンシールド', price: 300, type: 'armor', def: 5}
];

// Story Data (structured for branching)
const storyData = {
  "intro_01": { speaker: "宅間", text: "あ~暇だなネットサーフィンでもするか", next: "intro_02" },
  "intro_02": { speaker: "Narration", text: "新作VR機器を注文して翌日届いた。", next: "intro_03" },
  "intro_03": { speaker: "宅間", text: "ふひひ!幼女になれた!俺は幼女なんだ", next: "intro_04" },
  "intro_04": { speaker: "Narration", text: "ハンドルネームを真理にしてログイン。最初の街ポルッドに着く。", next: "marianne_meet_01" },
  "marianne_meet_01": { speaker: "マリアンヌ", text: "かわいいわね私はマリアンヌっていうの", next: "marianne_meet_02" },
  "marianne_meet_02": { speaker: "真理", text: "お主、なかなかの美少女でござるなぁ…", next: "marianne_meet_03" },
  "marianne_meet_03": { speaker: "マリアンヌ", text: "もしかして中身キモヲタのおっさん!?", next: "marianne_meet_04" },
  "marianne_meet_04": { speaker: "真理", text: "うるちゃい!俺は幼女なのだぁ…!", next: "marianne_meet_05" },
  "marianne_meet_05": { speaker: "マリアンヌ", text: "まあ見た目かわいいから一緒に行くか", next: "to_castle_01" },
  "to_castle_01": { speaker: "Narration", text: "真理はだんだん幼女化していった。お城へ。", next: "king_meet_01" },
  "king_meet_01": { speaker: "王様", text: "おお、マリアンヌ何処に行ってたのだ?おやその子は?", next: "king_meet_02" },
  "king_meet_02": { speaker: "真理", text: "真理なのじゃ!!", next: "king_meet_03" },
  "king_meet_03": { speaker: "王様", text: "何と可愛らしい…", next: "king_meet_04" },
  "king_meet_04": { speaker: "マリアンヌ", text: "私決めたわ!この子と一緒に旅することに!", next: "king_meet_05" },
  "king_meet_05": { speaker: "王様", text: "それは行かん!", next: "king_meet_06" },
  "king_meet_06": { speaker: "真理", text: "行くのじゃ!", next: "leave_castle_01" },
  "leave_castle_01": { speaker: "Narration", text: "マリアンヌの手を繋いで城を出た。", next: "leave_castle_02" },
  "leave_castle_02": { speaker: "マリアンヌ", text: "ちょっと待ちなさいよ城から出て行く当てでもあるの?", next: "leave_castle_03" },
  "leave_castle_03": { speaker: "真理", text: "次の街を探してみようと思うのじゃ", next: "leave_castle_04" },
  "leave_castle_04": { speaker: "マリアンヌ", text: "ここから一番近くの街って言ったらイデルかしら", next: "leave_castle_05" },
  "leave_castle_05": { speaker: "真理", text: "イデルってどういった場所なのかの?", next: "leave_castle_06" },
  "leave_castle_06": { speaker: "マリアンヌ", text: "知らないわよ私街から出たことないし…", next: "leave_castle_07" },
  "leave_castle_07": { speaker: "真理", text: "それじゃお試しでいくのじゃ!", next: "rest_01" },
  "rest_01": { speaker: "Narration", text: "焚火→テントで休憩→朝", next: "start_journey_01" },
  "start_journey_01": { speaker: "真理", text: "それじゃ向かうのじゃ!", next: "slime_appear_01" },
  "slime_appear_01": { speaker: "Narration", text: "フィールドに出るとスライムが現れた", next: "battle_slime_01" },
  "battle_slime_01": {
    speaker: "真理",
    text: "ファイアーボール!!",
    onComplete: () => { startBattle('slime'); }, // Trigger battle function
    next: "slime_defeated_01"
  },
  "slime_defeated_01": { speaker: "Narration", text: "真理の初級呪文でスライムを倒した", next: "marianne_magic_01" },
  "marianne_magic_01": { speaker: "マリアンヌ", text: "へぇあんた呪文使えるのね", next: "marianne_magic_02" },
  "marianne_magic_02": { speaker: "真理", text: "必要ならば教えてあげることも可能なのじゃ", next: "marianne_magic_03" },
  "marianne_magic_03": { speaker: "マリアンヌ", text: "教えて教えて!", next: "marianne_magic_04" },
  "marianne_magic_04": { speaker: "真理", text: "しょうがないのう", next: "marianne_magic_05" },
  "marianne_magic_05": { speaker: "Narration", text: "真理はマリアンヌに初級魔術を教えた。", next: "marianne_magic_06" },
  "marianne_magic_06": { speaker: "マリアンヌ", text: "こうですの?", next: "marianne_magic_07" },
  "marianne_magic_07": { speaker: "Narration", text: "炎の魔術を繰り出した", next: "marianne_magic_08" },
  "marianne_magic_08": { speaker: "真理", text: "そうそう", next: "marianne_magic_09" },
  "marianne_magic_09": { speaker: "マリアンヌ", text: "結構簡単でしたね", next: "marianne_magic_10" },
  "marianne_magic_10": { speaker: "真理", text: "初級魔術だからね今から魔術書で中級を覚える予定", next: "master_mid_magic_01" },
  "master_mid_magic_01": { speaker: "Narration", text: "次の日、中級魔術をマスター", next: "ogre_appear_01" },
  "ogre_appear_01": { speaker: "真理", text: "ファイアーイノセント!!", next: "ogre_defeated_01" },
  "ogre_defeated_01": { speaker: "Narration", text: "巨大なオークを丸焼きに", next: "ogre_defeated_02" },
  "ogre_defeated_02": { speaker: "マリアンヌ", text: "オークを一撃でやるなんてすごいわね", next: "ogre_defeated_03" },
  "ogre_defeated_03": { speaker: "真理", text: "いつの間にかに強くなってたのじゃ", next: "dungeon_found_01" },
  "dungeon_found_01": { speaker: "Narration", text: "洞窟を発見。中へ入る。", next: "dungeon_intro_01" },
  "dungeon_intro_01": { speaker: "マリアンヌ", text: "どうやらここは本で書いてあった始まりの洞窟のようね", next: "lizardman_appear_01" },
  "lizardman_appear_01": { speaker: "Narration", text: "リザードマンが出現!", next: "lizardman_battle_01" },
  "lizardman_battle_01": { speaker: "真理", text: "リザードマンなのじゃ気を付けるのじゃ", next: "lizardman_battle_02" },
  "lizardman_battle_02": { speaker: "マリアンヌ", text: "ファイアーボール!!", next: "lizardman_battle_03" },
  "lizardman_battle_03": { speaker: "Narration", text: "リザードマン「兄貴!尻尾が燃えてますぜ」", next: "lizardman_battle_04" },
  "lizardman_battle_04": { speaker: "真理", text: "もっと燃やしてやるのじゃ", next: "lizardman_defeated_01" },
  "lizardman_defeated_01": { speaker: "Narration", text: "炎の魔術でリザードマン撃破!", next: "lizardman_defeated_02" },
  "lizardman_defeated_02": { speaker: "マリアンヌ", text: "やるじゃない私も早く中級魔術使えるようになりたいわ", next: "lizardman_defeated_03" },
  "lizardman_defeated_03": { speaker: "真理", text: "今日の夜にでも教えてあげるのじゃ", next: "treasure_chest_01" },
  "treasure_chest_01": { speaker: "Narration", text: "洞窟の分岐で宝箱(ロングソード)を発見。", next: "treasure_chest_02" },
  "treasure_chest_02": { speaker: "真理", text: "やった宝箱なのじゃー!", next: "treasure_chest_03" },
  "treasure_chest_03": { speaker: "マリアンヌ", text: "中身は何かしらね", next: "treasure_chest_04" },
  "treasure_chest_04": { speaker: "Narration", text: "中身はロングソードだった", next: "treasure_chest_05" },
  "treasure_chest_05": { speaker: "真理", text: "何だ剣か…", next: "treasure_chest_06" },
  "treasure_chest_06": { speaker: "マリアンヌ", text: "杖の方が良かったわねでもせっかくだから装備して見ましょう", next: "sword_lv_up_01" },
  "sword_lv_up_01": { speaker: "Narration", text: "剣術レベル1になった", next: "sword_lv_up_02" },
  "sword_lv_up_02": { speaker: "真理", text: "剣をもっと使いこなしたいのう", next: "sword_lv_up_03" },
  "sword_lv_up_03": { speaker: "マリアンヌ", text: "剣術が出来る人を探すしかないわね", next: "exit_dungeon_01" },
  "exit_dungeon_01": { speaker: "Narration", text: "洞窟出口→外に出る。", next: "exit_dungeon_02" },
  "exit_dungeon_02": { speaker: "真理", text: "外に出たのじゃ!!", next: "idel_arrival_01" },
  "idel_arrival_01": { speaker: "Narration", text: "街イデルに到着。", next: "idel_guide_01" },
  "idel_guide_01": { speaker: "案内人", text: "ようこそイデルへ!ここは仲間を集めたりする酒場や、クエストを受けられる冒険者ギルドがあります", next: "idel_guide_02" },
  "idel_guide_02": { speaker: "真理", text: "それじゃあまずは酒場で情報収集と仲間集めと行きますか", next: "idel_guide_03" },
  "idel_guide_03": { speaker: "マリアンヌ", text: "どんな人がいるかしらね", next: "elina_appear_01" },
  "elina_appear_01": { speaker: "Narration", text: "酒場でエリナ登場。", next: "elina_join_01" },
  "elina_join_01": { speaker: "真理", text: "そこの美しいお方、わらわ達と冒険しませんか?", next: "elina_join_02" },
  "elina_join_02": { speaker: "エリナ", text: "私はエリナ・カリオットよ見ての通りエルフで魔術師をやっているわ", next: "elina_join_03" },
  "elina_join_03": { speaker: "真理", text: "よかったら仲間になってくれませんか?", next: "elina_join_04" },
  "elina_join_04": { speaker: "エリナ", text: "クエストを手伝ってくれたら考えてもいいわよ", next: "elina_join_05" },
  "elina_join_05": { speaker: "真理", text: "わーい手伝う手伝う!", next: "to_guild_with_elina_01" },
  "to_guild_with_elina_01": { speaker: "Narration", text: "エリナと共に冒険者ギルドへ。", next: "gigborg_quest_01" },
  "gigborg_quest_01": { speaker: "エリナ", text: "あなた達にはギグボルグの討伐をやって貰うわ", next: "gigborg_quest_02" },
  "gigborg_quest_02": { speaker: "真理", text: "どんなモンスターかわからにゃいけど頑張るにゃ", next: "gigborg_quest_03" },
  "gigborg_quest_03": { speaker: "マリアンヌ", text: "何でちょっと猫語になってんの", next: "gigborg_quest_04" },
  "gigborg_quest_04": { speaker: "真理", text: "ふにゃ??分からないにゃ", next: "gigborg_quest_05" },
  "gigborg_quest_05": { speaker: "エリナ", text: "場所は始まりの塔よ。北にあるわ。", next: "to_tower_01" },
  "to_tower_01": { speaker: "Narration", text: "始まりの塔へ向かう。", next: "goblin_battle_01" },
  "goblin_battle_01": { speaker: "Narration", text: "始まりの塔でゴブリン達とバトル!", next: "goblin_battle_02" },
  "goblin_battle_02": { speaker: "真理", text: "ファイアーイノセント!!", onComplete: () => { startBattle('goblin'); }, next: "goblin_defeated_01" },
  "goblin_defeated_01": { speaker: "Narration", text: "ゴブリンたちは焼き尽くされた。", next: "open_door_01" },
  "open_door_01": { speaker: "Narration", text: "塔の中でアイテム端末を使い扉を開く。", next: "boss_warning_01" },
  "boss_warning_01": { speaker: "冒険者", text: "この先ボス部屋があるぞ強いから注意しておけ", next: "gigborg_boss_01" },
  "gigborg_boss_01": { speaker: "Narration", text: "ボス部屋でギグボルグLv10戦。", next: "gigborg_boss_02" },
  "gigborg_boss_02": { speaker: "マリアンヌ", text: "ファイアーボール!!", next: "gigborg_boss_03" },
  "gigborg_boss_03": { speaker: "エリナ", text: "アクアスパイク!!", next: "gigborg_boss_04" },
  "gigborg_boss_04": { speaker: "Narration", text: "ギグボルグの斧で全滅→イデルで復活。", next: "level_up_needed_01" },
  "level_up_needed_01": { speaker: "マリアンヌ", text: "やられたみたいねレベル上げでもしましょ", next: "goblin_hunt_01" },
  "goblin_hunt_01": { speaker: "Narration", text: "西の森でゴブリン狩りLv10にアップ。", next: "lightning_vortex_01" },
  "lightning_vortex_01": { speaker: "真理", text: "ライトニングヴォルテックスを覚えた!", next: "gigborg_retry_01" },
  "gigborg_retry_01": { speaker: "Narration", text: "再挑戦でギグボルグ撃破。", next: "gigborg_defeated_01" },
  "gigborg_defeated_01": { speaker: "マリアンヌ", text: "やったわ!ギグボルグ撃破よあんたおっさんの癖になかなかやるわね", next: "gigborg_defeated_02" },
  "gigborg_defeated_02": { speaker: "真理", text: "おっさん言うな!どうみてもかわいい女の子じゃろ?", next: "gigborg_defeated_03" },
  "gigborg_defeated_03": { speaker: "マリアンヌ", text: "そ、そうね…", next: "elina_officially_join_01" },
  "elina_officially_join_01": { speaker: "エリナ", text: "約束通り仲間になってあげるわよ", next: "elina_officially_join_02" },
  "elina_officially_join_02": { speaker: "真理", text: "よろしくなのじゃ", next: "evolvia_quest_01" },
  "evolvia_quest_01": { speaker: "エリナ", text: "次はエボルビア討伐に行くわよ", next: "evolvia_quest_02" },
  "evolvia_quest_02": { speaker: "Narration", text: "海にいる怪物エボルビア討伐へ。", next: "evolvia_battle_01" },
  "evolvia_battle_01": { speaker: "真理", text: "ライトニングヴォルテックス!", next: "evolvia_retreat_01" },
  "evolvia_retreat_01": { speaker: "Narration", text: "レベル差で撤退、レベル上げ&アイテム集め。", next: "lightning_judgment_01" },
  "lightning_judgment_01": { speaker: "Narration", text: "Lv20到達でライトニングジャッジメントを覚える。", next: "evolvia_rematch_01" },
  "evolvia_rematch_01": { speaker: "真理", text: "エボルビアを倒しに行くわよ", next: "evolvia_rematch_02" },
  "evolvia_rematch_02": { speaker: "マリアンヌ", text: "今度こそ倒すわよ", next: "evolvia_rematch_03" },
  "evolvia_rematch_03": { speaker: "真理", text: "ライトニングジャッジメント!!", next: "evolvia_defeated_01" },
  "evolvia_defeated_01": { speaker: "Narration", text: "エボルビア討伐、クエストクリアー。", next: "quest_clear_effect_01" },
  "quest_clear_effect_01": { speaker: "エリナ", text: "おっしゃークリア!お疲れ!", onComplete: () => { showQuestClear(); }, next: "ogre_quest_01" },
  "ogre_quest_01": { speaker: "Narration", text: "オーガ討伐→オーガの爪1万Gで売却。", next: "buy_equip_01" },
  "buy_equip_01": { speaker: "Narration", text: "武器・防具を買い強化。宿屋で体力回復。", next: "rank_up_quest_01" },
  "rank_up_quest_01": { speaker: "受付の人", text: "現在のランクはEクラスです。ランクアップクエストはドラゴン討伐です。", next: "dragon_quest_01" },
  "dragon_quest_01": { speaker: "真理", text: "ドラゴンの討伐いくのじゃ", next: "dragon_quest_02" },
  "dragon_quest_02": { speaker: "Narration", text: "竜の山へピクニック→ドラゴンの巣で爆弾を設置して爆破!", next: "dragon_quest_03" },
  "dragon_quest_03": { speaker: "真理", text: "少々やりすぎたのじゃ", next: "rank_up_d_01" },
  "rank_up_d_01": { speaker: "Narration", text: "イデルでクエスト報告、Dランクにアップ&飛空艇GET。", next: "d_rank_quest_01" },
  "d_rank_quest_01": { speaker: "マリアンヌ", text: "Dランクのクエストも受けておきましょ", next: "hero_tower_01" },
  "hero_tower_01": { speaker: "Narration", text: "飛空艇で英雄の塔→闇の騎士ボス戦", next: "dark_knight_battle_01" },
  "dark_knight_battle_01": { speaker: "マリアンヌ", text: "受け取って!", next: "dark_knight_battle_02" },
  "dark_knight_battle_02": { speaker: "Narration", text: "マリアンヌが剣を投げ真理が闇の騎士を討つ。", next: "dark_knight_defeated_01" },
  "dark_knight_defeated_01": { speaker: "真理", text: "どうじゃ?わらわの力は?", next: "dark_knight_defeated_02" },
  "dark_knight_defeated_02": { speaker: "マリアンヌ", text: "あの時、私が剣を渡してなかったら死んでたわよ", next: "dark_knight_defeated_03" },
  "dark_knight_defeated_03": { speaker: "真理", text: "それは感謝してるのじゃ", next: "sky_castle_01" },
  "sky_castle_01": { speaker: "Narration", text: "塔の景色→空に浮かぶ城エリクッドへ。", next: "angel_meet_01" },
  "angel_meet_01": { speaker: "天使", text: "ようこそエリクッドへ", next: "king_attacked_01" },
  "king_attacked_01": { speaker: "王様", text: "今エリクッドは魔界の悪魔の攻撃を受けている", next: "demon_realm_quest_01" },
  "demon_realm_quest_01": { speaker: "真理", text: "んじゃわらわたちが魔界に行って悪魔を倒してやるのじゃ!", next: "demon_realm_quest_02" },
  "demon_realm_quest_02": { speaker: "王様", text: "異界の門はここからずっと北にある", next: "to_demon_gate_01" },
  "to_demon_gate_01": { speaker: "Narration", text: "異界の門へ→ワイバーン撃破→サタン戦", next: "satan_battle_01" },
  "satan_battle_01": { speaker: "サタン", text: "ここから先は通さないぜ", next: "satan_battle_02" },
  "satan_battle_02": { speaker: "真理", text: "サンダージャッジメント!!", next: "satan_battle_03" },
  "satan_battle_03": { speaker: "エリナ", text: "プラチナソード!!", next: "satan_defeated_01" },
  "satan_defeated_01": { speaker: "Narration", text: "サタン討伐、魔界へ突入!", next: "demon_realm_arrival_01" },
  "demon_realm_arrival_01": { speaker: "案内人", text: "ようこそ、魔界の街モルドへ", next: "demon_realm_arrival_02" },
  "demon_realm_arrival_02": { speaker: "マリアンヌ", text: "ここの悪魔達は敵対心がないようね", next: "demon_realm_arrival_03" },
  "demon_realm_arrival_03": { speaker: "真理", text: "もう歩き疲れたのじゃ宿屋に泊りたいのじゃ~", next: "demon_castle_01" },
  "demon_castle_01": { speaker: "Narration", text: "魔界の城を目指しゾンビ戦→エリナが撃破!", next: "elina_defeat_zombie_01" },
  "elina_defeat_zombie_01": { speaker: "エリナ", text: "私に任せなさい!!", next: "end_chapter" },
  "end_chapter": { speaker: "Narration", text: "次章へ続く…", next: null }
};

let currentStoryId = state.currentStoryStep;

// --- UI Functions ---
function setWarpUI() {
  warpBtns.innerHTML = '';
  warpPoints.forEach(p=>{
    let btn = document.createElement('button');
    btn.textContent = p.name + "へ転移";
    btn.onclick = ()=>{
      document.querySelector('#playerRig').setAttribute('position', `${p.pos.x} ${p.pos.y} ${p.pos.z}`);
      closeDialogue(); // Close dialogue on warp
      closeShop(); // Close shop on warp
    };
    warpBtns.appendChild(btn);
  });
}

function updatePartyStatus() {
  partyStatus.innerHTML = `<b>パーティ</b><br>`;
  state.party.forEach(p=>{
    partyStatus.innerHTML += `<span class="${p.alive?'alive':'dead'}">${p.name}(Lv${p.lv}) ${p.hp}/${p.maxhp}HP</span><br>`;
  });
  partyStatus.innerHTML += `<b>G:</b> ${state.gold}<br>`;
  partyStatus.innerHTML += `<b>アイテム:</b> ${state.inventory.map(item => item.name).join(', ') || 'なし'}`;
}

// --- Day/Night Cycle ---
let skyColor="#b8e6ff", nightColor="#26305a";
let night=false;
function setDayNight(toNight){
  night=toNight;
  document.getElementById('sky').setAttribute('color',night?nightColor:skyColor);
  document.getElementById('dirlight').setAttribute('intensity',night?0.28:1.13);
  document.getElementById('ambientlight').setAttribute('intensity',night?0.16:0.62);
  document.getElementById('nightFilter').style.background=night?"rgba(0,8,38,0.53)":"rgba(0,8,38,0.0)";
}
setInterval(()=>{setDayNight(!night);},15000); setDayNight(false);

// --- Dialogue System ---
function showDialogueBlock(dialogueId) {
  const data = storyData[dialogueId];
  if (!data) {
    closeDialogue();
    return;
  }

  dialogue.innerHTML = '';
  dialogue.style.display = 'block';

  if (data.speaker && data.speaker !== 'Narration') {
    const n = document.createElement('span');
    n.className = 'name';
    n.textContent = data.speaker + ' ';
    dialogue.appendChild(n);
  }
  const t = document.createElement('span');
  t.textContent = data.text;
  dialogue.appendChild(t);

  if (data.choices) {
    data.choices.forEach(c => {
      const btn = document.createElement('button');
      btn.className = 'choice';
      btn.textContent = c.text;
      btn.onclick = () => {
        if (c.onChoose) c.onChoose(); // Execute choice-specific logic
        currentStoryId = c.next;
        showDialogueBlock(currentStoryId);
      };
      dialogue.appendChild(btn);
    });
  } else {
    dialogue.onclick = () => {
      dialogue.onclick = null; // Prevent multiple clicks
      if (data.onComplete) data.onComplete(); // Execute onComplete logic
      currentStoryId = data.next;
      showDialogueBlock(currentStoryId);
    };
  }
}

function closeDialogue() {
  dialogue.style.display = 'none';
  dialogue.onclick = null;
}

// --- Battle System (Simplified) ---
function startBattle(enemyType) {
  state.inBattle = true;
  battleEffect.style.display = 'block';
  // Simulate battle outcome instantly for now
  setTimeout(() => {
    battleEffect.style.display = 'none';
    state.inBattle = false;
    // Example: Party takes some damage, or enemy is defeated
    state.party.forEach(p => {
      if (p.alive) p.hp = Math.max(0, p.hp - 5); // Simulate damage
      if (p.hp === 0) p.alive = false;
    });
    updatePartyStatus();
    // Logic for enemy defeat, item drops, XP gain would go here
    // For now, the story progresses automatically after the simulated battle
  }, 300); // Flash for 0.3 seconds
}

function showQuestClear() {
  questClear.style.display = 'block';
  setTimeout(() => {
    questClear.style.display = 'none';
  }, 3000); // Show for 3 seconds
}

// --- Shop System ---
function openShop() {
  state.shopOpen = true;
  shopDiv.style.display = 'block';
  shopDiv.innerHTML = `
    <h2>ショップ</h2>
    <p>ゴールド: <span id="shopGold">${state.gold}</span>G</p>
    <div id="shopItemsContainer"></div>
    <button class="close-button" onclick="closeShop()">X</button>
  `;
  const shopItemsContainer = document.getElementById('shopItemsContainer');

  shopItems.forEach(item => {
    const itemDiv = document.createElement('div');
    itemDiv.className = 'shop-item';
    itemDiv.innerHTML = `
      <span>${item.name} (${item.price}G)</span>
      <button onclick="buyItem('${item.id}')">購入</button>
    `;
    shopItemsContainer.appendChild(itemDiv);
  });
  // Add a simple "Sell" option
  if (state.inventory.length > 0) {
    const sellSection = document.createElement('div');
    sellSection.innerHTML = `<h3>持ち物売却</h3>`;
    state.inventory.forEach((item, index) => {
      sellSection.innerHTML += `
        <div class="shop-item">
          <span>${item.name} (${Math.floor(item.price / 2)}G)</span>
          <button onclick="sellItem(${index})">売却</button>
        </div>
      `;
    });
    shopItemsContainer.appendChild(sellSection);
  }
}

function buyItem(itemId) {
  const item = shopItems.find(i => i.id === itemId);
  if (item && state.gold >= item.price) {
    state.gold -= item.price;
    state.inventory.push(item);
    updatePartyStatus();
    document.getElementById('shopGold').textContent = state.gold;
    // Re-render shop to show updated inventory for selling
    openShop();
  } else if (item) {
    // Using dialogue for messages instead of alert
    showDialogueBlock({ speaker: "ショップ店員", text: "ゴールドが足りません!" });
  }
}

function sellItem(index) {
  if (index >= 0 && index < state.inventory.length) {
    const item = state.inventory.splice(index, 1)[0];
    state.gold += Math.floor(item.price / 2); // Sell for half price
    updatePartyStatus();
    document.getElementById('shopGold').textContent = state.gold;
    openShop(); // Re-render shop
  }
}

function closeShop() {
  state.shopOpen = false;
  shopDiv.style.display = 'none';
}

// --- Interaction System ---
// Add click listeners to interactable entities
document.addEventListener('DOMContentLoaded', () => {
  const scene = document.querySelector('a-scene');

  // Event listener for NPC interaction
  const townNpc = document.getElementById('town-npc-1');
  if (townNpc) {
    townNpc.addEventListener('click', () => {
      if (!state.inBattle && !state.shopOpen) {
        showDialogueBlock({ speaker: "村人", text: "こんにちは、冒険者さん!この街は平和ですよ。" });
      }
    });
  }

  // Event listener for Shop interaction
  const townShop = document.getElementById('town-shop');
  if (townShop) {
    townShop.addEventListener('click', () => {
      if (!state.inBattle && !state.shopOpen) {
        openShop();
      }
    });
  }

  // Event listeners for Enemy interaction (Slimes)
  const fieldSlime = document.getElementById('field-slime-1');
  if (fieldSlime) {
    fieldSlime.addEventListener('click', () => {
      if (!state.inBattle && !state.shopOpen) {
        showDialogueBlock({
          speaker: "Narration",
          text: "スライムが現れた!戦いますか?",
          choices: [
            { text: "戦う", onChoose: () => { startBattle('slime'); fieldSlime.setAttribute('visible', 'false'); }, next: "battle_result_slime" },
            { text: "逃げる", next: "flee_result" }
          ]
        });
      }
    });
  }

  const dungeonSlime = document.getElementById('dungeon-slime-1');
  if (dungeonSlime) {
    dungeonSlime.addEventListener('click', () => {
      if (!state.inBattle && !state.shopOpen) {
        showDialogueBlock({
          speaker: "Narration",
          text: "ダンジョンスライムが現れた!戦いますか?",
          choices: [
            { text: "戦う", onChoose: () => { startBattle('dungeon-slime'); dungeonSlime.setAttribute('visible', 'false'); }, next: "battle_result_dungeon_slime" },
            { text: "逃げる", next: "flee_result" }
          ]
        });
      }
    });
  }

  // Define battle results (simple for now)
  storyData["battle_result_slime"] = { speaker: "Narration", text: "スライムを倒した!経験値と10Gを獲得した。", onComplete: () => { state.gold += 10; updatePartyStatus(); }, next: currentStoryId };
  storyData["battle_result_dungeon_slime"] = { speaker: "Narration", text: "ダンジョンスライムを倒した!経験値と20Gを獲得した。", onComplete: () => { state.gold += 20; updatePartyStatus(); }, next: currentStoryId };
  storyData["flee_result"] = { speaker: "Narration", text: "なんとか逃げ切った。", next: currentStoryId };

  // Initial story start
  showDialogueBlock(currentStoryId);
});

// --- Main Game Loop for Progress (simplified) ---
function checkProgress() {
  updatePartyStatus();
  const playerRig = document.querySelector('#playerRig');
  if (!playerRig) return;
  let pos = playerRig.object3D.position;

  // Only progress linear story if no dialogue is open and not in battle/shop
  if (dialogue.style.display === 'none' && !state.inBattle && !state.shopOpen) {
    // Auto-progress main story
    if (storyData[currentStoryId] && !storyData[currentStoryId].choices) {
      // Simulate dialogue click if it's not a choice block
      if (storyData[currentStoryId].next) {
        // This part is tricky with auto-progression.
        // For now, the story relies on user clicks, or specific triggers.
        // The `onComplete` in storyData handles the actual progression.
      }
    }
  }

  // Example: Trigger story based on proximity (can be expanded)
  // This is just a basic example, the main story progression is click-driven.
  const townCenter = new THREE.Vector3(0, 1.6, 22);
  if (pos.distanceTo(townCenter) < 10 && state.currentStoryStep === "intro_04") {
    // This is handled by the initial showDialogueBlock, but a more complex game
    // might trigger different dialogue based on location.
  }
}

setInterval(checkProgress, 700); // Check progress every 0.7 seconds

// Initial setup calls
setWarpUI();
updatePartyStatus();
</script>
</body>
</html>

DeepLinkVR


<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Verse - 次世代ソーシャルネットワーク VR対応</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/rita/1.3.63/rita-full.min.js"></script>
    <style>
        body { font-family: Arial, sans-serif; margin: 0; padding: 0; background: #f0f0f0; }
        header, .footer { background: linear-gradient(45deg, #6a11cb, #2575fc); color: white; text-align: center; padding: 20px; }
        .nav-container { background: #2575fc; display: flex; justify-content: center; padding: 10px; position: sticky; top: 0; }
        .nav-menu a { color: white; text-decoration: none; margin: 0 10px; }
        .content { max-width: 900px; margin: 20px auto; background: white; padding: 20px; border-radius: 8px; }
        .cta-button { background: #2575fc; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; }
        .profile-icon { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
        .dark-mode { background: #1e1e1e; color: #ddd; }
        .timeline { margin-top: 20px; }
        .timeline-post { border: 1px solid #ddd; border-radius: 8px; padding: 10px; margin-bottom: 10px; background: #fff; }
        canvas { border: 1px solid #ccc; }
    </style>
    <script>
        let posts = JSON.parse(localStorage.getItem('posts') || '[]');

        function saveData() {
            localStorage.setItem('posts', JSON.stringify(posts));
        }

        function createPost(content) {
            posts.unshift({ content: content, likes: 0 });
            saveData();
            renderTimeline();
        }

        function renderTimeline() {
            const container = document.getElementById('timeline');
            container.innerHTML = '';
            posts.forEach((post, index) => {
                container.innerHTML += `<div class='timeline-post'><p>${post.content}</p></div>`;
            });
        }

        function toggleVR() {
            if (!navigator.xr) {
                alert('WebXRがサポートされていません。');
                return;
            }

            navigator.xr.requestSession('immersive-vr').then(session => {
                const vrCanvas = document.createElement('canvas');
                vrCanvas.width = window.innerWidth;
                vrCanvas.height = window.innerHeight;
                vrCanvas.style.width = '100vw';
                vrCanvas.style.height = '100vh';
                vrCanvas.style.position = 'fixed';
                vrCanvas.style.top = 0;
                vrCanvas.style.left = 0;
                vrCanvas.style.background = 'black';
                document.body.appendChild(vrCanvas);

                const ctx = vrCanvas.getContext('2d');
                ctx.fillStyle = 'white';
                ctx.font = '30px Arial';
                ctx.fillText('VRモード:仮想空間に没入中', 50, 100);

                drawVREnvironment(ctx);

                loadUnityAsset(ctx);
                loadUnrealAsset(ctx);

                session.end().then(() => {
                    document.body.removeChild(vrCanvas);
                });
            }).catch(err => {
                alert('VRセッションの開始に失敗しました。');
                console.error(err);
            });
        }

        function drawVREnvironment(ctx) {
            ctx.fillStyle = '#0f0';
            ctx.beginPath();
            ctx.arc(200, 200, 50, 0, 2 * Math.PI);
            ctx.fill();
            ctx.fillStyle = '#f00';
            ctx.fillRect(300, 150, 100, 100);
            ctx.fillStyle = 'cyan';
            ctx.font = '20px Arial';
            ctx.fillText('仮想オブジェクト: 球体と立方体', 50, 300);
        }

        function loadUnityAsset(ctx) {
            ctx.fillStyle = 'yellow';
            ctx.font = '20px Arial';
            ctx.fillText('Unityアセット読み込み: キャラクター', 50, 350);
        }

        function loadUnrealAsset(ctx) {
            ctx.fillStyle = 'orange';
            ctx.font = '20px Arial';
            ctx.fillText('Unreal Engineアセット読み込み: シーン', 50, 400);
        }

        function toggleDarkMode() {
            document.body.classList.toggle('dark-mode');
        }

        window.onload = renderTimeline;
    </script>
</head>
<body>
    <header>
        <h1>Verse VR SNS</h1>
        <button class="cta-button" onclick="toggleVR()">🎮 VRモード</button>
        <button class="cta-button" onclick="toggleDarkMode()">🌙 ダークモード</button>
    </header>

    <div class="nav-container">
        <div class="nav-menu">
            <a href="#" onclick="renderTimeline()">ホーム</a>
        </div>
    </div>

    <div class="content">
        <h2>新規投稿</h2>
        <textarea id="postContent" class="form-control" placeholder="いま何してる?"></textarea><br>
        <button class="cta-button" onclick="createPost(document.getElementById('postContent').value)">投稿</button>

        <section id="timeline" class="timeline"></section>
    </div>

    <div class="footer">&copy; 2025 Verse VR SNS</div>
</body>
</html>

Full Dive Virtual Reality

フルダイブVRとは

フルダイブVR(Full Dive Virtual Reality)は、ユーザーが現実世界から完全に切り離され、仮想世界に五感すべてを没入させる革新的な技術を指します。この概念は、ライトノベルやアニメ『ソードアート・オンライン』で人気を博したもので、ユーザーはヘッドセットやデバイスを通じて脳に直接信号を送り、視覚、聴覚、触覚、味覚、嗅覚をシミュレートします。現実のVR技術(例: Oculus QuestやMeta Questシリーズ)は主に視覚と聴覚に焦点を当てていますが、フルダイブVRは脳神経科学とコンピュータサイエンスの融合により、ユーザーが仮想空間で「生きる」ような体験を提供します。ただし、2025年現在、この技術はまだフィクションの域を出ておらず、完全な実現には医療、倫理、技術的な障壁が数多く存在します。このガイドでは、現実の技術を基に理論的な作り方を説明しますが、実際の構築は専門家による研究開発を推奨します。安全性を最優先に考え、脳に干渉する実験は絶対に行わないでください。

必要な技術と基礎知識

フルダイブVRを作成するためには、複数の分野の知識が不可欠です。まず、脳コンピュータインターフェース(BCI: Brain-Computer Interface)が核心となります。これは、NeuralinkやBrainGateのような既存の技術を参考に、脳波を読み取り、仮想信号を脳に送信するシステムです。視覚や聴覚のシミュレーションには高解像度のグラフィックスエンジン(例: Unreal EngineやUnity)が必要で、触覚を再現するためにはハプティクス技術(振動や温度変化を伴うフィードバックデバイス)を拡張します。さらに、味覚と嗅覚の再現は化学センサーや神経刺激装置を組み合わせる必要があります。これらの技術を統合するため、AIアルゴリズムがユーザーの脳信号をリアルタイムで処理し、仮想世界を生成します。ハードウェア的には、高性能のGPU、EEG(脳波計)センサー、侵襲型または非侵襲型の神経インプラントが求められます。ソフトウェア側では、セキュアなネットワークとデータ暗号化が必須で、ユーザーの安全を守るための緊急脱出プロトコルも組み込むべきです。このような基盤を築くことで、フルダイブVRのプロトタイプが理論的に可能になりますが、現実では倫理委員会の承認と多額の資金が必要です。

作り方のステップ

フルダイブVRの作成は、段階的なアプローチを採用します。以下に、理論的なステップを詳述します。各ステップは、現在の技術を基にした推論であり、実際の実施には専門的な知識と設備が必要です。まずは小規模なプロトタイプから始め、徐々に拡張することをおすすめします。

  • ステップ1: システムの設計と計画
    最初に、フルダイブVRの全体像を設計します。仮想世界のシナリオ(例: ファンタジー世界や現実シミュレーション)を定義し、必要な五感のマッピングを作成します。例えば、視覚は3Dレンダリングで、触覚は神経信号の模擬で再現します。ツールとして、PythonやC++でシミュレーションソフトウェアを構築し、脳信号の入力/出力モデルを数学的に表現します。たとえば、脳波の周波数を仮想刺激に変換する式として、$$ \theta = f(\alpha + \beta) $$ を用い、αを入力信号、βをフィードバックとして計算します。この段階で、倫理的考慮(例: ユーザーの同意とリスク評価)を文書化し、プロジェクトのロードマップを作成します。計画がしっかりしていれば、後続のステップでトラブルを最小限に抑えられます。
  • ステップ2: ハードウェアの構築
    次に、物理的なデバイスを組み立てます。非侵襲型BCIとして、EEGヘッドセット(例: EmotivやOpenBCI)を基にカスタマイズし、脳波を検知します。侵襲型を目指す場合(推奨しませんが)、Neuralinkのようなインプラントをシミュレートします。触覚デバイスとして、振動モーターや温度制御ユニットを追加し、仮想オブジェクトとの相互作用を可能にします。電源供給と冷却システムを確保し、全体をヘルメット状のデバイスに統合します。このプロセスでは、電子工学の知識が不可欠で、回路図を作成してプロトタイピングします。テスト時には、ダミー信号で安全性を確認し、過熱や誤作動を防ぐためのセンサーを搭載します。
  • ステップ3: ソフトウェアの開発
    ソフトウェアはフルダイブVRの心臓部です。UnityやUnreal Engineを使って仮想環境を構築し、AIでユーザーの行動を予測・応答します。コード例として、Pythonで簡単な脳信号処理スクリプトを作成します:
  import numpy as np
  from bci_library import BrainSignalReader  # 仮定のライブラリ

  def process_brain_signal(signal):
      # 脳波を仮想刺激に変換
      filtered_signal = np.fft.fft(signal)  # 周波数解析
      virtual_response = np.real(filtered_signal) * 1.5  # フィードバック生成
      return virtual_response

  reader = BrainSignalReader()
  while True:
      raw_signal = reader.read()
      response = process_brain_signal(raw_signal)
      # 仮想世界に送信
      send_to_vr(response)

このスクリプトは、脳信号をフィルタリングし、仮想応答を生成します。五感の統合のため、APIを介して視覚、聴覚、触覚モジュールを同期させます。デバッグ時には、仮想テスト環境でシミュレーションを行い、遅延を最小限に抑えます。

  • ステップ4: テストと最適化
    プロトタイプができたら、安全な環境でテストします。最初は視覚のみの没入から始め、徐々に五感を追加します。ユーザーのフィードバックを収集し、AIでシステムを最適化します。例えば、快適さを測る指標として、$$ \text{Immersion Score} = \frac{\sum_{s=1}^5 w_s \cdot q_s}{5} $$ を使用し、各感覚(s)の質(q_s)と重み(w_s)を評価します。問題が発生した場合(例: 吐き気や幻覚)、即時停止機能を実装します。このステップを繰り返すことで、システムの信頼性を高めます。
  • ステップ5: 展開とメンテナンス
    最終的に、完成したシステムを展開します。商用化を目指すなら、規制当局の承認を得て、ユーザー教育プログラムを作成します。メンテナンスとして、定期的なソフトウェアアップデートとハードウェアチェックを行い、セキュリティを強化します。フルダイブVRは進化する技術なので、継続的な研究が鍵です。

課題と注意点

フルダイブVRの作成には、数多くの課題があります。技術的には、脳信号の正確な解読が難しく、誤作動による精神的なダメージのリスクがあります。倫理的には、プライバシー侵害や依存症の可能性が懸念され、法的規制が厳格です。また、コストが高額で、個人レベルでの実現はほぼ不可能です。2025年の技術トレンドとして、BCIの進歩(例: Neuralinkの臨床試験)は有望ですが、フルダイブレベルには到達していません。万一実験する際は、医療専門家と協力し、絶対に自己責任で進めないでください。このガイドは教育目的のものであり、フィクションの魅力を現実的に探求するものです。将来的に、この技術がエンターテイメントや医療を変革する日が来るかもしれませんが、安全第一を心がけましょう。

アンリアルエンジンVRまとめ

コンテンツへとスキップする

あなた:

https://www.moguravr.com/uevr-review

ChatGPT:

こちらはいわゆる「UEVR」――Unreal Engine製ゲームにVR対応を後付けする改変ツールについてのレビュー記事ですね。以下に要点をまとめました👇


🧩 UEVRとは何か?

  • “Universal Unreal Engine VR Mod”という非公式ツールで、Unreal Engine 4/5で作られたほぼすべてのゲームを6DoF(全方向の動きと回転)対応でVR体験化できます Reddit+15UploadVR+15Reddit+15。
  • 対応ヘッドセットはQuestやValve Index、Pimaxなど多岐に渡り、OpenVR/OpenXRの両方に対応 cumberland.org+2uevr.io+2GitHub+2。

🎮 動作の仕組み

  • ゲーム実行中に「注入(inject)」処理を行い、Unreal Engineのネイティブなステレオ描画やポジショントラッキングを強制的に有効にします 。
  • レンダリング方式は3種類:
    1. Native Stereo(理想的。最も自然で高画質)
    2. Synchronized Sequential(バグ回避向けだがゴーストやブラーが出る可能性あり)
    3. Alternating/AFR(交互描画。遅延や不安定さが出る場合あり)UploadVR+4GitHub+4uevr.io+4

✅ 動作実績と使いやすさ

  • 約600本以上のUE4/5ゲームで動作確認済み 。
  • ゲームごとに互換性スプレッドシートが整備されており、「Works Perfectly」や「Works Well」等で動作レベルを確認可能 360 Rumors。
  • Redditでも「Beardo is my favorite review of UEVR so far.」と高評価されるなど、コミュニティ内での評価も上々 GAMINGDEPUTY+15Reddit+15Meta Community Forums+15。

🔧 使用手順(概要)

  1. UEVRのzipを解凍し、UEVRInjector.exeを起動
  2. 対象のUnrealゲームを起動
  3. プロセス選択後、OpenVR/OpenXR方式を選び「Inject」
  4. ゲーム内に起動メニューが出現
  5. 設定変更(UI位置、スケール調整など)
  6. 選ぶレンダリングモードに合わせてプレイ開始 Steam Community+14GitHub+14GitHub+14GitHub+1uevr.io+1
  • 一度設定をすればプロファイルとして保存され、次回以降は自動的に同条件で起動可能 。

💬 利用者の声(Reddit抜粋)

“Beardo is my favorite review of UEVR so far.” GAMINGDEPUTY+15Reddit+15YouTube+15
“UEVR is a great way for a developer to quickly see how their game might work if they were to make a full VR port themselves.” pcgamer.com+9Reddit+9UploadVR+9


📹 動画解説(ハイライト)

UEVRの実際の導入方法や動作例を見るならこちらの動画がおすすめです:


🧠 総まとめ

ポイント説明
メリット・多くのUEゲームをVR体験化
・無料&オープンソース
・動作確認済タイトルも豊富
注意点・公式VR対応とは異なり、一部UIや操作が不安定になる可能性あり
・レンダリングモード選択や設定が必要
・安定性はゲームごとに異なる

✨ もしご興味あれば…

  • 特定のゲームでの動作や相性について調べたいなら、スプレッドシートを共有できます。
  • 導入や設定について詳しく知りたい場合は、手順やトラブルシューティングもご案内可能です。

必要であればいつでもどうぞ〜!

あなた:
https://www.unrealengine.com/ja/spotlights/vr-medical-simulation-from-precision-os-trains-surgeons-five-times-faster
ChatGPT:
https://cdn2.unrealengine.com/Unreal%2BEngine/spotlights/vr-medical-simulation-from-precision-os-trains-surgeons-five-times-faster/Spotlight_PrecisionOSBlog_Body_Image_10-1640x900-7c345416096e33e3c0101f28d96925ca20785d61.jpg
https://cdn2.unrealengine.com/Unreal%2BEngine/spotlights/vr-medical-simulation-from-precision-os-trains-surgeons-five-times-faster/Spotlight_PrecisionOSBlog_Body_Image_1-1640x900-ca437838a01c6e8549fa48edd51e7cf22f7d0113.jpg
https://cdn2.unrealengine.com/Unreal%2BEngine/spotlights/vr-medical-simulation-from-precision-os-trains-surgeons-five-times-faster/Spotlight_PrecisionOS_Feature_V2-1920x960-e20d533ebcfaa881f58cc9dc2c07146998d3e0fe.jpg
https://assets.beesens.com/contents/slides/1553773966hJEn9.jpg

こちらは、Precision OSによるVR外科トレーニングを紹介したUnreal Engine公式スポットライト記事**「VR medical simulation from Precision OS trains surgeons five times faster」**です。以下に要点を分かりやすくまとめました👇


🩺 Precision OSとは?

  • バンクーバー拠点の医療シミュレーション会社で、整形外科などの手術手技をリアルなVR環境で訓練できるプラットフォームを開発しています YouTube+11Unreal Engine+11Unreal Engine+11。
  • Unreal Engineをベースに、クオリティの高いグラフィックと直感的操作を実現しています 。

🎯 教育におけるメリット

  • 従来の人骨モデルや遺体では体験できない「症例の変化」を繰り返し練習可能。
  • フライトシミュレーターのように「失敗して学ぶ」場を提供できるため、安全かつ効率的です 。

⚡ 効果:学習スピードは5倍!

  • 独立した研究により、通常トレーニングと比べてVRグループの習得速度が**570%(=約5.7倍)**向上したことが報告されています beesens.com+6Unreal Engine+6Unreal Engine+6。
  • 技術面のスキルだけでなく、知識習得の速度も大きく向上したといいます 。

🌍 グローバルな展開

  • NGOのSIGN Fracture Careと連携し、365病院・53ヶ国にOculus Questヘッドセットを配布して遠隔トレーニングを展開 Unreal Engine+1Unreal Engine+1。
  • 従来は費用や距離の壁があった手術訓練を、VRで遠隔でも実践的に実施できるようにしています。

🧩 Unreal Engineを選ぶ理由


✨ 総まとめ

項目内容
✅ メリット・多様な症例を安全に反復練習できる<br>・学習速度が5倍以上に向上<br>・リモート展開でコスト削減とアクセス向上
⚠️ 課題・ハード(VR機器)導入と運用コスト<br>・ハプティクス等、リアルな触覚の再現はまだ完全ではない

🎯 今後の展望にも注目!


もっと深く知りたいポイントがあれば遠慮なくどうぞ!

  • たとえば SIGNとの提携詳細、触覚インターフェース等の技術面、
  • または他社(Oxford Medical Simulationなど)との比較なども調べられます。

ご興味のあるところ、ぜひ教えてくださいね😊

あなた:
https://dev.epicgames.com/documentation/ja-jp/unreal-engine/virtual-reality-development?application_version=4.27
ChatGPT:
https://cdn2.unrealengine.com/blogAssets/2016/Feb/Feb_04/UEVREditor_SHARE-1200x630-1512467674.jpg
https://i.ytimg.com/vi/cB94bqv5GqA/maxresdefault.jpg
https://i.ytimg.com/vi/vT1T2unF8EI/maxresdefault.jpg
https://richmediatech.com/blog/wp-content/uploads/2024/07/13404816.jpg

Unreal Engine 4.27 の公式 VR 開発ドキュメントをもとに、主要ポイントをわかりやすく解説します。


🎮 VR フレームワークの概要

UE4.27 は、HMD とモーションコントローラを使った VR アプリを構築するための統合的なフレームワークを備えています。対応プラットフォームには Oculus Rift、HTC Vive、SteamVR、PS VR などがあります Epic Games Developers+13Epic Games Developers+13Epic Games Developers+13Epic Games Developers。

  • VR Mode(エディタ内 VR):VR 空間でのレベル編集に対応し、モーションコントローラで直感的な操作が可能 。
  • Spectator Screen:HMD を装着していない第三者にも VR の視覚をモニタに表示でき、開発時やプレゼンに便利 Epic Games Developers。

📚 開発サポートガイド

ドキュメントには、次のセクションがまとめられており、段階的に VR 開発を学べます :

  • Platforms:各 HMD ごとのセットアップ手順。
  • How‑To’s:インタラクションや移動実装などのチュートリアル。
  • Best Practices:VR 体験を快適に保つための設計ルール。
  • Performance & Profiler:GPU/CPU におけるパフォーマンス測定・最適化の方法 Epic Games Developers+1Epic Games Developers+1。

🛠 詳細機能と便利なツール

Visual Scripting(Blueprint)

ノードベースでの VR インタラクションやゲーム要素の設計が可能。非プログラマ向けにも強力 。

VR Cheat Sheet(コマンド早見表)

- VR Preview:エディタでの VR プレビュー
- UE4Editor.exe -game:独立起動
- VR 関連コンソールコマンド多数あり

など、開発中に頻繁に使う操作を網羅 。

パフォーマンス

VR はフレームレートの安定が極めて重要。UE4.27 では、コンソール変数(r.*)を用いた簡単な最適化から、CPU/GPU プロファイリングツールの利用まで解説 。


⚙️ 4.27 版ならではの更新点

  • nDisplay の VR 対応:複数スクリーンによる VR クラスター構築が容易に Epic Games Developers。
  • Chaos Physics:リアルなオブジェクト破壊表現が可能。VR の臨場感向上に一役 。

🎯 VR 開発フローまとめ

  1. HMD と SDK をセットアップ
  2. プロジェクトに VR Mode を有効化
  3. エディタ内で VR Preview / VR Mode を常用
  4. Blueprint で VR 操作や UI を組む
  5. Spectator Screen を使って外部視覚も管理
  6. パフォーマンス最適化を実施
  7. 複雑なケースでは nDisplay や Chaos の応用も

✨ 今すぐできること

  • Oculus や Vive 向け VR プロジェクトを0から構築可能
  • VR インタラクションの主要実装(掴む、移動、インターフェース)に Blueprint を活用
  • 観客用スクリーン表示でレビューやデモも容易に
  • フレームレート最適化とパフォーマンス管理が公式にサポート

もし特定のテーマ(例:「VR ハンドトラッキングの実装方法」や「Spectator Screen のカスタマイズ」)、あるいは UE5.x での最新 VR 機能にご関心があれば、気軽に教えてください!より深くご案内します😊

https://cdn2.unrealengine.com/Unreal%2BEngine/blog/mindesk-offers-cad-modeling-in-vr-with-real-time-rendering-courtesy-of-unreal-engine/blog_share_img-1200x630-2d4093182dff9b98270a2ac6c1acaeb303b4a966.jpg
https://cdn2.unrealengine.com/Unreal%2BEngine/spotlights/meshmatic-optimizing-cad-data-for-interactive-visualization/Spotlight_VRSquare_blog_body_img5-1640x941-0e6830abfa607dfec6fe9c920c7230d052c4c34a.jpg
https://cdn2.unrealengine.com/Unreal%2BEngine/spotlights/nouveau-architectural-visualization-vr-walkthroughs-groupe-legendre/blog_body_img4-1640x1000-cd304916a34825486a822b2101d3a18cb09b8aec.jpg
https://cdn2.unrealengine.com/blogAssets/2016/Feb/Feb_04/UEVREditor_SHARE-1200x630-1512467674.jpg

ご紹介の「キャド研」サイトでは、Unreal Engine を使った VR×CAD/3Dビジュアライゼーション活用について、公式スポットライト記事や導入事例が多くまとめられています。以下、主なトピックを整理しました👇


1. Mindesk – CADをVR空間でリアルタイム操作


2. Meshmatic + Datasmith – CADデータの最適化自動化

  • 大規模なCADファイルを、VRやリアルタイム表示向けに軽量化。元は数か月かかる作業が「1時間以内」に完結 。
  • Datasmith(Unreal公式のインポートツール)と組み合わせることで、最適化済モデルをそのままUEに取り込め、開発効率が大幅アップ Unreal Engine+3Unreal Engine+3Unreal Engine+3。

3. VRモードによるエディタ操作強化


🔍 小結

活用領域概要
リアルタイムVRモデリングMindeskで設計プロセスそのものをVRへ
大規模CADデータ対応Meshmatic + Datasmithで大規模ファイルの効率化
VRエディタUEエディタ自体をVRで操作して没入型開発が可能

🚀 次に調べられるテーマ

  • Mindeskの最新対応(UE5やQuest 3対応など)
  • MeshmaticとDatasmithを使ったワークフロー詳細
  • VR Mode利用下でのBlueprpintやアセット配置の具体例
  • VR設計プロトタイプ事例(建築・工業デザインなど)

どれにご興味ありますか?より深い解説や具体的な事例・手順をご案内できます!

https://www.uploadvr.com/content/images/size/w1200/2024/01/UEVR-feature-1.png
https://unrealenginefrance.com/wp-content/uploads/2024/01/UEVR3-1024x585-1.webp
https://www.backtovr.it/wp-content/uploads/2024/01/UEVR-INTRO-1.jpg
https://360rumors.com/wp-content/uploads/2023/12/Fh7-a5Pr1pYhd.jpg

こちらは「UEVR(Universal Unreal Engine VR Mod)」についてのまとめです。moguraVRの記事を元に、海外やコミュニティの情報も精査しました👇


🧩 UEVRとは?

  • UE4(4.8以上)やUE5で作られたほぼすべてのPCゲームをVR化できる無償・オープンソースのモッドツールです YouTube+10UploadVR+10thevrnexus.com+10。
  • Unreal Engine内蔵のVRレンダリング機能を強制的に有効化し、ヘッドトラッキングやステレオ視などを導入します 。
  • Oculus、SteamVR、OpenXR対応のヘッドセットに幅広く対応しており、Rift、Vive、Index、Quest(Link/Virtual Desktop経由)などに対応 YouTube+4UploadVR+4backtovr.it+4。

⚙️ 主な特徴とモード

  • Native Stereo(ネイティブ二眼視): 最も高品質で没入感◎
  • Synchronized Sequential(同期順序方式): 表示安定性を取るがゴーストが発生しやすい
  • Alternate Frame Rendering (AFR): FPS高いがレイテンシや不安定さ注意 VR WaveUploadVR+1VR Wave+1。
  • 6DoF対応:ルームスケールとモーションコントローラ入力による位置追従が可能 。
  • UIはVR空間内の仮想スクリーンに投影、設定はVRオーバーレイメニューから調整可 。

📚 利用の流れ

  1. SteamVRを起動
  2. ゲームを立ち上げた後でUEVRInjector.exeを管理者として起動
  3. 対象ゲームプロセスを選び、OpenVRかOpenXRを指定
  4. 「Inject」でVR化
  5. ゲーム内でInsertキーや両スティック同時押しで設定メニュー呼び出し 。

✅ 動作対象・互換性


💬 コミュニティと拡張性

  • Flat2VR Discordでは、ユーザーごとのプロファイル共有が活発で、設定プリセットも手に入る backtovr.it+1VR Wave+1。
  • Rai Palというランチャー的な外部ツールも登場し、インストール・起動・プロファイル管理がスムーズに UploadVR。

⚠️ 注意点

  • ベータ段階のため、未対応のゲームや不具合発生の可能性あり 。
  • VR動作に必要な高スペックPCが前提で、画質調整や最適化が求められます 。
  • UIや操作感が公式VR実装ほど自然ではない場合がある(物理的な掴みやリロード等) 。

🌐 全体まとめ

UEVRは、**公式VR非対応のUEゲームをVRで楽しむための“万能鍵”**とも言えるツールです。
対応可能タイトルは驚異の11,000本超、無料・オープンでかつ現状ベータ版ながらコミュニティの支援も確かなもの。
UI設計やパフォーマンスには多少の調整が必要ですが、標準的なPC環境でも多くのゲームをVR化して遊べる点は魅力的です🎮


🛠 知りたいことは?

  • 特定ゲームでの動作確認や最適化プロファイル
  • Rai Palの使い方や導入手順
  • モード別の比較(Native/Synced/AFR)

など、ご興味ありましたらお気軽にご質問ください!

https://cdn2.unrealengine.com/leehyunwoo-720x960-7eb07fcedf09.png
https://cdn2.unrealengine.com/10-comparison-of-rendering-image-and-actual-result-2472x1173-a59602d011a5.jpg?resize=1&w=1920
https://cdn2.unrealengine.com/1-from-the-start-of-oneness-to-gwacheon-national-science-museum-planetarium-showing-1920x893-8641fb605582.png?resize=1&w=1920
https://cdn2.unrealengine.com/7-1-neutron-blueprint-and-definition-map-1920x800-f877b6debba6.png?resize=1&w=1920

以下は、ソウル芸術大学の学生たちによる VR と Unreal Engine を活用したプラネタリウム作品「ONENESS」開発の概要です。


🎬 プロジェクト概要

  • チーム構成:デジタルアート専攻4名+実用音楽専攻1名、計5名で構成され、Hyunwoo Lee氏がディレクター&テクニカルアーティストとして率いた
  • 開催場所:果川国立科学館(直径25メートルのドームスクリーン)および2020年秋の学生ショーケースで発表 Unreal Engine+3Unreal Engine+3Unreal Engine+3Unreal Engine

⏱ 開発背景と課題

  • 本来、大規模ドーム映像の制作には高コスト・長期間が必要
  • 今回、3ヶ月で15分間のコンテンツを制作する必要があり、時間的制約が非常に厳しかった Unreal Engine+1Unreal Engine+1
  • さらに、ドームへの合成時に生じる映像の歪み問題の検証が、月2回の現地テストしかなく、効率が悪かった Unreal Engine

🥽 VRを使ったソリューション

  • Unreal Engine 上にドーム会場をVRで再現し、自宅等で視聴環境を仮想再構築
  • 座席配置、ドーム傾斜、半球面スクリーン等を正しく再現し、実際に近い歪みチェックが可能に ウィキペディア+7Unreal Engine+7Bard Tales+7
  • 即時フィードバックによる調整が可能となり、本来かかった時間を大幅短縮

🛠 技術的ハイライト

Niagara × Sequencer

  • パーティクル表現を Niagara で構築し、Sequencer からタイミングやエフェクトパラメータを制御 Bard Tales+5Unreal Engine+5Unreal Engine+5
  • UI でオパシティ・スピードなどを制御し、リアルタイムプレビュー付きで調整可能に

Blueprint による科学的シミュレーション

  • ビッグバン直後の原子核融合プロセスなど、微視的現象を再現する自動化ロジックを Blueprint で実装
  • 膨大な数の粒子を Sequencer でキーフレーム制御する代わりに、イベントトリガー+タイムライン制御で効率的かつ表現力豊かな表現が可能に Unreal Engine+1Unreal Engine+1

✅ 成果まとめ

  • 3ヶ月で完成という短納期ながら、高品質なプラネタリウム映像を制作
  • VR による仮想検証環境構築により、時間・コスト・歪み問題を実質的に解消
  • Niagara+Sequencer、Blueprint を活用した高度なビジュアル表現と自動化による制作効率向上

💡 学び・応用ポイント

  • VR環境の複製:大型スクリーンや空間特性を事前検証して映像制作に活かす手法
  • ビジュアルスクリプト×リアルタイムエフェクト:アート作品/科学教育/展覧会などで応用可能
  • Blueprint による動的シミュレーション:教科内容(物理・宇宙・化学など)をインタラクティブに可視化できる

もしさらに詳しく知りたい点があれば、ぜひ教えてください:

  • VR環境のセットアップ方法
  • NiagaraとBlueprintの組み合わせ手法の詳細
  • 同様のワークフローを他の教育コンテンツに応用する場合の展開アイディアなど

お気軽にどうぞ!😊

あなた:
https://developers.meta.com/horizon/documentation/unreal/unreal-engine-basics/?locale=ja_JP
ChatGPT:

こちらは、Metaの開発者サイトに掲載された、「Meta Horizon OS向けにUnreal EngineでPC‑VRアプリを開発する基本的なガイド」です。概要を以下に整理しました👇


🎯 HMD(Meta Questなど)向けVR開発の全体像

Metaの開発者向けガイドは、Unreal Engineを使ってQuestなどのMeta Horizon OS対応HMD向けアプリを作るための包括的な手引きです。
Questをはじめとしたヘッドセットをターゲットとし、PC‑VR向け開発と共通する要点をサポートしています Facebook Developers+3Meta Developers+3Meta Developers+3。


🔌 シンプルな導入フロー

  1. Meta XRプラグイン or OpenXR(Oculus拡張付き)を有効化
  2. プラットフォーム設定でAndroid向け環境を整える(SDK/NDKなど)
  3. HMDを接続し、VR PreviewやMigrate to device形式で動作確認

PC‑VR開発時と比べても、比較的スムーズにMeta Questへ展開可能 Epic Developer Community Forums。


🧰 ドキュメント内容の構成

  • セットアップ:OpenXRやMeta Quest向けプラグイン設定手順(Android SDK/NDK含む)
  • XRプレビュー:エディタでVR空間プレビュー、「VR Mode」や「VR Preview」でのデバッグ
  • パフォーマンス管理:モバイルVRでは特に重要なCPU/GPU負荷、プロファイリング手法の説明
  • 配信準備:デバイスへのパッケージ転送、Meta Store(Questストア)向けの設定ガイド

📝 コミュニティ・実践的情報


✅ まとめ:Meta Horizon向けUnreal開発のポイント

フェーズ内容
導入Meta XRプラグインの導入 → Android環境構築(SDK/NDK整備)
開発中VR Previewによるインタラクション確認、パフォーマンス監視
デプロイQuestヘッドセットへAPK配信 → Meta Store提出用設定
参考資料Meta公式ドキュメント、Horizon Creator Manual、コミュニティチュートリアル

🚀 次に深堀できるテーマ

  • Meta Quest 3への最適化設定(SDK/NDKのバージョン調整など)
  • Meta XR + OpenXR の組み合わせによる最良パフォーマンス例
  • Meta Store提出に必要なManifestや署名設定の詳細
  • Horizon WorldsやMeta Avatarsとの連携

もし特定の話題や実装要件(Quest 3、ハンドトラッキング、パフォーマンス改善等)があれば、お知らせいただければ詳細を掘り下げてご案内します! 😊

こちらは、Zennユーザー「えいとびーと」さんによる Unreal Engine × Webカメラ1台だけでフルトラッキングVtuber配信環境を構築 した記録ですね。解説と補足を添えてご紹介します👇


🔧 プロジェクト概要

  • 目的:VRフィットネスを実況配信しつつ、Unreal Engineで配信スタジオを作成。
  • 手段:「Webカメラ1台+顔や骨格認識」でフルトラッキングVtuberを実現 (turn0search0)。

🎯 使用ツール一覧

  1. Unreal Engine
  2. OWLプラグイン(OBSとの連携)
  3. OBS:配信ソフト
  4. TDPT(Three D Pose Tracker):Webカメラ画像から全身骨格検出するモーショントラッカー、精度高めでおすすめとのこと (turn0search0)。

🚀 技術的なセットアップ手順

  1. TDPT で骨格検出:広角Webカメラで全身を映す必要あり。
  2. VMC4UE + ueOSC を使って、TDPTのリアルタイムトラッキングを OSC 経由で Unreal に受け渡し (turn0search0)。
  3. VRM アバターのインポート:VMC4UE用に VRMMapExporter や Humanoid 設定を編集し、Blueprint でアバターに動きを反映 (turn0search0)。
  4. OWLプラグイン で Unreal→OBS に映像を送出し、配信ソフトと統合できる。

✅ メリット・工夫ポイント

  • 安価で気軽なフルトラV配信環境:モーションキャプチャ専用機材不要。
  • Webカメラベースで十分なトラッキング精度を実現。
  • VRMアバターと Unreal を連携するための実用的構成(TDPT+OSC+VMC4UE+ueOSC+OWL)。

🌱 さらなる改善や応用の可能性

  • 広角カメラの選定例や設置角度の最適化
  • 頭部以外のトラッキング精度を上げる補助技術(手や指の追加検出など)
  • Unreal Studio的な配信スタジオ背景や演出の構築例

もし気になる点がありましたら、例えば:

  • TDPTのインストール・チュートリアル
  • VMC4UE/ueOSC の具体設定方法
  • Unreal 内での Blueprint 組み方

といった部分について、さらに詳しくサポートできますのでお気軽にどうぞ!😊

あなた:
https://www.unrealengine.com/ja/spotlights/building-virtual-cities-and-digital-twins-with-unreal-engine
ChatGPT:
https://cdn2.unrealengine.com/digital-twins-zoan-body-1920x1080-ce6fd6e1d01a.jpg?resize=1&w=1920
https://cdn2.unrealengine.com/digital-twin-share-img-1-1200x630-7fe932bf539a.jpg
https://cdn2.unrealengine.com/body-image-digital-twins-1920x1080-lunas-pro-1920x1080-f2f696bd6b77.png?resize=1&w=1920
https://cdn2.unrealengine.com/gallery-image-digital-twins-4k-wellington-1-3840x2160-3ba6c3084821.png?resize=1&w=1200

Unreal Engine公式による「Building virtual cities and digital twins with Unreal Engine」スポットライト記事を中心に、都市や建築物といった現実世界のデジタルツイン構築の取り組みを詳しくご紹介します👇


🌇 デジタルツインとは?

  • 3Dモデルにリアルタイムデータ(交通、センサー、IoTなど)を組み込むことで、「動く/反応する」実世界の仮想ツインを作ります Planning, Building & Construction Today+11Unreal Engine+11Unreal Engine+11。
  • 単なる「スマートシティ」との違いは、3Dモデルを活用してリアルな視覚で「状況を把握・分析・最適化」できる点 。

🚀 なぜ UE が選ばれるのか?

  • 高度な視覚・没入感
    • Blueprint により非エンジニアでも手軽に開発可能。リアルタイムデータと即時インタラクションが可能 。
  • 大規模データに強い
    • GISやCAD/BIMデータをDatasmith経由で取り込み、大都市モデルでもリアルタイム表示が可能 Unreal Engine+1Unreal Engine+1。
  • ライブデータ連携
    • REST API経由でセンサー等のデータを取り込め、常に最新の情報を反映 。

🌍 実際の適用事例


🛠 デジタルツイン構築フロー

  1. 用途・対象を定義
    範囲(建物、地区など)と目的(交通改善、運用効率など)を明確化 Unreal Engine+3Program-Ace+3Unreal Engine+3。
    1. 3Dモデル構築・最適化

    CAD/BIMデータやフォトグラ、GISからモデルを取り込み、パフォーマンス重視の最適化を実施 Planning, Building & Construction Today+14Unreal Engine+14Program-Ace+14。
  2. ライブデータ取り込み
    IoTセンサーや公共APIからデータ取得、接続パイプを整備 。
    1. 可視化+対話設計

    データ可視化(グラフ、ヒートマップ等)や、ユーザーによる視点変更・シミュレーション設定を実装 。
  3. 最適化と評価
    表示パフォーマンスやレスポンスを測定・改善しながら実用化へ。

📈 メリット・課題

✔ メリット

  • 意思決定の迅速化・視認性の向上
  • シナリオ検証による事前問題予見
  • 多機関にまたがるデータ共有と連携が円滑に

⚠ 課題

  • 大量データや高解像度視覚表現のパフォーマンス負荷
  • セキュリティ・プライバシー(個人情報やインフラ情報取り扱い)
  • 初期導入における投資(ハードウェア・データ取得エコシステム構築) 。

📊 今後の展望

  • UE5採用による高品質表示の効率化(Nanite・Lumen・World Partition等)
  • AIによる予測・自動最適化の導入
  • メタバースとの融合による都市と人が継続的に交差する仮想環境の実現 Program-Ace+1TIME+1。

🗣 次に気になるテーマは?

  • 大都市モデルの最適化具体手法(LOD設計、ストリーミング)
  • 公共データ活用(API連携、可視化テンプレート)
  • UE5を活用したリアルタイムな都市シミュレーションパイプライン設計

ご関心がある領域があれば、ぜひお知らせください。さらに深くご案内できます!😊

こちらは、Qiita に掲載された「Unreal Engine の VR Mode から Meta Quest 3 にインストールする方法」についての詳細なチュートリアル記事です。内容を整理してご紹介します👇


🎯 記事の目的

Unreal Engine 5.2 の VR テンプレートを使用し、VR Preview で作成したコンテンツをアプリとしてビルドし、Meta Quest 3 にインストールして動作させる手順をまとめた初心者向けガイドです Qiita。


✅ 環境

  • OS:Windows 10
  • Unreal Engine:5.2
  • メタ Quest 3 をターゲット HMD として使用 Qiita。

💡 導入フロー(記事の流れ)

  1. Unreal プロジェクトの作成
     VR テンプレートで新規プロジェクトを作成し、Plugin メニューから「Oculus VR」「OpenXR」を有効化 Qiita。
  2. Android ビルド環境構築
     Meta Quest は Android アプリ形式なので以下をインストール:
     - Android Studio 4.0(API レベル 32 / Build-Tools 30.0.3 / CLI Tools 8.0 / NDK 25.2.5919653)
     - JDK 8u391(Java 17 以上ではエラー発生のため) Qiita。
  3. SDK/NDK/JDK のパス設定
     Unreal の「Android SDK」設定画面で、インストールした SDK、NDK、JDK のパスを指定。NDK API Level は 32 に設定 Qiita。
  4. アプリのビルド
     メニューから「Android → プロジェクトのパッケージ化」を実行し、Android_ASTC フォルダに .apk が生成されれば成功 Qiita。
  5. Meta Quest 3 へのインストール
     Oculus Developer Hub 2.0 を使い、USB 経由で Quest を接続し、生成した APK をドラッグ&ドロップでインストール。Quest 内の「提供元不明のアプリ」から起動可能に Qiita。

⚙️ 注意点/ポイント

  • Java は JDK 8 を使用:最新の Java 17 や 21 ではビルドエラーが出るため、記事では 8u391 を推奨 Qiita。
  • Android 工具のバージョン指定が重要:特に API と NDK は正しいバージョンでないとビルド失敗につながるため、記事の設定を厳密に守るのがカギ 。
  • Oculus Developer Hub の使用で Quest への APK インストールがとても簡単になる。

🧭 まとめ

この記事は、Unreal Engine 初心者が「VR テンプレート→APK ビルド→Quest にインストール→動作」で実際にアプリを起動するまでの一連の手順を、図解と共に丁寧に解説しています。
初めて Quest 向けに VR アプリを作ろうという方には、特に外せない便利なガイドです😊


🔄 必要であれば…

  • UE5.3+Quest 3 を使った最新のビルド手順
  • Quest 2 や他デバイス向けの設定解説
  • ビルドエラー発生時のトラブルシューティング

など、深堀りした内容もご希望であればぜひお知らせください!

あなた:
https://yoshikawastudio.com/unreal-engine-5-vr01/
ChatGPT:
https://yoshikawastudio.com/wp-content/uploads/2024/09/MetaQuest1_eyecatch.webp
https://yoshikawastudio.com/wp-content/uploads/2024/09/image-59-2.jpg
https://yoshikawastudio.com/wp-content/uploads/2024/09/image-43.png
https://yoshikawastudio.com/wp-content/uploads/2024/09/image-59-4.jpg

以下は、Yoshikawa Studio(AICG Seminar)による「Unreal Engine 5 と Meta Quest 3 を接続し、VR のサンプルプロジェクトをプレイする」手順ガイドの要点です 👇


🎯 対象


✅ セットアップ概要

1. Meta Quest の準備と Quest Link インストール

  • USB‑C ケーブルでQuestをPCと接続し、PCにQuest Link(旧 Oculus Link)アプリをインストール。
  • Metaアカウント(旧 Oculus)を作成し、プロフィールやユーザーネーム、プライバシー設定を完了。
  • Quest Link 上で「OpenXRランタイム」をアクティブにし、「提供元不明のアプリ」を許可 AICGセミナー+1AICGセミナー+1。

2. Unreal Engine 5 上での VR テンプレート利用

  • Epic Games Launcher から Unreal Engine 5 を起動し、「新規 → ゲーム → バーチャルリアリティ」テンプレートを選択してプロジェクトを作成。
  • 上部ツールバーの再生ボタン横にあるモード選択を「VRプレビュー」にし、再生を開始する Reddit+7AICGセミナー+7YouTube+7。

3. VRプレビューがグレーアウトする場合の確認項目

  • USB ケーブルがQuest付属の高速転送タイプであるか確認(速度が低いと認識されないことあり)。
  • Quest Link が正しく起動しており、接続されているかをチェック。
  • Unreal の「プラグイン」で OpenXR(およびハンドトラッキング等)を有効化してエディタ再起動する AICGセミナー+1AICGセミナー+1。

4. VRプレビューのプレイと終了

  • Quest + コントローラで正常にVR環境下を歩き回れることを確認。
  • 終了はコントローラ側で「Real Life」を選ぶか、PC側でエスケープキーを押すことで終了できる AICGセミナー+2AICGセミナー+2AICGセミナー+2。

🌟 ガイドの総まとめ

フェーズ内容
✅ Quest 準備Quest Link のインストールとランタイム設定、アカウント&プロフィール設定
✅ UE5 設定VR テンプレートプロジェクトの作成、モード切替、OpenXR 有効化
✅ 動作確認VRプレビュー起動、問題があれば接続やプラグインを見直し

🔧 次に進むべきステップ

  • Windows へのパッケージ化(.exe出力)や Quest 向け Android APK ビルド記事へ進む流れあり AICGセミナー+1AICGセミナー+1。
  • さらに「Quest 3 向け最適化」「ハンドトラッキング実装」「パフォーマンスチューニング」などを深掘り可能です。

🎥 参考動画(英語)

  • “Create Your First VR Project in Unreal Engine 5 | Meta Quest 3” —初回導入~テンプレートプレイまでを動画で追える入門チュートリアル YouTube+3YouTube+3AICGセミナー+3

Meta QuestとUE5の基本連携は、この記事だけで十分スタート可能です。
もし次の段階(ビルド・配信・パフォーマンス改善など)に興味があれば、ぜひお知らせください!詳細をお手伝いします 😊

こちらは、Meta の開発者向けドキュメント「Create and Configure Your New Project」(Unreal Engine×Meta Horizon OS向けプロジェクト作成ガイド)邦訳ページの内容を整理したものです👇


🚀 新しいプロジェクトの作成手順

1. Epic Games Launcher から始める

2. プロジェクトテンプレートの選択

  • Games または Blank からプロジェクトタイプを選び、Meta XR / Oculus / OpenXR のプラグインを有効化。
  • プロジェクト名・保存先を設定し、「Create Project」で作成します 。

🛠 プロジェクトの初期設定(Project Setup Tool)

  • Unreal Editor のメニューで、
  • ウィザードでは以下を自動チェック/設定できます:
    • 対応する Meta Quest ランタイムの有効化
    • Android SDK/NDK/JDK のパス設定
    • 標準的な Android 用権限やマニフェストの生成(例:マイク、ストレージ権限など)

📦 APKパッケージ化と署名の準備

  • keystore(Androidアプリ署名用の鍵ファイル)を生成する手順が用意されています 。
  • Editor 上では、Edit → Project Settings → Platforms → Android 項目で生成した keystore を設定して APK 書き出しが可能になります。

✅ 推奨する開発ワークフローまとめ

フェーズ内容
1. UE5.4起動Unreal Engine 5.4 を Epic Games Launcher で起動
2. 新規プロジェクト作成Meta XR/OpenXR を有効にしたテンプレートで新規作成
3. セットアップウィザード実行Meta XR Project Setup Tool で環境構成を一括設定
4. Keystore設定Android署名用環境の構築と keystore生成
5. APKビルドAndroid 設定画面から APK を書き出し
6. デバイスにインストールUSB 経由や ADB/APK 配布で Quest に転送・実行

🔍 さらに深掘りできるポイント


🧭 次のステップ候補

  • Quest 3/Quest 2 向け APK のパフォーマンス最適化
  • ハンドトラッキング、空間オーディオ、パススルーなど高度機能の導入
  • Meta Store 提出用マニフェスト・署名設定の詳細案内

これらについてご関心があれば、ぜひ目標や環境に合わせてご相談ください😊

https://cgworld.jp/interview/images/202112-halfdive/04.jpg
https://cgworld.jp/news/assets_c/2021/12/news211221_02a-thumb-640x427-18824.jpg
https://xqimg.imedao.com/17c15542ca0244c3fda31fbc.jpg%21800.jpg
https://vr-compare.com/img/headsets/preview/diver-xhalfdive.png

これはCGWORLDでインタビューされた、19歳の学生起業家・迫田大翔さん率いるDiver‑X開発のVRヘッドセット「HalfDive(ハーフダイブ)」に関する記事です。その内容を掘り下げて紹介します👇


🎯 HalfDiveとは?


🧠 技術的コンセプト

  • 10枚の非球面レンズを搭載し、視野角を従来比1.5倍以上に拡大しつつ一眼レフ並み高画質を目指している CG・映像の専門情報サイト | CGWORLD.jp。
  • 重量を気にしない寝ながら設計により、薄型フレネルレンズに比べて光学品質が大幅に向上している 。

🌟 デザインと起業ストーリー


💡 拡張モジュールとオープンソース戦略

  • 静電力覚や風フィードバック、振動エキサイタなど多彩な感覚モジュールを接続可能。
  • 制御プログラムをオープンソース化し、コミュニティによる拡張開発を狙っている 。

💬 起業とクラウドファンディング

  • 19歳の学生起業家による挑戦で、Kickstarterで支援金調達に成功。
  • クラファンを通じて需要を見極め、量産判断やマーケティングに役立てる戦略を採用 。

🔍 注目ポイントまとめ

項目内容
ユニーク性仰向け使用に最適化された据え置き型設計
画質非球面レンズ×10枚構成で広視野かつ高精細
拡張性感覚フィードバックモジュール搭載可で体験拡張
設計哲学『SAO』にインスパイアされた未来志向
オープン戦略プログラムの共有でコミュニティ支援を促進

📌 開発者の想い


もしさらに知りたいことがあれば、お気軽にどうぞ!

  • Kickstarterでの支援状況や価格レンジ
  • レンズ部の光学設計や性能比較
  • 実際に使った感覚フィードバックの感想やレビュー
  • 現在の開発・流通フェーズや購入可能性

など、ご興味ある分野を教えていただければ、さらに詳しく調べてご案内します 😊

あなた:
https://note.com/pridask/n/ne424a560972a
ChatGPT:

こちらは、PRIDASKさんによる「Unreal Engine 5 を使って手軽に VR 360° 動画をつくる方法」に関する note 記事です。以下に要点をまとめました👇


🛠 概要

  • 音楽ビジュアライザー「Say No More」を Unreal Engine 5 で 360°動画形式 にして YouTube に公開し、その制作手順を解説しています note(ノート)。
  • 主流の「Panoramic Capture」プラグイン + BP_Capture に比べ、手軽かつ高品質な方法として紹介されています。

✅ メイン手順

  1. プラグインを有効化
    「Movie Render Queue Additional Render Passes」を UE5 で有効に設定 note(ノート)。
  2. パノラマレンダリングをONに
    Movie Render Queue のレンダリングパスで「Panorama Rendering」を選択。
    ※Deferred Rendering はOFFにする必要あり note(ノート)。
  3. 連番画像で書き出し
    解像度(例:8192×4096、60fps)を設定し、連番 PNG/JPG 出力。
    JPGだと3分半で100GB超の容量になるので注意 note(ノート)。
  4. 360°動画形式に変換
    Adobe Media Encoder などを使い、VR対応コーデック(例:H.264/QuickTime)で変換。
    「VR video」オプションを有効にすれば完了 note(ノート)。
  5. 中心方向の調整(任意)
    Premiere Pro 使用時は「Distortion → Offset」エフェクトで初期カメラ方向を調整可能 。

🎯 ポイントとメリット

  • 高品質出力が可能で、「Panoramic Capture」方式より簡単かつ実用的。
  • 通常動画と360°動画の両方を同時に同じシーンから生成でき、VRコンテンツ制作の流れに自然に組み込めます note(ノート)。

🎶 PRIDASKについて

  • エレクトロ音楽ユニットで、映像制作やMV演出にも積極的に取り組むクリエイティブチーム。
  • note や YouTube、pixiv FANBOX でも創作活動を発信されています note(ノート)。

🔍 おすすめの次ステップ

  • 他の動画編集ソフト(DaVinci Resolve 等)での360°変換方法
  • 高解像度設定や出力フォーマット比較(例:ProRes vs JPEG vs PNG)
  • 長尺の VR 映像制作・ストレージ管理の工夫

気になるテーマがあれば、さらに深掘りしてお手伝いできます!😊

あなた:
https://zenn.dev/eightbeat/articles/4d7b764c795c21
ChatGPT:

思考時間: 10 秒

https://i.ytimg.com/vi/mKXHqQdVX1A/maxresdefault.jpg
https://i.ytimg.com/vi/Z4sClxhgsxk/maxresdefault.jpg
https://mixed-news.com/en/wp-content/uploads/2023/03/Meta-Quest-2-Unreal-Engine-Logo.jpg
https://mir-s3-cdn-cf.behance.net/projects/max_808/88ae91161984339.Y3JvcCwyMjExLDE3MzAsMCww.jpg

こちらは、Zennユーザー「えいとびーと」さんが書いた記事 「UnrealEngine5のVRモードをQuestProで起動する方法まとめ」 に関する要約&補足です📘


✅ 記事の背景と目的

えいとびーとさんは、Unreal Engine 5 を利用して Meta Quest Pro と接続し、VR Preview(VRモード)を起動する方法を詳述しています。純正の VR テンプレートでは動作するものの、Lighting エラーもあり「ThirdPerson」モードベースから VR 化に挑戦していますisoroot.jp+3Zenn+3Zenn+3。


🛠 セットアップ手順

1. プラグインの有効化

2. VR モードに切り替え

  • World Settings で GameMode を「ThirdPerson」から VR Mode に変更します。
  • これにより VR Preview ボタンで起動可能になりますReddit+14Zenn+14YouTube+14。

3. Quest Pro を動作させるための追加設定

  • Android SDK/NDK の導入
  • Oculus(Meta XR)/OpenXR プラグインの有効化
  • Engine → Input の Mobile タブで「Default Touch Instance」を None に
  • Rendering → Mobile セクションで MobileHDR を OFF
  • MSAA の検証も実行isoroot.jp+1Epic Developer Community Forums+1Zenn。

🧩 実践的な注意点

  • Lighting エラーの回避のために、ThirdPersonモードからの移行がベースになっています。
  • Quest Pro をPCに接続した際、Android や XR Runtime の設定が正しくないと VR Preview が動作しないこともありますReddit+3Zenn+3Epic Developer Community Forums+3。
  • UE5 の Quest 向け VR 構築は依然として多少の不安定さ(クラッシュ、レンダリング不整合等)があり、「安定運用」レベルとは言い難いという報告もあります。

🔍 総まとめと今後の一歩

項目内容
対象者UE5+Meta Quest Pro で VR Preview を動かしたい人
主な手順OpenXR導入 → GameMode VRへ切替 → Android・Quest用設定
注意点ライティング周りやRuntime設定、HDRなど細かい調整が必須
ツール状況PC-VR は比較的安定。Quest向けはまだ微調整が続く段階

🚀 次に掘れる話題

  • Quest Pro/Quest 3 向けに Performance ベストプラクティス(Vulkan/Forward Rendering設定など)
  • Lighting や MobileHDR 最適化の具体例
  • UE5の Mixed Reality Utility Kit やハンドトラッキング導入の実践方法

ご希望あれば、具体的な手順や最新リソースと共にさらに詳しくサポートしますので、ぜひ教えてください😊

あなた:

全てをまとめた記事書いて

ChatGPT:

✅ Unreal Engine VR開発・配信・360°映像制作の全手順・技術・事例をまとめた記事を作成しました。
追加情報や具体的なコード・設定方法が必要であれば教えてください。

あなた:

全てのURLをまとめて

ChatGPT:

全URLをまとめた一覧を記事末尾に追加しました。さらにリンクを追加したい場合や用途別に分類したい場合はご指示ください。

あなた:

HTMLで

ChatGPT:

以下は、ドキュメント末尾に挿入できる「全リンクまとめ」のHTML形式です。

<h2>🔗 関連URL一覧(HTML形式)</h2>
<ul>
  <li><a href="https://dev.epicgames.com/documentation/ja-jp/unreal-engine/virtual-reality-development?application_version=4.27" target="_blank">Unreal Engine VR開発公式</a></li>
  <li><a href="https://developers.meta.com/horizon/documentation/unreal/unreal-engine-basics/?locale=ja_JP" target="_blank">Meta Horizon 開発ドキュメント</a></li>
  <li><a href="https://developers.meta.com/horizon/documentation/unreal/unreal-create-and-configure-new-project/?locale=ja_JP" target="_blank">Meta XR Project Setup Tool</a></li>
  <li><a href="https://cgworld.jp/interview/2201-19vrhalfdive.html" target="_blank">CGWORLD HalfDiveインタビュー</a></li>
  <li><a href="https://yoshikawastudio.com/unreal-engine-5-vr01/" target="_blank">YoshikawaStudio Questセットアップ</a></li>
  <li><a href="https://note.com/pridask/n/ne424a560972a" target="_blank">PRIDASK 360°映像制作note</a></li>
  <li><a href="https://zenn.dev/eightbeat/articles/4d7b764c795c21" target="_blank">Zenn QuestPro VRモードまとめ</a></li>
  <li><a href="https://www.unrealengine.com/ja/spotlights/building-virtual-cities-and-digital-twins-with-unreal-engine" target="_blank">Unreal Engine デジタルツイン紹介</a></li>
  <li><a href="https://www.moguravr.com/unreal-engine-uevr/" target="_blank">Unreal Engine UEVR紹介記事(MoguraVR)</a></li>
  <li><a href="https://zenn.dev/eightbeat/scraps/5340d6b8eb8461" target="_blank">Zenn: Webカメラ×VRM×UnrealによるVtuber配信</a></li>
</ul>

すでにドキュメントに近い内容がありますので、これをそのまま置き換え/追記できます。

✅ 必要であれば「使用用途別カテゴリ分け」や「アイコン付きリスト表示(HTML+CSS)」などにも拡張可能です。希望があればお知らせください!

あなた:

AR関連をまとめた記事をURLでHTMLで書いて

ChatGPT:

以下はAR開発に関連する公式リソースのHTMLまとめです:

<h2>🕶️ AR開発 関連リンクまとめ</h2>
<ul>
  <li><a href="https://dev.epicgames.com/documentation/ja-jp/unreal-engine/augmented-reality-development-overview" target="_blank">Unreal Engine AR開発公式ドキュメント</a></li>
  <li><a href="https://developers.meta.com/quest/ar/" target="_blank">Meta Quest AR 開発ポータル</a></li>
  <li><a href="https://developer.apple.com/augmented-reality/" target="_blank">Apple ARKit 公式サイト</a></li>
  <li><a href="https://developers.google.com/ar" target="_blank">Google ARCore 公式サイト</a></li>
  <li><a href="https://www.vuforia.com/" target="_blank">Vuforia AR プラットフォーム</a></li>
</ul>

ご希望であれば、これに加えたAR開発の手順や使用例、UE5での具体的実装方法もまとめてご案内できますのでお申し付けください。

あなた:

有名な歌手一覧HTMLURLつき

ChatGPT:

以下は「有名な歌手一覧(HTML + URLリンク付き)」のサンプルコードです:

<h2>🎤 有名な歌手一覧</h2>
<ul>
  <li><a href="https://www.taylorswift.com/" target="_blank">Taylor Swift</a></li>
  <li><a href="https://www.beyonce.com/" target="_blank">Beyoncé</a></li>
  <li><a href="https://www.officialcharts.com/artist/15628/drake/" target="_blank">Drake</a></li>
  <li><a href="https://www.adele.com/" target="_blank">Adele</a></li>
  <li><a href="https://www.johnlegend.com/" target="_blank">John Legend</a></li>
  <li><a href="https://www.arianagrande.com/" target="_blank">Ariana Grande</a></li>
  <li><a href="https://www.billieeilish.com/" target="_blank">Billie Eilish</a></li>
  <li><a href="https://www.theweeknd.com/" target="_blank">The Weeknd</a></li>
  <li><a href="https://www.brunomars.com/" target="_blank">Bruno Mars</a></li>
  <li><a href="https://www.edsherran.com/" target="_blank">Ed Sheeran</a></li>
</ul>

もし「日本の歌手」「特定ジャンル別」や「年代別」など条件があれば教えてください。ご要望に応じてリストをカスタマイズします。

ChatGPT の回答は必ずしも正しいとは限りません。重要な情報は確認するようにしてください。

Unreal Vr Setup

Unreal Engine 5 VR開発・配信・360°映像制作 完全ガイド


🎮 Unreal Engine 5でのVR開発入門

【必要環境】

  • PC: Windows 10/11
  • Unreal Engine: 5.2以上推奨(Meta公式は5.4)
  • HMD: Meta Quest 2 / 3 / Pro
  • ケーブル: USB-C 3.0 or Oculus Air Link

【基本セットアップ】

  1. Epic Games LauncherでUnreal Engineインストール
  2. 新規プロジェクト
    • テンプレート: Games > VR Template または ThirdPerson
  3. プラグイン有効化
    • OpenXR、Meta XR、Oculus VR
  4. Project Settings
    • Android SDK/NDK/JDKパス設定
    • Mobile HDR OFF
    • MSAA設定
  5. VR Preview起動
    • VRヘッドセットを接続し、エディタ上の再生モードから「VR Preview」

【注意点】

  • VR Previewがグレーアウトする場合はケーブルやOpenXR設定確認
  • QuestではAPKビルドが必要(PC-VRでは直接Preview可能)

✅ Meta Quest 向けビルドとインストール

  1. Meta XR Project Setup Toolで設定ウィザード実行
  2. Keystoreを生成し、署名設定
  3. Package > Android_ASTCでAPKビルド
  4. Oculus Developer Hub または ADBでQuestにインストール
  5. Quest内「提供元不明のアプリ」から実行

📹 360°動画・パノラマ映像制作手順

【必要プラグイン】

  • Movie Render Queue Additional Render Passes

【手順】

  1. Movie Render QueueでPanorama Renderingを追加
  2. 解像度設定(8192×4096/60fpsなど)
  3. 連番画像としてPNG/JPGで書き出し
  4. Adobe Media Encoder等でVR動画に変換し、YouTube対応可

【補足】

  • Premiere ProのDistortion > Offsetで初期視点調整可能

🌐 デジタルツイン & バーチャルシティ開発

特徴

  • 都市/建築モデルの可視化・シミュレーション
  • GIS・CAD・BIMデータのDatasmith変換
  • IoT・センサーデータのリアルタイム連携

活用事例

  • タンパ市の都市モニタリング
  • 空港・駅・都市交通の混雑可視化

技術ポイント

  • Nanite、Lumen、World Partition対応で大規模データ処理
  • AI・シミュレーションとの連動

🚀 HalfDive:寝ながら体験できる据え置きVR

  • 日本発 Diver-X開発の仰向け専用VRヘッドセット
  • 非球面レンズ10枚で高画質・広視野角
  • 感覚フィードバック拡張(振動、風、力覚)
  • オープンソース化でカスタム開発可能

🔹 まとめ

領域ツール/手法
VR開発Unreal Engine 5 + OpenXR / Meta XR
Quest展開Meta XR Project Setup Tool / APKビルド
360°動画Movie Render Queue + Panorama Rendering
デジタルツインDatasmith, Nanite, Lumen
新機軸VRHalfDive / 据え置きVR

🌟 次のステップ

  • UE5のパフォーマンス最適化
  • ハンドトラッキングやMR(Mixed Reality)
  • Meta Storeへの申請方法

🔗 関連URL一覧(HTML形式)

ご活用ください!

Full-Dive Virtual Reality

フルダイブVRとは:

フルダイブVR(Full-Dive Virtual Reality)は、ユーザーが現実世界の五感と運動感覚をすべて遮断し、代わりにデジタル空間からの刺激だけを受け取ることで「完全没入」状態を実現する次世代インタラクティブ技術です。従来のヘッドマウントディスプレイ(HMD)型VRが視覚・聴覚を中心に外部ディスプレイを介して体験を提供するのに対し、フルダイブVRは脳神経への直接入力/出力(I/O)を目指し、身体を動かさずに仮想世界を「生きる」ことを可能にします。


主要技術要素:

  1. 脳–コンピュータ・インタフェース(BCI)
    脳の神経活動を高精度に読み取り、逆に電気的・化学的刺激を通じて信号を書き込む双方向技術が必須です。非侵襲型では高密度EEGや近赤外分光法(fNIRS)が候補ですが、真に高解像度のフルダイブには侵襲型マイクロ電極アレイやナノワイヤを用いたインタフェースが現実的と考えられています。
  2. センサリーフィードバック生成
    視覚・聴覚・触覚・嗅覚・味覚・前庭感覚の各チャネルを脳の対応領域へ正確に提示するアルゴリズムが必要です。これにはリアルタイム物理ベースレンダリング、空間音響合成、ハプティックディスプレイ生成などの既存VR要素に加え、神経刺激パターンの最適化が関わります。
  3. 運動意図デコードと運動遮断
    ユーザーが「身体を動かしたい」と脳内で決定した瞬間の運動前野/一次運動野の発火を検出し、仮想キャラクターへ写像すると同時に、末梢神経へ向かう信号を遮断して現実の筋肉が動かないようにする必要があります。
  4. 超低遅延・高帯域通信
    五感と運動を1ms以下の遅延で同期させるため、$$\text{必要帯域} \approx \text{感覚チャンネル数} \times \text{量子化ビット} \times \text{サンプリング周波数}$$
    という式が示唆するように、毎秒数十ギガビット級のインタフェースが求められます。
  5. 安全プロトコル・フェイルセーフ
    神経刺激の過負荷や誤動作は致命的な健康被害をもたらすため、冗長電源、ソフトリミット、リスクベース認証が不可欠です。

ニューロインタフェースの実装方法:

大別すると以下の二系統があります。

  • 非侵襲型BCI
    頭皮上の多点EEGキャップや光学式計測で信号を取得し、経頭蓋磁気刺激(TMS)や経頭蓋直流刺激(tDCS)で書き込みを行う方法です。手軽で安全ですが、空間分解能はmmオーダ、時間分解能も数十ms程度に限られ、フルダイブレベルの臨場感を得るには難があります。
  • 侵襲型BCI
    皮質表面または脳深部へ数百〜数千チャンネルのマイクロ電極を埋め込み、単一ニューロンレベルで読み書きします。近年は柔軟基板やカーボンナノチューブを用いた可塑性電極が研究されており、生体適合性を高めつつ長期安定動作を目標としています。完全没入を視野に入れるなら、電極挿入部位の個体差をAIで自動最適化し、手術支援ロボットでミクロン精度の配置を実現するアプローチが想定されます。

視覚・聴覚の再現:

  • 視覚
    視覚野(V1〜V4)の網膜像座標系に合わせて刺激する必要があり、フォトリアリスティックな知覚には数百万点の同時刺激が必須です。Deep Learningで学習したニューラルデコーダを活用し、実際の網膜入力→脳活動→逆写像のサイクルをエンドツーエンドで最適化する研究が進行中です。
  • 聴覚
    一次聴覚野A1の周波数帯域マップを刺激し、頭部伝達関数(HRTF)をパラメトリックに合成した電気刺激に変換します。結果として被験者は頭の外に3D音像を知覚します。

触覚・運動制御:

  • 触覚
    体性感覚皮質の体部位対応領野(ホムンクルス)をマイクロカソード刺激し、触圧、温度、振動を提示します。特に粗大触覚と微細触覚は伝導速度の異なる神経線維(Aβ, C線維)で中枢統合されるため、刺激パターン生成器が二系統をわずか数msの精度で同期させる必要があります。
  • 運動制御
    運動意図を早期に捉えるため、運動前皮質の発火パターンを逐次ベイズ推定でデコードし、仮想キャラクターへ運動コマンドを出力します。同時に、末梢神経ブロックを局所的に行う「可逆的神経遮断マイクロデバイス」を挿入すると、現実身体の動きを抑制し転倒や衝突を防げます。

解決すべき課題:

  1. 長期生体適合性
    電極周辺で発生するグリア瘢痕化の抑制は、信号SN比を維持する鍵になります。
  2. 脳可塑性との干渉
    長時間の人工刺激はシナプスの重みを変化させうるため、現実感覚機能への逆転移を避けるプロトコルが必要です。
  3. 情報安全
    神経パケットを暗号化しないままネットワークに流すと、プライバシやマルウェア攻撃の深刻なリスクが生じます。
  4. 倫理・法規制
    自己同一性の改変、依存症、年齢制限など社会的インパクトが大きいため、テクノロジーガバナンスが不可欠です。

今後のロードマップ:

  • 2025–2030年:高密度非侵襲BCIによる部分没入(視覚+聴覚の解像度向上、簡易ハプティクス連携)。
  • 2030–2040年:小規模侵襲型デバイスによる四肢の運動写像と触覚フィードバックを実現し、医療リハビリ用途から社会実装。
  • 2040–2050年:脳深部を含む数万チャンネル規模の双方向BCIが商用化され、静止状態でのフルダイブゲームが成立。
  • 2050年代以降:全感覚・全運動ループを束ねるクラウド型ニューラルOSが標準化し、現実とのシームレススイッチングが可能になる――というのが現時点での最も楽観的な推定です。

まとめ:

フルダイブVRの実現には、神経科学・電子工学・計算機科学・倫理学といった複数分野のブレークスルーが必要です。特に脳–コンピュータ・インタフェースの解像度、リアルタイム神経刺激の安全性、そして超低遅延ネットワークの確立が核心となります。現行技術はまだ基礎研究段階にありますが、医療BCIやハプティクス応用で得られた知見を段階的に統合することで、数十年スパンでの「完全没入」体験が射程圏内に入ると期待されています。

ドラゴンドライブVR

『ドラゴンドライブVR』企画書


1. タイトル

ドラゴンドライブVR(Dragon Drive VR)


2. ゲームジャンル

  • ジャンル:VRアクション・ドラゴンバトルRPG
  • プレイ方式:1人プレイ(将来的にオンライン対戦対応予定)
  • 対応ハード:Meta Quest 3 / PC VR(SteamVR対応) / PS VR2

3. コンセプト

「君と竜が一体となる、空中戦の限界へ。」

プレイヤーは“ドラゴンライダー”となり、現実世界とリンクした仮想空間でドラゴンを育成・騎乗し、空中戦・地上戦を体験。VRならではの臨場感で“ドラゴンと飛ぶ”夢を実現する。


4. 主なゲームシステム

● ドラゴン育成システム

  • タマゴから孵化→成長→進化(分岐進化あり)
  • 育成によってスキル・属性が変化(炎・氷・雷・闇・光など)
  • エサ・訓練・信頼度で個性が変化

● ライドバトル(空中戦)

  • フリーフライトで空を自由に飛ぶ
  • 射撃・ブレス攻撃・回避・突進などのバトルアクション
  • 一人称視点と三人称視点を切替可能

● 地上探索

  • 拠点となる街や遺跡を探索し、アイテムやミッションを獲得
  • ダンジョンはプレイヤー+ドラゴンで攻略(謎解き要素あり)

● VRインタラクション

  • ドラゴンとのふれあい:撫でる、餌をあげる、呼びかけるなど
  • 騎乗時のリアルな風・振動・高度変化演出

5. 世界観

かつて竜と人が共に生きていた「空界アルトレア」。
再び甦る邪竜の脅威に対抗するため、選ばれし“ライダー”たちが立ち上がる。


6. 想定ターゲット

  • VRユーザー(10代後半~30代前半)
  • ファンタジー・ドラゴン・育成ゲームファン
  • 『ドラゴンドライブ』『パンドラハーツ』『アバター』『竜とそばかすの姫』に魅力を感じる層

7. 収益モデル

  • 基本プレイ無料+アイテム課金(アバター/ドラゴンスキン)
  • 拡張DLC(新マップ、新ドラゴン、新ストーリー)
  • NFT連携によるドラゴン個体資産化(検討中)

8. 開発体制・ツール

  • エンジン:Unity(または Unreal Engine 5 + OpenXR)
  • ネットワーク:Photon Fusion または Mirror
  • VR対応:Meta SDK / OpenXR / SteamVR

9. 開発スケジュール(例)

フェーズ内容期間
企画・プロトタイプ世界観、コアシステム試作3か月
アルファ版飛行+戦闘+育成基本実装6か月
ベータ版UI/UX調整+コンテンツ拡充3か月
リリースマーケティング+ローンチ1か月

10. 補足・将来展望

  • マルチプレイヤーPvP空中戦の実装
  • ドラゴンコンテストイベント(飛行レース・育成大会)
  • AI搭載ドラゴンとの感情交流
  • Mixed Reality対応によるリアル環境でのドラゴン投影体験

.hack//VR 企画書

.hack//VR 企画書


【タイトル】

.hack//VR(ドットハック ヴィーアール)


【ジャンル】

フルダイブ型MMORPG(仮想現実大規模多人数同時接続型RPG)


【対応プラットフォーム】

  • Meta Quest 3 / Quest Pro
  • PlayStation VR2
  • PC VR(SteamVR対応)
  • フルダイブ対応ヘッドセット(将来的展望)

【コンセプト】

「仮想世界は、現実を超える」
架空のネットワークRPG《The World》を舞台にした、現実とリンクするフルダイブ型VR体験。ユーザーは「プレイヤー」としてゲームに参加しながらも、実はゲームの裏で進行する謎と陰謀に巻き込まれていく。


【開発背景】

  • 2002年の「.hack//Infection」シリーズから続く《The World》の世界観を最新技術で再構築。
  • フルダイブ技術の発展を見据えたVR MMORPGの実験的開発。
  • ユーザー間の社会的インタラクションとAI搭載NPCの自然会話を融合。

【ゲームの特徴】

1. フルダイブ没入体験

  • プレイヤーはアバターとして《The World》に降り立ち、五感(視覚、聴覚、触覚)を通じて世界を体験。
  • 拡張神経接続インターフェース「NeuroLink(仮)」対応。

2. 2層構造の物語

  • 仮想世界《The World》内のRPGストーリー。
  • 現実世界のプレイヤー間の謎、事件、そして「AI」の反乱。
  • 2つの時間軸が交錯し、プレイヤー自身が物語の一部になる。

3. AI NPCとのリアルな交流

  • GPT-4ベースの高度会話AI搭載NPC。
  • 各キャラクターが記憶・感情を持ち、ユーザーの選択により関係性が変化。

4. VR戦闘システム

  • ソードスキル、魔法、連携技をモーション操作でリアルタイム発動。
  • 攻撃タイミングと身体操作が勝敗を左右する、直感型バトル。

5. プレイヤーギルドとハッキング要素

  • ギルド運営、拠点の建築、PvPなどの要素に加え、
  • 特定プレイヤーが「ハッカー」となり、ゲームの奥深くに潜む謎の領域へアクセス可能。

【ゲーム内用語】

用語解説
The Worldゲームの舞台となる仮想空間
ネットスレイヤーデータを破壊する謎の存在
AIコア人格を持ったAI、暴走の兆しあり
データドレインプレイヤーの記憶や感情を吸収する技術(禁忌)

【ターゲット層】

  • VRゲーマー(16〜35歳)
  • SF・サイバーパンク・.hackシリーズファン
  • フルダイブ技術に興味を持つ先端層

【マネタイズ】

  • 基本無料+アバター装備・外見課金(スキン制)
  • ストーリーDLC、特定イベント有料開放
  • プレミアムアカウント(月額制)

【将来的展望】

  • プレイヤー間の記憶共有機能(記憶ログシェア)
  • 現実の感覚を記録・再体験する「リプレイVR」
  • 現実の時間と連動する仮想祭イベント

【イメージビジュアル】(必要なら生成可能)


【補足】

.hack//VRは「ゲーム」であると同時に、フルダイブVRの社会実験でもあります。AIと人間がどこまで共存できるか、仮想空間における「自我」とは何かを問いかける、哲学的な要素を含む作品です。

VRSNS

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>VR‑SNS Prototype v8 (Spatial Audio + PTT + エモート)</title>

<!-- Libraries -->
<script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/aframe-extras@6.1.1/dist/aframe-extras.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/gun.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/simple-peer@9.11.1/simplepeer.min.js"></script>

<style>
html,body{margin:0;padding:0;overflow:hidden;font-family:"Helvetica Neue",Arial,sans-serif;background:#111;color:#eee}
#ui{position:fixed;top:0;left:0;width:420px;height:100vh;overflow-y:auto;background:rgba(0,0,0,.9);backdrop-filter:blur(6px);padding:1rem;box-sizing:border-box;z-index:10;transition:transform .3s ease}
#ui.hidden{transform:translateX(-105%)}
#ui h1{font-size:1.5rem;margin:0 0 .8rem;text-align:center}
#ui label{display:block;font-size:.75rem;margin:.6rem 0 .15rem;color:#8fc}
#ui input,#ui select,#ui textarea{width:100%;box-sizing:border-box;margin-bottom:.7rem;padding:.56rem;border:none;border-radius:6px;font-size:.9rem;background:#222;color:#ddd}
#ui textarea{resize:vertical}
#ui button{width:100%;padding:.72rem;border:none;border-radius:6px;font-weight:bold;cursor:pointer;background:#06a;color:#fff;transition:background .2s}
#ui button:hover{background:#089}
#timeline{margin-top:1rem}
.post{background:#1a1a1a;border-radius:6px;padding:.75rem;margin-bottom:.75rem;word-break:break-word;font-size:.8rem;position:relative}
.post small{color:#999;font-size:.7rem}
.post img{max-width:100%;border-radius:4px;margin-top:.4rem}
.reactBar{display:flex;gap:5px;margin-top:.45rem}
.reactBtn{flex:1;background:#333;border:none;border-radius:4px;padding:3px 0;font-size:.75rem;cursor:pointer;color:#f88;display:flex;justify-content:center;align-items:center}
.reactBtn span{margin-left:4px;font-weight:bold;color:#ccc}
.hashTag{color:#6af;cursor:pointer}
#handle{position:absolute;top:50%;right:-18px;width:18px;height:80px;border-radius:0 6px 6px 0;background:#06a;cursor:pointer;display:flex;align-items:center;justify-content:center;color:#fff;font-size:.7rem;transform:translateY(-50%)}
#tagFilter{margin-bottom:.8rem;width:100%;padding:.56rem;border:none;border-radius:6px;background:#222;color:#ddd}
#onlineCount{font-size:.75rem;margin-bottom:.8rem;color:#9f9}
#roomInput{width:70%;display:inline-block}
#roomBtn{width:28%;display:inline-block;margin-left:2%}
#ttsToggleLbl,#muteToggleLbl,#pttInfo{display:flex;align-items:center;font-size:.75rem;margin-bottom:.7rem;gap:.5rem}
.sysMsg{color:#8ff;font-style:italic}
.speaking{animation:pulse 1s infinite}
@keyframes pulse{0%{opacity:1}50%{opacity:.4}100%{opacity:1}}
.emote{position:absolute;left:50%;transform:translateX(-50%);top:-0.4m;font-size:0.4m}
</style>
</head>
<body>
<div id="ui">
  <div id="handle">⮜</div>
  <h1>VR‑SNS</h1>

  <label>ルーム ID</label>
  <input id="roomInput" value="lobby"/><button id="roomBtn">入室</button>
  <div id="onlineCount">オンライン: 0</div>

  <label>ユーザー名</label>
  <input id="usernameInput" placeholder="匿名" />

  <label>アバター色</label>
  <input id="avatarColor" type="color" value="#ff8800" />

  <label>環境テーマ</label>
  <select id="themeSelect"><option value="dusk">夕暮れ空</option><option value="midnight">真夜中</option><option value="day">晴れ昼</option></select>

  <label>ハッシュタグ絞り込み</label>
  <select id="tagFilter"><option value="all">すべて</option></select>

  <label id="ttsToggleLbl"><input type="checkbox" id="ttsToggle"/> 投稿読み上げ</label>
  <label id="muteToggleLbl"><input type="checkbox" id="muteToggle"/> マイク常時OFF</label>
  <div id="pttInfo">Push‑To‑Talk: <strong>Vキー</strong> 押下中のみ送信</div>

  <label>投稿</label>
  <textarea id="postText" rows="3"></textarea>
  <button id="postButton">ポスト</button>
  <button id="clearButton" style="background:#a00;margin-top:.3rem">ローカル履歴削除</button>

  <div id="timeline"></div>
</div>

<a-scene renderer="antialias:true" xr-mode-ui="true" background="color:#112" cursor="rayOrigin:mouse">
  <a-entity environment="preset: forest; ground:y"></a-entity>
  <a-entity id="ground" geometry="primitive:plane; width:150; height:150" rotation="-90 0 0" material="visible:false" static-body></a-entity>

  <a-entity id="rig" position="0 1.6 4" movement-controls="fly:false; speed:0.22">
    <a-entity id="head" camera look-controls></a-entity>
    <a-entity id="leftHand"  laser-controls="hand:left"  raycaster="objects:.interactive" teleport-controls="button:trigger; collisionEntities:#ground; cameraRig:#rig"></a-entity>
    <a-entity id="rightHand" laser-controls="hand:right" raycaster="objects:.interactive"></a-entity>
  </a-entity>
</a-scene>

<script>
(()=>{
const gun=Gun({peers:['https://gun-manhattan.herokuapp.com/gun']});
const myId=Gun.text.random();
let room='lobby',roomRef;
const $=id=>document.getElementById(id);
const ui=$('ui'),handle=$('handle');
const roomInput=$('roomInput'),roomBtn=$('roomBtn'),onlineCount=$('onlineCount');
const usernameInput=$('usernameInput'),avatarColorIn=$('avatarColor');
const themeSelect=$('themeSelect'),tagFilter=$('tagFilter');
const ttsToggle=$('ttsToggle'),muteToggle=$('muteToggle');
const postText=$('postText'),postBtn=$('postButton'),clearBtn=$('clearButton');
const timelineEl=$('timeline');
const scene=document.querySelector('a-scene');
const head=$('head'),leftHand=$('leftHand'),rightHand=$('rightHand');

const store={get:(k,d)=>JSON.parse(localStorage.getItem('vrsns_'+k)||JSON.stringify(d)),set:(k,v)=>localStorage.setItem('vrsns_'+k,JSON.stringify(v))};
usernameInput.value=store.get('user','');avatarColorIn.value=store.get('color','#ff8800');themeSelect.value=store.get('theme','dusk');ttsToggle.checked=store.get('tts',false);

const postsMap=new Map();const tags=new Set();const remoteAvatars=new Map();const remotePeers=new Map();let micStream=null,aCtx=null;let pushTalking=false;
let presenceRef,posRef,presenceInterval,posInterval;
applyTheme(themeSelect.value);createOrUpdateAvatar();setupMic();enterRoom(room);

handle.onclick=()=>ui.classList.toggle('hidden');scene.addEventListener('enter-vr',()=>ui.classList.add('hidden'));scene.addEventListener('exit-vr',()=>ui.classList.remove('hidden'));
roomBtn.onclick=()=>{const r=roomInput.value.trim();if(r){leaveRoom();enterRoom(r)}};
themeSelect.onchange=e=>{const v=e.target.value;store.set('theme',v);applyTheme(v)};avatarColorIn.oninput=createOrUpdateAvatar;
ttsToggle.onchange=e=>store.set('tts',e.target.checked);
muteToggle.onchange=e=>updateMicState();
postBtn.onclick=submitPost;clearBtn.onclick=()=>{if(confirm('ローカル履歴を削除しますか?')){localStorage.removeItem('vrsns_posts_'+room);timelineEl.innerHTML='';}};
tagFilter.onchange=filterTimeline;
window.addEventListener('keydown',e=>{if(e.key==='v'&&!pushTalking){pushTalking=true;updateMicState();}});
window.addEventListener('keyup',e=>{if(e.key==='v'){pushTalking=false;updateMicState();}});

async function setupMic(){try{aCtx=new (window.AudioContext||window.webkitAudioContext)();micStream=await navigator.mediaDevices.getUserMedia({audio:true});updateMicState();}catch(err){alert('マイク利用不可');}}
function updateMicState(){if(!micStream)return;const enabled=!muteToggle.checked&&(pushTalking||muteToggle.checked===false&&ttsToggle);micStream.getAudioTracks()[0].enabled=enabled;}

function enterRoom(r){room=r;roomRef=gun.get('vrsns').get(room);roomInput.value=room;timelineEl.innerHTML='';postsMap.clear();tags.clear();rebuildTagFilter();onlineCount.textContent='オンライン: 0';
roomRef.get('posts').map().on(onPost);roomRef.get('posts').map().get('reactions').map().on(onReaction);
presenceRef=roomRef.get('presence').get(myId);presenceRef.put({ts:Gun.state(),color:avatarColorIn.value});presenceInterval=setInterval(()=>presenceRef.put({ts:Gun.state(),color:avatarColorIn.value}),10000);roomRef.get('presence').map().on(updateOnline);
posRef=roomRef.get('pos').get(myId);sendPos();posInterval=setInterval(sendPos,100);
roomRef.get('pos').map().on(onRemotePos);roomRef.get('signal').map().on(onSignal);sysMsg(`[${room}] 入室しました`);} 
function leaveRoom(){clearInterval(presenceInterval);clearInterval(posInterval);presenceRef&&presenceRef.put(null);posRef&&posRef.put(null);roomRef.off();roomRef.get('signal').off();remoteAvatars.forEach(av=>av.remove());remoteAvatars.clear();remotePeers.forEach(p=>p.destroy());remotePeers.clear();}

function submitPost(){const user=usernameInput.value.trim()||'匿名',text=postText.value.trim();if(!text)return;store.set('user',user);store.set('color',avatarColorIn.value);const id=Gun.text.random();const post={id,user,text,time:Date.now(),color:avatarColorIn.value,reactions:{'❤':0,'😂':0,'😮':0,'😢':0},tags:extractTags(text)};roomRef.get('posts').get(id).put(post);postText.value='';if(ttsToggle.checked)speak(`${user} さん: ${text.replace(/#/g,'')}`);} 
function onPost(post){if(!post||postsMap.has(post.id))return;postsMap.set(post.id,post);collectTags(post);rebuildTagFilter();renderPost2D(post);renderPost3D(post);filterTimeline();}
function onReaction(v,field,key){const pid=field,emoji=key;const p=postsMap.get(pid);if(!p)return;p.reactions[emoji]=v;updatePostCard(pid,p);updatePost3D(pid,p);} 
function react(id,emo){roomRef.get('posts').get(id).get('reactions').get(emo).once(v=>roomRef.get('posts').get(id).get('reactions').get(emo).put((v||0)+1));}

function updateOnline(){let c=0;roomRef.get('presence').map().once(()=>c++);setTimeout(()=>onlineCount.textContent=`オンライン: ${c}`,200);} 
function sendPos(){const p=head.object3D.position,l=leftHand.object3D.position,r=rightHand.object3D.position;posRef.put({x:p.x,y:p.y,z:p.z,l:{x:l.x,y:l.y,z:l.z},r:{x:r.x,y:r.y,z:r.z},color:avatarColorIn.value,ts:Gun.state()});}

function onRemotePos(data,id){if(id===myId||!data)return;let av=remoteAvatars.get(id);if(!av){av=createAvatar(id,data.color);remoteAvatars.set(id,av);connectVoice(id);}av.setAttribute('position',`${data.x} 0 ${data.z}`);av.querySelectorAll('[geometry]').forEach(g=>g.setAttribute('color',data.color||'#fff'));['l','r'].forEach(h=>{let el=av.querySelector('.'+h);if(!el){el=document.createElement('a-sphere');el.classList.add(h);el.setAttribute('radius',0.05);av.appendChild(el);}const hp=data[h];if(hp)el.setAttribute('position',`${hp.x} ${hp.y} ${hp.z}`);});}

function createAvatar(id,color){const root=document.createElement('a-entity');root.id='av_'+id;root.innerHTML=`<a-sphere radius='0.25' color='${color||'#fff'}' position='0 1.6 0'></a-sphere><a-cylinder height='0.8' radius='0.2' color='${color||'#fff'}' position='0 1 0'></a-cylinder>`;scene.appendChild(root);return root;}

function connectVoice(rid){if(remotePeers.has(rid)||!micStream)return;const init=myId>rid;const peer=new SimplePeer({initiator:init,trickle:true,stream:micStream});remotePeers.set(rid,peer);peer.on('signal',d=>roomRef.get('signal').get(myId).get(rid).put(JSON.stringify(d)));roomRef.get('signal').get(rid).get(myId).on(sig=>sig&&peer.signal(JSON.parse(sig)));peer.on('stream',s=>{const av=remoteAvatars.get(rid);if(!av)return;const a=new Audio();a.srcObject=s;const src=aCtx.createMediaStreamSource(s);const panner=aCtx.createPanner();panner.panningModel='HRTF';panner.distanceModel='inverse';panner.maxDistance=20;src.connect(panner).connect(aCtx.destination);function upd(){if(!av.parentNode)return;const pos=av.object3D.position;panner.setPosition(pos.x,pos.y,pos.z);requestAnimationFrame(upd);}upd();a.play();});peer.on('close',()=>remotePeers.delete(rid));peer.on('error',()=>remotePeers.delete(rid));}

function onSignal(){}

function renderPost2D(p){const isImg=/\.(gif|jpe?g|png|webp)$/i.test(p.text.trim());const card=document.createElement('div');card.className='post';card.dataset.id=p.id;card.dataset.tags=p.tags.join(',');card.innerHTML=`<strong style='color:${p.color}'>${escapeHTML(p.user)}</strong>: ${isImg?`<img src='${escapeHTML(p.text)}'/>`:linkify(escapeHTML(p.text))}${p.tags.map(t=>` <span class='hashTag'>#${t}</span>`).join('')}<br><small>${new Date(p.time).toLocaleString()}</small>`;const bar=document.createElement('div');bar.className='reactBar';['❤','😂','😮','😢'].forEach(e=>{const b=document.createElement('button');b.className='reactBtn';b.dataset.e=e;b.innerHTML=`${e} <span>${p.reactions[e]||0}</span>`;b.onclick=()=>react(p.id,e);bar.appendChild(b);});card.appendChild(bar);card.querySelectorAll('.hashTag').forEach(el=>el.onclick=()=>{tagFilter.value=el.textContent.slice(1).toLowerCase();filterTimeline();});timelineEl.insertBefore(card,timelineEl.firstChild);} 
function updatePostCard(id,p){const card=document.querySelector(`.post[data-id='${id}']`);if(card)card.querySelectorAll('.reactBtn').forEach(btn=>btn.querySelector('span').textContent=p.reactions[btn.dataset.e]||0);} 
function format3D(p){const top=Object.entries(p.reactions||{}).sort((a,b)=>b[1]-a[1])[0];const r=top&&top[1]>0?` ${top[0]}×${top[1]}`:'';return `${p.user}${r}\n${p.text}`;}
function renderPost3D(p){const ent=document.createElement('a-entity');ent.classList.add('interactive');ent.id='p3d_'+p.id;ent.setAttribute('text',{value:format3D(p),align:'center',width:4,color:p.color});ent.onclick=()=>react(p.id,'❤');positionEntity(ent);scene.appendChild(ent);setTimeout(()=>ent.remove(),300000);if(/\.(gif|jpe?g|png|webp)$/i.test(p.text.trim())){const plane=document.createElement('a-plane');plane.setAttribute('src',p.text);plane.setAttribute('width',1.8);plane.setAttribute('height',1.2);plane.classList.add('interactive');positionEntity(plane,0.6);scene.appendChild(plane);setTimeout(()=>plane.remove(),300000);}}
function updatePost3D(id,p){const e=$('p3d_'+id);if(e)e.setAttribute('text','value',format3D(p));}

function positionEntity(e,y=0){const ang=Math.random()*Math.PI,rad=5+Math.random()*5;e.setAttribute('position',`${Math.cos(ang)*rad} ${2+y} ${-Math.sin(ang)*rad}`);} 
function collectTags(p){p.tags.forEach(t=>tags.add(t.toLowerCase()));}
function rebuildTagFilter(){const cur=tagFilter.value;tagFilter.innerHTML='<option value="all">すべて</option>'+[...tags].sort().map(t=>`<option value='${t}'>#${t}</option>`).join('');tagFilter.value=cur||'all';}
function filterTimeline(){const f=tagFilter.value;document.querySelectorAll('.post').forEach(el=>el.style.display=(f==='all'||el.dataset.tags.includes(f))?'':'none');}
function escapeHTML(s){return s.replace(/[&<>"']/g,ch=>({'&':'&amp;','<':'&lt;',">":"&gt;","\"":"&quot;","'":"&#39;"}[ch]));}
function extractTags(t){return(t.match(/#(\w+)/g)||[]).map(x=>x.slice(1).toLowerCase());}
function linkify(t){return t.replace(/https?:\/\/\S+/g,u=>`<a href='${u}' target='_blank'>${u}</a>`);} 
function applyTheme(t){let sky=scene.querySelector('a-sky');if(!sky){sky=document.createElement('a-sky');scene.appendChild(sky);}sky.setAttribute('color',t==='midnight'?'#000022':t==='day'?'#86cefa':'#112');}
function createOrUpdateAvatar(){const c=avatarColorIn.value;store.set('color',c);let av=$('myAvatar');const body=`<a-sphere radius='0.25' color='${c}' position='0 1.6 0'></a-sphere><a-cylinder height='0.8' radius='0.2' color='${c}' position='0 1 0'></a-cylinder>`;if(!av){av=document.createElement('a-entity');av.id='myAvatar';av.innerHTML=body;scene.appendChild(av);}else av.innerHTML=body;}
function speak(msg){speechSynthesis.speak(new SpeechSynthesisUtterance(msg));}
function sysMsg(t){const el=document.createElement('div');el.className='post sysMsg';el.textContent=t;timelineEl.insertBefore(el,timelineEl.firstChild);} 
})();
</script>
</body>
</html>