Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
* { margin: 0; padding: 0; } #world { position: absolute; width: 100%; height: 100%; overflow: hidden; background: linear-gradient(#e4e0ba, #f7d9aa); }
JavaScript
var Colors = { red:0xf25346, yellow:0xedeb27, white:0xd8d0d1, brown:0x59332e, pink:0xF5986E, brownDark:0x23190f, blue:0x68c3c0, green:0x458248, purple:0x551A8B, lightgreen:0x629265, }; var scene, camera, fieldOfView, aspectRatio, nearPlane, farPlane, HEIGHT, WIDTH, renderer, container; function createScene() { // Get the width and height of the screen // and use them to setup the aspect ratio // of the camera and the size of the renderer. HEIGHT = window.innerHeight; WIDTH = window.innerWidth; // Create the scene. scene = new THREE.Scene(); // Add FOV Fog effect to the scene. Same colour as the BG int he stylesheet. scene.fog = new THREE.Fog(0xf7d9aa, 100, 950); // Create the camera aspectRatio = WIDTH / HEIGHT; fieldOfView = 60; nearPlane = 1; farPlane = 10000; camera = new THREE.PerspectiveCamera( fieldOfView, aspectRatio, nearPlane, farPlane ); // Position the camera camera.position.x = 0; camera.position.y = 150; camera.position.z = 100; // Create the renderer renderer = new THREE.WebGLRenderer ({ // Alpha makes the background transparent, antialias is performant heavy alpha: true, antialias:true }); //set the size of the renderer to fullscreen renderer.setSize (WIDTH, HEIGHT); //enable shadow rendering renderer.shadowMap.enabled = true; // Add the Renderer to the DOM, in the world div. container = document.getElementById('world'); container.appendChild (renderer.domElement); //RESPONSIVE LISTENER window.addEventListener('resize', handleWindowResize, false); } //RESPONSIVE FUNCTION function handleWindowResize() { HEIGHT = window.innerHeight; WIDTH = window.innerWidth; renderer.setSize(WIDTH, HEIGHT); camera.aspect = WIDTH / HEIGHT; camera.updateProjectionMatrix(); } var hemispshereLight, shadowLight; function createLights(){ // Gradient coloured light - Sky, Ground, Intensity hemisphereLight = new THREE.HemisphereLight(0xaaaaaa,0x000000, .9) // Parallel rays shadowLight = new THREE.DirectionalLight(0xffffff, .9); shadowLight.position.set(0,350,350); shadowLight.castShadow = true; // define the visible area of the projected shadow shadowLight.shadow.camera.left = -650; shadowLight.shadow.camera.right = 650; shadowLight.shadow.camera.top = 650; shadowLight.shadow.camera.bottom = -650; shadowLight.shadow.camera.near = 1; shadowLight.shadow.camera.far = 1000; // Shadow map size shadowLight.shadow.mapSize.width = 2048; shadowLight.shadow.mapSize.height = 2048; // Add the lights to the scene scene.add(hemisphereLight); scene.add(shadowLight); } Land = function(){ var geom = new THREE.CylinderGeometry(600,600,1700,40,10); //rotate on the x axis geom.applyMatrix(new THREE.Matrix4().makeRotationX(-Math.PI/2)); //create a material var mat = new THREE.MeshPhongMaterial({ color: Colors.lightgreen, shading:THREE.FlatShading, }); //create a mesh of the object this.mesh = new THREE.Mesh(geom, mat); //receive shadows this.mesh.receiveShadow = true; } Orbit = function(){ var geom =new THREE.Object3D(); this.mesh = geom; //this.mesh.add(sun); } Sun = function(){ this.mesh = new THREE.Object3D(); var sunGeom = new THREE.SphereGeometry( 400, 20, 10 ); var sunMat = new THREE.MeshPhongMaterial({ color: Colors.yellow, shading:THREE.FlatShading, }); var sun = new THREE.Mesh(sunGeom, sunMat); //sun.applyMatrix(new THREE.Matrix4().makeRotationX(-Math.PI/2)); sun.castShadow = false; sun.receiveShadow = false; this.mesh.add(sun); } Cloud = function(){ // Create an empty container for the cloud this.mesh = new THREE.Object3D(); // Cube geometry and material var geom = new THREE.DodecahedronGeometry(20,0); var mat = new THREE.MeshPhongMaterial({ color:Colors.white, }); var nBlocs = 3+Math.floor(Math.random()*3); for (var i=0; i
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>ThreeJS 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号