BufferAttribute.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!DOCTYPE html>
  2. <html lang="ko">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <p class="desc">
  12. 이 클래스에는 [page:BufferGeometry]와 연관된 속성 데이터(꼭짓점 위치, 면 순서, 법선, 색깔,
  13. UV, 모든 커스텀 속성들 등)를 저장하고 있으며, GPU에 보다 효율적으로 데이터를 전송할 수 있게 합니다.
  14. 세부사항 및 활용 예제를 확인해보세요.<br /><br />
  15. 데이터는 모든 길이가 벡터로 저장되며 ([page:BufferAttribute.itemSize itemSize]로 정의된 값),
  16. 일반적으로 인덱스 값으로 전달될 경우 메서드 내에서 밑줄이 쳐지며 자동으로 벡터 길이에 곱해집니다.
  17. </p>
  18. <h2>생성자</h2>
  19. <h3>[name]( [param:TypedArray array], [param:Integer itemSize], [param:Boolean normalized] )</h3>
  20. <p>
  21. [page:TypedArray array] -- 반드시 [link:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/TypedArray TypedArray]여야 합니다.
  22. 버퍼를 시작하는데에 사용됩니다. <br />
  23. 배열에는
  24. <code>itemSize * numVertices</code>
  25. 엘레먼트가 있어야 하며, numVertices는 [page:BufferGeometry BufferGeometry]와 연관된 꼭짓점의 갯수입니다.<br /><br />
  26. [page:Integer itemSize] -- 특정 꼭짓점과 연관된 배열의 값의 수입니다.
  27. 예를 들어 이 속성에서 3개의 벡터(위치, 법선, 색 처럼)를 저장하고 있다면, itemSize는 3이 됩니다.
  28. <br /><br />
  29. [page:Boolean normalized] -- (생략가능) 정수 데이터에만 적용됩니다. 버퍼에 있는 기저 데이터가 GLSL 코드에서 값으로 맵핑되는 방식입니다.
  30. 예를 들어 [page:TypedArray array]가 UInt16Array의 인스턴스이고, [page:Boolean normalized]가 true면 배열에 있는 0 - +65535 값들은
  31. GLSL 속성에서 0.0f - +1.0f로 매핑될 것입니다. Int16Array (기호 있는)는 -32767 - +32767 가 -1.0f - +1.0f 로 매핑될 것입니다.
  32. [page:Boolean normalized]가 false라면, 값은 수정 없이 floats로 변환될 것입니다. 예) 32767은 32767.0f로 변환.
  33. </p>
  34. <h2>프로퍼티</h2>
  35. <h3>[property:TypedArray array]</h3>
  36. <p>
  37. 버퍼에 저장되어 있는 데이터를 담고 있는 [page:TypedArray array].
  38. </p>
  39. <h3>[property:Integer count]</h3>
  40. <p>
  41. [page:BufferAttribute.itemSize itemSize]로 나눈 [page:BufferAttribute.array array]의 길이를 저장.<br /><br />
  42. 버퍼가 3개의 컴포넌트를 저장한 벡터(위치, 법선, 색 등)
  43. 저장된 벡터들의 수를 계산합니다.
  44. </p>
  45. <h3>[property:Integer itemSize]</h3>
  46. <p>[page:BufferAttribute.array array]에 저장되는 벡터의 길이.</p>
  47. <h3>[property:String name]</h3>
  48. <p>
  49. 이 속성 인스턴스의 임시 이름. 기본값은 빈 문자열입니다.
  50. </p>
  51. <h3>[property:Boolean needsUpdate]</h3>
  52. <p>
  53. 이 속성이 변했는지와 GPU에 다시 전송해야하는지에 대한 표시입니다.
  54. 배열의 값을 수정했다면 이 값을 true로 설정하세요.<br /><br />
  55. 이 값을 true로 설정하면 [page:BufferAttribute.version version] 값도 높입니다.
  56. </p>
  57. <h3>[property:Boolean normalized]</h3>
  58. <p>
  59. 버퍼에 있는 기저 데이터가 GLSL 코드에서 값으로 맵핑되는 방식입니다.
  60. 자세한 내용은 위의 생성자 부분을 참고하세요.
  61. </p>
  62. <h3>[property:Function onUploadCallback]</h3>
  63. <p>
  64. 렌더러가 속성 배열 데이터를 GPU에 전달한 후에 실행되는 함수입니다.
  65. </p>
  66. <h3>[property:Object updateRange]</h3>
  67. <p>포함 객체:<br />
  68. [page:Integer offset]: 기본값은 *0*입니다. 업데이트를 시작할 위치입니다.<br />
  69. [page:Integer count]: 기본값은 *-1*이고, 업데이트 번위를 사용하지 않는다는 의미입니다.<br /><br />
  70. 저장된 벡터의 몇몇 컴포넌트들을 업데이트 할 때만 사용됩니다 (예를 들면, 색과 관련된 컴포넌트만 업데이트할 때).
  71. </p>
  72. <h3>[property:Usage usage]</h3>
  73. <p>
  74. 최적화를 목적으로 특정 데이터 저장 패턴 사용을 정의합니다.
  75. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData WebGLRenderingContext.bufferData]()의 *usage* 파라미터에 대응됩니다.
  76. 기본값은 *THREE.StaticDrawUsage*입니다.
  77. </p>
  78. <h3>[property:Integer version]</h3>
  79. <p>버전값으로, [page:BufferAttribute.needsUpdate needsUpdate] 속성이 true로 설정될 때 증가합니다.</p>
  80. <h2>메서드</h2>
  81. <h3>[method:this applyMatrix3]( [param:Matrix3 m] )</h3>
  82. <p>현재 BufferAttribute의 모든 Vector3 엘레먼트에 matrix [page:Matrix3 m]를 적용합니다.</p>
  83. <h3>[method:this applyMatrix4]( [param:Matrix4 m] )</h3>
  84. <p>현재 BufferAttribute의 모든 Vector3 엘레먼트에 matrix [page:Matrix4 m]를 적용합니다.</p>
  85. <h3>[method:this applyNormalMatrix]( [param:Matrix3 m] )</h3>
  86. <p>현재 BufferAttribute의 모든 Vector3 엘레먼트에 일반 matrix [page:Matrix3 m]를 적용합니다.</p>
  87. <h3>[method:this transformDirection]( [param:Matrix4 m] )</h3>
  88. <p>현재 BufferAttribute의 모든 Vector3 엘레먼트에 matrix [page:Matrix4 m]를 적용하고, 엘레먼트를 방향 벡터로 이동합니다.</p>
  89. <h3>[method:BufferAttribute clone]() </h3>
  90. <p>bufferAttribute 사본을 리턴합니다.</p>
  91. <h3>[method:BufferAttribute copy]( [param:BufferAttribute bufferAttribute] )</h3>
  92. <p>현재의 BufferAttribute에 다른 BufferAttribute를 붙여 넣습니다.</p>
  93. <h3>[method:BufferAttribute copyArray]( array ) </h3>
  94. <p>[page:BufferAttribute.array array]에 해당 배열(일반 배열 혹은 TypedArray)을 복사합니다.<br /><br />
  95. TypedArray를 복사할 때의 조건에 대한 주의사항은 [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set TypedArray.set]
  96. 를 참고해 주세요.
  97. </p>
  98. <h3>[method:null copyAt] ( [param:Integer index1], [param:BufferAttribute bufferAttribute], [param:Integer index2] ) </h3>
  99. <p>bufferAttribute[index2]의 벡터를 [page:BufferAttribute.array array][index1]에 복사합니다.</p>
  100. <h3>[method:BufferAttribute copyColorsArray]( [param:Array colors] ) </h3>
  101. <p>RGB 색상 값을 나타내는 배열을 [page:BufferAttribute.array array]에 복사합니다.</p>
  102. <h3>[method:BufferAttribute copyVector2sArray]( [param:Array vectors] ) </h3>
  103. <p>[page:Vector2]값을 나타내는 배열을 [page:BufferAttribute.array array]에 복사합니다.</p>
  104. <h3>[method:BufferAttribute copyVector3sArray]( [param:Array vectors] ) </h3>
  105. <p>[page:Vector3]값을 나타내는 배열을 [page:BufferAttribute.array array]에 복사합니다.</p>
  106. <h3>[method:BufferAttribute copyVector4sArray]( [param:Array vectors] ) </h3>
  107. <p>[page:Vector4]값을 나타내는 배열을 [page:BufferAttribute.array array]에 복사합니다.</p>
  108. <h3>[method:Number getX]( [param:Integer index] ) </h3>
  109. <p>해당 index의 벡터의 x 컴포넌트 값을 리턴합니다.</p>
  110. <h3>[method:Number getY]( [param:Integer index] ) </h3>
  111. <p>해당 index의 벡터의 y 컴포넌트 값을 리턴합니다.</p>
  112. <h3>[method:Number getZ]( [param:Integer index] ) </h3>
  113. <p>해당 index의 벡터의 z 컴포넌트 값을 리턴합니다.</p>
  114. <h3>[method:Number getW]( [param:Integer index] ) </h3>
  115. <p>해당 index의 벡터의 w 컴포넌트 값을 리턴합니다.</p>
  116. <h3>[method:this onUpload]( [param:Function callback] ) </h3>
  117. <p>
  118. onUploadCallback 속성의 값을 설정합니다.<br /><br />
  119. 이 값은 [example:webgl_buffergeometry WebGL / Buffergeometry]에서 버퍼가 GPU로 전송된 후에 자유 메모리로 사용됩니다.
  120. </p>
  121. <h3>[method:BufferAttribute set] ( [param:Array value], [param:Integer offset] ) </h3>
  122. <p>
  123. value -- 복사할 [page:Array] 혹은 [page:TypedArray] 값입니다. <br />
  124. offset -- (생략가능) 복사를 시작할 [page:BufferAttribute.array array] 의 인덱스값입니다.<br /><br />
  125. [page:BufferAttribute.array array]에서 [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set TypedArray.set]( [page:Array value], [page:Integer offset] )
  126. 를 호출합니다.<br /><br />
  127. [page:Array value]가 [page:TypedArray]로 되는 조건에 대해서는 해당 페이지를 참고하세요.
  128. </p>
  129. <h3>[method:BufferAttribute setUsage] ( [param:Usage value] ) </h3>
  130. <p>[page:BufferAttribute.usage usage]를 value로 설정합니다.</p>
  131. <h3>[method:BufferAttribute setX]( [param:Integer index], [param:Float x] ) </h3>
  132. <p> x 컴포넌트 값을 설정합니다.</p>
  133. <h3>[method:BufferAttribute setY]( [param:Integer index], [param:Float y] ) </h3>
  134. <p> y 컴포넌트 값을 설정합니다.</p>
  135. <h3>[method:BufferAttribute setZ]( [param:Integer index], [param:Float z] ) </h3>
  136. <p> z 컴포넌트 값을 설정합니다.</p>
  137. <h3>[method:BufferAttribute setW]( [param:Integer index], [param:Float w] ) </h3>
  138. <p> w 컴포넌트 값을 설정합니다.</p>
  139. <h3>[method:BufferAttribute setXY]( [param:Integer index], [param:Float x], [param:Float y] ) </h3>
  140. <p>index의 벡터의 x 및 y 컴포넌트를 설정합니다.</p>
  141. <h3>[method:BufferAttribute setXYZ]( [param:Integer index], [param:Float x], [param:Float y], [param:Float z] ) </h3>
  142. <p> x, y 및 z 컴포넌트를 설정합니다. </p>
  143. <h3>[method:BufferAttribute setXYZW]( [param:Integer index], [param:Float x], [param:Float y], [param:Float z], [param:Float w] ) </h3>
  144. <p> x, y, z 및 w 컴포넌트를 설정합니다. </p>
  145. <h2>소스코드</h2>
  146. <p>
  147. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  148. </p>
  149. </body>
  150. </html>