three实现三维可发射炮弹机器猫行走动画代码

代码语言:html

所属分类:三维

代码描述:three实现三维可发射炮弹机器猫行走动画代码

代码标签: three 三维 发射 炮弹 机器 行走 动画 代码

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

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
    :root {
  --bg: #5530ab;
  --purple: #b665eb;
  --cyan: #5de3d1;
  --ink: #212121;
  --white: #ffffff;
  --panel: rgba(24, 13, 54, 0.52);
  --line: rgba(255, 255, 255, 0.17);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 38%, #7548cd 0%, var(--bg) 42%, #2a155f 100%);
  color: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
canvas {
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#scene:active {
  cursor: grabbing;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(18px, 3vw, 36px);
  pointer-events: none;
}

.hud__top,
.hud__bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.28em;
}

h1 {
  margin: 0;
  font-size: clamp(18px, 2.6vw, 34px);
  line-height: 1;
  letter-spacing: -0.04em;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.22);
}

.status,
.controls,
.hud__bottom p {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(15, 5, 38, 0.22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 14px var(--cyan);
}

.status[data-state="charge"] .status__dot {
  animation: chargePulse 0.5s ease-in-out infinite alternate;
}

.status[data-state="fire"] .status__dot {
  background: var(--white);
  box-shadow: 0 0 18px var(--white), 0 0 30px var(--cyan);
}

@keyframes chargePulse {
  from { transform: scale(0.8); opacity: 0.55; }
  to { transform: scale(1.35); opacity: 1; }
}

.hud__bottom {
  align-items: flex-end;
}

.controls {
  display: flex;
  gap: 8px;
  padding: 7px;
  border-radius: 16px;
  pointer-events: auto;
}

button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(93, 227, 209, 0.55);
}

button:active {
  transform: translateY(0) scale(0.98);
}

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

#fireBtn {
  background: rgba(93, 227, 209, 0.14);
  border-color: rgba(93, 227, 209, 0.48);
}

.hud__bottom p {
  margin: 0;
  padding: 11px 14px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

@media (max-width: 680px) {
  .hud__top,
  .hud__bottom {
    align-items: flex-start;
    flex-direction: column;
  }

  .hud__bottom {
    flex-direction: column-reverse;
  }

  .hud__bottom p {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status[data-state="charge"] .status__dot {
    animation: none;
  }
}
</style>
</head>
<body>
  <main class="app" aria-label="RoboCat 3D animation">
    <canvas id="scene" aria-label="Animated 3D RoboCat"></canvas>

    <section class="hud" aria-label="RoboCat controls">
      <div class="hud__top">
        <div>
          <div class="eyebrow">3D ROBOTS</div>
          <h1>RoboCat 3D</h1>
        </div>

        <div class="status" aria-live="polite">
          <span class="status__dot"></span>
          <span id="statusText">WALK CYCLE</span>
        </div>
      </div>

      <div class="hud__bottom&q.........完整代码请登录后点击上方下载按钮下载查看

网友评论0