opal-js_wrap-three 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9cae62516fa7b9a2f924dc94dfa5aa0207b92ced58133989b924da38ecb1a67d
4
+ data.tar.gz: 84c1d6bb5d517626befc59cc6bee512697ff1c3d688f59e07947b0ad3d444b6f
5
+ SHA512:
6
+ metadata.gz: 2a8d9c1652a52eac070c9343d108eeae2f539b8757687a3607da597eb519c7fef81caff6dfa4bb160835165621e8770a470d7d2259c720867355b05ccc2ee680
7
+ data.tar.gz: 7c533af27929c76db80cba39b29d434edc9bf0f84cc6e5847045c33ce439d481ed0b88f2a96ed7329dea2496bbd101823486269b5a785463c7e7f90895733a17
@@ -0,0 +1,16 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.2
14
+ bundler-cache: true
15
+ - name: Run the default task
16
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ /node_modules/
11
+ /lib-opal/js_wrap/three/three.js
12
+
13
+ Gemfile.lock
14
+
15
+ # rspec failure tracking
16
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-12-14
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in opal-js_wrap-three.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
13
+
14
+ gem "opal-rspec"
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ opal-js_wrap-three (0.1.0)
5
+ opal (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ concurrent-ruby (1.1.9)
12
+ diff-lcs (1.4.4)
13
+ opal (1.3.2)
14
+ ast (>= 2.3.0)
15
+ parser (~> 3.0)
16
+ opal-rspec (0.8.0)
17
+ opal (>= 1.0.0, < 2.0)
18
+ opal-sprockets (< 2.0)
19
+ rake (>= 12.0)
20
+ opal-sprockets (1.0.2)
21
+ opal (>= 1.0, < 2.0)
22
+ sprockets (~> 4.0)
23
+ tilt (>= 1.4)
24
+ parallel (1.21.0)
25
+ parser (3.0.3.2)
26
+ ast (~> 2.4.1)
27
+ rack (2.2.3)
28
+ rainbow (3.0.0)
29
+ rake (13.0.6)
30
+ regexp_parser (2.1.1)
31
+ rexml (3.2.5)
32
+ rspec (3.10.0)
33
+ rspec-core (~> 3.10.0)
34
+ rspec-expectations (~> 3.10.0)
35
+ rspec-mocks (~> 3.10.0)
36
+ rspec-core (3.10.1)
37
+ rspec-support (~> 3.10.0)
38
+ rspec-expectations (3.10.1)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.10.0)
41
+ rspec-mocks (3.10.2)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-support (3.10.3)
45
+ rubocop (1.22.3)
46
+ parallel (~> 1.10)
47
+ parser (>= 3.0.0.0)
48
+ rainbow (>= 2.2.2, < 4.0)
49
+ regexp_parser (>= 1.8, < 3.0)
50
+ rexml
51
+ rubocop-ast (>= 1.12.0, < 2.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (>= 1.4.0, < 3.0)
54
+ rubocop-ast (1.13.0)
55
+ parser (>= 3.0.1.1)
56
+ ruby-progressbar (1.11.0)
57
+ sprockets (4.0.2)
58
+ concurrent-ruby (~> 1.0)
59
+ rack (> 1, < 3)
60
+ tilt (2.0.10)
61
+ unicode-display_width (2.1.0)
62
+
63
+ PLATFORMS
64
+ x86_64-linux
65
+
66
+ DEPENDENCIES
67
+ opal-js_wrap-three!
68
+ opal-rspec
69
+ rake (~> 13.0)
70
+ rspec (~> 3.0)
71
+ rubocop (~> 1.7)
72
+
73
+ BUNDLED WITH
74
+ 2.2.20
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 hmdne
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Opal-JSWrap-Three
2
+
3
+ This gem wraps the Three.js library with JSWrap for Opal.
4
+
5
+ Releases before v0.2.0 should support all versions of Opal and
6
+ bundle JSWrap. Later versions will use Opal-bundled version of
7
+ JSWrap.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'opal-jswrap-three'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install opal-jswrap-three
24
+
25
+ ## Usage
26
+
27
+ Server-side:
28
+
29
+ ```ruby
30
+ require 'opal/js_wrap/three'
31
+ ```
32
+
33
+ Client-side:
34
+
35
+ ```ruby
36
+ require 'js_wrap/three'
37
+ ```
38
+
39
+ Three.js API follows, except that everything named like `setSize`
40
+ is now `set_size` and so on.
41
+
42
+ See examples for more info.
43
+
44
+ ## Development
45
+
46
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
47
+
48
+ 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`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hmdne/opal-jswrap-three.
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ file 'lib-opal/js_wrap/three/three.js' do
13
+ sh 'npx rollup -c'
14
+ end
15
+
16
+ task build_js: 'lib-opal/js_wrap/three/three.js'
17
+
18
+ task default: %i[build_js]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "opal/js_wrap/three"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+ npm i
8
+ bundle exec rake build
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "opal-js_wrap-three", path: "../.."
4
+ # This gem should work with any recent version of Opal (no guarantees),
5
+ # but it's strongly recommended to use Opal v1.4 for improved error
6
+ # reporting.
7
+ gem "opal", github: "opal/opal", ref: "hmdne/ruby31"
8
+ gem "rack"
9
+ gem "webrick"
@@ -0,0 +1,33 @@
1
+ # This example is adapted from three.js README document.
2
+
3
+ require 'js_wrap/three'
4
+
5
+ camera = Three::PerspectiveCamera.new(
6
+ 70,
7
+ JSGlobal.inner_width / JSGlobal.inner_height,
8
+ 0.01,
9
+ 10
10
+ )
11
+ camera.position.z = 1
12
+
13
+ scene = Three::Scene.new
14
+
15
+ geometry = Three::BoxGeometry.new(0.2, 0.2, 0.2)
16
+ material = Three::MeshNormalMaterial.new
17
+
18
+ mesh = Three::Mesh.new(geometry, material)
19
+ scene.add(mesh)
20
+
21
+ renderer = Three::WebGLRenderer.new(antialias: true)
22
+ renderer.set_size(JSGlobal.inner_width, JSGlobal.inner_height)
23
+
24
+ renderer.set_animation_loop do |time|
25
+ mesh.rotation.x = time / 2000
26
+ mesh.rotation.y = time / 1000
27
+
28
+ renderer.render(scene, camera)
29
+ end
30
+
31
+ JSGlobal.add_event_listener("DOMContentLoaded") do
32
+ JSGlobal.document.body.append_child(renderer.dom_element)
33
+ end
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ bundle exec opal -qopal/js_wrap/three -Rserver example.rb
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Opal
4
+ module JSWrap
5
+ module Three
6
+ VERSION = "0.1.0"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "three/version"
4
+
5
+ module Opal
6
+ module JSWrap
7
+ module Three
8
+ end
9
+ end
10
+ end
11
+
12
+ require "opal"
13
+
14
+ Opal.append_path File.expand_path('../../../../lib-opal', __FILE__).untaint