Skip to content
Browse files

Resize textures to be power of two

  • Loading branch information...
1 parent 2415e7e commit 24b6d43799d839d44910ccab41e7da25a21fd7ec @iain committed Jul 8, 2012
View
1 Gemfile
@@ -4,3 +4,4 @@ ruby "1.9.3"
gem 'middleman'
gem 'nokogiri'
+gem 'mini_magick'
View
4 Gemfile.lock
@@ -64,6 +64,8 @@ GEM
uglifier (~> 1.2)
middleman-livereload (0.2.2)
guard-livereload (~> 1.0)
+ mini_magick (3.4)
+ subexec (~> 0.2.1)
multi_json (1.3.6)
nokogiri (1.5.5)
padrino-core (0.10.6)
@@ -97,6 +99,7 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
+ subexec (0.2.2)
syntax (1.0.0)
temple (0.3.5)
thin (1.2.11)
@@ -116,4 +119,5 @@ PLATFORMS
DEPENDENCIES
middleman
+ mini_magick
nokogiri
View
16 lib/convert_collada.rb
@@ -7,6 +7,7 @@
require 'digest'
require 'pathname'
require 'fileutils'
+require 'mini_magick'
require_relative 'collada'
class ConvertCollada
@@ -27,6 +28,21 @@ def convert
mkdir_p destination
write_json
copy_files
+ resize_textures
+ end
+
+ # Resizing images to be a square and the dimensions to be a power of 2,
+ # because WebGL doesn't support other sizes.
+ # NB: this means that the key isn't the real MD5 hash anymore.
+ def resize_textures
+ data[:textures].each_value do |image|
+ target = destination.join(image)
+ image = MiniMagick::Image.open(target)
+ size = [ image[:width], image[:height] ].min
+ size = 2 ** Math.log(size, 2).floor
+ image.resize "#{size}x#{size}!"
+ image.write target.to_s
+ end
end
def write_json
View
159 models/cubism.dae
@@ -4,8 +4,8 @@
<contributor>
<authoring_tool>Google SketchUp 8.0.14345</authoring_tool>
</contributor>
- <created>2012-07-07T19:17:50Z</created>
- <modified>2012-07-07T19:17:50Z</modified>
+ <created>2012-07-07T22:25:27Z</created>
+ <modified>2012-07-07T22:25:27Z</modified>
<unit meter="0.0254000" name="inch" />
<up_axis>Z_UP</up_axis>
</asset>
@@ -24,16 +24,7 @@
<instance_geometry url="#ID15">
<bind_material>
<technique_common>
- <instance_material symbol="Material2" target="#ID16">
- <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <instance_geometry url="#ID28">
- <bind_material>
- <technique_common>
- <instance_material symbol="Material2" target="#ID29">
+ <instance_material symbol="Material2" target="#ID3">
<bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" />
</instance_material>
</technique_common>
@@ -46,29 +37,29 @@
<geometry id="ID2">
<mesh>
<source id="ID8">
- <float_array id="ID12" count="60">-6.1960478 25.2630123 74.0157480 -156.9834493 25.2630123 0.0000000 -6.1960478 25.2630123 0.0000000 -156.9834493 25.2630123 74.0157480 -6.1960478 169.3575005 0.0000000 -156.9834493 25.2630123 0.0000000 -156.9834493 169.3575005 0.0000000 -6.1960478 25.2630123 0.0000000 -6.1960478 169.3575005 0.0000000 -6.1960478 25.2630123 74.0157480 -6.1960478 25.2630123 0.0000000 -6.1960478 169.3575005 74.0157480 -6.1960478 25.2630123 74.0157480 -156.9834493 169.3575005 74.0157480 -156.9834493 25.2630123 74.0157480 -6.1960478 169.3575005 74.0157480 -156.9834493 169.3575005 74.0157480 -156.9834493 25.2630123 0.0000000 -156.9834493 25.2630123 74.0157480 -156.9834493 169.3575005 0.0000000</float_array>
+ <float_array id="ID12" count="72">-6.1960478 25.2630123 74.0157480 -156.9834493 25.2630123 0.0000000 -6.1960478 25.2630123 0.0000000 -156.9834493 25.2630123 74.0157480 -6.1960478 169.3575005 0.0000000 -156.9834493 25.2630123 0.0000000 -156.9834493 169.3575005 0.0000000 -6.1960478 25.2630123 0.0000000 -6.1960478 169.3575005 0.0000000 -6.1960478 25.2630123 74.0157480 -6.1960478 25.2630123 0.0000000 -6.1960478 169.3575005 74.0157480 -6.1960478 25.2630123 74.0157480 -156.9834493 169.3575005 74.0157480 -156.9834493 25.2630123 74.0157480 -6.1960478 169.3575005 74.0157480 -156.9834493 169.3575005 74.0157480 -156.9834493 25.2630123 0.0000000 -156.9834493 25.2630123 74.0157480 -156.9834493 169.3575005 0.0000000 -156.9834493 169.3575005 74.0157480 -6.1960478 169.3575005 0.0000000 -156.9834493 169.3575005 0.0000000 -6.1960478 169.3575005 74.0157480</float_array>
<technique_common>
- <accessor count="20" source="#ID12" stride="3">
+ <accessor count="24" source="#ID12" stride="3">
<param name="X" type="float" />
<param name="Y" type="float" />
<param name="Z" type="float" />
</accessor>
</technique_common>
</source>
<source id="ID9">
- <float_array id="ID13" count="60">-0.0000000 -1.0000000 -0.0000000 -0.0000000 -1.0000000 -0.0000000 -0.0000000 -1.0000000 -0.0000000 -0.0000000 -1.0000000 -0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000</float_array>
+ <float_array id="ID13" count="72">-0.0000000 -1.0000000 -0.0000000 -0.0000000 -1.0000000 -0.0000000 -0.0000000 -1.0000000 -0.0000000 -0.0000000 -1.0000000 -0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 1.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -0.0000000 1.0000000 0.0000000 -0.0000000 1.0000000 0.0000000 -0.0000000 1.0000000 0.0000000 -0.0000000 1.0000000 0.0000000</float_array>
<technique_common>
- <accessor count="20" source="#ID13" stride="3">
+ <accessor count="24" source="#ID13" stride="3">
<param name="X" type="float" />
<param name="Y" type="float" />
<param name="Z" type="float" />
</accessor>
</technique_common>
</source>
<source id="ID11">
- <float_array id="ID14" count="40">-0.6196048 7.4015748 -15.6983449 0.0000000 -0.6196048 0.0000000 -15.6983449 7.4015748 0.6196048 16.9357500 15.6983449 2.5263012 15.6983449 16.9357500 0.6196048 2.5263012 16.9357500 0.0000000 2.5263012 7.4015748 2.5263012 0.0000000 16.9357500 7.4015748 -0.6196048 2.5263012 -15.6983449 16.9357500 -15.6983449 2.5263012 -0.6196048 16.9357500 -16.9357500 7.4015748 -2.5263012 0.0000000 -2.5263012 7.4015748 -16.9357500 0.0000000</float_array>
+ <float_array id="ID14" count="48">-0.0737625 0.8811399 -1.8688506 0.0000000 -0.0737625 0.0000000 -1.8688506 0.8811399 0.0737625 2.0161607 1.8688506 0.3007501 1.8688506 2.0161607 0.0737625 0.3007501 2.0161607 0.0000000 0.3007501 0.8811399 0.3007501 0.0000000 2.0161607 0.8811399 -0.0737625 0.3007501 -1.8688506 2.0161607 -1.8688506 0.3007501 -0.0737625 2.0161607 -2.0161607 0.8811399 -0.3007501 0.0000000 -0.3007501 0.8811399 -2.0161607 0.0000000 1.8688506 0.8811399 0.0737625 0.0000000 1.8688506 0.0000000 0.0737625 0.8811399</float_array>
<technique_common>
- <accessor count="20" source="#ID14" stride="2">
+ <accessor count="24" source="#ID14" stride="2">
<param name="S" type="float" />
<param name="T" type="float" />
</accessor>
@@ -78,108 +69,60 @@
<input semantic="POSITION" source="#ID8" />
<input semantic="NORMAL" source="#ID9" />
</vertices>
- <triangles count="10" material="Material2">
+ <triangles count="12" material="Material2">
<input offset="0" semantic="VERTEX" source="#ID10" />
<input offset="1" semantic="TEXCOORD" source="#ID11" />
- <p>0 0 1 1 2 2 1 1 0 0 3 3 4 4 5 5 6 6 5 5 4 4 7 7 8 8 9 9 10 10 9 9 8 8 11 11 12 12 13 13 14 14 13 13 12 12 15 15 16 16 17 17 18 18 17 17 16 16 19 19</p>
+ <p>0 0 1 1 2 2 1 1 0 0 3 3 4 4 5 5 6 6 5 5 4 4 7 7 8 8 9 9 10 10 9 9 8 8 11 11 12 12 13 13 14 14 13 13 12 12 15 15 16 16 17 17 18 18 17 17 16 16 19 19 20 20 21 21 22 22 21 21 20 20 23 23</p>
</triangles>
</mesh>
</geometry>
<geometry id="ID15">
<mesh>
- <source id="ID21">
- <float_array id="ID25" count="12">-156.9834493 169.3575005 74.0157480 -6.1960478 169.3575005 0.0000000 -156.9834493 169.3575005 0.0000000 -6.1960478 169.3575005 74.0157480</float_array>
- <technique_common>
- <accessor count="4" source="#ID25" stride="3">
- <param name="X" type="float" />
- <param name="Y" type="float" />
- <param name="Z" type="float" />
- </accessor>
- </technique_common>
- </source>
- <source id="ID22">
- <float_array id="ID26" count="12">-0.0000000 1.0000000 0.0000000 -0.0000000 1.0000000 0.0000000 -0.0000000 1.0000000 0.0000000 -0.0000000 1.0000000 0.0000000</float_array>
- <technique_common>
- <accessor count="4" source="#ID26" stride="3">
- <param name="X" type="float" />
- <param name="Y" type="float" />
- <param name="Z" type="float" />
- </accessor>
- </technique_common>
- </source>
- <source id="ID24">
- <float_array id="ID27" count="8">3.2704885 1.5419948 0.1290843 0.0000000 3.2704885 0.0000000 0.1290843 1.5419948</float_array>
- <technique_common>
- <accessor count="4" source="#ID27" stride="2">
- <param name="S" type="float" />
- <param name="T" type="float" />
- </accessor>
- </technique_common>
- </source>
- <vertices id="ID23">
- <input semantic="POSITION" source="#ID21" />
- <input semantic="NORMAL" source="#ID22" />
- </vertices>
- <triangles count="2" material="Material2">
- <input offset="0" semantic="VERTEX" source="#ID23" />
- <input offset="1" semantic="TEXCOORD" source="#ID24" />
- <p>0 0 1 1 2 2 1 1 0 0 3 3</p>
- </triangles>
- </mesh>
- </geometry>
- <geometry id="ID28">
- <mesh>
- <source id="ID34">
- <float_array id="ID38" count="72">81.7977631 278.4485387 97.6377953 -68.9896385 422.5430269 97.6377953 -68.9896385 278.4485387 97.6377953 81.7977631 422.5430269 97.6377953 81.7977631 278.4485387 97.6377953 -68.9896385 278.4485387 23.6220472 81.7977631 278.4485387 23.6220472 -68.9896385 278.4485387 97.6377953 81.7977631 422.5430269 23.6220472 81.7977631 278.4485387 97.6377953 81.7977631 278.4485387 23.6220472 81.7977631 422.5430269 97.6377953 -68.9896385 422.5430269 97.6377953 81.7977631 422.5430269 23.6220472 -68.9896385 422.5430269 23.6220472 81.7977631 422.5430269 97.6377953 -68.9896385 422.5430269 97.6377953 -68.9896385 278.4485387 23.6220472 -68.9896385 278.4485387 97.6377953 -68.9896385 422.5430269 23.6220472 81.7977631 422.5430269 23.6220472 -68.9896385 278.4485387 23.6220472 -68.9896385 422.5430269 23.6220472 81.7977631 278.4485387 23.6220472</float_array>
+ <source id="ID16">
+ <float_array id="ID20" count="72">15.3316039 296.5905943 97.6377953 -135.4557977 440.6850825 97.6377953 -135.4557977 296.5905943 97.6377953 15.3316039 440.6850825 97.6377953 15.3316039 296.5905943 97.6377953 -135.4557977 296.5905943 23.6220472 15.3316039 296.5905943 23.6220472 -135.4557977 296.5905943 97.6377953 15.3316039 440.6850825 23.6220472 15.3316039 296.5905943 97.6377953 15.3316039 296.5905943 23.6220472 15.3316039 440.6850825 97.6377953 -135.4557977 440.6850825 97.6377953 15.3316039 440.6850825 23.6220472 -135.4557977 440.6850825 23.6220472 15.3316039 440.6850825 97.6377953 -135.4557977 440.6850825 97.6377953 -135.4557977 296.5905943 23.6220472 -135.4557977 296.5905943 97.6377953 -135.4557977 440.6850825 23.6220472 15.3316039 440.6850825 23.6220472 -135.4557977 296.5905943 23.6220472 -135.4557977 440.6850825 23.6220472 15.3316039 296.5905943 23.6220472</float_array>
<technique_common>
- <accessor count="24" source="#ID38" stride="3">
+ <accessor count="24" source="#ID20" stride="3">
<param name="X" type="float" />
<param name="Y" type="float" />
<param name="Z" type="float" />
</accessor>
</technique_common>
</source>
- <source id="ID35">
- <float_array id="ID39" count="72">-0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000</float_array>
+ <source id="ID17">
+ <float_array id="ID21" count="72">-0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000</float_array>
<technique_common>
- <accessor count="24" source="#ID39" stride="3">
+ <accessor count="24" source="#ID21" stride="3">
<param name="X" type="float" />
<param name="Y" type="float" />
<param name="Z" type="float" />
</accessor>
</technique_common>
</source>
- <source id="ID37">
- <float_array id="ID40" count="48">-0.6196048 2.5263012 -15.6983449 16.9357500 -15.6983449 2.5263012 -0.6196048 16.9357500 -0.6196048 7.4015748 -15.6983449 0.0000000 -0.6196048 0.0000000 -15.6983449 7.4015748 16.9357500 0.0000000 2.5263012 7.4015748 2.5263012 0.0000000 16.9357500 7.4015748 15.6983449 7.4015748 0.6196048 0.0000000 15.6983449 0.0000000 0.6196048 7.4015748 -16.9357500 7.4015748 -2.5263012 0.0000000 -2.5263012 7.4015748 -16.9357500 0.0000000 0.6196048 16.9357500 15.6983449 2.5263012 15.6983449 16.9357500 0.6196048 2.5263012</float_array>
+ <source id="ID19">
+ <float_array id="ID22" count="48">0.1825191 3.5308404 -1.6125690 5.2462510 -1.6125690 3.5308404 0.1825191 5.2462510 0.1825191 1.1623547 -1.6125690 0.2812148 0.1825191 0.2812148 -1.6125690 1.1623547 5.2462510 0.2812148 3.5308404 1.1623547 3.5308404 0.2812148 5.2462510 1.1623547 1.6125690 1.1623547 -0.1825191 0.2812148 1.6125690 0.2812148 -0.1825191 1.1623547 -5.2462510 1.1623547 -3.5308404 0.2812148 -3.5308404 1.1623547 -5.2462510 0.2812148 -0.1825191 5.2462510 1.6125690 3.5308404 1.6125690 5.2462510 -0.1825191 3.5308404</float_array>
<technique_common>
- <accessor count="24" source="#ID40" stride="2">
+ <accessor count="24" source="#ID22" stride="2">
<param name="S" type="float" />
<param name="T" type="float" />
</accessor>
</technique_common>
</source>
- <vertices id="ID36">
- <input semantic="POSITION" source="#ID34" />
- <input semantic="NORMAL" source="#ID35" />
+ <vertices id="ID18">
+ <input semantic="POSITION" source="#ID16" />
+ <input semantic="NORMAL" source="#ID17" />
</vertices>
<triangles count="12" material="Material2">
- <input offset="0" semantic="VERTEX" source="#ID36" />
- <input offset="1" semantic="TEXCOORD" source="#ID37" />
+ <input offset="0" semantic="VERTEX" source="#ID18" />
+ <input offset="1" semantic="TEXCOORD" source="#ID19" />
<p>0 0 1 1 2 2 1 1 0 0 3 3 4 4 5 5 6 6 5 5 4 4 7 7 8 8 9 9 10 10 9 9 8 8 11 11 12 12 13 13 14 14 13 13 12 12 15 15 16 16 17 17 18 18 17 17 16 16 19 19 20 20 21 21 22 22 21 21 20 20 23 23</p>
</triangles>
</mesh>
</geometry>
</library_geometries>
<library_materials>
- <material id="ID3" name="Stone_Granite_Midnite_">
+ <material id="ID3" name="Stone_Coursed_Rough_">
<instance_effect url="#ID4" />
</material>
- <material id="ID16" name="Stone_Flagstone_Ashlar_">
- <instance_effect url="#ID17" />
- </material>
- <material id="ID29" name="__Stone_Granite_Midnite_1">
- <instance_effect url="#ID30" />
- </material>
</library_materials>
<library_effects>
<effect id="ID4">
@@ -203,58 +146,10 @@
</technique>
</profile_COMMON>
</effect>
- <effect id="ID17">
- <profile_COMMON>
- <newparam sid="ID19">
- <surface type="2D">
- <init_from>ID18</init_from>
- </surface>
- </newparam>
- <newparam sid="ID20">
- <sampler2D>
- <source>ID19</source>
- </sampler2D>
- </newparam>
- <technique sid="COMMON">
- <lambert>
- <diffuse>
- <texture texture="ID20" texcoord="UVSET0" />
- </diffuse>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
- <effect id="ID30">
- <profile_COMMON>
- <newparam sid="ID32">
- <surface type="2D">
- <init_from>ID31</init_from>
- </surface>
- </newparam>
- <newparam sid="ID33">
- <sampler2D>
- <source>ID32</source>
- </sampler2D>
- </newparam>
- <technique sid="COMMON">
- <lambert>
- <diffuse>
- <texture texture="ID33" texcoord="UVSET0" />
- </diffuse>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
</library_effects>
<library_images>
<image id="ID5">
- <init_from>cubism/Stone_Granite_Midnite_.jpg</init_from>
- </image>
- <image id="ID18">
- <init_from>cubism/Stone_Flagstone_Ashlar_.jpg</init_from>
- </image>
- <image id="ID31">
- <init_from>cubism/__Stone_Granite_Midnite_1.jpg</init_from>
+ <init_from>cubism/Stone_Coursed_Rough_.jpg</init_from>
</image>
</library_images>
<scene>
View
BIN models/cubism.skp
Binary file not shown.
View
BIN models/cubism/Stone_Coursed_Rough_.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN models/cubism/Stone_Masonry_Multi_.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN models/cubism/Stone_Pavers_Flagstone_Gray_.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 source/javascripts/gl_extend.js.coffee
@@ -79,6 +79,8 @@
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.image)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST)
+ # gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
+ # gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
gl.generateMipmap(gl.TEXTURE_2D)
gl.bindTexture(gl.TEXTURE_2D, null)
View
8 source/javascripts/sketchup.js.coffee
@@ -1,13 +1,14 @@
class Sketchup
constructor: ->
@textureBuffers = {}
+ @buffered = false
draw: ->
- @drawObject(geometry) for geometry in @data.geometries
- # @drawObject(@data[0])
+ if @buffered
+ @drawObject(geometry) for geometry in @data.geometries
buffer: ->
- $.getJSON('models/cubism.json', @handleData )
+ $.getJSON("models/cubism.json?_#{(new Date).getTime()}", @handleData )
# @data = window.loaded_objects.scene
# @textures = window.loaded_objects.textures
@@ -18,6 +19,7 @@ class Sketchup
@data = data
@initTextures(data.textures)
@bufferObject(geometry) for geometry in data.geometries
+ @buffered = true
drawObject: (data) ->
gl.bindBuffer(gl.ARRAY_BUFFER, data.vertexPositionBuffer)
View
34 source/javascripts/walker.js.coffee
@@ -20,7 +20,7 @@ class Walker
@models = []
- @models[0] = new window.Sketchup
+ @models.push new window.Sketchup
if gl
gl.clearColor(0.0, 0.0, 0.0, 1.0) # Clear to black, fully opaque
@@ -31,30 +31,27 @@ class Walker
gl.initShaders()
# @initBuffers(gl)
- model.buffer() for model in @models
-
+ for model in @models
+ model.buffer()
@start()
start: ->
- setInterval(@drawLoop, 15, @)
-
- drawLoop: (scope) ->
- scope.drawScene()
+ setInterval(@drawScene, 15)
- handleMouseDown: (event) ->
- window.walker.startMoveCamera([event.x, event.y])
+ handleMouseDown: (event) =>
+ @startMoveCamera([event.x, event.y])
- handleMouseUp: (event) ->
- window.walker.endMoveCamera()
+ handleMouseUp: (event) =>
+ @endMoveCamera()
- handleMouseMove: (event) ->
- window.walker.moveCamera([event.x, event.y])
+ handleMouseMove: (event) =>
+ @moveCamera([event.x, event.y])
- handleKeyDown: (event) ->
- window.walker.currentlyPressedKeys[event.keyCode] = true
+ handleKeyDown: (event) =>
+ @currentlyPressedKeys[event.keyCode] = true
- handleKeyUp: (event) ->
- window.walker.currentlyPressedKeys[event.keyCode] = false
+ handleKeyUp: (event) =>
+ @currentlyPressedKeys[event.keyCode] = false
startMoveCamera: (pos) ->
@clicked = true
@@ -90,8 +87,7 @@ class Walker
return (((new Date).getTime() - @currentTime) / 1000)
- drawScene: ->
- # this = scope
+ drawScene: =>
@handleKeys()
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

0 comments on commit 24b6d43

Please sign in to comment.
Something went wrong with that request. Please try again.