three实现三维彩色鸡蛋掉落草坪动画效果代码

代码语言:html

所属分类:三维

代码描述:three实现三维彩色鸡蛋掉落草坪动画效果代码,鼠标移动,视角也平移。

代码标签: three 三维 彩色 鸡蛋 掉落 草坪 动画

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

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
  
<style>
@import url(https://fonts.googleapis.com/css?family=Montserrat);

body {
  margin: 0;
}
canvas {
  display: block;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  font-family: Montserrat;
}

.modal-content {
  background-color: #aaffaa;
  padding: 20px;
  border-radius: 10px;
  box-shadow: inset 0px 0px 5px 5px rgba(0,0,0,0.3);
  animation: fadeInModal 1s ease-in-out forwards;
}

button {
  position: relative;
  left: 50%;
  transform: translate(-50%, 0);
  background-color: #c2fbd7;
  border-radius: 100px;
  box-shadow: rgba(44, 187, 99, .2) 0 -25px 18px -14px inset,rgba(44, 187, 99, .15) 0 1px 2px,rgba(44, 187, 99, .15) 0 2px 4px,rgba(44, 187, 99, .15) 0 4px 8px,rgba(44, 187, 99, .15) 0 8px 16px,rgba(44, 187, 99, .15) 0 16px 32px;
  color: green;
  cursor: pointer;
  display: inline-block;
  font-family: CerebriSans-Regular,-apple-system,system-ui,Roboto,sans-serif;
  padding: 7px 20px;
  text-align: center;
  text-decoration: none;
  transition: all 250ms;
  border: 0;
  font-size: 16px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  &:hover {
    box-shadow: rgba(44,187,99,.35) 0 -25px 18px -14px inset,rgba(44,187,99,.25) 0 1px 2px,rgba(44,187,99,.25) 0 2px 4px,rgba(44,187,99,.25) 0 4px 8px,rgba(44,187,99,.25) 0 8px 16px,rgba(44,187,99,.25) 0 16px 32px;
    transform: translate(-50%, 0) scale(1.3) rotate(-4deg);
  }
}

@keyframes fadeInModal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
</style>

  
</head>

<body translate="no">
  <!-- Modal -->
<div id="modal" class="modal">
  <div class="modal-content">
    <h2> good job</h2>
    <button onclick="modal.style.display = 'none';">Close</button>
  </div>
</div>
  <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.139.js"></script>
      <script type="module">


const modal = document.getElementById('modal');

// Scene setup
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
50, window.innerWidth / window.innerHeight, 0.1, 1000);

camera.position.set(0, 0, 50);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0xccccdd);
document.body.appendChild(renderer.domElement);

// Lights
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
directionalLight.position.set(0, 1, 0);
scene.add(directionalLight);

// Add mouse movement control
const mouse = new THREE.Vector2();
window.addEventListener('mousemove', event => {
  mouse.x = event.clientX / window.innerWidth * 2 - 1;
  mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
});

// Add grass texture
const grassText.........完整代码请登录后点击上方下载按钮下载查看

网友评论0