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>
    * { margin: 0; padding: 0; }
    body { overflow: hidden; background: #1a1a2e; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; }
    canvas { display: block; }
    #title {
        position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
        color: #fff; font-size: 20px; letter-spacing: 4px; pointer-events: none;
        text-shadow: 0 0 12px rgba(255,150,180,.8); z-index: 10; opacity: .9;
    }
    #tip {
        position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
        color: rgba(255,255,255,.7); font-size: 12px; pointer-events: none; z-index: 10;
    }
    #loading {
        position: fixed; inset: 0; background: linear-gradient(#2a2a4a,#4a3a5a);
        display: flex; flex-direction: column; justify-content: center; align-items: center;
        color: #ffd9e8; z-index: 99; transition: opacity .8s; font-size: 18px; letter-spacing: 2px;
    }
    #loading .flower { font-size: 42px; animation: spin 3s linear infinite; margin-bottom: 20px; }
    @keyframes spin { to { transform: rotate(360deg); } }
</style>
</head>
<body>
<div id="title">樱 花 山 水</div>
<div id="tip">拖动旋转 · 滚轮缩放 · 右键平移</div>
<div id="loading"><div class="flower">🌸</div>正在栽种樱花树...</div>

<script type="importmap">
{
    "imports": {
        "three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
        "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"
    }
}
</script>

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

/* ============ 0. Simplex 噪声 ============ */
const SimplexNoise = (() => {
    const grad3 = [[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],
                   [1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]];
    const p = []; for (let i = 0; i < 256; i++) p[i] = i;
    for (let i = 255.........完整代码请登录后点击上方下载按钮下载查看

网友评论0