Skip to content

Commit

Permalink
BufferAttribute: Add generic vector "component" getter / setter (#24515)
Browse files Browse the repository at this point in the history
* Add "getComponent", "setComponent" functions

* Update docs

* update docs
  • Loading branch information
gkjohnson committed Jul 24, 2023
1 parent 6292f9b commit fcd3b77
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/api/ar/core/BufferAttribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ <h3>[method:this copyArray](array)</h3>
<h3>[method:this copyAt]([param:Integer index1]، [param:BufferAttribute bufferAttribute]، [param:Integer index2])</h3>
<p>انسخ متجهًا من bufferAttribute[index2] إلى [page:BufferAttribute.array array][index1].</p>

<h3>[method:Number getComponent]( [param:Integer index], [param:Integer component] ) </h3>
<p>Returns the given component of the vector at the given index.</p>

<h3>[method:Number getX]([param:Integer index])</h3>
<p>يعيد مكون x من المتجه في المؤشر المحدد.</p>

Expand Down Expand Up @@ -211,6 +214,9 @@ <h3>[method:this setUsage]([param:Usage value])</h3>
بدلاً من ذلك ، قم بإنشاء نسخة جديدة وتعيين الاستخدام المطلوب قبل التالي
جعل.
</p>

<h3>[method:Number setComponent]( [param:Integer index], [param:Integer component], [param:Float value] ) </h3>
<p>Sets the given component of the vector at the given index.</p>

<h3>[method:this setX]([param:Integer index], [param:Float x])</h3>
<p>تضبط مكون x من المتجه في المؤشر المحدد.</p>
Expand Down
8 changes: 7 additions & 1 deletion docs/api/en/core/BufferAttribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ <h3>[method:this copyArray]( array )</h3>
<h3>[method:this copyAt] ( [param:Integer index1], [param:BufferAttribute bufferAttribute], [param:Integer index2] )</h3>
<p>Copy a vector from bufferAttribute[index2] to [page:BufferAttribute.array array][index1].</p>

<h3>[method:Number getComponent]( [param:Integer index], [param:Integer component] ) </h3>
<p>Returns the given component of the vector at the given index.</p>

<h3>[method:Number getX]( [param:Integer index] )</h3>
<p>Returns the x component of the vector at the given index.</p>

Expand Down Expand Up @@ -218,7 +221,10 @@ <h3>[method:this setUsage] ( [param:Usage value] )</h3>
Instead, instantiate a new one and set the desired usage before the next
render.
</p>


<h3>[method:Number setComponent]( [param:Integer index], [param:Integer component], [param:Float value] ) </h3>
<p>Sets the given component of the vector at the given index.</p>

<h3>[method:this setX]( [param:Integer index], [param:Float x] )</h3>
<p>Sets the x component of the vector at the given index.</p>

Expand Down
6 changes: 6 additions & 0 deletions docs/api/fr/core/BufferAttribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ <h3>[method:this copyArray]( array ) </h3>
<h3>[method:this copyAt] ( [param:Integer index1], [param:BufferAttribute bufferAttribute], [param:Integer index2] ) </h3>
<p>Copie un vecteur de bufferAttribute[index2] à [page:BufferAttribute.array array][index1].</p>

<h3>[method:Number getComponent]( [param:Integer index], [param:Integer component] ) </h3>
<p>Returns the given component of the vector at the given index.</p>

<h3>[method:Number getX]( [param:Integer index] ) </h3>
<p>Renvoie le composant x d'un vecteur à l'index donné.</p>

Expand Down Expand Up @@ -185,6 +188,9 @@ <h3>[method:this setUsage] ( [param:Usage value] ) </h3>
Remarque : Après la première utilisation d'un tampon, son utilisation ne peut pas être modifiée. Au lieu de cela, instanciez-en un nouveau et définissez l'utilisation souhaitée avant le prochain rendu.
</p>

<h3>[method:Number setComponent]( [param:Integer index], [param:Integer component], [param:Float value] ) </h3>
<p>Sets the given component of the vector at the given index.</p>

<h3>[method:this setX]( [param:Integer index], [param:Float x] ) </h3>
<p>Définit la composante x du vecteur à l'indice donné.</p>

Expand Down
6 changes: 6 additions & 0 deletions docs/api/it/core/BufferAttribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ <h3>[method:this copyArray]( array ) </h3>
<h3>[method:this copyAt] ( [param:Integer index1], [param:BufferAttribute bufferAttribute], [param:Integer index2] ) </h3>
<p>Copia un vettore da bufferAttribute[index2] a [page:BufferAttribute.array array][index1].</p>

<h3>[method:Number getComponent]( [param:Integer index], [param:Integer component] ) </h3>
<p>Returns the given component of the vector at the given index.</p>

<h3>[method:Number getX]( [param:Integer index] ) </h3>
<p>Restituisce il componente x del vettore in corrispondenza dell'indice specificato.</p>

Expand Down Expand Up @@ -198,6 +201,9 @@ <h3>[method:this setUsage] ( [param:Usage value] ) </h3>
Nota: Dopo l'utilizzo iniziale di un buffer, il suo utilizzo non può cambiare. Invece, istanziane uno nuovo e
imposta l'utilizzo desiderato prima del rendering successivo.
</p>

<h3>[method:Number setComponent]( [param:Integer index], [param:Integer component], [param:Float value] ) </h3>
<p>Sets the given component of the vector at the given index.</p>

<h3>[method:this setX]( [param:Integer index], [param:Float x] ) </h3>
<p>Imposta il componente x del vettore in corrispondenza dell'indice specificato.</p>
Expand Down
6 changes: 6 additions & 0 deletions docs/api/ko/core/BufferAttribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ <h3>[method:this copyArray]( array ) </h3>
<h3>[method:this copyAt] ( [param:Integer index1], [param:BufferAttribute bufferAttribute], [param:Integer index2] ) </h3>
<p>bufferAttribute[index2]의 벡터를 [page:BufferAttribute.array array][index1]에 복사합니다.</p>

<h3>[method:Number getComponent]( [param:Integer index], [param:Integer component] ) </h3>
<p>Returns the given component of the vector at the given index.</p>

<h3>[method:Number getX]( [param:Integer index] ) </h3>
<p>해당 index의 벡터의 x 컴포넌트 값을 리턴합니다.</p>

Expand Down Expand Up @@ -179,6 +182,9 @@ <h3>[method:this set] ( [param:Array value], [param:Integer offset] ) </h3>
<h3>[method:this setUsage] ( [param:Usage value] ) </h3>
<p>[page:BufferAttribute.usage usage]를 value로 설정합니다.</p>

<h3>[method:Number setComponent]( [param:Integer index], [param:Integer component], [param:Float value] ) </h3>
<p>Sets the given component of the vector at the given index.</p>

<h3>[method:this setX]( [param:Integer index], [param:Float x] ) </h3>
<p> x 컴포넌트 값을 설정합니다.</p>

Expand Down
6 changes: 6 additions & 0 deletions docs/api/zh/core/BufferAttribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ <h3>[method:this copyArray]( array ) </h3>
<h3>[method:this copyAt] ( [param:Integer index1], [param:BufferAttribute bufferAttribute], [param:Integer index2] ) </h3>
<p>将一个矢量从 bufferAttribute[index2] 拷贝到 [page:BufferAttribute.array array][index1] 中。</p>

<h3>[method:Number getComponent]( [param:Integer index], [param:Integer component] ) </h3>
<p>Returns the given component of the vector at the given index.</p>

<h3>[method:Number getX]( [param:Integer index] ) </h3>
<p>获取给定索引的矢量的第一维元素 (即 X 值)。</p>

Expand Down Expand Up @@ -166,6 +169,9 @@ <h3>[method:this set] ( [param:Array value], [param:Integer offset] ) </h3>
<h3>[method:this setUsage] ( [param:Usage value] ) </h3>
<p>Set [page:BufferAttribute.usage usage] to value. See usage [page:BufferAttributeUsage constants] for all possible input values.</p>

<h3>[method:Number setComponent]( [param:Integer index], [param:Integer component], [param:Float value] ) </h3>
<p>Sets the given component of the vector at the given index.</p>

<h3>[method:this setX]( [param:Integer index], [param:Float x] ) </h3>
<p>设置给定索引的矢量的第一维数据(设置 X 值)。</p>

Expand Down
20 changes: 20 additions & 0 deletions src/core/BufferAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,26 @@ class BufferAttribute {

}

getComponent( index, component ) {

let value = this.array[ index * this.itemSize + component ];

if ( this.normalized ) value = denormalize( value, this.array );

return value;

}

setComponent( index, component, value ) {

if ( this.normalized ) value = normalize( value, this.array );

this.array[ index * this.itemSize + component ] = value;

return this;

}

getX( index ) {

let x = this.array[ index * this.itemSize ];
Expand Down

0 comments on commit fcd3b77

Please sign in to comment.