Skip to content

Commit 51f28af

Browse files
committed
Set F3D camera based on model up direction
1 parent def4d6b commit 51f28af

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/uploaders/application_uploader.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class ApplicationUploader < Shrine
3030
"anti-aliasing" => "true",
3131
"axis" => "0",
3232
"background-color" => "0,0,0",
33-
"camera-direction" => "-1,-0.5,-1",
3433
"filename" => "0",
3534
"grid" => "1",
3635
"grid-color" => "0,255,255",
@@ -43,6 +42,11 @@ class ApplicationUploader < Shrine
4342
"translucency-support" => "1"
4443
}.map { |k, v| "--#{k}=#{v}" }.join(" ").freeze
4544

45+
CAMERA_OPTS = {
46+
"+z" => "-1,1,-0.5",
47+
"+y" => "-1,-0.5,-1"
48+
}
49+
4650
storage(/library_(\d+)/) do |m|
4751
Library.find(m[1]).storage # rubocop:disable Pundit/UsePolicyScope
4852
rescue ActiveRecord::RecordNotFound
@@ -123,7 +127,8 @@ def generate_location(io, record: nil, derivative: nil, metadata: {}, **)
123127
end
124128
elsif SupportedMimeTypes.can_render?(context[:record].mime_type)
125129
Shrine.with_file(original) do |it|
126-
render = StringIO.new(`f3d #{it.path} #{F3D_OPTS}`)
130+
up = context[:record]&.up_direction
131+
render = StringIO.new(`f3d #{it.path} #{F3D_OPTS} --up=#{up} --camera-direction=#{CAMERA_OPTS[up]}`)
127132
{
128133
render: (render.length > 0) ? render : nil
129134
}.compact

0 commit comments

Comments
 (0)