three实现立方体爬上楼梯堆叠动画效果代码
代码语言:html
所属分类:三维
代码描述:three实现立方体爬上楼梯堆叠动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url(https://fonts.googleapis.com/css?family=Open+Sans:800); body{ margin: 0; padding: 0; overflow: hidden; } footer{ position: absolute; padding: 15px; bottom: 0; } footer a{ font-family:'Open Sans', sans-serif; font-size: 14px; color: #212121; text-decoration: underline; } </style> </head> <body> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/TweenMax.min.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.72.js"></script> <script> var that; var StairwayCubes = function () { this.scene = new THREE.Scene(); that = this; }; StairwayCubes.prototype.init = function () { this.createCamera(); this.createRenderer(); this.createBoxes(); this.createFloor(); this.createLights(); this.animateBoxes(); this.render(); }; StairwayCubes.prototype.createCamera = function () { this.camera = new THREE.OrthographicCamera(window.innerWidth / -2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / -2, -1000, 1000); this.camera.position.x = 100; this.camera.position.y = 100; this.camera.position.z = 100; this.camera.lookAt(new THREE.Vector3(0, 0, 0)); this.camera.zoom = 1.1; this.camera.updateProjectionMatrix(); //Adjust the scene to center the stairs this.scene.position.z = 150; this.scene.position.y = -50; }; StairwayCubes.prototype.createRenderer = function () { this.renderer = new THREE.WebGLRenderer({ antialias: true }); this.renderer.setSize(window.innerWidth, window.innerHeight); this.renderer.setClearColor(0xf2f2f2); this.renderer.shadowMapEnabled = true; this.renderer.shadowMapType = THREE.PCFSoftShadowMap; this.renderer.shadowMapSoft = true; document.body.appendChild(this.renderer.domElement); //window.addEventListener('resize', this.onWindowResize, false); }; StairwayCubes.prototype.createBoxes = function () { this.numberOfStairs = 4; this.repeatBoxeAnimation = this.numberOfStairs - 1; this.stairs = []; var positionZStart = -25; //start position of the stairs on their Z axis var geometry = new THREE.BoxGe.........完整代码请登录后点击上方下载按钮下载查看
网友评论0