three.js源码翻译及案例(二)-src/scenes/FogExp2.js

源码位置

  • 该源码位置在three.js源码src/scenes文件夹下

源码翻译

/**
 * @author mrdoob / http://mrdoob.com/
 * @author alteredq / http://alteredqualia.com/
 */

import { Color } from '../math/Color.js';
/*
* 本文档为Three.js翻译文档,如有任何疑问请联系:
* pygmalioneffect@aliyun.com
*/
function FogExp2(color, density) {
	/**
	 * 该雾为指数雾对应的还有线性雾
	 * 线性雾的意思是雾的密度是随着指数的增加而增大的
	 * 接收三个参数分别为{
	 * 雾的颜色,
	 * 应用雾的最大距离,
	 * 应用雾的最小距离,
	 * }
	 */
	//雾对象的名称,非必选属性,默认为空
	this.name = '';
	//雾的颜色可以传六位十六进制(0x000000)或者css中的颜色样式('blue')
	this.color = new Color(color);
	//雾的指数强度,缺省值为0.00025
	this.density = (density !== undefined) ? density : 0.00025;

}

Object.assign(FogExp2.prototype, {
	//是否为雾
	isFogExp2: true,

	/**
	 * 克隆方法,返回一个新的雾。
	 */
	clone: function () {

		return new FogExp2(this.color, this.density);

	},
	
	/**
	 * 转变为json格式,返回json,数据结构如下。
	 */
	toJSON: function ( /* meta */) {

		return {
			type: 'FogExp2',
			color: this.color.getHex(),
			density: this.density
		};

	}

});

export { FogExp2 };

案例地址

  • 缩略图
    在这里插入图片描述
  • 暂时博客还没搭起来以后再加
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值