Hello
I developed a website with babylon.js.
But I encountered a very wired error.
I load model via gltf loader and set position and rotation for them.
but when I get into my website, I get different result of these models’ transformation
This is what I need:
Imgur
But if I fresh the page f5 or hard fresh it with ctrl + f5
I get this:
Imgur
or some other situations.(sry, as new user in this forum I can only put one pic or two links)
I use some code like this to load models
const boxMix = require('../ult/ult.js').boxMix
module.exports = function(scene) {
window.BABYLON.SceneLoader.ImportMeshAsync(null, "assets/model/", "arcade.glb", scene)
.then((result) => {
//add loading progress
window.loadingFresh(10)
let parent = new window.BABYLON.Mesh("arcade", scene);
result.meshes.forEach((element) => {
if(element.id === '__root__') {
element.dispose(true, true)
}
element.setParent(parent)
});
boxMix(parent);
parent.scaling.x = 130;
parent.scaling.y = 130;
parent.scaling.z = 130;
parent.position.x = 700;
parent.position.z = 100;
parent.position.y = 120;
parent.rotation.y = (-1 * Math.PI / 4)
})
}
and the boxMix code:
let boxMix = function (parent) {
let childMeshes = parent.getChildMeshes();
let min, max
if (childMeshes.length > 0) {
min = childMeshes[0].getBoundingInfo().boundingBox.minimumWorld;
max = childMeshes[0].getBoundingInfo().boundingBox.maximumWorld;
}
childMeshes.forEach((it, idx) => {
let meshMin = it.getBoundingInfo().boundingBox.minimumWorld;
let meshMax = it.getBoundingInfo().boundingBox.maximumWorld;
min = window.BABYLON.Vector3.Minimize(min, meshMin);
max = window.BABYLON.Vector3.Maximize(max, meshMax);
})
parent.setBoundingInfo(new window.BABYLON.BoundingInfo(min, max));
//set pivot to center of the boundingBox
parent.setPivotPoint(window.BABYLON.Vector3.Center(min, max))
}
use parent mesh and boxMix func to fix some pivot problem in models
I’m pretty new with 3d and babylon
Did I do sometime wrong ?
How should I do to fix this issue?