Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/jsm/csm/CSMHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ class CSMHelper extends Group {

const nearVerts = mainFrustum.vertices.near;
const farVerts = mainFrustum.vertices.far;
frustumLinePositions.setXYZ( 0, farVerts[ 0 ].x, farVerts[ 0 ].y, farVerts[ 0 ].z );
frustumLinePositions.setXYZ( 1, farVerts[ 3 ].x, farVerts[ 3 ].y, farVerts[ 3 ].z );
frustumLinePositions.setXYZ( 2, farVerts[ 2 ].x, farVerts[ 2 ].y, farVerts[ 2 ].z );
frustumLinePositions.setXYZ( 3, farVerts[ 1 ].x, farVerts[ 1 ].y, farVerts[ 1 ].z );

frustumLinePositions.setXYZ( 4, nearVerts[ 0 ].x, nearVerts[ 0 ].y, nearVerts[ 0 ].z );
frustumLinePositions.setXYZ( 5, nearVerts[ 3 ].x, nearVerts[ 3 ].y, nearVerts[ 3 ].z );
frustumLinePositions.setXYZ( 6, nearVerts[ 2 ].x, nearVerts[ 2 ].y, nearVerts[ 2 ].z );
frustumLinePositions.setXYZ( 7, nearVerts[ 1 ].x, nearVerts[ 1 ].y, nearVerts[ 1 ].z );
frustumLinePositions.setVector3( 0, farVerts[ 0 ] );
frustumLinePositions.setVector3( 1, farVerts[ 3 ] );
frustumLinePositions.setVector3( 2, farVerts[ 2 ] );
frustumLinePositions.setVector3( 3, farVerts[ 1 ] );

frustumLinePositions.setVector3( 4, nearVerts[ 0 ] );
frustumLinePositions.setVector3( 5, nearVerts[ 3 ] );
frustumLinePositions.setVector3( 6, nearVerts[ 2 ] );
frustumLinePositions.setVector3( 7, nearVerts[ 1 ] );
frustumLinePositions.needsUpdate = true;

}
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ class GLTFWriter {

}

attribute.setXYZ( i, v.x, v.y, v.z );
attribute.setVector3( i, v );

}

Expand Down
6 changes: 1 addition & 5 deletions examples/jsm/helpers/TextureHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,7 @@ function createCubeGeometry( width, height, depth ) {

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

const u = _direction.x;
const v = _direction.y;
const w = _direction.z;

uvw.setXYZ( j, u, v, w );
uvw.setVector3( j, _direction );

}

