JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgithub.com/BabylonJS/Babylon.js/master/babylon.1.11.js"></script>
<canvas id="renderCanvas"></canvas>
<button name="applyParent">applyParent</button>
CSS
html, body, div, canvas {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
overflow: hidden;
}
button {
position: absolute;
top: 10px;
left: 10px;
}
}
JavaScript
var applyParent = function() {
var scene = window.scene;
var parentCube = scene.meshes[0];
var childCube = scene.meshes[1];
childCube.parent = parentCube;
};
$('button[name="applyParent"]').on('click', applyParent);
// Get the Canvas element from our HTML below
var canvas = document.getElementById("renderCanvas");
// Load BABYLON 3D engine
var engine = new BABYLON.Engine(canvas, true);
window.scene = new BABYLON.Scene(engine);
var scene = window.scene;
// Creating a camera looking to the zero point (0,0,0), a light, and a sphere of size 1
var camera = new BABYLON.ArcRotateCamera("Camera", 1, 0.8, 30, new BABYLON.Vector3(0, 0, 0), scene);
var light0 = new BABYLON.PointLight("Omni", new BABYLON.Vector3(0, 0, 10), scene);
/************************************/
var parent = BABYLON.Mesh.CreateBox("Box", 2, scene);
parent.position.x = 1;
parent.position.y = 1;
parent.position.z = 1;
parent.rotation.x = 10;
var child = BABYLON.Mesh.CreateBox("Box2", 2, scene);
child.position.x = 3;
child.position.y = 3;
child.position.z = 3;
/***********************************/
// Attach the camera to the scene
scene.activeCamera.attachControl(canvas);
// Once the scene is loaded, just register a render loop to render it
engine.runRenderLoop(function () {
scene.render();
});