فهرست منبع

BufferAttribute: Add generic vector "component" getter / setter (#24515)

* Add "getComponent", "setComponent" functions

* Update docs

* update docs
Garrett Johnson 2 سال پیش
والد
کامیت
fcd3b771cf

+ 6 - 0
docs/api/ar/core/BufferAttribute.html

@@ -166,6 +166,9 @@
 		<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>
 
@@ -211,6 +214,9 @@
 			بدلاً من ذلك ، قم بإنشاء نسخة جديدة وتعيين الاستخدام المطلوب قبل التالي
 			جعل.
 		</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>

+ 7 - 1
docs/api/en/core/BufferAttribute.html

@@ -173,6 +173,9 @@
 		<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>
 
@@ -218,7 +221,10 @@
 			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>
 

+ 6 - 0
docs/api/fr/core/BufferAttribute.html

@@ -146,6 +146,9 @@
 		<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>
 
@@ -185,6 +188,9 @@
 			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>
 

+ 6 - 0
docs/api/it/core/BufferAttribute.html

@@ -160,6 +160,9 @@
 		<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>
 
@@ -198,6 +201,9 @@
       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>

+ 6 - 0
docs/api/ko/core/BufferAttribute.html

@@ -146,6 +146,9 @@
 		<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>
 
@@ -179,6 +182,9 @@
 		<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>
 

+ 6 - 0
docs/api/zh/core/BufferAttribute.html

@@ -135,6 +135,9 @@
 		<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>
 
@@ -166,6 +169,9 @@
 		<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>
 

+ 20 - 0
src/core/BufferAttribute.js

@@ -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 ];