|
470 | 470 | __show_start_face:this.__show_start_face, __show_end_face:this.__show_end_face,
|
471 | 471 | __start_face_color:this.__start_face_color, __end_face_color:this.__end_face_color,
|
472 | 472 | __descender:this.__descender, __shininess:this.__shininess, __emissive:this.__emissive,
|
473 |
| - __pickable:this.__pickable} |
| 473 | + visible:true, __pickable:this.__pickable} |
474 | 474 | var newtext = new text(newargs)
|
475 | 475 | for (var attr in args) newtext[attr] = args[attr] // apply the args attributes to the clone
|
476 | 476 | newtext.__update()
|
477 | 477 | return newtext
|
478 | 478 | } else if (this instanceof curve) {
|
479 |
| - var newargs = {origin:this.__origin, pos:this.pos, color:this.__color, radius:this.__radius, |
480 |
| - size:this.__size, axis:this.__axis, |
481 |
| - shininess:this.__shininess, emissive:this.__emissive, |
482 |
| - visible:true, pickable:this.__pickable} |
| 479 | + var newargs = {__origin:this.__origin, __pos:this.pos, __color:this.__color, |
| 480 | + __radius:this.__radius, __size:this.__size, __axis:this.__axis, |
| 481 | + __shininess:this.__shininess, __emissive:this.__emissive, |
| 482 | + visible:true, __pickable:this.__pickable} |
483 | 483 | } else if (this instanceof helix) {
|
484 |
| - var newargs = {pos:this.pos, color:this.__color, |
485 |
| - thickness:this.__thickness, coils:this.__coils, |
486 |
| - size:this.__size, axis:this.__axis, |
487 |
| - shininess:this.__shininess, emissive:this.__emissive, |
488 |
| - visible:true, pickable:this.__pickable} |
| 484 | + var newargs = {__pos:this.pos, __color:this.__color, |
| 485 | + __thickness:this.__thickness, __coils:this.__coils, |
| 486 | + __size:this.__size, __axis:this.__axis, |
| 487 | + __shininess:this.__shininess, __emissive:this.__emissive, |
| 488 | + visible:true, __pickable:this.__pickable} |
489 | 489 | } else {
|
490 |
| - var newargs = {pos:this.__pos, color:this.__color, opacity:this.__opacity, |
491 |
| - size:this.__size, axis:this.__axis, __tex:this.__tex, |
492 |
| - shininess:this.__shininess, emissive:this.__emissive, |
493 |
| - visible:true, pickable:this.__pickable} |
| 490 | + var newargs = {__pos:this.__pos, __color:this.__color, __opacity:this.__opacity, |
| 491 | + __size:this.__size, __axis:this.__axis, __tex:this.__tex, __up:this.__up, |
| 492 | + __shininess:this.__shininess, __emissive:this.__emissive, |
| 493 | + visible:true, __pickable:this.__pickable} |
494 | 494 | if (this instanceof arrow || this instanceof vp_arrow) {
|
495 | 495 | newargs.shaftwidth = this.__shaftwidth
|
496 | 496 | newargs.headwidth = this.__headwidth
|
497 | 497 | newargs.headlength = this.__headlength
|
498 | 498 | }
|
499 | 499 | }
|
500 |
| - var ret = new this.constructor(newargs) // newargs does NOT contain newargs.up, to avoid up affecting axis in constructor |
501 |
| - for (var attr in args) ret[attr] = args[attr] // includes setting up |
| 500 | + // The newargs are in terms of __attr to avoid axis/up/size interconnections |
| 501 | + var ret = new this.constructor(newargs) |
| 502 | + for (var attr in args) ret[attr] = args[attr] // apply the args attributes to the clone |
502 | 503 | return ret
|
503 | 504 | },
|
504 | 505 | __change: function() { if (this.__id) this.canvas.__changed[this.__id] = this },
|
|
547 | 548 | // But when rotating an object, we must break this linkage and rotate both axis and up in the same way.
|
548 | 549 | // The global variable window.__adjustupaxis is normally true, but here we set it temporarilty to false.
|
549 | 550 | // The object axis and up attributes in vectors.js check this global variable.
|
| 551 | + // (Another way to deal with this would be to set __axis and __up, and then call __update.) |
550 | 552 | window.__adjustupaxis = false // unlink axis and up temporarily
|
551 | 553 | if (diff_angle(obj.__axis,rotaxis) > 1e-6) {
|
552 | 554 | // change axis, which will also change up
|
553 | 555 | if (isarrow) obj.axis_and_length = obj.axis_and_length.rotate({angle:angle, axis:rotaxis})
|
554 | 556 | else obj.axis = obj.__axis.rotate({angle:angle, axis:rotaxis}) // maintain special character of VPython axis
|
555 |
| - obj.up = obj.up.rotate({angle:angle, axis:rotaxis}) |
| 557 | + obj.up = obj.__up.rotate({angle:angle, axis:rotaxis}) |
556 | 558 | } else {
|
557 | 559 | obj.up = obj.__up.rotate({angle:angle, axis:rotaxis})
|
558 | 560 | }
|
|
1441 | 1443 | subclass(compound, box)
|
1442 | 1444 | property.declare( compound.prototype, {
|
1443 | 1445 | clone: function(args) { // cloning a compound object
|
1444 |
| - var newargs = {pos:this.__pos, color:this.__color, opacity:this.__opacity, |
1445 |
| - size:this.__size, axis:this.__axis, up:this.__up, |
1446 |
| - shininess:this.__shininess, emissive:this.__emissive, |
1447 |
| - visible:true, pickable:this.__pickable, |
| 1446 | + var newargs = {__pos:this.__pos, __color:this.__color, __opacity:this.__opacity, |
| 1447 | + __size:this.__size, __axis:this.__axis, __up:this.__up, |
| 1448 | + __shininess:this.__shininess, __emissive:this.__emissive, |
| 1449 | + visible:true, __pickable:this.__pickable, |
1448 | 1450 | __center:this.__center, __pseudosize:this.__pseudosize}
|
1449 | 1451 | if (this.texture.file !== null) newargs.texture = this.texture
|
1450 |
| - for (var attr in args) newargs[attr] = args[attr] |
| 1452 | + // The newargs are in terms of __attr to avoid axis/up/size interconnections |
1451 | 1453 | newargs.__cloning = this.__mesh
|
1452 |
| - return new this.constructor([], newargs) |
| 1454 | + var ret = new this.constructor([], newargs) |
| 1455 | + for (var attr in args) ret[attr] = args[attr] // apply the args attributes to the clone |
| 1456 | + return ret |
1453 | 1457 | },
|
1454 | 1458 | _world_zaxis: function() {
|
1455 | 1459 | return this.__axis.cross(this.__up).norm()
|
|
0 commit comments