|
90 | 90 | } |
91 | 91 |
|
92 | 92 | 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 ); |
95 | 95 |
|
96 | 96 | var color = new THREE.Color(); |
97 | 97 |
|
|
153 | 153 | var ny = cb.y; |
154 | 154 | var nz = cb.z; |
155 | 155 |
|
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; |
159 | 159 |
|
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; |
163 | 163 |
|
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; |
167 | 167 |
|
168 | 168 | // colors |
169 | 169 |
|
|
173 | 173 |
|
174 | 174 | color.setRGB( vx, vy, vz ); |
175 | 175 |
|
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; |
179 | 179 |
|
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; |
183 | 183 |
|
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; |
187 | 187 |
|
188 | 188 | } |
189 | 189 |
|
190 | 190 | geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) ); |
191 | 191 | 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 ) ); |
194 | 194 |
|
195 | 195 | geometry.computeBoundingSphere(); |
196 | 196 |
|
|
0 commit comments