js模拟风阻测试粒子动画代码

代码语言:html

所属分类:粒子

代码描述:js模拟风阻测试粒子动画代码,可调节参数

代码标签: js 模拟 风阻 测试 粒子 动画 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>固定物体风阻分析模拟</title>
<style>
  :root {
    --accent: #5cc8ff;
    --panel-bg: rgba(8, 14, 26, 0.84);
    --text: #dbeafe;
    --muted: #8ab4d8;
  }

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

  html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #04070e;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  }

  #windCanvas,
  #arrowCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  #windCanvas {
    cursor: crosshair;
    touch-action: none;
  }

  #arrowCanvas {
    pointer-events: none;
  }

  .panel {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 360px;
    max-height: calc(100vh - 32px);
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    backdrop-filter: blur(14px);
    color: var(--text);
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    transition: transform 0.28s ease;
  }

  .panel.hidden {
    transform: translateX(calc(100% + 24px));
    pointer-events: none;
  }

  .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-weight: 700;
    letter-spacing: 0.5px;
  }

  .panel-body {
    padding: 12px 16px 16px;
    overflow: auto;
  }

  .section-title {
    font-size: 12px;
    color: var(--muted);
    margin: 16px 0 8px;
    letter-spacing: 1px;
  }

  .row {
    display: grid;
    grid-template-columns: 92px 1fr 62px;
    gap: 8px;
    align-items: center;
    margin: 9px 0;
  }

  .row label {
    font-size: 13px;
    color: #b9cfe6;
  }

  .row output {
    font-size: 12px;
    color: var(--accent);
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
  }

  input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
  }

  select,
  input[type="color"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 6px 8px;
    outline: none;
    cursor: pointer;
  }

  input[type="color"] {
    padding: 2px;
    height: 34px;
  }

  .check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    font-size: 13px;
    color: #b9cfe6;
    cursor: pointer;
  }

  .btn-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 10px 0;
  }

  .preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  button {
    background: rgba(92, 200, 255, 0.12);
    color: #c9e8ff;
    border: 1px solid rgba(92, 200, 255, 0.24);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.18s, transform 0.12s;
  }

  button:hover {
    background: rgba(92, 200, 255, 0.22);
  }

  button:active {
    transform: scale(0.97);
  }

  .preset-grid button {
    padding: 6px 4px;
    font-size: 12px;
  }

  #hideBtn {
    padding: 2px 10px;
  }

  #showBtn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 11;
    padding: 10px 14px;
    border-radius: 12px;
  }

  #showBtn.hidden {
    display: none;
  }

  #stats {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 9;
    color: rgba(220, 240, 255, 0.78);
    font-size: 12px;
    line-height: 1.5;
    background: rgba(5, 10, 20, 0.45);
    padding: 8px 10px;
    border-radius: 10px;
    pointer-events: none;
    backdrop-filter: blur(8px);
  }

  .analysis {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 5px 12px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px;
    border-radius: 12px;
  }

  .analysis span {
    color: #9fb8d0;
  }

  .analysis b {
    color: #eaffff;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .hint {
    font-size: 12px;
    color: #7d93ab;
    margin-top: 10px;
    line-height: 1.5;
  }

  @media (max-width: 640px) {
    .panel {
      width: min(360px, calc(100vw - 32px));
    }

    .row {
      grid-template-columns: 84px 1fr 56px;
    }
  }
</style>
</head>
<body>

<canvas id="windCanvas"></canvas>
<canvas id="arrowCanvas"></canvas>

<div id="panel" class="panel">
  <div class="panel-header">
    <span>🧱 固定物体风阻分析</span>
    <button id="hideBtn" title=".........完整代码请登录后点击上方下载按钮下载查看

网友评论0