[SOLVED] Camera rotation around object

Hello all,

I`v have been doing research in which I figured out that I cant to find samples in which built camera which rotating around some object but also works as simple OrbitCamera, if someone has some similar samples pls could you share wih me,

Thanks all for attnetion,


HI Ivan,

Not sure I understand what you mean by a built camera which rotates around objects. The orbit-camera scripts that come with the model viewer can rotate around a focus entity.

Do you have an example of what you are looking for?


this is those sample,

Camera rotating around ring independently and also works as simple Orbitcamera,

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;


Yes, it works!!! =)