| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Local Development</title>
-
- <script src="https://babylonjs.azurewebsites.net/babylon.js"></script>
- <style>
- html, body {
- width: 100%;
- height: 100%;
- padding: 0;
- margin: 0;
- overflow: hidden;
- }
-
- #renderCanvas {
- width: 100%;
- height: 100%;
- }
- </style>
- </head>
- <body>
- <canvas id="renderCanvas"></canvas>
-
- <script>
- var canvas = document.getElementById("renderCanvas");
- var engine = new BABYLON.Engine(canvas, true, { stencil: false, audioEngine: false });
- engine.preventCacheWipeBetweenFrames = true;
- BABYLON.PerfCounter.Enabled = false;
-
- BABYLON.SceneLoader.ShowLoadingScreen = false;
-
- BABYLON.SceneLoader.Load("./", "cortana.babylon", engine, function(scene) {
-
- // Replace camera by a arcRotate to be able to rotate around Cortana
- var newCamera = new BABYLON.ArcRotateCamera("camera1", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
- // newCamera.attachControl(canvas, false); // Attach mouse control to be able to move around
- newCamera.setPosition(new BABYLON.Vector3(0, 2, -4));
-
- scene.activeCamera = newCamera;
-
- // Update materials (they are pretty good actually only alpha is missing)
- for (var index = 0; index < scene.materials.length; index++) {
- scene.materials[index].diffuseTexture.hasAlpha = true;
- scene.materials[index].useAlphaFromDiffuseTexture = true;
- scene.materials[index].alpha = 0.5;
- // Freezing materials
- scene.materials[index].freeze();
- }
-
- var mesh = scene.getMeshByName("Inner1");
- mesh.scaling = new BABYLON.Vector3(0.6, 0.6, 0.6);
- mesh = scene.getMeshByName("Inner2");
- mesh.scaling = new BABYLON.Vector3(0.6, 0.6, 0.6);
- mesh = scene.getMeshByName("Inner3");
- mesh.scaling = new BABYLON.Vector3(0.6, 0.6, 0.6);
- for (var index = 0; index < scene.meshes.length; index++) {
- // Avoid frustum clipping. No needed here as objects are always visible
- scene.meshes[index].alwaysSelectAsActiveMesh = true;
- }
-
- // Find root object
- var innerSphere = scene.getMeshByName("InnerSphereHolder");
- var outerSphere = scene.getMeshByName("OuterSphereHolder");
- // Set clear color to black (it is white by default)
- scene.clearColor = BABYLON.Color3.Black();
-
- // Register a render loop to repeatedly render the scene
- engine.runRenderLoop(function () {
- scene.render();
-
- // Do a bit of self-rotation
- innerSphere.rotation.y += 0.01;
- outerSphere.rotation.y -= 0.01;
- });
- });
-
- // Resize
- window.addEventListener("resize", function () {
- engine.resize();
- });
- </script>
- </body>
- </html>
|