three实现三维树脂微缩岛代码
代码语言:html
所属分类:三维
代码描述: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>树脂微缩岛 · Resin Island</title>
<style>
html,body{margin:0;height:100%;overflow:hidden;background:#f5ebdc;
font-family:"PingFang SC","Microsoft YaHei",system-ui,sans-serif}
canvas{display:block}
#title{position:fixed;top:28px;left:32px;color:#6b5a43;pointer-events:none;z-index:5}
#title h1{margin:0;font-size:20px;font-weight:600;letter-spacing:3px;
font-family:"Noto Serif SC","Songti SC",serif}
#title p{margin:7px 0 0;font-size:10px;letter-spacing:4px;opacity:.6;text-transform:uppercase}
#hint{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);
font-size:12px;color:#8a7658;letter-spacing:2px;opacity:.8;pointer-events:none;z-index:5}
#vig{position:fixed;inset:0;pointer-events:none;z-index:4;
background:radial-gradient(ellipse at 50% 42%,transparent 55%,rgba(101,78,45,.15) 100%)}
#loading{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;
background:#f5ebdc;color:#8a7658;font-size:13px;letter-spacing:3px;z-index:10;
transition:opacity .8s}
</style>
<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>
</head>
<body>
<div id="loading">正在生成微缩岛屿 …</div>
<div id="title"><h1>树脂微缩岛</h1><p>Resin Diorama · Three.js</p></div>
<div id="hint">拖拽旋转 · 滚轮缩放 · 双击切换自动旋转</div>
<div id="vig"></div>
<script type="module">
import * as THREE from 'three';
import {OrbitControls} from 'three/addons/controls/OrbitControls.js';
import {RoomEnvironment} from 'three/addons/environments/RoomEnvironment.js';
/* ---------------- 基础参数(CPU 与 GLSL 保持一致) ---------------- */
const HALF=5.0, RAD=1.2, WATER=2.35;
const RIDGE=[[-4.6,3.4],[-4.5,-0.8],[-3.9,-3.9],[-1.2,-4.5],[1.8,-4.0],[2.9,-3.0]];
const sstep=(a,b,x)=>{const t=Math.min(1,Math.max(0,(x-a)/(b-a)));return t*t*(3-2*t);};
.........完整代码请登录后点击上方下载按钮下载查看















网友评论0