three实现三维圆形笼子小球跳动旋转动画效果代码

代码语言:html

所属分类:三维

代码描述:three实现三维圆形笼子小球跳动旋转动画效果代码

代码标签: three 三维 圆形 笼子 小球 跳动 旋转 动画

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

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

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

  
  
  
<style>
body {
  overflow: hidden;
  margin: 0;
}
</style>



  <script async type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/es-module-shims.1.5.1.js"></script>
  
</head>

<body translate="no">

<script type="importmap">
  {
    "imports": {
      "three": "//repo.bfw.wiki/bfwrepo/js/module/three/build/158/three.module.js",
       "three/addons/": "//repo.bfw.wiki/bfwrepo/js/module/three/examples/158/jsm/"
    }
  }
</script>
  
 
      <script type="module">
// https://discourse.threejs.org/t/transparent-object-issue/57882

import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";


// boring stuff, scroll down to the next comment

console.clear();

var scene = new THREE.Scene();
scene.background = new THREE.Color('gainsboro');

var camera = new THREE.PerspectiveCamera(30, innerWidth / innerHeight);
camera.position.set(5, 5, 15);
camera.lookAt(scene.position);

var renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(innerWidth, innerHeight);
renderer.setAnimationLoop(animationLoop);
document.body.appendChild(renderer.domElement);

var light = new THREE.DirectionalLight('white', 2);
light.position.set(1, 1, 1);
scene.add(light);

var controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.autoRotate = true;


window.addEventListener("resize", event => {
  camera.aspect = innerWidth / innerHeight;
  camera.updateProjectionMatrix();
  renderer.setSize(innerWidth, innerHeight);
});


// create a canvas texture

var canvas = document.createElement('CANVAS');
canvas.width = 128;
canvas.height = 128;

var context = canvas.getContext('2d');
context.fillStyle = 'White';
context.gl.........完整代码请登录后点击上方下载按钮下载查看

网友评论0