Skip to content

Commit

Permalink
fix(ConnectorsList): add back missing ConnectorsList (#62)
Browse files Browse the repository at this point in the history
* fix(ConnectorList): added missing ConnectorList export
* test(connectors): added very basic check for ConnectorList objects
  • Loading branch information
kaosat-dev committed Nov 1, 2017
1 parent 2e2c989 commit cfc1c7e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion csg.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ CSG.Matrix4x4 = require('./src/math/Matrix4')

CAG.Side = require('./src/math/Side')

CSG.Connector = require('./src/connectors')
CSG.Connector = require('./src/connectors').Connector
CSG.ConnectorList = require('./src/connectors').ConnectorList
CSG.Properties = require('./src/Properties')

const {circle, ellipse, rectangle, roundedRectangle} = require('./src/primitives2d')
Expand Down
2 changes: 1 addition & 1 deletion src/CAG.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const {EPS, angleEPS, areaEPS, defaultResolution3D} = require('./constants')
const Connector = require('./connectors')
const {Connector} = require('./connectors')
const OrthoNormalBasis = require('./math/OrthoNormalBasis')
const Vertex2D = require('./math/Vertex2')
const Vertex3D = require('./math/Vertex3')
Expand Down
4 changes: 2 additions & 2 deletions src/CSG.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const OrthoNormalBasis = require('./math/OrthoNormalBasis')
const CAG = require('./CAG') // FIXME: circular dependency !

const Properties = require('./Properties')
const Connector = require('./connectors')
//let {fromPolygons} = require('./CSGMakers') // FIXME: circular dependency !
const {Connector} = require('./connectors')
// let {fromPolygons} = require('./CSGMakers') // FIXME: circular dependency !

/** Class CSG
* Holds a binary space partition tree representing a 3D solid. Two solids can
Expand Down
14 changes: 8 additions & 6 deletions src/connectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ ConnectorList._fromPath2DExplicit = function (path2D, angleIsh) {
}

ConnectorList.prototype = {
setClosed: function (bool) {
setClosed: function (closed) {
this.closed = !!closed // FIXME: what the hell ?
},
appendConnector: function (conn) {
Expand Down Expand Up @@ -202,17 +202,19 @@ ConnectorList.prototype = {
* TODO: add a check that 2 follow-on CAGs are not intersecting
*/
verify: function () {
let connI, connI1, dPosToAxis, axisToNextAxis
let connI
let connI1
for (let i = 0; i < this.connectors_.length - 1; i++) {
connI = this.connectors_[i], connI1 = this.connectors_[i + 1]
connI = this.connectors_[i]
connI1 = this.connectors_[i + 1]
if (connI1.point.minus(connI.point).dot(connI.axisvector) <= 0) {
throw ('Invalid ConnectorList. Each connectors position needs to be within a <90deg range of previous connectors axisvector')
throw new Error('Invalid ConnectorList. Each connectors position needs to be within a <90deg range of previous connectors axisvector')
}
if (connI.axisvector.dot(connI1.axisvector) <= 0) {
throw ('invalid ConnectorList. No neighboring connectors axisvectors may span a >=90deg angle')
throw new Error('invalid ConnectorList. No neighboring connectors axisvectors may span a >=90deg angle')
}
}
}
}

module.exports = Connector
module.exports = {Connector, ConnectorList}
2 changes: 1 addition & 1 deletion src/primitives3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {defaultResolution3D, defaultResolution2D, EPS} = require('./constants')
const Vector3D = require('./math/Vector3')
const Vertex = require('./math/Vertex3')
const Polygon = require('./math/Polygon3')
const Connector = require('./connectors')
const {Connector} = require('./connectors')
const Properties = require('./Properties')

/** Construct an axis-aligned solid cuboid.
Expand Down
7 changes: 6 additions & 1 deletion test/connectors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import test from 'ava'
import {CSG} from '../csg'


test('CSG.Connector exists', t => {
t.is('Connector' in CSG, true)
})

test('CSG.connectorslist can be instanciated', t => {
const observed = new CSG.ConnectorList()

t.deepEqual(observed, {connectors_: []})
})

0 comments on commit cfc1c7e

Please sign in to comment.