three实现三维儿童游乐场三维场景动画效果代码

代码语言:html

所属分类:三维

代码描述:three实现三维儿童游乐场三维场景动画效果代码

代码标签: three 三维 儿童 游乐场 三维 场景 动画

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

<!doctype html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <title>儿童主题乐园 3D 场景(Three.js)</title>
  <style>
    html, body { margin:0; height:100%; overflow:hidden; background:#87ceeb; }
    #hud{
      position:fixed; left:12px; top:12px; z-index:10;
      padding:10px 12px; border-radius:10px;
      background:rgba(255,255,255,.75); color:#222;
      font: 13px/1.4 system-ui, -apple-system, Segoe UI, Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
      user-select:none;
    }
    #hud b{ display:block; margin-bottom:4px; }
    #hud kbd{ background:#fff; border:1px solid rgba(0,0,0,.15); border-bottom-width:2px; padding:1px 6px; border-radius:6px; }
  </style>

  <script type="importmap">
    {
      "imports": {
        "three": "https://unpkg.com/three@0.160.0/build/three.module.js",
        "three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
      }
    }
  </script>
</head>
<body>
  <div id="hud">
    <b>儿童主题乐园 3D</b>
    鼠标:拖拽旋转 / 滚轮缩放 / 右键平移<br>
    <kbd>Space</kbd> 暂停/继续动画
  </div>

  <script type="module">
    import * as THREE from "three";
    import { OrbitControls } from "three/addons/controls/OrbitControls.js";

    // 场景
    const scene = new THREE.Scene();
    scene.background = new THREE.Color(0x87ceeb);
    scene.fog = new THREE.Fog(0x87ceeb, 30, 220);

    const camera = new THREE.PerspectiveCamera(55, innerWidth/innerHeight, 0.1, 500);
    camera.position.set(36, 22, 46);

    const renderer = new THREE.WebGLRenderer({ antialias:true });
    renderer.setSize(innerWidth, innerHeight);
   .........完整代码请登录后点击上方下载按钮下载查看

网友评论0