Make camera fix and 3d turn around himself

good evening everyone, I have a little problem with the poisitioning of the camera and the loaded scene, I would like to know how to fix the camera and rotate the object on itself here is the code that I use thank you.


ps: im building a configurator with babylonjs and angular

to be more precise I want to click or drag with the mouse and turn the shirt to one side or the other
neither up nor down and the camera doesn’t move.
knowing that I’m loading a scene that contains abstractmesch and not mesch.

You can add this code to only be able to rotate around the object:

    camera.lowerBetaLimit = camera.beta;
    camera.upperBetaLimit = camera.beta;
    camera.lowerRadiusLimit = camera.radius;
    camera.upperRadiusLimit = camera.radius;

it didn’t work Evgeni_Popov

It works for me here:

https://playground.babylonjs.com/#J67M1I

I can only rotate around the scene.

1 Like

I saw that it worked for you and I thank you for your answer, but in my case it doesn’t work , maybe because of the babylon that I’m loading, I don’t know


when i use
this.scene.createDefaultCamera(true,true,true)
the camera moves, and the scene rotates but not on itself .

He wants to spin the mesh not the camera I think.

If that is the case, you need to not attach camera controls, and interpolate the mouse input into inertia values on the mesh through a system of your own device.

This will remove the upper and lower limits you set previously, so I wouldn’t do that.

Can you try reproducing that on the playground? copy your code and make it work (or not work :slight_smile: ) the same as in your code, so we can understand what’s the problem. I have a feeling we are not seeing the entire code that can affect the scene’s camera

2 Likes

sorry I don’t know how to append my .babylon scene to the playground but this is my code,
when I append the scene
the object appears upside down,


but it rotate on itself (and the camera is not fixed).
when I did
this.scene.meshes.forEach(element => {
element.rotation.y = Math.PI
element.position.x = -180.0;
element.position.z = -70;
element.material = textures
});
} catch (err) {
console.log(‘error!’, err)
}
to put it back in place the object does not turn on itself anymore
this is why im trying to fix the camera and turn the meshs on them self

How to use external assets in the PG: Using External Assets - Babylon.js Documentation

1 Like

https://www.babylonjs-playground.com/#IX12S2#13
this is my pg , i use the rotation and translate to turn the object in the invers postion because it load upside down , thnx

Here it is:

https://www.babylonjs-playground.com/#IX12S2#14

You should rotate the shirt around an axis that passes through it, as it is not modeled so that the (0,0,0) coordinate of its local space is at the center of the shirt (it would be easier if it is).

2 Likes

Thank you, it works, but I had to comment.
scene.activecamera = camera
because it gave me this error
Type ‘Camera’ is missing the following properties from type ‘ArcRotateCamera’: alpha, beta, radius, _target, and 111 more.ts(2740)

i would like to know how to zoom also on the object without lossing the rotation around the axe beside the error of
scene.activecamera = camera
Type ‘Camera’ is missing the following properties from type ‘ArcRotateCamera’: alpha, beta, radius, _target, and 111 more.ts(2740)
thank you ,and I’m sorry for the inconvenience.

You are in typescript, you should do:

this.camera1 = this.scene.activeCamera as BABYLON.ArcRotateCamera;

To be able to zoom, just comment out:

      //camera.lowerRadiusLimit = camera.radius;
      //camera.upperRadiusLimit = camera.radius;
1 Like

Thank you all so much for helping me and especially you. Evgeni_Popov :smiley:

2 Likes