-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathWebGLRenderTarget.js
151 lines (130 loc) · 3.34 KB
/
WebGLRenderTarget.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* @author szimek / https://github.com/szimek/
* @author alteredq / http://alteredqualia.com/
*/
/**
* @classdesc 渲染目标对象
* @desc 通过options设置渲染目标对象,参数见对象的成员变量
* @param {number} width 宽度
* @param {number} height 高度
* @param {*} options 参数列表
* @constructor
*/
THREE.WebGLRenderTarget = function ( width, height, options ) {
/**
* @desc 宽度
* @type {number}
*/
this.width = width;
/**
* @desc 高度
* @type {number}
*/
this.height = height;
options = options || {};
/**
* @desc 纹理横轴覆盖模式
* @type {number}
*/
this.wrapS = options.wrapS !== undefined ? options.wrapS : THREE.ClampToEdgeWrapping;
/**
* @desc 纹理纵轴覆盖模式
* @type {number}
*/
this.wrapT = options.wrapT !== undefined ? options.wrapT : THREE.ClampToEdgeWrapping;
/**
* @desc 纹理扩大插值模式
* @type {number}
*/
this.magFilter = options.magFilter !== undefined ? options.magFilter : THREE.LinearFilter;
/**
* @desc 纹理缩小插值模式
* @type {number}
*/
this.minFilter = options.minFilter !== undefined ? options.minFilter : THREE.LinearMipMapLinearFilter;
/**
* @desc 各向异性参数
* @type {number}
*/
this.anisotropy = options.anisotropy !== undefined ? options.anisotropy : 1;
/**
* @desc 纹理起始偏移
* @type {number}
*/
this.offset = new THREE.Vector2( 0, 0 );
/**
* @desc 纹理重复参数
* @type {number}
*/
this.repeat = new THREE.Vector2( 1, 1 );
/**
* @desc 纹理颜色格式
* @type {number}
*/
this.format = options.format !== undefined ? options.format : THREE.RGBAFormat;
/**
* @desc 纹理数据字节大小
* @type {number}
*/
this.type = options.type !== undefined ? options.type : THREE.UnsignedByteType;
/**
* @desc 是否是深度缓冲
* @type {boolean}
*/
this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
/**
* @desc 是否是模板缓冲
* @type {number}
*/
this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
/**
* @desc 是否生成Mipmap
* @type {boolean}
*/
this.generateMipmaps = true;
/**
* @desc 共享深度连接
* @type {*}
*/
this.shareDepthFrom = null;
};
THREE.WebGLRenderTarget.prototype = {
constructor: THREE.WebGLRenderTarget,
/**
* @desc 设置渲染目标的尺寸
* @param {number} width 宽度
* @param {number} height 高度
*/
setSize: function ( width, height ) {
this.width = width;
this.height = height;
},
/**
* @desc 渲染目标的克隆
* @returns {THREE.WebGLRenderTarget}
*/
clone: function () {
var tmp = new THREE.WebGLRenderTarget( this.width, this.height );
tmp.wrapS = this.wrapS;
tmp.wrapT = this.wrapT;
tmp.magFilter = this.magFilter;
tmp.minFilter = this.minFilter;
tmp.anisotropy = this.anisotropy;
tmp.offset.copy( this.offset );
tmp.repeat.copy( this.repeat );
tmp.format = this.format;
tmp.type = this.type;
tmp.depthBuffer = this.depthBuffer;
tmp.stencilBuffer = this.stencilBuffer;
tmp.generateMipmaps = this.generateMipmaps;
tmp.shareDepthFrom = this.shareDepthFrom;
return tmp;
},
/**
* @desc WebGLRenderTarget的销毁事件
*/
dispose: function () {
this.dispatchEvent( { type: 'dispose' } );
}
};
THREE.EventDispatcher.prototype.apply( THREE.WebGLRenderTarget.prototype );