Advertisement
Mijyuoon

CEF shit #2

Aug 13th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. this.WebSize = 0.195
  2.  
  3. hook.Add("PostDrawOpaqueRenderables", this,
  4. function(self)
  5.     if not self.WebId then return end
  6.     if not IsValid(CHROME) then return end
  7.    
  8.     local web = CHROME.Web[self.WebId]
  9.     local scale = self.WebSize or 0.1
  10.        
  11.     local pos = self:GetPos() + self:GetUp() * 2.0
  12.     local angle = self:GetAngles()
  13.     angle:RotateAroundAxis(self:GetUp(), 90)
  14.    
  15.     cam.Start3D2D(pos, angle, scale)
  16.         local mat = web:GetHTMLMaterial()
  17.         local sw, sh = ScrW(), ScrH()
  18.         local swc, shc = scr.MatSize(mat)
  19.         scr.DrawTexRect(-sw/2, -sh/2, swc, shc, mat)
  20.     cam.End3D2D()
  21. end)
  22.  
  23. this.WebVol = { 1500, 0.8 }
  24.  
  25. hook.Add("Think", this,
  26. function(self)
  27.     if not self.WebId then return end
  28.     if not IsValid(CHROME) then return end
  29.    
  30.     local web = CHROME.Web[self.WebId]
  31.    
  32.     local volume = 0
  33.     if self.WebVol then
  34.         local falloff, maximum = unpack(self.WebVol)
  35.         local dist = self:GetPos():Distance(LocalPlayer():GetPos())
  36.         volume = maximum * (1 - math.Clamp(dist / falloff, 0, 1)^2)
  37.     end
  38.    
  39.     web:CallFunc("Volume", volume)
  40. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement