Skip to content

Commit 8275091

Browse files
authored
GLBufferAttribute: Add normalized property. (#31268)
* Update the screenshot of `webgl_buffergeometry_glbufferattribute` example * Add property `normalized` to `GLBufferAttribute` Update documentation and unit test. Update doc * Use `normalized` property in `webgl_buffergeometry_glbufferattribute` for the color buffer More efficient storage of colors in the GPU buffer and demonstration of the feature.
1 parent f1e0313 commit 8275091

File tree

10 files changed

+210
-90
lines changed

10 files changed

+210
-90
lines changed

docs/api/ar/core/GLBufferAttribute.html

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ <h1>[name]</h1>
1919
أكثر حالات الاستخدام شيوعًا لهذه الفئة هي عندما يتداخل نوع من
2020
حسابات GPGPU أو حتى ينتج VBOs المعنية.
2121
</p>
22-
22+
23+
<h2>Examples</h2>
24+
<p>
25+
[example:webgl_buffergeometry_glbufferattribute Points with custom buffers]<br />
26+
</p>
27+
2328
<h2>المنشئ (Constructor)</h2>
24-
<h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count] )</h3>
29+
<h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count], [param:Boolean normalized] )</h3>
2530
<p>
2631
`buffer` — يجب أن يكون
2732
[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer].
@@ -47,6 +52,16 @@ <h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer item
4752
<li>gl.UNSIGNED_BYTE: 1</li>
4853
</ul>
4954
<p>`count` — عدد الرؤوس المتوقع في VBO.</p>
55+
<p>
56+
`normalized` — (optional) Applies to integer data only.
57+
Indicates how the underlying data in the buffer maps to the values in the
58+
GLSL code. For instance, if [page:WebGLBuffer buffer] contains data of
59+
`gl.UNSIGNED_SHORT`, and [page:Boolean normalized] is true, the values `0 -
60+
+65535` in the buffer data will be mapped to 0.0f - +1.0f in the GLSL
61+
attribute. A `gl.SHORT` (signed) would map from -32768 - +32767 to -1.0f
62+
- +1.0f. If [page:Boolean normalized] is false, the values will be
63+
converted to floats unmodified, i.e. 32767 becomes 32767.0f.
64+
</p>
5065

5166
<h2>الخصائص (Properties)</h2>
5267

@@ -59,21 +74,33 @@ <h3>[property:WebGLBuffer buffer]</h3>
5974
<h3>[property:Integer count]</h3>
6075
<p>عدد الرؤوس المتوقع في VBO.</p>
6176

77+
<h3>[property:Integer elementSize]</h3>
78+
<p>
79+
يخزن الحجم المقابل بالبايت لقيمة خاصية `type` الحالية.
80+
</p>
81+
<p>انظر أعلاه (المُنشئ) لقائمة بأحجام الأنواع المعروفة.</p>
82+
6283
<h3>[property:Boolean isGLBufferAttribute]</h3>
6384
<p>للقراءة فقط. دائمًا `true`.</p>
6485

6586
<h3>[property:Integer itemSize]</h3>
6687
<p>كم عدد القيم التي تشكل كل عنصر (رأس).</p>
6788

68-
<h3>[property:Integer elementSize]</h3>
89+
<h3>[property:String name]</h3>
6990
<p>
70-
يخزن الحجم المقابل بالبايت لقيمة خاصية `type` الحالية.
91+
اسم اختياري لهذه الحالة من السمة. الافتراضي هو سلسلة فارغة.
7192
</p>
72-
<p>انظر أعلاه (المُنشئ) لقائمة بأحجام الأنواع المعروفة.</p>
7393

74-
<h3>[property:String name]</h3>
94+
<h3>[property:Boolean needsUpdate]</h3>
7595
<p>
76-
اسم اختياري لهذه الحالة من السمة. الافتراضي هو سلسلة فارغة.
96+
الافتراضي هو `false`. تعيين هذا إلى true يزاد
97+
[page:GLBufferAttribute.version version].
98+
</p>
99+
100+
<h3>[property:Boolean normalized]</h3>
101+
<p>
102+
Indicates how the underlying data in the buffer maps to the values in the
103+
GLSL shader code. See the constructor above for details.
77104
</p>
78105

79106
<h3>[property:GLenum type]</h3>
@@ -85,6 +112,11 @@ <h3>[property:GLenum type]</h3>
85112
باستخدام طريقة `setType`.
86113
</p>
87114

115+
<h3>[property:Integer version]</h3>
116+
<p>
117+
رقم إصدار، يزاد كل مرة يتم فيها تعيين خاصية needsUpdate على true.
118+
</p>
119+
88120
<h2>الوظائف (Methods)</h2>
89121

