function SPRING.new(H,o,f,Z,m)local L={Target=Vector3.new(),Position=Vector3.new(),Velocity=Vector3.new();Mass=o or 5;Force=f or 50;Damping=Z or 4;Speed=m or 4}function L.getstats(H)return H.Mass,H.Force,H.Damping,H.Speed end function L.changestats(H,o,f,Z,m)H.Mass=o or H.Mass H.Force=f or H.Force H.Damping=Z or H.Damping H.Speed=m or H.Speed end function L.shove(H,o)local f,Z,m=o.X,o.Y,o.Z if f~=f or f==math.huge or f==-math.huge then f=0 end if Z~=Z or Z==math.huge or Z==-math.huge then Z=0 end if m~=m or m==math.huge or m==-math.huge then m=0 end H.Velocity=H.Velocity+Vector3.new(f,Z,m)end function L.update(H,o)local f=(o*H.Speed)/ITERATIONS for o=1,ITERATIONS,1 do local Z=H.Target-H.Position local m=(Z*H.Force)/H.Mass m=m-H.Velocity*H.Damping H.Velocity=H.Velocity+m*f H.Position=H.Position+H.Velocity*f end return H.Position end return L end
-- Functions

function SPRING.new(self, mass, force, damping, speed)
	local spring = {
		Target = Vector3.new(),
		Position = Vector3.new(),
		Velocity = Vector3.new(),

		Mass = mass or 5,
		Force = force or 50,
		Damping = damping or 4,
		Speed = speed or 4,
	}

	function spring.getstats(self)
		return self.Mass, self.Force, self.Damping, self.Speed
	end

	function spring.changestats(self, mass, force, damping, speed)
		self.Mass = mass or self.Mass
		self.Force = force or self.Force
		self.Damping = damping or self.Damping
		self.Speed = speed or self.Speed
	end

	function spring.shove(self, force)
		local x, y, z = force.X, force.Y, force.Z
		if x ~= x or x == math.huge or x == -math.huge then
			x = 0
		end
		if y ~= y or y == math.huge or y == -math.huge then
			y = 0
		end
		if z ~= z or z == math.huge or z == -math.huge then
			z = 0
		end
		self.Velocity = self.Velocity + Vector3.new(x, y, z)
	end

	function spring.update(self, dt)
		local scaledDeltaTime = dt * self.Speed / ITERATIONS
		for i = 1, ITERATIONS do
			local iterationForce = self.Target - self.Position
			local acceleration = (iterationForce * self.Force) / self.Mass

			acceleration = acceleration - self.Velocity * self.Damping

			self.Velocity = self.Velocity + acceleration * scaledDeltaTime
			self.Position = self.Position + self.Velocity * scaledDeltaTime
		end

		return self.Position
	end

	return spring
end
