|
1642 | 1642 | return new curve(a) // so curve() is like new curve() |
1643 | 1643 | } |
1644 | 1644 | if (args.canvas !== null) { // it's null if first setting up objects; see subclass function |
1645 | | - if (args.canvas !== undefined) initObject(this, curve, {canvas:args.canvas}) // e.g. called from helix |
| 1645 | + if (args.length == 1 && toType(args[0]) == 'object' && args[0].canvas !== undefined) { |
| 1646 | + initObject(this, curve, {canvas:args[0].canvas}) // e.g. called from helix |
| 1647 | + delete args[0].canvas |
| 1648 | + } |
1646 | 1649 | else initObject(this, curve, {}) |
1647 | 1650 | this.__points = [] // list of point objects |
1648 | 1651 | this.__radius = 0 // means width of a few pixels |
|
2013 | 2016 | } |
2014 | 2017 | }) |
2015 | 2018 |
|
2016 | | - function points(args) { // TODO: shrinking a curve's extent doesn't trigger moving the camera inward; dunno why. |
| 2019 | + function points(args) { |
2017 | 2020 | if (!(this instanceof points)) { |
2018 | | - var a = [] |
2019 | | - for (var i=0; i<arguments.length; i++) a.push(arguments[i]) |
2020 | | - return new points(a) // so curve() is like new curve() |
| 2021 | + return new points(arguments[0]) // so points() is like new points() |
2021 | 2022 | } |
2022 | 2023 | if (args.canvas !== null) { // it's null if first setting up objects; see subclass function |
2023 | 2024 | initObject(this, points, {}) |
|
2027 | 2028 | this.__pixels = true |
2028 | 2029 | this.__opacity = 1 |
2029 | 2030 | this.pickable = true |
2030 | | - if (args.length == 1 && toType(args[0]) == 'object') { |
2031 | | - var obj = args[0] |
2032 | | - if (obj.size_units !== undefined) { |
2033 | | - if (obj.size_units == 'pixels') this.__pixels = true |
2034 | | - else if (obj.size_units == 'world') this.__pixels = false |
2035 | | - else throw new Error('size_units must be "pixels" (the default) or "world".') |
2036 | | - delete obj.size_units |
2037 | | - } |
2038 | | - for (var a in obj) { // include user variables |
2039 | | - if (a === 'pos') continue |
2040 | | - this[a] = obj[a] |
2041 | | - delete obj[a] |
2042 | | - } |
| 2031 | + if (args.size_units !== undefined) { |
| 2032 | + if (args.size_units == 'pixels') this.__pixels = true |
| 2033 | + else if (args.size_units == 'world') this.__pixels = false |
| 2034 | + else throw new Error('size_units must be "pixels" (the default) or "world".') |
| 2035 | + delete args.size_units |
2043 | 2036 | } |
2044 | | - var temp = this.__setup(args) // returns [pos, specs]; specs irrelevant in constructor |
| 2037 | + for (var a in args) { // include user variables |
| 2038 | + if (a === 'pos') continue |
| 2039 | + this[a] = args[a] |
| 2040 | + delete args[a] |
| 2041 | + } |
| 2042 | + var temp = this.__setup([args]) // returns [pos, specs]; specs irrelevant in constructor |
2045 | 2043 | pos = temp[0] |
2046 | 2044 | if (pos.length > 0) this.__push_and_append(pos, {}) |
2047 | 2045 | this.canvas.__points_objects.push(this) |
|
0 commit comments