90122
<h3>[method:this setBuffer]( buffer )</h3>
@@ -98,17 +130,6 @@ <h3>[method:this setItemSize]( itemSize )</h3>
98130

99131
<h3>[method:this setCount]( count )</h3>
100132
<p>تضبط خاصية `count`.</p>
101-
102-
<h3>[property:Integer version]</h3>
103-
<p>
104-
رقم إصدار، يزاد كل مرة يتم فيها تعيين خاصية needsUpdate على true.
105-
</p>
106-
107-
<h3>[property:Boolean needsUpdate]</h3>
108-
<p>
109-
الافتراضي هو `false`. تعيين هذا إلى true يزاد
110-
[page:GLBufferAttribute.version version].
111-
</p>
112133

113134
<h2>المصدر (Source)</h2>
114135
<p>

docs/api/en/core/GLBufferAttribute.html

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ <h1>[name]</h1>
2020
calculation interferes or even produces the VBOs in question.
2121
</p>
2222

23+
<h2>Examples</h2>
24+
<p>
25+
[example:webgl_buffergeometry_glbufferattribute Points with custom buffers]<br />
26+
</p>
27+
2328
<h2>Constructor</h2>
24-
<h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count] )</h3>
29+
<h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count], [param:Boolean normalized] )</h3>
2530
<p>
2631
`buffer` — Must be a
2732
[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer].
@@ -48,6 +53,15 @@ <h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer item
4853
<li>gl.UNSIGNED_BYTE: 1</li>
4954
</ul>
5055
`count` — The expected number of vertices in VBO.
56+
<br />
57+
`normalized` — (optional) Applies to integer data only.
58+
Indicates how the underlying data in the buffer maps to the values in the
59+
GLSL code. For instance, if [page:WebGLBuffer buffer] contains data of
60+
`gl.UNSIGNED_SHORT`, and [page:Boolean normalized] is true, the values `0 -
61+
+65535` in the buffer data will be mapped to 0.0f - +1.0f in the GLSL
62+
attribute. A `gl.SHORT` (signed) would map from -32768 - +32767 to -1.0f
63+
- +1.0f. If [page:Boolean normalized] is false, the values will be
64+
converted to floats unmodified, i.e. 32767 becomes 32767.0f.
5165

5266
<h2>Properties</h2>
5367

@@ -60,24 +74,36 @@ <h3>[property:WebGLBuffer buffer]</h3>
6074
<h3>[property:Integer count]</h3>
6175
<p>The expected number of vertices in VBO.</p>
6276

63-
<h3>[property:Boolean isGLBufferAttribute]</h3>
64-
<p>Read-only. Always `true`.</p>
65-
66-
<h3>[property:Integer itemSize]</h3>
67-
<p>How many values make up each item (vertex).</p>
68-
6977
<h3>[property:Integer elementSize]</h3>
7078
<p>
7179
Stores the corresponding size in bytes for the current `type` property
7280
value.
7381
</p>
7482
<p>See above (constructor) for a list of known type sizes.</p>
7583

84+
<h3>[property:Boolean isGLBufferAttribute]</h3>
85+
<p>Read-only. Always `true`.</p>
86+
87+
<h3>[property:Integer itemSize]</h3>
88+
<p>How many values make up each item (vertex).</p>
89+
7690
<h3>[property:String name]</h3>
7791
<p>
7892
Optional name for this attribute instance. Default is an empty string.
7993
</p>
8094

95+
<h3>[property:Boolean needsUpdate]</h3>
96+
<p>
97+
Default is `false`. Setting this to true increments
98+
[page:GLBufferAttribute.version version].
99+
</p>
100+
101+
<h3>[property:Boolean normalized]</h3>
102+
<p>
103+
Indicates how the underlying data in the buffer maps to the values in the
104+
GLSL shader code. See the constructor above for details.
105+
</p>
106+
81107
<h3>[property:GLenum type]</h3>
82108
<p>
83109
A
@@ -88,6 +114,12 @@ <h3>[property:GLenum type]</h3>
88114
using the `setType` method.
89115
</p>
90116

117+
<h3>[property:Integer version]</h3>
118+
<p>
119+
A version number, incremented every time the needsUpdate property is set
120+
to true.
121+
</p>
122+
91123
<h2>Methods</h2>
92124

93125
<h3>[method:this setBuffer]( buffer )</h3>
@@ -102,18 +134,6 @@ <h3>[method:this setItemSize]( itemSize )</h3>
102134
<h3>[method:this setCount]( count )</h3>
103135
<p>Sets the `count` property.</p>
104136

105-
<h3>[property:Integer version]</h3>
106-
<p>
107-
A version number, incremented every time the needsUpdate property is set
108-
to true.
109-
</p>
110-
111-
<h3>[property:Boolean needsUpdate]</h3>
112-
<p>
113-
Default is `false`. Setting this to true increments
114-
[page:GLBufferAttribute.version version].
115-
</p>
116-
117137
<h2>Source</h2>
118138
<p>
119139
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

