// // Trampoline-1-model.js // // Created by Bruce Brown on 6/8/17. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // /* global Vec3 MyAvatar Quat Entities Script */ var lifeExpectancy = -1; var position = {x: 1091.1509, y: 1006.3000, z: -239.5625};// Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation)); //var rotation = {x:0 y:0 z:0 w:0};http://brainstormer.no-ip.org:650/Entities/Trampoline/collision.js var xSize = 6.0; //Meters var zSize = 4.0; //Meters var trampolineHeight = .5; var trampolineThickness = 0.1; var groundOffset = -1; var powerJump = -3; var trampolineModelURL = "http://hifi-content.s3.amazonaws.com/DomainContent/production/domainsBaked/pumpkin/trampolineSurface/baked/trampolineSurface.baked.fbx"; var visibleFoot = false; // For Visible positioning var triggerSoundThickness = 1; var triggerSoundOffset = 1.5; var triggerSoundScriptURL = Script.resolvePath("collision.js"); //For Sound Trigger sensor box var trampolineID = null; var trampolineID2 = null; var footID = null; var triggerSoundID = null; function trampoline() { // *** Trampoline Surface *** trampolineID = Entities.addEntity({ type: "Model", shapeType: "Box", modelURL: trampolineModelURL, position: Vec3.sum(position, { x: 0, y: trampolineHeight + groundOffset, z: 0 }), dimensions: { x: xSize, y: trampolineThickness, z: zSize }, color: { red: 0, green: 0, blue: 0 }, dynamic: true, gravity: { x: 0, y: -9.8, z: 0 }, mass: 1, collidesWith: "myAvatar,otherAvatar,", visible: true, lifetime: lifeExpectancy, userData: "{ \"grabbableKey\": { \"grabbable\": false, \"kinematic\": false } }" }); // second entity to prevent ground bleed through trampolineID2 = Entities.addEntity({ type: "Model", shapeType: "Box", modelURL: trampolineModelURL, position: Vec3.sum(position, { x: 0, y: trampolineHeight + groundOffset - 0.375, z: 0 }), dimensions: { x: xSize, y: trampolineThickness+.1, z: zSize }, color: { red: 0, green: 0, blue: 0 }, dynamic: false, gravity: { x: 0, y: -9.8, z: 0 }, mass: 1, collisionless: false, visible: true, lifetime: lifeExpectancy, userData: "{ \"grabbableKey\": { \"grabbable\": false, \"kinematic\": false } }" }); // *** Trampoline Exciter *** Entities.addAction("slider", trampolineID, { point: { x: powerJump, y: 0, z: 0 }, axis: { x: 0, y: 2, z: 0 }, linearLow: 0, linearHigh: 2, tag: "Trampoline exciter" }); // *** Trampoline Foot *** footID = Entities.addEntity({ type: "Sphere", position: Vec3.sum(position, { x: 0, y:groundOffset, z: 0 }), dimensions: { x: 1, y: .05, z: 1 }, color: { red: 255, green: 0, blue: 0 }, dynamic: false, gravity: { x: 0, y: -9.8, z: 0 }, mass: 200, collisionless: false, visible: visibleFoot, lifetime: lifeExpectancy, userData: "{ \"grabbableKey\": { \"grabbable\": false, \"kinematic\": false } }" }); Entities.addAction("tractor", trampolineID, { targetPosition: { x: 0, y:trampolineHeight , z: 0 }, linearTimeScale: .00001, targetRotation: { x: 0, y: 0, z: 0, w: 1 }, angularTimeScale: .00001, otherID: footID, tag: "Foot tractor" }); // ***Sound Trigger box *** // triggerSoundID = Entities.addEntity({ name: "TriggerBox", type: "Box", position: Vec3.sum(position, { x: 0, y: trampolineHeight + triggerSoundOffset, z: 0 }), dimensions: { x: xSize, y: triggerSoundThickness, z: zSize }, color: { red: 0, green: 0, blue: 0 }, dynamic: false, collisionless: true, script: triggerSoundScriptURL, visible: visibleFoot, lifetime: lifeExpectancy, userData: "{ \"grabbableKey\": { \"grabbable\": false, \"kinematic\": false } }" }); } function scriptEnding() { Entities.deleteEntity(trampolineID); Entities.deleteEntity(trampolineID2); Entities.deleteEntity(footID); Entities.deleteEntity(triggerSoundID); } trampoline(); Script.scriptEnding.connect(scriptEnding);