|
114 | 114 | obj.__trail_color = args.trail_color |
115 | 115 | delete args.trail_color |
116 | 116 | } |
117 | | - obj.__trail_radius = 0.1*obj.__size.y // the default for attach_trail |
| 117 | + obj.__trail_radius = 0 //0.1*obj.__size.y // the default for attach_trail |
118 | 118 | if (args.trail_radius !== undefined) { |
119 | 119 | obj.__trail_radius = args.trail_radius |
120 | 120 | delete args.trail_radius |
| 121 | + } else { |
| 122 | + if (obj.__trail_type == 'points') obj.__trail_radius = 0.1*obj.__size.y |
121 | 123 | } |
122 | 124 | obj.__pps = 0 |
123 | 125 | if (args.pps !== undefined) { |
|
2403 | 2405 | if (options.canvas !== undefined) this.canvas = options.canvas |
2404 | 2406 | else this.canvas = canvas.selected |
2405 | 2407 | var radius = 0 |
| 2408 | + if (options.type === undefined) { |
| 2409 | + this.type = 'curve' |
| 2410 | + } else { |
| 2411 | + switch (options.type) { |
| 2412 | + case 'curve': |
| 2413 | + this.type = options.type |
| 2414 | + break |
| 2415 | + case 'spheres': // JavaScript name |
| 2416 | + case 'points': // VPython name |
| 2417 | + this.type = "points" |
| 2418 | + this.__options['size_units'] = "world" // make default size units same as those of curve |
| 2419 | + break |
| 2420 | + default: |
| 2421 | + throw new Error("attach_trail type must be 'curve' or 'points' (or 'spheres')") |
| 2422 | + } |
| 2423 | + } |
2406 | 2424 | if (typeof objectOrFunction !== "function" && typeof objectOrFunction !== "string") { // an object |
2407 | 2425 | this.canvas = objectOrFunction.canvas |
2408 | 2426 | this.__options['color'] = objectOrFunction.color |
2409 | | - if (options.radius === undefined) radius = 0.1*objectOrFunction.size.y |
2410 | | - else radius = options.radius |
| 2427 | + if (options.radius === undefined) { |
| 2428 | + if (this.type == 'points') radius = 0.1*objectOrFunction.size.y |
| 2429 | + } else radius = options.radius |
2411 | 2430 | } else { |
2412 | 2431 | if (options.radius !== undefined) radius = options.radius |
2413 | 2432 | } |
|
2425 | 2444 | this.pps = options.pps |
2426 | 2445 | } |
2427 | 2446 | this.__options['pickable'] = false |
2428 | | - if (options.type === undefined) { |
2429 | | - this.type = 'curve' |
2430 | | - } else { |
2431 | | - switch (options.type) { |
2432 | | - case 'curve': |
2433 | | - this.type = options.type |
2434 | | - break |
2435 | | - case 'spheres': // JavaScript name |
2436 | | - case 'points': // VPython name |
2437 | | - this.type = "points" |
2438 | | - this.__options['size_units'] = "world" // make default size units same as those of curve |
2439 | | - break |
2440 | | - default: |
2441 | | - throw new Error("attach_trail type must be 'curve' or 'points' (or 'spheres')") |
2442 | | - } |
2443 | | - } |
2444 | 2447 | var send = {} // send a copy to curve or points, to prevent overwrite of this.__options |
2445 | 2448 | for (var a in this.__options) send[a] = this.__options[a] |
2446 | 2449 | if (this.type == 'curve') this.__trail = curve(send) |
|
0 commit comments