Sha256: fe7a7ec68dab7aab0521c2500ab02ca63fd0d78c3a413305d835c7794079729a

Contents?: true

Size: 810 Bytes

Versions: 5

Compression:

Stored size: 810 Bytes

Contents

# This example is adapted from three.js README document.

require 'js_wrap/three'

camera = Three::PerspectiveCamera.new(
            70,
            JSGlobal.inner_width / JSGlobal.inner_height,
            0.01,
            10
          )
camera.position.z = 1

scene = Three::Scene.new

geometry = Three::BoxGeometry.new(0.2, 0.2, 0.2)
material = Three::MeshNormalMaterial.new

mesh = Three::Mesh.new(geometry, material)
scene << mesh

renderer = Three::WebGLRenderer.new(antialias: true)
renderer.set_size(JSGlobal.inner_width, JSGlobal.inner_height)

renderer.set_animation_loop do |time|
	mesh.rotation.x = time / 2000
	mesh.rotation.y = time / 1000

  renderer.render(scene, camera)
end

JSGlobal.add_event_listener("DOMContentLoaded") do
  JSGlobal.document.body.append_child(renderer.dom_element)
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-js_wrap-three-0.1.5 examples/readme/example.rb
opal-js_wrap-three-0.1.4 examples/readme/example.rb
opal-js_wrap-three-0.1.3 examples/readme/example.rb
opal-js_wrap-three-0.1.2 examples/readme/example.rb
opal-js_wrap-three-0.1.1 examples/readme/example.rb