three实现金鱼游动光影效果代码

代码语言:html

所属分类:动画

代码描述:three实现金鱼游动光影效果代码,通过three新建一个plane平面,并加载一张金鱼照片作为材质,结合webgl实现光影效果让金鱼看上去在游动。

代码标签: three 金鱼 游动 光影

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

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

<head>
    <meta charset="UTF-8">
    <style>
        body {margin:0; overflow:hidden;
    background-color:#000;
    }
    </style>

</head>

<body>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.88.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/OBJLoader.min.js"></script>
    <script >
        var camera, scene, renderer;
			var pointLight, pointLight2;
      var mesh, materialShader;
	var mouseX = 0, mouseY = 0;
      const TEXTURE_PATH = '//repo.bfw.wiki/bfwrepo/icon/';
			init();
			animate();
			function init() {
				camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 );
				camera.position.set( 0, 10, 60 );
				scene = new THREE.Scene();
				scene.add( new THREE.AmbientLight( 0xD31623 ) );
				// lights
				function createLight( color ) {
					var pointLight = new THREE.PointLight( color, 2.2, 43 );

					var geometry = new THREE.SphereGeometry( 0.001, 0.001, 0.001 );
					var material = new THREE.MeshBasicMaterial( { color: color } );
          
					var sphere = new THREE.Mesh( geometry, material );
          
					pointLight.add( sphere );
					return pointLight;
				}
				pointLight = createLight( 0xe0e0e0 );
				scene.add( pointLight );
				pointLight2 = createLight( 0xe0e0e0);
				//scene.add( pointLight2 );
        
        pointLight.position.y = 20;
        pointLight.position.x = 0;
        pointLight.position.z = 16;
        
        var manager = new THREE.LoadingManager();
        loader = new THREE.TextureLoader();
        loader.setCrossOrigin( '//repo.bfw.wiki' );
        
        var texture_wall = loader.load( TEXTURE_PATH + '62fa05136a7d0.png' );
        
        var wall = new THREE.BoxBufferGeometry( 0, 26, 33);
				
        var material = new THREE.MeshStandardMaterial( { transpare.........完整代码请登录后点击上方下载按钮下载查看

网友评论0