Class: Mittsu::CubeCamera
- Defined in:
- lib/mittsu/cameras/cube_camera.rb
Constant Summary
Constants inherited from Object3D
Instance Attribute Summary collapse
-
#render_target ⇒ Object
Returns the value of attribute render_target.
Attributes inherited from Object3D
#cast_shadow, #children, #frustum_culled, #geometry, #id, #matrix, #matrix_auto_update, #matrix_world, #matrix_world_needs_update, #name, #parent, #position, #quaternion, #receive_shadow, #render_order, #rotation, #rotation_auto_update, #scale, #type, #up, #user_data, #uuid, #visible
Instance Method Summary collapse
-
#initialize(near, far, cube_resolution) ⇒ CubeCamera
constructor
A new instance of CubeCamera.
- #update_cube_map(renderer, scene) ⇒ Object
Methods inherited from Object3D
#add, #apply_matrix, #clone, #get_object_by_id, #get_object_by_name, #get_object_by_property, #get_world_direction, #get_world_position, #get_world_quaternion, #get_world_rotation, #get_world_scale, #local_to_world, #look_at, #print_tree, #raycast, #remove, #rotate_on_axis, #rotate_x, #rotate_y, #rotate_z, #set_rotation_from_axis_angle, #set_rotation_from_euler, #set_rotation_from_matrix, #set_rotation_from_quaternion, #to_json, #to_s, #translate_on_axis, #translate_x, #translate_y, #translate_z, #traverse, #traverse_ancestors, #traverse_visible, #update_matrix, #update_matrix_world, #world_to_local
Methods included from EventDispatcher
#add_event_listener, #dispatch_event, #has_event_listener, #remove_event_listener
Constructor Details
#initialize(near, far, cube_resolution) ⇒ CubeCamera
Returns a new instance of CubeCamera.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mittsu/cameras/cube_camera.rb', line 5 def initialize(near, far, cube_resolution) super() @type = 'CubeCamera' fov = 90.0 aspect = 1.0 @camera_px = Mittsu::PerspectiveCamera.new(fov, aspect, near, far) @camera_px.up.set(0.0, -1.0, 0.0) @camera_px.look_at(Mittsu::Vector3.new(1.0, 0.0, 0.0)) self.add(@camera_px) @camera_nx = Mittsu::PerspectiveCamera.new(fov, aspect, near, far) @camera_nx.up.set(0.0, -1.0, 0.0) @camera_nx.look_at(Mittsu::Vector3.new(-1.0, 0.0, 0.0)) self.add(@camera_nx) @camera_py = Mittsu::PerspectiveCamera.new(fov, aspect, near, far) @camera_py.up.set(0.0, 0.0, 1.0) @camera_py.look_at(Mittsu::Vector3.new(0.0, 1.0, 0.0)) self.add(@camera_py) @camera_ny = Mittsu::PerspectiveCamera.new(fov, aspect, near, far) @camera_ny.up.set(0.0, 0.0, 1.0) @camera_ny.look_at(Mittsu::Vector3.new(0.0, -1.0, 0.0)) self.add(@camera_ny) @camera_pz = Mittsu::PerspectiveCamera.new(fov, aspect, near, far) @camera_pz.up.set(0.0, -1.0, 0.0) @camera_pz.look_at(Mittsu::Vector3.new(0.0, 0.0, 1.0)) self.add(@camera_pz) @camera_nz = Mittsu::PerspectiveCamera.new(fov, aspect, near, far) @camera_nz.up.set(0.0, -1.0, 0.0) @camera_nz.look_at(Mittsu::Vector3.new(0.0, 0.0, -1.0)) self.add(@camera_nz) @render_target = Mittsu::RenderTargetCube(cube_resolution, format: Mittsu::RGBFormat, mag_filter: Mittsu::LinearFilter, min_filter: Mittsu::LinearFilter) end |
Instance Attribute Details
#render_target ⇒ Object
Returns the value of attribute render_target.
3 4 5 |
# File 'lib/mittsu/cameras/cube_camera.rb', line 3 def render_target @render_target end |
Instance Method Details
#update_cube_map(renderer, scene) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/mittsu/cameras/cube_camera.rb', line 46 def update_cube_map(renderer, scene) generate_mipmaps = render_target.generate_mipmaps render_target.generate_mipmaps = false render_target.active_cube_face = 0 renderer.render(scene, @camera_px, render_target) render_target.active_cube_face = 1 renderer.render(scene, @camera_nx, render_target) render_target.active_cube_face = 2 renderer.render(scene, @camera_py, render_target) render_target.active_cube_face = 3 renderer.render(scene, @camera_ny, render_target) render_target.active_cube_face = 4 renderer.render(scene, @camera_pz, render_target) render_target.generate_mipmaps = generate_mipmaps render_target.active_cube_face = 5 renderer.render(scene, @camera_nz, render_target) end |