content/hifi-content/caitlyn/dev/Scripts/entityRotation.js
2022-02-13 22:19:19 +01:00

33 lines
No EOL
760 B
JavaScript

var orientation = Camera.getOrientation();
orientation = Quat.safeEulerAngles(orientation);
orientation.x = 0;
orientation = Quat.fromVec3Degrees(orientation);
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
var rotatingBox = Entities.addEntity({
type: "Box",
position: center,
dimensions: {
x: 1,
y: 1,
z: 1
},
color: {
red: 200,
green: 10,
blue: 200
},
angularVelocity: {
x: 0,
y: 0.1,
z: 0
},
angularDamping: 0
});
function cleanup() {
Entities.deleteEntity(rotatingBox);
}
Script.scriptEnding.connect(cleanup);