pong.app.json 5.6 KB

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