Is there a very simple script to make an object rotate on it’s own axis please.
And one to make the object rotate on an other objects axis.
I want it kept simple so that I can get a better understanding of the language.

Thanks but I am looking for something more simple that I can understand and expand on. The code on that page has no commenting so it is hard to follow. I always comment my coding because commenting makes is easy to understand what is going on if the code does not work as planned.

I think that is as simple worded as it can get without getting overly complex or optimized with tricks:

Let me comment it for you. (and fix some of it for @Richardus.Raymaker as well since I saw a few places that could have been straightened. (havent tested this that yet, but this is all based on theory, but generally the same concepts apply as in Richardus script.)

//
// Entity-Door.js V0.03M
//
// Created by Richardus Raymaker on 04-09-2015 - Modified / Commented by Menithal -3.7.15
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
(function () {
/*
initial Parameters:
*/
// Angle in degrees at which the doors opens
var doorAngle = 90;
// How long should we take?
var animationTime = 1;
// Is the door open?
var doorIsOpen = false;
// has it stopped moving?
var stopMove = true;
// Storage for ID
var doorEntityID;
// current relative angle
var i = 0;
// Corrective rotations
var pitch = 0.0;
var yaw = 0.0;
var roll = 0.0;
// Function to move the door
function movedoor(deltaTime) {
if (!stopMove) // Are we moving?
{
// deltaTime should be the difference of time from last call of this method:
// current time from last update deltaTime, which consist of a certain % of overall time we want the door to make.
// multiply this with to the target angle, and you have a small angle you can use per frame to meet that target animation Time.
var deltaAngle = (doorAngle * ( deltaTime/animationTime));
// If closed, open, if open, close.
if (!doorIsOpen) {
i = i + deltaAngle;
if(i>=doorAngle) i = doorAngle; // make sure angle never goes more than
} else {
i = i - deltaAngle;
if(i<=0) i = 0; // make sure angle never goes less than
}
// if door is not full open, and is opening OR
// if door is not fully closed, and is closing, continue rotating
if (i <= doorAngle && !doorIsOpen || i >= 0 && doorIsOpen) {
// build a new quaternion from Euler Pitch, Yaw, Roll
rotation = Quat.fromPitchYawRollDegrees(pitch, yaw + i, roll);
// store to a property map
var newProperties =
{
rotation: rotation
};
// Apply rotation change
Entities.editEntity(doorEntityID, newProperties); // set doorId's properties to newProperties
}
else {
// if door angle is larger or equal, then we are technically open and can stop moving.
// we are now in an opposite state.
doorIsOpen = !doorIsOpen;
stopMove = true;
// remove the movedoor method from frame updates.
Script.update.disconnect(movedoor);
}
}
}
// On click on Entity EnitityID
this.clickDownOnEntity = function (entityID, mouseEvent) {
// Make sure we do not accidentally animate the door again after pressing.
if (stopMove) {
doorEntityID = entityID;
// Add movedoor function to frame updates (run every time frame is rendered)
stopMove = false;
Script.update.connect(movedoor);
}
}
})

I think ill write entirely my own version later as theres a few things missing from this, and it script also has the assumption all doors at the same initial rotation and rotation direction…

Thanks I will have to read more.
I do not see Script window of the entity Properties Panel I have used Amazon to host the script but I see no action.
After I reload the Interface stops working
I will have a look at the Planet script and see how that words.
Thanks for the help.

Use the one I have at the top. Kept editing it in quite alot in, and it seems your have the very first version.

I didnt test as was just quickly typing pseudo code. the new one should be more uptodate after reading it over a few times.

again, written entirely by theory (JS Theory) , and I gotta get home to make sure it works, but some who currently has the client loaded up and has more experience in actual working scripts can look at the above and fix it.

As said, earlier ill probably look into writing a proper door script on Sunday which should be adjustable using the custom parameters.
I Finally got home an hour ago from work and actually tested the scripts and fixed the issues.

And yes, It is possible to spin objects . and here is the proof:
Fixed both scripts I posted earlier from work which technically were pseudo code (as i said, I did NOT test them when I first posted the scripts, as was expecting it to give an idea of the direction the scripts should be done,) Now i know better not to post incomplete scripts.

Alternatively, without scripts you can always set an angular velocity to an object if you just want to make something spin, while making sure angular dampening is 0:

As a side note @Richardus.Raymaker the reason it was doing it was due to a logic fault: basically the if clause never completed because it never went to else for both versions. The above version fixes that.

Also @subongo, don’t rely on google for scripts specifically for high fidelity; its better to wait till someone has them solved, or try to dig in your self as of the moment specifically for Hifi: Most conventions are for three.js, and thats where things get a lot more complicated: Similar concepts apply here too though, like with any other 3D scripting:
.
HF is not big enough for there to be any tutorials out there yet.

yes you can
Its already part of the Entity Properties
.>Edit .>Rez a Cube (Box) .> Entity Properties
0-0 see Angular Velocity & Angular Damping fields
0-0 Angular Velocity 3 fields to set rate of spin for xyz
0-0 Angular Damping - slows the spin in decay to zero, 0.5 will slow it quite quickly

Re you ‘googled’ - the problem is, there are lots of .js script for web development but not much for 3D graphics and what there is gets complicated really quickly. This needs to be adressed and Philip did mnetion this at meeting 26th June

ok i’m not a coder but
… here is a snippet i have for spinning a box

// addEntity()_with angular velocity

// create variable - for position in front of your avatar where you want to rez the box
var position = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));