three实现三维仓鼠生活群落模拟器代码

代码语言:html

所属分类:三维

代码描述:基于 Three.js(WebGL)的仓鼠群落模拟器「Burrow · Sunflower Hollow」。仓鼠会自主进食、喝水、跑轮、社交、睡觉、滑滑梯,还会繁育后代、经历生老病死,配有昼夜光照、跟随/导演镜头、观察日志和本地自动存档。

代码标签: three 三维 仓鼠 群落 模拟器 代码

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

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width,initial-scale=1,viewport-fit=cover" name="viewport"/>
<title>鼠窝 · 向日葵山谷|仓鼠群落模拟器</title>
<link href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%23b4ee87'/%3E%3Cpath d='M9 17Q4 6 15 9L18 13H23Q34 4 32 16Q39 32 21 34Q3 32 9 17' fill='%23232b21'/%3E%3Ccircle cx='15' cy='22' r='2' fill='%23b4ee87'/%3E%3Ccircle cx='27' cy='22' r='2' fill='%23b4ee87'/%3E%3C/svg%3E" rel="icon"/>
<style>
:root{color-scheme:dark;--bg:#111516;--panel:#1a1f21;--elevated:#23292b;--line:#32383a;--dim:#98a3a5;--muted:#aab4b4;--soft:#d4ddda;--text:#f2f5ed;--lime:#b5ec91;--aqua:#8accc2;--gold:#edc27c;--coral:#dfa48e;--violet:#b7a2d9;--mono:'Cascadia Code','SFMono-Regular',Consolas,'Courier New','PingFang SC','Microsoft YaHei',monospace;--sans:'PingFang SC','Hiragino Sans GB','Microsoft YaHei','Noto Sans CJK SC','Source Han Sans SC',system-ui,'Segoe UI',Arial,sans-serif;--display:'PingFang SC','Hiragino Sans GB','Microsoft YaHei','Noto Sans CJK SC',system-ui,sans-serif}
*{box-sizing:border-box}
html{min-width:300px;background:var(--bg)}
body{margin:0;background:radial-gradient(ellipse at 36% -35%,#222a24 0,transparent 62%),var(--bg);color:var(--text);font-family:var(--sans);-webkit-font-smoothing:antialiased}
button{color:inherit;font:inherit;cursor:pointer;background:none;border:none}
button:focus-visible,[tabindex]:focus-visible{outline:2px solid var(--lime);outline-offset:3px}
button:disabled{opacity:.4;cursor:default}
button,a{-webkit-tap-highlight-color:transparent}
button{touch-action:manipulation}
button:hover{color:#fff}
h1,h2,p{margin:0}
button svg,span svg,div>svg{display:block}
.ico{width:18px;height:18px;flex:none;stroke:currentColor;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round;fill:none}
.mono{font-family:var(--mono);font-variant-numeric:tabular-nums}
button,.badge{-webkit-user-select:none;user-select:none}
[hidden]{display:none!important}
.top{height:70px;border-bottom:1px solid #303635;background:#171b1bf7}
.topin,main{width:min(1780px,100%);margin:auto;padding:0 clamp(18px,3vw,54px)}
.topin{height:100%;display:flex;align-items:center;gap:35px}
.brand{display:flex;align-items:center;gap:10px;font:800 27px/.95 var(--display);letter-spacing:.5px;padding:0}
.brandmark{width:36px;height:36px;border-radius:10px;background:var(--lime);display:grid;place-items:center;color:#213320}
.brandmark svg{width:28px;height:28px}
.brandline{height:24px;width:1px;background:var(--line)}
.nav{display:flex;align-self:stretch;gap:20px}
.nav button{position:relative;color:var(--dim);font-weight:600;display:flex;align-items:center;gap:8px;padding:0 5px;font-size:14px}
.nav .on{color:var(--lime)}
.nav .on:after{content:'';position:absolute;height:2px;background:var(--lime);bottom:0;left:0;right:0}
.nav .ico{width:17px;height:17px}
.topright{margin-left:auto;display:flex;align-items:center;gap:10px}
.system{display:flex;align-items:center;gap:8px;color:#bac6bc;font-size:12px;font-weight:500;margin-right:10px}
.dot{width:6px;height:6px;border-radius:50%;background:var(--lime);display:inline-block;flex:none}
.system .dot{box-shadow:0 0 8px #9fda743a}
.square{width:33px;height:33px;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--line);background:#1d2223;border-radius:7px;color:var(--muted)}
.square:hover,.ghost:hover,.speed button:hover{background:#303738;color:var(--text)}
.square .ico{width:16px;height:16px}
main{padding-bottom:22px}
.intro{display:flex;align-items:center;justify-content:space-between;padding:27px 0 22px;gap:12px}
.eyebrow{display:flex;align-items:center;gap:9px;color:var(--lime);font:600 10px/1.3 var(--mono);letter-spacing:1.2px}
.eyebrow:before{content:'';height:2px;width:19px;background:var(--lime)}
h1{font:700 clamp(31px,2.65vw,46px)/1.1 var(--display);letter-spacing:-.5px;margin-top:6px}
.daybox{display:flex;align-items:center;gap:12px}
.sunicon{width:40px;height:40px;border:1px solid #4a4131;color:var(--gold);background:#2a291f;border-radius:10px;display:grid;place-items:center}
.sunicon .ico{width:22px;height:22px}
.daytxt{display:flex;flex-direction:column;gap:3px;align-items:flex-end}
.daytxt b{font-size:14px;font-weight:650}
.daytxt span{font-size:11px;color:var(--dim)}
.workbench{display:grid;grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr) clamp(268px,23.3vw,376px);gap:17px;align-items:stretch;height:clamp(459px,calc(61vh + 1vw),760px)}
.viewer,.panel,.stat,.activity,.journal{background:var(--panel);border:1px solid var(--line);border-radius:13px}
.viewer{min-width:0;display:flex;flex-direction:column;overflow:hidden}
.scene{min-height:0;position:relative;flex:1;background:#273238;overflow:hidden;isolation:isolate}
.scene canvas{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:grab}
.scene canvas:active{cursor:grabbing}
.scene:after{position:absolute;content:'';inset:0;pointer-events:none;z-index:1;box-shadow:inset 0 0 68px #11161926}
.overlay{position:absolute;z-index:2}
.camtop{left:16px;top:16px;display:flex;align-items:center;gap:10px;pointer-events:none}
.live{display:flex;align-items:center;gap:6px;color:#c1efa6;background:#17251deb;border:1px solid #6f8c674d;padding:6px 9px;border-radius:5px;font:700 10px/1 var(--mono);letter-spacing:1px}
.camid{font:500 10px var(--mono);letter-spacing:1.1px;color:#ced8d3;text-shadow:0 1px 3px #000}
.camright{top:14px;right:14px;display:flex;gap:7px}
.camright .square{color:#e2e9e5;background:#172023ab;border-color:#83948e45}
.camfoot{bottom:13px;left:16px;display:flex;gap:7px;align-items:center;font:500 10px var(--mono);letter-spacing:.2px;color:#d1dbd8;text-shadow:0 1px 3px #111}
.camfoot .ico{height:15px;width:15px}
.camcompass{bottom:14px;right:16px;color:#c7d3ca;display:flex;align-items:center;gap:5px;font:500 10px var(--mono);letter-spacing:1px}
.camcompass svg{width:23px;height:23px}
.camcompass path{transform-origin:12px 12px}
.transport{height:61px;flex:none;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 15px;border-top:1px solid #3c4442;background:#1e2425}
.transleft{display:flex;align-items:center;gap:11px}
.pause{border:1px solid #656f61;color:#d8efd0;background:#303d30;width:36px;height:33px;border-radius:6px;display:grid;place-items:center}
.pause:hover{background:#43503d}
.pause .ico{width:16px;height:16px}
.speed{display:inline-flex;align-items:center;padding:3px;gap:2px;border:1px solid #353c3c;background:#14191a;border-radius:7px}
.speed button{padding:0;width:37px;height:25px;border-radius:4px;color:#adb7b7;font:600 11px var(--mono)}
.speed button.active{background:var(--lime);color:#1b301e}
.ghost{display:inline-flex;align-items:center;justify-content:center;gap:7px;font-size:12px;font-weight:600;color:#bdc7c5;border-radius:6px;padding:7px 9px}
.ghost .ico{width:15px;height:15px}
.transright{display:flex;align-items:center;gap:7px}
.transright .divider{width:1px;height:18px;background:var(--line)}
.active-icon{color:var(--lime)!important;background:#303d31!important}
.side{min-height:0;display:grid;grid-template-rows:minmax(0,1fr) auto;gap:14px;min-width:0}
.panel{display:flex;flex-direction:column;min-height:0;overflow:hidden}
.panelhead{height:53px;min-height:53px;display:flex;align-items:center;justify-content:space-between;padding:0 17px;border-bottom:1px solid var(--line)}
.heading{display:flex;gap:9px;align-items:center}
.heading .ico{color:#a7b5ae;width:17px;height:17px}
h2{font:650 17px/1.1 var(--display);letter-spacing:0}
.count{font:500 11px var(--mono);border:1px solid #3b4442;background:#272e2c;border-radius:5px;padding:3px 7px;color:#c4d0c5}
.roster{flex:1;overflow:auto;scrollbar-width:thin;scrollbar-color:#49534f transparent;padding:2px 7px}
.resident{display:flex;align-items:center;gap:11px;width:100%;text-align:left;padding:7px 9px;min-height:43px;height:calc(100%/6);max-height:70px;border-bottom:1px solid #30363685}
.resident:last-child{border:0}
.resident:hover{background:#252c2c;border-radius:6px}
.face{width:clamp(36px,4.5vh,46px);height:clamp(36px,4.5vh,46px);border-radius:9px;object-fit:contain;background:#3b342b;flex:none}
.rtext{min-width:0;flex:1}
.rname{font-size:15px;line-height:1.35;font-weight:650;display:block}
.rstate{display:flex;align-items:center;gap:6px;font-size:11px;color:#a6b2af;line-height:1.4;margin-top:2px}
.rstate .dot{width:5px;height:5px}
.resident>.ico{width:13px;height:13px;color:#79847f}
.supplies .panelhead{height:42px;min-height:42px;border:0;padding-top:6px}
.refill{font-size:11px;color:#c8d5c2;gap:4px;padding:5px 6px}
.refill .ico{width:13px;height:13px}
.resourcegrid{display:grid;grid-template-columns:1fr 1fr;gap:15px;padding:12px 17px 17px}
.resitem{min-width:0}
.resline{display:flex;align-items:center;justify-content:space-between;gap:3px;font-size:12px}
.resline>span:first-child{display:flex;align-items:center;gap:5px;color:#c6cfcb}
.resline .ico{width:14px;height:14px}
.resline .mono{font-size:11px;color:var(--gold)}
.resitem:nth-child(2) .mono{color:var(--aqua)}
.bar{height:5px;background:#303738;overflow:hidden;border-radius:2px;margin-top:9px}
.bar i{display:block;height:100%;background:var(--gold);transition:width .4s;border-radius:2px}
.resitem:nth-child(2) i{background:var(--aqua)}
.stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:13px;margin-top:16px}
.stat{padding:15px 17px 13px;position:relative;overflow:hidden;min-width:0}
.stat-name{display:flex;align-items:center;gap:7px;font-size:12px;color:#bfcbc4;font-weight:550}
.stat-name .ico{width:15px;height:15px;color:var(--tone)}
.statline{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin-top:6px}
.figure{font:650 30px/1 var(--display);letter-spacing:-1px;font-variant-numeric:tabular-nums}
.statart{display:flex;align-items:center;height:24px;color:var(--tone);opacity:.78}
.statart svg{width:76px;height:23px}
.activity{display:flex;align-items:center;gap:18px;font-size:12px;padding:13px 17px;margin-top:14px}
.activity .heading{flex:none}
.activity .heading .ico{color:var(--lime)}
.activity .heading b{font-size:13px}
.activity .astream{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:#c2cbc7}
.activity time{font:10px var(--mono);color:var(--dim);margin-right:8px}
.activity .ghost{flex:none;margin-left:auto;font-size:11px;padding:3px}
.actsep{width:1px;height:16px;background:var(--line)}
.footer{display:flex;justify-content:space-between;margin-top:18px;color:#7f8b86;font:10px var(--mono);letter-spacing:.4px}
.footer span{display:flex;align-items:center;gap:5px}
.footer .ico{width:13px;height:13px}
.detail{padding:15px 17px;overflow:auto;scrollbar-width:thin;scrollbar-color:#49534f transparent}
.detailhero{display:flex;align-items:center;gap:12px;margin-bottom:15px}
.detailhero .face{width:53px;height:53px}
.detailhero strong{font:650 22px var(--display)}
.detailhero small{display:block;color:var(--muted);font:11px var(--mono);margin-top:3px}
.followtag{display:inline-flex;align-items:center;gap:5px;color:var(--lime);font:10px var(--mono);letter-spacing:.5px}
.followtag .ico{width:13px;height:13px}
.needs{display:grid;grid-template-columns:1fr 1fr;gap:15px}
.needhead{display:flex;justify-content:space-between;gap:3px;font-size:11px;color:var(--soft)}
.needhead span{color:var(--dim);font:10px var(--mono)}
.need .bar{margin-top:5px}
.detailstate{margin:15px 0 0;padding:9px 11px;border:1px solid #39433b;background:#222c25;border-radius:6px;display:flex;align-items:center;gap:7px;font-size:12px}
.detailmeta{display:flex;justify-content:space-between;gap:6px;border-top:1px solid var(--line);padding-top:12px;margin-top:14px;font-size:11px;color:var(--dim)}
.detailmeta strong{color:var(--soft);font-weight:550}
.tracking{position:absolute;z-index:3;transform:translate(-50%,-100%);pointer-events:none;text-align:center;white-space:nowrap}
.tracking b{display:block;border:1px solid #b5ec9199;background:#18271ded;color:var(--lime);font-size:11px;padding:3px 8px;border-radius:5px}
.tracking:after{content:'';margin:auto;display:block;width:1px;height:9px;background:var(--lime)}
.toast{position:absolute;left:50%;bottom:40px;transform:translate(-50%,6px);opacity:0;transition:.2s;z-index:6;pointer-events:none;font-size:12px;background:#17211ef0;border:1px solid #80927480;padding:8px 15px;border-radius:6px;white-space:nowrap}
.toast.show{transform:translate(-50%,0);opacity:1}
.journal{margin-top:0;overflow:hidden}
.journalbar{padding:16px 19px;display:flex;align-items:center;justify-content:space-between;gap:8px;border-bottom:1px solid var(--line)}
.journalbar .speed button{width:auto;padding:0 12px}
.eventlist{max-height:64vh;overflow:auto;scrollbar-width:thin;scrollbar-color:#49534f transparent;pad.........完整代码请登录后点击上方下载按钮下载查看

网友评论0