pong.app.json 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. {
  2. "metadata": {
  3. "type": "App"
  4. },
  5. "project": {
  6. "gammaInput": true,
  7. "gammaOutput": true,
  8. "shadows": true,
  9. "vr": false
  10. },
  11. "camera": {
  12. "metadata": {
  13. "version": 4.5,
  14. "type": "Object",
  15. "generator": "Object3D.toJSON"
  16. },
  17. "object": {
  18. "uuid": "4AC7ADED-CC22-4B16-8218-2E0A0C38C8F8",
  19. "type": "PerspectiveCamera",
  20. "name": "Camera",
  21. "layers": 1,
  22. "matrix": [0.952212,0,-0.305438,0,-0.17743,0.813973,-0.553142,0,0.248618,0.580902,0.775075,0,1.865,4.357,5.813,1],
  23. "fov": 50,
  24. "zoom": 1,
  25. "near": 0.1,
  26. "far": 100000,
  27. "focus": 10,
  28. "aspect": 1.428977,
  29. "filmGauge": 35,
  30. "filmOffset": 0
  31. }
  32. },
  33. "scene": {
  34. "metadata": {
  35. "version": 4.5,
  36. "type": "Object",
  37. "generator": "Object3D.toJSON"
  38. },
  39. "geometries": [
  40. {
  41. "uuid": "490CEBA3-6A25-4BE1-B517-C5FB11A5D18A",
  42. "type": "PlaneBufferGeometry",
  43. "width": 6,
  44. "height": 4,
  45. "widthSegments": 1,
  46. "heightSegments": 1
  47. },
  48. {
  49. "uuid": "D9A92F2D-2F08-4851-99C7-12D8D1CA13C7",
  50. "type": "BoxBufferGeometry",
  51. "width": 0.1,
  52. "height": 0.1,
  53. "depth": 0.1,
  54. "widthSegments": 1,
  55. "heightSegments": 1,
  56. "depthSegments": 1
  57. },
  58. {
  59. "uuid": "5E63B8CF-E225-4ABC-994A-4D06BD4E21EB",
  60. "type": "BoxBufferGeometry",
  61. "width": 0.2,
  62. "height": 0.2,
  63. "depth": 1,
  64. "widthSegments": 1,
  65. "heightSegments": 1,
  66. "depthSegments": 1
  67. },
  68. {
  69. "uuid": "D61532B4-24C3-4BC4-B56B-7245E8163E09",
  70. "type": "BoxBufferGeometry",
  71. "width": 0.2,
  72. "height": 0.2,
  73. "depth": 1,
  74. "widthSegments": 1,
  75. "heightSegments": 1,
  76. "depthSegments": 1
  77. }],
  78. "materials": [
  79. {
  80. "uuid": "7EDF7C08-6325-418A-BBAB-89341C694730",
  81. "type": "MeshPhongMaterial",
  82. "color": 16777215,
  83. "emissive": 0,
  84. "specular": 16777215,
  85. "shininess": 30,
  86. "depthFunc": 3,
  87. "depthTest": true,
  88. "depthWrite": true
  89. },
  90. {
  91. "uuid": "B1CAF098-FE36-45E1-BEBE-8D6AC04821CC",
  92. "type": "MeshPhongMaterial",
  93. "color": 16711680,
  94. "emissive": 0,
  95. "specular": 1118481,
  96. "shininess": 30,
  97. "depthFunc": 3,
  98. "depthTest": true,
  99. "depthWrite": true
  100. },
  101. {
  102. "uuid": "FBDBE66D-B613-4741-802D-5AE1DE07DE46",
  103. "type": "MeshPhongMaterial",
  104. "color": 2752767,
  105. "emissive": 0,
  106. "specular": 1118481,
  107. "shininess": 30,
  108. "depthFunc": 3,
  109. "depthTest": true,
  110. "depthWrite": true
  111. }],
  112. "object": {
  113. "uuid": "31517222-A9A7-4EAF-B5F6-60751C0BABA3",
  114. "type": "Scene",
  115. "name": "Scene",
  116. "layers": 1,
  117. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
  118. "children": [
  119. {
  120. "uuid": "B47D0BFC-D63A-4CBB-985E-9C4DBDF086E4",
  121. "type": "Mesh",
  122. "name": "Ground",
  123. "layers": 1,
  124. "matrix": [1,0,0,0,0,0.000796,-1,0,0,1,0.000796,0,0,-0.1,0,1],
  125. "geometry": "490CEBA3-6A25-4BE1-B517-C5FB11A5D18A",
  126. "material": "7EDF7C08-6325-418A-BBAB-89341C694730"
  127. },
  128. {
  129. "uuid": "CE13E58A-4E8B-4F72-9E2E-7DE57C58F989",
  130. "type": "Mesh",
  131. "name": "Ball",
  132. "layers": 1,
  133. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
  134. "geometry": "D9A92F2D-2F08-4851-99C7-12D8D1CA13C7",
  135. "material": "B1CAF098-FE36-45E1-BEBE-8D6AC04821CC"
  136. },
  137. {
  138. "uuid": "2AAEA3AA-EC45-492B-B450-10473D1EC6C5",
  139. "type": "Mesh",
  140. "name": "Pad 1",
  141. "layers": 1,
  142. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,-2.4,0,0,1],
  143. "geometry": "5E63B8CF-E225-4ABC-994A-4D06BD4E21EB",
  144. "material": "FBDBE66D-B613-4741-802D-5AE1DE07DE46"
  145. },
  146. {
  147. "uuid": "F1DD46A7-6584-4A37-BC76-852C3911077E",
  148. "type": "Mesh",
  149. "name": "Pad 2",
  150. "layers": 1,
  151. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,2.4,0,0,1],
  152. "geometry": "D61532B4-24C3-4BC4-B56B-7245E8163E09",
  153. "material": "FBDBE66D-B613-4741-802D-5AE1DE07DE46"
  154. },
  155. {
  156. "uuid": "C62AAE9F-9E51-46A5-BD2B-71BA804FC0B3",
  157. "type": "DirectionalLight",
  158. "name": "DirectionalLight",
  159. "layers": 1,
  160. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,1,2,1.5,1],
  161. "color": 16777215,
  162. "intensity": 1,
  163. "shadow": {
  164. "camera": {
  165. "uuid": "2CF1F42A-8992-4E8D-8D94-7CC20979344C",
  166. "type": "OrthographicCamera",
  167. "layers": 1,
  168. "zoom": 1,
  169. "left": -5,
  170. "right": 5,
  171. "top": 5,
  172. "bottom": -5,
  173. "near": 0.5,
  174. "far": 500
  175. }
  176. }
  177. }],
  178. "background": 11184810
  179. }
  180. },
  181. "scripts": {
  182. "31517222-A9A7-4EAF-B5F6-60751C0BABA3": [
  183. {
  184. "name": "Game logic",
  185. "source": "var ball = this.getObjectByName( 'Ball' );\n\nvar position = ball.position;\n\nvar velocity = new THREE.Vector3();\n\nvar direction = new THREE.Vector3();\ndirection.x = Math.random() - 0.5;\ndirection.z = Math.random() - 0.5;\ndirection.normalize().multiplyScalar( 0.1 );\n\nvar pad1 = this.getObjectByName( 'Pad 1' );\nvar pad2 = this.getObjectByName( 'Pad 2' );\n\nvar raycaster = new THREE.Raycaster();\nvar objects = [ pad1, pad2 ];\n\n//\n\nfunction mousemove( event ) {\n\n\tpad1.position.z = ( event.clientX / player.width ) * 3 - 1.5;\n\tpad2.position.z = - pad1.position.z;\n\n}\n\nfunction update( event ) {\n\t\n\tif ( position.x < -3 || position.x > 3 ) direction.x = - direction.x;\n\tif ( position.z < -2 || position.z > 2 ) direction.z = - direction.z;\n\t\n\tposition.x = Math.max( - 3, Math.min( 3, position.x ) );\n\tposition.z = Math.max( - 2, Math.min( 2, position.z ) );\n\t\n\traycaster.set( position, direction );\n\t\n\tvar intersections = raycaster.intersectObjects( objects );\n\t\n\tif ( intersections.length > 0 ) {\n\n\t\tvar intersection = intersections[ 0 ];\n\t\t\n\t\tif ( intersection.distance < 0.1 ) {\n\t\t\t\n\t\t\tdirection.reflect( intersection.face.normal );\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\tposition.add( velocity.copy( direction ).multiplyScalar( event.delta / 20 ) );\n\n}"
  186. }]
  187. }
  188. }