Skip to content
Snippets Groups Projects

Create dancing_light_box.js

1 file
+ 44
0
Compare changes
  • Side-by-side
  • Inline
+ 44
0
(function(){
var lightID = "{d4e37d71-b6e4-425d-ab2b-673f09fb1339}"
var minX = -110;
var maxX = -70;
var yDeg = 0;
var minZ = -20;
var maxZ = 20;
// Aktualisiert die Rotation der Lichtquelle
function setRotation() {
//Zufälliger Winkel
const rangeX = maxX - minX;
const randomNumberInRangeX = Math.random() * rangeX;
const randomNumberBetweenX = randomNumberInRangeX + minX;
const rangeZ = maxZ - minZ;
const randomNumberInRangeZ = Math.random() * rangeZ;
const randomNumberBetweenZ = randomNumberInRangeZ + minZ;
// Konvertieren Grad in Radiant
const xRad = (randomNumberBetweenX / 180) * Math.PI;
const yRad = (yDeg / 180) * Math.PI;
const zRad = (randomNumberBetweenZ / 180) * Math.PI;
// Die Entity mit der gegebenen ID finden
const entity = Entities.getEntityProperties(lightID);
// Die aktuelle Rotation der Entity abrufen
const currentRotation = entity.rotation;
// Die neue Rotation berechnen
const newRotation = Quat.fromPitchYawRollRadians(xRad, yRad, zRad);
// Die neue Rotation auf die Entity setzen
Entities.editEntity(lightID, { rotation: newRotation });
}
this.enterEntity = function(entityID) {
Script.setInterval(setRotation, 500);
};
});
\ No newline at end of file
Loading