content/hifi-content/elisalj/music_visualizer/outdated_scripts/effectTrailerLeft.js
2022-02-13 23:16:46 +01:00

55 lines
No EOL
1.6 KiB
JavaScript

//
// effectTrailerRight.js
// An entity script to track right trigger holds to create trails in a particle effect
//
// Author: Elisa Lupin-Jimenez
// Copyright High Fidelity 2017
//
// Licensed under the Apache 2.0 License
// See accompanying license file or http://apache.org/
//
// All assets are under CC Attribution Non-Commerical
// http://creativecommons.org/licenses/
//
(function() {
var _this = this;
_this.preload = function(entityID) {
print("Right trailer script has loaded");
_this.entityID = entityID;
};
// The name of the new mapping
var MAPPING_NAME = "com.highfidelity.controllers.example.triggerExample";
// Create a new mapping object
var mapping = Controller.newMapping(MAPPING_NAME);
var oldPressStrength = 0;
var pressStrength = 0;
mapping.from(Controller.Standard.LT).to(function(value) {
var props = Entities.getEntityProperties(_this.entityID, 'isEmitting');
pressStrength = value;
if (pressStrength < 0.01 && oldPressStrength >= 0.01) {
props.isEmitting = false;
Entities.editEntity(_this.entityID, props);
}
if (pressStrength >= 0.01 && oldPressStrength < 0.01) {
props.isEmitting = true;
Entities.editEntity(_this.entityID, props);
}
oldPressStrength = pressStrength;
});
Controller.enableMapping(MAPPING_NAME);
// Disable the new mapping when the script ends
Script.scriptEnding.connect(function () {
Controller.disableMapping(MAPPING_NAME);
});
});