jhs powerbar 3d rotate error fix
def onLButtonDown(flags, x, y, view)
nothing with this click if nothing is selected
puts 'nil' if(Sketchup.active_model.selection.length == 0)
Keep what's currently selected.
Might be temporarily selected because its hovered if there was no selection when tool was selected
@hasSelection = true
Select point when and draw when clicking
first 3 clicks select points and set jaw & pitch. 4th and 5th click are optional and sets roll
if @state == 0
# Select anchorpoint
#@pAnchor.pick view, x, y
if @pAnchor.valid?
@state = 1
@status_text = "Grab entity." # first status text defined in reset()
Sketchup::set_status_text(@status_text, SB_PROMPT)
end
elsif @state == 1
# Select startpoint 1
#@pStart1.pick view, x, y, @pAnchor
if @pStart1.valid?
@state = 2
@status_text = "Pick target to drag entity towards."
Sketchup::set_status_text(@status_text, SB_PROMPT)
end
elsif @state == 2
# Select targetpoint 1 and set yaw and pitch for selection
#@pTarget1.pick view, x, y, @pAnchor
if @pTarget1.valid?
@state = 3
@status_text = "(Optional) Grab entity again."
Sketchup::set_status_text(@status_text, SB_PROMPT)
self.rotateYawPitch(@pAnchor.position, @pStart1.position, @pTarget1.position)
# Set rotated flag so script knows whether to update view or not when leaving tool
@rotated = true
end
elsif @state == 3
# Select startpoint 2
#@pStart2.pick view, x, y, @pAnchor
if @pStart2.valid?
@state = 4
@status_text = "Pick target to drag entity towards."
Sketchup::set_status_text(@status_text, SB_PROMPT)
end
elsif @state == 4
# Select targetpoint 2 and set roll for selection
#@pTarget2.pick view, x, y, @pAnchor
if @pTarget2.valid?
self.rotateRoll(@pAnchor.position, @pStart2.position, @pTarget2.position, (@pTarget1.position - @pAnchor.position))
self.reset(view)
end
end
end#def