Skip to content

Commit b05132c

Browse files
committed
improved group
1 parent ada635c commit b05132c

6 files changed

Lines changed: 17 additions & 10 deletions

File tree

‎ForInstalledPython/glow.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎GlowScriptOffline/glowscript_libraries/glow.3.2.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎GlowScriptOffline3.2.zip‎

45 Bytes
Binary file not shown.

‎lib/glow/primitives.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@
751751
subclass(group, box)
752752
group.prototype.__hasPosAtCenter = true
753753
group.prototype.__objects = []
754+
group.prototype.__size
754755
property.declare( group.prototype, {
755756
objects: {
756757
get: function() { return this.__objects },
@@ -793,7 +794,7 @@
793794
axis_changed: function(oldaxis, newaxis){ // called from vectors.js
794795
let ax = cross(oldaxis, newaxis)
795796
let ang = diff_angle(oldaxis, newaxis)
796-
this.rotate({angle:ang, axis:ax})
797+
this.rotate({angle:ang, axis:ax, oldaxis:oldaxis, newaxis:newaxis})
797798
},
798799
rotate: function(args) {
799800
let ang = args.angle
@@ -805,10 +806,17 @@
805806
for (let c=0; c<this.__objects.length; c++) {
806807
let obj = this.__objects[c]
807808
obj.pos = this.group_to_world(obj.__pos)
808-
obj.rotate({angle:ang, axis:ax, origin:org})
809+
obj.rotate({angle:ang, axis:ax, origin:org}) // call regular rotate function
809810
obj.pos = this.world_to_group(obj.__pos)
810811
obj.__change()
811812
}
813+
if (args.oldaxis === undefined) { // rotate not called from axis_changed
814+
let v = rotate(this.__axis, {angle:ang, axis:ax})
815+
this.__axis = v
816+
v = rotate(this.__up, {angle:ang, axis:ax})
817+
this.__up = v
818+
}
819+
812820
},
813821
group_to_world: function(v) {
814822
return v.add(this.__pos)

‎lib/glow/vectors.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515

1616
function adjust_up(parent, oldaxis, newaxis) { // adjust up when axis is changed
1717
parent.__change()
18-
if (typeof group !== 'undefined' && parent instanceof group) {
19-
parent.axis_changed(oldaxis, newaxis)
20-
return
21-
}
2218
if (newaxis.mag2 === 0) {
2319
// If axis has changed to <0,0,0>, must save the old axis to restore later
2420
if (parent.__oldaxis === undefined) parent.__oldaxis = oldaxis
@@ -44,6 +40,9 @@
4440
parent.__up.__y = newup.y
4541
parent.__up.__z = newup.z
4642
}
43+
if (typeof group !== 'undefined' && parent instanceof group) {
44+
parent.axis_changed(oldaxis, newaxis)
45+
}
4746
}
4847

4948
function adjust_axis(parent, oldup, newup) { // adjust axis when up is changed
@@ -788,4 +787,4 @@
788787
__array_times_number: __array_times_number
789788
}
790789
Export(exports)
791-
})();
790+
})();

‎package/glow.3.2.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)