Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix float issues for CairoMakie by using Float64 #2573

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0d86adc
prototype scatter in scene
ffreyer Jan 8, 2023
1f90715
get axis working
ffreyer Jan 8, 2023
b24313c
fix autolimits
ffreyer Jan 8, 2023
13ce741
get mesh working?
ffreyer Jan 8, 2023
1069754
fix compilation
ffreyer Jan 8, 2023
d561a3e
get heatmap & image going
ffreyer Jan 8, 2023
d756561
get meshscatter working
ffreyer Jan 8, 2023
23e7cd1
fix compilation
ffreyer Jan 8, 2023
feca2c7
get Axis3 going
ffreyer Jan 8, 2023
230e8ec
get surface going
ffreyer Jan 8, 2023
77998bc
fixes
ffreyer Jan 8, 2023
9d8e919
get GLMakie working again
ffreyer Jan 8, 2023
d7e2306
fix GLMakie tests
ffreyer Jan 8, 2023
1084f4a
fix CairoMakie tests
ffreyer Jan 8, 2023
ee1022b
remove duplicate convert?
ffreyer Jan 8, 2023
48d9b97
get WGLMakie working
ffreyer Jan 10, 2023
5811c01
Merge branch 'master' into ff/Float64
ffreyer Jan 10, 2023
c2f0109
cleanup prints
ffreyer Jan 10, 2023
cbf702c
add BBox64
ffreyer Jan 10, 2023
dbccd69
move GeometryBasics changes to Makie
ffreyer Jan 10, 2023
d7f5693
fix mesh conversion
ffreyer Jan 10, 2023
e955f31
fix more mesh conversion problems
ffreyer Jan 10, 2023
7cb6aac
fix Makie tests
ffreyer Jan 10, 2023
a3b925f
fix BBox type
ffreyer Jan 12, 2023
c0e2db9
fix ssao
ffreyer Jan 12, 2023
05ee945
stricter Float64 typing
ffreyer Jan 12, 2023
4e1afcb
fix example
ffreyer Jan 12, 2023
53c8e21
use map! instead of onany
ffreyer Jan 12, 2023
33251b0
fix test failure
ffreyer Jan 12, 2023
74b689b
skip initialization update of converted_node
ffreyer Jan 14, 2023
07c411d
fix ecdf conversions
ffreyer Jan 14, 2023
9814af5
Merge branch 'master' into ff/Float64
ffreyer Jan 25, 2023
3fbd6ab
add NEWS entry
ffreyer Jan 25, 2023
a35a108
add test for "range step cannot be zero"
ffreyer Jan 25, 2023
523a514
fix rectzoom error
ffreyer Jan 25, 2023
b1a71a6
Fully convert cameras to Float64
ffreyer Jan 25, 2023
69295e2
Merge branch 'master' into ff/Float64
asinghvi17 Feb 6, 2023
327b574
Merge branch 'master' into ff/Float64
ffreyer Mar 3, 2023
75b600e
fix axis interactions
ffreyer Mar 3, 2023
16b0204
Merge branch 'master' into ff/Float64
ffreyer Mar 28, 2023
f0fbfac
back to Float64 meshes
ffreyer Mar 28, 2023
2c22614
broaden bbox type
ffreyer Mar 28, 2023
26c4dbc
less Float64 conversions
ffreyer Mar 29, 2023
b14fc0c
Merge branch 'master' into ff/Float64
ffreyer Apr 12, 2023
c021cfd
allow Float32 and Float64
ffreyer May 1, 2023
8ade215
cleanup
ffreyer May 1, 2023
e5807b1
Merge branch 'master' into ff/Float64
ffreyer May 1, 2023
75583e9
fix WGLMakie
ffreyer May 1, 2023
d859984
loosen some types [skip ci]
ffreyer May 1, 2023
36e08f6
Merge branch 'master' into ff/Float64
ffreyer Jun 4, 2023
2ada40e
allow empty inputs
ffreyer Jun 4, 2023
bada567
remove file from clipping pr
ffreyer Jun 4, 2023
ad056b3
remove unused `concrete_type`
ffreyer Jun 6, 2023
e49b2ad
drop intermediate functions, use Float64, use map
ffreyer Jun 6, 2023
84cdab5
generalize float type & minor reorganization
ffreyer Jun 6, 2023
a1cfa62
keep float (element) type through plot! and conversions
ffreyer Jun 7, 2023
c2daeaf
fix test failures
ffreyer Jun 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions CairoMakie/src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Unio
ctx = screen.context
image = primitive[3][]
xs, ys = primitive[1][], primitive[2][]

if !(xs isa AbstractVector)
l, r = extrema(xs)
N = size(image, 1)
Expand Down Expand Up @@ -584,8 +585,8 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Unio
# find projected image corners
# this already takes care of flipping the image to correct cairo orientation
space = to_value(get(primitive, :space, :data))
xy = project_position(scene, space, Point2f(first.(imsize)), model)
xymax = project_position(scene, space, Point2f(last.(imsize)), model)
xy = project_position(scene, space, Point2{Float64}(first.(imsize)), model)
xymax = project_position(scene, space, Point2{Float64}(last.(imsize)), model)
w, h = xymax .- xy

can_use_fast_path = !(is_vector && !interpolate) && regular_grid && identity_transform
Expand Down Expand Up @@ -682,7 +683,7 @@ end
function draw_mesh2D(scene, screen, @nospecialize(plot), @nospecialize(mesh))
@get_attribute(plot, (color,))
color = to_color(hasproperty(mesh, :color) ? mesh.color : color)
vs = decompose(Point2f, mesh)::Vector{Point2f}
vs = decompose(Point2{Float64}, mesh)::Vector{Point2{Float64}}
fs = decompose(GLTriangleFace, mesh)::Vector{GLTriangleFace}
uv = decompose_uv(mesh)::Union{Nothing, Vector{Vec2f}}
model = plot.model[]::Mat4f
Expand All @@ -702,7 +703,7 @@ function draw_mesh2D(scene, screen, @nospecialize(plot), @nospecialize(mesh))
end

function draw_mesh2D(scene, screen, per_face_cols, space::Symbol,
vs::Vector{Point2f}, fs::Vector{GLTriangleFace}, model::Mat4f)
vs::Vector{Point2{Float64}}, fs::Vector{GLTriangleFace}, model::Mat4f)

