scenejs_on_rails 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/app/controllers/scenejs_controller.rb +53 -0
  4. data/app/views/scenejs/get_scenejs_data.html.erb +3 -0
  5. data/lib/scenejs_on_rails.rb +1 -1
  6. data/lib/scenejs_on_rails/rails.rb +5 -0
  7. data/lib/scenejs_on_rails/version.rb +1 -1
  8. data/vendor/assets/javascripts/scenejs.js +17307 -0
  9. data/vendor/assets/javascripts/scenejs_extras/gui.js +478 -0
  10. data/vendor/assets/javascripts/scenejs_extras/gui/README.md +4 -0
  11. data/vendor/assets/javascripts/scenejs_extras/gui/dat.gui.min.js +94 -0
  12. data/vendor/assets/javascripts/scenejs_extras/gui/gui.js +385 -0
  13. data/vendor/assets/javascripts/scenejs_lib/cityBuilder.js +457 -0
  14. data/vendor/assets/javascripts/scenejs_lib/dat.gui.min.js +94 -0
  15. data/vendor/assets/javascripts/scenejs_lib/gl-matrix-min.js +28 -0
  16. data/vendor/assets/javascripts/scenejs_lib/gl-matrix.js +4078 -0
  17. data/vendor/assets/javascripts/scenejs_lib/require.js +36 -0
  18. data/vendor/assets/javascripts/scenejs_lib/requireConfig.js +18 -0
  19. data/vendor/assets/javascripts/scenejs_lib/requireWrapperEnd.js +1 -0
  20. data/vendor/assets/javascripts/scenejs_lib/requireWrapperStart.js +2 -0
  21. data/vendor/assets/javascripts/scenejs_lib/stats.min.js +6 -0
  22. data/vendor/assets/javascripts/scenejs_lib/sylvester.js +1 -0
  23. data/vendor/assets/javascripts/scenejs_lib/webgl-debug-utils.js +839 -0
  24. data/vendor/assets/javascripts/scenejs_plugins/geometry/boundary.js +59 -0
  25. data/vendor/assets/javascripts/scenejs_plugins/geometry/box.js +72 -0
  26. data/vendor/assets/javascripts/scenejs_plugins/geometry/plane.js +126 -0
  27. data/vendor/assets/javascripts/scenejs_plugins/geometry/quad.js +37 -0
  28. data/vendor/assets/javascripts/scenejs_plugins/geometry/skybox.js +86 -0
  29. data/vendor/assets/javascripts/scenejs_plugins/geometry/sphere.js +82 -0
  30. data/vendor/assets/javascripts/scenejs_plugins/geometry/teapot.js +5853 -0
  31. data/vendor/assets/javascripts/scenejs_plugins/geometry/torus.js +139 -0
  32. data/vendor/assets/javascripts/scenejs_plugins/geometry/vectorText.js +1499 -0
  33. data/vendor/assets/javascripts/scenejs_plugins/geometry/wobblyBox.js +44 -0
  34. data/vendor/assets/javascripts/scenejs_plugins/lib/canvas2image.js +198 -0
  35. data/vendor/assets/javascripts/scenejs_plugins/lib/frustum/frustumCullEngine.js +810 -0
  36. data/vendor/assets/javascripts/scenejs_plugins/lib/frustum/frustumCullSystem.js +185 -0
  37. data/vendor/assets/javascripts/scenejs_plugins/lib/frustum/frustumCullSystemPool.js +174 -0
  38. data/vendor/assets/javascripts/scenejs_plugins/lib/frustum/frustumCullWorker.js +142 -0
  39. data/vendor/assets/javascripts/scenejs_plugins/lib/gl-matrix-min.js +28 -0
  40. data/vendor/assets/javascripts/scenejs_plugins/lib/jquery-1.8.3.min.js +2 -0
  41. data/vendor/assets/javascripts/scenejs_plugins/lib/k3d.js +1029 -0
  42. data/vendor/assets/javascripts/scenejs_plugins/lib/physics/jiglib.all.min.js +3 -0
  43. data/vendor/assets/javascripts/scenejs_plugins/lib/physics/physics.js +223 -0
  44. data/vendor/assets/javascripts/scenejs_plugins/lib/physics/worker.js +330 -0
  45. data/vendor/assets/javascripts/scenejs_plugins/node/alpha/orbitTracking.js +295 -0
  46. data/vendor/assets/javascripts/scenejs_plugins/node/alpha/orbitTrackingTarget.js +43 -0
  47. data/vendor/assets/javascripts/scenejs_plugins/node/backgrounds/gradient.js +148 -0
  48. data/vendor/assets/javascripts/scenejs_plugins/node/cameras/orbit.js +172 -0
  49. data/vendor/assets/javascripts/scenejs_plugins/node/cameras/pickFlyOrbit.js +409 -0
  50. data/vendor/assets/javascripts/scenejs_plugins/node/canvas/capture.js +107 -0
  51. data/vendor/assets/javascripts/scenejs_plugins/node/demos/color.js +30 -0
  52. data/vendor/assets/javascripts/scenejs_plugins/node/demos/redTeapot.js +52 -0
  53. data/vendor/assets/javascripts/scenejs_plugins/node/demos/spinningTeapot.js +43 -0
  54. data/vendor/assets/javascripts/scenejs_plugins/node/effects/crt.js +36 -0
  55. data/vendor/assets/javascripts/scenejs_plugins/node/effects/fog.js +159 -0
  56. data/vendor/assets/javascripts/scenejs_plugins/node/effects/snowyPeaks.js +50 -0
  57. data/vendor/assets/javascripts/scenejs_plugins/node/effects/wobble.js +42 -0
  58. data/vendor/assets/javascripts/scenejs_plugins/node/effects/xray.js +126 -0
  59. data/vendor/assets/javascripts/scenejs_plugins/node/frustum/body.js +112 -0
  60. data/vendor/assets/javascripts/scenejs_plugins/node/frustum/cull.js +42 -0
  61. data/vendor/assets/javascripts/scenejs_plugins/node/frustum/lod.js +125 -0
  62. data/vendor/assets/javascripts/scenejs_plugins/node/heightmaps/custom.js +185 -0
  63. data/vendor/assets/javascripts/scenejs_plugins/node/import/3ds.js +91 -0
  64. data/vendor/assets/javascripts/scenejs_plugins/node/import/md2.js +139 -0
  65. data/vendor/assets/javascripts/scenejs_plugins/node/import/obj.js +100 -0
  66. data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building.js +352 -0
  67. data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building/HighRiseGlass.jpg +0 -0
  68. data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building/HighRiseGlassSpecular.jpg +0 -0
  69. data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building/highrise-windows.jpg +0 -0
  70. data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/building/pixelcity_windows7.jpg +0 -0
  71. data/vendor/assets/javascripts/scenejs_plugins/node/objects/buildings/city.js +26 -0
  72. data/vendor/assets/javascripts/scenejs_plugins/node/objects/plants/ghostTree.js +387 -0
  73. data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth.js +168 -0
  74. data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earth-lights.gif +0 -0
  75. data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earth-specular.gif +0 -0
  76. data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earth-specular.jpg +0 -0
  77. data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earth.jpg +0 -0
  78. data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earthbump.jpg +0 -0
  79. data/vendor/assets/javascripts/scenejs_plugins/node/objects/space/planets/earth/earthclouds.jpg +0 -0
  80. data/vendor/assets/javascripts/scenejs_plugins/node/objects/toys/drinkingBird.js +632 -0
  81. data/vendor/assets/javascripts/scenejs_plugins/node/objects/vehicles/tank.js +77670 -0
  82. data/vendor/assets/javascripts/scenejs_plugins/node/objects/vehicles/tank.js~ +77636 -0
  83. data/vendor/assets/javascripts/scenejs_plugins/node/physics/body.js +85 -0
  84. data/vendor/assets/javascripts/scenejs_plugins/node/physics/box.js +30 -0
  85. data/vendor/assets/javascripts/scenejs_plugins/node/physics/material.js +35 -0
  86. data/vendor/assets/javascripts/scenejs_plugins/node/physics/plane.js +47 -0
  87. data/vendor/assets/javascripts/scenejs_plugins/node/physics/sphere.js +32 -0
  88. data/vendor/assets/javascripts/scenejs_plugins/node/physics/system.js +44 -0
  89. data/vendor/assets/javascripts/scenejs_plugins/node/physics/teapot.js +29 -0
  90. data/vendor/assets/javascripts/scenejs_plugins/node/prims/boundary.js +73 -0
  91. data/vendor/assets/javascripts/scenejs_plugins/node/prims/box.js +87 -0
  92. data/vendor/assets/javascripts/scenejs_plugins/node/prims/cylinder.js +186 -0
  93. data/vendor/assets/javascripts/scenejs_plugins/node/prims/grid.js +47 -0
  94. data/vendor/assets/javascripts/scenejs_plugins/node/prims/plane.js +137 -0
  95. data/vendor/assets/javascripts/scenejs_plugins/node/prims/quad.js +43 -0
  96. data/vendor/assets/javascripts/scenejs_plugins/node/prims/sphere.js +107 -0
  97. data/vendor/assets/javascripts/scenejs_plugins/node/prims/teapot.js +5846 -0
  98. data/vendor/assets/javascripts/scenejs_plugins/node/prims/torus.js +149 -0
  99. data/vendor/assets/javascripts/scenejs_plugins/node/prims/vectorText.js +1508 -0
  100. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/clouds.js +19 -0
  101. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/cloudySea.js +19 -0
  102. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/custom.js +150 -0
  103. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/grimmNight.js +19 -0
  104. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/interstellarClouds.js +19 -0
  105. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/miramarClouds.js +19 -0
  106. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/stormyDays.js +19 -0
  107. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/clouds.jpg +0 -0
  108. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/cloudySea.jpg +0 -0
  109. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/grimmNight.jpg +0 -0
  110. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/interstellarClouds.jpg +0 -0
  111. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/miramarClouds.jpg +0 -0
  112. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/stormyDays.jpg +0 -0
  113. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/textures/violentDays.jpg +0 -0
  114. data/vendor/assets/javascripts/scenejs_plugins/node/skyboxes/violentDays.js +19 -0
  115. data/vendor/assets/javascripts/scenejs_plugins/texture/image.js +67 -0
  116. data/vendor/assets/javascripts/scenejs_plugins/texture/video.js +105 -0
  117. metadata +113 -1
