123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- var BABYLON = require("../../dist/preview release/babylon.max");
- var LOADERS = require("../../dist/preview release/loaders/babylonjs.loaders");
- global.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
- var engine = new BABYLON.NullEngine();
- var scene = new BABYLON.Scene(engine);
- // //Create a light
- // var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(-60, 60, 80), scene);
- // //Create an Arc Rotate Camera - aimed negative z this time
- // var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, 1.0, 110, BABYLON.Vector3.Zero(), scene);
- // //Creation of 6 spheres
- // var sphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 10.0, 9.0, scene);
- // var sphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 2.0, 9.0, scene);//Only two segments
- // var sphere3 = BABYLON.Mesh.CreateSphere("Sphere3", 10.0, 9.0, scene);
- // var sphere4 = BABYLON.Mesh.CreateSphere("Sphere4", 10.0, 9.0, scene);
- // var sphere5 = BABYLON.Mesh.CreateSphere("Sphere5", 10.0, 9.0, scene);
- // var sphere6 = BABYLON.Mesh.CreateSphere("Sphere6", 10.0, 9.0, scene);
- // //Position the spheres
- // sphere1.position.x = 40;
- // sphere2.position.x = 25;
- // sphere3.position.x = 10;
- // sphere4.position.x = -5;
- // sphere5.position.x = -20;
- // sphere6.position.x = -35;
- // //Creation of a plane
- // var plane = BABYLON.Mesh.CreatePlane("plane", 120, scene);
- // plane.position.y = -5;
- // plane.rotation.x = Math.PI / 2;
- // //Creation of a material with wireFrame
- // var materialSphere1 = new BABYLON.StandardMaterial("texture1", scene);
- // materialSphere1.wireframe = true;
- // //Creation of a red material with alpha
- // var materialSphere2 = new BABYLON.StandardMaterial("texture2", scene);
- // materialSphere2.diffuseColor = new BABYLON.Color3(1, 0, 0); //Red
- // materialSphere2.alpha = 0.3;
- // //Creation of a material with an image texture
- // var materialSphere3 = new BABYLON.StandardMaterial("texture3", scene);
- // materialSphere3.diffuseTexture = new BABYLON.Texture("textures/misc.jpg", scene);
- // //Creation of a material with translated texture
- // var materialSphere4 = new BABYLON.StandardMaterial("texture4", scene);
- // materialSphere4.diffuseTexture = new BABYLON.Texture("textures/misc.jpg", scene);
- // materialSphere4.diffuseTexture.vOffset = 0.1;//Vertical offset of 10%
- // materialSphere4.diffuseTexture.uOffset = 0.4;//Horizontal offset of 40%
- // //Creation of a material with an alpha texture
- // var materialSphere5 = new BABYLON.StandardMaterial("texture5", scene);
- // materialSphere5.diffuseTexture = new BABYLON.Texture("textures/tree.png", scene);
- // materialSphere5.diffuseTexture.hasAlpha = true;//Has an alpha
- // //Creation of a material and show all the faces
- // var materialSphere6 = new BABYLON.StandardMaterial("texture6", scene);
- // materialSphere6.diffuseTexture = new BABYLON.Texture("textures/tree.png", scene);
- // materialSphere6.diffuseTexture.hasAlpha = true;//Have an alpha
- // materialSphere6.backFaceCulling = false;//Show all the faces of the element
- // //Creation of a repeated textured material
- // var materialPlane = new BABYLON.StandardMaterial("texturePlane", scene);
- // materialPlane.diffuseTexture = new BABYLON.Texture("textures/grass.jpg", scene);
- // materialPlane.diffuseTexture.uScale = 5.0;//Repeat 5 times on the Vertical Axes
- // materialPlane.diffuseTexture.vScale = 5.0;//Repeat 5 times on the Horizontal Axes
- // materialPlane.backFaceCulling = false;//Always show the front and the back of an element
- // //Apply the materials to meshes
- // sphere1.material = materialSphere1;
- // sphere2.material = materialSphere2;
- // sphere3.material = materialSphere3;
- // sphere4.material = materialSphere4;
- // sphere5.material = materialSphere5;
- // sphere6.material = materialSphere6;
- // plane.material = materialPlane;
- //Adding a light
- var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);
- //Adding an Arc Rotate Camera
- var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene);
- // The first parameter can be used to specify which mesh to import. Here we import all meshes
- BABYLON.SceneLoader.ImportMesh("", "https://playground.babylonjs.com/scenes/", "skull.babylon", scene, function (newMeshes) {
- // Set the target of the camera to the first imported mesh
- camera.target = newMeshes[0];
- console.log("Meshes loaded from babylon file: " + newMeshes.length);
- for (var index = 0; index < newMeshes.length; index++) {
- console.log(newMeshes[index].toString());
- }
- BABYLON.SceneLoader.ImportMesh("", "https://www.babylonjs.com/Assets/DamagedHelmet/glTF/", "DamagedHelmet.gltf", scene, function (meshes) {
- console.log("Meshes loaded from gltf file: " + meshes.length);
- for (var index = 0; index < meshes.length; index++) {
- console.log(meshes[index].toString());
- }
- });
- console.log("render started")
- engine.runRenderLoop(function() {
- scene.render();
- })
- });
-
|