/* globals Script Entities Vec3 */ (function() { var pointA;// = {x: -15.3024, y: -15.1469, z: -11.7448}; var pointB;// = {x: -15.3024, y: -10.5879, z: -11.7448}; var liftOffset = 0.5; var pauseTime = 4; // seconds var MOVE_TIME = 5; var myProps; var goingUp = false; var _entityID; this.preload = function(entityID) { print("HI"); _entityID = entityID; myProps = Entities.getEntityProperties(entityID, ['position', 'rotation', 'dimensions', 'userData']); pointA = myProps.position; pointB = myProps.position; pointB.y += liftOffset; Script.setInterval(function() { movePlatform(goingUp); goingUp = !goingUp; }, (pauseTime + MOVE_TIME) * 1000); }; var movePlatform = function(isGoingUp) { var from = isGoingUp ? pointA : pointB; var to = isGoingUp ? pointB : pointA; var moveTime = MOVE_TIME; var moveDirection = Vec3.subtract(to , from); var moveVelocity = Vec3.multiply(moveDirection, 1 / moveTime); Entities.editEntity(_entityID, { velocity: moveVelocity, position: from, damping: 0 }) Script.setTimeout(function() { Entities.editEntity(_entityID, { velocity: {x: 0, y: 0, z: 0}, position: to }); }, moveTime * 1000); }; //https://hifi-content.s3.amazonaws.com/thoys/production/slidingDoorScript/slidingDoor.js })