Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ConnectorsList): add back missing ConnectorsList #62

Merged
merged 2 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_: []})
})