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.0" />
  <title>Three.js 清明节祭祖三维场景</title>
  <style>
    html, body {
      margin: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      font-family: "Microsoft YaHei", sans-serif;
      background: #cfd8dc;
    }
    #info {
      position: absolute;
      top: 12px;
      left: 12px;
      z-index: 10;
      color: #222;
      background: rgba(255,255,255,0.72);
      padding: 10px 14px;
      border-radius: 10px;
      line-height: 1.7;
      font-size: 14px;
      backdrop-filter: blur(4px);
    }
    canvas {
      display: block;
    }
  </style>
</head>
<body>
  <div id="info">
    <b>清明节祭祖三维场景</b><br />
    鼠标左键旋转、滚轮缩放、右键平移<br />
    场景包含:墓碑、供桌、香炉、蜡烛、纸钱、烟雾、山丘与树木
  </div>
  <script type="importmap">
{
 "imports":{
    "three":"//repo.bfw.wiki/bfwrepo/js/module/three/build/164/three.module.js",
    "three/addons/":"//repo.bfw.wiki/bfwrepo/js/module/three/examples/164/jsm/"
 }
}
</script>

<script type="module">

    import * as THREE from 'three';

    import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
    // =========================
    // 基础初始化
    // =========================
    const scene = new THREE.Scene();
    scene.fog = new THREE.Fog(0xcfd8dc, 30, 120);

    const camera = new THREE.PerspectiveCamera(
      60,
      window.innerWidth / window.innerHeight,
      0.1,
      500
    );
    camera.position.set(16, 12, 22);

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

网友评论0