Expand Down
6 changes: 1 addition & 5 deletions examples/jsm/helpers/TextureHelperGPU.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ function createCubeGeometry( width, height, depth ) {

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

const u = _direction.x;
const v = _direction.y;
const w = _direction.z;

uvw.setXYZ( j, u, v, w );
uvw.setVector3( j, _direction );

}

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/helpers/VertexNormalsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ class VertexNormalsHelper extends LineSegments {

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

position.setXYZ( idx, _v1.x, _v1.y, _v1.z );
position.setVector3( idx, _v1 );

idx = idx + 1;

position.setXYZ( idx, _v2.x, _v2.y, _v2.z );
position.setVector3( idx, _v2 );

idx = idx + 1;

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/helpers/VertexTangentsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ class VertexTangentsHelper extends LineSegments {

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

position.setXYZ( idx, _v1.x, _v1.y, _v1.z );
position.setVector3( idx, _v1 );

idx = idx + 1;

position.setXYZ( idx, _v2.x, _v2.y, _v2.z );
position.setVector3( idx, _v2 );

idx = idx + 1;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/loaders/DRACOLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class DRACOLoader extends Loader {

_color.fromBufferAttribute( attribute, i );
ColorManagement.colorSpaceToWorking( _color, SRGBColorSpace );
attribute.setXYZ( i, _color.r, _color.g, _color.b );
attribute.setColor( i, _color );

}

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/loaders/VRMLLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3220,7 +3220,7 @@ class VRMLLoader extends Loader {

ColorManagement.colorSpaceToWorking( color, SRGBColorSpace );

attribute.setXYZ( i, color.r, color.g, color.b );
attribute.setColor( i, color );

}

Expand Down Expand Up @@ -3327,7 +3327,7 @@ class VRMLLoader extends Loader {

ColorManagement.colorSpaceToWorking( color, SRGBColorSpace );

colorAttribute.setXYZ( index, color.r, color.g, color.b );
colorAttribute.setColor( index, color );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/utils/BufferGeometryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */
}

tempNorm2.normalize();
normAttr.setXYZ( i3 + n, tempNorm2.x, tempNorm2.y, tempNorm2.z );
normAttr.setVector3( i3 + n, tempNorm2 );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/misc_controls_pointerlock.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
vertex.y += Math.random() * 2;
vertex.z += Math.random() * 20 - 10;

position.setXYZ( i, vertex.x, vertex.y, vertex.z );
position.setVector3( i, vertex );

}

Expand Down
4 changes: 2 additions & 2 deletions examples/webgl_decals.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@
mouseHelper.lookAt( n );

const positions = line.geometry.attributes.position;
positions.setXYZ( 0, p.x, p.y, p.z );
positions.setXYZ( 1, n.x, n.y, n.z );
positions.setVector3( 0, p );
positions.setVector3( 1, n );
positions.needsUpdate = true;

intersection.intersects = true;
Expand Down
6 changes: 3 additions & 3 deletions examples/webgl_geometry_colors.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@
for ( let i = 0; i < count; i ++ ) {

color.setHSL( ( positions1.getY( i ) / radius + 1 ) / 2, 1.0, 0.5, THREE.SRGBColorSpace );
colors1.setXYZ( i, color.r, color.g, color.b );
colors1.setColor( i, color );

color.setHSL( 0, ( positions2.getY( i ) / radius + 1 ) / 2, 0.5, THREE.SRGBColorSpace );
colors2.setXYZ( i, color.r, color.g, color.b );
colors2.setColor( i, color );

color.setRGB( 1, 0.8 - ( positions3.getY( i ) / radius + 1 ) / 2, 0, THREE.SRGBColorSpace );
colors3.setXYZ( i, color.r, color.g, color.b );
colors3.setColor( i, color );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_geometry_colors_lookuptable.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@

color.copy( lut.getColor( colorValue ) ).convertSRGBToLinear();

colors.setXYZ( i, color.r, color.g, color.b );
colors.setColor( i, color );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_geometry_spline_editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@

const t = i / ( ARC_SEGMENTS - 1 );
spline.getPoint( t, point );
position.setXYZ( i, point.x, point.y, point.z );
position.setVector3( i, point );

}

Expand Down
6 changes: 3 additions & 3 deletions examples/webgl_multiple_views.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@
for ( let i = 0; i < count; i ++ ) {

color.setHSL( ( positions1.getY( i ) / radius + 1 ) / 2, 1.0, 0.5, THREE.SRGBColorSpace );
colors1.setXYZ( i, color.r, color.g, color.b );
colors1.setColor( i, color );

color.setHSL( 0, ( positions2.getY( i ) / radius + 1 ) / 2, 0.5, THREE.SRGBColorSpace );
colors2.setXYZ( i, color.r, color.g, color.b );
colors2.setColor( i, color );

color.setRGB( 1, 0.8 - ( positions3.getY( i ) / radius + 1 ) / 2, 0, THREE.SRGBColorSpace );
colors3.setXYZ( i, color.r, color.g, color.b );
colors3.setColor( i, color );

}

Expand Down
6 changes: 3 additions & 3 deletions examples/webgl_raycaster_bvh.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@
_matrix.compose( point, _quaternion, _scale );
sphereInstance.setMatrixAt( i * 2 + 1, _matrix );

lineSegments.geometry.attributes.position.setXYZ( lineNum ++, _position.x, _position.y, _position.z );
lineSegments.geometry.attributes.position.setXYZ( lineNum ++, point.x, point.y, point.z );
lineSegments.geometry.attributes.position.setVector3( lineNum ++, _position );
lineSegments.geometry.attributes.position.setVector3( lineNum ++, point );

} else {

sphereInstance.setMatrixAt( i * 2 + 1, _matrix );
lineSegments.geometry.attributes.position.setXYZ( lineNum ++, _position.x, _position.y, _position.z );
lineSegments.geometry.attributes.position.setVector3( lineNum ++, _position );
lineSegments.geometry.attributes.position.setXYZ( lineNum ++, 0, 0, 0 );

}
Expand Down
62 changes: 57 additions & 5 deletions src/core/BufferAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class BufferAttribute extends EventDispatcher {
_vector2.fromBufferAttribute( this, i );
_vector2.applyMatrix3( m );

this.setXY( i, _vector2.x, _vector2.y );
this.setVector2( i, _vector2 );

}

Expand All @@ -280,7 +280,7 @@ class BufferAttribute extends EventDispatcher {
_vector.fromBufferAttribute( this, i );
_vector.applyMatrix3( m );

this.setXYZ( i, _vector.x, _vector.y, _vector.z );
this.setVector3( i, _vector );

}

Expand All @@ -305,7 +305,7 @@ class BufferAttribute extends EventDispatcher {

_vector.applyMatrix4( m );

this.setXYZ( i, _vector.x, _vector.y, _vector.z );
this.setVector3( i, _vector );

}

Expand All @@ -328,7 +328,7 @@ class BufferAttribute extends EventDispatcher {

_vector.applyNormalMatrix( m );

this.setXYZ( i, _vector.x, _vector.y, _vector.z );
this.setVector3( i, _vector );

}

Expand All @@ -351,7 +351,7 @@ class BufferAttribute extends EventDispatcher {

_vector.transformDirection( m );

this.setXYZ( i, _vector.x, _vector.y, _vector.z );
this.setVector3( i, _vector );

}

Expand Down Expand Up @@ -629,6 +629,58 @@ class BufferAttribute extends EventDispatcher {

}

/**
* Sets the x and y component of the vector at the given index based on the values of the given vector.
*
* @param {number} index - The index into the buffer attribute.
* @param {Vector2} vector - The vector to set.
* @return {BufferAttribute} A reference to this instance.
*/
setVector2( index, vector ) {

return this.setXY( index, vector.x, vector.y );

}

/**
* Sets the x, y and z component of the vector at the given index based on the values of the given vector.
*
* @param {number} index - The index into the buffer attribute.
* @param {Vector3} vector - The vector to set.
* @return {BufferAttribute} A reference to this instance.
*/
setVector3( index, vector ) {

return this.setXYZ( index, vector.x, vector.y, vector.z );

}

/**
* Sets the x, y, z and w component of the vector at the given index based on the values of the given vector.
*
* @param {number} index - The index into the buffer attribute.
* @param {Vector4} vector - The vector to set.
* @return {BufferAttribute} A reference to this instance.
*/
setVector4( index, vector ) {

return this.setXYZW( index, vector.x, vector.y, vector.z, vector.w );

}

/**
* Sets the x, y and z component of the vector at the given index based on the r, g and b values of the given color.
*
* @param {number} index - The index into the buffer attribute.
* @param {Color} color - The color to set.
* @return {BufferAttribute} A reference to this instance.
*/
setColor( index, color ) {

return this.setXYZ( index, color.r, color.g, color.b );

}

/**
* Sets the given callback function that is executed after the Renderer has transferred
* the attribute array data to the GPU. Can be used to perform clean-up operations after
Expand Down
14 changes: 7 additions & 7 deletions src/core/BufferGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,9 @@ class BufferGeometry extends EventDispatcher {
nB.add( cb );
nC.add( cb );

normalAttribute.setXYZ( vA, nA.x, nA.y, nA.z );
normalAttribute.setXYZ( vB, nB.x, nB.y, nB.z );
normalAttribute.setXYZ( vC, nC.x, nC.y, nC.z );
normalAttribute.setVector3( vA, nA );
normalAttribute.setVector3( vB, nB );
normalAttribute.setVector3( vC, nC );

}

Expand All @@ -1060,9 +1060,9 @@ class BufferGeometry extends EventDispatcher {
ab.subVectors( pA, pB );
cb.cross( ab );

normalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z );
normalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z );
normalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z );
normalAttribute.setVector3( i + 0, cb );
normalAttribute.setVector3( i + 1, cb );
normalAttribute.setVector3( i + 2, cb );

}

Expand Down Expand Up @@ -1090,7 +1090,7 @@ class BufferGeometry extends EventDispatcher {

_vector.normalize();

normals.setXYZ( i, _vector.x, _vector.y, _vector.z );
normals.setVector3( i, _vector );

}

Expand Down
Loading
Loading