docs/api/it/core/GLBufferAttribute.html

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ <h1>[name]</h1>
2020
calcolo GPGPU interferisce o addirittura produce i VBO in questione.
2121
</p>
2222

23+
<h2>Examples</h2>
24+
<p>
25+
[example:webgl_buffergeometry_glbufferattribute Points with custom buffers]<br />
26+
</p>
27+
2328
<h2>Costruttore</h2>
24-
<h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count] )</h3>
29+
<h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count], [param:Boolean normalized] )</h3>
2530
<p>
2631
`buffer` — Deve essere un [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer].
2732
<br />
@@ -41,6 +46,15 @@ <h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer item
4146
<li>gl.UNSIGNED_BYTE: 1</li>
4247
</ul>
4348
`count` — Il numero previsto di vertici in VBO.
49+
<br />
50+
`normalized` — (optional) Applies to integer data only.
51+
Indicates how the underlying data in the buffer maps to the values in the
52+
GLSL code. For instance, if [page:WebGLBuffer buffer] contains data of
53+
`gl.UNSIGNED_SHORT`, and [page:Boolean normalized] is true, the values `0 -
54+
+65535` in the buffer data will be mapped to 0.0f - +1.0f in the GLSL
55+
attribute. A `gl.SHORT` (signed) would map from -32768 - +32767 to -1.0f
56+
- +1.0f. If [page:Boolean normalized] is false, the values will be
57+
converted to floats unmodified, i.e. 32767 becomes 32767.0f.
4458
</p>
4559

4660
<h2>Proprietà</h2>
@@ -55,6 +69,14 @@ <h3>[property:Integer count]</h3>
5569
Il numero previsto di vertici in VBO.
5670
</p>
5771

72+
<h3>[property:Integer elementSize]</h3>
73+
<p>
74+
Memorizza la dimensione corrispondente in byte per il valore della proprietà del `type` corrente.
75+
</p>
76+
<p>
77+
Vedi sopra (costruttore) per un elenco di dimensioni di type conosciute.
78+
</p>
79+
5880
<h3>[property:Boolean isGLBufferAttribute]</h3>
5981
<p>
6082
Solo lettura. Sempre `true`.
@@ -65,17 +87,20 @@ <h3>[property:Integer itemSize]</h3>
6587
Quanti valori compongono ogni elemento (vertice).
6688
</p>
6789

68-
<h3>[property:Integer elementSize]</h3>
90+
<h3>[property:String name]</h3>
6991
<p>
70-
Memorizza la dimensione corrispondente in byte per il valore della proprietà del `type` corrente.
92+
Un nome opzionale per questa istanza dell'attributo. Il valore predefinito è una stringa vuota.
7193
</p>
94+
95+
<h3>[property:Boolean needsUpdate]</h3>
7296
<p>
73-
Vedi sopra (costruttore) per un elenco di dimensioni di type conosciute.
97+
Il valore predefinito è `false`. Impostando questo metodo a true incrementa la [page:GLBufferAttribute.version versione].
7498
</p>
7599

76-
<h3>[property:String name]</h3>
100+
<h3>[property:Boolean normalized]</h3>
77101
<p>
78-
Un nome opzionale per questa istanza dell'attributo. Il valore predefinito è una stringa vuota.
102+
Indicates how the underlying data in the buffer maps to the values in the
103+
GLSL shader code. See the constructor above for details.
79104
</p>
80105

81106
<h3>[property:GLenum type]</h3>
@@ -88,6 +113,11 @@ <h3>[property:GLenum type]</h3>
88113
di usare il metodo `setType`.
89114
</p>
90115

116+
<h3>[property:Integer version]</h3>
117+
<p>
118+
Un numero di versione, incrementato ogni volta che la proprietà needsUpdate è impostata a true.
119+
</p>
120+
91121
<h2>Metodi</h2>
92122

93123
<h3>[method:this setBuffer]( buffer ) </h3>
@@ -102,16 +132,6 @@ <h3>[method:this setItemSize]( itemSize ) </h3>
102132
<h3>[method:this setCount]( count ) </h3>
103133
<p>Imposta la proprietà `count`.</p>
104134

105-
<h3>[property:Integer version]</h3>
106-
<p>
107-
Un numero di versione, incrementato ogni volta che la proprietà needsUpdate è impostata a true.
108-
</p>
109-
110-
<h3>[property:Boolean needsUpdate]</h3>
111-
<p>
112-
Il valore predefinito è `false`. Impostando questo metodo a true incrementa la [page:GLBufferAttribute.version versione].
113-
</p>
114-
115135
<h2>Source</h2>
116136
<p>
117137
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

0 commit comments

Comments
 (0)