1 | import { test } from 'tape';
|
2 | import * as d3 from '../';
|
3 |
|
4 | test('planes\' centroid calculation is correct', function(t){
|
5 |
|
6 |
|
7 | var _3d = d3._3d().shape('PLANE').x(function(d){ return d.x; }).y(function(d){ return d.y; }).z(function(d){ return d.z; });
|
8 | var data = [
|
9 | [ {x: 1, y: 1, z: 0}, {x: -1, y: 1, z: 0}, {x: 1, y:-1, z: 1}, {x: -1, y: -1, z: 1}],
|
10 | ];
|
11 | t.deepEqual(_3d(data)[0].centroid, { x: 0, y: 0, z: 0.5 });
|
12 | t.end();
|
13 | });
|
14 |
|
15 | test('draw function of \'planes\' draws correctly', function(t){
|
16 | var _3d = d3._3d().shape('PLANE');
|
17 | var data = [
|
18 | [[5,0,2],[6,4,1],[4,5,8],[1,5,9]]
|
19 | ];
|
20 | t.deepEqual(_3d.draw(_3d(data)[0]), 'M5,0L6,4L4,5L1,5Z');
|
21 | t.end();
|
22 | });
|
23 |
|
24 | test('planes are drawn counter-clockwise', function(t){
|
25 | var _3d = d3._3d().shape('PLANE');
|
26 | var data = [
|
27 | [[-1,0,0],[1,0,0],[1,1,0],[-1,1,0]]
|
28 | ];
|
29 | t.deepEqual(_3d(data)[0].ccw, false);
|
30 | t.end();
|
31 | });
|