scenejs_on_rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +177 -0
- data/Rakefile +1 -0
- data/lib/scenejs_on_rails/version.rb +4 -0
- data/lib/scenejs_on_rails.rb +6 -0
- data/scenejs_on_rails.gemspec +33 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c0c018e7eb556d0a1567186274fd7a8dffde1fd4
|
4
|
+
data.tar.gz: a0d0b24791560be6e87cd8109c639cba40536bac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95b76943c9bcd0f36af5d8b0c72df8a832d0eff059fdaec207bdef02d268ef3d217e6aed74fcf21c044211901f08150326141e010ff5cf5a6d2629282639ec9c
|
7
|
+
data.tar.gz: c6233899faa7cc3faf692ca274114f6499264e542896efcb286f9e24bc24d8b0a058f74d47d6aff71c22904b22bb940f363dc1dda0ecde9c18b51c6e724611aa
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Louis Alridge
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
# Scenejs On Rails
|
2
|
+
## Plugins last updated October 24th, 2013
|
3
|
+
|
4
|
+
First off, if you dont know about [Scenejs]:http://scenejs.org/ ,go take a look so you can appreciate what this gem does.
|
5
|
+
|
6
|
+
For the informed, this gem allows you to utilize scenejs and all of its plugin glory within rails WITHOUT having to load all
|
7
|
+
of its javascript files into your asset pipeline. If you are fine with scenejs.org hosting your files AND not being able to
|
8
|
+
easily create and utilize your own scenejs plugins, this gem is not for you. I repeat, if you don't plan on using self-made
|
9
|
+
plugins, just pull from scenejs.org directly.
|
10
|
+
|
11
|
+
Advantages:
|
12
|
+
|
13
|
+
* You will be hosting all the scenejs plugins through this gem and can not worry about scenejs.org being unreachable
|
14
|
+
* All plugins will be static
|
15
|
+
* You can create plugins in vendor/assets/javascripts/scenejs_plugins and link to them easily
|
16
|
+
* Images (gif, png, jpg) included in your plugins will be loaded as well and dont have to be embedded in asset pipeline
|
17
|
+
* Your filesystem will NOT be exposed by this gem
|
18
|
+
|
19
|
+
Disadvantages:
|
20
|
+
* You will be hosting an additional 32MB
|
21
|
+
* The scenejs.js file is ~580 kb
|
22
|
+
|
23
|
+
## If the above sounds good to you, heres how to install
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
gem 'scenejs_on_rails'
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
|
31
|
+
$ bundle
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
|
35
|
+
$ gem install scenejs_on_rails
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
Then add this to your routes.rb
|
40
|
+
|
41
|
+
$ resources :scenejs, only: [:get_scenejs_plugin]
|
42
|
+
|
43
|
+
And finally add this to your application.js
|
44
|
+
|
45
|
+
$ //= require scenejs
|
46
|
+
|
47
|
+
## Usage Example
|
48
|
+
In a script tag:
|
49
|
+
|
50
|
+
```javascript
|
51
|
+
// Demo of the "cameras/orbit" and "objects/space/planets/earth" custom node types
|
52
|
+
|
53
|
+
// Create scene
|
54
|
+
var scene = SceneJS.createScene({
|
55
|
+
nodes: [
|
56
|
+
|
57
|
+
{
|
58
|
+
type:"cameras/orbit",
|
59
|
+
id : "camera",
|
60
|
+
yaw:340,
|
61
|
+
pitch:-20,
|
62
|
+
zoom:7,
|
63
|
+
zoomSensitivity:1.0,
|
64
|
+
eye:{ y:0 },
|
65
|
+
look:{ y:0 },
|
66
|
+
|
67
|
+
nodes:[
|
68
|
+
// Custom lighting to simulate the Sun
|
69
|
+
{
|
70
|
+
type:"lights",
|
71
|
+
lights:[
|
72
|
+
{
|
73
|
+
mode:"dir",
|
74
|
+
color:{ r:1.0, g:1.0, b:1.0 },
|
75
|
+
diffuse:true,
|
76
|
+
specular:true,
|
77
|
+
dir:{ x:-0.5, y:-0.5, z:-0.75 }
|
78
|
+
}
|
79
|
+
],
|
80
|
+
|
81
|
+
nodes:[
|
82
|
+
// Planet Earth,
|
83
|
+
// implemented by plugin at http://scenejs.org/api/latest/plugins/node/objects/space/planets/earth.js
|
84
|
+
{
|
85
|
+
type:"objects/space/planets/earth"
|
86
|
+
}
|
87
|
+
]
|
88
|
+
}
|
89
|
+
]
|
90
|
+
}
|
91
|
+
]
|
92
|
+
});
|
93
|
+
```
|
94
|
+
|
95
|
+
This will render the SceneJS team's awesome earth graphic with no additional work on your part. If it doesnt, there is a problem
|
96
|
+
and you should create an issue about it.
|
97
|
+
|
98
|
+
## Detailed Information
|
99
|
+
|
100
|
+
Simply by declaring
|
101
|
+
|
102
|
+
```javascript
|
103
|
+
type: 'myplugin/path'
|
104
|
+
```
|
105
|
+
for a node, scenejs will send a request to your app for the plugin data it needs. If it is looking for javascripts that define the node,
|
106
|
+
it will recieve them as raw inline javascript and then mark that plugin as loaded. It looks in your /vendor/assets/javascripts/scenejs_plugins folder
|
107
|
+
THEN in its own directory for the javascripts. If it doesn't find the data, the scenejs controller (within rails) raises a
|
108
|
+
ActionController::RoutingError error.
|
109
|
+
|
110
|
+
If you want to link to a image within a plugin you made you should set this in your init function
|
111
|
+
```javascript
|
112
|
+
SceneJS.Types.addType("objects/spacee/my_planets/awesome_sun", {
|
113
|
+
|
114
|
+
init:function (params) {
|
115
|
+
|
116
|
+
var texturePath = "node/objects/space/my_planets/awesome_sun/";
|
117
|
+
```
|
118
|
+
Then set your texture nodes like so
|
119
|
+
```javascript
|
120
|
+
type: "texture",
|
121
|
+
layers: [
|
122
|
+
{
|
123
|
+
src: texturePath + 'mysunimg.png'
|
124
|
+
}
|
125
|
+
],
|
126
|
+
```
|
127
|
+
This will tell scenejs to grab the image data from scenejs controller's get_plugin_data url. The image data is served via send_data(location_of_image_file).
|
128
|
+
|
129
|
+
### NOTE!
|
130
|
+
|
131
|
+
If you plan on using images / whatever as textures within an init file (something that defines the base scene like above), just use your asset pipeline.
|
132
|
+
|
133
|
+
```javascript
|
134
|
+
type: "texture",
|
135
|
+
layers: [
|
136
|
+
{
|
137
|
+
src: "<%= asset_path 'mytexture.jpg' %>"
|
138
|
+
}
|
139
|
+
],
|
140
|
+
```
|
141
|
+
|
142
|
+
## Vulnerability via looking for the files?
|
143
|
+
|
144
|
+
For the security minded, the scenejs controller figures out where to find its files from params[:file] then searching in two possible locations for that data.
|
145
|
+
As the location parses uses File.join() it was possible for an attacker to use '..' to dig up files they are not meant to find. This has been prevented through
|
146
|
+
statements that scan the params[:file] string. If this occurs, the controller will raise a ActionController::UnpermittedParameters error. This will never occur
|
147
|
+
normally.
|
148
|
+
|
149
|
+
## So why did you need to modify the original source?
|
150
|
+
|
151
|
+
```javascript
|
152
|
+
SceneJS.setConfigs({
|
153
|
+
pluginPath: (((location.protocol.length === 0) ? 'http://' : location.protocol + '//') + location.host + '/scenejs/get_scenejs_data?file=')
|
154
|
+
});
|
155
|
+
```
|
156
|
+
|
157
|
+
Is the only edit made to scenejs.js source. Everything else happens naturally through the parsing of the files. Kudos to the SceneJS team on this by the way,
|
158
|
+
Louis Alridge had originally written some hacks into the source to get things to work just right, but with 3.2 simply adding that is all thats needed.
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
## SceneJS Libraries
|
163
|
+
|
164
|
+
Certain libraries like stats.min must be included through the asset pipeline in your application.js like this:
|
165
|
+
|
166
|
+
$ //= require scenejs_lib/stats.min
|
167
|
+
|
168
|
+
Anything you'd normally find in /examples/libs in the scenejs repo can be found there... Extras can be found with
|
169
|
+
|
170
|
+
$ //= require scenejs_extras/gui
|
171
|
+
|
172
|
+
### NOTE!
|
173
|
+
|
174
|
+
You may run into some libraries that don't work because they dont call on the SceneJS pluginPath variable and instead try finding their dependencies
|
175
|
+
through the filesystem (like the standard physics engine). Theres nothing you can really do about this unless you want to get your hands dirty with some js.
|
176
|
+
If you run into these, submit an issue (to both this gem and to the scenejs repo). You can 'fix' this by putting the files causing the problem in YOUR vendor
|
177
|
+
directory and fixing them there at the very least.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'scenejs_on_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "scenejs_on_rails"
|
8
|
+
spec.version = ScenejsOnRails::VERSION
|
9
|
+
spec.authors = ["Louis Alridge"]
|
10
|
+
spec.email = ["loualrid@gmail.com"]
|
11
|
+
spec.homepage = "https://github.com/loualrid/scenejs_on_rails"
|
12
|
+
spec.summary = %q{Scenejs On Rails Smart Asset Management}
|
13
|
+
spec.description = <<-EOF
|
14
|
+
### Features ###
|
15
|
+
* Allows you to utilize scenejs without having to clutter up your assets with tons of js files for self hosters.
|
16
|
+
* Seamlessly allows you to create and utilize plugins you've made and placed in your vendor/assets/javascripts/scenejs_plugins directory
|
17
|
+
* Preserves the directory structure of scenejs plugins, you can keep your custom made plugins in a place where scenejs
|
18
|
+
can find them.
|
19
|
+
EOF
|
20
|
+
|
21
|
+
spec.rubyforge_project = "scenejs_on_rails"
|
22
|
+
|
23
|
+
spec.files = `git ls-files`.split("\n")
|
24
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_runtime_dependency 'rails', '>= 3.1.1'
|
29
|
+
|
30
|
+
spec.license = 'MIT'
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
32
|
+
spec.add_development_dependency "rake"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scenejs_on_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Louis Alridge
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: |2
|
56
|
+
### Features ###
|
57
|
+
* Allows you to utilize scenejs without having to clutter up your assets with tons of js files for self hosters.
|
58
|
+
* Seamlessly allows you to create and utilize plugins you've made and placed in your vendor/assets/javascripts/scenejs_plugins directory
|
59
|
+
* Preserves the directory structure of scenejs plugins, you can keep your custom made plugins in a place where scenejs
|
60
|
+
can find them.
|
61
|
+
email:
|
62
|
+
- loualrid@gmail.com
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- .gitignore
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- lib/scenejs_on_rails.rb
|
73
|
+
- lib/scenejs_on_rails/version.rb
|
74
|
+
- scenejs_on_rails.gemspec
|
75
|
+
homepage: https://github.com/loualrid/scenejs_on_rails
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project: scenejs_on_rails
|
95
|
+
rubygems_version: 2.0.6
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Scenejs On Rails Smart Asset Management
|
99
|
+
test_files: []
|