ctx = screen.context
# Priorize colors of the mesh if present
Expand Down Expand Up @@ -747,7 +748,7 @@ function draw_mesh3D(scene, screen, attributes, mesh; pos = Vec4f(0), scale = 1f
matcap = to_value(get(attributes, :matcap, nothing))

color = hasproperty(mesh, :color) ? mesh.color : color
meshpoints = decompose(Point3f, mesh)::Vector{Point3f}
meshpoints = decompose(Point3{Float64}, mesh)::Vector{Point3{Float64}}
meshfaces = decompose(GLTriangleFace, mesh)::Vector{GLTriangleFace}
meshnormals = decompose_normals(mesh)::Vector{Vec3f}
meshuvs = texturecoordinates(mesh)::Union{Nothing, Vector{Vec2f}}
Expand Down Expand Up @@ -793,8 +794,8 @@ function draw_mesh3D(
vs = broadcast(meshpoints, (func,)) do v, f
# Should v get a nan2zero?
v = Makie.apply_transform(f, v, space)
p4d = to_ndim(Vec4f, scale .* to_ndim(Vec3f, v, 0f0), 1f0)
view * (model * p4d .+ to_ndim(Vec4f, pos, 0f0))
p4d = to_ndim(Vec4{Float64}, scale .* to_ndim(Vec3{Float64}, v, 0.0), 1.0)
view * (model * p4d .+ to_ndim(Vec4{Float64}, pos, 0.0))
end

ns = map(n -> normalize(normalmatrix * n), meshnormals)
Expand Down
8 changes: 4 additions & 4 deletions CairoMakie/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ end

function _project_position(scene, space, point, model, yflip)
res = scene.camera.resolution[]
p4d = to_ndim(Vec4f, to_ndim(Vec3f, point, 0f0), 1f0)
clip = Makie.space_to_clip(scene.camera, space) * model * p4d
p4d = to_ndim(Vec4{Float64}, to_ndim(Vec3{Float64}, point, 0.0), 1.0)
clip = Mat4{Float64}(Makie.space_to_clip(scene.camera, space)) * Mat4{Float64}(model) * p4d
@inbounds begin
# between -1 and 1
p = (clip ./ clip[4])[Vec(1, 2)]
# flip y to match cairo
p_yflip = Vec2f(p[1], (1f0 - 2f0 * yflip) * p[2])
p_yflip = Vec2{Float64}(p[1], (1.0 - 2.0 * yflip) * p[2])
# normalize to between 0 and 1
p_0_to_1 = (p_yflip .+ 1f0) ./ 2f0
p_0_to_1 = (p_yflip .+ 1.0) ./ 2.0
end
# multiply with scene resolution for final position
return p_0_to_1 .* res
Expand Down
4 changes: 2 additions & 2 deletions GLMakie/src/GLAbstraction/GLUniforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ opengl_postfix(T) = error("Object $T is not a supported uniform element type")


opengl_prefix(x::Type{T}) where {T <: Union{FixedPoint, Float32, Float16}} = ""
opengl_prefix(x::Type{T}) where {T <: Float64} = "d"
opengl_prefix(x::Type{T}) where {T <: Float64} = error("Float64") # "d"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
opengl_prefix(x::Type{T}) where {T <: Float64} = error("Float64") # "d"
opengl_prefix(x::Type{T}) where {T <: Float64} = error("Float64 encountered in GLMakie internals!") # "d"

opengl_prefix(x::Type{Cint}) = "i"
opengl_prefix(x::Type{T}) where {T <: Union{Cuint, UInt8, UInt16}} = "u"

opengl_postfix(x::Type{Float64}) = "dv"
opengl_postfix(x::Type{Float64}) = error("Float64") # "dv"
Copy link
Member

@asinghvi17 asinghvi17 Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
opengl_postfix(x::Type{Float64}) = error("Float64") # "dv"
opengl_postfix(x::Type{Float64}) = error("Float64 encountered in GLMakie internals!") # "dv"

opengl_postfix(x::Type{Float32}) = "fv"
opengl_postfix(x::Type{Cint}) = "iv"
opengl_postfix(x::Type{Cuint}) = "uiv"
Expand Down
37 changes: 17 additions & 20 deletions GLMakie/src/drawing_primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,29 @@ end
function connect_camera!(gl_attributes, cam, space = gl_attributes[:space])
for key in (:pixel_space, :resolution, :eyeposition)
# Overwrite these, user defined attributes shouldn't use those!
gl_attributes[key] = copy(getfield(cam, key))
gl_attributes[key] = getfield(cam, key)
end
get!(gl_attributes, :view) do
return lift(cam.view, space) do view, space
return is_data_space(space) ? view : Mat4f(I)
return is_data_space(space) ? Mat4f(view) : Mat4f(I)
end
end
get!(gl_attributes, :normalmatrix) do
return lift(gl_attributes[:view], gl_attributes[:model]) do v, m
i = Vec(1, 2, 3)
return transpose(inv(v[i, i] * m[i, i]))
return transpose(inv(Mat3f(v[i, i]) * Mat3f(m[i, i])))
end
end

get!(gl_attributes, :projection) do
return lift(cam.projection, cam.pixel_space, space) do _, _, space
return Makie.space_to_clip(cam, space, false)
return Mat4f(Makie.space_to_clip(cam, space, false))
end
end

get!(gl_attributes, :projectionview) do
return lift(cam.projectionview, cam.pixel_space, space) do _, _, space
Makie.space_to_clip(cam, space, true)
Mat4f(Makie.space_to_clip(cam, space, true))
end
end

Expand Down Expand Up @@ -203,12 +203,13 @@ function draw_atomic(screen::Screen, scene::Scene, @nospecialize(x::Union{Scatte
space = get(gl_attributes, :space, :data) # needs to happen before connect_camera! call
positions = handle_view(x[1], gl_attributes)
positions = apply_transform(transform_func_obs(x), positions, space)
positions = map(el32convert, positions)

if isa(x, Scatter)
mspace = get(gl_attributes, :markerspace, :pixel)
cam = scene.camera
gl_attributes[:preprojection] = map(space, mspace, cam.projectionview, cam.resolution) do space, mspace, _, _
return Makie.clip_to_space(cam, mspace) * Makie.space_to_clip(cam, space)
return Mat4f(Makie.clip_to_space(cam, mspace) * Makie.space_to_clip(cam, space))
end
# fast pixel does its own setup
if !(marker[] isa FastPixel)
Expand Down Expand Up @@ -274,6 +275,7 @@ function draw_atomic(screen::Screen, scene::Scene, @nospecialize(x::Lines))
space = get(gl_attributes, :space, :data) # needs to happen before connect_camera! call
positions = handle_view(x[1], data)
positions = apply_transform(transform_func_obs(x), positions, space)
positions = map(el32convert, positions)
handle_intensities!(data)
connect_camera!(data, scene.camera)
return draw_lines(screen, positions, data)
Expand All @@ -294,6 +296,7 @@ function draw_atomic(screen::Screen, scene::Scene, @nospecialize(x::LineSegments
space = get(gl_attributes, :space, :data) # needs to happen before connect_camera! call
positions = handle_view(x.converted[1], data)
positions = apply_transform(transform_func_obs(x), positions, space)
positions = map(el32convert, positions)
if haskey(data, :color) && data[:color][] isa AbstractVector{<: Number}
c = pop!(data, :color)
data[:color] = el32convert(c)
Expand Down Expand Up @@ -330,7 +333,6 @@ function draw_atomic(screen::Screen, scene::Scene,
lift(getindex, glyph_data, i)
end


filter!(gl_attributes) do (k, v)
# These are liftkeys without model
!(k in (
Expand Down Expand Up @@ -373,9 +375,8 @@ function draw_atomic(screen::Screen, scene::Scene,
gl_attributes[:distancefield] = get_texture!(atlas)
gl_attributes[:visible] = x.visible
cam = scene.camera
# gl_attributes[:preprojection] = Observable(Mat4f(I))
gl_attributes[:preprojection] = map(space, markerspace, cam.projectionview, cam.resolution) do s, ms, pv, res
Makie.clip_to_space(cam, ms) * Makie.space_to_clip(cam, s)
Mat4f(Makie.clip_to_space(cam, ms) * Makie.space_to_clip(cam, s))
end
connect_camera!(gl_attributes, cam, markerspace)

Expand Down Expand Up @@ -457,13 +458,6 @@ function draw_atomic(screen::Screen, scene::Scene, x::Image)
end
end

function update_positions(mesh::GeometryBasics.Mesh, positions)
points = coordinates(mesh)
attr = GeometryBasics.attributes(points)
delete!(attr, :position) # position == metafree(points)
return GeometryBasics.Mesh(meta(positions; attr...), faces(mesh))
end

function mesh_inner(screen::Screen, mesh, transfunc, gl_attributes, space=:data)
# signals not supported for shading yet
gl_attributes[:shading] = to_value(pop!(gl_attributes, :shading))
Expand Down Expand Up @@ -492,9 +486,12 @@ function mesh_inner(screen::Screen, mesh, transfunc, gl_attributes, space=:data)
end
mesh = map(mesh, transfunc, space) do mesh, func, space
if !Makie.is_identity_transform(func)
return update_positions(mesh, apply_transform.(Ref(func), mesh.position, space))
pos = apply_transform.(Ref(func), mesh.position, space)
else
pos = mesh.position
end
return mesh
m = el32convert(mesh, pos)
return m
end
return draw_mesh(screen, mesh, gl_attributes)
end
Expand Down Expand Up @@ -545,14 +542,14 @@ function draw_atomic(screen::Screen, scene::Scene, x::Surface)
xypos = map(t, x[1], x[2], space) do t, x, y, space
# Only if transform doesn't do anything, we can stay linear in 1/2D
if Makie.is_identity_transform(t)
return (x, y)
return (el32convert(x), el32convert(y))
else
matrix = if x isa AbstractMatrix && y isa AbstractMatrix
apply_transform.((t,), Point.(x, y), space)
else
# If we do any transformation, we have to assume things aren't on the grid anymore
# so x + y need to become matrices.
[apply_transform(t, Point(x, y), space) for x in x, y in y]
Point3f[apply_transform(t, Point(x, y), space) for x in x, y in y]
end
return (first.(matrix), last.(matrix))
end
Expand Down
2 changes: 1 addition & 1 deletion GLMakie/src/postprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function ssao_postprocessor(framebuffer, shader_cache)
a = pixelarea(scene)[]
glScissor(minimum(a)..., widths(a)...)
# update uniforms
data1[:projection] = scene.camera.projection[]
data1[:projection] = Mat4f(scene.camera.projection[])
data1[:bias] = scene.ssao.bias[]
data1[:radius] = scene.ssao.radius[]
GLAbstraction.render(pass1)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

- Fixed an issue where `poly` plots with `Vector{<: MultiPolygon}` inputs with per-polygon color were mistakenly rendered as meshes using CairoMakie. [#2590](https://github.com/MakieOrg/Makie.jl/pulls/2478)
- Fixed a small typo which caused an error in the `Stepper` constructor. [#2600](https://github.com/MakieOrg/Makie.jl/pulls/2478)
- Switch `plot.converted` to Float64 types to avoid loss of precision. This should fix precision related issues for CairoMakie but not GL backends [2573](https://github.com/MakieOrg/Makie.jl/pull/2573)

## v0.19.1

Expand Down
14 changes: 7 additions & 7 deletions WGLMakie/src/imagelike.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function draw_mesh(mscene::Scene, mesh, plot; uniforms...)
get!(uniforms, :interpolate_in_fragment_shader, true)
uniforms[:normalmatrix] = map(mscene.camera.view, plot.model) do v, m
i = Vec(1, 2, 3)
return transpose(inv(v[i, i] * m[i, i]))
return Mat3f(transpose(inv(v[i, i] * m[i, i])))
end

for key in (:diffuse, :specular, :shininess, :backlight)
Expand Down Expand Up @@ -61,19 +61,19 @@ function limits_to_uvmesh(plot)
rect = lift(px, py) do x, y
xmin, xmax = extrema(x)
ymin, ymax = extrema(y)
return Rect2(xmin, ymin, xmax - xmin, ymax - ymin)
return Rect2f(xmin, ymin, xmax - xmin, ymax - ymin)
end
positions = Buffer(lift(rect-> decompose(Point2f, rect), rect))
faces = Buffer(lift(rect -> decompose(GLTriangleFace, rect), rect))
uv = Buffer(lift(decompose_uv, rect))
else
grid(x, y, trans, space) = Makie.matrix_grid(p-> apply_transform(trans, p, space), x, y, zeros(length(x), length(y)))
rect = lift((x, y) -> Tesselation(Rect2(0f0, 0f0, 1f0, 1f0), (length(x), length(y))), px, py)
else
# TODO can we skip the second el32converet?
grid(x, y, trans, space) = el32convert(Makie.matrix_grid(p-> apply_transform(trans, p, space), x, y, zeros(length(x), length(y))))
rect = lift((x, y) -> Tesselation(Rect2f(0f0, 0f0, 1f0, 1f0), (length(x), length(y))), px, py)
positions = Buffer(lift(grid, px, py, t, get(plot, :space, :data)))
faces = Buffer(lift(r -> decompose(GLTriangleFace, r), rect))
uv = Buffer(lift(decompose_uv, rect))
end

vertices = GeometryBasics.meta(positions; uv=uv)

return GeometryBasics.Mesh(vertices, faces)
Expand All @@ -90,7 +90,7 @@ end
function create_shader(mscene::Scene, plot::Surface)
# TODO OWN OPTIMIZED SHADER ... Or at least optimize this a bit more ...
px, py, pz = plot[1], plot[2], plot[3]
grid(x, y, z, trans, space) = Makie.matrix_grid(p-> apply_transform(trans, p, space), x, y, z)
grid(x, y, z, trans, space) = el32convert(Makie.matrix_grid(p-> apply_transform(trans, p, space), x, y, z))
positions = Buffer(lift(grid, px, py, pz, transform_func_obs(plot), get(plot, :space, :data)))
rect = lift(z -> Tesselation(Rect2(0f0, 0f0, 1f0, 1f0), size(z)), pz)
faces = Buffer(lift(r -> decompose(GLTriangleFace, r), rect))
Expand Down
6 changes: 3 additions & 3 deletions WGLMakie/src/meshes.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function vertexbuffer(x, trans, space)
pos = decompose(Point, x)
return apply_transform(trans, pos, space)
return el32convert(apply_transform(trans, pos, space))
end

function vertexbuffer(x::Observable, p)
Expand Down Expand Up @@ -41,7 +41,7 @@ function create_shader(scene::Scene, plot::Makie.Mesh)

for (key, default) in (:uv => Vec2f(0), :normals => Vec3f(0))
if haskey(data, key)
attributes[key] = Buffer(get_attribute(mesh_signal, key))
attributes[key] = Buffer(map(el32convert, get_attribute(mesh_signal, key)))
else
uniforms[key] = Observable(default)
end
Expand Down Expand Up @@ -121,7 +121,7 @@ function create_shader(scene::Scene, plot::Makie.Mesh)

uniforms[:normalmatrix] = map(scene.camera.view, plot.model) do v, m
i = Vec(1, 2, 3)
return transpose(inv(v[i, i] * m[i, i]))
return transpose(Mat3f(inv(v[i, i] * m[i, i])))
end

# id + picking gets filled in JS, needs to be here to emit the correct shader uniforms
Expand Down
12 changes: 8 additions & 4 deletions WGLMakie/src/particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function create_shader(scene::Scene, plot::MeshScatter)
return k in per_instance_keys && !(isscalar(v[]))
end
space = get(plot, :space, :data)
per_instance[:offset] = apply_transform(transform_func_obs(plot), plot[1], space)
per_instance[:offset] = map(transform_func_obs(plot), plot[1], space) do tf, pos, space
el32convert(apply_transform(tf, pos, space))
end

for (k, v) in per_instance
per_instance[k] = Buffer(lift_convert(k, v, plot))
Expand All @@ -71,7 +73,7 @@ function create_shader(scene::Scene, plot::MeshScatter)
end

handle_color!(uniform_dict, per_instance)
instance = convert_attribute(plot.marker[], key"marker"(), key"meshscatter"())
instance = el32convert(convert_attribute(plot.marker[], key"marker"(), key"meshscatter"()))

if !hasproperty(instance, :uv)
uniform_dict[:uv] = Vec2f(0)
Expand Down Expand Up @@ -182,7 +184,7 @@ function scatter_shader(scene::Scene, attributes)

handle_color!(uniform_dict, per_instance)

instance = uv_mesh(Rect2(-0.5f0, -0.5f0, 1f0, 1f0))
instance = uv_mesh(Rect2f(-0.5f0, -0.5f0, 1f0, 1f0))
# Don't send obs, since it's overwritten in JS to be updated by the camera
uniform_dict[:resolution] = to_value(scene.camera.resolution)

Expand All @@ -204,7 +206,9 @@ function create_shader(scene::Scene, plot::Scatter)
space = get(attributes, :space, :data)
cam = scene.camera
attributes[:preprojection] = Mat4f(I) # calculate this in JS
attributes[:pos] = apply_transform(transform_func_obs(plot), plot[1], space)
attributes[:pos] = map(transform_func_obs(plot), plot[1], space) do tf, pos, space
el32convert(apply_transform(tf, pos, space))
end

quad_offset = get(attributes, :marker_offset, Observable(Vec2f(0)))
attributes[:marker_offset] = Vec3f(0)
Expand Down
7 changes: 6 additions & 1 deletion WGLMakie/src/serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,10 @@ function serialize_camera(scene::Scene)
# a view matrix change!
ep = cam.eyeposition[]
return [vec(collect(view)), vec(collect(proj)), Int32[res...], Float32[ep...]]
# eyepos32 = Vector{Float32}(cam.eyeposition[])
# res32 = Vector{Int32}(res)
# view32 = Vector{Float32}(vec(view))
# proj32 = Vector{Float32}(vec(proj))
# return [view32, proj32, res32, eyepos32]
end
end
end
4 changes: 3 additions & 1 deletion docs/documentation/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ function Makie.plot!(
push!(bar_tos[], s.close)
end
append!(colors[], [x.close > x.open for x in stockvalues])
colors[] = colors[]
notify(linesegs)
notify(colors)
return
Comment on lines +241 to +243
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this worked without notify(linesegs) because Makie did not copy the Point2f array. Now/currently it converts to Float64, so it does copy and needs an Observable update

end

# connect `update_plot` so that it is called whenever `times`
Expand Down
7 changes: 7 additions & 0 deletions src/Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ const RGBAf = RGBA{Float32}
const RGBf = RGB{Float32}
const NativeFont = FreeTypeAbstraction.FTFont

const Vec2e = Vec2{Float64}
const Vec3e = Vec3{Float64}
const Vec4e = Vec4{Float64}
const Point2e = Point2{Float64}
const Point3e = Point3{Float64}
const Point4e = Point4{Float64}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const Rect2e = Rect2{Float64}
const Rect3e = Rect3{Float64}

for completeness

const ASSETS_DIR = RelocatableFolders.@path joinpath(@__DIR__, "..", "assets")
assetpath(files...) = normpath(joinpath(ASSETS_DIR, files...))

Expand Down
Loading