{ "metadata": { "type": "App" }, "project": { "shadows": true, "vr": false }, "camera": { "metadata": { "version": 4.5, "type": "Object", "generator": "Object3D.toJSON" }, "object": { "uuid": "4AC7ADED-CC22-4B16-8218-2E0A0C38C8F8", "type": "PerspectiveCamera", "name": "Camera", "layers": 1, "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], "fov": 50, "zoom": 1, "near": 0.1, "far": 100000, "focus": 10, "aspect": 1.428977, "filmGauge": 35, "filmOffset": 0 } }, "scene": { "metadata": { "version": 4.5, "type": "Object", "generator": "Object3D.toJSON" }, "geometries": [ { "uuid": "490CEBA3-6A25-4BE1-B517-C5FB11A5D18A", "type": "PlaneBufferGeometry", "width": 6, "height": 4, "widthSegments": 1, "heightSegments": 1 }, { "uuid": "D9A92F2D-2F08-4851-99C7-12D8D1CA13C7", "type": "BoxBufferGeometry", "width": 0.1, "height": 0.1, "depth": 0.1, "widthSegments": 1, "heightSegments": 1, "depthSegments": 1 }, { "uuid": "5E63B8CF-E225-4ABC-994A-4D06BD4E21EB", "type": "BoxBufferGeometry", "width": 0.2, "height": 0.2, "depth": 1, "widthSegments": 1, "heightSegments": 1, "depthSegments": 1 }, { "uuid": "D61532B4-24C3-4BC4-B56B-7245E8163E09", "type": "BoxBufferGeometry", "width": 0.2, "height": 0.2, "depth": 1, "widthSegments": 1, "heightSegments": 1, "depthSegments": 1 }], "materials": [ { "uuid": "7EDF7C08-6325-418A-BBAB-89341C694730", "type": "MeshPhongMaterial", "color": 16777215, "emissive": 0, "specular": 16777215, "shininess": 30, "depthFunc": 3, "depthTest": true, "depthWrite": true }, { "uuid": "B1CAF098-FE36-45E1-BEBE-8D6AC04821CC", "type": "MeshPhongMaterial", "color": 16711680, "emissive": 0, "specular": 1118481, "shininess": 30, "depthFunc": 3, "depthTest": true, "depthWrite": true }, { "uuid": "FBDBE66D-B613-4741-802D-5AE1DE07DE46", "type": "MeshPhongMaterial", "color": 2752767, "emissive": 0, "specular": 1118481, "shininess": 30, "depthFunc": 3, "depthTest": true, "depthWrite": true }], "object": { "uuid": "31517222-A9A7-4EAF-B5F6-60751C0BABA3", "type": "Scene", "name": "Scene", "layers": 1, "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1], "children": [ { "uuid": "B47D0BFC-D63A-4CBB-985E-9C4DBDF086E4", "type": "Mesh", "name": "Ground", "layers": 1, "matrix": [1,0,0,0,0,0.000796,-1,0,0,1,0.000796,0,0,-0.1,0,1], "geometry": "490CEBA3-6A25-4BE1-B517-C5FB11A5D18A", "material": "7EDF7C08-6325-418A-BBAB-89341C694730" }, { "uuid": "CE13E58A-4E8B-4F72-9E2E-7DE57C58F989", "type": "Mesh", "name": "Ball", "layers": 1, "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1], "geometry": "D9A92F2D-2F08-4851-99C7-12D8D1CA13C7", "material": "B1CAF098-FE36-45E1-BEBE-8D6AC04821CC" }, { "uuid": "2AAEA3AA-EC45-492B-B450-10473D1EC6C5", "type": "Mesh", "name": "Pad 1", "layers": 1, "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,-2.4,0,0,1], "geometry": "5E63B8CF-E225-4ABC-994A-4D06BD4E21EB", "material": "FBDBE66D-B613-4741-802D-5AE1DE07DE46" }, { "uuid": "F1DD46A7-6584-4A37-BC76-852C3911077E", "type": "Mesh", "name": "Pad 2", "layers": 1, "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,2.4,0,0,1], "geometry": "D61532B4-24C3-4BC4-B56B-7245E8163E09", "material": "FBDBE66D-B613-4741-802D-5AE1DE07DE46" }, { "uuid": "C62AAE9F-9E51-46A5-BD2B-71BA804FC0B3", "type": "DirectionalLight", "name": "DirectionalLight", "layers": 1, "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,1,2,1.5,1], "color": 16777215, "intensity": 1, "shadow": { "camera": { "uuid": "2CF1F42A-8992-4E8D-8D94-7CC20979344C", "type": "OrthographicCamera", "layers": 1, "zoom": 1, "left": -5, "right": 5, "top": 5, "bottom": -5, "near": 0.5, "far": 500 } } }], "background": 11184810 } }, "scripts": { "31517222-A9A7-4EAF-B5F6-60751C0BABA3": [ { "name": "Game logic", "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}" }] } }