Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created December 11, 2019 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/9142663889293579b2ecdf52b58c8cdc to your computer and use it in GitHub Desktop.
Save flushpot1125/9142663889293579b2ecdf52b58c8cdc to your computer and use it in GitHub Desktop.
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