Skip to content

Instantly share code, notes, and snippets.



Created Nov 26, 2019
What would you like to do?
function love.draw()
local canvas, x, y, width, height, rotation, scaleX, scaleY, offsetX, offsetY = Scene:getRender(), x, y, width, height, rotation, scaleX, scaleY, offsetX, offsetY)
scene.getRender = function (self, drawArg),1,1){self.threeCanvas, depth=true}),0,0,0)
-- compile camera data into usable view to send to threeShader
local Camera =
local camTransform = cpml.mat4()
camTransform:rotate(camTransform, Camera.angle.y, cpml.vec3.unit_x)
camTransform:rotate(camTransform, Camera.angle.x, cpml.vec3.unit_y)
camTransform:rotate(camTransform, Camera.angle.z, cpml.vec3.unit_z)
camTransform:translate(camTransform, Camera.pos*-1)
self.threeShader:send("view", Camera.perspective * TransposeMatrix(camTransform))
self.threeShader:send("ambientLight", self.ambientLight)
self.threeShader:send("ambientVector", self.ambientVector)
-- go through all models in modelList and draw them
for i=1, #self.modelList do
local model = self.modelList[i]
if model ~= nil and model.visible and #model.verts > 0 then
self.threeShader:send("model_matrix", model.transform)
self.threeShader:send("model_matrix_inverse", TransposeMatrix(InvertMatrix(model.transform)))
if model.culling then"back")
end, -self.renderWidth/2, -self.renderHeight/2)"none")
if drawArg == nil or drawArg == true then
return self.threeCanvas, self.renderWidth/2, self.renderHeight/2, 0, 1,-1, self.renderWidth/2, self.renderHeight/2, self.renderWidth/2,self.renderHeight/2, 0, 1,-1, self.renderWidth/2, self.renderHeight/2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment