Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
#world { position: absolute; width: 100%; height: 100%; overflow: hidden; background: linear-gradient(#e4e0ba, #f7d9aa); }
JavaScript
var Colors = { red:0xf25346, white:0xd8d0d1, brown:0x59332e, pink:0xF5986E, brownDark:0x23190f, blue:0x68c3c0, }; window.addEventListener('load', init, false); function init(e) { // set up the scene, the camera and the renderer createScene(); // add the lights createLights(); // add the objects createPlane(); createSea(); createSky(); // follow mouse document.addEventListener('mousemove', handleMouseMove, false); // start a loop that will update the objects' positions // and render the scene on each frame loop(); // temp render // renderer.render(scene, camera); } var scene, camera, fieldOfView, aspectRatio, nearPlane, farPlane, HEIGHT, WIDTH, renderer, container; function createScene() { HEIGHT = window.innerHeight; WIDTH = window.innerWidth; scene = new THREE.Scene(); // Camera Stuff aspectRatio = WIDTH / HEIGHT; fieldOfView = 60; nearPlane = 1; farPlane = 10000; camera = new THREE.PerspectiveCamera( fieldOfView, aspectRatio, nearPlane, farPlane ); camera.position.x = 0; camera.position.z = 200; camera.position.y = 100; // Renderer creation renderer = new THREE.WebGLRenderer({ // Allow transparency to show the gradient background // we defined in the CSS alpha: true, // Activate the anti-aliasing; this is less performant, // but, as our project is low-poly based, it should be fine :) antialias: true }); renderer.setSize(WIDTH, HEIGHT); // shadows renderer.shadowMap.enabled = true; // add it container = document.getElementById('world'); container.appendChild(renderer.domElement); window.addEventListener('resize', handleWindowResize, false); } function handleWindowResize() { // update height and width of the renderer and the camera HEIGHT = window.innerHeight; WIDTH = window.innerWidth; renderer.setSize(WIDTH, HEIGHT); camera.aspect = WIDTH / HEIGHT; camera.updateProjectionMatrix(); } // Lighting stuff var hemisphereLight, shadowLight; function createLights() { // hemisphere light is a gradient colored light hemisphereLight = new THREE.HemisphereLight(0xaaaaaa, 0x000000, 0.9); shadowLight = new THREE.DirectionalLight(0xffffff, 0.9); shadowLight.position.set(150, 350, 350); shadowLight.castShadow = true; // define the visible area of the projected shadow shadowLight.shadow.camera.left = -400; shadowLight.shadow.camera.right = 400; shadowLight.shadow.camera.top = 400; shadowLight.shadow.camera.bottom = -400; shadowLight.shadow.camera.near = 1; shadowLight.shadow.camera.far = 1000; // define the resolution of the shadow; the higher the better, // but also the more expensive and less performant shadowLight.shadow.mapSize.width = 2048; shadowLight.shadow.mapSize.height = 2048; scene.add(hemisphereLight); scene.add(shadowLight); ambientLight = new THREE.AmbientLight(0xdc8874, .2); scene.add(ambientLight); } Sea = function () { var geom = new THREE.CylinderGeometry(600, 600, 800, 40, 10); //rotate that bad boy geom.applyMatrix(new THREE.Matrix4().makeRotationX(-Math.PI/2)); geom.mergeVertices(); var l = geom.vertices.length; this.waves = []; for (var i = 0; i < l; i++) { var v = geom.vertices[i]; this.waves.push({ y: v.y, x: v.x, z: v.z, ang: Math.random()*Math.PI*2, amp: 5 + Math.random()*15, speed: 0.016 + Math.random()*0.032 }); } var mat = new THREE.MeshPhongMaterial({ color: Colors.blue, transparent: true, opacity: 0.6, shading: THREE.FlatShading }); this.mesh = new THREE.Mesh(geom, mat); this.mesh.receiveShadow = true; } Sea.prototype.moveWaves = function () { var verts = this.mesh.geometry.vertices; var l = verts.length; for (var i=0; i
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>three.js 3d鼠标跟随-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号