In 3D objects, you have to make all of your objects into a single group for Rotate operation. Once you’ve designed all the mixed objects you’ve designed into a single group, you can do the following:
BABYLON.SceneLoader.Append("/models/scifi_girl_v.01/", “scene.gltf”, scene, function (meshes) {
//This line assigns your master group to a variable.
var model = meshes[0]
//This line gives the main group you create, 90 degrees rotation on the y axis.
model.rotate.y = MATH.PI/2
});
You want another solution? Then you can change the position of the camera and set the target again. So bring the camera in front of the model. Then give the camera the model as the target.
One of these two solutions will help you.
If this isn’t the solution for you, don’t hesitate to report it :")
<script>
var canvas = document.getElementById("renderCanvas"); // Get the canvas element
if(BABYLON.Engine.isSupported()){
var engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D engine
// Create the scene space
var scene = new BABYLON.Scene(engine);
//set black blackground
// scene.color = new BABYLON.Color3.White()
// var skybox = BABYLON.Mesh.CreateBox("skyBox", 100.0, scene);
// var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
// skyboxMaterial.backFaceCulling = false;
// skyboxMaterial.disableLighting = true;
// skybox.material = skyboxMaterial;
// Add a camera to the scene and attach it to the canvas
var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2, new BABYLON.Vector3(0,0,5), scene);
// mouse controls
camera.attachControl(canvas, true);
// Add lights to the scene
var light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), scene); //most realystic ligth
var light2 = new BABYLON.PointLight("light2", new BABYLON.Vector3(0, 1, -1), scene);
BABYLON.SceneLoader.Append("/models/scifi_girl_v.01/", "scene.gltf", scene, function (meshes) {
//This line assigns your master group to a variable.
var model = meshes[0]
//This line gives the main group you create, 90 degrees rotation on the y axis.
model.rotate.y = MATH.PI/2
});
// Register a render loop to repeatedly render the scene
engine.runRenderLoop(function () {
scene.render();
});
// Watch for browser/canvas resize events
window.addEventListener("resize", function () {
engine.resize();
});
} else {
alert("WebGl não suportado")
}