1 /* 2 Copyright (c) 2008 Seneca College 3 Licenced under the MIT License (http://www.c3dl.org/index.php/mit-license/) 4 */ 5 6 /** 7 @namespace values within this namespace are guarantted not be be changed 8 by the library. The const part of the values such as c3dl.FAR_CLIPPING_PLANE 9 indicate the library never changes the value and neither should the user. 10 */ 11 12 /** 13 c3dl.TOLERANCE = 0.00001<br /> 14 This is used as a buffer when doing some calculations with 15 floating point numbers. Due to floating point innacuracy, we cannot 16 use == on floating point numbers for comparison. Two floats which 17 we believe to be equal may in fact not be equal, they may vary a 18 small amount. Therefore a constant is defined here which will later 19 be used to compare against the difference on vector component 20 allowing some tolerance. 21 @constant 22 */ 23 c3dl.TOLERANCE = 0.00001; 24 25 /** 26 @private 27 We need to define this ourselves since it is not present in canvas 3d 0.4.3 28 */ 29 c3dl.VERTEX_PROGRAM_POINT_SIZE = 0x8642; 30 31 /** 32 @private 33 34 */ 35 c3dl.POINT_SMOOTH = 0x0B10; 36 37 /** 38 To render c3dl.Point objects using the built-in OpenGL 39 points rendering ( using circles ), pass this value to 40 the Scene's setPointRenderingMode() method. 41 42 Note that using this method of rendering c3dl.Point objects may crash 43 the browser or OS. 44 @constant 45 */ 46 c3dl.POINT_MODE_POINT = 1; 47 48 /** 49 To render c3dl.Point objects using spheres, pass this 50 value to the Scene's setPointRenderingMode() method. 51 52 This is the default method to render c3dl.Point objects. 53 @constant 54 */ 55 c3dl.POINT_MODE_SPHERE = 2; 56 57 /** 58 @private 59 c3dl.NEAR_CLIPPING_PLANE = 0.1<br /> 60 The distance from the viewpoint to the camera's near 61 clipping plane. This should always be positive. 62 @constant 63 */ 64 c3dl.DEFAULT_NEAR_CLIPPING_PLANE = 0.1; 65 66 /** 67 @private 68 c3dl.DEFAULT_FAR_CLIPPING_PLANE = 8000.0<br /> 69 The distance from the viewpoint to the camera's far 70 clipping plane. This should always be positive. 71 @constant 72 */ 73 c3dl.DEFAULT_FAR_CLIPPING_PLANE = 8000.0; 74 75 /** 76 @private 77 c3dl.FIELD_OF_VIEW = 45.0<br /> 78 Angle in degree of the camera's field of view. Must 79 range from 0 to 180. 80 @constant 81 */ 82 c3dl.DEFAULT_FIELD_OF_VIEW = 45.0; 83 84 /** 85 @private 86 c3dl.GLES_CONTEXT_20 = 2.0<br /> 87 @constant 88 */ 89 c3dl.GLES_CONTEXT_20 = 2.0; 90 91 92 /** 93 @private 94 c3dl.MAX_LIGHTS = 7<br /> 95 @constant 96 */ 97 c3dl.MAX_LIGHTS = 7; 98 99 /** 100 @private 101 If c3dl.Light is ever instantiated, which it shouldn't, it will have the the light 102 type of abstract. In that case we tell the user they have an error in their script. 103 @constant 104 @see c3dl.Light 105 */ 106 c3dl.ABSTRACT_LIGHT = 0; 107 108 /** 109 @private 110 A directional light is a light which does not have a position, but only 111 a direction. The light is understood to be infinitely far away. 112 @constant 113 @see c3dl.DirectionalLight 114 */ 115 c3dl.DIRECTIONAL_LIGHT = 1; 116 117 /** 118 @private 119 A positional light is a light with a position property. 120 @constant 121 @see c3dl.PositionalLight 122 */ 123 c3dl.POSITIONAL_LIGHT = 2; 124 125 /** 126 @private 127 A spotlight is a positional light with a cutoff component, so light is 128 restricted to a cone shape. 129 @constant 130 @see c3dl.SpotLight 131 */ 132 c3dl.SPOT_LIGHT = 3; 133 134 135 /** 136 @private 137 Symbol which must be passed into matrixMode() method to change the 138 matrix mode to projection. 139 @constant 140 */ 141 c3dl.PROJECTION = 1; 142 143 /** 144 @private 145 Symbol which must be passed into matrixMode() method to change the 146 matrix mode to model view. 147 @constant 148 */ 149 c3dl.MODELVIEW = 2; 150 151 /** 152 */ 153 c3dl.COLLADA = 0; 154 155 /** 156 */ 157 c3dl.LINE = 1; 158 159 /** 160 */ 161 c3dl.POINT = 2; 162 163 /** 164 */ 165 c3dl.PARTICLE_SYSTEM = 3; 166 167 ////////////////////// SCENE ///////////////////////// 168 169 /** 170 @constant 171 */ 172 c3dl.DEFAULT_BG_RED = 0.4; 173 174 175 /** 176 @constant 177 */ 178 c3dl.DEFAULT_BG_GREEN = 0.4; 179 180 181 /** 182 @constant 183 */ 184 c3dl.DEFAULT_BG_BLUE = 0.6; 185 186 187 /** 188 Used to set blending factors in c3dl.ParticleSystem. 189 @constant 190 @see c3dl.ParticleSystem#setDstBlend 191 @see c3dl.ParticleSystem#setSrcBlend 192 */ 193 c3dl.ZERO = 0; 194 195 /** 196 Used to set blending factors in c3dl.ParticleSystem. 197 @constant 198 @see c3dl.ParticleSystem#setDstBlend 199 @see c3dl.ParticleSystem#setSrcBlend 200 */ 201 c3dl.ONE = 1; 202 203 /** 204 Used to set blending factors in c3dl.ParticleSystem. 205 @constant 206 @see c3dl.ParticleSystem#setDstBlend 207 @see c3dl.ParticleSystem#setSrcBlend 208 */ 209 c3dl.SRC_COLOR = 0x0300; 210 211 /** 212 Used to set blending factors in c3dl.ParticleSystem. 213 @constant 214 @see c3dl.ParticleSystem#setDstBlend 215 @see c3dl.ParticleSystem#setSrcBlend 216 */ 217 c3dl.ONE_MINUS_SRC_COLOR = 0x0301; 218 219 /** 220 Used to set blending factors in c3dl.ParticleSystem. 221 @constant 222 @see c3dl.ParticleSystem#setDstBlend 223 @see c3dl.ParticleSystem#setSrcBlend 224 */ 225 c3dl.SRC_ALPHA = 0x0302; 226 227 /** 228 Used to set blending factors in c3dl.ParticleSystem. 229 @constant 230 @see c3dl.ParticleSystem#setDstBlend 231 @see c3dl.ParticleSystem#setSrcBlend 232 */ 233 c3dl.ONE_MINUS_SRC_ALPHA = 0x0303; 234 235 /** 236 Used to set blending factors in c3dl.ParticleSystem. 237 @constant 238 @see c3dl.ParticleSystem#setDstBlend 239 @see c3dl.ParticleSystem#setSrcBlend 240 */ 241 c3dl.DST_ALPHA = 0x0304; 242 243 /** 244 Used to set blending factors in c3dl.ParticleSystem. 245 @constant 246 @see c3dl.ParticleSystem#setDstBlend 247 @see c3dl.ParticleSystem#setSrcBlend 248 */ 249 c3dl.ONE_MINUS_DST_ALPHA = 0x0305; 250 251 /** 252 Used to set blending factors in c3dl.ParticleSystem. 253 @constant 254 @see c3dl.ParticleSystem#setDstBlend 255 @see c3dl.ParticleSystem#setSrcBlend 256 */ 257 c3dl.DST_COLOR = 0x0306; 258 259 /** 260 Used to set blending factors in c3dl.ParticleSystem. 261 @constant 262 @see c3dl.ParticleSystem#setDstBlend 263 @see c3dl.ParticleSystem#setSrcBlend 264 */ 265 c3dl.ONE_MINUS_DST_COLOR = 0x0307; 266 267 /** 268 Used to set blending factors in c3dl.ParticleSystem. 269 @constant 270 @see c3dl.ParticleSystem#setDstBlend 271 @see c3dl.ParticleSystem#setSrcBlend 272 */ 273 c3dl.SRC_ALPHA_SATURATE = 0x0308; 274 275 276 /** 277 Used to set the blending equation in c3dl.ParticleSystem. 278 @constant 279 @see c3dl.ParticleSystem#setBlendEquation 280 */ 281 c3dl.FUNC_ADD = 0x8006; 282 283 /** 284 Used to set the blending equation in c3dl.ParticleSystem. 285 @constant 286 @see c3dl.ParticleSystem#setBlendEquation 287 */ 288 c3dl.FUNC_SUBTRACT = 0x800A; 289 290 /** 291 Used to set the blending equation in c3dl.ParticleSystem. 292 @constant 293 @see c3dl.ParticleSystem#setBlendEquation 294 */ 295 c3dl.FUNC_REVERSE_SUBTRACT = 0x800B; 296 297 298 299 300 ////////////////////////// SHADERS ///////////////////////// 301 302 /** 303 @private 304 When we try to get a location of a variable from a shader program, 305 it may not exist. If that is the case, opengles will return -1 to 306 indicate that. 307 @constant 308 */ 309 c3dl.SHADER_VAR_NOT_FOUND = -1; 310 311 312 /** 313 This is used internally by c3DL. 314 @constant 315 @private 316 */ 317 c3dl.VERTEX_SHADER = "x-vertex"; 318 319 /** 320 This is used internally by c3DL. 321 @constant 322 @private 323 */ 324 c3dl.FRAGMENT_SHADER = "x-fragment"; 325 326 327 328 329 330 // 0x0001 is the value assigned to glCanvas3D.LINES. Similarly, 331 // 0x0004 is the value assigned to glCanvas3D.TRIANGLES. We have to 332 // use the numerical values here since we do not yet have a context. 333 // Within the renderer is a variable which hold one of these values. 334 // When drawArrays() is called, it will be given this value, thus filled 335 // trianges or lines will be rendered. 336 337 // This was done to avoid having: 338 // if(fillMode == c3dl.WIRE_FRAME) 339 // drawArrays(glCanvas3D.LINES, ...); 340 // else 341 // drawArrays(glCanvas3D.TRIANGLES,...); 342 // 343 // instead of the above code, we only need one line of code. 344 345 /** 346 Pass this to renderer's setFillMode() if you want models to be 347 drawn with lines. Note that using this may result in rendering of 348 extra lines. This should mostly used for debugging scripts such as 349 when drawing bounding volumes. 350 @constant 351 @see c3dl.Renderer#setFillMode 352 */ 353 c3dl.WIRE_FRAME = 0x0001; 354 355 /** 356 Pass this to a renderer's setFillMode() if you want models to be 357 drawn 'filled in'. Renderers will use fill mode by default. 358 359 @constant 360 @see c3dl.Renderer#setFillMode 361 */ 362 c3dl.FILL = 0x0004; 363 364 365 366 //////////////////////// DEBUG //////////////////////////////// 367 368 /** 369 This is used internally in c3DL by the debug class. 370 @private 371 @constant 372 */ 373 c3dl.DEBUG_INFO = "Info"; 374 375 /** 376 This is used internally in c3DL by the debug class. 377 @private 378 @constant 379 */ 380 c3dl.DEBUG_ERROR = "Error"; 381 382 /** 383 This is used internally in c3DL by the debug class. 384 @private 385 @constant 386 */ 387 c3dl.DEBUG_WARNING = "Warning"; 388 389 /** 390 This is used internally in c3DL by the debug class. 391 @private 392 @constant 393 */ 394 c3dl.DEBUG_EXCEPTION = "Exception"; 395 396 397 ////////////////////////////// PICKING /////////////////////////// 398 399 /** 400 This constant can be passed into the setPickingPrecision() of scene 401 if accuracy is not important for your script and/or you require the 402 picking algorithm to work as fast as possible. If using this value, when 403 a user clicks on the canvas, all objects which can be picked will only 404 be tested against their bounding volume. 405 406 @constant 407 */ 408 c3dl.PICK_PRECISION_BOUNDING_VOLUME = 1; 409 410 /** 411 This is currently the most accurate test available. If this is passed 412 into the setPickingPrecision() function of scene, everytime the user clicks, 413 the ray generated will be tested against the triangles of each model which 414 pass the bounding volume test. Use this constant if accuracy is important 415 for your script using C3DL.<br /> 416 <br /> 417 This is the default precision of each scene created. 418 419 @constant 420 */ 421 c3dl.PICK_PRECISION_TRIANGLE = 2; 422