java script code 2017


SUBMITTED BY: karimdzdz

DATE: May 23, 2017, 9:02 a.m.

FORMAT: JavaScript+Cheetah

SIZE: 3.7 kB

HITS: 1440

  1. Var VERTEX = "vertex" ; Var COLOR = "couleur" ;
  2. Var NORMAL = "normal" ; Var TEX_COORD = "texCoord" ;
  3. Var wallModel = [
  4. [ COLOR , [ 1 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 0 ] ] ,
  5. [ VERTEX , [ [ 5 , 5 , 0 ] , [ - 5 , 5 , 0 ] , [ 5 , - 5 , 0 ] , [ - 5 , - 5 , 0 ] ] ] ,
  6. [ TEX_COORD , [ 0 , 1 , 1 , 1 , 1 , 0 , 0 , 0 ] ] ,
  7. [ NORMAL , $ W. Util . GenDummyArray ( [ 0 , 0 , - 1 ] , 4 ) ] ] ;
  8. Var floorModel = [
  9. [ COLOR , [ 1 , 1 , .5 , 1 , 1 , .5 , 1 , 1 , .5 , 1 , 1 , .5 ] ] ,
  10. [ VERTEX , [ [ 5 , - 5 , 5 ] , [ - 5 , - 5 , 5 ] , [ 5 , - 5 , - 5 ] , [ - 5 , - 5 , - 5 ] ] ] ,
  11. [ TEX_COORD , [ 0 , 1 , 1 , 1 , 1 , 0 , 0 , 0 ] ] ,
  12. [ NORMAL , $ W. Util . GenDummyArray ( [ 0 , 1 , 0 ] , 4 ) ] ] ;
  13. Var spotlit = new $ W. Matériel ( 'spotlit.json' ) ;
  14. Var wall = new $ W. Objet ( $ W. GL . TRIANGLE_STRIP ) ;
  15. mur. SetMaterial ( spotlit ) ;
  16. mur. VertexCount = 4 ;
  17. mur. FillArrays ( wallModel ) ;
  18. mur. Ambiance = [ 1 , 0 , 0 ] ;
  19. mur. Diffuse = [ 1 , 0 , 0 ] ;
  20. Var floor = new $ W. Objet ( $ W. GL . TRIANGLE_STRIP ) ;
  21. sol. SetMaterial ( spotlit ) ;
  22. sol. VertexCount = 4 ;
  23. sol. FillArrays ( floorModel ) ;
  24. sol. Diffuse = [ 1 , 1 , .5 ] ;
  25. sol. Diffuse = [ 1 , 1 , .5 ] ;
  26. Var sphère = new $ W. Objet ( $ W. GL . TRIANGLES ) ;
  27. sphère. SetMaterial ( spotlit ) ;
  28. sphère. SetPosition ( 0 , 0 , - .02 ) ;
  29. sphère. Environnement = [ 0,5 , 0,5 , 0,05 ] ;
  30. sphère. Diffuse = [ 0.5 , 0.5 , 0.05 ] ;
  31. Var sphereData = $ W. Util . GenSphere ( 30 , 30 ) ;
  32. sphère. FillArray ( TEX_COORD , sphereData. TexCoords ) ;
  33. sphère. FillArray ( VERTEX , sphereData. sommets ) ;
  34. sphère. FillArray ( COLOR , $ W. util . genDummyArray ( [ 0 , 1 , 0 ] , sphereData. sommets . longueur ) ) ;
  35. sphère. FillArray ( NORMAL , sphereData. normales ) ;
  36. sphère. SetElements ( sphereData. Indices ) ;
  37. Spotlit. SetUniformAction ( 'global_ambient' ,
  38. Fonction ( uniforme , objet , matériau ) {
  39. $ W. GL . Uniform1f ( uniform. Location , 0.4 ) ;
  40. }
  41. ) ;
  42. Spotlit. SetUniformAction ( 'l0_position' ,
  43. Fonction ( uniforme , objet , matériau ) {
  44. $ W. GL . uniform3fv ( uniforme. emplacement , [ 0 , 10 , - 8 ] ) ;
  45. }
  46. ) ;
  47. Spotlit. SetUniformAction ( 'l0_spot_target' ,
  48. Fonction ( uniforme , objet , matériau ) {
  49. $ W. GL . uniform3fv ( uniforme. emplacement , [ 0 , 0 , 0 ] ) ;
  50. }
  51. ) ;
  52. Spotlit. SetUniformAction ( 'camera_position' ,
  53. Fonction ( uniforme , objet , matériau ) {
  54. $ W. GL . uniform3fv ( . uniforme emplacement , $ W. caméra . Position . éléments ) ;
  55. }
  56. ) ;
  57. Spotlit. SetUniformAction ( 'l0_ambient' ,
  58. Fonction ( uniforme , objet , matériau ) {
  59. $ W. GL . Uniform3fv ( uniform. Location , [ .2 , .2 , .2 ] ) ;
  60. }
  61. ) ;
  62. Spotlit. SetUniformAction ( 'l0_diffuse' ,
  63. Fonction ( uniforme , objet , matériau ) {
  64. $ W. GL . Uniform3fv ( uniform , location , [ 1 , 1 , 1 ] ) ;
  65. }
  66. ) ;
  67. Spotlit. SetUniformAction ( 'mat_ambient' ,
  68. Fonction ( uniforme , objet , matériau ) {
  69. $ W. GL . uniform3fv ( . uniforme emplacement , . objet ambiante ) ;
  70. }
  71. ) ;
  72. Spotlit. SetUniformAction ( 'mat_diffuse' ,
  73. Fonction ( uniforme , objet , matériau ) {
  74. $ W. GL . uniform3fv ( . uniforme emplacement , objet. diffuse ) ;
  75. }
  76. ) ;

comments powered by Disqus