Vector4.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /**
  2. * @author bhouston / http://exocortex.com
  3. */
  4. QUnit.module( "Vector4" );
  5. QUnit.test( "constructor" , function( assert ) {
  6. var a = new THREE.Vector4();
  7. assert.ok( a.x == 0, "Passed!" );
  8. assert.ok( a.y == 0, "Passed!" );
  9. assert.ok( a.z == 0, "Passed!" );
  10. assert.ok( a.w == 1, "Passed!" );
  11. a = new THREE.Vector4( x, y, z, w );
  12. assert.ok( a.x === x, "Passed!" );
  13. assert.ok( a.y === y, "Passed!" );
  14. assert.ok( a.z === z, "Passed!" );
  15. assert.ok( a.w === w, "Passed!" );
  16. });
  17. QUnit.test( "copy" , function( assert ) {
  18. var a = new THREE.Vector4( x, y, z, w );
  19. var b = new THREE.Vector4().copy( a );
  20. assert.ok( b.x == x, "Passed!" );
  21. assert.ok( b.y == y, "Passed!" );
  22. assert.ok( b.z == z, "Passed!" );
  23. assert.ok( b.w == w, "Passed!" );
  24. // ensure that it is a true copy
  25. a.x = 0;
  26. a.y = -1;
  27. a.z = -2;
  28. a.w = -3;
  29. assert.ok( b.x == x, "Passed!" );
  30. assert.ok( b.y == y, "Passed!" );
  31. assert.ok( b.z == z, "Passed!" );
  32. assert.ok( b.w == w, "Passed!" );
  33. });
  34. QUnit.test( "set" , function( assert ) {
  35. var a = new THREE.Vector4();
  36. assert.ok( a.x == 0, "Passed!" );
  37. assert.ok( a.y == 0, "Passed!" );
  38. assert.ok( a.z == 0, "Passed!" );
  39. assert.ok( a.w == 1, "Passed!" );
  40. a.set( x, y, z, w );
  41. assert.ok( a.x == x, "Passed!" );
  42. assert.ok( a.y == y, "Passed!" );
  43. assert.ok( a.z == z, "Passed!" );
  44. assert.ok( a.w == w, "Passed!" );
  45. });
  46. QUnit.test( "setX,setY,setZ,setW", function( assert ) {
  47. var a = new THREE.Vector4();
  48. assert.ok( a.x == 0, "Passed!" );
  49. assert.ok( a.y == 0, "Passed!" );
  50. assert.ok( a.z == 0, "Passed!" );
  51. assert.ok( a.w == 1, "Passed!" );
  52. a.setX( x );
  53. a.setY( y );
  54. a.setZ( z );
  55. a.setW( w );
  56. assert.ok( a.x == x, "Passed!" );
  57. assert.ok( a.y == y, "Passed!" );
  58. assert.ok( a.z == z, "Passed!" );
  59. assert.ok( a.w == w, "Passed!" );
  60. });
  61. QUnit.test( "setComponent,getComponent", function( assert ) {
  62. var a = new THREE.Vector4();
  63. assert.ok( a.x == 0, "Passed!" );
  64. assert.ok( a.y == 0, "Passed!" );
  65. assert.ok( a.z == 0, "Passed!" );
  66. assert.ok( a.w == 1, "Passed!" );
  67. a.setComponent( 0, 1 );
  68. a.setComponent( 1, 2 );
  69. a.setComponent( 2, 3 );
  70. a.setComponent( 3, 4 );
  71. assert.ok( a.getComponent( 0 ) == 1, "Passed!" );
  72. assert.ok( a.getComponent( 1 ) == 2, "Passed!" );
  73. assert.ok( a.getComponent( 2 ) == 3, "Passed!" );
  74. assert.ok( a.getComponent( 3 ) == 4, "Passed!" );
  75. });
  76. QUnit.test( "add" , function( assert ) {
  77. var a = new THREE.Vector4( x, y, z, w );
  78. var b = new THREE.Vector4( -x, -y, -z, -w );
  79. a.add( b );
  80. assert.ok( a.x == 0, "Passed!" );
  81. assert.ok( a.y == 0, "Passed!" );
  82. assert.ok( a.z == 0, "Passed!" );
  83. assert.ok( a.w == 0, "Passed!" );
  84. var c = new THREE.Vector4().addVectors( b, b );
  85. assert.ok( c.x == -2*x, "Passed!" );
  86. assert.ok( c.y == -2*y, "Passed!" );
  87. assert.ok( c.z == -2*z, "Passed!" );
  88. assert.ok( c.w == -2*w, "Passed!" );
  89. });
  90. QUnit.test( "sub" , function( assert ) {
  91. var a = new THREE.Vector4( x, y, z, w );
  92. var b = new THREE.Vector4( -x, -y, -z, -w );
  93. a.sub( b );
  94. assert.ok( a.x == 2*x, "Passed!" );
  95. assert.ok( a.y == 2*y, "Passed!" );
  96. assert.ok( a.z == 2*z, "Passed!" );
  97. assert.ok( a.w == 2*w, "Passed!" );
  98. var c = new THREE.Vector4().subVectors( a, a );
  99. assert.ok( c.x == 0, "Passed!" );
  100. assert.ok( c.y == 0, "Passed!" );
  101. assert.ok( c.z == 0, "Passed!" );
  102. assert.ok( c.w == 0, "Passed!" );
  103. });
  104. QUnit.test( "multiply/divide", function( assert ) {
  105. var a = new THREE.Vector4( x, y, z, w );
  106. var b = new THREE.Vector4( -x, -y, -z, -w );
  107. a.multiplyScalar( -2 );
  108. assert.ok( a.x == x*-2, "Passed!" );
  109. assert.ok( a.y == y*-2, "Passed!" );
  110. assert.ok( a.z == z*-2, "Passed!" );
  111. assert.ok( a.w == w*-2, "Passed!" );
  112. b.multiplyScalar( -2 );
  113. assert.ok( b.x == 2*x, "Passed!" );
  114. assert.ok( b.y == 2*y, "Passed!" );
  115. assert.ok( b.z == 2*z, "Passed!" );
  116. assert.ok( b.w == 2*w, "Passed!" );
  117. a.divideScalar( -2 );
  118. assert.ok( a.x == x, "Passed!" );
  119. assert.ok( a.y == y, "Passed!" );
  120. assert.ok( a.z == z, "Passed!" );
  121. assert.ok( a.w == w, "Passed!" );
  122. b.divideScalar( -2 );
  123. assert.ok( b.x == -x, "Passed!" );
  124. assert.ok( b.y == -y, "Passed!" );
  125. assert.ok( b.z == -z, "Passed!" );
  126. assert.ok( b.w == -w, "Passed!" );
  127. });
  128. QUnit.test( "min/max/clamp", function( assert ) {
  129. var a = new THREE.Vector4( x, y, z, w );
  130. var b = new THREE.Vector4( -x, -y, -z, -w );
  131. var c = new THREE.Vector4();
  132. c.copy( a ).min( b );
  133. assert.ok( c.x == -x, "Passed!" );
  134. assert.ok( c.y == -y, "Passed!" );
  135. assert.ok( c.z == -z, "Passed!" );
  136. assert.ok( c.w == -w, "Passed!" );
  137. c.copy( a ).max( b );
  138. assert.ok( c.x == x, "Passed!" );
  139. assert.ok( c.y == y, "Passed!" );
  140. assert.ok( c.z == z, "Passed!" );
  141. assert.ok( c.w == w, "Passed!" );
  142. c.set( -2*x, 2*y, -2*z, 2*w );
  143. c.clamp( b, a );
  144. assert.ok( c.x == -x, "Passed!" );
  145. assert.ok( c.y == y, "Passed!" );
  146. assert.ok( c.z == -z, "Passed!" );
  147. assert.ok( c.w == w, "Passed!" );
  148. });
  149. QUnit.test( "negate" , function( assert ) {
  150. var a = new THREE.Vector4( x, y, z, w );
  151. a.negate();
  152. assert.ok( a.x == -x, "Passed!" );
  153. assert.ok( a.y == -y, "Passed!" );
  154. assert.ok( a.z == -z, "Passed!" );
  155. assert.ok( a.w == -w, "Passed!" );
  156. });
  157. QUnit.test( "dot" , function( assert ) {
  158. var a = new THREE.Vector4( x, y, z, w );
  159. var b = new THREE.Vector4( -x, -y, -z, -w );
  160. var c = new THREE.Vector4( 0, 0, 0, 0 );
  161. var result = a.dot( b );
  162. assert.ok( result == (-x*x-y*y-z*z-w*w), "Passed!" );
  163. result = a.dot( c );
  164. assert.ok( result == 0, "Passed!" );
  165. });
  166. QUnit.test( "length/lengthSq", function( assert ) {
  167. var a = new THREE.Vector4( x, 0, 0, 0 );
  168. var b = new THREE.Vector4( 0, -y, 0, 0 );
  169. var c = new THREE.Vector4( 0, 0, z, 0 );
  170. var d = new THREE.Vector4( 0, 0, 0, w );
  171. var e = new THREE.Vector4( 0, 0, 0, 0 );
  172. assert.ok( a.length() == x, "Passed!" );
  173. assert.ok( a.lengthSq() == x*x, "Passed!" );
  174. assert.ok( b.length() == y, "Passed!" );
  175. assert.ok( b.lengthSq() == y*y, "Passed!" );
  176. assert.ok( c.length() == z, "Passed!" );
  177. assert.ok( c.lengthSq() == z*z, "Passed!" );
  178. assert.ok( d.length() == w, "Passed!" );
  179. assert.ok( d.lengthSq() == w*w, "Passed!" );
  180. assert.ok( e.length() == 0, "Passed!" );
  181. assert.ok( e.lengthSq() == 0, "Passed!" );
  182. a.set( x, y, z, w );
  183. assert.ok( a.length() == Math.sqrt( x*x + y*y + z*z + w*w ), "Passed!" );
  184. assert.ok( a.lengthSq() == ( x*x + y*y + z*z + w*w ), "Passed!" );
  185. });
  186. QUnit.test( "normalize" , function( assert ) {
  187. var a = new THREE.Vector4( x, 0, 0, 0 );
  188. var b = new THREE.Vector4( 0, -y, 0, 0 );
  189. var c = new THREE.Vector4( 0, 0, z, 0 );
  190. var d = new THREE.Vector4( 0, 0, 0, -w );
  191. a.normalize();
  192. assert.ok( a.length() == 1, "Passed!" );
  193. assert.ok( a.x == 1, "Passed!" );
  194. b.normalize();
  195. assert.ok( b.length() == 1, "Passed!" );
  196. assert.ok( b.y == -1, "Passed!" );
  197. c.normalize();
  198. assert.ok( c.length() == 1, "Passed!" );
  199. assert.ok( c.z == 1, "Passed!" );
  200. d.normalize();
  201. assert.ok( d.length() == 1, "Passed!" );
  202. assert.ok( d.w == -1, "Passed!" );
  203. });
  204. /*
  205. QUnit.test( "distanceTo/distanceToSquared", function() {
  206. var a = new THREE.Vector4( x, 0, 0, 0 );
  207. var b = new THREE.Vector4( 0, -y, 0, 0 );
  208. var c = new THREE.Vector4( 0, 0, z, 0 );
  209. var d = new THREE.Vector4( 0, 0, 0, -w );
  210. var e = new THREE.Vector4();
  211. ok( a.distanceTo( e ) == x, "Passed!" );
  212. ok( a.distanceToSquared( e ) == x*x, "Passed!" );
  213. ok( b.distanceTo( e ) == y, "Passed!" );
  214. ok( b.distanceToSquared( e ) == y*y, "Passed!" );
  215. ok( c.distanceTo( e ) == z, "Passed!" );
  216. ok( c.distanceToSquared( e ) == z*z, "Passed!" );
  217. ok( d.distanceTo( e ) == w, "Passed!" );
  218. ok( d.distanceToSquared( e ) == w*w, "Passed!" );
  219. });
  220. */
  221. QUnit.test( "setLength" , function( assert ) {
  222. var a = new THREE.Vector4( x, 0, 0, 0 );
  223. assert.ok( a.length() == x, "Passed!" );
  224. a.setLength( y );
  225. assert.ok( a.length() == y, "Passed!" );
  226. a = new THREE.Vector4( 0, 0, 0, 0 );
  227. assert.ok( a.length() == 0, "Passed!" );
  228. a.setLength( y );
  229. assert.ok( a.length() == 0, "Passed!" );
  230. a.setLength();
  231. assert.ok( isNaN( a.length() ), "Passed!" );
  232. });
  233. QUnit.test( "lerp/clone", function( assert ) {
  234. var a = new THREE.Vector4( x, 0, z, 0 );
  235. var b = new THREE.Vector4( 0, -y, 0, -w );
  236. assert.ok( a.lerp( a, 0 ).equals( a.lerp( a, 0.5 ) ), "Passed!" );
  237. assert.ok( a.lerp( a, 0 ).equals( a.lerp( a, 1 ) ), "Passed!" );
  238. assert.ok( a.clone().lerp( b, 0 ).equals( a ), "Passed!" );
  239. assert.ok( a.clone().lerp( b, 0.5 ).x == x*0.5, "Passed!" );
  240. assert.ok( a.clone().lerp( b, 0.5 ).y == -y*0.5, "Passed!" );
  241. assert.ok( a.clone().lerp( b, 0.5 ).z == z*0.5, "Passed!" );
  242. assert.ok( a.clone().lerp( b, 0.5 ).w == -w*0.5, "Passed!" );
  243. assert.ok( a.clone().lerp( b, 1 ).equals( b ), "Passed!" );
  244. });
  245. QUnit.test( "equals" , function( assert ) {
  246. var a = new THREE.Vector4( x, 0, z, 0 );
  247. var b = new THREE.Vector4( 0, -y, 0, -w );
  248. assert.ok( a.x != b.x, "Passed!" );
  249. assert.ok( a.y != b.y, "Passed!" );
  250. assert.ok( a.z != b.z, "Passed!" );
  251. assert.ok( a.w != b.w, "Passed!" );
  252. assert.ok( ! a.equals( b ), "Passed!" );
  253. assert.ok( ! b.equals( a ), "Passed!" );
  254. a.copy( b );
  255. assert.ok( a.x == b.x, "Passed!" );
  256. assert.ok( a.y == b.y, "Passed!" );
  257. assert.ok( a.z == b.z, "Passed!" );
  258. assert.ok( a.w == b.w, "Passed!" );
  259. assert.ok( a.equals( b ), "Passed!" );
  260. assert.ok( b.equals( a ), "Passed!" );
  261. });
  262. QUnit.test( "setComponent/getComponent exceptions", function ( assert ) {
  263. var a = new THREE.Vector4();
  264. assert.throws(
  265. function () {
  266. a.setComponent( 4, 0 );
  267. },
  268. /index is out of range/,
  269. "setComponent with an out of range index throws Error"
  270. );
  271. assert.throws(
  272. function () {
  273. a.getComponent( 4 );
  274. },
  275. /index is out of range/,
  276. "getComponent with an out of range index throws Error"
  277. );
  278. } );
  279. QUnit.test( "lengthManhattan", function ( assert ) {
  280. var a = new THREE.Vector4( x, 0, 0, 0 );
  281. var b = new THREE.Vector4( 0, - y, 0, 0 );
  282. var c = new THREE.Vector4( 0, 0, z, 0 );
  283. var d = new THREE.Vector4( 0, 0, 0, w );
  284. var e = new THREE.Vector4( 0, 0, 0, 0 );
  285. assert.ok( a.lengthManhattan() == x, "Positive x" );
  286. assert.ok( b.lengthManhattan() == y, "Negative y" );
  287. assert.ok( c.lengthManhattan() == z, "Positive z" );
  288. assert.ok( d.lengthManhattan() == w, "Positive w" );
  289. assert.ok( e.lengthManhattan() == 0, "Empty initialization" );
  290. a.set( x, y, z, w );
  291. assert.ok(
  292. a.lengthManhattan() == Math.abs( x ) + Math.abs( y ) + Math.abs( z ) + Math.abs( w ),
  293. "All components"
  294. );
  295. } );
  296. QUnit.test( "setScalar/addScalar/subScalar", function ( assert ) {
  297. var a = new THREE.Vector4();
  298. var s = 3;
  299. a.setScalar( s );
  300. assert.strictEqual( a.x, s, "setScalar: check x" );
  301. assert.strictEqual( a.y, s, "setScalar: check y" );
  302. assert.strictEqual( a.z, s, "setScalar: check z" );
  303. assert.strictEqual( a.w, s, "setScalar: check w" );
  304. a.addScalar( s );
  305. assert.strictEqual( a.x, 2 * s, "addScalar: check x" );
  306. assert.strictEqual( a.y, 2 * s, "addScalar: check y" );
  307. assert.strictEqual( a.z, 2 * s, "addScalar: check z" );
  308. assert.strictEqual( a.w, 2 * s, "addScalar: check w" );
  309. a.subScalar( 2 * s );
  310. assert.strictEqual( a.x, 0, "subScalar: check x" );
  311. assert.strictEqual( a.y, 0, "subScalar: check y" );
  312. assert.strictEqual( a.z, 0, "subScalar: check z" );
  313. assert.strictEqual( a.w, 0, "subScalar: check w" );
  314. } );
  315. QUnit.test( "addScaledVector", function ( assert ) {
  316. var a = new THREE.Vector4( x, y, z, w );
  317. var b = new THREE.Vector4( 6, 7, 8, 9 );
  318. var s = 3;
  319. a.addScaledVector( b, s );
  320. assert.strictEqual( a.x, x + b.x * s, "Check x" );
  321. assert.strictEqual( a.y, y + b.y * s, "Check y" );
  322. assert.strictEqual( a.z, z + b.z * s, "Check z" );
  323. assert.strictEqual( a.w, w + b.w * s, "Check w" );
  324. } );
  325. QUnit.test( "applyMatrix4", function ( assert ) {
  326. var a = new THREE.Vector4( x, y, z, w );
  327. var m = new THREE.Matrix4().makeRotationX( Math.PI );
  328. var expected = new THREE.Vector4( 2, - 3, - 4, 5 );
  329. a.applyMatrix4( m );
  330. assert.ok( Math.abs( a.x - expected.x ) <= eps, "Rotation matrix: check x" );
  331. assert.ok( Math.abs( a.y - expected.y ) <= eps, "Rotation matrix: check y" );
  332. assert.ok( Math.abs( a.z - expected.z ) <= eps, "Rotation matrix: check z" );
  333. assert.ok( Math.abs( a.w - expected.w ) <= eps, "Rotation matrix: check w" );
  334. a.set( x, y, z, w );
  335. m.makeTranslation( 5, 7, 11 );
  336. expected.set( 27, 38, 59, 5 );
  337. a.applyMatrix4( m );
  338. assert.ok( Math.abs( a.x - expected.x ) <= eps, "Translation matrix: check x" );
  339. assert.ok( Math.abs( a.y - expected.y ) <= eps, "Translation matrix: check y" );
  340. assert.ok( Math.abs( a.z - expected.z ) <= eps, "Translation matrix: check z" );
  341. assert.ok( Math.abs( a.w - expected.w ) <= eps, "Translation matrix: check w" );
  342. a.set( x, y, z, w );
  343. m.set( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 );
  344. expected.set( 2, 3, 4, 4 );
  345. a.applyMatrix4( m );
  346. assert.ok( Math.abs( a.x - expected.x ) <= eps, "Custom matrix: check x" );
  347. assert.ok( Math.abs( a.y - expected.y ) <= eps, "Custom matrix: check y" );
  348. assert.ok( Math.abs( a.z - expected.z ) <= eps, "Custom matrix: check z" );
  349. assert.ok( Math.abs( a.w - expected.w ) <= eps, "Custom matrix: check w" );
  350. a.set( x, y, z, w );
  351. m.set( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 );
  352. expected.set( 68, 224, 442, 664 );
  353. a.applyMatrix4( m );
  354. assert.ok( Math.abs( a.x - expected.x ) <= eps, "Bogus matrix: check x" );
  355. assert.ok( Math.abs( a.y - expected.y ) <= eps, "Bogus matrix: check y" );
  356. assert.ok( Math.abs( a.z - expected.z ) <= eps, "Bogus matrix: check z" );
  357. assert.ok( Math.abs( a.w - expected.w ) <= eps, "Bogus matrix: check w" );
  358. } );
  359. QUnit.test( "clampScalar", function ( assert ) {
  360. var a = new THREE.Vector4( - 0.1, 0.01, 0.5, 1.5 );
  361. var clamped = new THREE.Vector4( 0.1, 0.1, 0.5, 1.0 );
  362. a.clampScalar( 0.1, 1.0 );
  363. assert.ok( Math.abs( a.x - clamped.x ) <= eps, "Check x" );
  364. assert.ok( Math.abs( a.y - clamped.y ) <= eps, "Check y" );
  365. assert.ok( Math.abs( a.z - clamped.z ) <= eps, "Check z" );
  366. assert.ok( Math.abs( a.w - clamped.w ) <= eps, "Check w" );
  367. } );
  368. QUnit.test( "fromArray", function ( assert ) {
  369. var a = new THREE.Vector4();
  370. var array = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
  371. a.fromArray( array );
  372. assert.strictEqual( a.x, 1, "No offset: check x" );
  373. assert.strictEqual( a.y, 2, "No offset: check y" );
  374. assert.strictEqual( a.z, 3, "No offset: check z" );
  375. assert.strictEqual( a.w, 4, "No offset: check w" );
  376. a.fromArray( array, 4 );
  377. assert.strictEqual( a.x, 5, "With offset: check x" );
  378. assert.strictEqual( a.y, 6, "With offset: check y" );
  379. assert.strictEqual( a.z, 7, "With offset: check z" );
  380. assert.strictEqual( a.w, 8, "With offset: check w" );
  381. } );
  382. QUnit.test( "toArray", function ( assert ) {
  383. var a = new THREE.Vector4( x, y, z, w );
  384. var array = a.toArray();
  385. assert.strictEqual( array[ 0 ], x, "No array, no offset: check x" );
  386. assert.strictEqual( array[ 1 ], y, "No array, no offset: check y" );
  387. assert.strictEqual( array[ 2 ], z, "No array, no offset: check z" );
  388. assert.strictEqual( array[ 3 ], w, "No array, no offset: check w" );
  389. array = [];
  390. a.toArray( array );
  391. assert.strictEqual( array[ 0 ], x, "With array, no offset: check x" );
  392. assert.strictEqual( array[ 1 ], y, "With array, no offset: check y" );
  393. assert.strictEqual( array[ 2 ], z, "With array, no offset: check z" );
  394. assert.strictEqual( array[ 3 ], w, "With array, no offset: check w" );
  395. array = [];
  396. a.toArray( array, 1 );
  397. assert.strictEqual( array[ 0 ], undefined, "With array and offset: check [0]" );
  398. assert.strictEqual( array[ 1 ], x, "With array and offset: check x" );
  399. assert.strictEqual( array[ 2 ], y, "With array and offset: check y" );
  400. assert.strictEqual( array[ 3 ], z, "With array and offset: check z" );
  401. assert.strictEqual( array[ 4 ], w, "With array and offset: check w" );
  402. } );
  403. QUnit.test( "fromBufferAttribute", function ( assert ) {
  404. var a = new THREE.Vector4();
  405. var attr = new THREE.BufferAttribute( new Float32Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), 4 );
  406. a.fromBufferAttribute( attr, 0 );
  407. assert.strictEqual( a.x, 1, "Offset 0: check x" );
  408. assert.strictEqual( a.y, 2, "Offset 0: check y" );
  409. assert.strictEqual( a.z, 3, "Offset 0: check z" );
  410. assert.strictEqual( a.w, 4, "Offset 0: check w" );
  411. a.fromBufferAttribute( attr, 1 );
  412. assert.strictEqual( a.x, 5, "Offset 1: check x" );
  413. assert.strictEqual( a.y, 6, "Offset 1: check y" );
  414. assert.strictEqual( a.z, 7, "Offset 1: check z" );
  415. assert.strictEqual( a.w, 8, "Offset 1: check w" );
  416. } );
粤ICP备19079148号