Skip to content

Commit a9ee6bc

Browse files
committed
Merged webgl_buffergeometry_bufferDataTypes into _uint example.
1 parent 1e7a586 commit a9ee6bc

File tree

2 files changed

+22
-286
lines changed

2 files changed

+22
-286
lines changed

examples/webgl_buffergeometry_bufferDataTypes.html

Lines changed: 0 additions & 264 deletions
This file was deleted.

examples/webgl_buffergeometry_uint.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@
9090
}
9191

9292
var positions = new Float32Array( triangles * 3 * 3 );
93-
var normals = new Float32Array( triangles * 3 * 3 );
94-
var colors = new Float32Array( triangles * 3 * 3 );
93+
var normals = new Int16Array( triangles * 3 * 3 );
94+
var colors = new Uint8Array( triangles * 3 * 3 );
9595

9696
var color = new THREE.Color();
9797

@@ -153,17 +153,17 @@
153153
var ny = cb.y;
154154
var nz = cb.z;
155155

156-
normals[ i ] = nx;
157-
normals[ i + 1 ] = ny;
158-
normals[ i + 2 ] = nz;
156+
normals[ i ] = nx * 32767;
157+
normals[ i + 1 ] = ny * 32767;
158+
normals[ i + 2 ] = nz * 32767;
159159

160-
normals[ i + 3 ] = nx;
161-
normals[ i + 4 ] = ny;
162-
normals[ i + 5 ] = nz;
160+
normals[ i + 3 ] = nx * 32767;
161+
normals[ i + 4 ] = ny * 32767;
162+
normals[ i + 5 ] = nz * 32767;
163163

164-
normals[ i + 6 ] = nx;
165-
normals[ i + 7 ] = ny;
166-
normals[ i + 8 ] = nz;
164+
normals[ i + 6 ] = nx * 32767;
165+
normals[ i + 7 ] = ny * 32767;
166+
normals[ i + 8 ] = nz * 32767;
167167

168168
// colors
169169

@@ -173,24 +173,24 @@
173173

174174
color.setRGB( vx, vy, vz );
175175

176-
colors[ i ] = color.r;
177-
colors[ i + 1 ] = color.g;
178-
colors[ i + 2 ] = color.b;
176+
colors[ i ] = color.r * 255;
177+
colors[ i + 1 ] = color.g * 255;
178+
colors[ i + 2 ] = color.b * 255;
179179

180-
colors[ i + 3 ] = color.r;
181-
colors[ i + 4 ] = color.g;
182-
colors[ i + 5 ] = color.b;
180+
colors[ i + 3 ] = color.r * 255;
181+
colors[ i + 4 ] = color.g * 255;
182+
colors[ i + 5 ] = color.b * 255;
183183

184-
colors[ i + 6 ] = color.r;
185-
colors[ i + 7 ] = color.g;
186-
colors[ i + 8 ] = color.b;
184+
colors[ i + 6 ] = color.r * 255;
185+
colors[ i + 7 ] = color.g * 255;
186+
colors[ i + 8 ] = color.b * 255;
187187

188188
}
189189

190190
geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
191191
geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
192-
geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
193-
geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) );
192+
geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3, true ) );
193+
geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3, true ) );
194194

195195
geometry.computeBoundingSphere();
196196

0 commit comments

Comments
 (0)