I want to scale a gltf model I have . Here is the code I have :
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.babylonjs.com/babylon.js"></script>
<script src="https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>
<script src="https://code.jquery.com/pep/0.4.3/pep.js"></script>
<script src="https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>
<style>
#renderCanvas {
width: 100%;
height: 100%;
touch-action: none;
}
</style>
</head>
<body>
<canvas id="renderCanvas" touch-action="none"></canvas>
<script type="text/javascript">
const canvas = document.getElementById("renderCanvas"); /*Get the canvas element*/
const engine = new BABYLON.Engine(canvas, true); /*Generate the BABYLON 3D engine*/
let render = true
const createScene = function () {
const scene = new BABYLON.Scene(engine);
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.5, 15, new BABYLON.Vector3(0, 0, 0));
camera.attachControl(canvas, true);
BABYLON.MeshBuilder.CreateBox("box",{})
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(1, 1, 0));
BABYLON.SceneLoader.Append("./city_scene_tokyo/", "scene.gltf", scene);
return scene;
};
const scene = createScene(); /*Call the createScene function*/
/* Register a render loop to repeatedly render the scene*/
engine.runRenderLoop(function () {
if (render) {
scene.render();
}
});
/*Watch for browser/canvas resize events*/
window.addEventListener("resize", function () {
engine.resize();
});
</script>
</body>
</html>
Here’s what I tried:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.babylonjs.com/babylon.js"></script>
<script src="https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>
<script src="https://code.jquery.com/pep/0.4.3/pep.js"></script>
<script src="https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>
<style>
#renderCanvas {
width: 100%;
height: 100%;
touch-action: none;
}
</style>
</head>
<body>
<canvas id="renderCanvas" touch-action="none"></canvas>
<script type="text/javascript">
const canvas = document.getElementById("renderCanvas"); /*Get the canvas element*/
const engine = new BABYLON.Engine(canvas, true); /*Generate the BABYLON 3D engine*/
let render = true
/*Add your code here matching the playground format*/
const createScene = function () {
const scene = new BABYLON.Scene(engine);
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.5, 15, new BABYLON.Vector3(0, 0, 0));
camera.attachControl(canvas, true);
BABYLON.MeshBuilder.CreateBox("box",{})
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(1, 1, 0));
let city = BABYLON.SceneLoader.Append("./city_scene_tokyo/", "scene.gltf", scene);
city.scaling = new BABYLON.Vector3(0.1,0.1,0.1)
return scene;
};
const scene = createScene(); /*Call the createScene function*/
/* Register a render loop to repeatedly render the scene*/
engine.runRenderLoop(function () {
if (render) {
scene.render();
}
});
/*Watch for browser/canvas resize events*/
window.addEventListener("resize", function () {
engine.resize();
});
</script>
</body>
</html>