├── .gitignore ├── README.md ├── build ├── npos3d.js └── npos3d.min.js ├── prelim_tests ├── 10_plus_config_object_passing_and_basic_sprite_animation.html ├── 11_plus_shape_shatter.html ├── 11_plus_shape_shatter_lols.html ├── 12_plus_vector_font.html ├── 12_plus_vector_font_demo.html ├── 1_first_3d_attempt.html ├── 2_second_3d_attempt.html ├── 3_plus_rotation.html ├── 4_plus_sprites.html ├── 5_plus_rotation_caching_and_omg_the_grid.html ├── 6_plus_bounding_box_calculation_and_caching_for_culling.html ├── 7_plus_better_bb_calc_and_line_intersection_and_bbhit_and_interpolation_and_cleanup.html ├── 8_plus_scaling_and_rotation_order_and_first_attempt_game_basics.html ├── 9_plus_mouse_ship_control.html ├── Car.obj ├── Stats.js ├── all_objects.blend ├── basic_shapes.blend ├── basic_shapes.mtl ├── basic_shapes.obj ├── basic_shapes_edges.obj ├── battlegirl_objects.blend ├── bots.mtl ├── bots.obj ├── canvas_first_3d_attempt_front.png ├── canvas_first_3d_attempt_side.png ├── convert_obj_to_font.html ├── convert_obj_to_shape.html ├── convert_obj_to_shape.php ├── horus.html ├── horus_model.obj ├── horus_rotation.html ├── levels.mtl ├── levels.obj ├── nyan-sprite.png ├── snake_creature.blend ├── sprites │ ├── megaman_heart_sprite.png │ ├── megaman_heart_sprite_2x.png │ ├── megaman_heart_sprite_4x.png │ └── nyan-sprite.png ├── trons.obj ├── vector_font.blend ├── vector_font.mtl ├── vector_font.obj └── vector_font_m_w.obj ├── src ├── core.js ├── font.js ├── fx.explosion.js ├── fx.tween.js ├── geom.circle.js ├── geom.lathe.js ├── geom.pn3.js ├── geom.sphere.js ├── geom.twist.js ├── layout.js ├── sprite.js └── utils.color.js ├── tests ├── basic_scene.html ├── cached_vert_position.html ├── camera_movement.html ├── circles.html ├── destroy.html ├── draw_points.html ├── existing_canvas.html ├── explosion.html ├── img │ ├── 3px.png │ ├── 4x4.png │ ├── adam.png │ ├── adam.psd │ ├── bw_grad.png │ ├── bw_grad.psd │ ├── dexter.png │ ├── h.gif │ ├── heart.png │ ├── heart_sort.png │ ├── heartsub.png │ ├── heartsub_100.jpg │ ├── heartsub_50.jpg │ ├── heartsub_51.jpg │ ├── heartsub_60.jpg │ ├── heartsub_70.jpg │ ├── heartsub_80.jpg │ ├── heartsub_90.jpg │ ├── heartsub_anim.png │ ├── heartsub_anim.psd │ ├── heartsub_anim_360.png │ ├── heartsub_anim_360.psd │ ├── hole_16.png │ ├── hole_16.psd │ ├── hv.gif │ ├── hv.psd │ ├── intersphere.png │ ├── meg.png │ ├── meg.psd │ ├── megface.png │ ├── megface.psd │ ├── noise_spectrum_16.png │ ├── noise_spectrum_32.png │ ├── rupee.png │ ├── rupeebev.png │ ├── spectrum_128.psd │ ├── spectrum_16.jpg │ ├── spectrum_16.png │ ├── spectrum_16.psd │ ├── spectrum_24.png │ ├── spectrum_24.psd │ ├── spectrum_24_hue.png │ ├── spectrum_24_luminosity.png │ ├── spectrum_32.png │ ├── spectrum_anim_360.png │ ├── spectrum_anim_360.psd │ ├── spectrum_limited_16.png │ ├── spectrum_linear_128.png │ ├── spectrum_linear_128.psd │ ├── spectrum_wtf_anim_360.psd │ ├── sphere2.png │ ├── sphere3.png │ ├── sphere3.psd │ ├── swinj_gold_tooth.png │ ├── swinj_gold_tooth_4x.png │ ├── swinj_green_hat_sprite.png │ ├── swinj_green_hat_sprite_4x.png │ └── v.gif ├── lathe.html ├── lathe_twist.html ├── layout.html ├── mat4_basics.html ├── models │ ├── berk.obj │ ├── demon_puppy_a.obj │ ├── diamond.obj │ ├── diamond_rounded.obj │ ├── dinosaur_2_v7.obj │ ├── eyeguy_3.obj │ ├── eyeguy_3_hi.obj │ ├── interesting_shape.blend │ ├── interesting_shape.obj │ ├── meg.blend │ ├── meg.obj │ ├── obj_content.blend │ ├── pn3_test_shapes.blend │ ├── pn3_test_shapes.obj │ ├── shade_3.obj │ ├── time_flies_00.obj │ ├── trents_devil_guy_v14_posed_singleshape.obj │ └── whats_up.obj ├── parenting.html ├── particle_toy.html ├── particle_toy_1.html ├── pixel_scale.html ├── pn3_files │ ├── demonpuppy.png │ ├── shade.png │ └── trents_devilguy.png ├── pn3_idea_test.html ├── pn3_image_manip_toy.html ├── pn3_sprite_anim.html ├── pn3_what_does_jpeg_do.html ├── point_at.html ├── point_format_test.html ├── point_format_test.js ├── polyshape.svg ├── polyshape_open.svg ├── rotation_order.html ├── text_cycler.html ├── tween.html ├── twist.html ├── utils_color_unit_tests.html └── vec3min.js ├── tools ├── convert_obj_to_pn3.php ├── convert_obj_to_shape.js └── pn3_loader.php └── utils └── build ├── build.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | tests/img/heartsub_anim.aep 3 | 4 | tests/img/heartsub_anim.mov 5 | 6 | npos3d.iml 7 | 8 | .idea 9 | 10 | node_modules -------------------------------------------------------------------------------- /prelim_tests/1_first_3d_attempt.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 25 | 26 | 255 | -------------------------------------------------------------------------------- /prelim_tests/Car.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.54 (sub 0) OBJ File: 'Car.blend' 2 | # www.blender.org 3 | mtllib Car.mtl 4 | o Plane 5 | v 2.163921 -0.725157 -3.724300 6 | v -2.163921 -0.725157 -3.724300 7 | v 2.121930 -0.807697 2.150446 8 | v -2.121930 -0.807697 2.150446 9 | v 2.096745 -0.150843 -3.501182 10 | v -2.096745 -0.150843 -3.501182 11 | v 2.094168 -0.206014 2.317057 12 | v -2.094168 -0.206014 2.317057 13 | v 2.109602 -0.192432 -2.186362 14 | v -2.109602 -0.192432 -2.186362 15 | v 2.118498 -0.790806 -2.015423 16 | v -2.118498 -0.790806 -2.015423 17 | v 2.120975 0.141685 -3.109049 18 | v -2.120975 0.141685 -3.109049 19 | v 2.135267 0.128766 2.669049 20 | v -2.135267 0.128766 2.669049 21 | v 1.696101 -0.708369 -4.669006 22 | v -1.696101 -0.708369 -4.669006 23 | v 1.688386 1.001493 -4.782826 24 | v -1.688386 1.001493 -4.782826 25 | v 1.795827 1.103931 -3.866575 26 | v -1.795827 1.103931 -3.866575 27 | v 1.174411 1.701487 -2.472279 28 | v -1.174411 1.701487 -2.472279 29 | v 0.991161 1.832380 -1.777977 30 | v -0.991161 1.832380 -1.777977 31 | v 1.174411 1.720575 0.437148 32 | v -1.174411 1.720575 0.437148 33 | v 1.641521 0.785235 2.325236 34 | v -1.641521 0.785235 2.325236 35 | v 1.863398 0.466539 4.237413 36 | v -1.863398 0.466539 4.237413 37 | v 1.962378 0.250281 4.590256 38 | v -1.962378 0.250281 4.590256 39 | v 1.987746 -0.159471 4.783750 40 | v -1.987746 -0.159471 4.783750 41 | v 1.955023 -0.875932 4.656412 42 | v -1.955023 -0.875932 4.656412 43 | v 2.160875 -0.863451 3.742296 44 | v -2.160875 -0.863451 3.742296 45 | v 2.132911 -0.200997 3.573371 46 | v -2.132911 -0.200997 3.573371 47 | v 2.167342 0.138087 3.207874 48 | v -2.167342 0.138087 3.207874 49 | v 1.454195 1.019070 1.853214 50 | v -1.454195 1.019070 1.853214 51 | v 1.270233 1.554329 0.161346 52 | v -1.270233 1.554329 0.161346 53 | v 1.270233 1.672192 -0.814506 54 | v -1.270233 1.672192 -0.814506 55 | v 1.270233 1.610935 -1.707063 56 | v -1.270233 1.610935 -1.707063 57 | v 1.647557 0.734803 1.675746 58 | v -1.647557 0.734803 1.675746 59 | v 2.116716 -0.791832 -0.582518 60 | v -2.116716 -0.791832 -0.582518 61 | v 1.270233 1.662375 -0.920427 62 | v -1.270233 1.662375 -0.920427 63 | v 1.621475 0.828351 -0.634893 64 | v -1.621475 0.828351 -0.634893 65 | v 1.621736 0.831204 -0.796079 66 | v -1.621736 0.831204 -0.796079 67 | v 1.620911 0.920407 -2.303669 68 | v -1.620911 0.920407 -2.303669 69 | v -0.000000 0.133045 -2.515304 70 | v -0.000000 -0.218867 -2.125076 71 | v -0.000000 -0.847338 -1.939744 72 | v -0.000000 0.141451 -3.122649 73 | v -0.000000 -0.174016 -3.546609 74 | v -0.000000 -0.800494 -3.787315 75 | v 0.000000 -0.236681 2.322122 76 | v 0.000000 0.123507 2.712921 77 | v -0.000000 -0.782389 -5.036030 78 | v -0.000000 1.061554 -5.158776 79 | v -0.000000 1.172025 -4.170675 80 | v -0.000000 1.816439 -2.667044 81 | v -0.000000 1.957596 -1.918296 82 | v -0.000000 1.837024 0.470531 83 | v 0.000000 0.828339 2.506677 84 | v 0.000000 0.484651 4.568801 85 | v 0.000000 0.251435 4.949312 86 | v 0.000000 -0.190449 5.157979 87 | v 0.000000 -0.963092 5.020656 88 | v 0.000000 -0.949632 3.863158 89 | v 0.000000 -0.225727 3.672991 90 | v 0.000000 0.133560 3.293998 91 | v -0.000000 0.294856 -5.097403 92 | v 0.000000 1.022435 1.858261 93 | v 2.117221 -0.791117 -0.767342 94 | v -2.117221 -0.791117 -0.767342 95 | v 2.122195 -0.806670 1.818529 96 | v -2.122195 -0.806670 1.818529 97 | v 0.884136 -0.218867 -2.125076 98 | v -0.884136 -0.218867 -2.125076 99 | v 0.881805 0.133045 -2.515304 100 | v -0.881805 0.133045 -2.515304 101 | v 0.884852 -0.802300 -1.939744 102 | v -0.884852 -0.802300 -1.939744 103 | v 0.881805 0.141451 -3.122649 104 | v -0.881805 0.141451 -3.122649 105 | v 0.877204 -0.174016 -3.546609 106 | v -0.877204 -0.174016 -3.546609 107 | v 0.913425 -0.800494 -3.787315 108 | v -0.913425 -0.800494 -3.787315 109 | v 1.043353 0.123507 2.712921 110 | v -1.043353 0.123507 2.712921 111 | v 1.044835 -0.236681 2.322122 112 | v -1.044835 -0.236681 2.322122 113 | v 0.877197 -0.782389 -5.036030 114 | v -0.877197 -0.782389 -5.036030 115 | v 0.873037 1.061554 -5.158776 116 | v -0.873037 1.061554 -5.158776 117 | v 0.916941 1.172025 -4.170675 118 | v -0.916941 1.172025 -4.170675 119 | v 0.595898 1.816439 -2.667044 120 | v -0.595898 1.816439 -2.667044 121 | v 0.497088 1.957596 -1.918296 122 | v -0.497088 1.957596 -1.918296 123 | v 0.595898 1.837024 0.470531 124 | v -0.595898 1.837024 0.470531 125 | v 0.805075 0.828339 2.506677 126 | v -0.805075 0.828339 2.506677 127 | v 0.967405 0.484651 4.568801 128 | v -0.967405 0.484651 4.568801 129 | v 1.020776 0.251435 4.949312 130 | v -1.020776 0.251435 4.949312 131 | v 1.034455 -0.190449 5.157979 132 | v -1.034455 -0.190449 5.157979 133 | v 1.016810 -0.963092 5.020656 134 | v -1.016810 -0.963092 5.020656 135 | v 1.047570 -0.949632 3.863158 136 | v -1.047570 -0.949632 3.863158 137 | v 1.044835 -0.225727 3.672991 138 | v -1.044835 -0.225727 3.672991 139 | v 1.040887 0.133560 3.293998 140 | v -1.040887 0.133560 3.293998 141 | v 0.883514 0.294856 -5.097403 142 | v -0.883514 0.294856 -5.097403 143 | v 0.746760 1.022435 1.858261 144 | v -0.746760 1.022435 1.858261 145 | v 0.000000 -0.859366 -0.582518 146 | v 0.000000 -0.860745 -0.767342 147 | v 1.045864 -0.826507 2.146481 148 | v -1.045864 -0.826507 2.146481 149 | v 0.969333 -0.830776 1.818529 150 | v -0.969333 -0.830776 1.818529 151 | v 0.000000 -0.826507 2.146481 152 | v 0.000000 -0.830776 1.818529 153 | v 2.121204 0.133890 -2.547296 154 | v -2.121204 0.133890 -2.547296 155 | v 2.119303 0.045433 -0.608706 156 | v -2.119303 0.045433 -0.608706 157 | v 2.119431 0.050576 -0.781711 158 | v -2.119431 0.050576 -0.781711 159 | v 2.116436 -0.078369 1.747138 160 | v -2.116436 -0.078369 1.747138 161 | v 0.995804 1.844556 -0.884950 162 | v -0.995804 1.844556 -0.884950 163 | v 0.498379 1.907178 -0.886961 164 | v -0.498379 1.907178 -0.886961 165 | v -0.000000 1.907178 -0.886961 166 | usemtl (null) 167 | s off 168 | f 21 23 51 63 169 | f 52 24 22 64 170 | f 57 49 59 61 171 | f 60 50 58 62 172 | f 157 27 47 49 173 | f 48 28 158 50 174 | f 29 53 45 175 | f 46 54 30 176 | f 27 45 53 47 177 | f 54 46 28 48 178 | f 9 89 11 179 | f 12 90 10 180 | f 9 93 95 149 181 | f 96 94 10 150 182 | f 93 66 65 95 183 | f 65 66 94 96 184 | f 149 95 99 13 185 | f 100 96 150 14 186 | f 95 65 68 99 187 | f 68 65 96 100 188 | f 13 99 101 5 189 | f 102 100 14 6 190 | f 99 68 69 101 191 | f 69 68 100 102 192 | f 15 105 107 7 193 | f 108 106 16 8 194 | f 105 72 71 107 195 | f 71 72 106 108 196 | f 1 103 109 17 197 | f 110 104 2 18 198 | f 103 70 73 109 199 | f 73 70 104 110 200 | f 19 111 113 21 201 | f 114 112 20 22 202 | f 111 74 75 113 203 | f 75 74 112 114 204 | f 21 113 115 23 205 | f 116 114 22 24 206 | f 113 75 76 115 207 | f 76 75 114 116 208 | f 23 115 117 25 209 | f 118 116 24 26 210 | f 115 76 77 117 211 | f 77 76 116 118 212 | f 157 159 119 27 213 | f 120 160 158 28 214 | f 159 161 78 119 215 | f 78 161 160 120 216 | f 29 121 123 31 217 | f 124 122 30 32 218 | f 121 79 80 123 219 | f 80 79 122 124 220 | f 31 123 125 33 221 | f 126 124 32 34 222 | f 123 80 81 125 223 | f 81 80 124 126 224 | f 33 125 127 35 225 | f 128 126 34 36 226 | f 125 81 82 127 227 | f 82 81 126 128 228 | f 35 127 129 37 229 | f 130 128 36 38 230 | f 127 82 83 129 231 | f 83 82 128 130 232 | f 37 129 131 39 233 | f 132 130 38 40 234 | f 129 83 84 131 235 | f 84 83 130 132 236 | f 41 133 135 43 237 | f 136 134 42 44 238 | f 133 85 86 135 239 | f 86 85 134 136 240 | f 43 135 105 15 241 | f 106 136 44 16 242 | f 135 86 72 105 243 | f 72 86 136 106 244 | f 109 73 87 137 245 | f 87 73 110 138 246 | f 137 87 74 111 247 | f 74 87 138 112 248 | f 45 139 121 29 249 | f 122 140 46 30 250 | f 139 88 79 121 251 | f 79 88 140 122 252 | f 67 97 89 253 | f 90 98 67 254 | f 97 11 89 255 | f 90 12 98 256 | f 39 131 133 41 257 | f 134 132 40 42 258 | f 131 84 85 133 259 | f 85 84 132 134 260 | f 11 97 93 9 261 | f 94 98 12 10 262 | f 97 67 66 93 263 | f 66 67 98 94 264 | f 103 1 5 101 265 | f 6 2 104 102 266 | f 101 69 70 103 267 | f 70 69 102 104 268 | f 35 37 39 41 269 | f 40 38 36 42 270 | f 33 35 41 271 | f 42 36 34 272 | f 89 55 141 142 273 | f 141 56 90 142 274 | f 67 89 142 275 | f 142 90 67 276 | f 91 3 143 145 277 | f 144 4 92 146 278 | f 145 143 147 148 279 | f 147 144 146 148 280 | f 55 91 145 141 281 | f 146 92 56 141 282 | f 141 145 148 283 | f 148 146 141 284 | f 17 109 137 285 | f 138 110 18 286 | f 19 137 111 287 | f 112 138 20 288 | f 17 137 19 289 | f 20 138 18 290 | f 1 17 19 21 291 | f 20 18 2 22 292 | f 59 151 153 61 293 | f 154 152 60 62 294 | f 151 55 89 153 295 | f 90 56 152 154 296 | f 9 149 153 89 297 | f 154 150 10 90 298 | f 149 63 61 153 299 | f 62 64 150 154 300 | f 53 155 151 59 301 | f 152 156 54 60 302 | f 155 91 55 151 303 | f 56 92 156 152 304 | f 149 13 21 63 305 | f 22 14 150 64 306 | f 5 21 13 307 | f 14 22 6 308 | f 1 21 5 309 | f 6 22 2 310 | f 3 7 107 143 311 | f 108 8 4 144 312 | f 71 147 143 107 313 | f 144 147 71 108 314 | f 3 91 155 7 315 | f 156 92 4 8 316 | f 31 33 41 43 317 | f 42 34 32 44 318 | f 29 31 43 15 319 | f 44 32 30 16 320 | f 7 155 15 321 | f 16 156 8 322 | f 29 15 155 53 323 | f 156 16 30 54 324 | f 157 49 57 325 | f 58 50 158 326 | f 25 157 57 51 327 | f 58 158 26 52 328 | f 23 25 51 329 | f 52 26 24 330 | f 25 117 159 157 331 | f 160 118 26 158 332 | f 77 161 159 117 333 | f 160 161 77 118 334 | -------------------------------------------------------------------------------- /prelim_tests/Stats.js: -------------------------------------------------------------------------------- 1 | // stats.js r6 - http://github.com/mrdoob/stats.js 2 | var Stats=function(){function s(a,g,d){var f,c,e;for(c=0;c<30;c++)for(f=0;f<73;f++)e=(f+c*74)*4,a[e]=a[e+4],a[e+1]=a[e+5],a[e+2]=a[e+6];for(c=0;c<30;c++)e=(73+c*74)*4,c'+n+" MS ("+z+"-"+A+")";o.putImageData(B,0,0);F=j;if(j> 9 | v+1E3){l=Math.round(u*1E3/(j-v));w=Math.min(w,l);x=Math.max(x,l);s(y.data,Math.min(30,30-l/100*30),"fps");d.innerHTML=''+l+" FPS ("+w+"-"+x+")";m.putImageData(y,0,0);if(t==3)p=performance.memory.usedJSHeapSize*9.54E-7,C=Math.min(C,p),D=Math.max(D,p),s(E.data,Math.min(30,30-p/2),"mb"),i.innerHTML=''+Math.round(p)+" MB ("+Math.round(C)+"-"+Math.round(D)+")",q.putImageData(E,0,0);v=j;u=0}}}}; 10 | 11 | -------------------------------------------------------------------------------- /prelim_tests/all_objects.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/all_objects.blend -------------------------------------------------------------------------------- /prelim_tests/basic_shapes.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/basic_shapes.blend -------------------------------------------------------------------------------- /prelim_tests/basic_shapes.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'basic_shapes.blend' 2 | # Material Count: 0 3 | -------------------------------------------------------------------------------- /prelim_tests/basic_shapes_edges.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.58 (sub 1) OBJ File: 'basic_shapes.blend' 2 | # www.blender.org 3 | o c_car 4 | v -4.000000 1.000000 1.000000 5 | v -3.000000 0.000000 1.000000 6 | v -3.000000 0.000000 2.000000 7 | v -4.000000 1.000000 2.000000 8 | v -3.000000 2.000000 1.000000 9 | v -2.000000 1.000000 1.000000 10 | v -2.000000 1.000000 2.000000 11 | v -3.000000 2.000000 2.000000 12 | v 3.000000 2.000000 2.000000 13 | v 4.000000 1.000000 2.000000 14 | v 4.000000 1.000000 1.000000 15 | v 3.000000 2.000000 1.000000 16 | v 2.000000 1.000000 2.000000 17 | v 3.000000 0.000000 2.000000 18 | v 3.000000 0.000000 1.000000 19 | v 2.000000 1.000000 1.000000 20 | v 2.000000 1.000000 -2.000000 21 | v 3.000000 0.000000 -2.000000 22 | v 3.000000 0.000000 -1.000000 23 | v 2.000000 1.000000 -1.000000 24 | v 3.000000 2.000000 -2.000000 25 | v 4.000000 1.000000 -2.000000 26 | v 4.000000 1.000000 -1.000000 27 | v 3.000000 2.000000 -1.000000 28 | v -3.000000 2.000000 -1.000000 29 | v -2.000000 1.000000 -1.000000 30 | v -2.000000 1.000000 -2.000000 31 | v -3.000000 2.000000 -2.000000 32 | v -4.000000 1.000000 -1.000000 33 | v -3.000000 0.000000 -1.000000 34 | v -3.000000 0.000000 -2.000000 35 | v -4.000000 1.000000 -2.000000 36 | v -4.000000 2.000000 2.000000 37 | v -4.000000 2.000000 -2.000000 38 | v -3.000000 3.000000 -2.000000 39 | v -2.000000 2.000000 2.000000 40 | v -2.000000 2.000000 -2.000000 41 | v 2.000000 2.000000 -2.000000 42 | v 2.000000 2.000000 2.000000 43 | v 3.000000 3.000000 2.000000 44 | v 4.000000 2.000000 -2.000000 45 | v 4.000000 2.000000 2.000000 46 | v 6.000000 2.000000 1.000000 47 | v 6.000000 2.000000 -1.000000 48 | v 6.000000 3.000000 -1.000000 49 | v 6.000000 3.000000 1.000000 50 | v 5.000000 3.000000 2.000000 51 | v 5.000000 3.000000 -2.000000 52 | v 1.000000 6.000000 -1.000000 53 | v 1.000000 6.000000 1.000000 54 | v -1.000000 6.000000 1.000000 55 | v -1.000000 6.000000 -1.000000 56 | v -5.000000 3.000000 -2.000000 57 | v -5.000000 3.000000 2.000000 58 | v -6.000000 3.000000 1.000000 59 | v -6.000000 3.000000 -1.000000 60 | v -6.000000 2.000000 -1.000000 61 | v -6.000000 2.000000 1.000000 62 | v 3.000000 5.000000 -2.000000 63 | v 3.000000 5.000000 2.000000 64 | v -3.000000 5.000000 -2.000000 65 | v -3.000000 5.000000 2.000000 66 | v 3.000000 3.000000 -2.000000 67 | v -3.000000 3.000000 2.000000 68 | v -5.000000 2.000000 -2.000000 69 | v -5.000000 2.000000 2.000000 70 | v 5.000000 2.000000 -2.000000 71 | v 5.000000 2.000000 2.000000 72 | usemtl (null) 73 | s off 74 | f 1 2 3 4 75 | f 1 5 6 2 76 | f 2 6 7 3 77 | f 3 7 8 4 78 | f 5 1 4 8 79 | f 8 7 6 5 80 | f 9 10 11 12 81 | f 12 16 13 9 82 | f 14 10 9 13 83 | f 15 11 10 14 84 | f 16 12 11 15 85 | f 16 15 14 13 86 | f 17 18 19 20 87 | f 17 21 22 18 88 | f 18 22 23 19 89 | f 19 23 24 20 90 | f 21 17 20 24 91 | f 24 23 22 21 92 | f 25 26 27 28 93 | f 28 32 29 25 94 | f 30 26 25 29 95 | f 31 27 26 30 96 | f 32 28 27 31 97 | f 32 31 30 29 98 | f 33 34 35 64 99 | f 64 35 37 36 100 | f 36 37 38 39 101 | f 39 38 63 40 102 | f 40 63 41 42 103 | f 43 44 45 46 104 | f 46 45 48 47 105 | f 50 49 52 51 106 | f 55 56 57 58 107 | f 48 59 60 47 108 | f 59 49 50 60 109 | f 52 61 62 51 110 | f 61 53 54 62 111 | f 60 50 51 62 112 | f 61 52 49 59 113 | f 53 56 55 54 114 | f 63 35 61 59 115 | f 48 63 59 116 | f 35 53 61 117 | f 64 40 60 62 118 | f 54 64 62 119 | f 40 47 60 120 | f 35 63 38 37 121 | f 36 39 40 64 122 | f 58 57 65 66 123 | f 33 66 65 34 124 | f 33 64 54 66 125 | f 34 65 53 35 126 | f 56 53 65 57 127 | f 55 58 66 54 128 | f 41 67 68 42 129 | f 67 44 43 68 130 | f 44 67 48 45 131 | f 43 46 47 68 132 | f 40 42 68 47 133 | f 48 67 41 63 134 | o tr_treeRect 135 | v -2.000000 0.000000 -2.000000 136 | v 2.000000 0.000000 -2.000000 137 | v 2.000000 0.000000 2.000000 138 | v -2.000000 0.000000 2.000000 139 | v 1.000000 4.000000 1.000000 140 | v -1.000000 4.000000 1.000000 141 | v 1.000000 4.000000 -1.000000 142 | v -1.000000 4.000000 -1.000000 143 | v 0.000000 11.000000 0.000000 144 | v -2.000000 9.000000 -2.000000 145 | v -2.000000 9.000000 2.000000 146 | v 2.000000 9.000000 2.000000 147 | v 2.000000 9.000000 -2.000000 148 | v -3.000000 7.000000 -3.000000 149 | v -3.000000 7.000000 3.000000 150 | v 3.000000 7.000000 3.000000 151 | v 3.000000 7.000000 -3.000000 152 | v -2.000000 4.000000 -2.000000 153 | v 2.000000 4.000000 -2.000000 154 | v 2.000000 4.000000 2.000000 155 | v -2.000000 4.000000 2.000000 156 | usemtl (null) 157 | s off 158 | f 69 70 71 72 159 | f 69 76 75 70 160 | f 70 75 73 71 161 | f 71 73 74 72 162 | f 76 69 72 74 163 | f 78 77 81 164 | f 81 77 80 165 | f 80 77 79 166 | f 79 77 78 167 | f 82 78 81 85 168 | f 85 81 80 84 169 | f 84 80 79 83 170 | f 83 79 78 82 171 | f 76 86 87 75 172 | f 86 82 85 87 173 | f 75 87 88 73 174 | f 87 85 84 88 175 | f 73 88 89 74 176 | f 88 84 83 89 177 | f 74 89 86 76 178 | f 89 83 82 86 179 | o td_treeDiag 180 | v 0.000000 0.000000 -2.000000 181 | v 2.000000 0.000000 0.000000 182 | v 0.000000 0.000000 2.000000 183 | v -2.000000 0.000000 0.000000 184 | v 0.000000 4.000000 -1.000000 185 | v 1.000000 4.000000 0.000000 186 | v 0.000000 4.000000 1.000000 187 | v -1.000000 4.000000 0.000000 188 | v -2.000000 4.000000 0.000000 189 | v 0.000000 4.000000 2.000000 190 | v 2.000000 4.000000 0.000000 191 | v 0.000000 4.000000 -2.000000 192 | v 0.000000 11.000000 0.000000 193 | v 0.000000 9.000000 -3.000000 194 | v -3.000000 9.000000 0.000000 195 | v 0.000000 9.000000 3.000000 196 | v 3.000000 9.000000 0.000000 197 | v 0.000000 7.000000 -4.000000 198 | v -4.000000 7.000000 0.000000 199 | v 0.000000 7.000000 4.000000 200 | v 4.000000 7.000000 0.000000 201 | usemtl (null) 202 | s off 203 | f 90 91 92 93 204 | f 90 94 95 91 205 | f 91 95 96 92 206 | f 92 96 97 93 207 | f 94 90 93 97 208 | f 94 97 98 101 209 | f 97 96 99 98 210 | f 96 95 100 99 211 | f 95 94 101 100 212 | f 103 102 106 213 | f 106 102 105 214 | f 105 102 104 215 | f 104 102 103 216 | f 101 107 110 100 217 | f 107 103 106 110 218 | f 100 110 109 99 219 | f 110 106 105 109 220 | f 99 109 108 98 221 | f 109 105 104 108 222 | f 98 108 107 101 223 | f 108 104 103 107 224 | o p_plane 225 | v -100.000000 0.000000 100.000000 226 | v 100.000000 0.000000 100.000000 227 | v 80.000000 0.000000 100.000000 228 | v 60.000000 0.000000 100.000000 229 | v 40.000000 0.000000 100.000000 230 | v 20.000000 0.000000 100.000000 231 | v 0.000000 0.000000 100.000000 232 | v -20.000000 0.000000 100.000000 233 | v -40.000000 0.000000 100.000000 234 | v -60.000000 0.000000 100.000000 235 | v -80.000000 0.000000 100.000000 236 | v -100.000000 0.000000 80.000000 237 | v -100.000000 0.000000 60.000000 238 | v -100.000000 0.000000 40.000000 239 | v -100.000000 0.000000 20.000000 240 | v -100.000000 0.000000 0.000000 241 | v -100.000000 0.000000 -20.000000 242 | v -100.000000 0.000000 -40.000000 243 | v -100.000000 0.000000 -60.000000 244 | v -100.000000 0.000000 -80.000000 245 | v -100.000000 0.000000 -100.000000 246 | v 100.000000 0.000000 -100.000000 247 | v 80.000000 0.000000 -100.000000 248 | v 60.000000 0.000000 -100.000000 249 | v 40.000000 0.000000 -100.000000 250 | v 20.000000 0.000000 -100.000000 251 | v 0.000000 0.000000 -100.000000 252 | v -20.000000 0.000000 -100.000000 253 | v -40.000000 0.000000 -100.000000 254 | v -60.000000 0.000000 -100.000000 255 | v -80.000000 0.000000 -100.000000 256 | v 100.000000 0.000000 -80.000000 257 | v 80.000000 0.000000 -80.000000 258 | v 60.000000 0.000000 -80.000000 259 | v 40.000000 0.000000 -80.000000 260 | v 20.000000 0.000000 -80.000000 261 | v 0.000000 0.000000 -80.000000 262 | v -20.000000 0.000000 -80.000000 263 | v -40.000000 0.000000 -80.000000 264 | v -60.000000 0.000000 -80.000000 265 | v -80.000000 0.000000 -80.000000 266 | v 100.000000 0.000000 -60.000000 267 | v 80.000000 0.000000 -60.000000 268 | v 60.000000 0.000000 -60.000000 269 | v 40.000000 0.000000 -60.000000 270 | v 20.000000 0.000000 -60.000000 271 | v 0.000000 0.000000 -60.000000 272 | v -20.000000 0.000000 -60.000000 273 | v -40.000000 0.000000 -60.000000 274 | v -60.000000 0.000000 -60.000000 275 | v -80.000000 0.000000 -60.000000 276 | v 100.000000 0.000000 -40.000000 277 | v 80.000000 0.000000 -40.000000 278 | v 60.000000 0.000000 -40.000000 279 | v 40.000000 0.000000 -40.000000 280 | v 20.000000 0.000000 -40.000000 281 | v 0.000000 0.000000 -40.000000 282 | v -20.000000 0.000000 -40.000000 283 | v -40.000000 0.000000 -40.000000 284 | v -60.000000 0.000000 -40.000000 285 | v -80.000000 0.000000 -40.000000 286 | v 100.000000 0.000000 -20.000000 287 | v 80.000000 0.000000 -20.000000 288 | v 60.000000 0.000000 -20.000000 289 | v 40.000000 0.000000 -20.000000 290 | v 20.000000 0.000000 -20.000000 291 | v 0.000000 0.000000 -20.000000 292 | v -20.000000 0.000000 -20.000000 293 | v -40.000000 0.000000 -20.000000 294 | v -60.000000 0.000000 -20.000000 295 | v -80.000000 0.000000 -20.000000 296 | v 100.000000 0.000000 0.000000 297 | v 80.000000 0.000000 0.000000 298 | v 60.000000 0.000000 0.000000 299 | v 40.000000 0.000000 0.000000 300 | v 20.000000 0.000000 0.000000 301 | v 0.000000 0.000000 0.000000 302 | v -20.000000 0.000000 0.000000 303 | v -40.000000 0.000000 0.000000 304 | v -60.000000 0.000000 0.000000 305 | v -80.000000 0.000000 0.000000 306 | v 100.000000 0.000000 20.000000 307 | v 80.000000 0.000000 20.000000 308 | v 60.000000 0.000000 20.000000 309 | v 40.000000 0.000000 20.000000 310 | v 20.000000 0.000000 20.000000 311 | v 0.000000 0.000000 20.000000 312 | v -20.000000 0.000000 20.000000 313 | v -40.000000 0.000000 20.000000 314 | v -60.000000 0.000000 20.000000 315 | v -80.000000 0.000000 20.000000 316 | v 100.000000 0.000000 40.000000 317 | v 80.000000 0.000000 40.000000 318 | v 60.000000 0.000000 40.000000 319 | v 40.000000 0.000000 40.000000 320 | v 20.000000 0.000000 40.000000 321 | v 0.000000 0.000000 40.000000 322 | v -20.000000 0.000000 40.000000 323 | v -40.000000 0.000000 40.000000 324 | v -60.000000 0.000000 40.000000 325 | v -80.000000 0.000000 40.000000 326 | v 100.000000 0.000000 60.000000 327 | v 80.000000 0.000000 60.000000 328 | v 60.000000 0.000000 60.000000 329 | v 40.000000 0.000000 60.000000 330 | v 20.000000 0.000000 60.000000 331 | v 0.000000 0.000000 60.000000 332 | v -20.000000 0.000000 60.000000 333 | v -40.000000 0.000000 60.000000 334 | v -60.000000 0.000000 60.000000 335 | v -80.000000 0.000000 60.000000 336 | v 100.000000 0.000000 80.000000 337 | v 80.000000 0.000000 80.000000 338 | v 60.000000 0.000000 80.000000 339 | v 40.000000 0.000000 80.000000 340 | v 20.000000 0.000000 80.000000 341 | v 0.000000 0.000000 80.000000 342 | v -20.000000 0.000000 80.000000 343 | v -40.000000 0.000000 80.000000 344 | v -60.000000 0.000000 80.000000 345 | v -80.000000 0.000000 80.000000 346 | usemtl Material 347 | s off 348 | f 141 131 130 151 349 | f 140 141 151 150 350 | f 139 140 150 149 351 | f 138 139 149 148 352 | f 137 138 148 147 353 | f 136 137 147 146 354 | f 135 136 146 145 355 | f 134 135 145 144 356 | f 133 134 144 143 357 | f 132 133 143 142 358 | f 151 130 129 161 359 | f 150 151 161 160 360 | f 149 150 160 159 361 | f 148 149 159 158 362 | f 147 148 158 157 363 | f 146 147 157 156 364 | f 145 146 156 155 365 | f 144 145 155 154 366 | f 143 144 154 153 367 | f 142 143 153 152 368 | f 161 129 128 171 369 | f 160 161 171 170 370 | f 159 160 170 169 371 | f 158 159 169 168 372 | f 157 158 168 167 373 | f 156 157 167 166 374 | f 155 156 166 165 375 | f 154 155 165 164 376 | f 153 154 164 163 377 | f 152 153 163 162 378 | f 171 128 127 181 379 | f 170 171 181 180 380 | f 169 170 180 179 381 | f 168 169 179 178 382 | f 167 168 178 177 383 | f 166 167 177 176 384 | f 165 166 176 175 385 | f 164 165 175 174 386 | f 163 164 174 173 387 | f 162 163 173 172 388 | f 181 127 126 191 389 | f 180 181 191 190 390 | f 179 180 190 189 391 | f 178 179 189 188 392 | f 177 178 188 187 393 | f 176 177 187 186 394 | f 175 176 186 185 395 | f 174 175 185 184 396 | f 173 174 184 183 397 | f 172 173 183 182 398 | f 191 126 125 201 399 | f 190 191 201 200 400 | f 189 190 200 199 401 | f 188 189 199 198 402 | f 187 188 198 197 403 | f 186 187 197 196 404 | f 185 186 196 195 405 | f 184 185 195 194 406 | f 183 184 194 193 407 | f 182 183 193 192 408 | f 201 125 124 211 409 | f 200 201 211 210 410 | f 199 200 210 209 411 | f 198 199 209 208 412 | f 197 198 208 207 413 | f 196 197 207 206 414 | f 195 196 206 205 415 | f 194 195 205 204 416 | f 193 194 204 203 417 | f 192 193 203 202 418 | f 211 124 123 221 419 | f 210 211 221 220 420 | f 209 210 220 219 421 | f 208 209 219 218 422 | f 207 208 218 217 423 | f 206 207 217 216 424 | f 205 206 216 215 425 | f 204 205 215 214 426 | f 203 204 214 213 427 | f 202 203 213 212 428 | f 221 123 122 231 429 | f 220 221 231 230 430 | f 219 220 230 229 431 | f 218 219 229 228 432 | f 217 218 228 227 433 | f 216 217 227 226 434 | f 215 216 226 225 435 | f 214 215 225 224 436 | f 213 214 224 223 437 | f 212 213 223 222 438 | f 111 121 231 122 439 | f 230 231 121 120 440 | f 229 230 120 119 441 | f 228 229 119 118 442 | f 227 228 118 117 443 | f 226 227 117 116 444 | f 225 226 116 115 445 | f 224 225 115 114 446 | f 223 224 114 113 447 | f 222 223 113 112 448 | -------------------------------------------------------------------------------- /prelim_tests/battlegirl_objects.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/battlegirl_objects.blend -------------------------------------------------------------------------------- /prelim_tests/bots.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'basic_shapes.blend' 2 | # Material Count: 0 3 | -------------------------------------------------------------------------------- /prelim_tests/canvas_first_3d_attempt_front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/canvas_first_3d_attempt_front.png -------------------------------------------------------------------------------- /prelim_tests/canvas_first_3d_attempt_side.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/canvas_first_3d_attempt_side.png -------------------------------------------------------------------------------- /prelim_tests/convert_obj_to_font.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 27 | 28 | 167 | -------------------------------------------------------------------------------- /prelim_tests/convert_obj_to_shape.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 27 | 28 | 150 | -------------------------------------------------------------------------------- /prelim_tests/horus_model.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.58 (sub 1) OBJ File: 'horus model.blend' 2 | # www.blender.org 3 | mtllib horus model.mtl 4 | o Cube 5 | v 0.477315 0.135025 -3.483326 6 | v -0.477315 0.135025 -3.483326 7 | v 0.391792 0.267136 -3.393796 8 | v -0.391792 0.267136 -3.393796 9 | v 0.477315 0.429819 -3.450571 10 | v -0.477315 0.429819 -3.450571 11 | v 0.531905 0.359578 -3.542285 12 | v -0.531905 0.359578 -3.542285 13 | v 0.541003 0.218004 -3.546652 14 | v -0.541003 0.218004 -3.546652 15 | v 0.642621 0.081762 -3.671445 16 | v -0.642621 0.081762 -3.671445 17 | v 0.632066 0.522399 -3.635668 18 | v -0.632066 0.522399 -3.635668 19 | v 0.240200 0.681176 -3.290614 20 | v -0.240200 0.681176 -3.290614 21 | v 0.278436 0.244615 -3.360146 22 | v -0.278436 0.244615 -3.360146 23 | v 0.437368 -0.101176 -3.458758 24 | v -0.437368 -0.101176 -3.458758 25 | v 0.149746 0.195399 -3.181615 26 | v -0.149746 0.195399 -3.181615 27 | v 0.002601 0.039007 -2.990144 28 | v -0.002601 0.039007 -2.990144 29 | v 0.047585 0.121232 -2.904417 30 | v -0.047585 0.121232 -2.904417 31 | v 0.126805 0.357287 -2.987043 32 | v -0.126805 0.357287 -2.987043 33 | v 0.210682 0.767634 -3.209396 34 | v -0.210682 0.767634 -3.209396 35 | v 0.097287 0.443745 -2.905825 36 | v -0.097287 0.443745 -2.905825 37 | v 0.417396 0.838372 -3.474010 38 | v -0.417396 0.838372 -3.474010 39 | v 0.387878 0.924830 -3.392792 40 | v -0.387878 0.924830 -3.392792 41 | v 0.631405 0.984575 -3.627595 42 | v -0.631405 0.984575 -3.627595 43 | v 0.631405 0.867706 -3.647917 44 | v -0.631405 0.867706 -3.647917 45 | v 0.867199 0.794347 -3.949210 46 | v -0.867199 0.794347 -3.949210 47 | v 0.867199 0.911216 -3.928888 48 | v -0.867199 0.911216 -3.928888 49 | v 0.990336 0.816688 -4.137671 50 | v -0.990336 0.816688 -4.137671 51 | v 0.990336 0.704817 -4.098222 52 | v -0.990336 0.704817 -4.098222 53 | v 1.101523 0.584639 -4.391710 54 | v -1.101523 0.584639 -4.391710 55 | v 1.053807 0.483455 -4.352261 56 | v -1.053807 0.483455 -4.352261 57 | v 1.059332 0.131750 -4.472837 58 | v -1.059332 0.131750 -4.472837 59 | v 1.156292 0.187552 -4.512286 60 | v -1.156292 0.187552 -4.512286 61 | v 1.077674 -0.129833 -4.451571 62 | v -1.077674 -0.129833 -4.451571 63 | v 0.966018 -0.122906 -4.412121 64 | v -0.966018 -0.122906 -4.412121 65 | v 0.943990 -0.547763 -4.260408 66 | v -0.943990 -0.547763 -4.260408 67 | v 0.671699 -0.519826 -4.158134 68 | v -0.671699 -0.519826 -4.158134 69 | v 0.879960 -0.787114 -4.153408 70 | v -0.879960 -0.787114 -4.153408 71 | v 0.574800 -0.755804 -4.038788 72 | v -0.574800 -0.755804 -4.038788 73 | v 0.541749 -0.887838 -3.985346 74 | v -0.541749 -0.887838 -3.985346 75 | v 0.846909 -0.919148 -4.099965 76 | v -0.846909 -0.919148 -4.099965 77 | v 0.428927 -1.086711 -3.926906 78 | v -0.428927 -1.086711 -3.926906 79 | v 0.734087 -1.097514 -4.045233 80 | v -0.734087 -1.097514 -4.045233 81 | v 0.587395 1.223484 -3.627595 82 | v -0.587395 1.223484 -3.627595 83 | v 0.823189 1.150126 -3.928888 84 | v -0.823189 1.150126 -3.928888 85 | v 0.355115 1.134485 -3.409104 86 | v -0.355115 1.134485 -3.409104 87 | v 0.201970 1.025003 -3.300459 88 | v -0.201970 1.025003 -3.300459 89 | v 0.522453 1.405539 -3.644773 90 | v -0.522453 1.405539 -3.644773 91 | v 0.274813 1.291693 -3.446977 92 | v -0.274813 1.291693 -3.446977 93 | v 0.000000 1.563973 -3.833650 94 | v -0.015785 1.446870 -3.568434 95 | v 0.015785 1.446870 -3.568434 96 | v 0.000000 1.608538 -4.002664 97 | v 0.601850 1.388134 -3.892216 98 | v -0.601850 1.388134 -3.892216 99 | v 0.000000 1.570073 -4.451544 100 | v 0.601850 1.330631 -4.392858 101 | v -0.601850 1.330631 -4.392858 102 | v 0.538393 1.110348 -4.767917 103 | v -0.538393 1.110348 -4.767917 104 | v 0.000000 1.393309 -4.849382 105 | v 0.000000 1.024640 -5.373871 106 | v 0.543673 0.813420 -5.143202 107 | v -0.543673 0.813420 -5.143202 108 | v 0.000000 0.397060 -5.735641 109 | v 0.601850 0.304202 -5.498570 110 | v -0.601850 0.304202 -5.498570 111 | v 0.000000 -0.114029 -5.887394 112 | v 0.601850 -0.142357 -5.655423 113 | v -0.601850 -0.142357 -5.655423 114 | v 0.000000 -0.729718 -5.841329 115 | v 0.601850 -0.675463 -5.636011 116 | v -0.601850 -0.675463 -5.636011 117 | v 0.000000 -1.189129 -5.646418 118 | v 0.601850 -1.033991 -5.454823 119 | v -0.601850 -1.033991 -5.454823 120 | v 0.000000 -1.434457 -5.301492 121 | v 0.593055 -1.164250 -5.248207 122 | v -0.593055 -1.164250 -5.248207 123 | v 1.144507 -0.241404 -5.327240 124 | v -1.144507 -0.241404 -5.327240 125 | v 1.148071 -0.774825 -5.332572 126 | v -1.148071 -0.774825 -5.332572 127 | v 1.045432 0.197040 -5.179020 128 | v -1.045432 0.197040 -5.179020 129 | v 0.819156 0.640724 -4.958931 130 | v -0.819156 0.640724 -4.958931 131 | v 1.111090 0.197040 -4.850671 132 | v -1.111090 0.197040 -4.850671 133 | v 1.275827 -0.241404 -4.918838 134 | v -1.275827 -0.241404 -4.918838 135 | v 1.281754 -0.774825 -4.921290 136 | v -1.281754 -0.774825 -4.921290 137 | v 0.828082 0.938009 -4.319505 138 | v -0.828082 0.938009 -4.319505 139 | v 0.874184 0.700429 -4.678966 140 | v -0.874184 0.700429 -4.678966 141 | v 0.943990 -0.547763 -4.260408 142 | v -0.943990 -0.547763 -4.260408 143 | v 1.281754 -0.774825 -4.921290 144 | v -1.281754 -0.774825 -4.921290 145 | v 1.148071 -0.774825 -5.332572 146 | v -1.148071 -0.774825 -5.332572 147 | v 0.601850 -0.675463 -5.636011 148 | v -0.601850 -0.675463 -5.636011 149 | v 0.906408 -1.005529 -5.254022 150 | v -0.906408 -1.005529 -5.254022 151 | v 1.040090 -1.005529 -4.842740 152 | v -1.040090 -1.005529 -4.842740 153 | v 0.906408 -1.005529 -5.254022 154 | v -0.906408 -1.005529 -5.254022 155 | v 1.040090 -1.005529 -4.842740 156 | v -1.040090 -1.005529 -4.842740 157 | v 0.763517 -1.122906 -5.201723 158 | v -0.763517 -1.122906 -5.201723 159 | v 0.964444 -1.059805 -4.824006 160 | v -0.964444 -1.059805 -4.824006 161 | v 0.000000 -1.532734 -5.117074 162 | v 0.535161 -1.262527 -5.063788 163 | v -0.535161 -1.262527 -5.063788 164 | v 0.773680 -1.168292 -4.675072 165 | v -0.773680 -1.168292 -4.675072 166 | v 0.546207 -1.245701 -5.034637 167 | v -0.546207 -1.245701 -5.034637 168 | v 0.024495 0.133904 -2.855272 169 | v -0.024495 0.133904 -2.855272 170 | v 0.138320 1.165431 -3.229492 171 | v -0.138320 1.165431 -3.229492 172 | v 0.000000 1.253490 -3.219404 173 | v 0.101877 0.891024 -3.097116 174 | v -0.101877 0.891024 -3.097116 175 | v 0.070678 0.927562 -3.029196 176 | v -0.070678 0.927562 -3.029196 177 | v 0.000000 0.960128 -3.000438 178 | v 0.214091 0.220007 -3.270880 179 | v -0.214091 0.220007 -3.270880 180 | v 0.153984 0.605690 -3.057611 181 | v -0.153984 0.605690 -3.057611 182 | v 0.183502 0.519232 -3.138829 183 | v -0.183502 0.519232 -3.138829 184 | v 0.000000 0.474691 -2.869059 185 | v 0.000000 0.132534 -2.826701 186 | v 0.000000 -0.052921 -2.849985 187 | v 0.070678 0.752041 -2.936610 188 | v -0.070678 0.752041 -2.936610 189 | v 0.000000 0.780619 -2.903886 190 | v 0.101877 0.724583 -3.008681 191 | v -0.101877 0.724583 -3.008681 192 | usemtl (null) 193 | s off 194 | f 9 1 19 11 195 | f 20 2 10 12 196 | f 9 7 13 11 197 | f 14 8 10 12 198 | f 7 5 15 13 199 | f 16 6 8 14 200 | f 5 3 17 15 201 | f 18 4 6 16 202 | f 3 1 19 17 203 | f 20 2 4 18 204 | f 27 21 23 25 205 | f 24 22 28 26 206 | f 15 29 35 33 207 | f 36 30 16 34 208 | f 33 35 37 39 209 | f 38 36 34 40 210 | f 39 37 43 41 211 | f 44 38 40 42 212 | f 41 43 45 47 213 | f 46 44 42 48 214 | f 47 45 49 51 215 | f 50 46 48 52 216 | f 51 49 55 53 217 | f 56 50 52 54 218 | f 53 55 57 59 219 | f 58 56 54 60 220 | f 59 57 61 63 221 | f 62 58 60 64 222 | f 63 61 65 67 223 | f 66 62 64 68 224 | f 67 65 71 69 225 | f 72 66 68 70 226 | f 69 71 75 73 227 | f 76 72 70 74 228 | f 43 37 77 79 229 | f 78 38 44 80 230 | f 37 35 81 77 231 | f 82 36 38 78 232 | f 35 29 83 81 233 | f 84 30 36 82 234 | f 77 81 87 85 235 | f 88 82 78 86 236 | f 85 87 90 89 237 | f 91 88 86 89 238 | f 85 89 92 93 239 | f 92 89 86 94 240 | f 93 92 95 96 241 | f 95 92 94 97 242 | f 96 95 100 98 243 | f 100 95 97 99 244 | f 98 100 101 102 245 | f 101 100 99 103 246 | f 102 101 104 105 247 | f 104 101 103 106 248 | f 105 104 107 108 249 | f 107 104 106 109 250 | f 108 107 110 111 251 | f 110 107 109 112 252 | f 111 110 113 114 253 | f 113 110 112 115 254 | f 114 113 116 117 255 | f 116 113 115 118 256 | f 108 111 121 119 257 | f 122 112 109 120 258 | f 105 108 119 123 259 | f 120 109 106 124 260 | f 102 105 123 125 261 | f 124 106 103 126 262 | f 125 123 127 135 263 | f 128 124 126 136 264 | f 123 119 129 127 265 | f 130 120 124 128 266 | f 119 121 131 129 267 | f 132 122 120 130 268 | f 98 102 125 135 269 | f 126 103 99 136 270 | f 49 45 133 135 271 | f 134 46 50 136 272 | f 43 79 133 45 273 | f 134 80 44 46 274 | f 79 93 96 133 275 | f 97 94 80 134 276 | f 77 85 93 79 277 | f 94 86 78 80 278 | f 96 98 135 133 279 | f 136 99 97 134 280 | f 49 135 127 55 281 | f 128 136 50 56 282 | f 55 127 129 57 283 | f 130 128 56 58 284 | f 57 129 131 61 285 | f 132 130 58 62 286 | f 61 131 139 137 287 | f 140 132 62 138 288 | f 131 121 141 139 289 | f 142 122 132 140 290 | f 121 111 143 141 291 | f 144 112 122 142 292 | f 139 141 145 147 293 | f 146 142 140 148 294 | f 111 114 145 141 295 | f 146 115 112 142 296 | f 61 139 147 65 297 | f 148 140 62 66 298 | f 147 145 149 151 299 | f 150 146 148 152 300 | f 151 149 153 155 301 | f 154 150 152 156 302 | f 65 151 155 71 303 | f 156 152 66 72 304 | f 114 117 153 149 305 | f 154 118 115 150 306 | f 117 116 157 158 307 | f 157 116 118 159 308 | f 155 153 162 160 309 | f 163 154 156 161 310 | f 117 158 162 153 311 | f 163 159 118 154 312 | f 71 155 160 75 313 | f 161 156 72 76 314 | f 25 164 31 27 315 | f 32 165 26 28 316 | f 90 87 166 168 317 | f 167 88 91 168 318 | f 81 83 166 87 319 | f 167 84 82 88 320 | f 166 83 169 171 321 | f 170 84 167 172 322 | f 168 166 171 173 323 | f 172 167 168 173 324 | f 17 174 178 15 325 | f 179 175 18 16 326 | f 174 21 27 178 327 | f 28 22 175 179 328 | f 15 178 176 29 329 | f 177 179 16 30 330 | f 178 27 31 176 331 | f 32 28 179 177 332 | f 29 176 169 83 333 | f 170 177 30 84 334 | f 31 164 181 180 335 | f 181 165 32 180 336 | f 181 164 182 337 | f 182 165 181 338 | f 164 25 182 339 | f 182 26 165 340 | f 25 23 182 341 | f 182 24 26 342 | f 173 171 183 185 343 | f 184 172 173 185 344 | f 171 169 186 183 345 | f 187 170 172 184 346 | -------------------------------------------------------------------------------- /prelim_tests/levels.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'basic_shapes.blend' 2 | # Material Count: 0 3 | -------------------------------------------------------------------------------- /prelim_tests/levels.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.58 (sub 1) OBJ File: 'basic_shapes.blend' 2 | # www.blender.org 3 | mtllib levels.mtl 4 | o level1Bounds_Plane.004 5 | v 10.000000 0.000000 50.000000 6 | v -10.000000 0.000000 -50.000000 7 | v 10.000000 0.000000 -50.000000 8 | v -10.000000 0.000000 50.000000 9 | v -40.000000 0.000000 80.000000 10 | v -40.000000 0.000000 -80.000000 11 | v 40.000000 0.000000 -80.000000 12 | v 40.000000 0.000000 80.000000 13 | v 80.000000 0.000000 80.000000 14 | v 80.000000 0.000000 -80.000000 15 | v -80.000000 0.000000 -80.000000 16 | v -80.000000 0.000000 80.000000 17 | v -110.000000 0.000000 50.000000 18 | v -110.000000 0.000000 -50.000000 19 | v 110.000000 0.000000 -50.000000 20 | v 110.000000 0.000000 50.000000 21 | v -40.000000 0.000000 -20.000000 22 | v 40.000000 0.000000 20.000000 23 | v -40.000000 0.000000 20.000000 24 | v 40.000000 0.000000 -20.000000 25 | v 50.000000 0.000000 -10.000000 26 | v -50.000000 0.000000 10.000000 27 | v 50.000000 0.000000 10.000000 28 | v -50.000000 0.000000 -10.000000 29 | f 4 5 30 | f 3 7 31 | f 8 9 32 | f 7 10 33 | f 6 11 34 | f 5 12 35 | f 12 13 36 | f 11 14 37 | f 10 15 38 | f 9 16 39 | f 13 14 40 | f 15 16 41 | f 1 8 42 | f 2 6 43 | f 2 3 44 | f 1 4 45 | f 17 20 46 | f 18 19 47 | f 19 22 48 | f 18 23 49 | f 20 21 50 | f 17 24 51 | f 22 24 52 | f 21 23 53 | o level0Bounds_Plane.003 54 | v 20.000000 0.000000 -130.000000 55 | v 50.000000 0.000000 -100.000000 56 | v 50.000000 0.000000 -50.000000 57 | v 100.000000 0.000000 -50.000000 58 | v 20.000000 0.000000 130.000000 59 | v 50.000000 0.000000 100.000000 60 | v 50.000000 0.000000 50.000000 61 | v 100.000000 0.000000 50.000000 62 | v 130.000000 0.000000 20.000000 63 | v 130.000000 0.000000 -20.000000 64 | v -130.000000 0.000000 20.000000 65 | v -130.000000 0.000000 -20.000000 66 | v -100.000000 0.000000 -50.000000 67 | v -50.000000 0.000000 -50.000000 68 | v -50.000000 0.000000 -100.000000 69 | v -20.000000 0.000000 -130.000000 70 | v -100.000000 0.000000 50.000000 71 | v -50.000000 0.000000 50.000000 72 | v -50.000000 0.000000 100.000000 73 | v -20.000000 0.000000 130.000000 74 | v 20.000000 0.000000 20.000000 75 | v -20.000000 0.000000 20.000000 76 | v 19.999996 0.000000 -20.000004 77 | v -20.000004 0.000000 -19.999996 78 | f 25 26 79 | f 26 27 80 | f 27 28 81 | f 29 30 82 | f 30 31 83 | f 31 32 84 | f 32 33 85 | f 28 34 86 | f 35 41 87 | f 36 37 88 | f 37 38 89 | f 38 39 90 | f 39 40 91 | f 41 42 92 | f 42 43 93 | f 43 44 94 | f 29 44 95 | f 33 34 96 | f 25 40 97 | f 35 36 98 | f 45 46 99 | f 47 48 100 | f 45 47 101 | f 46 48 102 | o level1Render_Plane.001 103 | v 10.000000 0.000000 50.000000 104 | v -10.000000 0.000000 -50.000000 105 | v 10.000000 0.000000 -50.000000 106 | v -10.000000 0.000000 50.000000 107 | v -40.000000 0.000000 80.000000 108 | v -40.000000 0.000000 -80.000000 109 | v 40.000000 0.000000 -80.000000 110 | v 40.000000 0.000000 80.000000 111 | v 80.000000 0.000000 80.000000 112 | v 80.000000 0.000000 -80.000000 113 | v -80.000000 0.000000 -80.000000 114 | v -80.000000 0.000000 80.000000 115 | v -110.000000 0.000000 50.000000 116 | v -110.000000 0.000000 -50.000000 117 | v 110.000000 0.000000 -50.000000 118 | v 110.000000 0.000000 50.000000 119 | v -40.000000 0.000000 -20.000000 120 | v 40.000000 0.000000 20.000000 121 | v -40.000000 0.000000 20.000000 122 | v 40.000000 0.000000 -20.000000 123 | v 50.000000 0.000000 -10.000000 124 | v -50.000000 0.000000 10.000000 125 | v 50.000000 0.000000 10.000000 126 | v -50.000000 0.000000 -10.000000 127 | v -40.000000 10.000000 -10.000000 128 | v -40.000000 10.000000 10.000000 129 | v 40.000000 10.000000 -10.000000 130 | v 40.000000 10.000000 10.000000 131 | v 110.000000 10.000000 50.000000 132 | v 110.000000 10.000000 -50.000000 133 | v -110.000000 10.000000 -50.000000 134 | v -110.000000 10.000000 50.000000 135 | v -80.000000 10.000000 80.000000 136 | v -80.000000 10.000000 -80.000000 137 | v 80.000000 10.000000 -80.000000 138 | v 80.000000 10.000000 80.000000 139 | v 40.000000 10.000000 80.000000 140 | v 40.000000 10.000000 -80.000000 141 | v -40.000000 10.000000 -80.000000 142 | v -40.000000 10.000000 80.000000 143 | v -10.000000 10.000000 50.000000 144 | v 10.000000 10.000000 -50.000000 145 | v -10.000000 10.000000 -50.000000 146 | v 10.000000 10.000000 50.000000 147 | usemtl (null) 148 | s off 149 | f 71 69 75 76 150 | f 72 70 74 73 151 | f 65 72 73 152 | f 69 68 75 153 | f 66 71 76 154 | f 70 67 74 155 | f 66 67 74 76 156 | f 65 68 75 73 157 | f 49 52 89 92 158 | f 50 51 90 91 159 | f 50 54 87 91 160 | f 49 56 85 92 161 | f 63 64 77 78 162 | f 62 61 80 79 163 | f 57 64 77 84 164 | f 58 63 78 83 165 | f 59 62 79 82 166 | f 60 61 80 81 167 | f 53 60 81 88 168 | f 59 54 87 82 169 | f 58 55 86 83 170 | f 57 56 85 84 171 | f 51 55 86 90 172 | f 52 53 88 89 173 | o level0Render_Plane 174 | v 20.000000 0.000000 -130.000000 175 | v 50.000000 0.000000 -100.000000 176 | v 50.000000 0.000000 -50.000000 177 | v 100.000000 0.000000 -50.000000 178 | v 20.000000 0.000000 130.000000 179 | v 50.000000 0.000000 100.000000 180 | v 50.000000 0.000000 50.000000 181 | v 100.000000 0.000000 50.000000 182 | v 130.000000 0.000000 20.000000 183 | v 130.000000 0.000000 -20.000000 184 | v -130.000000 0.000000 20.000000 185 | v -130.000000 0.000000 -20.000000 186 | v -100.000000 0.000000 -50.000000 187 | v -50.000000 0.000000 -50.000000 188 | v -50.000000 0.000000 -100.000000 189 | v -20.000000 0.000000 -130.000000 190 | v -100.000000 0.000000 50.000000 191 | v -50.000000 0.000000 50.000000 192 | v -50.000000 0.000000 100.000000 193 | v -20.000000 0.000000 130.000000 194 | v 20.000000 0.000000 20.000000 195 | v -20.000000 0.000000 20.000000 196 | v 19.999996 0.000000 -20.000004 197 | v -20.000004 0.000000 -19.999996 198 | v 0.000000 20.000000 0.000000 199 | v -20.000000 20.000000 130.000000 200 | v -50.000000 20.000000 100.000000 201 | v -50.000000 20.000000 50.000000 202 | v -100.000000 20.000000 50.000000 203 | v -20.000000 20.000000 -130.000000 204 | v -50.000000 20.000000 -100.000000 205 | v -50.000000 20.000000 -50.000000 206 | v -100.000000 20.000000 -50.000000 207 | v -130.000000 20.000000 -20.000000 208 | v -130.000000 20.000000 20.000000 209 | v 130.000000 20.000000 -20.000000 210 | v 130.000000 20.000000 20.000000 211 | v 100.000000 20.000000 50.000000 212 | v 50.000000 20.000000 50.000000 213 | v 50.000000 20.000000 100.000000 214 | v 20.000000 20.000000 130.000000 215 | v 100.000000 20.000000 -50.000000 216 | v 50.000000 20.000000 -50.000000 217 | v 50.000000 20.000000 -100.000000 218 | v 20.000000 20.000000 -130.000000 219 | usemtl (null) 220 | s off 221 | f 114 116 117 222 | f 115 113 117 223 | f 116 115 117 224 | f 113 114 117 225 | f 104 103 127 126 226 | f 108 93 137 122 227 | f 102 101 129 128 228 | f 112 97 133 118 229 | f 112 111 119 118 230 | f 111 110 120 119 231 | f 109 110 120 121 232 | f 108 107 123 122 233 | f 106 107 123 124 234 | f 106 105 125 124 235 | f 104 105 125 126 236 | f 103 109 121 127 237 | f 102 96 134 128 238 | f 101 100 130 129 239 | f 100 99 131 130 240 | f 99 98 132 131 241 | f 98 97 133 132 242 | f 96 95 135 134 243 | f 95 94 136 135 244 | f 94 93 137 136 245 | -------------------------------------------------------------------------------- /prelim_tests/nyan-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/nyan-sprite.png -------------------------------------------------------------------------------- /prelim_tests/snake_creature.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/snake_creature.blend -------------------------------------------------------------------------------- /prelim_tests/sprites/megaman_heart_sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/sprites/megaman_heart_sprite.png -------------------------------------------------------------------------------- /prelim_tests/sprites/megaman_heart_sprite_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/sprites/megaman_heart_sprite_2x.png -------------------------------------------------------------------------------- /prelim_tests/sprites/megaman_heart_sprite_4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/sprites/megaman_heart_sprite_4x.png -------------------------------------------------------------------------------- /prelim_tests/sprites/nyan-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/sprites/nyan-sprite.png -------------------------------------------------------------------------------- /prelim_tests/vector_font.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/prelim_tests/vector_font.blend -------------------------------------------------------------------------------- /prelim_tests/vector_font.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'vector_font.blend' 2 | # Material Count: 0 3 | -------------------------------------------------------------------------------- /prelim_tests/vector_font_m_w.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.58 (sub 1) OBJ File: 'vector_font.blend' 2 | # www.blender.org 3 | mtllib vector_font_m_w.mtl 4 | o m 5 | v 0.000000 0.000000 4.000000 6 | v 2.000000 0.000000 1.000000 7 | v 1.000000 0.000000 1.000000 8 | v 1.000000 0.000000 2.000000 9 | v 2.000000 0.000000 4.000000 10 | v 0.000000 0.000000 1.000000 11 | v 0.000000 0.000000 2.000000 12 | f 2 4 13 | f 3 4 14 | f 2 5 15 | f 1 6 16 | f 3 7 17 | o w 18 | v 2.000000 0.000000 1.000000 19 | v 2.000000 0.000000 3.000000 20 | v 0.000000 0.000000 1.000000 21 | v 1.000000 0.000000 3.000000 22 | v 0.000000 0.000000 4.000000 23 | v 1.000000 0.000000 4.000000 24 | f 8 9 25 | f 9 13 26 | f 10 12 27 | f 11 12 28 | f 11 13 29 | -------------------------------------------------------------------------------- /src/font.js: -------------------------------------------------------------------------------- 1 | //Because it's just fine to spend 12K worth of data to include a sexy vector font that I designed in about an hour and a half 2 | NPos3d.Geom.font = { 3 | "!":{"points":[[1,0],[1,2],[1,3],[1,4]],"lines":[[0,1],[2,3]]}, 4 | "\"":{"points":[[1,1],[1,0],[0,0],[0,1]],"lines":[[0,1],[2,3]]}, 5 | "#":{"points":[[2,4],[1,4],[0,3],[0,1],[1,0],[2,0],[2,1],[2,3]],"lines":[[0,5],[1,4],[2,7],[3,6]]}, 6 | "$":{"points":[[1,0],[1,4],[0,3],[0,1],[2,1],[2,3]],"lines":[[0,1],[0,3],[0,4],[1,2],[1,5],[3,5]]}, 7 | "%":{"points":[[0,4],[2,0],[1,4],[2,3],[1,3],[0,1],[1,0],[1,1]],"lines":[[0,1],[2,3],[2,4],[3,4],[5,7],[5,6],[6,7]]}, 8 | "&":{"points":[[2,4],[2,1],[0,1],[1,0],[1,2],[2,3],[0,3],[1,4]],"lines":[[0,2],[1,3],[2,3],[4,6],[5,7],[6,7]]}, 9 | "'":{"points":[[1,1],[1,0]],"lines":[[0,1]]}, 10 | "(":{"points":[[2,0],[2,4],[1,3],[1,1]],"lines":[[0,3],[1,2],[2,3]]}, 11 | ")":{"points":[[1,1],[1,3],[0,4],[0,0]],"lines":[[0,1],[0,3],[1,2]]}, 12 | "*":{"points":[[1,3],[1,1],[0,2],[2,2],[0,3],[2,3],[0,1],[2,1]],"lines":[[0,1],[2,3],[4,7],[5,6]]}, 13 | "+":{"points":[[2,2],[0,2],[1,1],[1,3]],"lines":[[0,1],[2,3]]}, 14 | ",":{"points":[[0,4],[1,3]],"lines":[[0,1]]}, 15 | "-":{"points":[[2,2],[0,2]],"lines":[[0,1]]}, 16 | ".":{"points":[[1,4],[1,3],[0,4]],"lines":[[0,2],[0,1],[1,2]]}, 17 | "/":{"points":[[2,1],[0,3]],"lines":[[0,1]]}, 18 | "0":{"points":[[2,3],[2,1],[0,1],[0,3],[1,4],[1,0]],"lines":[[0,4],[0,1],[1,3],[1,5],[2,3],[2,5],[3,4]]}, 19 | "1":{"points":[[0,1],[0,4],[2,4],[1,0],[1,4]],"lines":[[0,3],[1,2],[3,4]]}, 20 | "2":{"points":[[0,4],[2,1],[1,0],[2,4],[0,1]],"lines":[[0,3],[0,1],[1,2],[2,4]]}, 21 | "3":{"points":[[1,4],[1,0],[0,1],[0,3],[1,2],[2,1],[2,3]],"lines":[[0,3],[0,6],[1,2],[1,5],[4,5],[4,6]]}, 22 | "4":{"points":[[0,0],[2,0],[2,4],[0,2],[2,2]],"lines":[[0,3],[1,2],[3,4]]}, 23 | "5":{"points":[[2,3],[1,2],[0,2],[0,4],[2,0],[1,4],[0,0]],"lines":[[0,5],[0,1],[1,2],[2,6],[3,5],[4,6]]}, 24 | "6":{"points":[[1,0],[0,1],[2,3],[1,4],[0,3],[1,2]],"lines":[[0,1],[1,4],[2,5],[2,3],[3,4],[4,5]]}, 25 | "7":{"points":[[1,4],[2,0],[0,0]],"lines":[[0,1],[1,2]]}, 26 | "8":{"points":[[1,2],[1,4],[1,0],[0,1],[0,3],[2,1],[2,3]],"lines":[[0,6],[0,5],[0,3],[0,4],[1,4],[1,6],[2,3],[2,5]]}, 27 | "9":{"points":[[1,2],[2,1],[1,0],[0,1],[2,3],[1,4]],"lines":[[0,1],[0,3],[1,2],[1,4],[2,3],[4,5]]}, 28 | ":":{"points":[[1,0],[1,1],[1,4],[1,3]],"lines":[[0,1],[2,3]]}, 29 | ";":{"points":[[1,3],[0,4],[1,1],[1,0]],"lines":[[0,1],[2,3]]}, 30 | "<":{"points":[[2,0],[2,4],[0,2]],"lines":[[0,2],[1,2]]}, 31 | "=":{"points":[[2,1],[0,1],[2,3],[0,3]],"lines":[[0,1],[2,3]]}, 32 | ">":{"points":[[2,2],[0,0],[0,4]],"lines":[[0,1],[0,2]]}, 33 | "?":{"points":[[1,2],[2,1],[0,1],[1,0],[1,4],[1,3]],"lines":[[0,1],[1,3],[2,3],[4,5]]}, 34 | "@":{"points":[[2,1],[0,1],[1,0],[0,3],[1,4],[1,2],[1,3],[2,2],[2,3]],"lines":[[0,2],[1,2],[1,3],[3,4],[4,8],[5,7],[5,6],[6,7],[7,8]]}, 35 | "A":{"points":[[2,4],[1,0],[0,2],[0,4],[2,2]],"lines":[[0,4],[1,2],[1,4],[2,4],[2,3]]}, 36 | "B":{"points":[[2,3],[2,1],[1,2],[0,4],[0,0],[1,0],[1,4]],"lines":[[0,2],[0,6],[1,2],[1,5],[3,4],[3,6],[4,5]]}, 37 | "C":{"points":[[2,3],[2,1],[0,1],[0,3],[1,4],[1,0]],"lines":[[0,4],[1,5],[2,3],[2,5],[3,4]]}, 38 | "D":{"points":[[1,4],[1,0],[0,4],[0,0],[2,1],[2,3]],"lines":[[0,2],[0,5],[1,3],[1,4],[2,3],[4,5]]}, 39 | "E":{"points":[[2,4],[2,0],[2,2],[0,4],[0,0],[0,2]],"lines":[[0,3],[1,4],[2,5],[3,4]]}, 40 | "F":{"points":[[0,0],[0,4],[2,2],[2,0],[0,2]],"lines":[[0,3],[0,1],[2,4]]}, 41 | "G":{"points":[[1,2],[2,2],[2,1],[2,3],[1,0],[1,4],[0,3],[0,1]],"lines":[[0,1],[1,3],[2,4],[3,5],[4,7],[5,6],[6,7]]}, 42 | "H":{"points":[[2,4],[2,0],[0,4],[0,0],[0,2],[2,2]],"lines":[[0,1],[2,3],[4,5]]}, 43 | "I":{"points":[[0,4],[2,4],[0,0],[2,0],[1,0],[1,4]],"lines":[[0,1],[2,3],[4,5]]}, 44 | "J":{"points":[[2,0],[2,3],[1,4],[0,3]],"lines":[[0,1],[1,2],[2,3]]}, 45 | "K":{"points":[[0,0],[0,4],[2,0],[2,4],[0,2]],"lines":[[0,1],[2,4],[3,4]]}, 46 | "L":{"points":[[0,0],[2,4],[0,4]],"lines":[[0,2],[1,2]]}, 47 | "M":{"points":[[2,4],[0,4],[1,2],[0,0],[2,0]],"lines":[[0,4],[1,3],[2,3],[2,4]]}, 48 | "N":{"points":[[2,0],[2,4],[0,0],[0,4]],"lines":[[0,1],[1,2],[2,3]]}, 49 | "O":{"points":[[1,0],[1,4],[0,3],[0,1],[2,1],[2,3]],"lines":[[0,3],[0,4],[1,2],[1,5],[2,3],[4,5]]}, 50 | "P":{"points":[[1,0],[0,0],[0,4],[1,2],[2,1],[0,2]],"lines":[[0,1],[0,4],[1,2],[3,4],[3,5]]}, 51 | "Q":{"points":[[2,4],[2,3],[2,1],[0,1],[0,3],[1,4],[1,0]],"lines":[[0,5],[1,5],[1,2],[2,6],[3,4],[3,6],[4,5]]}, 52 | "R":{"points":[[2,4],[2,1],[1,2],[0,4],[0,0],[1,0],[0,2]],"lines":[[0,2],[1,2],[1,5],[2,6],[3,4],[4,5]]}, 53 | "S":{"points":[[2,3],[2,1],[0,1],[0,3],[1,4],[1,0]],"lines":[[0,2],[0,4],[1,5],[2,5],[3,4]]}, 54 | "T":{"points":[[1,4],[2,0],[0,0],[1,0]],"lines":[[0,3],[1,2]]}, 55 | "U":{"points":[[2,3],[2,0],[0,0],[0,3],[1,4]],"lines":[[0,4],[0,1],[2,3],[3,4]]}, 56 | "V":{"points":[[1,4],[0,1],[0,0],[2,0],[2,1]],"lines":[[0,1],[0,4],[1,2],[3,4]]}, 57 | "W":{"points":[[0,4],[2,4],[1,2],[2,0],[0,0]],"lines":[[0,2],[0,4],[1,2],[1,3]]}, 58 | "X":{"points":[[2,0],[0,0],[2,4],[0,4]],"lines":[[0,3],[1,2]]}, 59 | "Y":{"points":[[1,4],[1,2],[0,0],[2,0]],"lines":[[0,1],[1,2],[1,3]]}, 60 | "Z":{"points":[[0,0],[2,4],[2,0],[0,4]],"lines":[[0,2],[1,3],[2,3]]}, 61 | "[":{"points":[[1,0],[1,4],[2,4],[2,0]],"lines":[[0,1],[0,3],[1,2]]}, 62 | "\\":{"points":[[2,3],[0,1]],"lines":[[0,1]]}, 63 | "]":{"points":[[0,0],[0,4],[1,4],[1,0]],"lines":[[0,3],[1,2],[2,3]]}, 64 | "^":{"points":[[0,1],[2,1],[1,0]],"lines":[[0,2],[1,2]]}, 65 | "_":{"points":[[0,4],[2,4]],"lines":[[0,1]]}, 66 | "`":{"points":[[0,0],[1,1]],"lines":[[0,1]]}, 67 | "a":{"points":[[2,4],[2,3],[2,2],[0,2],[0,3],[1,4],[1,1]],"lines":[[0,1],[1,2],[1,5],[2,6],[3,4],[3,6],[4,5]]}, 68 | "b":{"points":[[1,4],[0,0],[0,4],[1,2],[2,3],[0,2]],"lines":[[0,2],[0,4],[1,2],[3,4],[3,5]]}, 69 | "c":{"points":[[1,1],[1,4],[0,3],[0,2],[2,2],[2,3]],"lines":[[0,3],[0,4],[1,2],[1,5],[2,3]]}, 70 | "d":{"points":[[0,3],[1,2],[2,4],[2,0],[1,4],[2,2]],"lines":[[0,1],[0,4],[1,5],[2,4],[2,3]]}, 71 | "e":{"points":[[2,3],[2,2],[0,2],[0,3],[1,4],[1,1]],"lines":[[0,4],[1,2],[1,5],[2,3],[2,5],[3,4]]}, 72 | "f":{"points":[[2,2],[1,1],[1,3],[0,4],[0,2],[0,3]],"lines":[[0,1],[1,4],[2,5],[3,4]]}, 73 | "g":{"points":[[0,5],[1,6],[2,5],[1,1],[1,4],[0,3],[0,2],[2,2],[2,3]],"lines":[[0,1],[1,2],[2,7],[3,6],[3,7],[4,5],[4,8],[5,6]]}, 74 | "h":{"points":[[2,4],[0,0],[0,4],[1,2],[2,3],[0,2]],"lines":[[0,4],[1,2],[3,4],[3,5]]}, 75 | "i":{"points":[[1,1],[1,0],[1,2],[2,4],[0,4],[1,4]],"lines":[[0,1],[2,5],[3,4]]}, 76 | "j":{"points":[[1,2],[1,6],[0,5],[2,5],[2,2]],"lines":[[0,4],[1,3],[1,2],[3,4]]}, 77 | "k":{"points":[[2,4],[0,4],[0,0],[2,3],[2,1],[1,2],[0,2]],"lines":[[0,3],[1,2],[3,5],[4,5],[5,6]]}, 78 | "l":{"points":[[0,2],[2,4],[0,0]],"lines":[[0,1],[0,2]]}, 79 | "m":{"points":[[0,4],[2,1],[1,1],[1,2],[2,4],[0,1],[0,2]],"lines":[[0,5],[1,3],[1,4],[2,3],[2,6]]}, 80 | "n":{"points":[[2,4],[0,4],[1,1],[2,2],[0,2],[0,1]],"lines":[[0,3],[1,4],[2,3],[2,4],[4,5]]}, 81 | "o":{"points":[[2,3],[2,2],[0,2],[0,3],[1,4],[1,1]],"lines":[[0,4],[0,1],[1,5],[2,3],[2,5],[3,4]]}, 82 | "p":{"points":[[2,3],[1,4],[0,6],[0,2],[1,2],[0,4]],"lines":[[0,1],[0,4],[1,5],[2,3],[3,4]]}, 83 | "q":{"points":[[1,2],[2,2],[2,6],[1,4],[0,3],[2,4]],"lines":[[0,1],[0,4],[1,2],[3,4],[3,5]]}, 84 | "r":{"points":[[0,4],[0,1],[1,1],[2,2],[0,2]],"lines":[[0,1],[2,3],[2,4]]}, 85 | "s":{"points":[[1,1],[1,4],[0,3],[0,2],[2,2],[2,3]],"lines":[[0,3],[0,4],[1,2],[1,5],[3,5]]}, 86 | "t":{"points":[[1,1],[0,2],[2,2],[1,4]],"lines":[[0,3],[1,2]]}, 87 | "u":{"points":[[1,4],[0,3],[0,1],[2,1],[2,3]],"lines":[[0,1],[0,4],[1,2],[3,4]]}, 88 | "v":{"points":[[2,1],[0,1],[1,4]],"lines":[[0,2],[1,2]]}, 89 | "w":{"points":[[2,1],[2,3],[0,1],[1,3],[0,4],[1,4]],"lines":[[0,1],[1,5],[2,4],[3,4],[3,5]]}, 90 | "x":{"points":[[2,1],[0,1],[1,2],[0,4],[2,4],[1,3]],"lines":[[0,2],[1,2],[2,5],[3,5],[4,5]]}, 91 | "y":{"points":[[2,1],[0,1],[1,2],[1,4]],"lines":[[0,2],[1,2],[2,3]]}, 92 | "z":{"points":[[0,4],[2,1],[2,4],[0,1]],"lines":[[0,1],[0,2],[1,3]]}, 93 | "{":{"points":[[1,1],[1,3],[0,2],[2,0],[2,4],[1,4],[1,0]],"lines":[[0,2],[0,6],[1,2],[1,5],[3,6],[4,5]]}, 94 | "|":{"points":[[1,0],[1,4]],"lines":[[0,1]]}, 95 | "}":{"points":[[1,1],[1,3],[2,2],[1,0],[1,4],[0,4],[0,0]],"lines":[[0,2],[0,3],[1,2],[1,4],[3,6],[4,5]]}, 96 | "~":{"points":[[1,1],[1,3],[2,2],[0,2]],"lines":[[0,1],[0,3],[1,2]]} 97 | }; 98 | 99 | //VectorText generation! Weeeeeeeeeeeee!!! 100 | 101 | NPos3d.VText = function(args){ 102 | var t = this, type = 'VText'; 103 | if(t.type !== type){throw 'You must use the `new` keyword when invoking the ' + type + ' constructor.';} 104 | args = args || {}; 105 | NPos3d.blessWith3DBase(t,args); 106 | t.string = args.string || 'NEED INPUT'; 107 | t.textAlign = args.textAlign || 'center'; 108 | t.characterWidth = 2; //This is set static because of the design of the font. 109 | t.characterHeight = 4; //This is set static because of the design of the font. 110 | t.characterHeightOffset = 2; //This is set static because of the design of the font. 111 | t.letterSpacing = args.letterSpacing || 1; 112 | t.lineHeight = args.lineHeight || 6; 113 | t.fontSize = args.fontSize|| 32; 114 | t.shape = { 115 | points:[], 116 | lines:[] 117 | }; 118 | t.stringCached = false; 119 | t.font = args.font || NPos3d.Geom.font; 120 | t.cacheTextGeom(); 121 | }; 122 | NPos3d.VText.prototype = { 123 | type: 'VText', 124 | getStateString:function(){ 125 | var t = this; 126 | return (t.string + t.textAlign + t.characterWidth + t.letterSpacing + t.lineHeight + t.fontSize).toString(); 127 | }, 128 | cacheTextGeom:function(){ 129 | var t = this; 130 | //this line is -important-: if any text property changes, new point caches won't be updated without scaling or rotating the object. 131 | t.lastGlobalCompositeMatrixString = false; 132 | 133 | //clear the geom, but keep the array references 134 | t.shape.points.length = 0; 135 | t.shape.lines.length = 0; 136 | 137 | var offsetPointCount = 0; 138 | var textAlignTypes = { 139 | left:{ 140 | charOffset:function(){ 141 | return 0; 142 | }, 143 | spacingOffset: 0 144 | }, 145 | right:{ 146 | charOffset:function(num){ 147 | return -num; 148 | }, 149 | spacingOffset: t.letterSpacing 150 | }, 151 | center: { 152 | charOffset: function(num){ 153 | //Plus 2 because each character is 2 wide. 154 | return -(num / 2); 155 | }, 156 | spacingOffset: t.letterSpacing /2 157 | } 158 | }; 159 | if(textAlignTypes.hasOwnProperty(t.textAlign)){ 160 | var offsetSpacing = textAlignTypes[t.textAlign].spacingOffset; 161 | var linesOText = t.string.split("\n"); 162 | for(var lineNum = 0; lineNum < linesOText.length; lineNum += 1){ 163 | var thisLine = linesOText[lineNum]; 164 | var charCount = thisLine.length; 165 | var offsetCharCount = textAlignTypes[t.textAlign].charOffset(charCount); 166 | for(var charNum = 0; charNum < charCount; charNum += 1){ 167 | var thisChar = thisLine[charNum]; 168 | //console.log(t.string[i]); 169 | if(thisChar === ' '){ 170 | //This is a space character. 171 | //I need to bump over the text by one char, 172 | //but I don't need to add any geom. 173 | }else if(thisChar === '\t'){ 174 | //This is a tab character. 175 | //I need to bump over the text by TWO chars, 176 | //but I don't need to add any geom. 177 | offsetCharCount += 1; 178 | }else if(t.font.hasOwnProperty(thisChar)){ 179 | var letter = t.font[thisChar]; 180 | for(var p = 0; p < letter.points.length; p += 1){ 181 | t.shape.points.push([ 182 | (letter.points[p][0] + ((t.characterWidth + t.letterSpacing) * offsetCharCount) + offsetSpacing) * t.fontSize / t.characterHeight, 183 | (letter.points[p][1] + (t.lineHeight * lineNum) - t.characterHeightOffset) * t.fontSize / t.characterHeight, 184 | letter.points[p][2] || 0 185 | ]); 186 | } 187 | for(var l = 0; l < letter.lines.length; l += 1){ 188 | var line = letter.lines[l]; 189 | t.shape.lines.push([line[0] + offsetPointCount, line[1] + offsetPointCount]); 190 | } 191 | //console.log('#char',thisChar,'#points',t.shape.points,'#lines',t.shape.lines); 192 | offsetPointCount = t.shape.points.length; 193 | }else{ 194 | throw('This font does not contain the character "' + ch + '"'); 195 | } 196 | offsetCharCount += 1; 197 | } 198 | offsetCharCount = 0; 199 | } 200 | }else{ 201 | throw('You passed an unsupported textAlign type named "' + t.textAlign + '"'); 202 | } 203 | 204 | t.stringCached = t.getStateString(); 205 | }, 206 | update:function(s){ 207 | var t = this; 208 | if(t.getStateString() !== t.stringCached){ 209 | t.cacheTextGeom(); 210 | } 211 | t.shape.color = t.color; 212 | }, 213 | destroy:NPos3d.destroyFunc 214 | }; 215 | -------------------------------------------------------------------------------- /src/fx.explosion.js: -------------------------------------------------------------------------------- 1 | NPos3d.Fx = NPos3d.Fx || {}; 2 | 3 | NPos3d.Fx.Explosion = function(args){ 4 | var t = this, type = 'Explosion'; 5 | if(t.type !== type){throw 'You must use the `new` keyword when invoking the ' + type + ' constructor.';} 6 | if(NPos3d.Utils === undefined || NPos3d.Utils.Color === undefined){throw 'Please load the `NPos3d.Utils.Color` library prior to invoking the NPos3d.Fx.Explosion effects.';} 7 | args = args || {}; 8 | //NPos3d.blessWith3DBase(t,args); 9 | if(!args.object || !args.object.shape.lines || !args.object.transformedPointCache){ 10 | throw 'Fx.Explosion requires an Ob3D as the value for the `object` argument in the passed configuration object.'; 11 | } 12 | if(!args.scene || args.scene.type !== 'Scene'){ 13 | throw 'Fx.Explosion requires a Scene as the value for the `scene` argument in the passed configuration object.'; 14 | } 15 | t.o = args.object; 16 | args.scene.add(t); 17 | return t; 18 | }; 19 | 20 | NPos3d.Fx.Explosion.prototype = { 21 | type: 'Explosion', 22 | update: function() { 23 | var t = this; 24 | t.lines = t.o.shape.lines; 25 | t.points = t.o.getTransformedPoints(); 26 | //console.log(t); 27 | t.lines.forEach(function(line){ 28 | var p1 = t.points[line[0]], 29 | p2 = t.points[line[1]], 30 | color = line[2] || t.o.shape.color || t.o.color || t.scene.strokeStyle; 31 | t.scene.add(new NPos3d.Fx.ExplosionLine({ 32 | p1:p1, 33 | p2:p2, 34 | object:t.o, 35 | scene:t.scene, 36 | colorArray: NPos3d.Utils.Color.colorStringToRGBAArray(color) 37 | })); 38 | }); 39 | t.o.destroy(); 40 | t.destroy(); 41 | }, 42 | destroy: NPos3d.destroyFunc 43 | }; 44 | 45 | NPos3d.Fx.ExplosionLine = function(args){ 46 | var t = this, type = 'ExplosionLine'; 47 | if(t.type !== type){throw 'You must use the `new` keyword when invoking the ' + type + ' constructor.';} 48 | args = args || {}; 49 | args.shape = {}; 50 | NPos3d.blessWith3DBase(t,args); 51 | t.o = args.object; 52 | t.scene = args.scene; 53 | t.pos = t.o.gPos.slice(0); 54 | t.p1 = t.subVel(args.p1.slice(0), t.pos); //cloning the points 55 | t.p2 = t.subVel(args.p2.slice(0), t.pos); 56 | t.midpoint = t.getMidpoint(); 57 | t.addVel(t.pos,t.midpoint); 58 | t.subVel(t.p1,t.midpoint); 59 | t.subVel(t.p2,t.midpoint); 60 | t.shape.points = [t.p1,t.p2]; 61 | t.shape.lines = [[0,1]]; 62 | t.colorArray = args.colorArray; 63 | t.vel = args.vel || [t.rint(2),t.rint(2),t.rint(2)]; 64 | t.rotVel = args.rotVel || [t.rneg(2) * deg,t.rneg(2) * deg,t.rneg(2) * deg]; 65 | t.lifespan = 50 + t.rint(100); 66 | t.life = t.lifespan; 67 | t.scene.add(t); 68 | return t; 69 | }; 70 | 71 | NPos3d.Fx.ExplosionLine.prototype = { 72 | type: 'ExplosionLine', 73 | rneg:function(num){return ((Math.random()*2)-1)*num;}, 74 | rint:function(num){return Math.round(((Math.random()*2)-1)*num);}, 75 | rpos:function(n){return Math.random() * n;}, 76 | rintpos:function(n){return Math.round(Math.random() * n);}, 77 | getMidpoint:function(){ 78 | var t = this; 79 | var length = [ 80 | t.p2[0] - t.p1[0], 81 | t.p2[1] - t.p1[1], 82 | t.p2[2] - t.p1[2] 83 | ]; 84 | length[0] /= 2; 85 | length[1] /= 2; 86 | length[2] /= 2; 87 | length[0] += t.p1[0]; 88 | length[1] += t.p1[1]; 89 | length[2] += t.p1[2]; 90 | return length; 91 | }, 92 | addVel:function(o,v){ 93 | o[0] += v[0]; 94 | o[1] += v[1]; 95 | o[2] += v[2]; 96 | return o; 97 | }, 98 | subVel:function(o,v){ 99 | o[0] -= v[0]; 100 | o[1] -= v[1]; 101 | o[2] -= v[2]; 102 | return o; 103 | }, 104 | update:function(){ 105 | var t = this,ca = t.colorArray; 106 | t.addVel(t.pos,t.vel); 107 | t.addVel(t.rot,t.rotVel); 108 | t.color = ['rgba(',ca[0],',',ca[1],',',ca[2],',',(ca[3] * (t.life / t.lifespan)),')'].join(''); 109 | t.life -= 1; 110 | if(t.life < 1){ 111 | t.destroy(); 112 | } 113 | } 114 | }; 115 | -------------------------------------------------------------------------------- /src/fx.tween.js: -------------------------------------------------------------------------------- 1 | NPos3d.Fx = NPos3d.Fx || {}; 2 | 3 | NPos3d.Fx.Tween = function(args){ 4 | var t = this, type = 'Tween'; 5 | if(t.type !== type){throw 'You must use the `new` keyword when invoking the ' + type + ' constructor.';} 6 | if(!args.object){ 7 | throw 'Fx.Tween requires an Object as the value for the `object` argument in the passed configuration object.'; 8 | } 9 | if(!args.properties){ 10 | throw 'Fx.Tween requires an Object as the value for the `properties` argument in the passed configuration object.'; 11 | } 12 | t.o = args.object; 13 | t.properties = args.properties; 14 | t.onUpdate = args.onUpdate || undefined; 15 | t.callback = args.callback || undefined; 16 | t.method = args.method || t.transitionLinear; 17 | t.frames = args.frames || 60; 18 | t.frameState = 0; 19 | t.frac = 0; 20 | t.initialValues = {}; 21 | t.pos = [0,0,0]; // required if the tween is to be in the scene's update queue 22 | for(var p in t.properties){ 23 | if(t.properties.hasOwnProperty(p)){ 24 | var prop = t.properties[p]; 25 | if(prop.length !== undefined){ //if property is an array, clone it 26 | t.initialValues[p] = t.o[p].slice(0); 27 | }else{ 28 | t.initialValues[p] = t.o[p]; 29 | } 30 | } 31 | } 32 | t.o.add(this); 33 | return t; 34 | }; 35 | 36 | NPos3d.Fx.Tween.prototype = { 37 | type: 'Tween', 38 | transitionLinear:function(n){return n;}, 39 | update:function(){ 40 | var t = this; 41 | t.frac = t.method(t.frameState / t.frames); 42 | for(var p in t.properties){ 43 | if(t.properties.hasOwnProperty(p)){ 44 | var prop = t.properties[p]; 45 | var init = t.initialValues[p]; 46 | if(prop.length !== undefined){ //if property is an array, loop through it 47 | for(var i = 0; i < prop.length; i += 1){ 48 | t.o[p][i] = init[i] + ((prop[i] - init[i]) * t.frac); 49 | } 50 | }else{ 51 | t.o[p] = init + ((prop - init) * t.frac); 52 | } 53 | } 54 | } 55 | if(t.onUpdate !== undefined){ 56 | t.onUpdate(t); 57 | } 58 | t.frameState += 1; 59 | if(t.frameState > t.frames){ 60 | if(t.callback !== undefined){ 61 | t.callback(t); 62 | } 63 | t.o.remove(t); 64 | } 65 | } 66 | }; 67 | -------------------------------------------------------------------------------- /src/geom.circle.js: -------------------------------------------------------------------------------- 1 | NPos3d.Geom.Circle = function(args){ 2 | var t = this, type = 'Circle'; 3 | if(t.type !== type){throw 'You must use the `new` keyword when invoking the ' + type + ' constructor.';} 4 | args = args || {}; 5 | t.color = args.color || undefined; 6 | t.segments = args.segments || 12; 7 | t.offset = args.offset || 0; 8 | t.points = []; 9 | t.lines = []; 10 | t.radius = args.radius || 20; 11 | t.axies = args.axies || [0,1,2]; 12 | t.formCircle(); 13 | return t; 14 | }; 15 | NPos3d.Geom.Circle.prototype = { 16 | type: 'Circle', 17 | formCircle: function(){ 18 | var t = this, 19 | m = NPos3d.Maths, 20 | slice = m.tau / t.segments, 21 | i, point, angle; 22 | t.points = []; 23 | t.lines = []; 24 | for(i = 0; i < t.segments; i += 1){ 25 | point = []; 26 | angle = (slice * i) + t.offset; 27 | //relative x 28 | point[t.axies[0]] = m.cos(angle) * t.radius; 29 | //relative y 30 | point[t.axies[1]] = m.sin(angle) * t.radius; 31 | //relative z 32 | point[t.axies[2]] = 0; 33 | t.points.push(point); 34 | //creates the line between the current point and the previous point 35 | if(i > 0 && i <= t.segments){ 36 | t.lines.push([i -1, i]); //,'#0f0' 37 | //closes the gap between the first point and the ending point 38 | if(i === t.segments -1){ 39 | t.lines.push([i, 0]); //,'#f0f' 40 | } 41 | } 42 | } 43 | return t; 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /src/geom.lathe.js: -------------------------------------------------------------------------------- 1 | NPos3d.Geom.Lathe = function(args) { 2 | var t = this, type = 'Lathe'; 3 | if(t.type !== type){ throw type + ' constructor requires the use of the `new` keyword.'; } 4 | if( 5 | typeof args.shape !== 'object' || 6 | typeof args.shape.points !== 'object' || 7 | typeof args.shape.points.length !== 'number' 8 | ){ throw type + ' constructor requires the that the configuration object contains a `shape` property containing an object with a `points` array.'; } 9 | t.shape = args.shape; 10 | t.axis = args.axis === 0 ? 0 : args.axis || 1; 11 | t.segments = args.segments || 12; 12 | t.frac = args.frac || tau; 13 | t.points = []; 14 | t.lines = []; 15 | t.generate(); 16 | }; 17 | 18 | NPos3d.Geom.Lathe.prototype = { 19 | type: 'Lathe', 20 | generate: function() { 21 | var t = this, m = NPos3d.Maths, 22 | segment, segmentAngle = t.frac / parseInt(t.segments), segmentEuler = [0,0,0], segmentMatrix = m.makeMat4(), 23 | pointIndex, pointNum = t.shape.points.length, point, 24 | lineIndex, lineNum = t.shape.lines.length, line; 25 | t.points.length = 0; 26 | t.lines.length = 0; 27 | for(segment = 0; segment < t.segments; segment += 1){ 28 | segmentEuler[t.axis] = segmentAngle * segment; 29 | m.eulerToMat4(segmentEuler, [0,1,2], segmentMatrix); 30 | for(pointIndex = 0; pointIndex < pointNum; pointIndex += 1){ 31 | point = t.shape.points[pointIndex]; 32 | t.points.push(m.p3Mat4Mul(point, segmentMatrix)); 33 | if(t.shape.lines.length > 0){ 34 | if(segment > 0) { 35 | t.lines.push([ 36 | (segment * pointNum) + pointIndex, 37 | ((segment - 1) * pointNum) + pointIndex 38 | ]); 39 | } 40 | if(segment === t.segments -1) { 41 | t.lines.push([ 42 | (segment * pointNum) + pointIndex, 43 | pointIndex 44 | ]); 45 | } 46 | } 47 | } 48 | for(lineIndex = 0; lineIndex < lineNum; lineIndex += 1){ 49 | line = t.shape.lines[lineIndex]; 50 | t.lines.push([ 51 | (segment * pointNum) + line[0], 52 | (segment * pointNum) + line[1] 53 | ]); 54 | } 55 | } 56 | 57 | } 58 | }; 59 | -------------------------------------------------------------------------------- /src/geom.sphere.js: -------------------------------------------------------------------------------- 1 | NPos3d.Geom.Sphere = function(args){ 2 | var o = {};//Output 3 | args = args || {}; 4 | o.color = args.color || undefined; 5 | o.points = []; 6 | o.lines = []; 7 | o.order = args.order || 'xzy'; 8 | var radius = args.radius || 20; 9 | var segments = args.segments || 12; 10 | var rad = tau / segments; 11 | var rings = args.rings || 8; 12 | var sliceWidth = pi / (rings -1); 13 | var pointNum = 0; 14 | var point = 0; 15 | for(var ring = 0; ring < rings; ring += 1){ 16 | var z = (Math.cos(sliceWidth * ring) * (radius)); 17 | if(ring === 0 || ring === (rings -1)){ 18 | if (o.order === 'xyz' || o.order === 'yxz'){o.points.push([0,0,z]);} 19 | else if(o.order === 'xzy' || o.order === 'yzx'){o.points.push([0,z,0]);} 20 | else if(o.order === 'zxy' || o.order === 'zyx'){o.points.push([z,0,0]);} 21 | pointNum = o.points.length - 1; 22 | if(ring === (rings -1)){ 23 | for(point = 0; point < segments; point += 1){ 24 | o.lines.push([(pointNum - point -1),pointNum]); //,'#0f0' 25 | } 26 | } 27 | }else{ 28 | var amp = Math.sin(sliceWidth * ring) * radius; 29 | for(point = 0; point < segments; point += 1){ 30 | var x = Math.sin(rad*point) * amp; 31 | var y = Math.cos(rad*point) * amp; 32 | 33 | if (o.order === 'xyz'){o.points.push([x,y,z]);} 34 | else if(o.order === 'xzy'){o.points.push([x,z,y]);} 35 | else if(o.order === 'zyx'){o.points.push([z,y,x]);} 36 | else if(o.order === 'zxy'){o.points.push([z,x,y]);} 37 | else if(o.order === 'yxz'){o.points.push([y,x,z]);} 38 | else if(o.order === 'yzx'){o.points.push([y,z,x]);} 39 | pointNum = o.points.length - 1; 40 | 41 | //creates the line between this point and the last 42 | if(pointNum < segments +1){ 43 | o.lines.push([0,pointNum]); //,'#0f0' 44 | } 45 | 46 | //draws the rings... 47 | if(pointNum > 1 && point > 0){ 48 | o.lines.push([pointNum -1, pointNum]); //,'#00f' 49 | } 50 | 51 | //closes the gap between the first point in a ring and the last 52 | if(point === segments -1){ 53 | o.lines.push([pointNum - (segments -1), pointNum]); //,'#f0f' 54 | } 55 | 56 | //draws the rings... 57 | if(pointNum > segments){ 58 | o.lines.push([pointNum -segments, pointNum]); 59 | } 60 | 61 | //if(pointNum > segments){ 62 | //s.lines.push([pointNum,]); 63 | } 64 | } 65 | } 66 | return o; 67 | }; 68 | -------------------------------------------------------------------------------- /src/geom.twist.js: -------------------------------------------------------------------------------- 1 | NPos3d.Geom.Twist = function(args) { 2 | var t = this, type = 'Twist'; 3 | if(t.type !== type){ throw type + ' constructor requires the use of the `new` keyword.'; } 4 | if( 5 | typeof args.shape !== 'object' || 6 | typeof args.shape.points !== 'object' || 7 | typeof args.shape.points.length !== 'number' 8 | ){ throw type + ' constructor requires the that the configuration object contains a `shape` property containing an object with a `points` array.'; } 9 | t.shape = args.shape; 10 | if(args.axis === 0){ 11 | t.axis = 0; 12 | } else { 13 | t.axis = args.axis || 1; //y axis 14 | } 15 | t.points = []; 16 | //in radians 17 | t.factor = args.factor === 0 ? 0 : args.factor || tau; 18 | //in radians 19 | t.offset = args.offset || 0; 20 | //TODO: implement limits! 21 | //t.limitUpper = args.limitUpper || 0; 22 | //t.limitLower = args.limitLower || 1; 23 | t.generate(); 24 | } 25 | 26 | NPos3d.Geom.Twist.prototype = { 27 | type: 'Twist', 28 | generate: function() { 29 | var t = this, 30 | m = NPos3d.Maths, 31 | boundingBox = m.nGetBounds(t.shape.points), 32 | length = boundingBox[1][t.axis] - boundingBox[0][t.axis], 33 | pointIndex, pointNum = t.shape.points.length, point, 34 | axisProgression, 35 | twistEuler = [0,0,0], 36 | twistMatrix = m.makeMat4(); 37 | t.points.length = 0; 38 | for(pointIndex = 0; pointIndex < pointNum; pointIndex += 1){ 39 | point = t.shape.points[pointIndex].slice(); 40 | axisProgression = ((point[t.axis] - boundingBox[0][t.axis]) / length) + t.offset; 41 | twistEuler[t.axis] = axisProgression * t.factor; 42 | m.eulerToMat4(twistEuler, [0,1,2], twistMatrix); 43 | m.p3Mat4Mul(point, twistMatrix, point); 44 | t.points.push(point); 45 | } 46 | if(t.shape.lines !== undefined){ 47 | t.lines = t.shape.lines.slice(); 48 | } 49 | //console.log(t.factor, twistEuler[t.axis]); 50 | } 51 | }; 52 | -------------------------------------------------------------------------------- /src/layout.js: -------------------------------------------------------------------------------- 1 | NPos3d.Layout = NPos3d.Layout || {}; 2 | 3 | NPos3d.Layout.ResponsivePoint = function(args) { 4 | var t = this, type = 'ResponsivePoint'; 5 | if(t.type !== type){throw type + ' must be invoked using the `new` keyword.';} 6 | args = args || {}; 7 | if(typeof args.offset !== 'undefined' && typeof args.offset.length !== 'number'){ //does it smell like an array? 8 | throw type + ' constructor MUST be provided an `offset` array argument'; 9 | } 10 | if( 11 | typeof args.scene === 'undefined' || 12 | typeof args.scene.type === 'undefined' || 13 | args.scene.type !== 'Scene' 14 | ){ 15 | throw type + ' constructor MUST be provided a `Scene` object argument'; 16 | } 17 | t.offset = args.offset; 18 | t.scene = args.scene; 19 | t.scene.add(t); //adds itself to the scene automatically, because it needs the scene to work 20 | t.update(); 21 | return t; 22 | }; 23 | 24 | NPos3d.Layout.ResponsivePoint.prototype = []; //it has to smell like a normal vertex 25 | NPos3d.Layout.ResponsivePoint.prototype.type = 'ResponsivePoint'; 26 | NPos3d.Layout.ResponsivePoint.prototype.update = function() { 27 | var t = this, i; 28 | if(t.offset[0] < 0) { 29 | t[0] = t.scene.cx + t.offset[0]; 30 | } else if(t.offset[0] > 0) { 31 | t[0] = t.offset[0] - t.scene.cx; 32 | } else { 33 | t[0] = 0; 34 | } 35 | if(t.offset[1] < 0) { 36 | t[1] = t.scene.cy + t.offset[1]; 37 | } else if(t.offset[1] > 0) { 38 | t[1] = t.offset[1] - t.scene.cy; 39 | } else { 40 | t[1] = 0; 41 | } 42 | t[2] = t.offset[2]; 43 | if(typeof t.offset[3] !== 'undefined') { //set the color property, if it's a vertex 44 | t[3] = t.offset[3]; 45 | t.length = 4; 46 | } else { 47 | t.length = 3; 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /src/sprite.js: -------------------------------------------------------------------------------- 1 | NPos3d.Scene.prototype.drawSprite = function(c,o){ 2 | c.save(); 3 | c.translate(o.point2D.x, o.point2D.y); 4 | if(o.depthScale){ 5 | c.scale(o.spriteScale * o.point2D.scale, o.spriteScale * o.point2D.scale); 6 | } else { 7 | c.scale(o.spriteScale, o.spriteScale); 8 | } 9 | c.rotate(o.spriteRot); 10 | if(o.numFrames > 1){ 11 | o.frameState += 0.3; 12 | if(o.frameState >= o.numFrames){ 13 | o.frameState = 0; 14 | } 15 | c.drawImage(o.image, (o.width * Math.floor(o.frameState)), 0, o.width, o.height, o.offset.x, o.offset.y, o.width, o.height); 16 | }else{ 17 | c.drawImage(o.image, o.offset.x, o.offset.y); 18 | } 19 | c.restore(); 20 | }; 21 | NPos3d.Scene.prototype.renderSprite = function(o){ 22 | var t = this; 23 | o.updateMatrices(); 24 | if(o.loaded){ 25 | //offset the points by the object's position 26 | var p3 = o.gPos; 27 | if( p3[2] < t.camera.clipNear && p3[2] > t.camera.clipFar ){ 28 | o.point2D = t.camera.project3Dto2D(p3); //a convenience measure 29 | //Just some basic positional culling... if it's not on screen, don't render it... 30 | if( 31 | (o.point2D.x + (o.offset.x * o.point2D.scale) < t.cx && o.point2D.x - (o.offset.x * o.point2D.scale) > -t.cx) && 32 | (o.point2D.y + (o.offset.y * o.point2D.scale) < t.cy && o.point2D.y - (o.offset.y * o.point2D.scale) > -t.cy) 33 | ){ 34 | t.renderInstructionList.push({ 35 | method: t.drawSprite, 36 | args: o, //It just seemed silly to re-define all of the render args over again in a new object 37 | z: p3[2] 38 | }); 39 | } 40 | } 41 | } 42 | }; 43 | NPos3d.renderSpriteFunc = function(){ 44 | this.scene.renderSprite(this); 45 | }; 46 | 47 | NPos3d.blessWithSpriteBase = function(o,config){ 48 | if(!config.path){throw 'You MUST provide an image `path` value on sprite type objects!'}; 49 | 50 | NPos3d.blessWith3DBase(o, config); //Add universal 3D properties to the object first 51 | 52 | o.spriteRot = config.spriteRot || 0; 53 | o.spriteScale = config.spriteScale || 1; 54 | o.depthScale = config.depthScale || false; //Default behavior: Act as a non-scaling billboard 55 | o.numFrames = config.numFrames || 1; 56 | o.frameState = o.numFrames; 57 | o.width = 0; 58 | o.height = 0; 59 | o.loaded = false; 60 | o.image = new Image(); 61 | o.image.onload = function(){ 62 | o.width = o.image.width / o.numFrames; 63 | o.height = o.image.height; 64 | o.offset = { 65 | x:-Math.round(o.width/2), 66 | y:-Math.round(o.height/2) 67 | }; 68 | o.boundingBox = [[o.offset.x,o.offset.y,-32],[-o.offset.x,-o.offset.y,32]]; 69 | o.loaded = true; 70 | //console.log(t); 71 | }; 72 | o.render = NPos3d.renderSpriteFunc; 73 | o.image.src = config.path; 74 | return o; 75 | }; 76 | 77 | NPos3d.Sprite3D = function(config){ 78 | var t = this, type = 'Sprite3D'; 79 | if(t.type !== type){throw 'You must use the `new` keyword when invoking the ' + type + ' constructor.';} 80 | NPos3d.blessWithSpriteBase(t,config); 81 | return t; 82 | }; 83 | 84 | NPos3d.Sprite3D.prototype = { 85 | type: 'Sprite3D', 86 | update:function(){}, 87 | destroy:NPos3d.destroyFunc 88 | }; 89 | -------------------------------------------------------------------------------- /src/utils.color.js: -------------------------------------------------------------------------------- 1 | NPos3d.Utils = NPos3d.Utils || {}; 2 | 3 | NPos3d.Utils.Color = { 4 | detectCSSColorType: function(string){ 5 | if(string.indexOf('#') > -1){ 6 | return 'hex'; 7 | } 8 | else if(string.toLowerCase().indexOf('rgb') > -1){ 9 | return 'rgb'; 10 | } 11 | else if(string.toLowerCase().indexOf('hsl') > -1){ 12 | return 'hsl'; 13 | } 14 | else if(string.toLowerCase().indexOf('hsv') > -1){ 15 | return 'hsv'; 16 | } 17 | return false; 18 | }, 19 | hexToDec:function(string){ 20 | return parseInt(string,16); 21 | }, 22 | convertHexToRGBArray: function(string){ 23 | var r, g, b,chars = string.split(''),h = NPos3d.Utils.Color.hexToDec; 24 | if(chars.length < 7){ 25 | r = h(''+chars[1]+chars[1]); 26 | g = h(''+chars[2]+chars[2]); 27 | b = h(''+chars[3]+chars[3]); 28 | }else{ 29 | r = h(''+chars[1]+chars[2]); 30 | g = h(''+chars[3]+chars[4]); 31 | b = h(''+chars[5]+chars[6]); 32 | } 33 | return [r, g, b]; 34 | }, 35 | parenColorToArray:function(string){ 36 | return string.replace(/rgb|hsl|hsv|a|\(|\)|;|%| /g, '').split(',').map(function(v,k){if(k<3){return parseInt(v);}else{return parseFloat(v);}}); 37 | }, 38 | rgbArrayToHLSArray:function(inp){ 39 | var o = NPos3d.Utils.Color.rgbToHsl(inp[0],inp[1],inp[2]); 40 | o[0] *= 360; 41 | o[1] *= 100; 42 | o[2] *= 100; 43 | if(inp.length > 3){o.push(inp[3]);} 44 | return o; 45 | }, 46 | hslArrayToRGBArray:function(inp){ 47 | var o = NPos3d.Utils.Color.hslToRgb((inp[0] % 360) / 360,inp[1] / 100, inp[2]/ 100), r = Math.round; 48 | o[0] = r(o[0]); 49 | o[1] = r(o[1]); 50 | o[2] = r(o[2]); 51 | if(inp.length > 3){o.push(inp[3]);} 52 | return o; 53 | }, 54 | colorStringToHSLAArray:function(string){ 55 | var t = NPos3d.Utils.Color, type = t.detectCSSColorType(string), nums = [], d; 56 | if(type === 'hex'){ 57 | d = t.convertHexToRGBArray(string); 58 | d = t.rgbArrayToHLSArray(d); 59 | nums.push(d[0],d[1],d[2],1); 60 | } 61 | else if(type === 'rgb'){ 62 | d = t.parenColorToArray(string); 63 | d = t.rgbArrayToHLSArray(d); 64 | nums.push(d[0],d[1],d[2],d[3]||1); 65 | } 66 | else if(type === 'hsl'){ 67 | d = t.parenColorToArray(string); 68 | nums.push(d[0],d[1],d[2],d[3]||1); 69 | } 70 | return nums; 71 | }, 72 | colorStringToHSLAString:function(string){ 73 | var t = NPos3d.Utils.Color, 74 | n = t.colorStringToHSLAArray(string), 75 | output = ['hsla(',n[0]+',',n[1]+'%,',n[2]+'%,',n[3],');']; 76 | return output.join(''); 77 | }, 78 | colorStringToRGBAArray:function(string){ 79 | var t = NPos3d.Utils.Color, type = t.detectCSSColorType(string), nums = [],d; 80 | if(type === 'hex'){ 81 | d = t.convertHexToRGBArray(string); 82 | nums.push(d[0],d[1],d[2],1); 83 | } 84 | else if(type === 'hsl'){ 85 | d = t.parenColorToArray(string); 86 | d = t.hslArrayToRGBArray(d); 87 | nums.push(d[0],d[1],d[2],d[3]||1); 88 | } 89 | else if(type === 'rgb'){ 90 | d = t.parenColorToArray(string); 91 | nums.push(d[0],d[1],d[2],d[3]||1); 92 | } 93 | return nums; 94 | }, 95 | colorStringToRGBAString:function(string){ 96 | var t = NPos3d.Utils.Color, 97 | output = ['rgba(',t.colorStringToRGBAArray(string).join(),');']; 98 | return output.join(''); 99 | }, 100 | 101 | //The following functions pulled from: 102 | //http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript 103 | /** 104 | * Converts an RGB color value to HSL. Conversion formula 105 | * adapted from http://en.wikipedia.org/wiki/HSL_color_space. 106 | * Assumes r, g, and b are contained in the set [0, 255] and 107 | * returns h, s, and l in the set [0, 1]. 108 | * 109 | * @param Number r The red color value 110 | * @param Number g The green color value 111 | * @param Number b The blue color value 112 | * @return Array The HSL representation 113 | */ 114 | rgbToHsl:function(r, g, b){ 115 | r /= 255, g /= 255, b /= 255; 116 | var max = Math.max(r, g, b), min = Math.min(r, g, b); 117 | var h, s, l = (max + min) / 2; 118 | 119 | if(max == min){ 120 | h = s = 0; // achromatic 121 | }else{ 122 | var d = max - min; 123 | s = l > 0.5 ? d / (2 - max - min) : d / (max + min); 124 | switch(max){ 125 | case r: h = (g - b) / d + (g < b ? 6 : 0); break; 126 | case g: h = (b - r) / d + 2; break; 127 | case b: h = (r - g) / d + 4; break; 128 | } 129 | h /= 6; 130 | } 131 | 132 | return [h, s, l]; 133 | }, 134 | /** 135 | * Converts an HSL color value to RGB. Conversion formula 136 | * adapted from http://en.wikipedia.org/wiki/HSL_color_space. 137 | * Assumes h, s, and l are contained in the set [0, 1] and 138 | * returns r, g, and b in the set [0, 255]. 139 | * 140 | * @param Number h The hue 141 | * @param Number s The saturation 142 | * @param Number l The lightness 143 | * @return Array The RGB representation 144 | */ 145 | hslToRgb:function(h, s, l){ 146 | var r, g, b; 147 | 148 | if(s == 0){ 149 | r = g = b = l; // achromatic 150 | }else{ 151 | function hue2rgb(p, q, t){ 152 | if(t < 0) t += 1; 153 | if(t > 1) t -= 1; 154 | if(t < 1/6) return p + (q - p) * 6 * t; 155 | if(t < 1/2) return q; 156 | if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; 157 | return p; 158 | } 159 | 160 | var q = l < 0.5 ? l * (1 + s) : l + s - l * s; 161 | var p = 2 * l - q; 162 | r = hue2rgb(p, q, h + 1/3); 163 | g = hue2rgb(p, q, h); 164 | b = hue2rgb(p, q, h - 1/3); 165 | } 166 | 167 | return [r * 255, g * 255, b * 255]; 168 | } 169 | }; 170 | -------------------------------------------------------------------------------- /tests/basic_scene.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Basic Scene 5 | 6 | 7 | 8 | 9 | 10 | 11 | 74 | 75 | -------------------------------------------------------------------------------- /tests/cached_vert_position.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Cached Vertex Position 5 | 6 | 7 | 8 | 9 | 10 | 63 | 64 | -------------------------------------------------------------------------------- /tests/camera_movement.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NPos3D Camera Movement test 6 | 7 | 8 | 9 | 10 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /tests/circles.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Testing some circle geometry 6 | 7 | 8 | 9 | 10 | 11 | 67 | 68 | -------------------------------------------------------------------------------- /tests/destroy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Destroy 5 | 6 | 7 | 8 | 29 | 30 | -------------------------------------------------------------------------------- /tests/draw_points.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | drawPoints 5 | 6 | 7 | 8 | 9 | 10 | 73 | 74 | -------------------------------------------------------------------------------- /tests/existing_canvas.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Existing Canvas 5 | 18 | 19 | 20 |
21 | 22 | 23 | 45 | 46 | -------------------------------------------------------------------------------- /tests/explosion.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Explosion 5 | 6 | 7 | 8 | 9 | 10 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /tests/img/3px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/3px.png -------------------------------------------------------------------------------- /tests/img/4x4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/4x4.png -------------------------------------------------------------------------------- /tests/img/adam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/adam.png -------------------------------------------------------------------------------- /tests/img/adam.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/adam.psd -------------------------------------------------------------------------------- /tests/img/bw_grad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/bw_grad.png -------------------------------------------------------------------------------- /tests/img/bw_grad.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/bw_grad.psd -------------------------------------------------------------------------------- /tests/img/dexter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/dexter.png -------------------------------------------------------------------------------- /tests/img/h.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/h.gif -------------------------------------------------------------------------------- /tests/img/heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heart.png -------------------------------------------------------------------------------- /tests/img/heart_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heart_sort.png -------------------------------------------------------------------------------- /tests/img/heartsub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub.png -------------------------------------------------------------------------------- /tests/img/heartsub_100.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_100.jpg -------------------------------------------------------------------------------- /tests/img/heartsub_50.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_50.jpg -------------------------------------------------------------------------------- /tests/img/heartsub_51.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_51.jpg -------------------------------------------------------------------------------- /tests/img/heartsub_60.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_60.jpg -------------------------------------------------------------------------------- /tests/img/heartsub_70.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_70.jpg -------------------------------------------------------------------------------- /tests/img/heartsub_80.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_80.jpg -------------------------------------------------------------------------------- /tests/img/heartsub_90.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_90.jpg -------------------------------------------------------------------------------- /tests/img/heartsub_anim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_anim.png -------------------------------------------------------------------------------- /tests/img/heartsub_anim.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_anim.psd -------------------------------------------------------------------------------- /tests/img/heartsub_anim_360.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_anim_360.png -------------------------------------------------------------------------------- /tests/img/heartsub_anim_360.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/heartsub_anim_360.psd -------------------------------------------------------------------------------- /tests/img/hole_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/hole_16.png -------------------------------------------------------------------------------- /tests/img/hole_16.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/hole_16.psd -------------------------------------------------------------------------------- /tests/img/hv.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/hv.gif -------------------------------------------------------------------------------- /tests/img/hv.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/hv.psd -------------------------------------------------------------------------------- /tests/img/intersphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/intersphere.png -------------------------------------------------------------------------------- /tests/img/meg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/meg.png -------------------------------------------------------------------------------- /tests/img/meg.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/meg.psd -------------------------------------------------------------------------------- /tests/img/megface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/megface.png -------------------------------------------------------------------------------- /tests/img/megface.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/megface.psd -------------------------------------------------------------------------------- /tests/img/noise_spectrum_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/noise_spectrum_16.png -------------------------------------------------------------------------------- /tests/img/noise_spectrum_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/noise_spectrum_32.png -------------------------------------------------------------------------------- /tests/img/rupee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/rupee.png -------------------------------------------------------------------------------- /tests/img/rupeebev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/rupeebev.png -------------------------------------------------------------------------------- /tests/img/spectrum_128.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_128.psd -------------------------------------------------------------------------------- /tests/img/spectrum_16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_16.jpg -------------------------------------------------------------------------------- /tests/img/spectrum_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_16.png -------------------------------------------------------------------------------- /tests/img/spectrum_16.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_16.psd -------------------------------------------------------------------------------- /tests/img/spectrum_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_24.png -------------------------------------------------------------------------------- /tests/img/spectrum_24.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_24.psd -------------------------------------------------------------------------------- /tests/img/spectrum_24_hue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_24_hue.png -------------------------------------------------------------------------------- /tests/img/spectrum_24_luminosity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_24_luminosity.png -------------------------------------------------------------------------------- /tests/img/spectrum_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_32.png -------------------------------------------------------------------------------- /tests/img/spectrum_anim_360.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_anim_360.png -------------------------------------------------------------------------------- /tests/img/spectrum_anim_360.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_anim_360.psd -------------------------------------------------------------------------------- /tests/img/spectrum_limited_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_limited_16.png -------------------------------------------------------------------------------- /tests/img/spectrum_linear_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_linear_128.png -------------------------------------------------------------------------------- /tests/img/spectrum_linear_128.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_linear_128.psd -------------------------------------------------------------------------------- /tests/img/spectrum_wtf_anim_360.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/spectrum_wtf_anim_360.psd -------------------------------------------------------------------------------- /tests/img/sphere2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/sphere2.png -------------------------------------------------------------------------------- /tests/img/sphere3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/sphere3.png -------------------------------------------------------------------------------- /tests/img/sphere3.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/sphere3.psd -------------------------------------------------------------------------------- /tests/img/swinj_gold_tooth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/swinj_gold_tooth.png -------------------------------------------------------------------------------- /tests/img/swinj_gold_tooth_4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/swinj_gold_tooth_4x.png -------------------------------------------------------------------------------- /tests/img/swinj_green_hat_sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/swinj_green_hat_sprite.png -------------------------------------------------------------------------------- /tests/img/swinj_green_hat_sprite_4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/swinj_green_hat_sprite_4x.png -------------------------------------------------------------------------------- /tests/img/v.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/img/v.gif -------------------------------------------------------------------------------- /tests/lathe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Lathe 5 | 57 | 58 | 59 |
60 | 61 | 62 | 63 |
64 | 65 | 66 | 196 | 197 | -------------------------------------------------------------------------------- /tests/lathe_twist.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Lathe & Twist 5 | 73 | 74 | 75 |
76 | 77 | 96 | 97 |
98 | 99 | 100 | 101 | 240 | 241 | -------------------------------------------------------------------------------- /tests/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Layout 5 | 37 | 38 | 39 |
40 | Resize the window and watch the objects.
41 | 
42 | 
43 | 44 | 45 | 46 | 89 | 90 | -------------------------------------------------------------------------------- /tests/mat4_basics.html: -------------------------------------------------------------------------------- 1 | See the console for output. 2 | -------------------------------------------------------------------------------- /tests/models/diamond.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.63 (sub 0) OBJ File: 'obj_content.blend' 2 | # www.blender.org 3 | o diamond_Cube 4 | v -1.000000 0.000000 0.000000 5 | v 0.000000 0.000000 -1.000000 6 | v 0.000000 -1.000000 0.000000 7 | v 0.000000 1.000000 0.000000 8 | v 1.000000 0.000000 0.000000 9 | v 0.000000 0.000000 1.000000 10 | s off 11 | f 2 1 4 12 | f 4 1 6 13 | f 4 5 2 14 | f 2 5 3 15 | f 6 1 3 16 | f 1 2 3 17 | f 6 5 4 18 | f 5 6 3 19 | -------------------------------------------------------------------------------- /tests/models/diamond_rounded.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.63 (sub 0) OBJ File: 'obj_content.blend' 2 | # www.blender.org 3 | o diamond.001_Cube.003 4 | v -1.000000 0.000000 0.000000 5 | v 0.000000 0.000000 -1.000000 6 | v 0.000000 -1.000000 0.000000 7 | v 0.000000 1.000000 0.000000 8 | v 1.000000 0.000000 0.000000 9 | v 0.000000 0.000000 1.000000 10 | v 0.000000 0.646000 -0.646000 11 | v -0.646000 0.000000 -0.646000 12 | v 0.646000 0.646000 0.000000 13 | v 0.646000 0.000000 0.646000 14 | v 0.000000 -0.646000 0.646000 15 | v -0.646000 0.646000 0.000000 16 | v -0.646000 -0.646000 0.000000 17 | v 0.000000 0.646000 0.646000 18 | v -0.646000 0.000000 0.646000 19 | v 0.646000 0.000000 -0.646000 20 | v 0.000000 -0.646000 -0.646000 21 | v 0.646000 -0.646000 0.000000 22 | s off 23 | f 4 7 12 24 | f 6 14 15 25 | f 4 9 7 26 | f 2 16 17 27 | f 6 15 11 28 | f 1 8 13 29 | f 6 10 14 30 | f 5 10 18 31 | f 8 1 12 32 | f 12 7 8 33 | f 7 2 8 34 | f 12 1 15 35 | f 15 14 12 36 | f 14 4 12 37 | f 7 16 2 38 | f 7 9 16 39 | f 9 5 16 40 | f 17 18 3 41 | f 17 16 18 42 | f 16 5 18 43 | f 11 13 3 44 | f 11 15 13 45 | f 15 1 13 46 | f 13 17 3 47 | f 13 8 17 48 | f 8 2 17 49 | f 14 9 4 50 | f 14 10 9 51 | f 10 5 9 52 | f 18 11 3 53 | f 18 10 11 54 | f 10 6 11 55 | -------------------------------------------------------------------------------- /tests/models/interesting_shape.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/models/interesting_shape.blend -------------------------------------------------------------------------------- /tests/models/meg.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/models/meg.blend -------------------------------------------------------------------------------- /tests/models/obj_content.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/models/obj_content.blend -------------------------------------------------------------------------------- /tests/models/pn3_test_shapes.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/models/pn3_test_shapes.blend -------------------------------------------------------------------------------- /tests/parenting.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Parenting 5 | 6 | 7 | 8 | 9 | 10 | 11 | 96 | 97 | -------------------------------------------------------------------------------- /tests/particle_toy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Particle Toy 5 | 6 | 7 | 8 | 75 | 76 | -------------------------------------------------------------------------------- /tests/particle_toy_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Particle Toy 1 5 | 6 | 7 | 8 | 88 | 89 | -------------------------------------------------------------------------------- /tests/pixel_scale.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Basic Scene + pixelScale 6 | 7 | 8 | 9 | 10 | 11 | 12 | 44 | 45 | -------------------------------------------------------------------------------- /tests/pn3_files/demonpuppy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/pn3_files/demonpuppy.png -------------------------------------------------------------------------------- /tests/pn3_files/shade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/pn3_files/shade.png -------------------------------------------------------------------------------- /tests/pn3_files/trents_devilguy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdmiralPotato/npos3d/0c46993e2b64771cbfcead0ee652d017a707faee/tests/pn3_files/trents_devilguy.png -------------------------------------------------------------------------------- /tests/pn3_idea_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PN3 Idea Test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 154 | 155 | -------------------------------------------------------------------------------- /tests/pn3_image_manip_toy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PN3 Image Manip Toy 6 | 7 | 8 | 9 | 10 | 11 | 12 | 132 | 133 | -------------------------------------------------------------------------------- /tests/pn3_sprite_anim.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PN3 Image Manip Toy 6 | 7 | 8 | 9 | 10 | 11 | 12 | 121 | 122 | -------------------------------------------------------------------------------- /tests/pn3_what_does_jpeg_do.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PN3 Idea Test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 99 | 100 | -------------------------------------------------------------------------------- /tests/point_at.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Point At 5 | 6 | 7 | 8 | 52 | 53 | -------------------------------------------------------------------------------- /tests/point_format_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Testing to see which format of point is faster. 5 | 6 | 7 |
Please wait while the speed test is performed.
8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/point_format_test.js: -------------------------------------------------------------------------------- 1 | var timer = { 2 | q:{}, 3 | start:function(string){ 4 | this.q[string] = { 5 | start: false, 6 | stop: false, 7 | diff: false 8 | }; 9 | var rec = this.q[string], 10 | now = new Date(); 11 | rec.start = now.getTime(); 12 | document.body.innerHTML += 'starting ' + string + '
'; 13 | }, 14 | stop:function(string){ 15 | var rec = this.q[string], 16 | now = new Date(); 17 | rec.stop = now.getTime(); 18 | rec.diff = rec.stop - rec.start; 19 | return rec.diff; 20 | } 21 | }; 22 | 23 | var totalRotationCalculations = 0; 24 | var rotatePoint = function(x,y,rad){ 25 | var length = Math.sqrt((x * x) + (y * y)), 26 | currentRad = Math.atan2(x,y); 27 | x = Math.sin(currentRad - rad) * length; 28 | y = Math.cos(currentRad - rad) * length; 29 | totalRotationCalculations += 1; 30 | return [x,y]; 31 | }; 32 | //--start array styled functions-- 33 | var arrayClone = function(a){ 34 | return [a[0], a[1], a[2]]; 35 | }; 36 | var arrayAdd = function(a,b){ 37 | a[0] += b[0]; 38 | a[1] += b[1]; 39 | a[2] += b[2]; 40 | }; 41 | var arraySub = function(a,b){ 42 | a[0] -= b[0]; 43 | a[1] -= b[1]; 44 | a[2] -= b[2]; 45 | }; 46 | var arrayMul = function(a,n){ 47 | a[0] *= n; 48 | a[1] *= n; 49 | a[2] *= n; 50 | }; 51 | var arrayDiv = function(a,n){ 52 | a[0] /= n; 53 | a[1] /= n; 54 | a[2] /= n; 55 | }; 56 | var arrayScale = function(a,b){ 57 | a[0] *= b[0]; 58 | a[1] *= b[1]; 59 | a[2] *= b[2]; 60 | }; 61 | var arrayRotate = function(a,rot,order){ 62 | var x = a[0], y = a[1], z = a[2], r; 63 | order = order || [0,1,2]; 64 | for(r = 0; r < order.length; r += 1){ 65 | if(order[r] === 0){ 66 | //x... 67 | if(rot[0] !== 0){ 68 | var zy = rotatePoint(z,y,rot[0]); 69 | z = zy[0]; 70 | y = zy[1]; 71 | } 72 | }else if(order[r] === 1){ 73 | //y... 74 | if(rot[1] !== 0){ 75 | var xz = rotatePoint(x,z,rot[1]); 76 | x = xz[0]; 77 | z = xz[1]; 78 | } 79 | }else if(order[r] === 2){ 80 | //z... 81 | if(rot[2] !== 0){ 82 | var xy = rotatePoint(x,y,rot[2]); 83 | x = xy[0]; 84 | y = xy[1]; 85 | } 86 | }else{ 87 | throw 'up'; 88 | } 89 | } 90 | a[0] = x; 91 | a[1] = y; 92 | a[2] = z; 93 | return a; 94 | }; 95 | //--end array styled functions-- 96 | 97 | //--start object styled functions-- 98 | var objectClone = function(a){ 99 | return {x: a.x, y: a.y, z: a.z}; 100 | }; 101 | var objectAdd = function(a,b){ 102 | a.x += b.x; 103 | a.y += b.y; 104 | a.z += b.z; 105 | }; 106 | var objectSub = function(a,b){ 107 | a.x -= b.x; 108 | a.y -= b.y; 109 | a.z -= b.z; 110 | }; 111 | var objectScale = function(a,b){ 112 | a.x *= b.x; 113 | a.y *= b.y; 114 | a.z *= b.z; 115 | }; 116 | var objectMul = function(a,n){ 117 | a.x *= n; 118 | a.y *= n; 119 | a.z *= n; 120 | }; 121 | var objectDiv = function(a,n){ 122 | a.x /= n; 123 | a.y /= n; 124 | a.z /= n; 125 | }; 126 | var objectRotate = function(a,rot,order){ 127 | var x = a.x, y = a.y, z = a.z, r; 128 | order = order || [0,1,2]; 129 | for(r = 0; r < order.length; r += 1){ 130 | if(order[r] === 0){ 131 | //x... 132 | if(rot.x !== 0){ 133 | var zy = rotatePoint(z,y,rot.x); 134 | z = zy[0]; 135 | y = zy[1]; 136 | } 137 | }else if(order[r] === 1){ 138 | //y... 139 | if(rot.y !== 0){ 140 | var xz = rotatePoint(x,z,rot.y); 141 | x = xz[0]; 142 | z = xz[1]; 143 | } 144 | }else if(order[r] === 2){ 145 | //z... 146 | if(rot.z !== 0){ 147 | var xy = rotatePoint(x,y,rot.z); 148 | x = xy[0]; 149 | y = xy[1]; 150 | } 151 | }else{ 152 | throw 'up'; 153 | } 154 | } 155 | a.x = x; 156 | a.y = y; 157 | a.z = z; 158 | return a; 159 | }; 160 | //--end array styled functions-- 161 | 162 | 163 | var approaches = { 164 | array: { 165 | create: function(input, output, key) { 166 | input.push([ 167 | (Math.random() * 100), 168 | (Math.random() * 100), 169 | (Math.random() * 100) 170 | ]); 171 | }, 172 | clone: function(input, output, key) { 173 | output.push(arrayClone(input[key])); 174 | }, 175 | mul: function(input, output, key) { 176 | arrayMul(output[key], Math.random() * 100); 177 | }, 178 | scale: function(input, output, key) { 179 | arrayScale(output[key], [ 180 | (Math.random() * 100), 181 | (Math.random() * 100), 182 | (Math.random() * 100) 183 | ]); 184 | }, 185 | rotate: function(input, output, key) { 186 | arrayRotate(output[key], [ 187 | (Math.random() * 100), 188 | (Math.random() * 100), 189 | (Math.random() * 100) 190 | ]); 191 | } 192 | }, 193 | objectLiteral: { 194 | create: function(input, output, key) { 195 | input.push({ 196 | x: (Math.random() * 100), 197 | y: (Math.random() * 100), 198 | z: (Math.random() * 100) 199 | }); 200 | }, 201 | clone: function(input, output, key) { 202 | output.push(objectClone(input[key])); 203 | }, 204 | mul: function(input, output, key) { 205 | objectMul(output[key], Math.random() * 100); 206 | }, 207 | scale: function(input, output, key) { 208 | objectScale(output[key], { 209 | x: (Math.random() * 100), 210 | y: (Math.random() * 100), 211 | z: (Math.random() * 100) 212 | }); 213 | }, 214 | rotate: function(input, output, key) { 215 | objectRotate(output[key], { 216 | x: (Math.random() * 100), 217 | y: (Math.random() * 100), 218 | z: (Math.random() * 100) 219 | }); 220 | } 221 | }, 222 | vec3: { 223 | create: function(input, output, key) { 224 | input.push(new Vec3( 225 | (Math.random() * 100), 226 | (Math.random() * 100), 227 | (Math.random() * 100) 228 | )); 229 | }, 230 | clone: function(input, output, key) { 231 | output.push(input[key].clone()); 232 | }, 233 | mul: function(input, output, key) { 234 | output[key].mul(Math.random() * 100); 235 | }, 236 | scale: function(input, output, key) { 237 | output[key].scale( 238 | (Math.random() * 100), 239 | (Math.random() * 100), 240 | (Math.random() * 100) 241 | ); 242 | }, 243 | rotate: function(input, output, key) { 244 | output[key].rotate( 245 | [ 246 | (Math.random() * 100), 247 | (Math.random() * 100), 248 | (Math.random() * 100) 249 | ] 250 | ); 251 | } 252 | } 253 | }; 254 | 255 | var operationCount = 500000; 256 | var speedTest = function(taskName, task, input, output){ 257 | var i; 258 | timer.start(taskName); 259 | for(i = 0; i < operationCount; i += 1){ 260 | task(input, output, i); 261 | } 262 | return timer.stop(taskName); 263 | }; 264 | 265 | var arrayList = [], 266 | arrayListTransformed = [], 267 | objectLiteralList = [], 268 | objectLiteralListTransformed = [], 269 | vec3List = [], 270 | vec3ListTransformed = []; 271 | 272 | alert('Be patient, this is going to take a minute.'); 273 | var approach, task, result, table = ['All operations completed ', operationCount, ' times. Smaller numbers are better.
'], tableHeader = [], tableRow = [], firstRowComplete = false; 274 | for(approachName in approaches){ 275 | if(approaches.hasOwnProperty(approachName)){ 276 | approach = approaches[approachName]; 277 | for(taskName in approach){ 278 | if(approach.hasOwnProperty(taskName)){ 279 | task = approach[taskName]; 280 | console.log(approachName + ' ' + taskName); 281 | if(!firstRowComplete){ 282 | tableHeader.push(''); 283 | } 284 | result = speedTest( 285 | approachName + ' ' + taskName, 286 | task, 287 | window[approachName + 'List'], 288 | window[approachName + 'ListTransformed'] 289 | ); 290 | tableRow.push(''); 291 | } 292 | } 293 | if(!firstRowComplete){ 294 | table.push('', tableHeader.join(''), ''); 295 | firstRowComplete = true; 296 | } 297 | table.push('', tableRow.join(''), ''); 298 | tableRow = []; 299 | } 300 | } 301 | table.push('
', taskName, '', result, '
Type
', approachName, '
'); 302 | document.body.innerHTML += table.join(''); -------------------------------------------------------------------------------- /tests/polyshape.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 8 | 9 | -------------------------------------------------------------------------------- /tests/polyshape_open.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tests/rotation_order.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rotation Order 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 219 | 220 | -------------------------------------------------------------------------------- /tests/text_cycler.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Text Cycler 5 | 6 | 7 | 8 | 9 | 72 | 73 | -------------------------------------------------------------------------------- /tests/tween.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tween 5 | 6 | 7 | 8 | 9 | 10 | 37 | 38 | -------------------------------------------------------------------------------- /tests/twist.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Twist 5 | 66 | 67 | 68 |
69 | 70 | 71 |
72 | 73 | 74 | 75 | 120 | 121 | -------------------------------------------------------------------------------- /tests/utils_color_unit_tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | utils.Color Unit Tests 5 | 17 | 18 | 19 | 20 | 21 | 60 | 61 | -------------------------------------------------------------------------------- /tests/vec3min.js: -------------------------------------------------------------------------------- 1 | var Vec3 = function(args){ 2 | var type = 'Vec3', v; 3 | if(this.type !== type){throw 'You must use the `new` keyword when invoking the ' + type + ' constructor.';} 4 | v = this.parseArgs(arguments); 5 | this.x = v.x; 6 | this.y = v.y; 7 | this.z = v.z; 8 | return this; 9 | }; 10 | 11 | Vec3.prototype = { 12 | type: 'Vec3', 13 | parseArgs: function(){ 14 | var output; 15 | if(arguments.length === 3) { //vanilla 16 | output = {x: arguments[0],y: arguments[1],z: arguments[2]}; 17 | } else if(arguments[0].length !== undefined && arguments[0].length > 2) { //is array 18 | output = {x: arguments[0][0],y: arguments[0][1],z: arguments[0][2]}; 19 | }else if(arguments[0].x !== undefined && arguments[0].y !== undefined && arguments[0].z !== undefined) { //is object 20 | output = arguments[0]; 21 | } else { 22 | output = {x: 0, y: 0, z: 0}; 23 | } 24 | return output; 25 | }, 26 | clone:function(){ 27 | return new Vec3(this); 28 | }, 29 | add:function(){ 30 | var v = this.parseArgs(arguments); 31 | this.x += v.x; 32 | this.y += v.y; 33 | this.z += v.z; 34 | return this; 35 | }, 36 | sub:function(){ 37 | var v = this.parseArgs(arguments); 38 | this.x -= v.x; 39 | this.y -= v.y; 40 | this.z -= v.z; 41 | return this; 42 | }, 43 | mul:function(num){ 44 | num = parseFloat(num); 45 | this.x *= num; 46 | this.y *= num; 47 | this.z *= num; 48 | return this; 49 | }, 50 | div:function(num){ 51 | num = parseFloat(num); 52 | this.x /= num; 53 | this.y /= num; 54 | this.z /= num; 55 | return this; 56 | }, 57 | scale:function(v){ 58 | this.x *= v.x; 59 | this.y *= v.y; 60 | this.z *= v.z; 61 | return this; 62 | }, 63 | length:function(){ 64 | return Math.sqrt((this.x*this.x) + (this.y*this.y) + (this.z*this.z)); 65 | }, 66 | sqlen:function(){ 67 | return ((this.x*this.x) + (this.y*this.y) + (this.z*this.z)); 68 | }, 69 | length2d:function(x,y){ 70 | return Math.sqrt((x*x) + (y*y)); 71 | }, 72 | rotate2d:function(x,y,r){ 73 | //current Radians, current Length 74 | var cR = Math.atan2(y,x), 75 | cL = this.length2d(x,y); 76 | var newX = Math.sin(cR + r) * cL; 77 | var newY = Math.cos(cR + r) * cL; 78 | return [newX,newY]; 79 | }, 80 | rotate:function(rot,order){ 81 | order = order || [0,1,2]; 82 | //Alright, here's something interesting. 83 | //The order you rotate the dimensions is IMPORTANT to rotation animation! 84 | //Here's my quick, no math approach to applying that. 85 | for(var r = 0; r < order.length; r += 1){ 86 | if(order[r] === 0){ 87 | //x... 88 | if(rot[0] !== 0){ 89 | var zy = this.rotate2d(this.z,this.y,rot[0]); 90 | this.z = zy[0]; 91 | this.y = zy[1]; 92 | } 93 | }else if(order[r] === 1){ 94 | //y... 95 | if(rot[1] !== 0){ 96 | var xz = this.rotate2d(this.x,this.z,rot[1]); 97 | this.x = xz[0]; 98 | this.z = xz[1]; 99 | } 100 | }else if(order[r] === 2){ 101 | //z... 102 | if(rot[2] !== 0){ 103 | var xy = this.rotate2d(this.x,this.y,rot[2]); 104 | this.x = xy[0]; 105 | this.y = xy[1]; 106 | } 107 | }else{ 108 | throw 'up'; 109 | } 110 | } 111 | return this; 112 | }, 113 | set:function(){ 114 | var v = this.parseArgs(arguments); 115 | this.x = v.x; 116 | this.y = v.y; 117 | this.z = v.z; 118 | return this; 119 | }, 120 | toString:function(){ 121 | return 'Vec3 { x:'+this.x+', y:'+this.y+', z:'+this.z+'}'; 122 | }, 123 | toUrlString:function(){ 124 | return this.x+this.sep+this.y+this.sep+this.z; 125 | }, 126 | normalize:function(){ 127 | this.div(this.length()); 128 | return this; 129 | } 130 | }; -------------------------------------------------------------------------------- /tools/convert_obj_to_pn3.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 40 | 41 | 42 |
43 | Upload an OBJ file. Or else.
44 | Moving the your mouse rotates your shape.
45 | Scrolling controlls camera Z
46 |
47 | 57 |
Scaled: 58 | 59 | 60 |
Centered: 61 | 62 | 63 |
64 |
65 | 66 | 67 | 68 | 69 | 70 | 152 | 153 | -------------------------------------------------------------------------------- /tools/convert_obj_to_shape.js: -------------------------------------------------------------------------------- 1 | //Thanks, Heilmann. http://www.wait-till-i.com/2007/08/08/simulating-array_unique-in-javascript/ 2 | function heilmanns_array_unique(ar){ 3 | if(ar.length && typeof ar!=='string'){ 4 | var sorter = {}; 5 | var out = []; 6 | for(var i=0,j=ar.length;i 2){ //oops, someone got sloppy in their mesh naming - correcting for that 112 | meshNameColorSplit = meshName.replace(meshNameColorSingleReg,'&&&').split(meshNameColorSeparator); 113 | } 114 | if(meshNameColorSplit.length > 1){ 115 | meshName = meshNameColorSplit[0]; 116 | mesh.color = meshNameColorSplit[1]; 117 | } 118 | } 119 | 120 | currentMeshName = meshName; 121 | meshList[currentMeshName] = mesh; 122 | }; 123 | for(instructonIndex = 0; instructonIndex < instructionStringList.length; instructonIndex += 1){ 124 | //I have no why some OBJ exporters would use multiple spaces, but some do...? 125 | instructonString = instructionStringList[instructonIndex].split(' ').join(' '); 126 | instructionArgs = instructonString.split(' '); 127 | instructionName = instructionArgs[0]; 128 | instructionArgs.splice(0,1); //removes instructionName 129 | if(instructionName === 'o'){ //Create Object 130 | createMeshObject(instructionArgs[0]); 131 | } 132 | if(instructionName === 'v'){ //Create Vertex 133 | if(currentMeshName === undefined){ //Just checking to see if the OBJ creator was smart enough to create an object first 134 | createMeshObject('unnamedObject'); 135 | } 136 | //Blender's default OBJ export orientation is Y up, -Z forward at the moment, so I'm pushing 137 | //the vertex axies in the order of [0,2,1] because I want to compensate for that odd default. 138 | if(mode === 'shape'){ 139 | //3D Data 140 | meshList[currentMeshName].points.push([ 141 | (parseFloat(instructionArgs[0])*exportScale), 142 | (parseFloat(instructionArgs[2])*exportScale), 143 | (parseFloat(instructionArgs[1])*exportScale) 144 | ]); 145 | }else if(mode === 'font'){ 146 | //2D Data 147 | //By the way, it -is- in theory possible to have a 3D font. I'll wait for that though. 148 | meshList[currentMeshName].points.push([ 149 | (parseFloat(instructionArgs[0])*exportScale), 150 | (parseFloat(instructionArgs[2])*exportScale) 151 | ]); 152 | } 153 | } 154 | if(instructionName === 'f' || instructionName === 'l'){ //Create Face or Line 155 | //See note WTF1 above to understand the pointNumOffset variable 156 | for(pointIndex = 1; pointIndex < instructionArgs.length; pointIndex += 1){ 157 | line = [ 158 | parseInt(instructionArgs[pointIndex -1]) - pointNumOffset, 159 | parseInt(instructionArgs[pointIndex]) - pointNumOffset 160 | ]; 161 | //Why do I sort the array literal before pushing it into the set? So I can compare easily by join() later. 162 | line.sort(whyDoINeedToWriteANumericSortingFunction); 163 | meshList[currentMeshName].lines.push(line); 164 | } 165 | //It took me a long time to figure this out; Filled polys autoclose; Line segments don't. 166 | //This is the last line segment in a closed poly. 167 | line = [ 168 | parseInt(instructionArgs[0]) - pointNumOffset, 169 | parseInt(instructionArgs[instructionArgs.length -1]) - pointNumOffset 170 | ]; 171 | line.sort(whyDoINeedToWriteANumericSortingFunction); 172 | meshList[currentMeshName].lines.push(line); 173 | } 174 | } 175 | 176 | //Alphabetizing the output(for pretty) and killing duplicate lines(in case of overlap from exported faces) 177 | 178 | for(meshName in meshList){ 179 | if(meshList.hasOwnProperty(meshName)){ 180 | //console.log(meshList[property]); 181 | meshNameList.push(meshName); 182 | meshList[meshName].lines = array_unique(meshList[meshName].lines); 183 | meshList[meshName].lines.sort(whyDoINeedToWriteANumericSortingFunctionForA2dArray); 184 | } 185 | } 186 | meshNameList.sort(); 187 | for(meshIndex = 0; meshIndex < meshNameList.length; meshIndex++){ 188 | meshName = meshNameList[meshIndex]; 189 | //console.log(property); 190 | output.push("\t" + JSON.stringify(meshName) + ':' + JSON.stringify(meshList[meshName])); 191 | } 192 | 193 | //quick and dirty output. Oh yeah. 194 | //var formattedOutput = "var shapes = {\n"; 195 | var formattedOutput = "{\n"; 196 | formattedOutput += output.join(",\n"); 197 | formattedOutput += "\n}"; 198 | //console.log(meshList); 199 | return formattedOutput; 200 | }; -------------------------------------------------------------------------------- /tools/pn3_loader.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 41 | 42 | 43 |
44 | Upload a PN3 file. Or else. 45 | Moving the your mouse rotates your shape. 46 | Scrolling controlls camera Z 47 | 48 | 49 |
'; 52 | } 53 | ?>
54 | 55 | 56 | 57 | 58 | 103 | 104 | -------------------------------------------------------------------------------- /utils/build/build.js: -------------------------------------------------------------------------------- 1 | var gear = require('gear'); 2 | new gear.Queue({registry: new gear.Registry({module: 'gear-lib'})}) 3 | .read([ 4 | '../../src/core.js', 5 | '../../src/font.js', 6 | '../../src/layout.js', 7 | '../../src/sprite.js', 8 | '../../src/utils.color.js', 9 | '../../src/fx.tween.js', 10 | '../../src/fx.explosion.js', 11 | '../../src/geom.circle.js', 12 | '../../src/geom.sphere.js', 13 | '../../src/geom.lathe.js', 14 | '../../src/geom.twist.js' 15 | //,'../../src/geom.pn3.js' 16 | ]) 17 | .log('read files') 18 | .concat() 19 | .write('../../build/npos3d.js') 20 | .jslint() 21 | .jsminify() 22 | .write('../../build/npos3d.min.js') 23 | .log('wrote output files') 24 | .run(); -------------------------------------------------------------------------------- /utils/build/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "npos3d-builder", 3 | "version": "0.0.1", 4 | "dependencies": { 5 | "gear": "*", 6 | "gear-lib": "*", 7 | "requirejs": "*" 8 | }, 9 | "scripts": { 10 | "build": "node build.js" 11 | } 12 | } --------------------------------------------------------------------------------