three打造三维鱼骨随鼠标游动躲避障碍物效果代码
代码语言:html
所属分类:三维
代码描述:three打造三维鱼骨随鼠标游动躲避障碍物效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<html lang="en"><head>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css?family=Allerta+Stencil" rel="stylesheet">
<style>
#ocean {
position: absolute;
width: 100%;
height: 100%;
background: linear-gradient(#045c7c, #0d324e);
}
body {
margin: 0;
height: 100%;
overflow: hidden;
}
#overlay {
background: white;
font-family: "Allerta Stencil", sans-serif;
font-size: 1em;
opacity: 0.75;
position: absolute;
width: 100%;
height: 100%;
display: none;
top: 0;
left: 0;
}
#settings {
margin-top: 50px;
font-size: 2.8em;
}
#parameter {
margin-top: 50px;
font-size: 1.1em;
}
#holder {
width: 40%;
margin-left: auto;
margin-right: auto;
}
#parameter {
width: 100%;
margin-top: 20px;
text-align: center;
}
#settings {
text-align: center;
}
.slidecontainer {
width: 100%;
}
.slider:hover {
opacity: 0.85;
}
.slider {
-webkit-appearance: none;
margin-top: 30px;
width: 100%;
height: 2px;
border-radius: 5px;
background: #d3d3d3;
outline: none;
opacity: 0.25;
-webkit-transition: 0.2s;
transition: opacity 0.2s;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
display: inline-block;
margin-left: 0px;
height: 45px;
border-radius: 100%;
width: 45px;
border: solid black 6px;
cursor: pointer;
}
.slider::-moz-range-thumb {
display: inline-block;
margin-left: 0px;
height: 50px;
border-radius: 100%;
width: 50px;
border: solid black 4px;
cursor: pointer;
}
#button {
margin-top: 40px;
width: 100%;
background-color: white;
color: black;
border: 3px solid #555555;
font-size: 1.75em;
font-family: "Allerta Stencil", sans-serif;
}
#button:hover {
background-color: #555555;
color: white;
}
</style>
</head>
<body>
<div id="ocean" class="ocean"></div>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.109.js"></script>
<script>
let mousePos = { x: 0, y: 0 };
HEIGHT = window.innerHeight,
WIDTH = window.innerWidth,
flag = true;
const Pi = Math.PI,
scene = new THREE.Scene(),
camera = new THREE.PerspectiveCamera(60, WIDTH / HEIGHT, 1, 10000),
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true }),
container = document.getElementById('ocean'),
ambientLight = new THREE.AmbientLight(0x045c7c, .5),
hemisphereLight = new THREE.HemisphereLight(0xaaaaaa, 0x000000, .9),
shadowLight = new THREE.DirectionalLight(0xffffff, .9);
const shapes = { //all the variables behind the objects in the scene
seabed: {
radius: 660,
height: 700,
rSeg: 50,
hSeg: 20,
ampR: 20,
speedC: .015,
color: 0x531e1e,
rotation: .005,
x: 0,
y: -620,
z: -50,
step: .000005 },
bottle: {
colors: ["orange", "blue", "white", "red", "green", "blue"],
height: 20,
radius: 5,
segments: 16,
x: 0,
y: 150,
z: 110,
scale: 1 },
can: {
colors: ["green", "orange", "black", "red", "brown", "blue"],
radius: 5,
height: 20,
segments: 16 },
fish: {
radius: 4,
height: 15,
segments: 12 },
water: {
groupNumber: 22,
membersNumber: 20,
depth: 450,
step: .0015 },
tire: {
innerR: 8,
outerR: 16,
rSegments: 8,
tSegments: 20,
number: 25,
step: .003 },
tentacle: {
partsNum: 20,
partsOffset: 30,
f.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0