scenejs_on_rails 1.0.4 → 1.0.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 641822c9bc3d6e6aee5c5b7185b9305c63dddef0
|
4
|
+
data.tar.gz: 65f889792a6defaaf2966f665298daf977477f8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a0449fa272e84054179c43f4205c00750a04c139b5266eeb4da693246b6380e06db3fbb6e2d85587623b40a4c7b9e546802a3f89ac90e5014095db255e15c47
|
7
|
+
data.tar.gz: eb1814165999b1569a9fbd802ede0f9c7f9c31b8ad3f66cce93386edda184fe01f7aada33c7c62e20719092db3a29ff78ee925c1049ce20a23fe67776ccab2f5
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Scenejs On Rails
|
2
|
-
##
|
2
|
+
## Currently Running SceneJS V3.2
|
3
3
|
|
4
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
5
|
|
@@ -28,14 +28,12 @@ Add this line to your application's Gemfile:
|
|
28
28
|
|
29
29
|
And then execute:
|
30
30
|
|
31
|
-
$ bundle
|
31
|
+
$ bundle install
|
32
32
|
|
33
33
|
Or install it yourself as:
|
34
34
|
|
35
35
|
$ gem install scenejs_on_rails
|
36
36
|
|
37
|
-
|
38
|
-
|
39
37
|
Then add this to your routes.rb
|
40
38
|
|
41
39
|
get '/scenejs/get_scenejs_data'
|
@@ -103,19 +101,24 @@ Simply by declaring
|
|
103
101
|
type: 'myplugin/path'
|
104
102
|
```
|
105
103
|
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 /
|
107
|
-
|
104
|
+
it will recieve them as raw inline javascript and then mark that plugin as loaded. It looks in your /lib/assets/javascripts/scenejs_plugins folder
|
105
|
+
then /vendor/assets/javascripts/scenejs_plugins and finally in its own directory for the javascripts. If it doesn't find the data, the scenejs controller (within rails) raises a
|
108
106
|
ActionController::RoutingError error.
|
109
107
|
|
110
|
-
|
108
|
+
It is an extremely good idea to have your node type data be based on your filesystem for your plugins. For example, if you are creating a plugin like
|
109
|
+
|
111
110
|
```javascript
|
112
|
-
SceneJS.Types.addType("objects/space/
|
111
|
+
SceneJS.Types.addType("objects/space/planets/awesome_sun", {
|
113
112
|
|
114
113
|
init:function (params) {
|
115
114
|
|
116
|
-
var texturePath = "node/objects/space/
|
115
|
+
var texturePath = "node/objects/space/planets/awesome_sun/";
|
117
116
|
```
|
118
|
-
Then
|
117
|
+
Then your plugin should have its main js file be at Rails.root / lib / assets / javascripts / scenejs_plugins / node / objects / space / planets / awesome_sun.js
|
118
|
+
|
119
|
+
For your images, they should be in Rails.root / lib / assets / javascripts / scenejs_plugins / node / objects / space / planets / awesome_sun (with awesome_sun being
|
120
|
+
a directory) and then linked like so:
|
121
|
+
|
119
122
|
```javascript
|
120
123
|
type: "texture",
|
121
124
|
layers: [
|
@@ -128,7 +131,7 @@ This will tell scenejs to grab the image data from scenejs controller's get_plug
|
|
128
131
|
|
129
132
|
### NOTE!
|
130
133
|
|
131
|
-
If you plan on using images / whatever as textures within an init
|
134
|
+
If you plan on using images / whatever as textures within an init script (something that defines the base scene like the earth example), you can use your asset pipeline.
|
132
135
|
|
133
136
|
```javascript
|
134
137
|
type: "texture",
|
@@ -138,10 +141,24 @@ If you plan on using images / whatever as textures within an init file (somethin
|
|
138
141
|
}
|
139
142
|
],
|
140
143
|
```
|
144
|
+
You can also setup a path to grab these from if you dont want too many images in your pipeline (advanced graphics may use very large images). For example you could store
|
145
|
+
your images in Rails.root / lib / assets / javascripts / scenejs_plugins / generic_images and then link to your images like this:
|
146
|
+
|
147
|
+
```javascript
|
148
|
+
type: "texture",
|
149
|
+
layers: [
|
150
|
+
{
|
151
|
+
src: "generic_images/mytexture.jpg"
|
152
|
+
}
|
153
|
+
],
|
154
|
+
|
155
|
+
```
|
156
|
+
It is always better to store images used in the init script in the pipeline! You dont have a choice for plugins however. It is highly recommended to write all your objects
|
157
|
+
as plugins to better utilize DRY which allows you to use the least amount of code possible to render your scene from the init script.
|
141
158
|
|
142
159
|
## Vulnerability via looking for the files?
|
143
160
|
|
144
|
-
For the security minded, the scenejs controller figures out where to find its files from params[:file] then searching in
|
161
|
+
For the security minded, the scenejs controller figures out where to find its files from params[:file] then searching in three possible locations for that data.
|
145
162
|
As the location parser 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
163
|
statements that scan the params[:file] string. If this occurs, the controller will raise a ActionController::UnpermittedParameters error. This will never occur
|
147
164
|
normally.
|
@@ -150,7 +167,7 @@ normally.
|
|
150
167
|
|
151
168
|
```javascript
|
152
169
|
SceneJS.setConfigs({
|
153
|
-
pluginPath: (((location.protocol.length === 0) ? 'http://' : location.protocol + '//') + location.host + '/scenejs/get_scenejs_data?file=')
|
170
|
+
pluginPath: (((location.protocol.length === 0) ? 'http://' : location.protocol + '//') + location.host + '/scenejs/get_scenejs_data.js?file=')
|
154
171
|
});
|
155
172
|
```
|
156
173
|
|
@@ -161,7 +178,7 @@ Louis Alridge had originally written some hacks into the source to get things to
|
|
161
178
|
|
162
179
|
## SceneJS Libraries
|
163
180
|
|
164
|
-
Certain libraries like stats.min
|
181
|
+
Certain libraries like stats.min can be included through the asset pipeline in your application.js like this:
|
165
182
|
|
166
183
|
//= require scenejs_lib/stats.min
|
167
184
|
|
@@ -28,10 +28,13 @@ class ScenejsController < ApplicationController
|
|
28
28
|
end
|
29
29
|
|
30
30
|
in_gem_file_ref = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', "vendor","assets","javascripts","scenejs_plugins", params[:file])
|
31
|
-
|
31
|
+
in_app_vendor_file_ref = Rails.root.join("vendor","assets","javascripts","scenejs_plugins", params[:file])
|
32
|
+
in_app_lib_file_ref = Rails.root.join("lib","assets","javascripts","scenejs_plugins", params[:file])
|
32
33
|
|
33
|
-
if File.exist?(
|
34
|
-
fileloc =
|
34
|
+
if File.exist?(in_app_lib_file_ref)
|
35
|
+
fileloc = in_app_lib_file_ref
|
36
|
+
elsif File.exist?(in_app_vendor_file_ref)
|
37
|
+
fileloc = in_app_vendor_file_ref
|
35
38
|
elsif File.exist?(in_gem_file_ref)
|
36
39
|
fileloc = in_gem_file_ref
|
37
40
|
end
|
@@ -49,14 +49,17 @@ SceneJS.Types.addType("objects/space/planets/earth", {
|
|
49
49
|
// },
|
50
50
|
{
|
51
51
|
src:texturePath + "earth.jpg",
|
52
|
+
flipY: true,
|
52
53
|
applyTo:"color"
|
53
54
|
},
|
54
55
|
{
|
55
56
|
src:texturePath + "earth-specular.jpg",
|
57
|
+
flipY: true,
|
56
58
|
applyTo:"specular"
|
57
59
|
} ,
|
58
60
|
{
|
59
61
|
src:texturePath + "earth-lights.gif",
|
62
|
+
flipY: true,
|
60
63
|
applyTo:"emit"
|
61
64
|
}
|
62
65
|
],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scenejs_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis Alridge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
205
|
rubyforge_project: scenejs_on_rails
|
206
|
-
rubygems_version: 2.
|
206
|
+
rubygems_version: 2.1.11
|
207
207
|
signing_key:
|
208
208
|
specification_version: 4
|
209
209
|
summary: Scenejs On Rails Smart Asset Management
|