// // 4squareGloveDispenser.js // // Created by Thijs Wenker on 8/2/16. // Editted by Jimi Youm on 1/4/17 // Copyright 2016 High Fidelity, Inc. // // Based on examples/winterSmashUp/targetPractice/shooterPlatform.js // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // (function() { var _this = this; var leftBoxingGlove = undefined; var rightBoxingGlove = undefined; _this.enterEntity = function(entityID) { print('entered boxing glove dispenser entity'); leftBoxingGlove = Entities.addEntity({ position: MyAvatar.position, // collisionSoundURL: "http://hifi-content.s3.amazonaws.com/caitlyn/production/elBoppo/51460__andre-rocha-nascimento__basket-ball-01-bounce.wav", collisionsWillMove: true, dimensions: { x: 0.3316, //size of object y: 0.4445, z: 0.1691 }, dynamic: true, gravity: { x: 0, y: -9.8, z: 0 }, modelURL: "https://hifi-content.s3.amazonaws.com/jimi/props/sportsHands/sportsHand_Thick_L.fbx", name: "Boxing Glove - Left", shapeType: "simple-hull", type: "Model", userData: JSON.stringify({ grabbableKey: { invertSolidWhileHeld: true }, wearable: { joints: { LeftHand: [ {x: -0.05, y: 0.2, z: 0.03 }, //position on joint Quat.fromVec3Degrees({x: 0, y: 0, z: 0}) //rotation ] } } }) }); Messages.sendLocalMessage('Hifi-Hand-Grab', JSON.stringify({hand: 'left', entityID: leftBoxingGlove})); rightBoxingGlove = Entities.addEntity({ position: MyAvatar.position, // collisionSoundURL: "http://hifi-content.s3.amazonaws.com/caitlyn/production/elBoppo/51460__andre-rocha-nascimento__basket-ball-01-bounce.wav", collisionsWillMove: true, dimensions: { x: 0.3316, //size of object y: 0.4445, z: 0.1691 }, dynamic: true, gravity: { x: 0, y: -9.8000001907348633, z: 0 }, modelURL: "https://hifi-content.s3.amazonaws.com/jimi/props/sportsHands/sportsHand_Thick_R.fbx", name: "Boxing Glove - Right", shapeType: "simple-hull", type: "Model", userData: JSON.stringify({ grabbableKey: { invertSolidWhileHeld: true }, wearable: { joints: { RightHand: [ {x: 0.05, y: 0.2, z: 0.03 }, Quat.fromVec3Degrees({x: 0, y: 0, z: 0}) ] } } }) }); Messages.sendLocalMessage('Hifi-Hand-Grab', JSON.stringify({hand: 'right', entityID: rightBoxingGlove})); }; _this.leaveEntity = function(entityID) { if (leftBoxingGlove !== undefined) { Entities.deleteEntity(leftBoxingGlove); leftBoxingGlove = undefined; } if (rightBoxingGlove !== undefined) { Entities.deleteEntity(rightBoxingGlove); rightBoxingGlove = undefined; } }; _this.unload = _this.leaveEntity; });