// // Tetherball! // examples // // Created by Seth Alves on 2015-6-10 // Copyright 2015 High Fidelity, Inc. // // Makes a tetherball that responds to collisions. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // "use strict"; /*jslint vars: true*/ //var Overlays, Entities, Controller, Script, MyAvatar, Vec3; // Referenced globals provided by High Fidelity. var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; var boxId; var poleID; var paddle1_ID; var paddle2_ID; var position = Vec3.sum(MyAvatar.position, { x: 1.0, y: 0.4, z: 0.0 }); boxId = Entities.addEntity({ type: "Model", // type: "Sphere", modelURL: "http://hifi-content.s3.amazonaws.com/Examples%20Content/production/marblecollection/Star.fbx", name: "Tetherball", shapeType: "Sphere", position: position, dimensions: { x: 0.3, y: 0.3, z: 0.3 }, gravity: { x: 0.0, y: -9.8, z: 0.0 }, damping: 0.2, dynamic: true }); var pointToOffsetFrom = Vec3.sum(position, { x: 0.0, y: 2.0, z: 0.0 }); Entities.addAction("offset", boxId, { pointToOffsetFrom: pointToOffsetFrom, linearDistance: 2.0, // linearTimeScale: 0.005 linearTimeScale: 0.1 }); position = Vec3.sum(MyAvatar.position, { x: 1.25, y: 1.6, z: 0.0 }); poleID = Entities.addEntity({ type: "Model", // type: "Sphere", modelURL: "http://hifi-content.s3.amazonaws.com/Examples%20Content/production/paddleball/tballPole_VR.fbx", compoundShapeURL: "http://hifi-content.s3.amazonaws.com/Examples%20Content/production/paddleball/tballPole_phys.obj", name: "Tetherball Pole", shapeType: "compound", position: position, dimensions: { x: 0.4, y: 5, z: 0.4 } }); position = Vec3.sum(MyAvatar.position, { x: 1.15, y: 0.2, z: 0.15 }); paddle1_ID = Entities.addEntity({ "angularDamping": 0.10000000149011612, "collisionsWillMove": 1, "compoundShapeURL": "http://hifi-content.s3.amazonaws.com/Examples%20Content/production/paddleball/squashRacket_phys.obj", "created": "2016-05-31T22:34:16Z", "damping": 0.10000000149011612, "density": 10000, "description": "For paddleball and other games!", "dimensions": { "x": 0.4639, "y": 1.7339, "z": 0.0236 }, "dynamic": 1, "gravity": { "x": 0, "y": -9.8, "z": 0 }, "modelURL": "http://hifi-content.s3.amazonaws.com/Examples%20Content/production/paddleball/squashRacket_2_VR.fbx", "name": "Paddleball Paddle", "queryAACube": { "scale": 4.3842158317565918, "x": -2.1921079158782959, "y": -2.1921079158782959, "z": -2.1921079158782959 }, "registrationPoint": { "x": 0.5, "y": 0.0099999997764825821, "z": 0.5 }, "restitution": 0, "position": position, "shapeType": "compound", "type": "Model", "userData": "{}" }); position = Vec3.sum(MyAvatar.position, { x: 0.85, y: 0.2, z: -0.15 }); paddle2_ID = Entities.addEntity({ "angularDamping": 0.10000000149011612, "collisionsWillMove": 1, "compoundShapeURL": "http://hifi-content.s3.amazonaws.com/Examples%20Content/production/paddleball/squashRacket_phys.obj", "created": "2016-05-31T22:34:16Z", "damping": 0.10000000149011612, "density": 10000, "description": "For paddleball and other games!", "dimensions": { "x": 0.4639, "y": 1.7339, "z": 0.0236 }, "dynamic": 1, "gravity": { "x": 0, "y": -9.8, "z": 0 }, "modelURL": "http://hifi-content.s3.amazonaws.com/Examples%20Content/production/paddleball/squashRacket_2_VR.fbx", "name": "Paddleball Paddle", "queryAACube": { "scale": 4.3842158317565918, "x": -2.1921079158782959, "y": -2.1921079158782959, "z": -2.1921079158782959 }, "registrationPoint": { "x": 0.5, "y": 0.0099999997764825821, "z": 0.5 }, "restitution": 0, "position": position, "shapeType": "compound", "type": "Model", "userData": "{}" }); Script.stop();