Skip to content
Permalink
Browse files

Trying to work around Chrome’s stricter Matrix handling

  • Loading branch information...
nvh committed May 15, 2018
1 parent c0cad18 commit ffd0a4db808a866cb75cdfc3cf42b0282e6aea18
Showing with 11 additions and 6 deletions.
  1. +4 −4 framer/Layer.coffee
  2. +4 −0 framer/Matrix.coffee
  3. +3 −2 framer/Utils.coffee
@@ -447,7 +447,7 @@ class exports.Layer extends BaseClass
get: ->
if @force2d
return @_matrix2d
return new Matrix()
return Matrix.identity3d()
.translate(@x, @y, @z)
.scale(@scale)
.scale(@scaleX, @scaleY, @scaleZ)
@@ -463,7 +463,7 @@ class exports.Layer extends BaseClass
# matrix of layer transforms when 2d is forced
@define "_matrix2d",
get: ->
return new Matrix()
return Matrix.identity3d()
.translate(@x, @y)
.scale(@scale)
.scale(@scaleX, @scaleY)
@@ -474,7 +474,7 @@ class exports.Layer extends BaseClass
# matrix of layer transforms with transform origin applied
@define "transformMatrix",
get: ->
return new Matrix()
return Matrix.identity3d()
.translate(@originX * @width, @originY * @height)
.multiply(@matrix)
.translate(-@originX * @width, -@originY * @height)
@@ -484,7 +484,7 @@ class exports.Layer extends BaseClass
get: ->
parent = @parent or @context
ppm = Utils.perspectiveMatrix(parent)
return new Matrix()
return Matrix.identity3d()
.multiply(ppm)
.multiply(@transformMatrix)

@@ -16,4 +16,8 @@ WebKitCSSMatrix::point = (point = {}) ->
y: (@m12 * x + @m22 * y + @m32 * z + @m42) / w
z: (@m13 * x + @m23 * y + @m33 * z + @m43) / w


WebKitCSSMatrix.identity3d = ->
return new WebKitCSSMatrix("matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)")

exports.Matrix = WebKitCSSMatrix
@@ -1325,7 +1325,8 @@ Utils.boundingFrame = (layer, rootContext=true) ->

Utils.perspectiveProjectionMatrix = (element) ->
p = element.perspective
m = new Matrix()

m = Matrix.identity3d()
m.m34 = -1 / p if p? and p isnt 0
return m

@@ -1334,7 +1335,7 @@ Utils.perspectiveMatrix = (element) ->
ox = element.perspectiveOriginX * element.width
oy = element.perspectiveOriginY * element.height
ppm = Utils.perspectiveProjectionMatrix(element)
return new Matrix()
return Matrix.identity3d()
.translate(ox, oy)
.multiply(ppm)
.translate(-ox, -oy)

0 comments on commit ffd0a4d

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.