three.js 场景编辑器 源码解析(十四)

本章介绍一下命令的基类Command.js,这个文件是编辑器的所有操作命令共性提取的文件。

 //命令基类(编辑的对象)
var Command = function ( editorRef ) {

	this.id = - 1;			   //命令的id,主要是对应history中的序号
	this.inMemory = false;     //命令可以在内存中,也可以序列化到json中,方便存储
	this.updatable = false;    //命令是否可以更新??
	this.type = '';			   //命令的类型
	this.name = '';			   //命令的名称

	if ( editorRef !== undefined ) {		
		//对象级别的editor引用,每个新创建的对象都有这个成员
		Command.editor = editorRef;     //使用函数调用方式传入的editor,而不是new方式,静态成员

	}
	this.editor = Command.editor;	//命令编辑
};

//原型上添加函数
Command.prototype.toJSON = function () {

	//返回对象
	var output = {};
	output.type = this.type;
	output.id = this.id;
	output.name = this.name;
	return output;
};

//原型上添加函数
Command.prototype.fromJSON = function ( json ) {
	//设置成员
	this.inMemory = true;
	this.type = json.type;
	this.id = json.id;
	this.name = json.name;
};

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值