Skip to content

Commit bbf484d

Browse files
committed
BufferAttribute setFromVector, setFromColor convenience methods
1 parent c73eff8 commit bbf484d

24 files changed

+285
-89
lines changed

examples/jsm/csm/CSMHelper.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ class CSMHelper extends Group {
191191

192192
const nearVerts = mainFrustum.vertices.near;
193193
const farVerts = mainFrustum.vertices.far;
194-
frustumLinePositions.setXYZ( 0, farVerts[ 0 ].x, farVerts[ 0 ].y, farVerts[ 0 ].z );
195-
frustumLinePositions.setXYZ( 1, farVerts[ 3 ].x, farVerts[ 3 ].y, farVerts[ 3 ].z );
196-
frustumLinePositions.setXYZ( 2, farVerts[ 2 ].x, farVerts[ 2 ].y, farVerts[ 2 ].z );
197-
frustumLinePositions.setXYZ( 3, farVerts[ 1 ].x, farVerts[ 1 ].y, farVerts[ 1 ].z );
198-
199-
frustumLinePositions.setXYZ( 4, nearVerts[ 0 ].x, nearVerts[ 0 ].y, nearVerts[ 0 ].z );
200-
frustumLinePositions.setXYZ( 5, nearVerts[ 3 ].x, nearVerts[ 3 ].y, nearVerts[ 3 ].z );
201-
frustumLinePositions.setXYZ( 6, nearVerts[ 2 ].x, nearVerts[ 2 ].y, nearVerts[ 2 ].z );
202-
frustumLinePositions.setXYZ( 7, nearVerts[ 1 ].x, nearVerts[ 1 ].y, nearVerts[ 1 ].z );
194+
frustumLinePositions.setFromVector3( 0, farVerts[ 0 ] );
195+
frustumLinePositions.setFromVector3( 1, farVerts[ 3 ] );
196+
frustumLinePositions.setFromVector3( 2, farVerts[ 2 ] );
197+
frustumLinePositions.setFromVector3( 3, farVerts[ 1 ] );
198+
199+
frustumLinePositions.setFromVector3( 4, nearVerts[ 0 ] );
200+
frustumLinePositions.setFromVector3( 5, nearVerts[ 3 ] );
201+
frustumLinePositions.setFromVector3( 6, nearVerts[ 2 ] );
202+
frustumLinePositions.setFromVector3( 7, nearVerts[ 1 ] );
203203
frustumLinePositions.needsUpdate = true;
204204

205205
}

examples/jsm/exporters/GLTFExporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ class GLTFWriter {
884884

885885
}
886886

887-
attribute.setXYZ( i, v.x, v.y, v.z );
887+
attribute.setFromVector3( i, v );
888888

889889
}
890890

examples/jsm/helpers/TextureHelper.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,7 @@ function createCubeGeometry( width, height, depth ) {
203203

204204
_direction.fromBufferAttribute( position, j ).normalize();
205205

206-
const u = _direction.x;
207-
const v = _direction.y;
208-
const w = _direction.z;
209-
210-
uvw.setXYZ( j, u, v, w );
206+
uvw.setFromVector3( j, _direction );
211207

212208
}
213209

examples/jsm/helpers/TextureHelperGPU.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,7 @@ function createCubeGeometry( width, height, depth ) {
152152

153153
_direction.fromBufferAttribute( position, j ).normalize();
154154

155-
const u = _direction.x;
156-
const v = _direction.y;
157-
const w = _direction.z;
158-
159-
uvw.setXYZ( j, u, v, w );
155+
uvw.setFromVector3( j, _direction );
160156

161157
}
162158

examples/jsm/helpers/VertexNormalsHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ class VertexNormalsHelper extends LineSegments {
123123

124124
_v2.applyMatrix3( _normalMatrix ).normalize().multiplyScalar( this.size ).add( _v1 );
125125

126-
position.setXYZ( idx, _v1.x, _v1.y, _v1.z );
126+
position.setFromVector3( idx, _v1 );
127127

128128
idx = idx + 1;
129129

130-
position.setXYZ( idx, _v2.x, _v2.y, _v2.z );
130+
position.setFromVector3( idx, _v2 );
131131

132132
idx = idx + 1;
133133

examples/jsm/helpers/VertexTangentsHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ class VertexTangentsHelper extends LineSegments {
103103

104104
_v2.transformDirection( matrixWorld ).multiplyScalar( this.size ).add( _v1 );
105105

106-
position.setXYZ( idx, _v1.x, _v1.y, _v1.z );
106+
position.setFromVector3( idx, _v1 );
107107

108108
idx = idx + 1;
109109

110-
position.setXYZ( idx, _v2.x, _v2.y, _v2.z );
110+
position.setFromVector3( idx, _v2 );
111111

112112
idx = idx + 1;
113113

examples/jsm/loaders/DRACOLoader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class DRACOLoader extends Loader {
322322

323323
_color.fromBufferAttribute( attribute, i );
324324
ColorManagement.colorSpaceToWorking( _color, SRGBColorSpace );
325-
attribute.setXYZ( i, _color.r, _color.g, _color.b );
325+
attribute.setFromColor( i, _color );
326326

327327
}
328328

examples/jsm/loaders/VRMLLoader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,7 +3220,7 @@ class VRMLLoader extends Loader {
32203220

32213221
ColorManagement.colorSpaceToWorking( color, SRGBColorSpace );
32223222

3223-
attribute.setXYZ( i, color.r, color.g, color.b );
3223+
attribute.setFromColor( i, color );
32243224

32253225
}
32263226

@@ -3327,7 +3327,7 @@ class VRMLLoader extends Loader {
33273327

33283328
ColorManagement.colorSpaceToWorking( color, SRGBColorSpace );
33293329

3330-
colorAttribute.setXYZ( index, color.r, color.g, color.b );
3330+
colorAttribute.setFromColor( index, color );
33313331

33323332
}
33333333

examples/jsm/utils/BufferGeometryUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */
14061406
}
14071407

14081408
tempNorm2.normalize();
1409-
normAttr.setXYZ( i3 + n, tempNorm2.x, tempNorm2.y, tempNorm2.z );
1409+
normAttr.setFromVector3( i3 + n, tempNorm2 );
14101410

14111411
}
14121412

examples/misc_controls_pointerlock.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
vertex.y += Math.random() * 2;
201201
vertex.z += Math.random() * 20 - 10;
202202

203-
position.setXYZ( i, vertex.x, vertex.y, vertex.z );
203+
position.setFromVector3( i, vertex );
204204

205205
}
206206

0 commit comments

Comments
 (0)