Created
December 11, 2019 10:24
-
-
Save flushpot1125/9142663889293579b2ecdf52b58c8cdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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