Skip to content

Commit

Permalink
samples: core: better thumbnails and unit previews
Browse files Browse the repository at this point in the history
  • Loading branch information
dbartolini committed Dec 15, 2024
1 parent 605ee1d commit dd92a41
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Changelog
* Fixed an issue that caused warnings to be printed on the console when a Sound Source was deleted from a level.
* Reduced clutter in the Project Browser by hiding all files with importable extensions.
* Fixed missing/wrong previews and thumbnails in some circumnstances.
* Improved unit previews and thumbnails with better lighting/dimensionality.

**Runtime**

Expand Down
11 changes: 6 additions & 5 deletions samples/core/editors/thumbnail/thumbnail.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ function MaterialPreview:destroy()
end

function MaterialPreview:render(camera)
local obb_tm, obb_he = self._unit_preview._object:obb()

local camera_pos = Vector3(1, 1, 1)
local camera_rot = Quaternion.look(Vector3.normalize(-camera_pos))
local camera_pos = Vector3(1, -1, 0.5)
local camera_rot = Quaternion.from_axis_angle(Vector3.up(), 45.0 * (math.pi / 180.0))
local camera_pose = Matrix4x4.from_quaternion_translation(camera_rot, camera_pos)

camera:set_local_pose(camera_pose)
Expand All @@ -92,7 +90,10 @@ function Thumbnail:init()
self._requests = {}
self._pending = {}

World.spawn_unit(self._world, "core/units/light", Vector3(1000, -1000, 1000))
World.spawn_unit(self._world, "core/units/light"
, Vector3(1000, 0, 0)
, Quaternion.from_axis_angle(Vector3.forward(), 45.0 * (math.pi / 180.0))
)
end

function Thumbnail:thumbnail_ready(screenshot_path)
Expand Down
5 changes: 4 additions & 1 deletion samples/core/editors/unit_preview/unit_preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ function UnitPreview:init()
self._camera = Camera(self._world, World.spawn_unit(self._world, "core/units/camera"))
self._object = nil

World.spawn_unit(self._world, "core/units/light", Vector3(1000, -1000, 1000))
World.spawn_unit(self._world, "core/units/light"
, Vector3(1000, 0, 0)
, Quaternion.from_axis_angle(Vector3.forward(), 45.0 * (math.pi / 180.0))
)
end

function UnitPreview:update(dt)
Expand Down

0 comments on commit dd92a41

Please sign in to comment.