浏览代码

add localDev environment

sevan 8 年之前
父节点
当前提交
a6497ffe92
共有 5 个文件被更改,包括 1555 次插入1426 次删除
  1. 9 0
      .vscode/launch.json
  2. 1426 1426
      dist/preview release/babylon.d.ts
  3. 1 0
      localDev/.gitignore
  4. 85 0
      localDev/index.html
  5. 34 0
      localDev/template/index.js

+ 9 - 0
.vscode/launch.json

@@ -36,6 +36,15 @@
             "webRoot": "${workspaceRoot}/",
             "sourceMaps": true,
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug"
+        },
+        {
+            "name": "Launch Local Dev (Chrome)",
+            "type": "chrome",
+            "request": "launch",
+            "url": "http://localhost:1338/localDev/index.html",
+            "webRoot": "${workspaceRoot}/",
+            "sourceMaps": true,
+            "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug"
         }
     ]
 }

文件差异内容过多而无法显示
+ 1426 - 1426
dist/preview release/babylon.d.ts


+ 1 - 0
localDev/.gitignore

@@ -0,0 +1 @@
+src/**/*

+ 85 - 0
localDev/index.html

@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>Local Development</title>
+	<script src="../assets/refs/dat.gui.min.js"></script>
+	<script src="../tools/DevLoader/BabylonLoader.js"></script>
+
+	<style>
+		html, body {
+			width: 100%;
+			height: 100%;
+			padding: 0;
+			margin: 0;
+			overflow: hidden;
+		}
+
+		#renderCanvas {
+			width: 100%;
+			height: 100%;
+		}
+
+		#fps {
+			position: absolute;
+			background-color: black;
+			border: 2px solid red;
+			text-align: center;
+			font-size: 16px;
+			color: white;
+			top: 15px;
+			left: 10px;
+			width: 60px;
+			height: 20px;
+		}
+	</style>
+</head>
+<body>
+	<div id="fps">0</div>
+	<canvas id="renderCanvas"></canvas>
+	
+	<script>
+		var canvas = document.getElementById("renderCanvas");
+		var divFps = document.getElementById("fps");
+
+		// Global to simulate PG.
+		var engine = null;
+
+		// Allow querystring to navigate easily in debug in local samples.
+		var indexjs = 'src/index';
+		var sampleSearch = /sample=([0-9]+)/i;
+		var matches = null;
+		if ((matches = sampleSearch.exec(window.location)) !== null) {			
+			indexjs += '.';
+			indexjs += matches[1];
+		}
+		indexjs += '.js';
+
+		// Load the scripts + map file to allow vscode debug.
+		BABYLONDEVTOOLS.Loader
+			.require(indexjs)
+			.load(function() {
+				if (BABYLON.Engine.isSupported()) {
+					engine = new BABYLON.Engine(canvas, true);				
+
+					// call the scene creation from the js.
+					var scene = createScene();
+
+					// Register a render loop to repeatedly render the scene
+					engine.runRenderLoop(function () {
+						scene.render();
+						divFps.innerHTML = engine.getFps().toFixed() + " fps";
+					});
+
+					// Resize
+					window.addEventListener("resize", function () {
+						engine.resize();
+					});
+					
+				}
+				else {
+					alert('BabylonJS is not supported.')
+				}
+			});
+	</script>
+</body>
+</html>

+ 34 - 0
localDev/template/index.js

@@ -0,0 +1,34 @@
+/// <reference path="../../dist/preview release/babylon.d.ts"/>
+
+// Playground like creation of the scene
+var createScene = function () {
+
+    // This creates a basic Babylon Scene object (non-mesh)
+    var scene = new BABYLON.Scene(engine);
+
+    // This creates and positions a free camera (non-mesh)
+    var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
+
+    // This targets the camera to scene origin
+    camera.setTarget(BABYLON.Vector3.Zero());
+
+    // This attaches the camera to the canvas
+    camera.attachControl(canvas, true);
+
+    // This creates a light, aiming 0,1,0 - to the sky (non-mesh)
+    var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
+
+    // Default intensity is 1. Let's dim the light a small amount
+    light.intensity = 0.7;
+
+    // Our built-in 'sphere' shape. Params: name, subdivs, size, scene
+    var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);
+
+    // Move the sphere upward 1/2 its height
+    sphere.position.y = 1;
+
+    // Our built-in 'ground' shape. Params: name, width, depth, subdivs, scene
+    var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);
+
+    return scene;
+};