Пример #1
0
func (rv *RoomViewer) Drag(dx, dy float64) {
	v := mathgl.Vec3{X: rv.fx, Y: rv.fy}
	vx := mathgl.Vec3{1, -1, 0}
	vx.Normalize()
	vy := mathgl.Vec3{1, 1, 0}
	vy.Normalize()
	vx.Scale(float32(dx) / rv.zoom * 2)
	vy.Scale(float32(dy) / rv.zoom * 2)
	v.Add(&vx)
	v.Add(&vy)
	rv.fx, rv.fy = v.X, v.Y
	rv.makeMat()
}
Пример #2
0
func (hv *HouseViewer) Drag(dx, dy float64) {
	v := mathgl.Vec3{X: hv.fx, Y: hv.fy}
	vx := mathgl.Vec3{1, -1, 0}
	vx.Normalize()
	vy := mathgl.Vec3{1, 1, 0}
	vy.Normalize()
	vx.Scale(float32(dx) / hv.zoom * 2)
	vy.Scale(float32(dy) / hv.zoom * 2)
	v.Add(&vx)
	v.Add(&vy)
	if hv.bounds.on {
		hv.fx = clamp(v.X, hv.bounds.min.x, hv.bounds.max.x)
		hv.fy = clamp(v.Y, hv.bounds.min.y, hv.bounds.max.y)
	} else {
		hv.fx, hv.fy = v.X, v.Y
	}
	hv.target_on = false
}