@@ -0,0 +1,457 @@
1
+ /**
2
+
3
+ Quick and dirty procedural city builder
4
+
5
+ Usage:
6
+
7
+ var builder= new CityBuilder({
8
+ texturePath: "foo/bar/myTextures/"
9
+ });
10
+
11
+ builder.build(myNode, {
12
+ xPos: 0,
13
+ zPos: 0,
14
+ xBuildings: 10,
15
+ zBuildings: 10,
16
+ xWidth: 500,
17
+ zWidth: 500
18
+ });
19
+
20
+ */
21
+ var CityBuilder = function (cfg) {
22
+
23
+ var buildingType;
24
+ var buildingTypes;
25
+
26
+ initBuildingTypes(cfg);
27
+
28
+ /** Make some buildings under the given node
29
+ *
30
+ * @param node
31
+ * @param params
32
+ */
33
+ this.build = function (node, params) {
34
+
35
+ node = node.addNode({
36
+ type:"flags",
37
+ enabled:true
38
+ }); // City root node
39
+
40
+ var xPos = params.xPos || 0;
41
+ var zPos = params.zPos || 0;
42
+
43
+ var xBuildings = params.xBuildings || 5;
44
+ var zBuildings = params.zBuildings || 5;
45
+
46
+ var xWidth = params.xWidth || 200;
47
+ var zWidth = params.zWidth || 200;
48
+
49
+ var xMin = xPos - (xWidth * 0.5);
50
+ var xMax = xPos + (xWidth * 0.5);
51
+
52
+ var zMin = zPos - (zWidth * 0.5);
53
+ var zMax = zPos + (zWidth * 0.5);
54
+
55
+ var streetWidth = params.streetWidth || 20;
56
+
57
+ var stepX = (xWidth + streetWidth) / xBuildings;
58
+ var stepZ = (zWidth + streetWidth) / zBuildings;
59
+
60
+ var name;
61
+
62
+ for (var x = xMin; x <= xMax; x += stepX) {
63
+ for (var z = zMin; z <= zMax; z += stepZ) {
64
+
65
+ selectBuildingType();
66
+
67
+ addBuilding(node, {
68
+ xmin:x - 10,
69
+ zmin:z - 10,
70
+ xmax:x + 10,
71
+ zmax:z + 10
72
+ });
73
+ }
74
+ }
75
+
76
+ /**
77
+ *
78
+ * @param params
79
+ * @param params.enabled
80
+ */
81
+ this.set = function (params) {
82
+ if (params.enabled != undefined) {
83
+ node.setEnabled(params.enabled);
84
+ }
85
+ };
86
+
87
+ this._destroy = function () {
88
+ node.destroy();
89
+ };
90
+ };
91
+
92
+ function initBuildingTypes(cfg) {
93
+
94
+ if (!cfg.texturePath) {
95
+ throw "config expected: texturePath";
96
+ }
97
+
98
+ buildingTypes = [
99
+
100
+ /* Building 1
101
+ */
102
+ {
103
+ freq:50,
104
+
105
+ material:{
106
+ type:"material",
107
+ baseColor:{
108
+ r:1.0,
109
+ g:1.0,
110
+ b:1.0
111
+ },
112
+ specularColor:[ 1.0, 1.0, 1.0 ],
113
+ specular:0.4,
114
+ shine:20.0
115
+ },
116
+
117
+ texture:{
118
+ type:"texture",
119
+ coreId:"__type1",
120
+ layers:[
121
+ {
122
+ src:cfg.texturePath + "/highrise-windows.jpg",
123
+ applyTo:"baseColor",
124
+ blendMode:"multiply",
125
+ wrapS:"repeat",
126
+ wrapT:"repeat",
127
+ scale:{
128
+ x:0.04,
129
+ y:0.05
130
+ }
131
+ }
132
+ ]
133
+ },
134
+
135
+ roof:{
136
+ height:1,
137
+ material:{
138
+ type:"material",
139
+ baseColor:{
140
+ r:1.0,
141
+ g:1.0,
142
+ b:1.0
143
+ }
144
+ }
145
+ }
146
+ },
147
+
148
+ /* Building 2
149
+ */
150
+ {
151
+
152
+ freq:30,
153
+
154
+ material:{
155
+ type:"material",
156
+ baseColor:{
157
+ r:1.0,
158
+ g:1.0,
159
+ b:1.0
160
+ },
161
+ specularColor:[ 1.0, 1.0, 1.0 ],
162
+ specular:1.0,
163
+ shine:5.0
164
+ },
165
+
166
+ texture:{
167
+ type:"texture",
168
+ coreId:"__type2",
169
+ layers:[
170
+ {
171
+ src:cfg.texturePath + "/HighRiseGlass.jpg",
172
+ applyTo:"baseColor",
173
+ blendMode:"multiply",
174
+ wrapS:"repeat",
175
+ wrapT:"repeat",
176
+ scale:{
177
+ x:0.25,
178
+ y:0.2
179
+ }
180
+ },
181
+ {
182
+ src:cfg.texturePath + "/HighRiseGlassSpecular.jpg",
183
+ applyTo:"specular",
184
+ blendMode:"multiply",
185
+ wrapS:"repeat",
186
+ wrapT:"repeat",
187
+ scale:{
188
+ x:0.25,
189
+ y:0.2
190
+ }
191
+ }
192
+ ]
193
+ },
194
+
195
+ roof:{
196
+ height:1,
197
+ material:{
198
+ type:"material",
199
+ baseColor:{
200
+ r:0.4,
201
+ g:0.4,
202
+ b:0.4
203
+ }
204
+ }
205
+ }
206
+ },
207
+
208
+ /* Building 3
209
+ */
210
+ {
211
+
212
+ freq:20,
213
+
214
+ material:{
215
+ type:"material",
216
+ baseColor:{
217
+ r:1.0,
218
+ g:1.0,
219
+ b:1.0
220
+ },
221
+ specularColor:[ 1.0, 1.0, 1.0 ],
222
+ specular:0.4,
223
+ shine:20.0
224
+ },
225
+
226
+ texture:{
227
+ type:"texture",
228
+ coreId:"__type3",
229
+ layers:[
230
+ {
231
+ src:cfg.texturePath + "/pixelcity_windows7.jpg",
232
+ applyTo:"baseColor",
233
+ blendMode:"multiply",
234
+ wrapS:"repeat",
235
+ wrapT:"repeat",
236
+ scale:{
237
+ x:0.015,
238
+ y:0.01
239
+ }
240
+ }
241
+ ]
242
+ },
243
+
244
+ roof:{
245
+ height:1,
246
+ material:{
247
+ type:"material",
248
+ baseColor:{
249
+ r:0.0,
250
+ g:0.0,
251
+ b:0.0
252
+ }
253
+ }
254
+ }
255
+ }
256
+ ];
257
+ }
258
+
259
+ function selectBuildingType() {
260
+
261
+ var n = Math.round(Math.random() * 100);
262
+ var type;
263
+ var min = 0;
264
+ var max;
265
+
266
+ for (var i = 0, len = buildingTypes.length; i < len; i++) {
267
+
268
+ type = buildingTypes[i];
269
+ max = min + type.freq;
270
+
271
+ if (min <= n && n <= max) {
272
+ buildingType = type;
273
+ return;
274
+ }
275
+
276
+ min = max
277
+ }
278
+
279
+ buildingType = buildingTypes[0];
280
+ }
281
+
282
+
283
+ function addBuilding(node, footprint) {
284
+
285
+ var xpos = (footprint.xmin + footprint.xmax) * 0.5;
286
+ var ypos = 0;
287
+ var zpos = (footprint.zmin + footprint.zmax) * 0.5;
288
+
289
+ /* Base
290
+ */
291
+
292
+ var baseWidth = 0.6;
293
+
294
+ addBase(node,
295
+ xpos, zpos,
296
+ footprint.xmax - footprint.xmin,
297
+ baseWidth / 2,
298
+ footprint.zmax - footprint.zmin);
299
+
300
+ var xmin;
301
+ var ymin;
302
+ var zmin;
303
+ var xmax;
304
+ var ymax;
305
+ var zmax;
306
+
307
+ var width;
308
+ var axis;
309
+ var sign;
310
+
311
+ var yMaxSize = (Math.random() * 30) + 15;
312
+ var ySize = yMaxSize + baseWidth;
313
+
314
+ while (ySize > 5) {
315
+
316
+ width = (Math.random() * 3) + 2;
317
+
318
+ axis = Math.round(Math.random());
319
+ sign = Math.round(Math.random());
320
+
321
+ ymin = baseWidth;
322
+ ymax = ySize;
323
+
324
+ switch (axis) {
325
+
326
+ case 0:
327
+
328
+ if (sign == 0) {
329
+
330
+ xmin = footprint.xmin;
331
+ zmin = zpos - width;
332
+
333
+ xmax = xpos + width;
334
+ zmax = zpos + width;
335
+
336
+ } else {
337
+
338
+ xmin = xpos - width;
339
+ zmin = zpos - width;
340
+
341
+ xmax = footprint.xmax;
342
+ zmax = zpos + width;
343
+ }
344
+
345
+ break;
346
+
347
+ case 1:
348
+
349
+
350
+ if (sign == 0) {
351
+
352
+ xmin = xpos - width;
353
+ zmin = footprint.zmin;
354
+
355
+ xmax = xpos + width;
356
+ zmax = zpos + width;
357
+
358
+ } else {
359
+
360
+ xmin = xpos - width;
361
+ zmin = zpos - width;
362
+
363
+ xmax = xpos + width;
364
+ zmax = footprint.zmax;
365
+ }
366
+
367
+ break;
368
+ }
369
+
370
+ addBox(node,
371
+ (xmin + xmax) * 0.5,
372
+ ySize + baseWidth,
373
+ (zmin + zmax) * 0.5,
374
+
375
+ xmax - xmin,
376
+ ySize,
377
+ zmax - zmin);
378
+
379
+ ySize -= (Math.random() * 5) + 2;
380
+ }
381
+ }
382
+
383
+
384
+ function addBase(node, xpos, zpos, xsize, ysize, zsize) {
385
+
386
+ node.addNode({
387
+ type:"translate",
388
+ x:xpos,
389
+ y:ysize,
390
+ z:zpos,
391
+
392
+ nodes:[
393
+ {
394
+ type:"material",
395
+ baseColor:{
396
+ r:0.6, g:.6, b:0.6
397
+ },
398
+ nodes:[
399
+ {
400
+ type:"geometry",
401
+ source:{
402
+ type:"box",
403
+ xSize:xsize,
404
+ ySize:ysize,
405
+ zSize:zsize
406
+ }
407
+ }
408
+ ]
409
+ }
410
+ ]
411
+ });
412
+
413
+ }
414
+
415
+ function addBox(node, xpos, ypos, zpos, xsize, ysize, zsize) {
416
+
417
+ /* Roof cap
418
+ */
419
+ node.addNode(buildingType.roof.material)
420
+ .addNode({
421
+ type:"translate",
422
+ x:xpos,
423
+ y:ypos + ysize + buildingType.roof.height,
424
+ z:zpos
425
+ })
426
+ .addNode({
427
+ type:"geometry",
428
+ source:{
429
+ type:"box",
430
+ xSize:xsize,
431
+ ySize:buildingType.roof.height,
432
+ zSize:zsize
433
+ }
434
+ });
435
+
436
+ /* Body with texture
437
+ */
438
+ node.addNode(buildingType.material)// Current material
439
+ .addNode(buildingType.texture)// Current texture
440
+ .addNode({
441
+ type:"translate",
442
+ x:xpos,
443
+ y:ypos,
444
+ z:zpos
445
+ })
446
+ .addNode({
447
+ type:"geometry",
448
+ source:{
449
+ type:"box",
450
+ xSize:xsize,
451
+ ySize:ysize,
452
+ zSize:zsize
453
+ }
454
+ });
455
+ }
456
+ };
457
+