[SOLVED] Camera rotation around object

Ok, here is a script that can do that. Attach it on a camera that uses the orbit-camera.js script:

var CameraAutoRotate = pc.createScript('cameraAutoRotate');

CameraAutoRotate.attributes.add('speed', {
    type: 'number',
    default: 1,
    title: 'Speed',
    description: 'The rotate speed of camera.'
});

// initialize code called once per entity
CameraAutoRotate.prototype.initialize = function() {
    this.orbitCamera = this.entity.script.orbitCamera;
};

// update code called every frame
CameraAutoRotate.prototype.update = function(dt) {

    this.orbitCamera.yaw += this.speed * dt;
};
2 Likes