2
0

pong.app.json 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. {
  2. "metadata": {
  3. "type": "App"
  4. },
  5. "project": {
  6. "shadows": false,
  7. "editable": false,
  8. "vr": false
  9. },
  10. "camera": {
  11. "metadata": {
  12. "version": 4.4,
  13. "type": "Object",
  14. "generator": "Object3D.toJSON"
  15. },
  16. "object": {
  17. "uuid": "B901700E-2B1B-4D74-9201-164193F8304E",
  18. "type": "PerspectiveCamera",
  19. "name": "Camera",
  20. "matrix": [0.9522120356559753,4.608077919243669e-9,-0.3054378032684326,0,-0.17742955684661865,0.8139732480049133,-0.553142249584198,0,0.24861818552017212,0.5809023976325989,0.7750750780105591,0,18.645999908447266,43.56800079345703,58.13100051879883,1],
  21. "focalLength": 10,
  22. "zoom": 1,
  23. "fov": 50,
  24. "aspect": 1.3217270194986073,
  25. "near": 0.1,
  26. "far": 100000
  27. }
  28. },
  29. "scene": {
  30. "metadata": {
  31. "version": 4.4,
  32. "type": "Object",
  33. "generator": "Object3D.toJSON"
  34. },
  35. "geometries": [
  36. {
  37. "uuid": "713F75F5-5D04-4069-89CB-2035F5619AC3",
  38. "type": "PlaneGeometry",
  39. "width": 60,
  40. "height": 40,
  41. "widthSegments": 1,
  42. "heightSegments": 1
  43. },
  44. {
  45. "uuid": "4537EA66-3CD6-43A1-97A9-EB59F3258BF9",
  46. "type": "BoxGeometry",
  47. "width": 1,
  48. "height": 1,
  49. "depth": 1,
  50. "widthSegments": 1,
  51. "heightSegments": 1,
  52. "depthSegments": 1
  53. },
  54. {
  55. "uuid": "3C546CA4-FF0F-4BA1-9406-0CD0D560A396",
  56. "type": "BoxGeometry",
  57. "width": 2,
  58. "height": 2,
  59. "depth": 10,
  60. "widthSegments": 1,
  61. "heightSegments": 1,
  62. "depthSegments": 1
  63. },
  64. {
  65. "uuid": "4628F4A7-D572-45C2-9A67-807D71FF19EC",
  66. "type": "BoxGeometry",
  67. "width": 2,
  68. "height": 2,
  69. "depth": 10,
  70. "widthSegments": 1,
  71. "heightSegments": 1,
  72. "depthSegments": 1
  73. }],
  74. "materials": [
  75. {
  76. "uuid": "7EDF7C08-6325-418A-BBAB-89341C694730",
  77. "type": "MeshPhongMaterial",
  78. "color": 16777215,
  79. "emissive": 0,
  80. "specular": 16777215,
  81. "shininess": 30
  82. },
  83. {
  84. "uuid": "B1CAF098-FE36-45E1-BEBE-8D6AC04821CC",
  85. "type": "MeshPhongMaterial",
  86. "color": 16711680,
  87. "emissive": 0,
  88. "specular": 1118481,
  89. "shininess": 30
  90. },
  91. {
  92. "uuid": "FBDBE66D-B613-4741-802D-5AE1DE07DE46",
  93. "type": "MeshPhongMaterial",
  94. "color": 2752767,
  95. "emissive": 0,
  96. "specular": 1118481,
  97. "shininess": 30
  98. }],
  99. "object": {
  100. "uuid": "31517222-A9A7-4EAF-B5F6-60751C0BABA3",
  101. "type": "Scene",
  102. "name": "Scene",
  103. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
  104. "children": [
  105. {
  106. "uuid": "B47D0BFC-D63A-4CBB-985E-9C4DBDF086E4",
  107. "type": "Mesh",
  108. "name": "Ground",
  109. "matrix": [1,0,0,0,0,0.0007960238144733012,-0.9999997019767761,0,0,0.9999997019767761,0.0007960238144733012,0,0,-1,0,1],
  110. "geometry": "713F75F5-5D04-4069-89CB-2035F5619AC3",
  111. "material": "7EDF7C08-6325-418A-BBAB-89341C694730"
  112. },
  113. {
  114. "uuid": "CE13E58A-4E8B-4F72-9E2E-7DE57C58F989",
  115. "type": "Mesh",
  116. "name": "Ball",
  117. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
  118. "geometry": "4537EA66-3CD6-43A1-97A9-EB59F3258BF9",
  119. "material": "B1CAF098-FE36-45E1-BEBE-8D6AC04821CC"
  120. },
  121. {
  122. "uuid": "2AAEA3AA-EC45-492B-B450-10473D1EC6C5",
  123. "type": "Mesh",
  124. "name": "Pad 1",
  125. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,-24,0,0,1],
  126. "geometry": "3C546CA4-FF0F-4BA1-9406-0CD0D560A396",
  127. "material": "FBDBE66D-B613-4741-802D-5AE1DE07DE46"
  128. },
  129. {
  130. "uuid": "F1DD46A7-6584-4A37-BC76-852C3911077E",
  131. "type": "Mesh",
  132. "name": "Pad 2",
  133. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,24,0,0,1],
  134. "geometry": "4628F4A7-D572-45C2-9A67-807D71FF19EC",
  135. "material": "FBDBE66D-B613-4741-802D-5AE1DE07DE46"
  136. },
  137. {
  138. "uuid": "C62AAE9F-9E51-46A5-BD2B-71BA804FC0B3",
  139. "type": "DirectionalLight",
  140. "name": "DirectionalLight 3",
  141. "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,10,20,15,1],
  142. "color": 16777215,
  143. "intensity": 1
  144. }]
  145. }
  146. },
  147. "scripts": {
  148. "31517222-A9A7-4EAF-B5F6-60751C0BABA3": [
  149. {
  150. "name": "Game logic",
  151. "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();\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 ) * 30 - 15;\n\tpad2.position.z = - pad1.position.z;\n\n}\n\nfunction update( event ) {\n\t\n\tif ( position.x < -30 || position.x > 30 ) direction.x = - direction.x;\n\tif ( position.z < -20 || position.z > 20 ) direction.z = - direction.z;\n\t\n\tposition.x = Math.max( - 30, Math.min( 30, position.x ) );\n\tposition.z = Math.max( - 20, Math.min( 20, 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 < 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}"
  152. }]
  153. }
  154. }