Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
define({
inputs: {
scriptLoaded: "string",
domElement: "domelement",
filePath:"string",
fileName:"string",
scale:"string"
},
outputs: {
},
destroy: function(inputs, outputs) {
},
setup: function(inputs, outputs) {
},
run: function(inputs, outputs, changedInputs) {
if (!inputs.scriptLoaded) {
return;
}
var canvas = document.getElementById("canvas");
var engine = new BABYLON.Engine(canvas, true);
var createScene = function () {
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, new BABYLON.Vector3(0, 0, 0), scene);
camera.setPosition(new BABYLON.Vector3(0, 0, 7));
camera.attachControl(canvas, true);
var light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), scene);
var light2 = new BABYLON.PointLight("light2", new BABYLON.Vector3(0, 1, -1), scene);
BABYLON.SceneLoader.ImportMeshAsync("", inputs.filePath, inputs.fileName, scene).then(function(result) {
result.meshes[0].position = new BABYLON.Vector3(0, 0, 0);
result.meshes[0].scaling = new BABYLON.Vector3(inputs.scale,inputs.scale,inputs.scale);
});
return scene;
};
var scene = createScene();
engine.runRenderLoop(function () {
scene.render();
});
window.addEventListener("resize", function () {
engine.resize();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment