three.rb 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f67b8f4b57e3b3ba14df5fed864899cb377b2fc5
4
- data.tar.gz: ad787ca3413ee7e02ae4abaade2622ee0f01cdfa
3
+ metadata.gz: c1498e455772b4dfa70e3d46013f571ea9048ddf
4
+ data.tar.gz: e6580a03b58f1bff0021d444133f6f916d2f29f8
5
5
  SHA512:
6
- metadata.gz: d9842b01a869a05747636e9a35b341bf9d26a36ca754272882aeeb6582f77bdbe1cc9088a9c09677442a2380921159aa2ad81d8db9a663fcf710cc056df60ef8
7
- data.tar.gz: 728421872fdf9c01ac348771857e56326cbc63479119b58257d981e83c8423f32fe1c2be174846e424af20fe2ad9c3f7cbfbb2c34a8e25b8af25f8bc94892fcc
6
+ metadata.gz: f251fdf60e56e3a3379aaa2549f37861691f921556b4f1eaebf346369cb460f47f5c448c07c3699fd8bb44989a2e4914a3b6239a42a56a74deabcb68b06ad004
7
+ data.tar.gz: 1e57cff400b00f2025a99929f601dcc3096bdbd30188a1e9e5c1915447082aa2ab021b16ecfcdd746798d5204a07c2b3f8258da1500955d7e2401ee38b2327e1
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Three.rb
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/three.rb`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ [Three.js](http://threejs.org) for Ruby via Opal.
6
4
 
7
5
  ## Installation
8
6
 
@@ -20,15 +18,6 @@ Or install it yourself as:
20
18
 
21
19
  $ gem install three.rb
22
20
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
21
 
33
22
  ## Contributing
34
23
 
File without changes
data/bin/setup CHANGED
File without changes
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'three.rb', path: '..'
5
+ gem 'opal-browser'
@@ -0,0 +1,29 @@
1
+ require 'opal'
2
+ require 'browser'
3
+ require 'three'
4
+ require 'pp'
5
+
6
+ aspect_ratio = $$.innerWidth / $$.innerHeight
7
+
8
+ scene = THREE::Scene.new
9
+ camera = THREE::PerspectiveCamera.new(field_of_view: 75, aspect_ratio: aspect_ratio, near: 0.1, far: 1000)
10
+
11
+ renderer = THREE::WebGLRenderer.new
12
+ renderer.set_size($$.innerWidth, $$.innerHeight)
13
+ renderer.dom_element.append_to($document.body)
14
+
15
+ # THE FOLLOWING CODE IS A WORK-IN-PROGRESS AND WILL BE IMPLEMENTED SOON
16
+ # ----------------------------------------------------------------------
17
+ #geometry = THREE::BoxGeometry(1, 1, 1)
18
+ #material = THREE::MeshBasicMaterial( color: 0x00ff00 )
19
+ #cube = THREE::Mesh(geometry, material)
20
+ #scene.add(cube)
21
+ #
22
+ #camera.position.z = 5
23
+ #
24
+ #render = proc do
25
+ # $$.requestAnimationFrame(render)
26
+ # cube.rotation.x += 0.1
27
+ # cube.rotation.y += 0.1
28
+ # renderer.render(scene, camera)
29
+ #end
@@ -0,0 +1,19 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ opal = Opal::Server.new { |s|
5
+ s.append_path 'app'
6
+ s.append_path 'assets'
7
+
8
+ s.main = 'main'
9
+ }
10
+
11
+ map '/assets' do
12
+ run opal.sprockets
13
+ end
14
+
15
+ get '/' do
16
+ send_file 'index.html'
17
+ end
18
+
19
+ run Sinatra::Application
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset= "utf-8" />
5
+ <title>Three.rb in action</title>
6
+ <script src="//cdnjs.cloudflare.com/ajax/libs/three.js/r70/three.js"></script>
7
+ </head>
8
+
9
+ <body>
10
+ <script src="/assets/main.js"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,8 @@
1
+ if RUBY_ENGINE == 'opal'
2
+ require 'opal/three/core'
3
+ else
4
+ require 'opal'
5
+ require 'opal/three/version'
6
+
7
+ Opal.append_path File.expand_path('../..', __FILE__).untaint
8
+ end
@@ -0,0 +1,5 @@
1
+ require 'native'
2
+
3
+ require 'opal/three/core/scene'
4
+ require 'opal/three/core/perspective_camera'
5
+ require 'opal/three/core/webgl_renderer'
@@ -0,0 +1,14 @@
1
+ module THREE
2
+ class PerspectiveCamera
3
+ include Native
4
+
5
+ def initialize (arg_hash = {})
6
+ field_of_view = arg_hash[:field_of_view]
7
+ aspect_ratio = arg_hash[:aspect_ratio]
8
+ near = arg_hash[:near]
9
+ far = arg_hash[:far]
10
+
11
+ @native = `new THREE.Scene(field_of_view, aspect_ratio, near, far)`
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ module THREE
2
+ class Scene
3
+ include Native
4
+
5
+ def initialize
6
+ @native = `new THREE.Scene()`
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module THREE
2
+ class WebGLRenderer
3
+ include Native
4
+
5
+ def initialize
6
+ @native = `new THREE.WebGLRenderer()`
7
+ end
8
+
9
+ alias_native :set_size, :setSize
10
+ alias_native :dom_element, :domElement
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Opal
2
+ module THREE
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require 'opal/require_core.rb'
@@ -1,11 +1,9 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'three.rb/version'
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/opal/three/version', __FILE__)
5
3
 
6
4
  Gem::Specification.new do |s|
7
5
  s.name = "three.rb"
8
- s.version = ThreeRb::VERSION
6
+ s.version = Opal::THREE::VERSION
9
7
  s.authors = ["George Plymale", "Gabriel Rios", "George D. Plymale II"]
10
8
  s.email = ["george@orbitalimpact.com"]
11
9
  s.homepage = "https://github.com/orbitalimpact/three.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: three.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Plymale
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-03-02 00:00:00.000000000 Z
13
+ date: 2015-03-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: opal
@@ -68,8 +68,17 @@ files:
68
68
  - Rakefile
69
69
  - bin/console
70
70
  - bin/setup
71
- - lib/three.rb.rb
72
- - lib/three.rb/version.rb
71
+ - demo/Gemfile
72
+ - demo/app/main.rb
73
+ - demo/config.ru
74
+ - demo/index.html
75
+ - lib/opal/require_core.rb
76
+ - lib/opal/three/core.rb
77
+ - lib/opal/three/core/perspective_camera.rb
78
+ - lib/opal/three/core/scene.rb
79
+ - lib/opal/three/core/webgl_renderer.rb
80
+ - lib/opal/three/version.rb
81
+ - lib/three.rb
73
82
  - three.rb.gemspec
74
83
  homepage: https://github.com/orbitalimpact/three.rb
75
84
  licenses: []
@@ -1,5 +0,0 @@
1
- require "three.rb/version"
2
-
3
- module ThreeRb
4
- # Your code goes here...
5
- end
@@ -1,3 +0,0 @@
1
- module ThreeRb
2
- VERSION = "0.0.0"
3
- end