3D星球动画html,基于Three.js实现的3D土星(星球)动画

JavaScript

语言:

JaveScriptBabelCoffeeScript

确定

function getMat(color) {

// our material is a phong material, with no shininess (highlight) and a black specular

return new THREE.MeshPhongMaterial({

color: color,

shininess: 0,

specular: 0x000000,

shading: THREE.FlatShading // THREE.SmoothShading

});

}

// colors

var Colors = {

green: 0x8fc999,

blue: 0x5fc4d0,

orange: 0xee5624,

yellow: 0xfaff70,

}

var colorsLength = Object.keys(Colors).length;

function getRandomColor() {

var colIndx = Math.floor(Math.random() * colorsLength);

var colorStr = Object.keys(Colors)[colIndx];

return Colors[colorStr];

}

// parameters to customize the planet

var parameters = {

minRadius: 30,

maxRadius: 50,

minSpeed: .015,

maxSpeed: .025,

particles: 300,

minSize: .1,

maxSize: 2,

}

// For a THREEJS project we need at least

// a scene

// a renderer

// a camera

// a light (1 or many)

// a mesh (an object to display)

var scene, renderer, camera, saturn, light;

var WIDTH = window.innerWidth,

HEIGHT = window.innerHeight;

var controls;

// initialise the world

function initWorld() {

//

// THE SCENE

//

scene = new THREE.Scene();

//

// THE CAMERA

//

// Perspective or Orthographic

// Field of view : I use 75, play with it

// Aspect ratio : width / height of the screen

// near and far plane : I usually set them at .1 and 2000

/*

camera = new THREE.PerspectiveCamera(

fieldOfView,

aspectRatio,

nearPlane,

farPlane

);

*/

camera = new THREE.PerspectiveCamera(75, WIDTH / HEIGHT, .1, 2000);

camera.position.z = 100;

//

// THE RENDERER

//

renderer = new THREE.WebGLRenderer({

alpha: true,

antialias: true

});

renderer.setSize(WIDTH, HEIGHT);

renderer.shadowMapEnabled = true;

// Make the renderer use the #world div to render le scene

container 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值