最后是立方体本身对象:
因为立方体最后要旋转,所以,立方体对象里面不仅有面对象,还要有点对象,点旋转后才会引起面的旋转。length是立方体的边长,_initVector是初始化立方体的各个顶点,_draw方法就是把所有点形成面,将面放入数组,然后对面进行排序(就是根据面里的zIndex排序),排序好后,调用每个面里的draw方法。立方体就出来了。
- var Cube = function(length){ this.length = length;
- this.faces = []; this.vectors = [];
- } Cube.prototype = {
- _initVector:function(){ this.vectors[0] = new Vector(-this.length/2 , -this.length/2 , this.length/2);
- this.vectors[1] = new Vector(-this.length/2 , this.length/2 , this.length/2); this.vectors[2] = new Vector(this.length/2 , -this.length/2 , this.length/2);
- this.vectors[3] = new Vector(this.length/2 , this.length/2 , this.length/2); this.vectors[4] = new Vector(this.length/2 , -this.length/2 , -this.length/2);
- this.vectors[5] = new Vector(this.length/2 , this.length/2 , -this.length/2); this.vectors[6] = new Vector(-this.length/2 , -this.length/2 , -this.length/2);
相关文章
大家在看
-

福昕阅读器如何复制文字
2023-03-02
0万阅读
-

Dubbo 系列JDK SPI 原理解析
2023-02-24
0万阅读
-

欲为王者至尊 888元志美4倍速DVD刻录机评测
2023-02-22
6万阅读
-

拼音标注能手--中华拼读王
2023-02-17
10万阅读
-

360随身WiFi怎么设置隐藏信号 360随身wifi隐藏信号
2023-02-12
9万阅读
-

怎么用酷盘分享文件给好友
2023-02-11
12万阅读
-

企业应如何防范内存抓取恶意软件
2023-02-10
6万阅读
-

如何知道电脑是否含有病毒
2023-02-09
8万阅读
-

美图秀秀让你的国庆旅游照片更出彩
2023-01-16
9万阅读
-

u启动怎么用 U启动使用教程
2023-01-14
4万阅读
-

福昕阅读器如何复制文字
2023-03-02
0万阅读
-

Dubbo 系列JDK SPI 原理解析
2023-02-24
0万阅读
-

欲为王者至尊 888元志美4倍速DVD刻录机评测
2023-02-22
6万阅读
-

拼音标注能手--中华拼读王
2023-02-17
10万阅读
-

360随身WiFi怎么设置隐藏信号 360随身wifi隐藏信号
2023-02-12
9万阅读
-

怎么用酷盘分享文件给好友
2023-02-11
12万阅读
-

企业应如何防范内存抓取恶意软件
2023-02-10
6万阅读
-

如何知道电脑是否含有病毒
2023-02-09
8万阅读
-

美图秀秀让你的国庆旅游照片更出彩
2023-01-16
9万阅读
-

u启动怎么用 U启动使用教程
2023-01-14
4万阅读
