Box2.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. 表示二维空间中的一个包围盒。
  14. </p>
  15. <h2>构造函数(Constructor)</h2>
  16. <h3>[name]( [param:Vector2 min], [param:Vector2 max] )</h3>
  17. <p>
  18. [page:Vector2 min] - (可选) [page:Vector2] 表示该盒子的下边界(x, y)。默认值为( + Infinity, + Infinity )。<br>
  19. [page:Vector2 max] - (可选) [page:Vector2] 表示该盒子的上边界(x, y)。默认值为( - Infinity, - Infinity )。<br /><br />
  20. 创建一个介于最小和最大值之间的[name]。
  21. </p>
  22. <h2>属性(Properties)</h2>
  23. <h3>[property:Vector2 min]</h3>
  24. <p>
  25. [page:Vector2] 表示该盒子的下边界(x, y)。<br />
  26. 默认值为( + Infinity, + Infinity )。
  27. </p>
  28. <h3>[property:Vector2 max]</h3>
  29. <p>
  30. [page:Vector2] 表示该盒子的上边界(x, y)。<br />
  31. 默认值为( - Infinity, - Infinity )。
  32. </p>
  33. <h2>方法(Methods)</h2>
  34. <h3>[method:Vector2 clampPoint]( [param:Vector2 point], [param:Vector2 target] )</h3>
  35. <p>
  36. [page:Vector2 point] - clamp 的位置 ([page:Vector2]) <br>
  37. [page:Vector2 target] — 结果会被复制到该二维向量中。<br /><br />
  38. 在该盒子范围内夹紧([link:https://en.wikipedia.org/wiki/Clamping_(graphics) Clamps])[page:Vector2 point]。<br />
  39. </p>
  40. <h3>[method:Box2 clone]()</h3>
  41. <p>返回一个新的[page:Box2],其[page:.min min]和[page:.max max]与此盒子相同。</p>
  42. <h3>[method:Boolean containsBox]( [param:Box2 box] )</h3>
  43. <p>
  44. [page:Box2 box] - 要检查是否被包含的盒子。<br /><br />
  45. 如果盒子包含整个被检查盒子,则返回true。如果两者重叠,<br>
  46. 也会返回true。
  47. </p>
  48. <h3>[method:Boolean containsPoint]( [param:Vector2 point] )</h3>
  49. <p>
  50. [page:Vector2 point] - 要检查是否被包含的点[page:Vector2]。<br /><br />
  51. 如果指定的点([page:Vector2 point])位于盒子的边界内或边界上,则返回true。
  52. </p>
  53. <h3>[method:Box2 copy]( [param:Box2 box] )</h3>
  54. <p>
  55. 将[page:Box2 box]的[page:.min min] 和 [page:.max max]复制到此盒子中。
  56. </p>
  57. <h3>[method:Float distanceToPoint]( [param:Vector2 point] )</h3>
  58. <p>
  59. [page:Vector2 point] - 要测量距离的点([page:Vector2])。<br /><br />
  60. 返回这个盒子的任何边缘到指定点的距离。如果这个点([page:Vector2 point])位于这个盒子里,距离将是0。
  61. </p>
  62. <h3>[method:Boolean equals]( [param:Box2 box] )</h3>
  63. <p>
  64. [page:Box2 box] - 要对比的盒子<br /><br />
  65. 如果这个盒子和被对比盒子具有相同的上下边界,则返回true。
  66. </p>
  67. <h3>[method:Box2 expandByPoint]( [param:Vector2 point] )</h3>
  68. <p>
  69. [page:Vector2 point] - 应该被盒子包含的点。<br /><br />
  70. 扩展盒子的边界来包含该点。
  71. </p>
  72. <h3>[method:Box2 expandByScalar]( [param:float scalar] )</h3>
  73. <p>
  74. [page:float scalar] - 盒子扩展的距离。<br /><br />
  75. 在每个维度上扩展参数scalar所指定的距离,如果为负数,则盒子空间将收缩。
  76. </p>
  77. <h3>[method:Box2 expandByVector]( [param:Vector2 vector] )</h3>
  78. <p>
  79. [page:Vector2 vector] - 按照该向量扩展。<br /><br />
  80. 在每个维度中按vector的数值进行扩展。宽度在两个方向上的扩展将由vector的x分量确定,
  81. 高度在两个方向上的扩展则由y分量确定。
  82. </p>
  83. <h3>[method:Vector2 getCenter]( [param:Vector2 target] )</h3>
  84. <p>
  85. [page:Vector2 target] — 结果将被复制到此二维向量中。<br /><br />
  86. 以二维向量形式返回盒子的中心点。
  87. </p>
  88. <h3>[method:Vector2 getParameter]( [param:Vector2 point], [param:Vector2 target] ) </h3>
  89. <p>
  90. [page:Vector2 point] - 二维向量([page:Vector2]).<br/>
  91. [page:Vector2 target] — 结果将被复制到此二维向量中。<br /><br />
  92. 返回一个点作为此盒子的宽度和高度的比例。
  93. </p>
  94. <h3>[method:Vector2 getSize]( [param:Vector2 target] )</h3>
  95. <p>
  96. [page:Vector2 target] — 结果将被复制到此二维向量中。<br /><br />
  97. 返回此盒子的宽度和高度。
  98. </p>
  99. <h3>[method:Box2 intersect]( [param:Box2 box] )</h3>
  100. <p>
  101. [page:Box2 box] - 要相交的盒子。<br /><br />
  102. 返回两者的相交后的盒子,并将相交后的盒子的上限设置为两者的上限中的较小者,将下限设置为两者的下限中的较大者。
  103. </p>
  104. <h3>[method:Boolean intersectsBox]( [param:Box2 box] )</h3>
  105. <p>
  106. [page:Box2 box] - 用来检查相交的盒子。<br /><br />
  107. 确定该盒子是否和其相交。
  108. </p>
  109. <h3>[method:Boolean isEmpty]()</h3>
  110. <p>
  111. 如果这个盒子包含0个顶点,则返回true。<br>
  112. 请注意,一个下上边界相等的的盒子仍然包括一个点,一个两个边界共享的点。
  113. </p>
  114. <h3>[method:Box2 makeEmpty]()</h3>
  115. <p>使此盒子为空。</p>
  116. <h3>[method:Box2 set]( [param:Vector2 min], [param:Vector2 max] )</h3>
  117. <p>
  118. [page:Vector2 min] - (必须 ) 表示该盒子的下边界(x, y)。 <br>
  119. [page:Vector2 max] - (必须) 表示该盒子的上边界(x, y)。 <br /><br />
  120. 设置这个盒子的上下(x, y)的界限。<br>
  121. Please note that this method only copies the values from the given objects.
  122. </p>
  123. <h3>[method:Box2 setFromCenterAndSize]( [param:Vector2 center], [param:Vector2 size] )</h3>
  124. <p>
  125. [page:Vector2 center] - 盒子所要设置的中心位置。 ([page:Vector2]). <br>
  126. [page:Vector2 size] - 盒子所要设置的x和y尺寸 ([page:Vector2]).<br /><br />
  127. 使盒子的中心点位于[page:Vector2 center],并设置宽高为[page:Vector2 size]中指定的值。
  128. </p>
  129. <h3>[method:Box2 setFromPoints]( [param:Array points] )</h3>
  130. <p>
  131. [page:Array points] - 点的集合,由这些点确定的空间将被盒子包围。<br /><br />
  132. 设置这个盒子的上下边界,来包含所有设置在[page:Array points]参数中的点。
  133. </p>
  134. <h3>[method:Box2 translate]( [param:Vector2 offset] )</h3>
  135. <p>
  136. [page:Vector2 offset] - 偏移方向和距离。<br /><br />
  137. 添加 [page:Vector2 offset] 到这个盒子的上下边界,实际上在2D空间移动这个盒子[page:Vector2 offset]个单位。
  138. </p>
  139. <h3>[method:Box2 union]( [param:Box2 box] )</h3>
  140. <p>
  141. [page:Box2 box] - 将要与该盒子联合的盒子<br /><br />
  142. 在[page:Box2 box]参数的上边界和该盒子的上边界之间取较大者,而对两者的下边界取较小者,这样获得一个新的较大的联合盒子。
  143. </p>
  144. <h2>源码(Source)</h2>
  145. <p>
  146. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  147. </p>
  148. </body>
  149. </html>