You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

A-Frame physics system中dynamic-body无法下落问题求助

问题分析与解决方案
  • 核心问题:无效的物理系统脚本链接
    你使用的physics系统导入链接中,@v$npm_package_version是npm模板占位符,并非实际版本号,浏览器无法加载到有效的脚本文件,这就是物理系统完全没生效的根本原因。

  • 修复步骤

    1. 替换为有效的CDN链接,可选择两种方式:
      • 使用仓库指定稳定版本(以v4.0.1为例,可根据仓库实际更新调整):
        <script src="https://cdn.jsdelivr.net/gh/n5ro/aframe-physics-system@v4.0.1/dist/aframe-physics-system.min.js"></script>
        
      • 使用unpkg自动拉取最新版本:
        <script src="https://unpkg.com/aframe-physics-system"></script>
        
    2. 添加静态地面实体,避免动态盒子下落出视野导致看起来“没动”:
      <a-box static-body position="0 -10 -6" scale="20 2 20" color="#222"></a-box>
      
    3. 按F12打开浏览器控制台,确认脚本加载无404错误,确保物理系统组件成功注册。
  • 修复后的完整示例代码

<script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script>
<script src="https://unpkg.com/aframe-event-set-component@^3.0.0/dist/aframe-event-set-component.min.js"></script>
<!-- 替换为有效版本的物理系统脚本 -->
<script src="https://unpkg.com/aframe-physics-system"></script>

<body>
  <a-scene physics="debug: true;">
    <!-- 自定义光标 -->
    <a-camera>
      <a-entity cursor position="0 0 -1" geometry="primitive: sphere; radius: 0.005;" material="color: #000000; opacity: 0.5;">
      </a-entity>
    </a-camera>
    <!-- 天空与地面 -->
    <a-sky color="#FFAA00"></a-sky>
    <a-box static-body position="0 -10 -6" scale="20 2 20" color="#222"></a-box>
    <!-- 动态盒子 -->
    <a-box dynamic-body position="-5 2.5 -6" color="red" scale="1 1 2" 
           animation="property: rotation; to: 360 360 0; dur: 3000; easing: linear; loop: true;"
           event-set__enter="_event: mouseenter; material.color: blue;"
           event-set__leave="_event: mouseleave; material.color: red;">
    </a-box>
  </a-scene>
</body>

内容的提问来源于stack exchange,提问作者Worker1432

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 01:40:05